2016-12-11 13:06:36 +01:00
|
|
|
<?php
|
2016-12-11 20:58:36 +01:00
|
|
|
|
2016-12-11 13:06:36 +01:00
|
|
|
error_reporting(0);
|
|
|
|
session_start();
|
|
|
|
$from=$argv[1];
|
|
|
|
$to=$argv[2];
|
2016-12-11 20:58:36 +01:00
|
|
|
$start_only=$argv[3];
|
2016-12-11 13:06:36 +01:00
|
|
|
|
|
|
|
define("YOURTIMEZONE",getenv("timezone"));
|
|
|
|
define("BOOKEDWEBSERVICESURL",getenv("url"));
|
2016-12-11 16:15:22 +01:00
|
|
|
|
2016-12-11 13:06:36 +01:00
|
|
|
require_once(__DIR__ . "/bookedapi.php");
|
|
|
|
|
2016-12-11 20:58:36 +01:00
|
|
|
$tz=New DateTimeZone(getenv("timezone"));
|
|
|
|
|
|
|
|
if ($from!="") {
|
|
|
|
$fromd=New DateTime(strtr($from,"_"," "));
|
|
|
|
$fromd->setTimezone($tz);
|
|
|
|
$from=$fromd->getTimestamp();
|
2016-12-11 13:06:36 +01:00
|
|
|
} else {
|
|
|
|
$from=time();
|
|
|
|
}
|
2016-12-11 20:58:36 +01:00
|
|
|
if ($to!="") {
|
|
|
|
$tod=New DateTime(strtr($to,"_"," "));
|
|
|
|
$tod->setTimezone($tz);
|
|
|
|
$to=$tod->getTimestamp();
|
2016-12-11 13:06:36 +01:00
|
|
|
} else {
|
|
|
|
$to=time()+3600;
|
|
|
|
}
|
|
|
|
|
|
|
|
$bookedapiclient = new bookedapiclient(getenv("username"), getenv("password"));
|
|
|
|
$bookedapiclient-> authenticate();
|
|
|
|
$reservations=$bookedapiclient->getReservation(null,null,null,date("c",$from),date("c",$to));
|
|
|
|
|
|
|
|
$cnt=0;
|
|
|
|
foreach ($reservations["reservations"] as $r) {
|
|
|
|
$start=New DateTime($r["startDate"]);
|
2016-12-11 20:58:36 +01:00
|
|
|
$start->setTimezone($tz);
|
2016-12-11 13:06:36 +01:00
|
|
|
$end=New DateTime($r["endDate"]);
|
2016-12-11 20:58:36 +01:00
|
|
|
$end->setTimezone($tz);
|
2016-12-11 13:06:36 +01:00
|
|
|
$sstart=$start->getTimestamp();
|
|
|
|
$send=$end->getTimestamp();
|
2016-12-11 20:58:36 +01:00
|
|
|
#echo $fromd->format("Y-m-d H:i") . "," . $start->format("Y-m-d H:i") . "," . $end->format("Y-m-d H:i") . "," . $tod->format("Y-m-d H:i"). "\n";
|
|
|
|
#echo $from . "," . $start->getTimestamp() . "," . $end->getTimestamp() . "," . $to . "\n";
|
|
|
|
if ($start_only=="yes") {
|
|
|
|
if ($sstart>=$from && $sstart<=$to) {
|
|
|
|
$cnt++;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if ($sstart>=$from && $send<=$to) {
|
|
|
|
$cnt++;
|
|
|
|
}
|
2016-12-11 13:06:36 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
echo $cnt;
|
|
|
|
|
|
|
|
|