%PDF- %PDF-
Direktori : /var/www/html/buggydubrovnik.com/buggy-booking/ |
Current File : /var/www/html/buggydubrovnik.com/buggy-booking/getTimes.php |
<?php date_default_timezone_set("Europe/Zagreb"); if(isset($_GET["date"])){ $timestamp=strtotime($_GET["date"]); //OVERHEAD, ali za svaki slučaj $date=date("Y-m-d", $timestamp); $m=date("m", $timestamp); /*4.5. - 10h 6.,7.,8. - 10h,18h 9., 10. - 10h, 16 h*/ $min=10; if($timestamp==strtotime("today")) { $min=intval(date("H", strtotime("now")))+6; if($min<10) $min=10; } $max=0; $con=mysqli_connect("localhost", "buggydubrovnik_app_production", "appr-17", "buggydubrovnik_app_production"); // $con=mysqli_connect("localhost", "root", "", "buggydubrovnik_app_production"); echo $con->error; if($m==3||$m==4||$m==5||$m==11) $termini=[10,16]; elseif($m==6||$m==7||$m==8) $termini=[10,18]; elseif($m==9||$m==10) $termini=[10,16]; foreach($termini as $i) { if($i<$min) continue; $time=str_pad($i, 2, "0", STR_PAD_LEFT).":00"; $start=$date." ".$time.":00"; $end=$date." ".(str_pad($i+2, 2, "0", STR_PAD_LEFT).":00").":00"; // die ($end); //(StartA <= EndB) and (EndA >= StartB) $sql="SELECT SUM(r.resurs) FROM rezervacija r JOIN izlet_termin t ON t.id_izlet_termin=r.id_izlet_termin WHERE r.aktivan=1 AND t.aktivan=1 AND r.id_izlet_tip=1 and r.id_vozilo_tip=4 AND t.termin < STR_TO_DATE('$end', '%Y-%m-%d %H:%i:%s') AND r.datum_kupnja > STR_TO_DATE('$start', '%Y-%m-%d %H:%i:%s')"; // echo $sql; $res=$con->query($sql); $row=$res->fetch_row(); $sql2="SELECT (SUM(r.odrasli)+SUM(r.djeca)) FROM rezervacija r JOIN izlet_termin t ON t.id_izlet_termin=r.id_izlet_termin WHERE r.aktivan=1 AND t.aktivan=1 AND r.id_izlet_tip=2 and r.id_vozilo_tip=4 AND t.termin < STR_TO_DATE('$end', '%Y-%m-%d %H:%i:%s') AND r.datum_kupnja > STR_TO_DATE('$start', '%Y-%m-%d %H:%i:%s')"; // echo $sql2; $res2=$con->query($sql2); $row2=$res2->fetch_row(); // echo($row2[0]); $row2Rest=$row2[0]%3!=0?3-($row2[0]%3):0; $row2=ceil($row2[0]/3); $row[0]=$row[0]+$row2; ?> <option data-rest="<?=$row2Rest?>" data-free="<?=(4-$row[0])?>" value="<?=$time?>"><?=$time?></option> <?php } } /** * Created by PhpStorm. * User: Leo * Date: 20.3.2017. * Time: 13:36 */