<?php
// Include your database connection code here, and ensure $conn is defined.
include_once 'shikanisha.kts.php';

$response = array();

// Check if salaryId is set
if (isset($_GET['salaryId'])) {
    $salaryId = $_GET['salaryId'];

    // Execute the SQL query to fetch salary details for the specified ID
    $sql = "SELECT `salary_id`, `phone_number`, `salary`, `salary_date`, `method`, `purpose` FROM `employee_salary` WHERE `salary_id` = $salaryId";
    $result = mysqli_query($conn, $sql);

    if ($result) {
        $salaryDetails = mysqli_fetch_assoc($result);

        if ($salaryDetails) {
            $response['success'] = true;
            $response['salaryDetails'] = $salaryDetails;
        } else {
            $response['success'] = false;
            $response['message'] = 'Salary details not found.';
        }
    } else {
        $response['success'] = false;
        $response['message'] = 'Error executing the SQL query.';
    }
} else {
    $response['success'] = false;
    $response['message'] = 'Salary ID not provided.';
}

// Return the response as JSON
header('Content-type: application/json');
echo json_encode($response);
?>
