<?php
header('content-type:application/json');
include($_SERVER['DOCUMENT_ROOT'] . "/API-Others/connection/conn.php");

$year = $_GET["year"];
$month = $_GET["month"];
$query1 = mysqli_query($conn, "SELECT *,salary_wage_information AS BasicSalary FROM staff");
$staff_list_payroll = array();
while ($spec1 = mysqli_fetch_assoc($query1)) {
    $query = mysqli_query($conn, "SELECT * FROM payroll WHERE unique_user_id = '" . $spec1["unique_user_id"] . "' AND Year = '$year' AND Month = '$month'");
    $affected_row = mysqli_affected_rows($conn);
    if ($affected_row > 0) {
        while ($spec = mysqli_fetch_assoc($query)) {
            $staff_list_payroll[] =  $spec;
        }
    } else {

        $staff_list_payroll[] =  $spec1;
    }
}





$statusCode = 200;
$statusMessage = "Signed In Successfully";

$resultData = array('code' => $statusCode, 'message' => $statusMessage, 'staff_list_payroll' => $staff_list_payroll);
echo json_encode($resultData);
