function changePassword() {
    // Change the admin password
    // ...

    alert("Password changed successfully.");
    return false;
}

function viewClients() {
    // Retrieve and display the list of clients
    // ...

    // Dummy response for demonstration purposes
    var clients = "<h2>Clients List</h2>" +
        "<ul>" +
        "<li>Client 1</li>" +
        "<li>Client 2</li>" +
        "<li>Client 3</li>" +
        "</ul>";

    document.getElementById("output").innerHTML = clients;
}

function createClient() {
    // Redirect to the create client page
    window.location.href = "create_client.php";
}

function searchTracking() {
    var trackingNumber = document.getElementById("trackingNumber").value;

    // Perform the tracking search
    // Example code to retrieve client details based on tracking number
    /*// Perform the database query to retrieve client details
    // ...

    // Build the client details HTML dynamically based on the retrieved data
    // ...

    // Display the client details
    // ...

    // Dummy response for demonstration purposes
    var clientDetails = "<h2>Client Details</h2>" +
        "<p>Tracking Number: " + trackingNumber + "</p>" +
        "<p>Sender Name: John Doe</p>" +
        "<p>Sender Location: New York</p>" +
        "<p>Sender Phone: 123-456-7890</p>" +
        "<p>Receiver Name: Jane Smith</p>" +
        "<p>Receiver Location: Los Angeles</p>" +
        "<p>Receiver Phone: 987-654-3210</p>" +
        "<p>Package Weight: 5 kg</p>" +
        "<p>Delivery Amount: $50</p>" +
        "<p>Date Sent: 2023-06-20</p>" +
        "<p>Arrival Date: 2023-06-25</p>";

    document.getElementById("clientDetails").innerHTML = clientDetails;*/
}



function searchTracking() {
    var trackingNumber = document.getElementById("trackingNumber").value;

    // Perform the tracking search
    var xhr = new XMLHttpRequest();
    var url = 'search_tracking.php';
    var params = 'trackingNumber=' + trackingNumber;

    xhr.open('POST', url, true);
    xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');

    xhr.onreadystatechange = function() {
        if (xhr.readyState === XMLHttpRequest.DONE) {
            if (xhr.status === 200) {
                var response = JSON.parse(xhr.responseText);

                if (response.success) {
                    document.getElementById("clientDetails").innerHTML = response.clientDetails;
                } else {
                    document.getElementById("clientDetails").innerHTML = "<p>" + response.message + "</p>";
                }
            } else {
                console.log('Error: ' + xhr.status);
            }
        }
    };

    xhr.send(params);
}
