$sql="select * from `$tbbooking` where `status`='Booking' order by `id_booking` desc";
$jum=getJum($conn,$sql);
if($jum > 0){
$arr=getData($conn,$sql);
foreach($arr as $d) {
$id_booking=$d["id_booking"];
$tanggal_booking=($d["tanggal_booking"]);
$jam_booking=$d["jam_booking"];
$awal = strtotime($tanggal_booking.' '.$jam_booking);
$wkt=date("Y-m-d H:i:s");
$akhir = strtotime($wkt);
$diff = $akhir - $awal;
$jam = floor($diff / (60 * 60));
$menit = $diff - $jam * (60 * 60);
echo 'Waktu tinggal: ' . $jam . ' jam, ' . floor( $menit / 60 ) . ' menit<br>';
if($jam>0){
$sql="Update `$tbbooking` set `status` ='Batal' where `id_booking`='$id_booking'";
$up=process($conn,$sql);
$sql="Update `$tbdetail` set `status_main` ='Batal' where `id_booking`='$id_booking'";
$up=process($conn,$sql);
}
else if($menit>30){
$sql="Update `$tbbooking` set `status` ='Batal' where `id_booking`='$id_booking'";
$up=process($conn,$sql);
$sql="Update `$tbdetail` set `status_main` ='Batal' where `id_booking`='$id_booking'";
$up=process($conn,$sql);
}
}
}
function getData($conn,$sql){
$rs=$conn->query($sql);
$rs->data_seek(0);
//$arr = $rs->fetch_all(MYSQLI_ASSOC);
//$arr = $rs->fetch_assoc();
while ($row = $rs->fetch_assoc()) {
$arr[] = $row;
}
$rs->free();
return $arr;
}
$hr = date('l', strtotime($tanggal_main));
//$hr=date("l");
$kat="Weekday ";
$hari="Minggu";
if($hr=="Sunday"){$hari="Minggu";$kat="Weekend";}
else if($hr=="Monday"){$hari="Senin";}
else if($hr=="Tuesday"){$hari="Selasa";}
else if($hr=="Wednesday"){$hari="Rabu";}
else if($hr=="Thrusday"){$hari="Kamis";}
else if($hr=="Friday"){$hari="Jumat";}
else if($hr=="Saturday"){$hari="Sabtu";$kat="Weekend";}
Tidak ada komentar:
Posting Komentar