<?php

require_once __DIR__ . '/db_config.php';

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

if ( isset($_POST["companyname"]) && isset($_POST["employeemailid"]) && isset($_POST["date"]) ) {
    
    $companyname = $_POST['companyname'];
    $employeemailid = $_POST['employeemailid'];
    $date = $_POST['date'];
    $con = mysqli_connect(DB_SERVER, DB_USER, DB_PASSWORD,DB_DATABASE) or die(mysql_error());

    // get a product from expense
    $query ="SELECT timesheetdate,attendenceteam,activity,starttime,endtime FROM timesheet 
        WHERE ( companyname = '$companyname' AND employeemailid = '$employeemailid' AND timesheetdate = '$date' AND deleted = 'no' ) 
        ORDER BY Id ASC ";
    
    $result=mysqli_query($con,$query);
    if(!empty($result) && mysqli_num_rows($result) > 0){
        while ($row = mysqli_fetch_array($result,MYSQLI_ASSOC)) {
            array_push($r["list"], $row);
        }
    }
}
 // echo no users JSON
            echo json_encode($r);



?>