30if (!defined(
'NOLOGIN')) {
33if (!defined(
'NOCSRFCHECK')) {
34 define(
"NOCSRFCHECK", 1);
36if (!defined(
'NOBROWSERNOTIF')) {
37 define(
'NOBROWSERNOTIF',
'1');
41require
'../../main.inc.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
44require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
45require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
46require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
47require_once DOL_DOCUMENT_ROOT.
'/bookcal/class/calendar.class.php';
48require_once DOL_DOCUMENT_ROOT.
'/bookcal/class/availabilities.class.php';
49require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
50require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
51require_once DOL_DOCUMENT_ROOT.
'/core/lib/public.lib.php';
66$langs->loadLangs(array(
"main",
"other",
"dict",
"agenda",
"errors",
"companies"));
68$action =
GETPOST(
'action',
'aZ09');
70$id_availability =
GETPOSTINT(
'id_availability');
82$backtopage =
GETPOST(
"backtopage",
"alpha");
88if ($id_availability > 0) {
89 $result = $availability->fetch($id_availability);
94$nowyear = $nowarray[
'year'];
95$nowmonth = $nowarray[
'mon'];
96$nowday = $nowarray[
'mday'];
99$prev_year = $prev[
'year'];
100$prev_month = $prev[
'month'];
102$next_year = $next[
'year'];
103$next_month = $next[
'month'];
105$max_day_in_prev_month = idate(
"t",
dol_mktime(0, 0, 0, $prev_month, 1, $prev_year,
'gmt'));
106$max_day_in_month = idate(
"t",
dol_mktime(0, 0, 0, $month, 1, $year));
108$tmpday = - idate(
"w",
dol_mktime(12, 0, 0, $month, 1, $year,
'gmt')) + 2;
114$firstdaytoshow =
dol_mktime(0, 0, 0, $prev_month, $max_day_in_prev_month + $tmpday, $prev_year,
'tzuserrel');
115$next_day = 7 - ($max_day_in_month + 1 - $tmpday) % 7;
119$lastdaytoshow =
dol_mktime(0, 0, 0, $next_month, $next_day, $next_year,
'tzuserrel');
121$datechosen =
GETPOST(
'datechosen',
'alpha');
122$datetimechosen =
GETPOSTINT(
'datetimechosen');
123$isdatechosen =
false;
124$timebooking =
GETPOST(
"timebooking");
125$datetimebooking =
GETPOSTINT(
"datetimebooking");
126$durationbooking =
GETPOSTINT(
"durationbooking");
142function llxHeaderVierge($title, $head =
"", $disablejs = 0, $disablehead = 0, $arrayofjs = [], $arrayofcss = [])
144 global $conf, $langs,
$mysoc;
146 top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
148 print
'<body id="mainbody" class="publicnewmemberform">';
150 include_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
153 print
'<div class="divmainbodylarge">';
161if ($action ==
'add') {
167 $nb_post_max =
getDolGlobalInt(
"MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS", 200);
169 if (!is_object($user)) {
170 $user =
new User($db);
177 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Lastname")).
"<br>\n";
181 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Firstname")).
"<br>\n";
185 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Email")).
"<br>\n";
189 $sql =
"SELECT s.rowid";
190 $sql .=
" FROM ".MAIN_DB_PREFIX.
"socpeople as s";
191 $sql .=
" WHERE s.lastname = '".$db->escape(
GETPOST(
"lastname")).
"'";
192 $sql .=
" AND s.firstname = '".$db->escape(
GETPOST(
"firstname")).
"'";
193 $sql .=
" AND s.email = '".$db->escape(
GETPOST(
"email")).
"'";
194 $resql = $db->query($sql);
197 $num = $db->num_rows($resql);
199 $obj = $db->fetch_object($resql);
200 $idcontact = $obj->rowid;
201 $contact->fetch($idcontact);
203 $contact->lastname =
GETPOST(
"lastname");
204 $contact->firstname =
GETPOST(
"firstname");
205 $contact->email =
GETPOST(
"email");
210 $errmsg .= implode(
'<br>', $contact->errors);
212 $result = $contact->create($user);
215 $errmsg .= $contact->error.
" ".implode(
',', $contact->errors);
221 $errmsg .= $db->lasterror();
228 $actioncomm->label = $langs->trans(
"BookcalBookingTitle");
229 $actioncomm->type =
'AC_RDV';
230 $actioncomm->type_id = 5;
231 $actioncomm->datep =
GETPOSTINT(
"datetimebooking");
232 $actioncomm->datef = $dateend;
233 $actioncomm->note_private =
GETPOST(
"description");
234 $actioncomm->percentage = -1;
235 $actioncomm->fk_bookcal_calendar =
$id;
236 $actioncomm->userownerid = $calendar->visibility;
237 $actioncomm->contact_id = $contact->id;
238 $actioncomm->socpeopleassigned = [
240 'id' => $contact->id,
242 'answer_status' => 0,
249 $errmsg .= implode(
'<br>', $actioncomm->errors);
251 $result = $actioncomm->create($user);
254 $errmsg .= $actioncomm->error.
" ".implode(
',', $actioncomm->errors);
261 $action =
'afteradd';
273$form =
new Form($db);
278$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT;
287if (
$object->status == $object::STATUS_DRAFT) {
288 $langs->trans(
"errors");
289 $errmsg = $langs->trans(
"ErrorCalendarIsNotYetOpenOrHasBeenClosed");
294if ($action ==
'create') {
295 $backtopage = $_SERVER[
"PHP_SELF"].
'?id='.
$id.
'&datechosen='.$datechosen;
297 $backtopage = DOL_URL_ROOT.
'/public/bookcal/index.php?id='.
$id;
302print
'<div class="bookcalpublicarea centpercent center" style="min-width:30%;width:fit-content;height:70%;top:60%;left: 50%;">';
303print
'<div class="bookcalform" style="min-height:50%">';
304if ($action ==
'afteradd') {
306 print $langs->trans(
"BookingSuccessfullyBooked");
312 print
'<table class="centpercent">';
315 if ($action !=
'create') {
316 print
'<form name="formsearch" class="bookcalsearch" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
317 print
'<input type="hidden" name="id" value="'.$id.
'">';
319 $nav =
'<a href="?id='.$id.
"&year=".$prev_year.
"&month=".$prev_month.$param.
'"><i class="fa fa-chevron-left"></i></a> '.
"\n";
320 $nav .=
' <span id="month_name">'.dol_print_date(
dol_mktime(0, 0, 0, $month, 1, $year),
"%b %Y");
321 $nav .=
" </span>\n";
322 $nav .=
' <a href="?id='.$id.
"&year=".$next_year.
"&month=".$next_month.$param.
'"><i class="fa fa-chevron-right"></i></a>'.
"\n";
323 if (empty($conf->dol_optimize_smallscreen)) {
324 $nav .=
' <a href="?id='.$id.
"&year=".$nowyear.
"&month=".$nowmonth.
"&day=".$nowday.$param.
'" class="datenowlink">'.$langs->trans(
"Today").
'</a> ';
326 $nav .= $form->selectDate($dateselect,
'dateselect', 0, 0, 1,
'', 1, 0);
327 $nav .=
'<button type="submit" class="liste_titre button_search valignmiddle" name="button_search_x" value="x"><span class="fa fa-search"></span></button>';
334 print
'<div class="bookingtab hidden" style="height:50%">';
335 print
'<div id="bookingtabspandate"></div>';
341 if ($action ==
"create") {
343 if (empty($datetimebooking)) {
344 $timebookingarray = explode(
" - ", $timebooking);
345 $timestartarray = explode(
":", $timebookingarray[0]);
346 $timeendarray = explode(
":", $timebookingarray[1]);
350 print
'<span>'.img_picto(
"",
"calendar").
" ".
dol_print_date($datetimebooking,
'dayhourtext').
'</span>';
351 print
'<div class="center"><a href="'.$_SERVER[
"PHP_SELF"].
'?id=1&year=2024&month=2" class="small">('.$langs->trans(
"SelectANewDate").
')</a></div>';
355 print
'<form method="POST" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
356 print
'<table class="border" summary="form to subscribe" id="tablesubscribe">'.
"\n";
357 print
'<input type="hidden" name="token" value="'.newToken().
'">';
358 print
'<input type="hidden" name="action" value="add">';
359 print
'<input type="hidden" name="datetimebooking" value="'.$datetimebooking.
'">';
360 print
'<input type="hidden" name="datechosen" value="'.$datechosen.
'">';
361 print
'<input type="hidden" name="id" value="'.$id.
'">';
362 print
'<input type="hidden" name="durationbooking" value="'.$durationbooking.
'">';
365 print
'<tr><td><input autofocus type="text" name="lastname" class="minwidth150" placeholder="'.dol_escape_htmltag($langs->trans(
"Lastname").
'*').
'" value="'.
dol_escape_htmltag(
GETPOST(
'lastname')).
'"></td></tr>'.
"\n";
367 print
'<tr><td><input type="text" name="firstname" class="minwidth150" placeholder="'.dol_escape_htmltag($langs->trans(
"Firstname").
'*').
'" value="'.
dol_escape_htmltag(
GETPOST(
'firstname')).
'"></td></tr>'.
"\n";
369 print
'<tr><td><input type="email" name="email" maxlength="255" class="minwidth150" placeholder="'.dol_escape_htmltag($langs->trans(
"Email").
'*').
'" value="'.
dol_escape_htmltag(
GETPOST(
'email')).
'"></td></tr>'.
"\n";
373 print
'<td class="tdtop">';
374 print $langs->trans(
"Message");
375 print
'<textarea name="description" id="description" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_4.
'">'.
dol_escape_htmltag(
GETPOST(
'description',
'restricthtml'), 0, 1).
'</textarea></td>';
377 print
'</table>'.
"\n";
378 print
'<div class="center">';
379 print
'<input type="submit" value="'.$langs->trans(
"Submit").
'" id="submitsave" class="button">';
385 print
'<table class="centpercent noborder nocellnopadd cal_pannel cal_month">';
386 print
' <tr class="">';
388 print
' <td class="center hideonsmartphone">#</td>';
392 if (!empty($conf->dol_optimize_smallscreen)) {
393 print
' <td class="center bold uppercase tdfordaytitle'.($i == 0 ?
' borderleft' :
'').
'">';
394 $labelshort = array(0 =>
'SundayMin', 1 =>
'MondayMin', 2 =>
'TuesdayMin', 3 =>
'WednesdayMin', 4 =>
'ThursdayMin', 5 =>
'FridayMin', 6 =>
'SaturdayMin');
395 print $langs->trans($labelshort[$numdayinweek]);
398 print
' <td class="center minwidth75 bold uppercase small tdoverflowmax50 tdfordaytitle'.($i == 0 ?
' borderleft' :
'').
'">';
400 $labelshort = array(0 =>
'Sunday', 1 =>
'Monday', 2 =>
'Tuesday', 3 =>
'Wednesday', 4 =>
'Thursday', 5 =>
'Friday', 6 =>
'Saturday');
401 print $langs->trans($labelshort[$numdayinweek]);
409 $todaytms =
dol_mktime(0, 0, 0, $todayarray[
'mon'], $todayarray[
'mday'], $todayarray[
'year']);
412 $arrayofavailabledays = array();
414 $arrayofavailabilities = $availability->fetchAll(
'',
'', 0, 0,
'(status:=:1) AND (fk_bookcal_calendar:=:'.((
int) $id).
')');
415 if ($arrayofavailabilities < 0) {
418 foreach ($arrayofavailabilities as $key => $value) {
421 for ($i = $startarray[
'mday']; $i <= $endarray[
'mday']; $i++) {
422 if ($todayarray[
'mon'] >= $startarray[
'mon'] && $todayarray[
'mon'] <= $endarray[
'mon']) {
423 $arrayofavailabledays[
dol_mktime(0, 0, 0, $todayarray[
'mon'], $i, $todayarray[
'year'])] =
dol_mktime(0, 0, 0, $todayarray[
'mon'], $i, $todayarray[
'year']);
429 for ($iter_week = 0; $iter_week < 6; $iter_week++) {
433 $currdate0 = sprintf(
"%04d", $prev_year).sprintf(
"%02d", $prev_month).sprintf(
"%02d", $max_day_in_prev_month + $tmpday);
434 } elseif ($tmpday <= $max_day_in_month) {
435 $currdate0 = sprintf(
"%04d", $year).sprintf(
"%02d", $month).sprintf(
"%02d", $tmpday);
437 $currdate0 = sprintf(
"%04d", $next_year).sprintf(
"%02d", $next_month).sprintf(
"%02d", $tmpday - $max_day_in_month);
440 $numweek0 = idate(
"W", strtotime(
date($currdate0)));
442 echo
' <td class="center weeknumber opacitymedium hideonsmartphone" style="min-width: 40px">'.$numweek0.
'</td>';
444 for ($iter_day = 0; $iter_day < 7; $iter_day++) {
447 $style =
'cal_other_month cal_past';
448 if ($iter_day == 6) {
449 $style .=
' cal_other_month_right';
451 echo
' <td class="'.$style.
' nowrap tdtop" width="14%">';
454 } elseif ($tmpday <= $max_day_in_month) {
456 $curtime =
dol_mktime(0, 0, 0, $month, $tmpday, $year);
457 $style =
'cal_current_month';
458 if ($iter_day == 6) {
459 $style .=
' cal_current_month_right';
462 if ($todayarray[
'mday'] == $tmpday && $todayarray[
'mon'] == $month && $todayarray[
'year'] == $year) {
466 if ($curtime > $todaytms && in_array($curtime, $arrayofavailabledays)) {
467 $style .=
' cal_available cursorpointer';
469 if ($curtime < $todaytms) {
470 $style .=
' cal_past';
472 $dateint = sprintf(
"%04d", $year).
'_'.sprintf(
"%02d", $month).
'_'.sprintf(
"%02d", $tmpday);
473 if (!empty(explode(
'dayevent_', $datechosen)[1]) && explode(
'dayevent_', $datechosen)[1] == $dateint) {
474 $style .=
' cal_chosen';
475 $isdatechosen =
true;
477 echo
' <td class="'.$style.
' nowrap tdtop" width="14%">';
482 $style =
'cal_other_month';
483 if ($iter_day == 6) {
484 $style .=
' cal_other_month_right';
486 echo
' <td class="'.$style.
' nowrap tdtop" width="14%">';
498 print
'<div class="center bookingtab" style="height:50%">';
499 print
'<div style="height:100%">';
500 print
'<form id="formbooking" name="formbooking" method="POST" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
501 print
'<input type="hidden" name="id" value="'.$id.
'">';
502 print
'<input type="hidden" name="token" value="'.newToken().
'">';
503 print
'<input type="hidden" name="action" value="create">';
504 print
'<input type="hidden" id="datechosen" name="datechosen" value="">';
505 print
'<input type="hidden" id="datetimechosen" name="datetimechosen" value="">';
506 print
'<input type="hidden" id="durationbooking" name="durationbooking" value="">';
508 print
'<div id="bookinghoursection">';
509 print
'<br><br><br><br><br><br><div class="opacitymedium center">'.$langs->trans(
"SelectADay").
'</div>';
524 function generateBookingButtons(timearray, datestring){
525 console.log("We generate all booking buttons of "+datestring);
528 for (index in timearray){
529 let hour = new Date("2000-01-01T" + index + ":00");
530 duration = timearray[index];
531 isalreadybooked = false;
534 isalreadybooked = true;
536 hour.setMinutes(hour.getMinutes() + duration);
538 let hours = hour.getHours().toString().padStart(2, "0"); // Formatter pour obtenir deux chiffres
539 let mins = hour.getMinutes().toString().padStart(2, "0"); // Formatter pour obtenir deux chiffres
541 timerange = index + " - " + `${hours}:${mins}`;
542 str += \'<input class="button btnsubmitbooking \'+(isalreadybooked == true ? "btnbookcalbooked" : "")+\'" type="submit" name="timebooking" value="\'+timerange+\'" data-duration="\'+duration+\'"><br>\';
545 $("#bookinghoursection").html(str);
546 $(".btnsubmitbooking").on("click", function(){
547 duration = $(this).data("duration");
548 $("#durationbooking").val(duration);
551 print
'$(document).ready(function() {
552 $(".cal_available").on("click", function(){
553 console.log("We click on cal_available");
554 $(".cal_chosen").removeClass("cal_chosen");
555 $(this).addClass("cal_chosen");
556 datestring = $(this).children("div").data("date");
559 url: "'.DOL_URL_ROOT.
'/public/bookcal/bookcalAjax.php",
561 action: "verifyavailability",
563 datetocheck: $(this).children("div").data("datetime"),
566 }).done(function (data) {
567 console.log("We show all booking");
568 if (data["code"] == "SUCCESS") {
569 /* TODO Replace this with a creating of allavailable hours button */
571 timearray = data["availability"];
572 console.log(timearray);
573 generateBookingButtons(timearray, datestring);
574 $(".btnbookcalbooked").prop("disabled", true);
576 if(data["code"] == "NO_DATA_FOUND"){
577 console.log("No booking to hide");
579 console.log(data["message"]);
583 $(".bookingtab").removeClass("hidden");
584 $("#bookingtabspandate").text($(this).children("div").data("date"));
585 $("#datechosen").val($(this).children("div").attr("id"));
586 $("#datetimechosen").val($(this).children("div").data("datetime"));
591 '.($datechosen ?
'$(".cal_chosen").trigger( "click" )' :
'').
'
611 if ($conf->use_javascript_ajax) {
612 $conf->global->MAIN_JS_SWITCH_AGENDA = 1;
615 $dateint = sprintf(
"%04d", $year).
'_'.sprintf(
"%02d", $month).
'_'.sprintf(
"%02d", $day);
616 $eventdatetime =
dol_mktime(-1, -1, -1, $month, $day, $year);
621 $curtime =
dol_mktime(0, 0, 0, $month, $day, $year);
623 print
'<div id="dayevent_'.$dateint.
'" class="dayevent tagtable centpercent nobordernopadding" data-datetime="'.$eventdatetime.
'" data-date="'.
dol_print_date($eventdatetime,
"daytext").
'">'.
"\n";
627 print
img_picto(
'today',
'fontawesome_circle_fas_black_7px');
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
global $dolibarr_main_url_root
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Class to manage agenda events (actions)
Class for Availabilities.
Class to manage Dolibarr users.
htmlPrintOnlineHeader($mysoc, $langs, $showlogo=1, $alttext='', $subimageconst='', $altlogo1='', $altlogo2='')
Show the header of a company in HTML public pages.
dol_get_prev_month($month, $year)
Return previous month.
dol_get_next_month($month, $year)
Return next month.
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
dol_now($mode='gmt')
Return date for now.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
currentToken()
Return the value of token currently saved into session with name 'token'.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
getUserRemoteIP($trusted=0)
Return the real IP of remote user.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_htmloutput_errors($mesgstring='', $mesgarray=array(), $keepembedded=0)
Print formatted error messages to output (Used to show messages on html output).
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs=array(), $arrayofcss=array(), $disableforlogin=0, $disablenofollow=0, $disablenoindex=0)
Output html header of a page.
show_bookcal_day_events($day, $month, $year, $today=0)
Show event of a particular day.
llxHeaderVierge($title, $head="", $disablejs=0, $disablehead=0, $arrayofjs=[], $arrayofcss=[])
Show header for booking.
checkNbPostsForASpeceificIp($object, $nb_post_max)
Check if the object exceeded the number of posts for a specific ip in the same week.
if(getDolGlobalString( 'TAKEPOS_SHOW_CUSTOMER')) print $langs trans('Date')." left Label right Qty right Price right TotalHT right TotalTTC right right right right right right right right right centpercent right TotalHT right n right VAT right n right TotalVAT right n No sujeto a RE IRPF right TotalLT1 right n right TotalLT2 right n right TotalTTC right n takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency right TotalTTC takeposcustomercurrency right takeposcustomercurrency n right PaymentTypeShortLIQ right SELECT p pos_change as p datep as date
httponly_accessforbidden($message='1', $http_response_code=403, $stringalreadysanitized=0)
Show a message to say access is forbidden and stop program.