mirror of
https://github.com/limosek/zaf-plugins.git
synced 2025-01-21 07:25:56 +01:00
Working on booked
This commit is contained in:
parent
08875ed63c
commit
09785e4cf6
@ -4,7 +4,7 @@ Description::
|
|||||||
Plugin for booked PHP reservation system
|
Plugin for booked PHP reservation system
|
||||||
::
|
::
|
||||||
|
|
||||||
Version: 0.1
|
Version: 0.2
|
||||||
Url: https://raw.githubusercontent.com/limosek/zaf-plugins/master/booked
|
Url: https://raw.githubusercontent.com/limosek/zaf-plugins/master/booked
|
||||||
Web: https://github.com/limosek/zaf-plugins
|
Web: https://github.com/limosek/zaf-plugins
|
||||||
|
|
||||||
@ -29,10 +29,11 @@ Return: int
|
|||||||
Parameters::
|
Parameters::
|
||||||
from 'now' ''
|
from 'now' ''
|
||||||
to '+1 hour' ''
|
to '+1 hour' ''
|
||||||
|
start_only 'no' ''
|
||||||
::
|
::
|
||||||
Description::
|
Description::
|
||||||
Get number of reservations in given time range
|
Get number of reservations in given time range. If start_only is not null, report even reservations which ends after to.
|
||||||
::
|
::
|
||||||
Cmd: php getr.php "$from" "$to"
|
Cmd: php getr.php "$from" "$to" "$start_only"
|
||||||
/Item
|
/Item
|
||||||
|
|
||||||
|
@ -1,23 +1,29 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
error_reporting(0);
|
error_reporting(0);
|
||||||
session_start();
|
session_start();
|
||||||
$from=$argv[1];
|
$from=$argv[1];
|
||||||
$to=$argv[2];
|
$to=$argv[2];
|
||||||
|
$start_only=$argv[3];
|
||||||
|
|
||||||
define("YOURTIMEZONE",getenv("timezone"));
|
define("YOURTIMEZONE",getenv("timezone"));
|
||||||
define("BOOKEDWEBSERVICESURL",getenv("url"));
|
define("BOOKEDWEBSERVICESURL",getenv("url"));
|
||||||
|
|
||||||
require_once(__DIR__ . "/bookedapi.php");
|
require_once(__DIR__ . "/bookedapi.php");
|
||||||
|
|
||||||
if ($from) {
|
$tz=New DateTimeZone(getenv("timezone"));
|
||||||
$from=New DateTime(strtr($from,"_"," "));
|
|
||||||
$from=$from->getTimestamp();
|
if ($from!="") {
|
||||||
|
$fromd=New DateTime(strtr($from,"_"," "));
|
||||||
|
$fromd->setTimezone($tz);
|
||||||
|
$from=$fromd->getTimestamp();
|
||||||
} else {
|
} else {
|
||||||
$from=time();
|
$from=time();
|
||||||
}
|
}
|
||||||
if ($to) {
|
if ($to!="") {
|
||||||
$to=New DateTime(strtr($to,"_"," "));
|
$tod=New DateTime(strtr($to,"_"," "));
|
||||||
$to=$to->getTimestamp();
|
$tod->setTimezone($tz);
|
||||||
|
$to=$tod->getTimestamp();
|
||||||
} else {
|
} else {
|
||||||
$to=time()+3600;
|
$to=time()+3600;
|
||||||
}
|
}
|
||||||
@ -29,13 +35,21 @@
|
|||||||
$cnt=0;
|
$cnt=0;
|
||||||
foreach ($reservations["reservations"] as $r) {
|
foreach ($reservations["reservations"] as $r) {
|
||||||
$start=New DateTime($r["startDate"]);
|
$start=New DateTime($r["startDate"]);
|
||||||
$start->setTimezone(New DateTimeZone(getenv("timezone")));
|
$start->setTimezone($tz);
|
||||||
$end=New DateTime($r["endDate"]);
|
$end=New DateTime($r["endDate"]);
|
||||||
$end->setTimezone(New DateTimeZone(getenv("timezone")));
|
$end->setTimezone($tz);
|
||||||
$sstart=$start->getTimestamp();
|
$sstart=$start->getTimestamp();
|
||||||
$send=$end->getTimestamp();
|
$send=$end->getTimestamp();
|
||||||
if ($sstart>=$from && $send<=$to) {
|
#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";
|
||||||
$cnt++;
|
#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++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user