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

$query = mysqli_query($conn, "SELECT * FROM stockwarehouses WHERE id = '1'");
while ($spec = mysqli_fetch_assoc($query)) {
    $warehouseName1 =  $spec["warehouse"];
    $warehouseQty1 =  $spec["quantity"];
}

$query = mysqli_query($conn, "SELECT * FROM stockwarehouses WHERE id = '2'");
while ($spec = mysqli_fetch_assoc($query)) {
    $warehouseName2 =  $spec["warehouse"];
    $warehouseQty2 =  $spec["quantity"];
}

$query = mysqli_query($conn, "SELECT * FROM stockwarehouses WHERE id = '3'");
while ($spec = mysqli_fetch_assoc($query)) {
    $warehouseName3 =  $spec["warehouse"];
    $warehouseQty3 =  $spec["quantity"];
}

$query = mysqli_query($conn, "SELECT * FROM stockwarehouses WHERE id = '4'");
while ($spec = mysqli_fetch_assoc($query)) {
    $warehouseName4 =  $spec["warehouse"];
    $warehouseQty4 =  $spec["quantity"];
}

$query = mysqli_query($conn, "SELECT * FROM stockwarehouses WHERE id = '5'");
while ($spec = mysqli_fetch_assoc($query)) {
    $warehouseName5 =  $spec["warehouse"];
    $warehouseQty5 =  $spec["quantity"];
}

$query = mysqli_query($conn, "SELECT * FROM stockwarehouses WHERE id = '6'");
while ($spec = mysqli_fetch_assoc($query)) {
    $warehouseName6 =  $spec["warehouse"];
    $warehouseQty6 =  $spec["quantity"];
}

$query = mysqli_query($conn, "SELECT * FROM stockwarehouses WHERE id = '7'");
while ($spec = mysqli_fetch_assoc($query)) {
    $warehouseName7 =  $spec["warehouse"];
    $warehouseQty7 =  $spec["quantity"];
}

$query = mysqli_query($conn, "SELECT * FROM stockwarehouses WHERE id = '8'");
while ($spec = mysqli_fetch_assoc($query)) {
    $warehouseName8 =  $spec["warehouse"];
    $warehouseQty8 =  $spec["quantity"];
}

$query = mysqli_query($conn, "SELECT * FROM stockwarehouses WHERE id = '9'");
while ($spec = mysqli_fetch_assoc($query)) {
    $warehouseName9 =  $spec["warehouse"];
    $warehouseQty9 =  $spec["quantity"];
}

$query = mysqli_query($conn, "SELECT * FROM stockwarehouses WHERE id = '10'");
while ($spec = mysqli_fetch_assoc($query)) {
    $warehouseName10 =  $spec["warehouse"];
    $warehouseQty10 =  $spec["quantity"];
}

$query = mysqli_query($conn, "SELECT * FROM stockwarehouses WHERE id = '11'");
while ($spec = mysqli_fetch_assoc($query)) {
    $warehouseName11 =  $spec["warehouse"];
    $warehouseQty11 =  $spec["quantity"];
}















// $query = mysqli_query($conn, "SELECT COUNT(*) AS TOTAL FROM candidates WHERE worker_type = 'Skilled/Unskilled' AND status = 'Travel Documents' $nationality");
// while ($spec = mysqli_fetch_assoc($query)) {
//     $skilled_unskilled_travel_documents =  $spec["TOTAL"];
// }

// $query = mysqli_query($conn, "SELECT COUNT(*) AS TOTAL FROM candidates WHERE worker_type = 'Skilled/Unskilled' AND status = 'Ready To Be Deployed' $nationality");
// while ($spec = mysqli_fetch_assoc($query)) {
//     $skilled_unskilled_ready_to_be_deployed =  $spec["TOTAL"];
// }

// $query = mysqli_query($conn, "SELECT COUNT(*) AS TOTAL FROM candidates WHERE worker_type = 'Skilled/Unskilled' AND status = 'Currently Deployed' $nationality");
// while ($spec = mysqli_fetch_assoc($query)) {
//     $skilled_unskilled_currently_deployed =  $spec["TOTAL"];
// }

// $query = mysqli_query($conn, "SELECT COUNT(*) AS TOTAL FROM candidates WHERE worker_type = 'Masters Degree Workers' $nationality");
// while ($spec = mysqli_fetch_assoc($query)) {
//     $masters_degree_total_candidates =  $spec["TOTAL"];
// }

// $query = mysqli_query($conn, "SELECT COUNT(*) AS TOTAL FROM candidates WHERE worker_type = 'Masters Degree Workers' AND status = 'Applied / Pending' $nationality");
// while ($spec = mysqli_fetch_assoc($query)) {
//     $masters_degree_applied_pending =  $spec["TOTAL"];
// }

// $query = mysqli_query($conn, "SELECT COUNT(*) AS TOTAL FROM candidates WHERE worker_type = 'Diaspora Engagement' $nationality");
// while ($spec = mysqli_fetch_assoc($query)) {
//     $diaspora_engagement_total_candidates =  $spec["TOTAL"];
// }

// $query = mysqli_query($conn, "SELECT COUNT(*) AS TOTAL FROM candidates WHERE worker_type = 'Diaspora Engagement' AND status = 'Applied / Pending' $nationality");
// while ($spec = mysqli_fetch_assoc($query)) {
//     $diaspora_engagement_applied_pending =  $spec["TOTAL"];
// }






// $query = mysqli_query($conn, "SELECT COUNT(*) AS TOTAL FROM candidates WHERE YEAR(date_of_application) = '" . DATE('Y') . "' AND MONTH(date_of_application) = 1  $nationality");
// while ($spec = mysqli_fetch_assoc($query)) {
//     $jan_applications =  $spec["TOTAL"];
// }

// $query = mysqli_query($conn, "SELECT COUNT(*) AS TOTAL FROM candidates WHERE YEAR(date_of_application) = '" . DATE('Y') . "' AND MONTH(date_of_application) = 2  $nationality");
// while ($spec = mysqli_fetch_assoc($query)) {
//     $feb_applications =  $spec["TOTAL"];
// }

// $query = mysqli_query($conn, "SELECT COUNT(*) AS TOTAL FROM candidates WHERE YEAR(date_of_application) = '" . DATE('Y') . "' AND MONTH(date_of_application) = 3  $nationality");
// while ($spec = mysqli_fetch_assoc($query)) {
//     $mar_applications =  $spec["TOTAL"];
// }

// $query = mysqli_query($conn, "SELECT COUNT(*) AS TOTAL FROM candidates WHERE YEAR(date_of_application) = '" . DATE('Y') . "' AND MONTH(date_of_application) = 4  $nationality");
// while ($spec = mysqli_fetch_assoc($query)) {
//     $apr_applications =  $spec["TOTAL"];
// }

// $query = mysqli_query($conn, "SELECT COUNT(*) AS TOTAL FROM candidates WHERE YEAR(date_of_application) = '" . DATE('Y') . "' AND MONTH(date_of_application) = 5  $nationality");
// while ($spec = mysqli_fetch_assoc($query)) {
//     $may_applications =  $spec["TOTAL"];
// }

// $query = mysqli_query($conn, "SELECT COUNT(*) AS TOTAL FROM candidates WHERE YEAR(date_of_application) = '" . DATE('Y') . "' AND MONTH(date_of_application) = 6  $nationality");
// while ($spec = mysqli_fetch_assoc($query)) {
//     $jun_applications =  $spec["TOTAL"];
// }

// $query = mysqli_query($conn, "SELECT COUNT(*) AS TOTAL FROM candidates WHERE YEAR(date_of_application) = '" . DATE('Y') . "' AND MONTH(date_of_application) = 7  $nationality");
// while ($spec = mysqli_fetch_assoc($query)) {
//     $july_applications =  $spec["TOTAL"];
// }

// $query = mysqli_query($conn, "SELECT COUNT(*) AS TOTAL FROM candidates WHERE YEAR(date_of_application) = '" . DATE('Y') . "' AND MONTH(date_of_application) = 8  $nationality");
// while ($spec = mysqli_fetch_assoc($query)) {
//     $aug_applications =  $spec["TOTAL"];
// }

// $query = mysqli_query($conn, "SELECT COUNT(*) AS TOTAL FROM candidates WHERE YEAR(date_of_application) = '" . DATE('Y') . "' AND MONTH(date_of_application) = 9  $nationality");
// while ($spec = mysqli_fetch_assoc($query)) {
//     $sept_applications =  $spec["TOTAL"];
// }

// $query = mysqli_query($conn, "SELECT COUNT(*) AS TOTAL FROM candidates WHERE YEAR(date_of_application) = '" . DATE('Y') . "' AND MONTH(date_of_application) = 10  $nationality");
// while ($spec = mysqli_fetch_assoc($query)) {
//     $oct_applications =  $spec["TOTAL"];
// }

// $query = mysqli_query($conn, "SELECT COUNT(*) AS TOTAL FROM candidates WHERE YEAR(date_of_application) = '" . DATE('Y') . "' AND MONTH(date_of_application) = 11  $nationality");
// while ($spec = mysqli_fetch_assoc($query)) {
//     $nov_applications =  $spec["TOTAL"];
// }

// $query = mysqli_query($conn, "SELECT COUNT(*) AS TOTAL FROM candidates WHERE YEAR(date_of_application) = '" . DATE('Y') . "' AND MONTH(date_of_application) = 12  $nationality");
// while ($spec = mysqli_fetch_assoc($query)) {
//     $dec_applications =  $spec["TOTAL"];
// }


// $query = mysqli_query($conn, "SELECT nationality,COUNT(id) AS TOTAL FROM candidates WHERE YEAR(date_of_application) = '" . DATE('Y') . "' $nationality GROUP BY nationality ");
// $countries_count = array();
// while ($spec = mysqli_fetch_assoc($query)) {
//     $countries_count[] = $spec;
// }
$current_year = DATE('Y');

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

$resultData = array('role' => $role, 'code' => $statusCode, 'message' => $statusMessage, 'warehouseName1' => $warehouseName1, 'warehouseQty1' => $warehouseQty1, 'warehouseName2' => $warehouseName2, 'warehouseQty2' => $warehouseQty2, 'warehouseName3' => $warehouseName3, 'warehouseQty3' => $warehouseQty3, 'warehouseName4' => $warehouseName4, 'warehouseQty4' => $warehouseQty4, 'warehouseName5' => $warehouseName5, 'warehouseQty5' => $warehouseQty5, 'warehouseName6' => $warehouseName6, 'warehouseQty6' => $warehouseQty6, 'warehouseName7' => $warehouseName7, 'warehouseQty7' => $warehouseQty7, 'warehouseName8' => $warehouseName8, 'warehouseQty8' => $warehouseQty8, 'warehouseName9' => $warehouseName9, 'warehouseQty9' => $warehouseQty9, 'warehouseName10' => $warehouseName10, 'warehouseQty10' => $warehouseQty10, 'warehouseName11' => $warehouseName11, 'warehouseQty111' => $warehouseQty11);
echo json_encode($resultData);
