22if (!defined(
'NOTOKENRENEWAL')) {
23 define(
'NOTOKENRENEWAL',
'1');
25if (!defined(
'NOREQUIREHTML')) {
26 define(
'NOREQUIREHTML',
'1');
28if (!defined(
'NOREQUIREAJAX')) {
29 define(
'NOREQUIREAJAX',
'1');
31if (!defined(
'NOREQUIRESOC')) {
32 define(
'NOREQUIRESOC',
'1');
35if (!defined(
'NOREQUIREMENU')) {
36 define(
'NOREQUIREMENU',
'1');
38if (!defined(
"NOLOGIN")) {
39 define(
"NOLOGIN",
'1');
41if (!defined(
'NOBROWSERNOTIF')) {
42 define(
'NOBROWSERNOTIF',
'1');
45require
'../../main.inc.php';
46require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
48$action =
GETPOST(
'action',
'aZ09');
50$datetocheckbooking =
GETPOSTINT(
'datetocheck');
68if ($action ==
'verifyavailability') {
72 $response[
"code"] =
"MISSING_ID";
73 $response[
"message"] =
"Missing parameter id";
74 header(
'HTTP/1.0 400 Bad Request');
75 echo json_encode($response);
78 if (empty($datetocheckbooking)) {
80 $response[
"code"] =
"MISSING_DATE_AVAILABILITY";
81 $response[
"message"] =
"Missing parameter datetocheck";
82 header(
'HTTP/1.0 400 Bad Request');
83 echo json_encode($response);
90 $availabilitytab = array();
91 $sql =
"SELECT ba.rowid as id, ba.duration, ba.startHour, ba.endHour, ba.start, ba.end";
92 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bookcal_availabilities as ba";
93 $sql .=
" WHERE ba.fk_bookcal_calendar = ".((int) $id);
94 $sql .=
" AND ba.status = 1";
95 $resql = $db->query($sql);
97 $num = $db->num_rows($resql);
100 $obj = $db->fetch_object($resql);
101 $starttime = $db->jdate($obj->start);
102 $endtime = $db->jdate($obj->end);
103 $offsetmin = $obj->duration % 60;
104 if ($offsetmin == 0) {
107 $startHourstring = $obj->startHour;
108 $endHourstring = $obj->endHour;
109 if ($startHourstring <= 0) {
110 $startHourstring = 0;
112 if ($endHourstring >= 24) {
115 $offsethour = round($obj->duration / 60);
117 if ($datetocheckbooking >= $starttime && $datetocheckbooking <= $endtime) {
118 for ($hour=$startHourstring; $hour < $endHourstring; $hour+= $offsethour) {
119 for ($min=0; $min < 60; $min += $offsetmin) {
123 $hourstring =
"0".$hourstring;
126 $minstring =
"0".$minstring;
128 $response[
"availability"][$hourstring.
":".$minstring] = intval($obj->duration);
135 $response[
"code"] =
"SUCCESS";
137 $response[
"code"] =
"ERROR";
146 $sql =
"SELECT b.datep, b.id";
147 $sql .=
" FROM ".MAIN_DB_PREFIX.
"actioncomm as b";
148 $sql .=
" WHERE b.datep >= '".$db->idate($datetocheckbooking).
"'";
149 $sql .=
" AND b.datep < '".$db->idate($datetocheckbooking_end).
"'";
150 $sql .=
" AND b.code = 'AC_RDV'";
151 $sql .=
" AND b.status = 0";
152 $sql .=
" AND b.fk_bookcal_calendar = ".((int) $id);
153 $resql = $db->query($sql);
155 $num = $db->num_rows($resql);
158 $obj = $db->fetch_object($resql);
159 $datebooking = $db->jdate($obj->datep);
161 $hourstring = $datebookingarray[
"hours"];
162 $minstring = $datebookingarray[
"minutes"];
163 if ($hourstring < 10) {
164 $hourstring =
"0".$hourstring;
166 if ($minstring < 10) {
167 $minstring =
"0".$minstring;
169 $response[
"availability"][$hourstring.
":".$minstring] *= -1;
183echo json_encode($result);
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
if(!defined( 'NOREQUIREMENU')) if(!empty(GETPOST('seteventmessages', 'alpha'))) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.