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

$response = array();

// Check if form data is set
if (isset($_POST['salaryId'], $_POST['salary'], $_POST['salaryDate'], $_POST['method'], $_POST['purpose'])) {
    $salaryId = $_POST['salaryId'];
    $salary = $_POST['salary'];
    $salaryDate = $_POST['salaryDate'];
    $method = $_POST['method'];
    $purpose = $_POST['purpose'];

    // Execute the SQL query to update salary details
    $sql = "UPDATE `employee_salary` SET `salary` = '$salary', `salary_date` = '$salaryDate', `method` = '$method', `purpose` = '$purpose' WHERE `salary_id` = $salaryId";
    $result = mysqli_query($conn, $sql);

    if ($result) {
        $response['success'] = true;
    } else {
        $response['success'] = false;
        $response['message'] = 'Error executing the SQL query.';
    }
} else {
    $response['success'] = false;
    $response['message'] = 'Form data not provided.';
}

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