37require
'../../main.inc.php';
45require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
46require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
47require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
48require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
49require_once DOL_DOCUMENT_ROOT.
'/core/lib/agenda.lib.php';
50require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
51require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
56$action =
GETPOST(
'action',
'aZ09');
57$optioncss =
GETPOST(
'optioncss',
'aZ');
59if (empty($mode) && preg_match(
'/show_/', $action)) {
63$disabledefaultvalues =
GETPOSTINT(
'disabledefaultvalues');
66$check_birthday = !empty(
$conf->use_javascript_ajax) ?
GETPOSTINT(
"check_birthday") : 1;
67$filter =
GETPOST(
"search_filter",
'alpha', 3) ?
GETPOST(
"search_filter",
'alpha', 3) :
GETPOST(
"filter",
'alpha', 3);
68$filtert =
GETPOST(
"search_filtert",
"intcomma", 3) ?
GETPOST(
"search_filtert",
"intcomma", 3) :
GETPOST(
"filtert",
"intcomma", 3);
69$usergroup =
GETPOST(
"search_usergroup",
"intcomma", 3) ?
GETPOST(
"search_usergroup",
"intcomma", 3) :
GETPOST(
"usergroup",
"intcomma", 3);
70$usergroupids = array_map(
'intval', array_filter(explode(
',', $usergroup)));
71$search_categ_cus =
GETPOST(
"search_categ_cus",
'intcomma', 3) ?
GETPOST(
"search_categ_cus",
'intcomma', 3) : 0;
75 $filtert = (string) $user->id;
85$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
86$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
88if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
92$offset = $limit * $page;
97 $sortfield =
"a.datec";
103 $socid = $user->socid;
110if (!$user->hasRight(
'agenda',
'myactions',
'read')) {
113if (!$user->hasRight(
'agenda',
'allactions',
'read')) {
116if (!$user->hasRight(
'agenda',
'allactions',
'read') || $filter ==
'mine') {
117 $filtert = (string) $user->id;
131if ($dateselect > 0) {
138if (
GETPOST(
'search_actioncode',
'array:aZ09')) {
139 $actioncode =
GETPOST(
'search_actioncode',
'array:aZ09', 3);
140 if (!count($actioncode)) {
144 $actioncode =
GETPOST(
"search_actioncode",
"alpha", 3) ?
GETPOST(
"search_actioncode",
"alpha", 3) : (
GETPOST(
"search_actioncode") ==
'0' ?
'0' : ((!
getDolGlobalString(
'AGENDA_DEFAULT_FILTER_TYPE') || $disabledefaultvalues) ?
'' :
getDolGlobalString(
'AGENDA_DEFAULT_FILTER_TYPE')));
146if (is_scalar($actioncode) && $actioncode ==
'-1') {
157 $mode = $defaultview;
159if ($mode ==
'default') {
160 $mode = (($defaultview !=
'show_list') ? $defaultview :
'show_month');
164 $mode =
'show_month';
170 $week = ($week ? $week :
date(
"W"));
171 $day = ($day ? $day :
date(
"d"));
176 $day = ($day ? $day :
date(
"d"));
182$langs->loadLangs(array(
'agenda',
'other',
'commercial'));
185$hookmanager->initHooks(array(
'agenda'));
187$result =
restrictedArea($user,
'agenda', 0,
'actioncomm&societe',
'myactions|allactions',
'fk_soc',
'id');
188if ($user->socid && $socid) {
192require_once DOL_DOCUMENT_ROOT.
'/core/redirect_if_setup_not_complete.inc.php';
199if (
GETPOST(
"viewlist",
'alpha') || $mode ==
'show_list') {
201 if (is_array($_POST)) {
202 foreach ($_POST as $key => $val) {
203 if ($key ==
'token') {
206 $param .=
'&'.urlencode($key).
'='.urlencode($val);
209 if (!preg_match(
'/action=/', $param)) {
210 $param .= ($param ?
'&' :
'').
'mode=show_list';
213 header(
"Location: ".DOL_URL_ROOT.
'/comm/action/list.php?'.$param);
217if (
GETPOST(
"viewperuser",
'alpha') || $mode ==
'show_peruser') {
219 if (is_array($_POST)) {
220 foreach ($_POST as $key => $val) {
221 if ($key ==
'token') {
224 $param .=
'&'.urlencode($key).
'='.urlencode($val);
228 header(
"Location: ".DOL_URL_ROOT.
'/comm/action/peruser.php?'.$param);
244 'maxprint' => $maxprint,
246 'filtert' => $filtert,
247 'showbirthday' => $check_birthday,
248 'canedit' => $canedit,
249 'optioncss' => $optioncss,
250 'actioncode' => $actioncode,
252 'resourceid' => $resourceid,
253 'usergroup' => $usergroup,
255$reshook = $hookmanager->executeHooks(
'beforeAgenda', $parameters, $object, $action);
257 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
260$form =
new Form($db);
261$companystatic =
new Societe($db);
262$contactstatic =
new Contact($db);
263$userstatic =
new User($db);
265$help_url =
'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda|DE:Modul_Terminplanung';
266llxHeader(
'', $langs->trans(
"Agenda"), $help_url);
270$nowyear = $nowarray[
'year'];
271$nowmonth = $nowarray[
'mon'];
272$nowday = $nowarray[
'mday'];
274$listofextcals = array();
279 while ($i < $MAXAGENDA) {
281 $source =
'AGENDA_EXT_SRC'.$i;
282 $name =
'AGENDA_EXT_NAME'.$i;
283 $offsettz =
'AGENDA_EXT_OFFSETTZ'.$i;
284 $color =
'AGENDA_EXT_COLOR'.$i;
285 $enabled =
'AGENDA_EXT_ENABLED'.$i;
286 $default =
'AGENDA_EXT_ACTIVEBYDEFAULT'.$i;
287 $buggedfile =
'AGENDA_EXT_BUGGEDFILE'.$i;
290 $listofextcals[] = array(
291 'type' =>
'globalsetup',
308 while ($i < $MAXAGENDA) {
310 $source =
'AGENDA_EXT_SRC_'.$user->id.
'_'.$i;
311 $name =
'AGENDA_EXT_NAME_'.$user->id.
'_'.$i;
312 $offsettz =
'AGENDA_EXT_OFFSETTZ_'.$user->id.
'_'.$i;
313 $color =
'AGENDA_EXT_COLOR_'.$user->id.
'_'.$i;
314 $enabled =
'AGENDA_EXT_ENABLED_'.$user->id.
'_'.$i;
315 $default =
'AGENDA_EXT_ACTIVEBYDEFAULT_'.$user->id.
'_'.$i;
316 $buggedfile =
'AGENDA_EXT_BUGGEDFILE_'.$user->id.
'_'.$i;
320 $listofextcals[] = array(
321 'type' =>
'usersetup',
324 'offsettz' => (
int) (empty($user->conf->$offsettz) ? 0 : $user->
conf->$offsettz),
326 'cachedelay' =>
getDolUserInt(
'AGENDA_EXT_CACHE_'.$user->id.
'_'.$i, 0),
336$max_day_in_month = 0;
347$max_day_in_prev_month = 0;
351if (empty($mode) || $mode ==
'show_month') {
353 $prev_year = $prev[
'year'];
354 $prev_month = $prev[
'month'];
356 $next_year = $next[
'year'];
357 $next_month = $next[
'month'];
359 $max_day_in_prev_month = (int)
date(
"t",
dol_mktime(12, 0, 0, $prev_month, 1, $prev_year,
'gmt'));
360 $max_day_in_month = (int)
date(
"t",
dol_mktime(12, 0, 0, $month, 1, $year,
'gmt'));
362 $tmpday = - (int)
date(
"w",
dol_mktime(12, 0, 0, $month, 1, $year,
'gmt')) + 2;
368 $firstdaytoshow =
dol_mktime(0, 0, 0, $prev_month, $max_day_in_prev_month + $tmpday, $prev_year,
'tzuserrel');
369 $next_day = 7 - ($max_day_in_month + 1 - $tmpday) % 7;
373 $lastdaytoshow =
dol_mktime(0, 0, 0, $next_month, $next_day, $next_year,
'tzuserrel');
375if ($mode ==
'show_week') {
377 $prev_year = $prev[
'prev_year'];
378 $prev_month = $prev[
'prev_month'];
379 $prev_day = $prev[
'prev_day'];
380 $first_day = $prev[
'first_day'];
381 $first_month = $prev[
'first_month'];
382 $first_year = $prev[
'first_year'];
384 $week = $prev[
'week'];
388 $next_year = $next[
'year'];
389 $next_month = $next[
'month'];
390 $next_day = $next[
'day'];
393 $firstdaytoshow =
dol_mktime(0, 0, 0, $first_month, $first_day, $first_year,
'tzuserrel');
396 $max_day_in_month =
date(
"t",
dol_mktime(0, 0, 0, $month, 1, $year,
'gmt'));
398 $tmpday = $first_day;
400if ($mode ==
'show_day') {
402 $prev_year = $prev[
'year'];
403 $prev_month = $prev[
'month'];
404 $prev_day = $prev[
'day'];
406 $next_year = $next[
'year'];
407 $next_month = $next[
'month'];
408 $next_day = $next[
'day'];
410 $firstdaytoshow =
dol_mktime(0, 0, 0, $prev_month, $prev_day, $prev_year,
'tzuserrel');
411 $lastdaytoshow =
dol_mktime(0, 0, 0, $next_month, $next_day, $next_year,
'tzuserrel');
428 if (is_array($actioncode)) {
429 foreach ($actioncode as $str_action) {
430 if ($str_action !=
'-1') {
431 $param .=
"&search_actioncode[]=".urlencode($str_action);
435 $param .=
"&search_actioncode=".urlencode($actioncode);
438if ($resourceid > 0) {
439 $param .=
"&search_resourceid=".urlencode((
string) ($resourceid));
442 $param .=
"&search_status=".urlencode($status);
445 $param .=
"&search_filter=".urlencode((
string) $filter);
448 $param .=
"&search_filtert=".urlencode((
string) $filtert);
451 $param .=
"&search_usergroup=".urlencode((
string) ($usergroup));
454 $param .=
"&search_socid=".urlencode((
string) ($socid));
456if ($check_birthday) {
457 $param .=
"&check_birthday=1";
460 $param .=
"&check_holiday=1";
463 $param .=
"&search_projectid=".urlencode((
string) ($pid));
466 $param .=
"&search_type=".urlencode($type);
468$param .=
"&maxprint=".urlencode((
string) ($maxprint));
469if ($mode ==
'show_day' || $mode ==
'show_week' || $mode ==
'show_month') {
470 $param .=
'&mode='.urlencode($mode);
472if ($search_categ_cus != 0) {
473 $param .=
'&search_categ_cus='.urlencode((
string) ($search_categ_cus));
476 $param .=
'&check_holiday=1';
481$nav .=
'<div class="navselectiondate inline-block nowraponall">';
482if (empty($mode) || $mode ==
'show_month') {
483 $nav .=
"<a href=\"?year=".$prev_year.
"&month=".$prev_month.$param.
"\"><i class=\"fa fa-chevron-left\"></i></a> \n";
484 $nav .=
" <span id=\"month_name\">".dol_print_date(
dol_mktime(0, 0, 0, $month, 1, $year),
"%b %Y");
485 $nav .=
" </span>\n";
486 $nav .=
" <a href=\"?year=".$next_year.
"&month=".$next_month.$param.
"\"><i class=\"fa fa-chevron-right\"></i></a>\n";
489if ($mode ==
'show_week') {
490 $nav .=
"<a href=\"?year=".$prev_year.
"&month=".$prev_month.
"&day=".$prev_day.$param.
"\"><i class=\"fa fa-chevron-left\" title=\"".
dol_escape_htmltag($langs->trans(
"Previous")).
"\"></i></a> \n";
491 $nav .=
" <span id=\"month_name\">".dol_print_date(
dol_mktime(0, 0, 0, $first_month, $first_day, $first_year),
"%Y").
", ".$langs->trans(
"WeekShort").
" ".$week;
492 $nav .=
" </span>\n";
493 $nav .=
" <a href=\"?year=".$next_year.
"&month=".$next_month.
"&day=".$next_day.$param.
"\"><i class=\"fa fa-chevron-right\" title=\"".
dol_escape_htmltag($langs->trans(
"Next")).
"\"></i></a>\n";
494 $picto =
'calendarweek';
496if ($mode ==
'show_day') {
497 $nav .=
"<a href=\"?year=".$prev_year.
"&month=".$prev_month.
"&day=".$prev_day.$param.
"\"><i class=\"fa fa-chevron-left\"></i></a> \n";
498 $nav .=
" <span id=\"month_name\">".dol_print_date(
dol_mktime(0, 0, 0, $month, $day, $year),
"daytextshort");
499 $nav .=
" </span>\n";
500 $nav .=
" <a href=\"?year=".$next_year.
"&month=".$next_month.
"&day=".$next_day.$param.
"\"><i class=\"fa fa-chevron-right\"></i></a>\n";
501 $picto =
'calendarday';
503if (empty(
$conf->dol_optimize_smallscreen)) {
504 $nav .=
' <a href="?year='.$nowyear.
'&month='.$nowmonth.
'&day='.$nowday.$param.
'" class="datenowlink marginleftonly marginrightonly">'.$langs->trans(
"Today").
'</a> ';
508$nav .= $form->selectDate($dateselect,
'dateselect', 0, 0, 1,
'', 1, 0);
510$nav .=
'<button type="submit" class="liste_titre button_search valignmiddle" name="button_search_x" value="x"><span class="fa fa-search"></span></button>';
513$paramnodate = $param;
514$param .=
'&year='.$year.
'&month='.$month.($day ?
'&day='.$day :
'');
529$paramnoaction = preg_replace(
'/mode=[a-z_]+/',
'', preg_replace(
'/action=[a-z_]+/',
'', $param));
530$paramnoactionodate = preg_replace(
'/mode=[a-z_]+/',
'', preg_replace(
'/action=[a-z_]+/',
'', $paramnodate));
534print
'<form method="POST" id="searchFormList" class="listactionsfilter" action="'.$_SERVER[
"PHP_SELF"].
'" spellcheck="false">'.
"\n";
535if ($optioncss !=
'') {
536 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
538print
'<input type="hidden" name="token" value="'.newToken().
'">';
539print
'<input type="hidden" name="mode" value="'.$mode.
'">';
542$viewmode =
'<div class="navmode inline-block">';
544$viewmode .=
'<a class="btnTitle'.($mode ==
'list' ?
' btnTitleSelected' :
'').
' reposition" href="'.DOL_URL_ROOT.
'/comm/action/list.php?mode=show_list&restore_lastsearch_values=1'.$paramnoactionodate.
'">';
546$viewmode .= img_picto($langs->trans(
"List"),
'object_calendarlist',
'class="imgforviewmode pictoactionview block"');
548$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow">'.$langs->trans(
"ViewList").
'</span></a>';
550$viewmode .=
'<a class="btnTitle'.($mode ==
'show_month' ?
' btnTitleSelected' :
'').
' reposition" href="'.DOL_URL_ROOT.
'/comm/action/index.php?mode=show_month&year='.(isset(
$object->datep) ?
dol_print_date(
$object->datep,
'%Y') : $year).
'&month='.(isset(
$object->datep) ?
dol_print_date(
$object->datep,
'%m') : $month).
'&day='.(isset(
$object->datep) ?
dol_print_date(
$object->datep,
'%d') : $day).$paramnoactionodate.
'">';
552$viewmode .= img_picto($langs->trans(
"ViewCal"),
'object_calendarmonth',
'class="pictoactionview block"');
554$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow">'.$langs->trans(
"ViewCal").
'</span></a>';
556$viewmode .=
'<a class="btnTitle'.($mode ==
'show_week' ?
' btnTitleSelected' :
'').
' reposition" href="'.DOL_URL_ROOT.
'/comm/action/index.php?mode=show_week&year='.(isset(
$object->datep) ?
dol_print_date(
$object->datep,
'%Y') : $year).
'&month='.(isset(
$object->datep) ?
dol_print_date(
$object->datep,
'%m') : $month).
'&day='.(isset(
$object->datep) ?
dol_print_date(
$object->datep,
'%d') : $day).$paramnoactionodate.
'">';
558$viewmode .= img_picto($langs->trans(
"ViewWeek"),
'object_calendarweek',
'class="pictoactionview block"');
560$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow">'.$langs->trans(
"ViewWeek").
'</span></a>';
562$viewmode .=
'<a class="btnTitle'.($mode ==
'show_day' ?
' btnTitleSelected' :
'').
' reposition" href="'.DOL_URL_ROOT.
'/comm/action/index.php?mode=show_day&year='.(isset(
$object->datep) ?
dol_print_date(
$object->datep,
'%Y') : $year).
'&month='.(isset(
$object->datep) ?
dol_print_date(
$object->datep,
'%m') : $month).
'&day='.(isset(
$object->datep) ?
dol_print_date(
$object->datep,
'%d') : $day).$paramnoactionodate.
'">';
564$viewmode .= img_picto($langs->trans(
"ViewDay"),
'object_calendarday',
'class="pictoactionview block"');
566$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow">'.$langs->trans(
"ViewDay").
'</span></a>';
568$viewmode .=
'<a class="btnTitle'.($mode ==
'show_peruser' ?
' btnTitleSelected' :
'').
' reposition" href="'.DOL_URL_ROOT.
'/comm/action/peruser.php?mode=show_peruser&year='.(isset(
$object->datep) ?
dol_print_date(
$object->datep,
'%Y') : $year).
'&month='.(isset(
$object->datep) ?
dol_print_date(
$object->datep,
'%m') : $month).
'&day='.(isset(
$object->datep) ?
dol_print_date(
$object->datep,
'%d') : $day).$paramnoactionodate.
'">';
570$viewmode .= img_picto($langs->trans(
"ViewPerUser"),
'object_calendarperuser',
'class="pictoactionview block"');
572$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow" title="'.dolPrintHTML($langs->trans(
"ViewPerUser")).
'">'.$langs->trans(
"ViewPerUser").
'</span></a>';
575$parameters = array();
577$reshook = $hookmanager->executeHooks(
'addCalendarView', $parameters, $object, $action);
578if (empty($reshook)) {
579 $viewmode .= $hookmanager->resPrint;
580} elseif ($reshook > 1) {
581 $viewmode = $hookmanager->resPrint;
584$viewmode .=
'</div>';
586$viewmode .=
'<span class="marginrightonly"></span>';
591if ($user->hasRight(
'agenda',
'myactions',
'create') || $user->hasRight(
'agenda',
'allactions',
'create')) {
594 $newparam .=
'&month='.((int) $month).
'&year='.((int) $tmpforcreatebutton[
'year']).
'&mode='.urlencode($mode);
599 $urltocreateaction = DOL_URL_ROOT.
'/comm/action/card.php?action=create';
600 $urltocreateaction .=
'&apyear='.$tmpforcreatebutton[
'year'].
'&apmonth='.$tmpforcreatebutton[
'mon'].
'&apday='.$tmpforcreatebutton[
'mday'].
'&aphour='.$tmpforcreatebutton[
'hours'].
'&apmin='.$tmpforcreatebutton[
'minutes'];
601 $urltocreateaction .=
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].($newparam ?
'?'.$newparam :
''));
603 $newcardbutton .=
dolGetButtonTitle($langs->trans(
"AddAction"),
'',
'fa fa-plus-circle', $urltocreateaction);
610$showextcals = $listofextcals;
611$bookcalcalendars = array();
615 $sql =
"SELECT ba.rowid, bc.label, bc.ref, bc.rowid as id_cal";
616 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bookcal_availabilities as ba";
617 $sql .=
" JOIN ".MAIN_DB_PREFIX.
"bookcal_calendar as bc";
618 $sql .=
" ON bc.rowid = ba.fk_bookcal_calendar";
619 $sql .=
" WHERE bc.status = 1";
620 $sql .=
" AND ba.status = 1";
621 $sql .=
" AND bc.entity IN (".getEntity(
'agenda').
")";
622 if (!empty($filtert) && $filtert !=
'-1') {
623 $sql .=
" AND bc.visibility IN (".$db->sanitize($filtert, 0, 0, 0, 0).
")";
625 $resql = $db->query($sql);
627 $num = $db->num_rows($resql);
630 $objp = $db->fetch_object($resql);
631 $label = !empty($objp->label) ? $objp->label : $objp->ref;
632 $bookcalcalendars[
"calendars"][$objp->id_cal] = array(
"id" => $objp->id_cal,
"label" => $label);
633 $bookcalcalendars[
"availabilitieslink"][$objp->rowid] = $objp->id_cal;
637 dol_print_error($db);
641if (!empty(
$conf->use_javascript_ajax)) {
642 $s .=
"\n".
'<!-- Div to calendars selectors -->'.
"\n";
644 $s .=
'<script type="text/javascript">'.
"\n";
645 $s .=
'jQuery(document).ready(function () {'.
"\n";
646 $s .=
'jQuery(".check_birthday").click(function() { console.log("Toggle class .family_birthday"); jQuery(".family_birthday").toggle(); });'.
"\n";
647 $s .=
'jQuery(".check_holiday").click(function() { console.log("Toggle class .family_holiday"); jQuery(".family_holiday").toggle(); jQuery(this).closest("form").submit(); });'.
"\n";
648 if (
isModEnabled(
"bookcal") && !empty($bookcalcalendars[
"calendars"])) {
649 foreach ($bookcalcalendars[
"calendars"] as $key => $value) {
650 $s .=
'jQuery(".check_bookcal_calendar_'.$value[
'id'].
'").click(function() { console.log("Toggle Bookcal Calendar '.$value[
'id'].
'"); jQuery(".family_bookcal_calendar_'.$value[
'id'].
'").toggle(); });'.
"\n";
653 if ($mode ==
"show_week" || $mode ==
"show_month" || empty($mode)) {
655 $s .=
'jQuery( "div.sortable" ).sortable({connectWith: ".sortable", placeholder: "ui-state-highlight", items: "div.movable", receive: function( event, ui ) {'.
"\n";
657 $s .=
'console.log("submit form to record new event");'.
"\n";
659 $s .=
'var newval = jQuery(event.target).closest("div.dayevent").attr("id");'.
"\n";
660 $s .=
'console.log("found parent div.dayevent with id = "+newval);'.
"\n";
661 $s .=
'var frm=jQuery("#searchFormList");'.
"\n";
662 $s .=
'var newurl = ui.item.find("a.cal_event").attr("href");'.
"\n";
663 $s .=
'console.log("Found url on href of a.cal_event"+newurl+", we submit form with actionmove=mupdate");'.
"\n";
664 $s .=
'frm.attr("action", newurl).children("#newdate").val(newval);frm.submit();}'.
"\n";
668 $s .=
'</script>'.
"\n";
671 $s .=
'<div class="nowrap inline-block minheight30 hideonsmartphone"><input type="checkbox" id="check_mytasks" name="check_mytasks" value="1" checked disabled><label class="labelcalendar"><span class="check_local_text small"> '.$langs->trans(
"LocalAgenda").
' </span></label></div>';
674 if ($user->hasRight(
"holiday",
"read")) {
676 <div class="nowrap inline-block minheight30"><input type="checkbox" id="check_holiday" name="check_holiday" value="1" class="marginleftonly check_holiday"' . ($check_holiday ?
' checked' :
'') .
'>
677 <label for="check_holiday" class="labelcalendar">
678 <span class="check_holiday_text small">' . $langs->trans(
"Holidays") .
'</span>
684 if (is_array($showextcals) && count($showextcals) > 0) {
685 $s .=
'<script type="text/javascript">'.
"\n";
686 $s .=
'jQuery(document).ready(function () {
687 jQuery("div input[name^=\"check_ext\"]").each(function(index, elem) {
688 var name = jQuery(elem).attr("name");
689 if (jQuery(elem).is(":checked")) {
690 jQuery(".family_ext" + name.replace("check_ext", "")).show();
692 jQuery(".family_ext" + name.replace("check_ext", "")).hide();
696 jQuery("div input[name^=\"check_ext\"]").click(function() {
697 var name = $(this).attr("name");
698 jQuery(".family_ext" + name.replace("check_ext", "")).toggle();
701 $s .=
'</script>'.
"\n";
703 foreach ($showextcals as $val) {
704 $htmlname = md5($val[
'name']);
706 if (!empty($val[
'default']) ||
GETPOSTINT(
'check_ext'.$htmlname)) {
707 $default =
"checked";
712 $cachedelayshown = (!empty($val[
'cachedelay']) && $val[
'cachedelay'] > 0 ? (int) $val[
'cachedelay'] : $DELAYFORCACHE);
713 $tooltip = $langs->trans(
"Cache").
' '.($cachedelayshown < 120 ? $cachedelayshown.
's' : round($cachedelayshown / 60).
'mn');
715 $s .=
'<div class="nowrap inline-block minheight30"><input type="checkbox" id="check_ext'.$htmlname.
'" class="marginleftonly check_ext_'.$htmlname.
'" name="check_ext'.$htmlname.
'" value="1" '.$default.
'><label for="check_ext'.$htmlname.
'" title="'.
dol_escape_htmltag($tooltip).
'" class="labelcalendar"><span class="check_ext_text small">'.
dol_escape_htmltag($val[
'name']).
'</small></label> </div>';
720 $s .=
'<div class="nowrap inline-block minheight30"><input type="checkbox" id="check_birthday" name="check_birthday" class="marginleftonly check_birthday" value="1" '. (
GETPOSTINT(
'check_birthday') ?
' checked' :
'') .
'><label for="check_birthday" class="labelcalendar"><span class="check_birthday_text small">'.$langs->trans(
"AgendaShowBirthdayEvents").
'</span></label> </div>';
724 if (!empty($bookcalcalendars[
"calendars"])) {
725 foreach ($bookcalcalendars[
"calendars"] as $key => $value) {
726 $label = $value[
'label'];
727 $s .=
'<div class="nowrap inline-block minheight30">';
728 $s .=
'<input '.(GETPOST(
'check_bookcal_calendar_'.$value[
'id']) ?
"checked" :
"").
' type="checkbox" id="check_bookcal_calendar_'.$value[
'id'].
'" name="check_bookcal_calendar_'.$value[
'id'].
'" class="marginleftonly check_bookcal_calendar_'.$value[
'id'].
'">';
729 $s .=
'<label for="check_bookcal_calendar_'.$value[
'id'].
'" class="labelcalendar">';
730 $s .=
'<span class="check_bookcal_calendar_'.$value[
'id'].
'_text">'.$langs->trans(
"AgendaShowBookcalCalendar", $label).
'</span>';
731 $s .=
'</label> </div>';
737 $parameters = array();
738 $reshook = $hookmanager->executeHooks(
'addCalendarChoice', $parameters, $object, $action);
739 if (empty($reshook)) {
740 $s .= $hookmanager->resPrint;
741 } elseif ($reshook > 1) {
742 $s = $hookmanager->resPrint;
745 $s .=
"\n".
'<!-- End div to calendars selectors -->'.
"\n";
748 $newparam = preg_replace(
'/check_birthday=[0-1]/i',
'check_birthday='.(empty($check_birthday) ? 1 : 0), $newparam);
749 if (!preg_match(
'/check_birthday=/i', $newparam)) {
750 $newparam .=
'&check_birthday=1';
754 if (empty($check_birthday)) {
755 $s .= $langs->trans(
"AgendaShowBirthdayEvents");
757 $s .= $langs->trans(
"AgendaHideBirthdayEvents");
765 'usergroup' => $usergroup,
766 'filtert' => $filtert,
767 'resourceid' => $resourceid,
768 'actioncode' => $actioncode,
773 'search_categ_cus' => $search_categ_cus,
775$agendaeventresult =
agenda_build_eventarray($db, $hookmanager, $user, $object, $action, $mode, $year, $month, $day, $firstdaytoshow, $lastdaytoshow, $filters);
776$eventarray = $agendaeventresult[
'eventarray'];
777$nbevents = $agendaeventresult[
'nbevents'];
778$MAXONSAMEPAGE = $agendaeventresult[
'maxonsamepage'];
782agenda_get_birthday_events($db, $langs, $user, $mode, $month, $day, $year, $eventarray, $nbevents, $firstdaytoshow, $lastdaytoshow);
786if ($user->hasRight(
"holiday",
"read")) {
787 $sql =
"SELECT u.rowid as uid, u.lastname, u.firstname, u.statut, x.rowid, x.date_debut as date_start, x.date_fin as date_end, x.halfday, x.statut as status";
788 $sql .=
" FROM ".MAIN_DB_PREFIX.
"holiday as x, ".MAIN_DB_PREFIX.
"user as u";
789 $sql .=
" WHERE u.rowid = x.fk_user";
790 $sql .=
" AND u.statut = '1'";
791 $sql .=
" AND (x.statut = '2' OR x.statut = '3')";
792 if ($mode ==
'show_day') {
794 $sql .=
" AND '".$db->escape($year.
"-".$month.
"-".$day).
"' BETWEEN x.date_debut AND x.date_fin";
795 } elseif ($mode ==
'show_week') {
797 $sql .=
" AND x.date_debut < '".$db->idate(
dol_get_last_day($year, $month)).
"'";
799 } elseif ($mode ==
'show_month') {
801 $sql .=
" AND x.date_debut <= '".$db->idate(
dol_get_last_day($year, $month)).
"'";
804 if (!$user->hasRight(
'holiday',
'readall') || $filtert ==
'-3') {
806 $sql .=
" AND x.fk_user IN(".$db->sanitize(implode(
", ", $user->getAllChildIds(1))).
") ";
810 $sql .=
" AND x.fk_user = ".((int) $filtert);
813 $resql = $db->query($sql);
815 $num = $db->num_rows($resql);
820 $obj = $db->fetch_object($resql);
825 $event->id = $obj->rowid;
826 $event->ref = (string) $event->id;
828 $event->type_code =
'HOLIDAY';
829 $event->type_label =
'';
830 $event->type_color =
'';
831 $event->type =
'holiday';
832 $event->type_picto =
'holiday';
836 $event->datep = (int) $db->jdate($obj->date_start,
'gmt') + (empty($obj->halfday) || $obj->halfday == 1 ? 0 : 12) * 60 * 60;
837 $event->datef = (int) $db->jdate($obj->date_end,
'gmt') + (empty($obj->halfday) || $obj->halfday == -1 ? 24 : 12) * 60 * 60 - 1;
838 $event->date_start_in_calendar = $event->datep;
839 $event->date_end_in_calendar = $event->datef;
841 if ($obj->status == 3) {
843 $event->percentage = -1;
844 } elseif ($obj->status == 2) {
846 $event->percentage = 0;
849 $event->label = $langs->trans(
"Holiday");
851 $daycursor = $event->date_start_in_calendar;
856 $daycursorend = $event->date_end_in_calendar;
862 $daykey =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
863 $daykeygmt =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
868 $firstdayofholiday = ($ifornbofdays == 1);
869 $lastdayofholiday = ($daykeygmt ==
dol_get_first_hour($event->date_end_in_calendar,
'gmt'));
878 if ((in_array($obj->halfday, array(1, 2)) == 1 && $lastdayofholiday) || (in_array($obj->halfday, array(-1, 2)) && $firstdayofholiday)) {
881 if (in_array($obj->halfday, array(1, 2)) && $lastdayofholiday) {
882 $newevent->label .=
' ('.$langs->trans(
"Morning").
')';
883 } elseif (in_array($obj->halfday, array(-1, 2)) && $firstdayofholiday) {
884 $newevent->label .=
' ('.$langs->trans(
"Afternoon").
')';
886 $eventarray[$daykey][] = $newevent;
888 $eventarray[$daykey][] = $event;
891 $daykey += 60 * 60 * 24;
892 $daykeygmt += 60 * 60 * 24;
893 }
while ($daykey <= $event->date_end_in_calendar);
902if (count($listofextcals)) {
903 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/ical.class.php';
905 foreach ($listofextcals as $key => $extcal) {
906 $url = $extcal[
'src'];
907 $namecal = $extcal[
'name'];
908 $offsettz = $extcal[
'offsettz'];
909 $colorcal = $extcal[
'color'];
910 $buggedfile = $extcal[
'buggedfile'];
912 if ($extcal[
'type'] ==
'globalsetup') {
923 $ical->parse($url, $pathforcachefile, (!empty($extcal[
'cachedelay']) && $extcal[
'cachedelay'] > 0 ? (
int) $extcal[
'cachedelay'] : $DELAYFORCACHE));
926 $listofextcals[$key][
'error'] = $ical->error;
927 $s .=
'<br><div class="warning">'.dol_escape_htmltag($listofextcals[$key][
'name']).
': '.$url.
'<br>Error message: '.
dol_escape_htmltag($ical->error).
'</div>';
932 $icalevents = array();
933 $tmparray = $ical->get_event_list();
934 if (is_array($tmparray)) {
935 $icalevents = array_merge($icalevents, $tmparray);
937 $tmparray = $ical->get_freebusy_list();
938 if (is_array($tmparray)) {
939 $icalevents = array_merge($icalevents, $tmparray);
942 $icalevents = array_merge($icalevents, $ical->getTodoAndJournalAsEvents());
945 $nbevents += count($icalevents);
947 if (count($icalevents) > 0) {
949 $moreicalevents = array();
950 foreach ($icalevents as $icalkey => $icalevent) {
951 if (!$ical->hasStartDate($icalevent)) {
952 dol_syslog(
"Skip external calendar component without a valid DTSTART", LOG_WARNING);
956 $hasrrule = (isset($icalevent[
'RRULE']) && is_array($icalevent[
'RRULE']));
959 if ($hasrrule || !empty($icalevent[
'RDATE'])) {
962 if (isset($icalevent[
'DTSTART;VALUE=DATE'])) {
964 $datecurend = (empty($icalevent[
'DTEND;VALUE=DATE']) ? $datecurstart + 86400 :
dol_stringtotime($icalevent[
'DTEND;VALUE=DATE'], 1)) - 1;
965 } elseif (isset($icalevent[
'DTSTART']) && !is_array($icalevent[
'DTSTART'])) {
966 $datecurstart = $icalevent[
'DTSTART'];
967 $datecurend = empty($icalevent[
'DTEND']) ? $datecurstart : $icalevent[
'DTEND'];
968 } elseif (is_array($icalevent[
'DTSTART']) && isset($icalevent[
'DTSTART'][
'unixtime']) && $icalevent[
'DTSTART'][
'unixtime'] !==
'') {
969 $datecurstart = $icalevent[
'DTSTART'][
'unixtime'];
970 $datecurend = empty($icalevent[
'DTEND'][
'unixtime']) ? $datecurstart : $icalevent[
'DTEND'][
'unixtime'];
971 $tzidname = (string) ($icalevent[
'DTSTART'][
'TZID'] ??
'');
972 $tzidwall = (empty($buggedfile) && $ical->isTzidKnown($tzidname));
973 if (!$tzidwall && !empty($ical->cal[
'DAYLIGHT'][
'DTSTART']) && $datecurstart) {
975 $tmpcurstart = $datecurstart;
976 $tmpcurend = $datecurend;
977 $tmpdaylightstart =
dol_mktime(0, 0, 0, 1, 1, 1970, 1) + (int) $ical->cal[
'DAYLIGHT'][
'DTSTART'];
978 $tmpdaylightend =
dol_mktime(0, 0, 0, 1, 1, 1970, 1) + (int) $ical->cal[
'STANDARD'][
'DTSTART'];
981 if ($tmpcurstart >= $tmpdaylightstart && $tmpcurstart < $tmpdaylightend) {
982 $datecurstart -= ((int) $ical->cal[
'DAYLIGHT'][
'TZOFFSETTO']) * 36;
984 $datecurstart -= ((int) $ical->cal[
'STANDARD'][
'TZOFFSETTO']) * 36;
986 if ($tmpcurend >= $tmpdaylightstart && $tmpcurstart < $tmpdaylightend) {
987 $datecurend -= ((int) $ical->cal[
'DAYLIGHT'][
'TZOFFSETTO']) * 36;
989 $datecurend -= ((int) $ical->cal[
'STANDARD'][
'TZOFFSETTO']) * 36;
996 dol_syslog(
"Found a not recognized repeatable record with unknown date start", LOG_ERR);
1002 $exdates = (isset($icalevent[
'EXDATE']) && is_array($icalevent[
'EXDATE'])) ? $icalevent[
'EXDATE'] : [];
1003 $exdateshift = (isset($icalevent[
'DTSTART']) && is_array($icalevent[
'DTSTART']) && !empty($icalevent[
'DTSTART'][
'unixtime'])) ? ((
int) $icalevent[
'DTSTART'][
'unixtime'] - (int) $datecurstart) : 0;
1004 $firstdatecurstart = $datecurstart;
1005 $occurrenceduration = $datecurend - $datecurstart;
1013 $unsupportedrule = !$ical->isRRuleSupported($icalevent[
'RRULE']);
1014 if ($unsupportedrule) {
1015 dol_syslog(
"Found a repeatable record with a rule not managed by dolibarr code (".json_encode($icalevent[
'RRULE']).
"). Only first occurrence is shown.", LOG_WARNING);
1016 unset($icalevents[$icalkey][
'RRULE']);
1022 $interval = (empty($icalevent[
'RRULE'][
'INTERVAL']) ? 1 : $icalevent[
'RRULE'][
'INTERVAL']);
1023 $until = empty($icalevent[
'RRULE'][
'UNTIL']) ? 0 :
dol_stringtotime($icalevent[
'RRULE'][
'UNTIL'], 1);
1024 $maxrepeat = empty($icalevent[
'RRULE'][
'COUNT']) ? 0 : $icalevent[
'RRULE'][
'COUNT'];
1025 if ($until && ($until + ($datecurend - $datecurstart)) < $firstdaytoshow) {
1028 if ($datecurstart >= $lastdaytoshow + ($tzidwall ? 86400 : 0)) {
1033 if ($hasrrule && ($tzidwall || in_array($icalevent[
'RRULE'][
'FREQ'] ??
'', [
'MINUTELY',
'HOURLY']) || count(array_filter(array_keys($icalevent[
'RRULE']),
function (
string $rulekey): bool {
1034 return strpos($rulekey,
'BY') === 0;
1037 foreach ($ical->expandRRule($icalevent[
'RRULE'], (
int) $datecurstart + $exdateshift, (int) $lastdaytoshow + $exdateshift, ($until ? (
int) $until + $exdateshift : 0), (
int) $firstdaytoshow + $exdateshift - $occurrenceduration - 86400) as $occurrencewall) {
1040 $occurrencestart = (int) $ical->tzidToTimestamp($occurrencewall, $tzidname);
1041 $occurrenceend = (int) $ical->tzidToTimestamp($occurrencewall + $occurrenceduration, $tzidname);
1043 $occurrencestart = $occurrencewall - $exdateshift;
1044 $occurrenceend = $occurrencestart + $occurrenceduration;
1046 if ($occurrenceend < $firstdaytoshow || in_array(gmdate(
'Ymd', $occurrencewall), $exdates)) {
1049 $newevent = $icalevent;
1050 unset($newevent[
'RRULE']);
1051 if (!empty($icalevent[
'DTSTART;VALUE=DATE'])) {
1052 $newevent[
'DTSTART;VALUE=DATE'] =
dol_print_date($occurrencestart,
'%Y%m%d');
1053 $newevent[
'DTEND;VALUE=DATE'] =
dol_print_date($occurrenceend + 1,
'%Y%m%d');
1055 $newevent[
'DTSTART'] = $occurrencestart;
1056 $newevent[
'DTEND'] = $occurrenceend;
1058 $moreicalevents[] = $newevent;
1060 } elseif ($hasrrule) {
1062 while (($datecurstart < $lastdaytoshow) && (empty($maxrepeat) || ($numofevent < $maxrepeat)) && (empty($until) || $datecurstart <= $until)) {
1063 if ($datecurend >= $firstdaytoshow && !in_array(gmdate(
'Ymd', (
int) $datecurstart + $exdateshift), $exdates)) {
1064 $newevent = $icalevent;
1065 unset($newevent[
'RRULE']);
1066 if (!empty($icalevent[
'DTSTART;VALUE=DATE'])) {
1067 $newevent[
'DTSTART;VALUE=DATE'] =
dol_print_date($datecurstart,
'%Y%m%d');
1068 $newevent[
'DTEND;VALUE=DATE'] =
dol_print_date($datecurend + 1,
'%Y%m%d');
1070 $newevent[
'DTSTART'] = $datecurstart;
1071 $newevent[
'DTEND'] = $datecurend;
1073 $moreicalevents[] = $newevent;
1077 $savdatecurstart = $datecurstart;
1078 if ($icalevent[
'RRULE'][
'FREQ'] ==
'DAILY') {
1082 if ($icalevent[
'RRULE'][
'FREQ'] ==
'WEEKLY') {
1085 } elseif ($icalevent[
'RRULE'][
'FREQ'] ==
'MONTHLY') {
1088 } elseif ($icalevent[
'RRULE'][
'FREQ'] ==
'YEARLY') {
1093 if ($savdatecurstart >= $datecurstart) {
1094 dol_syslog(
"Found a rule freq ".$icalevent[
'RRULE'][
'FREQ'].
" not managed by dolibarr code. Assume 1 week frequency.", LOG_ERR);
1095 $datecurstart += 3600 * 24 * 7;
1096 $datecurend += 3600 * 24 * 7;
1102 if (!empty($icalevent[
'RDATE']) && is_array($icalevent[
'RDATE'])) {
1104 foreach ($icalevent[
'RDATE'] as $rdate) {
1105 if (!empty($icalevent[
'DTSTART;VALUE=DATE'])) {
1108 $rdatewall = $ical->ical_date_to_unix($rdate);
1109 $rdatestart = ($tzidwall ? (int) $ical->tzidToTimestamp($rdatewall, $tzidname) : $rdatewall - $exdateshift);
1111 $rdateend = $rdatestart + $occurrenceduration;
1112 if (($tzidwall ? $rdatewall : $rdatestart) == $firstdatecurstart || $rdateend < $firstdaytoshow || $rdatestart >= $lastdaytoshow || in_array(gmdate(
'Ymd', ($tzidwall ? $rdatewall : $rdatestart + $exdateshift)), $exdates)) {
1115 $newevent = $icalevent;
1116 unset($newevent[
'RRULE'], $newevent[
'RDATE']);
1117 if (!empty($icalevent[
'DTSTART;VALUE=DATE'])) {
1118 $newevent[
'DTSTART;VALUE=DATE'] =
dol_print_date($rdatestart,
'%Y%m%d');
1119 $newevent[
'DTEND;VALUE=DATE'] =
dol_print_date($rdateend + 1,
'%Y%m%d');
1121 $newevent[
'DTSTART'] = $rdatestart;
1122 $newevent[
'DTEND'] = $rdateend;
1124 $moreicalevents[] = $newevent;
1129 $icalevents = array_merge($icalevents, $moreicalevents);
1132 foreach ($icalevents as $icalevent) {
1135 if (!$ical->hasStartDate($icalevent)) {
1141 if (!empty($icalevent[
'RRULE'])) {
1148 if (isset($icalevent[
'DTSTART;VALUE=DATE'])) {
1151 if (empty($icalevent[
'DTEND;VALUE=DATE'])) {
1152 $dateend = $datestart + 86400 - 1;
1158 $event->fulldayevent = 1;
1160 } elseif (!is_array($icalevent[
'DTSTART'])) {
1161 $datestart = $icalevent[
'DTSTART'];
1162 $dateend = empty($icalevent[
'DTEND']) ? $datestart : $icalevent[
'DTEND'];
1164 $datestart += +($offsettz * 3600);
1165 $dateend += +($offsettz * 3600);
1170 } elseif (isset($icalevent[
'DTSTART'][
'unixtime'])) {
1171 $datestart = $icalevent[
'DTSTART'][
'unixtime'];
1172 $dateend = $icalevent[
'DTEND'][
'unixtime'];
1175 $tzidconverted =
false;
1176 if (empty($buggedfile)) {
1177 $tzidstart = $ical->tzidToTimestamp((
int) $datestart, (
string) ($icalevent[
'DTSTART'][
'TZID'] ??
''));
1178 if ($tzidstart !==
null) {
1179 $tzidend = $ical->tzidToTimestamp((
int) $dateend, (
string) ($icalevent[
'DTEND'][
'TZID'] ?? ($icalevent[
'DTSTART'][
'TZID'] ??
'')));
1180 $datestart = $tzidstart;
1181 $dateend = ($tzidend !==
null ? $tzidend : $tzidstart + ((int) $dateend - (
int) $icalevent[
'DTSTART'][
'unixtime']));
1182 $tzidconverted =
true;
1186 $datestart += +($offsettz * 3600);
1187 $dateend += +($offsettz * 3600);
1190 if (!$tzidconverted && $buggedfile ===
'uselocalandtznodaylight') {
1194 if (!$tzidconverted && $buggedfile ===
'uselocalandtzdaylight') {
1195 $localtzs =
new DateTimeZone((
string) preg_replace(
'/"/',
'', $icalevent[
'DTSTART'][
'TZID']));
1196 $localtze =
new DateTimeZone((
string) preg_replace(
'/"/',
'', $icalevent[
'DTEND'][
'TZID']));
1197 $localdts =
new DateTime(
dol_print_date($datestart,
'dayrfc',
'gmt'), $localtzs);
1198 $localdte =
new DateTime(
dol_print_date($dateend,
'dayrfc',
'gmt'), $localtze);
1199 $tmps = -1 * $localtzs->getOffset($localdts);
1200 $tmpe = -1 * $localtze->getOffset($localdte);
1201 $datestart += $tmps;
1209 $event->id = $icalevent[
'UID'];
1210 $event->ref = (string) $event->id;
1211 $userId = $userstatic->findUserIdByEmail($namecal);
1212 if (!empty($userId) && $userId > 0) {
1213 $event->userassigned[$userId] = array(
'id' => $userId,
'transparency' => 1);
1214 $event->percentage = -1;
1217 $event->type_code =
"ICALEVENT";
1218 $event->type_label = $namecal;
1219 $event->type_color = $colorcal;
1220 $event->type =
'icalevent';
1221 $event->type_picto =
'rss';
1223 $event->icalname = $namecal;
1224 $event->icalcolor = $colorcal;
1226 $event->datep = (int) ($datestart + $usertime);
1227 $event->datef = (int) ($dateend + $usertime);
1230 $isprivate = (isset($icalevent[
'CLASS']) && is_string($icalevent[
'CLASS']) && in_array(strtoupper(trim($icalevent[
'CLASS'])), [
'PRIVATE',
'CONFIDENTIAL']) && !
getDolGlobalString(
'AGENDA_EXT_SHOW_PRIVATE'));
1233 $event->label = $langs->trans(
"Private");
1234 } elseif (isset($icalevent[
'SUMMARY']) && $icalevent[
'SUMMARY']) {
1236 } elseif (isset($icalevent[
'DESCRIPTION']) && $icalevent[
'DESCRIPTION']) {
1239 $event->label = $langs->trans(
"ExtSiteNoLabel");
1246 if (!empty($icalevent[
'PRIORITY'])) {
1247 $event->priority = $icalevent[
'PRIORITY'];
1251 if (!empty($icalevent[
'TRANSP'])) {
1252 if ($icalevent[
'TRANSP'] ==
"TRANSPARENT") {
1253 $event->transparency = 0;
1255 if ($icalevent[
'TRANSP'] ==
"OPAQUE") {
1256 $event->transparency = 1;
1267 if (!empty($icalevent[
'LOCATION']) && !$isprivate) {
1268 $event->location = $icalevent[
'LOCATION'];
1272 $event->icaldetails = array();
1274 foreach (array(
'DESCRIPTION' =>
'description',
'ORGANIZER' =>
'organizer',
'URL' =>
'url',
'CATEGORIES' =>
'categories',
'GEO' =>
'geo') as $icalproperty => $detailkey) {
1275 if (!empty($icalevent[$icalproperty]) && is_string($icalevent[$icalproperty])) {
1276 $event->icaldetails[$detailkey] = $icalevent[$icalproperty];
1279 if (!empty($icalevent[
'ATTENDEE']) && is_array($icalevent[
'ATTENDEE'])) {
1280 $event->icaldetails[
'attendees'] = $icalevent[
'ATTENDEE'];
1284 $event->date_start_in_calendar = $event->datep;
1286 if ((
int) $event->datef != 0 && $event->datef >= $event->datep) {
1287 $event->date_end_in_calendar = $event->datef;
1289 $event->date_end_in_calendar = $event->datep;
1293 if ($event->date_end_in_calendar < $firstdaytoshow || $event->date_start_in_calendar >= $lastdaytoshow) {
1299 if ($event->date_start_in_calendar < $firstdaytoshow) {
1300 $event->date_start_in_calendar = $firstdaytoshow;
1302 if ($event->date_end_in_calendar >= $lastdaytoshow) {
1303 $event->date_end_in_calendar = ($lastdaytoshow - 1);
1307 $daycursor = $event->date_start_in_calendar;
1316 $daykey =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
1317 $daykeygmt =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
1320 $eventarray[$daykey][] = $event;
1321 $daykey += 60 * 60 * 24;
1322 $daykeygmt += 60 * 60 * 24;
1323 if (($event->fulldayevent ? $daykeygmt : $daykey) > $event->date_end_in_calendar) {
1335$parameters = array();
1337$reshook = $hookmanager->executeHooks(
'getCalendarEvents', $parameters, $object, $action);
1338if (!empty($hookmanager->resArray[
'eventarray'])) {
1339 foreach ($hookmanager->resArray[
'eventarray'] as $keyDate => $events) {
1340 if (!isset($eventarray[$keyDate])) {
1341 $eventarray[$keyDate] = array();
1343 $eventarray[$keyDate] = array_merge($eventarray[$keyDate], $events);
1348foreach ($eventarray as $keyDate => &$dateeventarray) {
1349 usort($dateeventarray,
'sort_events_by_date');
1354$cachethirdparties = array();
1355$cachecontacts = array();
1359 array(137, 86, 161),
1360 array(60, 147, 183),
1361 array(250, 190, 80),
1363 array(190, 190, 100),
1364 array(91, 115, 247),
1365 array(140, 140, 220),
1366 array(190, 120, 120),
1367 array(115, 125, 150),
1368 array(100, 170, 20),
1369 array(150, 135, 125),
1370 array(85, 135, 150),
1371 array(150, 135, 80),
1377if ($color_file && is_readable($color_file)) {
1379 include $color_file;
1383$massactionbutton =
'';
1385print_barre_liste($langs->trans(
"Agenda"), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, 1, -1,
'object_action', 0, $nav.
'<span class="marginleftonly"></span>'.$newcardbutton,
'', $limit, 1, 0, 1, $viewmode);
1387if ($nbevents > $MAXONSAMEPAGE) {
1388 print
info_admin(
'Number of results has been truncated to '.$MAXONSAMEPAGE, 0, 0,
'warning').
'<br>';
1395if (empty($mode) || $mode ==
'show_month') {
1397 $newparam = preg_replace(
'/check_birthday=/i',
'check_birthday_=', $newparam);
1398 $newparam = preg_replace(
'/mode=show_month&?/i',
'', $newparam);
1399 $newparam = preg_replace(
'/mode=show_week&?/i',
'', $newparam);
1400 $newparam = preg_replace(
'/day=[0-9]+&?/i',
'', $newparam);
1401 $newparam = preg_replace(
'/month=[0-9]+&?/i',
'', $newparam);
1402 $newparam = preg_replace(
'/year=[0-9]+&?/i',
'', $newparam);
1403 $newparam = preg_replace(
'/viewcal=[0-9]+&?/i',
'', $newparam);
1404 $newparam = preg_replace(
'/check_birthday_=/i',
'check_birthday=', $newparam);
1405 $newparam .=
'&viewcal=1';
1407 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1408 print_actions_filter($form, $canedit, $status, $year, $month, $day, $check_birthday,
'', $filtert,
'', $pid, $socid, $action, -1, $actioncode, $usergroupids,
'', $resourceid, $search_categ_cus);
1411 print
'<div class="div-table-responsive-no-min sectioncalendarbymonth maxscreenheightless300">';
1412 print
'<table class="centpercent noborder nocellnopadd cal_pannel cal_month listwithfilterbefore">';
1413 print
' <tr class="liste_titre stickyagenda">';
1415 echo
' <td class="center">#</td>';
1418 print
' <td class="center bold uppercase tdfordaytitle'.($i == 0 ?
' borderleft' :
'').
'">';
1420 if (!empty(
$conf->dol_optimize_smallscreen)) {
1421 $labelshort = array(0 =>
'SundayMin', 1 =>
'MondayMin', 2 =>
'TuesdayMin', 3 =>
'WednesdayMin', 4 =>
'ThursdayMin', 5 =>
'FridayMin', 6 =>
'SaturdayMin');
1422 print $langs->trans($labelshort[$numdayinweek]);
1424 print $langs->trans(
"Day".$numdayinweek);
1426 print
' </td>'.
"\n";
1432 $todaytms =
dol_mktime(0, 0, 0, $todayarray[
'mon'], $todayarray[
'mday'], $todayarray[
'year']);
1436 for ($iter_week = 0; $iter_week < 6; $iter_week++) {
1440 $currdate0 = sprintf(
"%04d", $prev_year).sprintf(
"%02d", $prev_month).sprintf(
"%02d", $max_day_in_prev_month + $tmpday);
1441 } elseif ($tmpday <= $max_day_in_month) {
1442 $currdate0 = sprintf(
"%04d", $year).sprintf(
"%02d", $month).sprintf(
"%02d", $tmpday);
1444 $currdate0 = sprintf(
"%04d", $next_year).sprintf(
"%02d", $next_month).sprintf(
"%02d", $tmpday - $max_day_in_month);
1447 $numweek0 =
date(
"W", strtotime(
date($currdate0)));
1449 echo
' <td class="center weeknumber opacitymedium" width="2%">'.$numweek0.
'</td>';
1451 for ($iter_day = 0; $iter_day < 7; $iter_day++) {
1454 $style =
'cal_other_month cal_past';
1455 if ($iter_day == 6) {
1456 $style .=
' cal_other_month_right';
1458 echo
' <td class="'.$style.
' nowrap tdtop" width="14%">';
1460 show_day_events($db, $max_day_in_prev_month + $tmpday, $prev_month, $prev_year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam);
1462 } elseif ($tmpday <= $max_day_in_month) {
1464 $curtime =
dol_mktime(0, 0, 0, $month, $tmpday, $year);
1465 $style =
'cal_current_month';
1466 if ($iter_day == 6) {
1467 $style .=
' cal_current_month_right';
1470 if ($todayarray[
'mday'] == $tmpday && $todayarray[
'mon'] == $month && $todayarray[
'year'] == $year) {
1474 $style =
'cal_today';
1476 if ($curtime < $todaytms) {
1477 $style .=
' cal_past';
1480 echo
' <td class="'.$style.
' nowrap tdtop" width="14%">';
1482 show_day_events($db, $tmpday, $month, $year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam, 0, 60, 0, $bookcalcalendars);
1486 $style =
'cal_other_month';
1487 if ($iter_day == 6) {
1488 $style .=
' cal_other_month_right';
1490 echo
' <td class="'.$style.
' nowrap tdtop" width="14%">';
1492 show_day_events($db, $tmpday - $max_day_in_month, $next_month, $next_year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam);
1502 print
'<input type="hidden" name="actionmove" value="mupdate">';
1503 print
'<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($_SERVER[
'PHP_SELF']).
'?mode=show_month&'.
dol_escape_htmltag($_SERVER[
'QUERY_STRING']).
'">';
1504 print
'<input type="hidden" name="newdate" id="newdate">';
1505} elseif ($mode ==
'show_week') {
1508 $newparam = preg_replace(
'/check_birthday=/i',
'check_birthday_=', $newparam);
1509 $newparam = preg_replace(
'/mode=show_month&?/i',
'', $newparam);
1510 $newparam = preg_replace(
'/mode=show_week&?/i',
'', $newparam);
1511 $newparam = preg_replace(
'/day=[0-9]+&?/i',
'', $newparam);
1512 $newparam = preg_replace(
'/month=[0-9]+&?/i',
'', $newparam);
1513 $newparam = preg_replace(
'/year=[0-9]+&?/i',
'', $newparam);
1514 $newparam = preg_replace(
'/viewweek=[0-9]+&?/i',
'', $newparam);
1515 $newparam = preg_replace(
'/check_birthday_=/i',
'check_birthday=', $newparam);
1516 $newparam .=
'&viewweek=1';
1518 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1519 print_actions_filter($form, $canedit, $status, $year, $month, $day, $check_birthday,
'', $filtert,
'', $pid, $socid, $action, -1, $actioncode, $usergroupids,
'', $resourceid);
1522 print
'<div class="div-table-responsive-no-min sectioncalendarbyweek maxscreenheightless300">';
1523 print
'<table class="centpercent noborder nocellnopadd cal_pannel cal_month listwithfilterbefore">';
1524 print
' <tr class="liste_titre">';
1527 echo
' <td class="center bold uppercase tdfordaytitle">'.$langs->trans(
"Day".(($i + (
getDolGlobalInt(
'MAIN_START_WEEK', 1))) % 7)).
"</td>\n";
1532 echo
' <tr class="trcalweek">'.
"\n";
1534 for ($iter_day = 0; $iter_day < 7; $iter_day++) {
1541 $style =
'cal_current_month';
1542 if ($iter_day == 6) {
1543 $style .=
' cal_other_month_right';
1548 if ($todayarray[
'mday'] == $tmpday && $todayarray[
'mon'] == $tmpmonth && $todayarray[
'year'] == $tmpyear) {
1552 $style =
'cal_today';
1555 echo
' <td class="'.$style.
'" width="14%" valign="top">';
1557 show_day_events($db, $tmpday, $tmpmonth, $tmpyear, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 0, $bookcalcalendars);
1565 echo
'<input type="hidden" name="actionmove" value="mupdate">';
1566 echo
'<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($_SERVER[
'PHP_SELF']).
'?mode=show_week&'.
dol_escape_htmltag($_SERVER[
'QUERY_STRING']).
'">';
1567 echo
'<input type="hidden" name="newdate" id="newdate">';
1570 $newparam = preg_replace(
'/mode=show_month&?/i',
'', $newparam);
1571 $newparam = preg_replace(
'/mode=show_week&?/i',
'', $newparam);
1572 $newparam = preg_replace(
'/viewday=[0-9]+&?/i',
'', $newparam);
1573 $newparam .=
'&viewday=1';
1575 $style =
'cal_current_month cal_current_month_oneday';
1578 if ($todayarray[
'mday'] == $day && $todayarray[
'mon'] == $month && $todayarray[
'year'] == $year) {
1583 $timestamp =
dol_mktime(12, 0, 0, $month, $day, $year);
1586 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1587 print_actions_filter($form, $canedit, $status, $year, $month, $day, $check_birthday,
'', $filtert,
'', $pid, $socid, $action, -1, $actioncode, $usergroupids,
'', $resourceid);
1590 print
'<div class="div-table-responsive-no-min sectioncalendarbyday maxscreenheightless300">';
1591 echo
'<table class="tagtable centpercent noborder nocellnopadd cal_pannel cal_month listwithfilterbefore" style="margin-bottom: 10px !important;">';
1593 echo
' <tr class="tagtr liste_titre">';
1594 echo
' <td class="tagtd center bold uppercase">'.$langs->trans(
"Day".$arraytimestamp[
'wday']).
"</td>\n";
1606 print
'<tr class="trcalday"><td class="tdtop">';
1611 print
'<div class="div-table-responsive-no-min">';
1613 $maxheightwin = (isset($_SESSION[
"dol_screenheight"]) && $_SESSION[
"dol_screenheight"] > 500) ? ($_SESSION[
"dol_screenheight"] - 200) : 660;
1615 echo
'<div style="max-height: '.$maxheightwin.
'px;">';
1616 echo
'<div class="tagtable centpercent calendarviewcontainer">';
1621 $minhour = round((
float) $tmp[0], 0);
1622 $maxhour = round((
float) $tmp[1], 0);
1623 if ($minhour > 23) {
1629 if ($maxhour <= $minhour) {
1630 $maxhour = $minhour + 1;
1636 echo
' <div class="tagtr calendarviewcontainertr">'.
"\n";
1637 echo
' <div class="tagtd width100 tdtop">'.dol_print_date($i * 3600,
'hour',
'gmt').
'</div>';
1638 echo
' <div class="tagtd '.$style.
' tdtop"></div>'.
"\n";
1639 echo
' </div>'.
"\n";
1644 echo
'</div></div>';
1647 show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 1, $bookcalcalendars);
1651 print
'<div class="div-table-responsive-no-min">';
1654 show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 0, $bookcalcalendars);
1666print
"\n".
'</form>';
1683 if ($a->type_code ===
'HOLIDAY') {
1686 if ($b->type_code ===
'HOLIDAY') {
1697 if ($a->datep !== $b->datep) {
1698 return (
int) $a->datep - (int) $b->datep;
1702 if ((!is_numeric($b->datef)) || (!is_numeric($a->datef))) {
1707 if ($b->datef === $a->datef) {
1712 return (
int) ($b->datef - $a->datef);
1727 if ($a->percentage < 0) {
1731 if ($b->percentage < 0) {
1735 return (
int) ($b->percentage - $a->percentage);
if(! $sortfield) if(! $sortorder) $object
agenda_get_birthday_events($db, $langs, $user, $mode, $month, $day, $year, &$eventarray, &$nbevents, $firstdaytoshow, $lastdaytoshow)
Complete an agenda calendar event array with contact birthday pseudo-events.
print_actions_filter( $form, $canedit, $status, $year, $month, $day, $showbirthday, $filtera, $filtert, $filtered, $pid, $socid, $action, $showextcals=array(), $actioncode='', $usergroupid=0, $excludetype='', $resourceid=0, $search_categ_cus=0, $search_import_key='')
Show filter form in agenda view.
calendars_prepare_head($param)
Define head array for tabs of agenda setup pages.
agenda_build_eventarray($db, $hookmanager, $user, &$object, &$action, $mode, $year, $month, $day, $firstdaytoshow, $lastdaytoshow, $filters, $sincedatec=null)
Build $eventarray (list of ActionComm objects, indexed by day) for the agenda calendar views (month/w...
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
Class to manage agenda events (actions)
Class to read/parse ICal calendars.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
sort_events_by_percentage($a, $b)
Sort events by percentage.
sort_events_by_date($a, $b)
Sort events by date.
dol_get_prev_month($month, $year)
Return previous month.
dol_get_first_hour($date, $gm='tzserver')
Return GMT time for first hour of a given GMT date (it removes hours, min and second part)
dol_get_next_day($day, $month, $year)
Return next day.
dol_get_next_week($day, $week, $month, $year)
Return next week.
dol_get_first_day_week($day, $month, $year, $gm=false)
Return first day of week for a date.
dol_get_prev_day($day, $month, $year)
Return previous day.
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
dol_get_next_month($month, $year)
Return next month.
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0, $tz='')
Add a delay to a date.
dol_stringtotime($string, $gm=1, $processnotimeasnoon=0)
Convert a string date into a GM Timestamps date Warning: YYYY-MM-DDTHH:MM:SS+02:00 (RFC3339) is not s...
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...
getDolUserInt($key, $default=0, $tmpuser=null)
Return Dolibarr user constant int value.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
dol_getThemeFilePath($file, $theme='')
Return the full filesystem path of a file located in the currently selected theme directory.
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
dol_sanitizePathName($str, $newstr='_', $unaccent=0, $allowdash=0)
Clean a string to use it as a path name.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
getDolUserString($key, $default='', $tmpuser=null)
Return Dolibarr user constant string value.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_clone($srcobject, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
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).
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='', $textonpictotooltip='', $cssfordropdown='info_admin')
Show information in HTML for admin users or standard users.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
conf($dolibarr_main_document_root, $realpathconf=null)
Load conf file (file must exists)
print $langs trans('Date')." left Ref 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 Paid right PaymentTypeShortLIQ right SELECT p pos_change as p datep as date
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $nodie=0, $mode='')
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.