<?php
include_once 'shikanisha.kts.php';

// Initialize the response array
$response = array('success' => false, 'message' => 'Error processing payment');

// Get the data from the AJAX request
$phone = $_POST['loanid'];
$salary = $_POST['pay_amount'];
$method = $_POST['pay_method'];
$purpose = $_POST['purpose'];
$date = date('Y-m-d');

// Insert the data into the database
$sql = "INSERT INTO `employee_salary`(`phone_number`, `salary`, `salary_date`, `method`, `purpose`)
        VALUES ('$phone', '$salary', '$date', '$method', '$purpose')";

if ($conn->query($sql) === TRUE) {
    // If the query was successful, update the response
    $response['success'] = true;
    $response['message'] = 'Employee Payment Made Successfully';
} else {
    // If there was an error, the default response message will be used
    $response['error'] = $conn->error;
}

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