100 lines
2.8 KiB
PHP
100 lines
2.8 KiB
PHP
|
<?php
|
||
|
error_reporting(E_ERROR | E_PARSE);
|
||
|
include ('includes/config/config.php');
|
||
|
include ('includes/functions.php');
|
||
|
include('log_entry.php');
|
||
|
|
||
|
function getSoltes($shifts){
|
||
|
|
||
|
$slot_id=array();
|
||
|
for($s=0;$s<count($shifts);$s++){
|
||
|
$start=getTableFieldValue('shift_status','start_time','shift_status_id','"'.$shifts[$s].'"');
|
||
|
|
||
|
$end=getTableFieldValue('shift_status','end_time','shift_status_id','"'.$shifts[$s].'"');
|
||
|
$slotes='select * from appoinment_slots ';
|
||
|
|
||
|
|
||
|
|
||
|
$result_slotes = mysqli_query($GLOBALS['conn'], $slotes);
|
||
|
|
||
|
while ($row_slotes = mysqli_fetch_array($result_slotes)) {
|
||
|
|
||
|
$solte_time='';
|
||
|
|
||
|
$time=explode(':',$row_slotes['slot']) ;
|
||
|
// error_log(print_r($time,true));
|
||
|
for($x=0;$x<2;$x++){
|
||
|
|
||
|
$solte_time.=$time[$x];
|
||
|
}
|
||
|
// error_log('s '.$start);
|
||
|
// error_log('x1-'.$solte_time);
|
||
|
// error_log('e '.$end);
|
||
|
|
||
|
if($start<=$solte_time && $end>=$solte_time){
|
||
|
// error_log('x2-'.$solte_time);
|
||
|
array_push($slot_id,$row_slotes['slot_id']);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
return($slot_id);
|
||
|
}
|
||
|
begin();
|
||
|
|
||
|
$query = "SELECT * FROM `shift_details` where shift_date >= CURRENT_DATE() ";
|
||
|
|
||
|
|
||
|
error_log("sql " . $query);
|
||
|
if (!$result = @mysqli_query($conn,$query)) {
|
||
|
rollback();
|
||
|
exit(mysqli_error($conn));
|
||
|
}
|
||
|
$data = array();
|
||
|
if(mysqli_num_rows($result) > 0) {
|
||
|
while ($row = mysqli_fetch_assoc($result)) {
|
||
|
|
||
|
$slotes = getSoltes($row['shift_status']);
|
||
|
echo($row['emp_id'].'--'.($slotes));
|
||
|
|
||
|
|
||
|
for($s=0;$s<count($slotes);$s++){
|
||
|
|
||
|
if($slotes[$s]!=0 && $slotes[$s]!=null && $slotes[$s]!='' ){
|
||
|
$doc_slot_id=getTableFieldValue('doc_slots','doc_slot_id','emp_id','"'.$row['emp_id'].'"','slot_date','"'.$row['shift_date'].'"','slot_id','"'.$slotes[$s].'"','ohc_type_id','"'.$row['ohc_type_id'].'"');
|
||
|
|
||
|
$in_q='';
|
||
|
$end_q='';
|
||
|
if(!empty($doc_slot_id)){
|
||
|
$in_q="UPDATE";
|
||
|
$end_q=" where doc_slot_id='".$doc_slot_id."'";
|
||
|
}else{
|
||
|
$in_q="insert into ";
|
||
|
}
|
||
|
|
||
|
|
||
|
$sql = $in_q." doc_slots SET emp_id='".$row['emp_id']."' , slot_date= str_to_date('".$row['shift_date']."','%Y-%m-%d') , slot_id='".$slotes[$s]."' , ohc_type_id='".$row['ohc_type_id']."' ".$end_q;
|
||
|
echo('----'.$sql);
|
||
|
if (!$result_sql = @mysqli_query($conn,$sql)) {
|
||
|
rollback();
|
||
|
exit(mysqli_error($conn));
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
$data['status'] = "succes";
|
||
|
$data['message'] = "Assign menu done!";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
$data['status'] = 200;
|
||
|
$data['message'] = "Data not found!";
|
||
|
}
|
||
|
|
||
|
commit();
|
||
|
echo json_encode($data);
|
||
|
|
||
|
?>
|