%PDF- %PDF-
Direktori : /var/www/html/buggydubrovnik.com/buggy-booking/ |
Current File : /var/www/html/buggydubrovnik.com/buggy-booking/getTimesTest.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); echo $timestamp; echo strtotime("today"); $m=date("m", $timestamp); /*3.4. - do 17 h 6.,7.,8. - do 19 h 5.,9. - do 18h 10. - do 17 h*/ $min=9; if($timestamp==strtotime("today")) { $min=intval(date("H", strtotime("now")))+2; if($min<9) $min=9; } $max=0; $con=mysqli_connect("localhost", "buggydubrovnik_app_production", "appr-17", "buggydubrovnik_app_production"); echo $con->error; if($m==3||$m==4||$m==10) $max=17; elseif($m==6||$m==7||$m==8) $max=19; elseif($m==5||$m==9) $max=18; for($i=$min; $i<=$max; $i++) { $time=str_pad($i, 2, "0", STR_PAD_LEFT).":00"; $start=$date." ".$time.":00"; $end=$date." ".(str_pad($i+1, 2, "0", STR_PAD_LEFT).":00").":00"; //(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 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(); ?> <option data-free="<?=(10-$row[0])?>" value="<?=$time?>"><?=$time?></option> <?php } } /** * Created by PhpStorm. * User: Leo * Date: 20.3.2017. * Time: 13:36 */