<?php

require_once __DIR__ . '/db_config.php';

$r = array();
$r["list"] = array();

if (isset($_POST["mail"]) ) {
 
$email=$_POST["mail"];
$facility=$_POST["id"];
$date=$_POST["date"];

$con = mysqli_connect(DB_SERVER, DB_USER, DB_PASSWORD,DB_DATABASE) or die(mysql_error());

$query="SELECT cm.ID,product.product,model.model,brand.brand,serialnumber.serialnumber,asi.assigndate,asi.facilityid,asi.combinationtype FROM scheduleassigndate asi LEFT JOIN combination cm ON asi.combinationid=cm.ID  LEFT JOIN brand ON brand.id=cm.brand LEFT JOIN product ON product.id=cm.product LEFT JOIN model ON model.id=cm.model LEFT JOIN serialnumber ON cm.serialnumber=serialnumber.id WHERE asi.assigndate='$date' AND asi.facilityid='$facility' AND empemailid='$email'";
$result=mysqli_query($con,$query);
if(!empty($result) && mysqli_num_rows($result) > 0){
    while ($row = mysqli_fetch_array($result)) {
        array_push($r["list"], $row);
    }
}

}

echo json_encode($r);


?>