<?php
include('dbconnect.php');


$sql = 'SELECT * FROM `empdetails` WHERE status = \'Active\' AND empid = \'ATV21-281\'';

$results =  mysqli_query($conn, $sql);
while($result = mysqli_fetch_assoc($results)){
    $dates = ['2022-06-26', '2022-07-03'];
    foreach($dates as $date) {
        $day = date('w', strtotime($date));
        $week_start = date('Y-m-d', strtotime($date . ' -' . ($day) . ' days'));
        $week_end = date('Y-m-d', strtotime($date . ' +' . (6 - $day) . ' days'));
        
        $query = 'SELECT * FROM `schedule` WHERE `empid` = "' . $result['empid'] . '" AND `date` >= "' . $week_start . '" AND `date` <= "' . $week_end . '" ORDER BY FIELD(day, "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday") LIMIT 7';
        
        $query_results =  mysqli_query($conn, $query);
        while($query_result = mysqli_fetch_assoc($query_results)){
            // $schedule_query = "INSERT INTO `schedule` (`schedcode`, `week`, `day`, `date`, `month`, `year`, `starttime`, `endtime`, `pststarttime`, `pstendtime`, `team`, `empid`, `indi`, `id`, `idl`, `leaveduration`, `pstdate`, `datetime`) VALUES 
            //     ('" . $query_results["empid"] . "2022-06-26', '26', 'Sunday', '2022-06-26', 'June', '2022', '" . $query_results["starttime"] . "', '" . $query_results["endtime"] . "', '" . $query_results["pststarttime"] . "', '" . $query_results["pstendtime"] . "', '" . $query_results["team"] . "', '" . $query_results["empid"] . "', '0', NULL, NULL, NULL, NULL, NULL)";
            echo json_encode($query_result).'<br>';
        }
        return;
    }
}

echo 'test';
return;











$ftp_server = 'scp.tirewebllc.com';
$ftp_user_name = 'scp';
$ftp_user_pass='Sanlibo1000';
$conn_id = ftp_connect($ftp_server);


//$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);


//$contents = ftp_nlist($conn_id, ".");


//var_dump($contents);
phpinfo();
?>