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',
307 while ($i < $MAXAGENDA) {
309 $source =
'AGENDA_EXT_SRC_'.$user->id.
'_'.$i;
310 $name =
'AGENDA_EXT_NAME_'.$user->id.
'_'.$i;
311 $offsettz =
'AGENDA_EXT_OFFSETTZ_'.$user->id.
'_'.$i;
312 $color =
'AGENDA_EXT_COLOR_'.$user->id.
'_'.$i;
313 $enabled =
'AGENDA_EXT_ENABLED_'.$user->id.
'_'.$i;
314 $default =
'AGENDA_EXT_ACTIVEBYDEFAULT_'.$user->id.
'_'.$i;
315 $buggedfile =
'AGENDA_EXT_BUGGEDFILE_'.$user->id.
'_'.$i;
319 $listofextcals[] = array(
320 'type' =>
'usersetup',
323 'offsettz' => (
int) (empty($user->conf->$offsettz) ? 0 : $user->
conf->$offsettz),
334$max_day_in_month = 0;
345$max_day_in_prev_month = 0;
349if (empty($mode) || $mode ==
'show_month') {
351 $prev_year = $prev[
'year'];
352 $prev_month = $prev[
'month'];
354 $next_year = $next[
'year'];
355 $next_month = $next[
'month'];
357 $max_day_in_prev_month = (int)
date(
"t",
dol_mktime(12, 0, 0, $prev_month, 1, $prev_year,
'gmt'));
358 $max_day_in_month = (int)
date(
"t",
dol_mktime(12, 0, 0, $month, 1, $year,
'gmt'));
360 $tmpday = - (int)
date(
"w",
dol_mktime(12, 0, 0, $month, 1, $year,
'gmt')) + 2;
366 $firstdaytoshow =
dol_mktime(0, 0, 0, $prev_month, $max_day_in_prev_month + $tmpday, $prev_year,
'tzuserrel');
367 $next_day = 7 - ($max_day_in_month + 1 - $tmpday) % 7;
371 $lastdaytoshow =
dol_mktime(0, 0, 0, $next_month, $next_day, $next_year,
'tzuserrel');
373if ($mode ==
'show_week') {
375 $prev_year = $prev[
'prev_year'];
376 $prev_month = $prev[
'prev_month'];
377 $prev_day = $prev[
'prev_day'];
378 $first_day = $prev[
'first_day'];
379 $first_month = $prev[
'first_month'];
380 $first_year = $prev[
'first_year'];
382 $week = $prev[
'week'];
386 $next_year = $next[
'year'];
387 $next_month = $next[
'month'];
388 $next_day = $next[
'day'];
391 $firstdaytoshow =
dol_mktime(0, 0, 0, $first_month, $first_day, $first_year,
'tzuserrel');
394 $max_day_in_month =
date(
"t",
dol_mktime(0, 0, 0, $month, 1, $year,
'gmt'));
396 $tmpday = $first_day;
398if ($mode ==
'show_day') {
400 $prev_year = $prev[
'year'];
401 $prev_month = $prev[
'month'];
402 $prev_day = $prev[
'day'];
404 $next_year = $next[
'year'];
405 $next_month = $next[
'month'];
406 $next_day = $next[
'day'];
408 $firstdaytoshow =
dol_mktime(0, 0, 0, $prev_month, $prev_day, $prev_year,
'tzuserrel');
409 $lastdaytoshow =
dol_mktime(0, 0, 0, $next_month, $next_day, $next_year,
'tzuserrel');
426 if (is_array($actioncode)) {
427 foreach ($actioncode as $str_action) {
428 if ($str_action !=
'-1') {
429 $param .=
"&search_actioncode[]=".urlencode($str_action);
433 $param .=
"&search_actioncode=".urlencode($actioncode);
436if ($resourceid > 0) {
437 $param .=
"&search_resourceid=".urlencode((
string) ($resourceid));
440 $param .=
"&search_status=".urlencode($status);
443 $param .=
"&search_filter=".urlencode((
string) $filter);
446 $param .=
"&search_filtert=".urlencode((
string) $filtert);
449 $param .=
"&search_usergroup=".urlencode((
string) ($usergroup));
452 $param .=
"&search_socid=".urlencode((
string) ($socid));
454if ($check_birthday) {
455 $param .=
"&check_birthday=1";
458 $param .=
"&check_holiday=1";
461 $param .=
"&search_projectid=".urlencode((
string) ($pid));
464 $param .=
"&search_type=".urlencode($type);
466$param .=
"&maxprint=".urlencode((
string) ($maxprint));
467if ($mode ==
'show_day' || $mode ==
'show_week' || $mode ==
'show_month') {
468 $param .=
'&mode='.urlencode($mode);
470if ($search_categ_cus != 0) {
471 $param .=
'&search_categ_cus='.urlencode((
string) ($search_categ_cus));
474 $param .=
'&check_holiday=1';
479$nav .=
'<div class="navselectiondate inline-block nowraponall">';
480if (empty($mode) || $mode ==
'show_month') {
481 $nav .=
"<a href=\"?year=".$prev_year.
"&month=".$prev_month.$param.
"\"><i class=\"fa fa-chevron-left\"></i></a> \n";
482 $nav .=
" <span id=\"month_name\">".dol_print_date(
dol_mktime(0, 0, 0, $month, 1, $year),
"%b %Y");
483 $nav .=
" </span>\n";
484 $nav .=
" <a href=\"?year=".$next_year.
"&month=".$next_month.$param.
"\"><i class=\"fa fa-chevron-right\"></i></a>\n";
487if ($mode ==
'show_week') {
488 $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";
489 $nav .=
" <span id=\"month_name\">".dol_print_date(
dol_mktime(0, 0, 0, $first_month, $first_day, $first_year),
"%Y").
", ".$langs->trans(
"WeekShort").
" ".$week;
490 $nav .=
" </span>\n";
491 $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";
492 $picto =
'calendarweek';
494if ($mode ==
'show_day') {
495 $nav .=
"<a href=\"?year=".$prev_year.
"&month=".$prev_month.
"&day=".$prev_day.$param.
"\"><i class=\"fa fa-chevron-left\"></i></a> \n";
496 $nav .=
" <span id=\"month_name\">".dol_print_date(
dol_mktime(0, 0, 0, $month, $day, $year),
"daytextshort");
497 $nav .=
" </span>\n";
498 $nav .=
" <a href=\"?year=".$next_year.
"&month=".$next_month.
"&day=".$next_day.$param.
"\"><i class=\"fa fa-chevron-right\"></i></a>\n";
499 $picto =
'calendarday';
501if (empty(
$conf->dol_optimize_smallscreen)) {
502 $nav .=
' <a href="?year='.$nowyear.
'&month='.$nowmonth.
'&day='.$nowday.$param.
'" class="datenowlink marginleftonly marginrightonly">'.$langs->trans(
"Today").
'</a> ';
506$nav .= $form->selectDate($dateselect,
'dateselect', 0, 0, 1,
'', 1, 0);
508$nav .=
'<button type="submit" class="liste_titre button_search valignmiddle" name="button_search_x" value="x"><span class="fa fa-search"></span></button>';
511$paramnodate = $param;
512$param .=
'&year='.$year.
'&month='.$month.($day ?
'&day='.$day :
'');
527$paramnoaction = preg_replace(
'/mode=[a-z_]+/',
'', preg_replace(
'/action=[a-z_]+/',
'', $param));
528$paramnoactionodate = preg_replace(
'/mode=[a-z_]+/',
'', preg_replace(
'/action=[a-z_]+/',
'', $paramnodate));
532print
'<form method="POST" id="searchFormList" class="listactionsfilter" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
533if ($optioncss !=
'') {
534 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
536print
'<input type="hidden" name="token" value="'.newToken().
'">';
537print
'<input type="hidden" name="mode" value="'.$mode.
'">';
540$viewmode =
'<div class="navmode inline-block">';
542$viewmode .=
'<a class="btnTitle'.($mode ==
'list' ?
' btnTitleSelected' :
'').
' reposition" href="'.DOL_URL_ROOT.
'/comm/action/list.php?mode=show_list&restore_lastsearch_values=1'.$paramnoactionodate.
'">';
544$viewmode .= img_picto($langs->trans(
"List"),
'object_calendarlist',
'class="imgforviewmode pictoactionview block"');
546$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow">'.$langs->trans(
"ViewList").
'</span></a>';
548$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.
'">';
550$viewmode .= img_picto($langs->trans(
"ViewCal"),
'object_calendarmonth',
'class="pictoactionview block"');
552$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow">'.$langs->trans(
"ViewCal").
'</span></a>';
554$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.
'">';
556$viewmode .= img_picto($langs->trans(
"ViewWeek"),
'object_calendarweek',
'class="pictoactionview block"');
558$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow">'.$langs->trans(
"ViewWeek").
'</span></a>';
560$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.
'">';
562$viewmode .= img_picto($langs->trans(
"ViewDay"),
'object_calendarday',
'class="pictoactionview block"');
564$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow">'.$langs->trans(
"ViewDay").
'</span></a>';
566$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.
'">';
568$viewmode .= img_picto($langs->trans(
"ViewPerUser"),
'object_calendarperuser',
'class="pictoactionview block"');
570$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow" title="'.dolPrintHTML($langs->trans(
"ViewPerUser")).
'">'.$langs->trans(
"ViewPerUser").
'</span></a>';
573$parameters = array();
575$reshook = $hookmanager->executeHooks(
'addCalendarView', $parameters, $object, $action);
576if (empty($reshook)) {
577 $viewmode .= $hookmanager->resPrint;
578} elseif ($reshook > 1) {
579 $viewmode = $hookmanager->resPrint;
582$viewmode .=
'</div>';
584$viewmode .=
'<span class="marginrightonly"></span>';
589if ($user->hasRight(
'agenda',
'myactions',
'create') || $user->hasRight(
'agenda',
'allactions',
'create')) {
592 $newparam .=
'&month='.((int) $month).
'&year='.((int) $tmpforcreatebutton[
'year']).
'&mode='.urlencode($mode);
597 $urltocreateaction = DOL_URL_ROOT.
'/comm/action/card.php?action=create';
598 $urltocreateaction .=
'&apyear='.$tmpforcreatebutton[
'year'].
'&apmonth='.$tmpforcreatebutton[
'mon'].
'&apday='.$tmpforcreatebutton[
'mday'].
'&aphour='.$tmpforcreatebutton[
'hours'].
'&apmin='.$tmpforcreatebutton[
'minutes'];
599 $urltocreateaction .=
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].($newparam ?
'?'.$newparam :
''));
601 $newcardbutton .=
dolGetButtonTitle($langs->trans(
"AddAction"),
'',
'fa fa-plus-circle', $urltocreateaction);
608$showextcals = $listofextcals;
609$bookcalcalendars = array();
613 $sql =
"SELECT ba.rowid, bc.label, bc.ref, bc.rowid as id_cal";
614 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bookcal_availabilities as ba";
615 $sql .=
" JOIN ".MAIN_DB_PREFIX.
"bookcal_calendar as bc";
616 $sql .=
" ON bc.rowid = ba.fk_bookcal_calendar";
617 $sql .=
" WHERE bc.status = 1";
618 $sql .=
" AND ba.status = 1";
619 $sql .=
" AND bc.entity IN (".getEntity(
'agenda').
")";
620 if (!empty($filtert) && $filtert !=
'-1') {
621 $sql .=
" AND bc.visibility IN (".$db->sanitize($filtert, 0, 0, 0, 0).
")";
623 $resql = $db->query($sql);
625 $num = $db->num_rows($resql);
628 $objp = $db->fetch_object($resql);
629 $label = !empty($objp->label) ? $objp->label : $objp->ref;
630 $bookcalcalendars[
"calendars"][$objp->id_cal] = array(
"id" => $objp->id_cal,
"label" => $label);
631 $bookcalcalendars[
"availabilitieslink"][$objp->rowid] = $objp->id_cal;
635 dol_print_error($db);
639if (!empty(
$conf->use_javascript_ajax)) {
640 $s .=
"\n".
'<!-- Div to calendars selectors -->'.
"\n";
642 $s .=
'<script type="text/javascript">'.
"\n";
643 $s .=
'jQuery(document).ready(function () {'.
"\n";
644 $s .=
'jQuery(".check_birthday").click(function() { console.log("Toggle class .family_birthday"); jQuery(".family_birthday").toggle(); });'.
"\n";
645 $s .=
'jQuery(".check_holiday").click(function() { console.log("Toggle class .family_holiday"); jQuery(".family_holiday").toggle(); jQuery(this).closest("form").submit(); });'.
"\n";
646 if (
isModEnabled(
"bookcal") && !empty($bookcalcalendars[
"calendars"])) {
647 foreach ($bookcalcalendars[
"calendars"] as $key => $value) {
648 $s .=
'jQuery(".check_bookcal_calendar_'.$value[
'id'].
'").click(function() { console.log("Toggle Bookcal Calendar '.$value[
'id'].
'"); jQuery(".family_bookcal_calendar_'.$value[
'id'].
'").toggle(); });'.
"\n";
651 if ($mode ==
"show_week" || $mode ==
"show_month" || empty($mode)) {
653 $s .=
'jQuery( "div.sortable" ).sortable({connectWith: ".sortable", placeholder: "ui-state-highlight", items: "div.movable", receive: function( event, ui ) {'.
"\n";
655 $s .=
'console.log("submit form to record new event");'.
"\n";
657 $s .=
'var newval = jQuery(event.target).closest("div.dayevent").attr("id");'.
"\n";
658 $s .=
'console.log("found parent div.dayevent with id = "+newval);'.
"\n";
659 $s .=
'var frm=jQuery("#searchFormList");'.
"\n";
660 $s .=
'var newurl = ui.item.find("a.cal_event").attr("href");'.
"\n";
661 $s .=
'console.log("Found url on href of a.cal_event"+newurl+", we submit form with actionmove=mupdate");'.
"\n";
662 $s .=
'frm.attr("action", newurl).children("#newdate").val(newval);frm.submit();}'.
"\n";
666 $s .=
'</script>'.
"\n";
669 $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>';
672 if ($user->hasRight(
"holiday",
"read")) {
674 <div class="nowrap inline-block minheight30"><input type="checkbox" id="check_holiday" name="check_holiday" value="1" class="marginleftonly check_holiday"' . ($check_holiday ?
' checked' :
'') .
'>
675 <label for="check_holiday" class="labelcalendar">
676 <span class="check_holiday_text small">' . $langs->trans(
"Holidays") .
'</span>
682 if (is_array($showextcals) && count($showextcals) > 0) {
683 $s .=
'<script type="text/javascript">'.
"\n";
684 $s .=
'jQuery(document).ready(function () {
685 jQuery("div input[name^=\"check_ext\"]").each(function(index, elem) {
686 var name = jQuery(elem).attr("name");
687 if (jQuery(elem).is(":checked")) {
688 jQuery(".family_ext" + name.replace("check_ext", "")).show();
690 jQuery(".family_ext" + name.replace("check_ext", "")).hide();
694 jQuery("div input[name^=\"check_ext\"]").click(function() {
695 var name = $(this).attr("name");
696 jQuery(".family_ext" + name.replace("check_ext", "")).toggle();
699 $s .=
'</script>'.
"\n";
701 foreach ($showextcals as $val) {
702 $htmlname = md5($val[
'name']);
704 if (!empty($val[
'default']) ||
GETPOSTINT(
'check_ext'.$htmlname)) {
705 $default =
"checked";
710 $tooltip = $langs->trans(
"Cache").
' '.round($DELAYFORCACHE / 60).
'mn';
712 $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>';
717 $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>';
721 if (!empty($bookcalcalendars[
"calendars"])) {
722 foreach ($bookcalcalendars[
"calendars"] as $key => $value) {
723 $label = $value[
'label'];
724 $s .=
'<div class="nowrap inline-block minheight30">';
725 $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'].
'">';
726 $s .=
'<label for="check_bookcal_calendar_'.$value[
'id'].
'" class="labelcalendar">';
727 $s .=
'<span class="check_bookcal_calendar_'.$value[
'id'].
'_text">'.$langs->trans(
"AgendaShowBookcalCalendar", $label).
'</span>';
728 $s .=
'</label> </div>';
734 $parameters = array();
735 $reshook = $hookmanager->executeHooks(
'addCalendarChoice', $parameters, $object, $action);
736 if (empty($reshook)) {
737 $s .= $hookmanager->resPrint;
738 } elseif ($reshook > 1) {
739 $s = $hookmanager->resPrint;
742 $s .=
"\n".
'<!-- End div to calendars selectors -->'.
"\n";
745 $newparam = preg_replace(
'/check_birthday=[0-1]/i',
'check_birthday='.(empty($check_birthday) ? 1 : 0), $newparam);
746 if (!preg_match(
'/check_birthday=/i', $newparam)) {
747 $newparam .=
'&check_birthday=1';
751 if (empty($check_birthday)) {
752 $s .= $langs->trans(
"AgendaShowBirthdayEvents");
754 $s .= $langs->trans(
"AgendaHideBirthdayEvents");
762 'usergroup' => $usergroup,
763 'filtert' => $filtert,
764 'resourceid' => $resourceid,
765 'actioncode' => $actioncode,
770 'search_categ_cus' => $search_categ_cus,
772$agendaeventresult =
agenda_build_eventarray($db, $hookmanager, $user, $object, $action, $mode, $year, $month, $day, $firstdaytoshow, $lastdaytoshow, $filters);
773$eventarray = $agendaeventresult[
'eventarray'];
774$nbevents = $agendaeventresult[
'nbevents'];
775$MAXONSAMEPAGE = $agendaeventresult[
'maxonsamepage'];
779agenda_get_birthday_events($db, $langs, $user, $mode, $month, $day, $year, $eventarray, $nbevents, $firstdaytoshow, $lastdaytoshow);
783if ($user->hasRight(
"holiday",
"read")) {
784 $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";
785 $sql .=
" FROM ".MAIN_DB_PREFIX.
"holiday as x, ".MAIN_DB_PREFIX.
"user as u";
786 $sql .=
" WHERE u.rowid = x.fk_user";
787 $sql .=
" AND u.statut = '1'";
788 $sql .=
" AND (x.statut = '2' OR x.statut = '3')";
789 if ($mode ==
'show_day') {
791 $sql .=
" AND '".$db->escape($year.
"-".$month.
"-".$day).
"' BETWEEN x.date_debut AND x.date_fin";
792 } elseif ($mode ==
'show_week') {
794 $sql .=
" AND x.date_debut < '".$db->idate(
dol_get_last_day($year, $month)).
"'";
796 } elseif ($mode ==
'show_month') {
798 $sql .=
" AND x.date_debut <= '".$db->idate(
dol_get_last_day($year, $month)).
"'";
801 if (!$user->hasRight(
'holiday',
'readall') || $filtert ==
'-3') {
803 $sql .=
" AND x.fk_user IN(".$db->sanitize(implode(
", ", $user->getAllChildIds(1))).
") ";
807 $sql .=
" AND x.fk_user = ".((int) $filtert);
810 $resql = $db->query($sql);
812 $num = $db->num_rows($resql);
817 $obj = $db->fetch_object($resql);
822 $event->id = $obj->rowid;
823 $event->ref = (string) $event->id;
825 $event->type_code =
'HOLIDAY';
826 $event->type_label =
'';
827 $event->type_color =
'';
828 $event->type =
'holiday';
829 $event->type_picto =
'holiday';
833 $event->datep = (int) $db->jdate($obj->date_start,
'gmt') + (empty($obj->halfday) || $obj->halfday == 1 ? 0 : 12) * 60 * 60;
834 $event->datef = (int) $db->jdate($obj->date_end,
'gmt') + (empty($obj->halfday) || $obj->halfday == -1 ? 24 : 12) * 60 * 60 - 1;
835 $event->date_start_in_calendar = $event->datep;
836 $event->date_end_in_calendar = $event->datef;
838 if ($obj->status == 3) {
840 $event->percentage = -1;
841 } elseif ($obj->status == 2) {
843 $event->percentage = 0;
846 $event->label = $langs->trans(
"Holiday");
848 $daycursor = $event->date_start_in_calendar;
853 $daycursorend = $event->date_end_in_calendar;
859 $daykey =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
860 $daykeygmt =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
865 $firstdayofholiday = ($ifornbofdays == 1);
866 $lastdayofholiday = ($daykeygmt ==
dol_get_first_hour($event->date_end_in_calendar,
'gmt'));
875 if ((in_array($obj->halfday, array(1, 2)) == 1 && $lastdayofholiday) || (in_array($obj->halfday, array(-1, 2)) && $firstdayofholiday)) {
878 if (in_array($obj->halfday, array(1, 2)) && $lastdayofholiday) {
879 $newevent->label .=
' ('.$langs->trans(
"Morning").
')';
880 } elseif (in_array($obj->halfday, array(-1, 2)) && $firstdayofholiday) {
881 $newevent->label .=
' ('.$langs->trans(
"Afternoon").
')';
883 $eventarray[$daykey][] = $newevent;
885 $eventarray[$daykey][] = $event;
888 $daykey += 60 * 60 * 24;
889 $daykeygmt += 60 * 60 * 24;
890 }
while ($daykey <= $event->date_end_in_calendar);
899if (count($listofextcals)) {
900 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/ical.class.php';
902 foreach ($listofextcals as $key => $extcal) {
903 $url = $extcal[
'src'];
904 $namecal = $extcal[
'name'];
905 $offsettz = $extcal[
'offsettz'];
906 $colorcal = $extcal[
'color'];
907 $buggedfile = $extcal[
'buggedfile'];
913 $ical->parse($url, $pathforcachefile, $DELAYFORCACHE);
916 $listofextcals[$key][
'error'] = $ical->error;
917 $s .=
'<br><div class="warning">'.dol_escape_htmltag($listofextcals[$key][
'name']).
': '.$url.
'<br>Error message: '.
dol_escape_htmltag($ical->error).
'</div>';
922 $icalevents = array();
923 $tmparray = $ical->get_event_list();
924 if (is_array($tmparray)) {
925 $icalevents = array_merge($icalevents, $tmparray);
927 $tmparray = $ical->get_freebusy_list();
928 if (is_array($tmparray)) {
929 $icalevents = array_merge($icalevents, $tmparray);
932 $nbevents += count($icalevents);
934 if (count($icalevents) > 0) {
936 $moreicalevents = array();
937 foreach ($icalevents as $icalevent) {
938 if (isset($icalevent[
'RRULE']) && is_array($icalevent[
'RRULE'])) {
941 if ($icalevent[
'DTSTART;VALUE=DATE']) {
944 } elseif (is_array($icalevent[
'DTSTART']) && !empty($icalevent[
'DTSTART'][
'unixtime'])) {
945 $datecurstart = $icalevent[
'DTSTART'][
'unixtime'];
946 $datecurend = $icalevent[
'DTEND'][
'unixtime'];
947 if (!empty($ical->cal[
'DAYLIGHT'][
'DTSTART']) && $datecurstart) {
949 $tmpcurstart = $datecurstart;
950 $tmpcurend = $datecurend;
951 $tmpdaylightstart =
dol_mktime(0, 0, 0, 1, 1, 1970, 1) + (int) $ical->cal[
'DAYLIGHT'][
'DTSTART'];
952 $tmpdaylightend =
dol_mktime(0, 0, 0, 1, 1, 1970, 1) + (int) $ical->cal[
'STANDARD'][
'DTSTART'];
955 if ($tmpcurstart >= $tmpdaylightstart && $tmpcurstart < $tmpdaylightend) {
956 $datecurstart -= ((int) $ical->cal[
'DAYLIGHT'][
'TZOFFSETTO']) * 36;
958 $datecurstart -= ((int) $ical->cal[
'STANDARD'][
'TZOFFSETTO']) * 36;
960 if ($tmpcurend >= $tmpdaylightstart && $tmpcurstart < $tmpdaylightend) {
961 $datecurend -= ((int) $ical->cal[
'DAYLIGHT'][
'TZOFFSETTO']) * 36;
963 $datecurend -= ((int) $ical->cal[
'STANDARD'][
'TZOFFSETTO']) * 36;
970 dol_syslog(
"Found a not recognized repeatable record with unknown date start", LOG_ERR);
975 $interval = (empty($icalevent[
'RRULE'][
'INTERVAL']) ? 1 : $icalevent[
'RRULE'][
'INTERVAL']);
976 $until = empty($icalevent[
'RRULE'][
'UNTIL']) ? 0 :
dol_stringtotime($icalevent[
'RRULE'][
'UNTIL'], 1);
977 $maxrepeat = empty($icalevent[
'RRULE'][
'COUNT']) ? 0 : $icalevent[
'RRULE'][
'COUNT'];
978 if ($until && ($until + ($datecurend - $datecurstart)) < $firstdaytoshow) {
981 if ($datecurstart >= $lastdaytoshow) {
986 while (($datecurstart < $lastdaytoshow) && (empty($maxrepeat) || ($numofevent < $maxrepeat))) {
987 if ($datecurend >= $firstdaytoshow) {
988 $newevent = $icalevent;
989 unset($newevent[
'RRULE']);
990 if ($icalevent[
'DTSTART;VALUE=DATE']) {
991 $newevent[
'DTSTART;VALUE=DATE'] =
dol_print_date($datecurstart,
'%Y%m%d');
992 $newevent[
'DTEND;VALUE=DATE'] =
dol_print_date($datecurend + 1,
'%Y%m%d');
994 $newevent[
'DTSTART'] = $datecurstart;
995 $newevent[
'DTEND'] = $datecurend;
997 $moreicalevents[] = $newevent;
1001 $savdatecurstart = $datecurstart;
1002 if ($icalevent[
'RRULE'][
'FREQ'] ==
'DAILY') {
1006 if ($icalevent[
'RRULE'][
'FREQ'] ==
'WEEKLY') {
1009 } elseif ($icalevent[
'RRULE'][
'FREQ'] ==
'MONTHLY') {
1012 } elseif ($icalevent[
'RRULE'][
'FREQ'] ==
'YEARLY') {
1017 if ($savdatecurstart >= $datecurstart) {
1018 dol_syslog(
"Found a rule freq ".$icalevent[
'RRULE'][
'FREQ'].
" not managed by dolibarr code. Assume 1 week frequency.", LOG_ERR);
1019 $datecurstart += 3600 * 24 * 7;
1020 $datecurend += 3600 * 24 * 7;
1025 $icalevents = array_merge($icalevents, $moreicalevents);
1028 foreach ($icalevents as $icalevent) {
1033 if (!empty($icalevent[
'RRULE'])) {
1040 if (isset($icalevent[
'DTSTART;VALUE=DATE'])) {
1043 if (empty($icalevent[
'DTEND;VALUE=DATE'])) {
1044 $dateend = $datestart + 86400 - 1;
1050 $event->fulldayevent = 1;
1052 } elseif (!is_array($icalevent[
'DTSTART'])) {
1053 $datestart = $icalevent[
'DTSTART'];
1054 $dateend = empty($icalevent[
'DTEND']) ? $datestart : $icalevent[
'DTEND'];
1056 $datestart += +($offsettz * 3600);
1057 $dateend += +($offsettz * 3600);
1062 } elseif (isset($icalevent[
'DTSTART'][
'unixtime'])) {
1063 $datestart = $icalevent[
'DTSTART'][
'unixtime'];
1064 $dateend = $icalevent[
'DTEND'][
'unixtime'];
1066 $datestart += +($offsettz * 3600);
1067 $dateend += +($offsettz * 3600);
1070 if ($buggedfile ===
'uselocalandtznodaylight') {
1074 if ($buggedfile ===
'uselocalandtzdaylight') {
1075 $localtzs =
new DateTimeZone((
string) preg_replace(
'/"/',
'', $icalevent[
'DTSTART'][
'TZID']));
1076 $localtze =
new DateTimeZone((
string) preg_replace(
'/"/',
'', $icalevent[
'DTEND'][
'TZID']));
1077 $localdts =
new DateTime(
dol_print_date($datestart,
'dayrfc',
'gmt'), $localtzs);
1078 $localdte =
new DateTime(
dol_print_date($dateend,
'dayrfc',
'gmt'), $localtze);
1079 $tmps = -1 * $localtzs->getOffset($localdts);
1080 $tmpe = -1 * $localtze->getOffset($localdte);
1081 $datestart += $tmps;
1089 $event->id = $icalevent[
'UID'];
1090 $event->ref = (string) $event->id;
1091 $userId = $userstatic->findUserIdByEmail($namecal);
1092 if (!empty($userId) && $userId > 0) {
1093 $event->userassigned[$userId] = array(
'id' => $userId,
'transparency' => 1);
1094 $event->percentage = -1;
1097 $event->type_code =
"ICALEVENT";
1098 $event->type_label = $namecal;
1099 $event->type_color = $colorcal;
1100 $event->type =
'icalevent';
1101 $event->type_picto =
'rss';
1103 $event->icalname = $namecal;
1104 $event->icalcolor = $colorcal;
1106 $event->datep = (int) ($datestart + $usertime);
1107 $event->datef = (int) ($dateend + $usertime);
1109 if (isset($icalevent[
'SUMMARY']) && $icalevent[
'SUMMARY']) {
1111 } elseif (isset($icalevent[
'DESCRIPTION']) && $icalevent[
'DESCRIPTION']) {
1114 $event->label = $langs->trans(
"ExtSiteNoLabel");
1121 if (!empty($icalevent[
'PRIORITY'])) {
1122 $event->priority = $icalevent[
'PRIORITY'];
1126 if (!empty($icalevent[
'TRANSP'])) {
1127 if ($icalevent[
'TRANSP'] ==
"TRANSPARENT") {
1128 $event->transparency = 0;
1130 if ($icalevent[
'TRANSP'] ==
"OPAQUE") {
1131 $event->transparency = 1;
1142 if (!empty($icalevent[
'LOCATION'])) {
1143 $event->location = $icalevent[
'LOCATION'];
1146 $event->date_start_in_calendar = $event->datep;
1148 if ((
int) $event->datef != 0 && $event->datef >= $event->datep) {
1149 $event->date_end_in_calendar = $event->datef;
1151 $event->date_end_in_calendar = $event->datep;
1155 if ($event->date_end_in_calendar < $firstdaytoshow || $event->date_start_in_calendar >= $lastdaytoshow) {
1161 if ($event->date_start_in_calendar < $firstdaytoshow) {
1162 $event->date_start_in_calendar = $firstdaytoshow;
1164 if ($event->date_end_in_calendar >= $lastdaytoshow) {
1165 $event->date_end_in_calendar = ($lastdaytoshow - 1);
1169 $daycursor = $event->date_start_in_calendar;
1178 $daykey =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
1179 $daykeygmt =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
1182 $eventarray[$daykey][] = $event;
1183 $daykey += 60 * 60 * 24;
1184 $daykeygmt += 60 * 60 * 24;
1185 if (($event->fulldayevent ? $daykeygmt : $daykey) > $event->date_end_in_calendar) {
1197$parameters = array();
1199$reshook = $hookmanager->executeHooks(
'getCalendarEvents', $parameters, $object, $action);
1200if (!empty($hookmanager->resArray[
'eventarray'])) {
1201 foreach ($hookmanager->resArray[
'eventarray'] as $keyDate => $events) {
1202 if (!isset($eventarray[$keyDate])) {
1203 $eventarray[$keyDate] = array();
1205 $eventarray[$keyDate] = array_merge($eventarray[$keyDate], $events);
1210foreach ($eventarray as $keyDate => &$dateeventarray) {
1211 usort($dateeventarray,
'sort_events_by_date');
1216$cachethirdparties = array();
1217$cachecontacts = array();
1221 array(137, 86, 161),
1222 array(60, 147, 183),
1223 array(250, 190, 80),
1225 array(190, 190, 100),
1226 array(91, 115, 247),
1227 array(140, 140, 220),
1228 array(190, 120, 120),
1229 array(115, 125, 150),
1230 array(100, 170, 20),
1231 array(150, 135, 125),
1232 array(85, 135, 150),
1233 array(150, 135, 80),
1239if ($color_file && is_readable($color_file)) {
1241 include $color_file;
1245$massactionbutton =
'';
1247print_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);
1249if ($nbevents > $MAXONSAMEPAGE) {
1250 print
info_admin(
'Number of results has been truncated to '.$MAXONSAMEPAGE, 0, 0,
'warning').
'<br>';
1257if (empty($mode) || $mode ==
'show_month') {
1259 $newparam = preg_replace(
'/check_birthday=/i',
'check_birthday_=', $newparam);
1260 $newparam = preg_replace(
'/mode=show_month&?/i',
'', $newparam);
1261 $newparam = preg_replace(
'/mode=show_week&?/i',
'', $newparam);
1262 $newparam = preg_replace(
'/day=[0-9]+&?/i',
'', $newparam);
1263 $newparam = preg_replace(
'/month=[0-9]+&?/i',
'', $newparam);
1264 $newparam = preg_replace(
'/year=[0-9]+&?/i',
'', $newparam);
1265 $newparam = preg_replace(
'/viewcal=[0-9]+&?/i',
'', $newparam);
1266 $newparam = preg_replace(
'/check_birthday_=/i',
'check_birthday=', $newparam);
1267 $newparam .=
'&viewcal=1';
1269 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1270 print_actions_filter($form, $canedit, $status, $year, $month, $day, $check_birthday,
'', $filtert,
'', $pid, $socid, $action, -1, $actioncode, $usergroupids,
'', $resourceid, $search_categ_cus);
1273 print
'<div class="div-table-responsive-no-min sectioncalendarbymonth maxscreenheightless300">';
1274 print
'<table class="centpercent noborder nocellnopadd cal_pannel cal_month listwithfilterbefore">';
1275 print
' <tr class="liste_titre sticky">';
1277 echo
' <td class="center">#</td>';
1280 print
' <td class="center bold uppercase tdfordaytitle'.($i == 0 ?
' borderleft' :
'').
'">';
1282 if (!empty(
$conf->dol_optimize_smallscreen)) {
1283 $labelshort = array(0 =>
'SundayMin', 1 =>
'MondayMin', 2 =>
'TuesdayMin', 3 =>
'WednesdayMin', 4 =>
'ThursdayMin', 5 =>
'FridayMin', 6 =>
'SaturdayMin');
1284 print $langs->trans($labelshort[$numdayinweek]);
1286 print $langs->trans(
"Day".$numdayinweek);
1288 print
' </td>'.
"\n";
1294 $todaytms =
dol_mktime(0, 0, 0, $todayarray[
'mon'], $todayarray[
'mday'], $todayarray[
'year']);
1298 for ($iter_week = 0; $iter_week < 6; $iter_week++) {
1302 $currdate0 = sprintf(
"%04d", $prev_year).sprintf(
"%02d", $prev_month).sprintf(
"%02d", $max_day_in_prev_month + $tmpday);
1303 } elseif ($tmpday <= $max_day_in_month) {
1304 $currdate0 = sprintf(
"%04d", $year).sprintf(
"%02d", $month).sprintf(
"%02d", $tmpday);
1306 $currdate0 = sprintf(
"%04d", $next_year).sprintf(
"%02d", $next_month).sprintf(
"%02d", $tmpday - $max_day_in_month);
1309 $numweek0 =
date(
"W", strtotime(
date($currdate0)));
1311 echo
' <td class="center weeknumber opacitymedium" width="2%">'.$numweek0.
'</td>';
1313 for ($iter_day = 0; $iter_day < 7; $iter_day++) {
1316 $style =
'cal_other_month cal_past';
1317 if ($iter_day == 6) {
1318 $style .=
' cal_other_month_right';
1320 echo
' <td class="'.$style.
' nowrap tdtop" width="14%">';
1322 show_day_events($db, $max_day_in_prev_month + $tmpday, $prev_month, $prev_year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam);
1324 } elseif ($tmpday <= $max_day_in_month) {
1326 $curtime =
dol_mktime(0, 0, 0, $month, $tmpday, $year);
1327 $style =
'cal_current_month';
1328 if ($iter_day == 6) {
1329 $style .=
' cal_current_month_right';
1332 if ($todayarray[
'mday'] == $tmpday && $todayarray[
'mon'] == $month && $todayarray[
'year'] == $year) {
1336 $style =
'cal_today';
1338 if ($curtime < $todaytms) {
1339 $style .=
' cal_past';
1342 echo
' <td class="'.$style.
' nowrap tdtop" width="14%">';
1344 show_day_events($db, $tmpday, $month, $year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam, 0, 60, 0, $bookcalcalendars);
1348 $style =
'cal_other_month';
1349 if ($iter_day == 6) {
1350 $style .=
' cal_other_month_right';
1352 echo
' <td class="'.$style.
' nowrap tdtop" width="14%">';
1354 show_day_events($db, $tmpday - $max_day_in_month, $next_month, $next_year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam);
1364 print
'<input type="hidden" name="actionmove" value="mupdate">';
1365 print
'<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($_SERVER[
'PHP_SELF']).
'?mode=show_month&'.
dol_escape_htmltag($_SERVER[
'QUERY_STRING']).
'">';
1366 print
'<input type="hidden" name="newdate" id="newdate">';
1367} elseif ($mode ==
'show_week') {
1370 $newparam = preg_replace(
'/check_birthday=/i',
'check_birthday_=', $newparam);
1371 $newparam = preg_replace(
'/mode=show_month&?/i',
'', $newparam);
1372 $newparam = preg_replace(
'/mode=show_week&?/i',
'', $newparam);
1373 $newparam = preg_replace(
'/day=[0-9]+&?/i',
'', $newparam);
1374 $newparam = preg_replace(
'/month=[0-9]+&?/i',
'', $newparam);
1375 $newparam = preg_replace(
'/year=[0-9]+&?/i',
'', $newparam);
1376 $newparam = preg_replace(
'/viewweek=[0-9]+&?/i',
'', $newparam);
1377 $newparam = preg_replace(
'/check_birthday_=/i',
'check_birthday=', $newparam);
1378 $newparam .=
'&viewweek=1';
1380 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1381 print_actions_filter($form, $canedit, $status, $year, $month, $day, $check_birthday,
'', $filtert,
'', $pid, $socid, $action, -1, $actioncode, $usergroupids,
'', $resourceid);
1384 print
'<div class="div-table-responsive-no-min sectioncalendarbyweek maxscreenheightless300">';
1385 print
'<table class="centpercent noborder nocellnopadd cal_pannel cal_month listwithfilterbefore">';
1386 print
' <tr class="liste_titre">';
1389 echo
' <td class="center bold uppercase tdfordaytitle">'.$langs->trans(
"Day".(($i + (
getDolGlobalInt(
'MAIN_START_WEEK', 1))) % 7)).
"</td>\n";
1394 echo
' <tr class="trcalweek">'.
"\n";
1396 for ($iter_day = 0; $iter_day < 7; $iter_day++) {
1403 $style =
'cal_current_month';
1404 if ($iter_day == 6) {
1405 $style .=
' cal_other_month_right';
1410 if ($todayarray[
'mday'] == $tmpday && $todayarray[
'mon'] == $tmpmonth && $todayarray[
'year'] == $tmpyear) {
1414 $style =
'cal_today';
1417 echo
' <td class="'.$style.
'" width="14%" valign="top">';
1419 show_day_events($db, $tmpday, $tmpmonth, $tmpyear, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 0, $bookcalcalendars);
1427 echo
'<input type="hidden" name="actionmove" value="mupdate">';
1428 echo
'<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($_SERVER[
'PHP_SELF']).
'?mode=show_week&'.
dol_escape_htmltag($_SERVER[
'QUERY_STRING']).
'">';
1429 echo
'<input type="hidden" name="newdate" id="newdate">';
1432 $newparam = preg_replace(
'/mode=show_month&?/i',
'', $newparam);
1433 $newparam = preg_replace(
'/mode=show_week&?/i',
'', $newparam);
1434 $newparam = preg_replace(
'/viewday=[0-9]+&?/i',
'', $newparam);
1435 $newparam .=
'&viewday=1';
1437 $style =
'cal_current_month cal_current_month_oneday';
1440 if ($todayarray[
'mday'] == $day && $todayarray[
'mon'] == $month && $todayarray[
'year'] == $year) {
1445 $timestamp =
dol_mktime(12, 0, 0, $month, $day, $year);
1448 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1449 print_actions_filter($form, $canedit, $status, $year, $month, $day, $check_birthday,
'', $filtert,
'', $pid, $socid, $action, -1, $actioncode, $usergroupids,
'', $resourceid);
1452 print
'<div class="div-table-responsive-no-min sectioncalendarbyday maxscreenheightless300">';
1453 echo
'<table class="tagtable centpercent noborder nocellnopadd cal_pannel cal_month listwithfilterbefore" style="margin-bottom: 10px !important;">';
1455 echo
' <tr class="tagtr liste_titre">';
1456 echo
' <td class="tagtd center bold uppercase">'.$langs->trans(
"Day".$arraytimestamp[
'wday']).
"</td>\n";
1468 print
'<tr class="trcalday"><td class="tdtop">';
1473 print
'<div class="div-table-responsive-no-min">';
1475 $maxheightwin = (isset($_SESSION[
"dol_screenheight"]) && $_SESSION[
"dol_screenheight"] > 500) ? ($_SESSION[
"dol_screenheight"] - 200) : 660;
1477 echo
'<div style="max-height: '.$maxheightwin.
'px;">';
1478 echo
'<div class="tagtable centpercent calendarviewcontainer">';
1483 $minhour = round((
float) $tmp[0], 0);
1484 $maxhour = round((
float) $tmp[1], 0);
1485 if ($minhour > 23) {
1491 if ($maxhour <= $minhour) {
1492 $maxhour = $minhour + 1;
1498 echo
' <div class="tagtr calendarviewcontainertr">'.
"\n";
1499 echo
' <div class="tagtd width100 tdtop">'.dol_print_date($i * 3600,
'hour',
'gmt').
'</div>';
1500 echo
' <div class="tagtd '.$style.
' tdtop"></div>'.
"\n";
1501 echo
' </div>'.
"\n";
1506 echo
'</div></div>';
1509 show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 1, $bookcalcalendars);
1513 print
'<div class="div-table-responsive-no-min">';
1516 show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 0, $bookcalcalendars);
1528print
"\n".
'</form>';
1545 if ($a->type_code ===
'HOLIDAY') {
1548 if ($b->type_code ===
'HOLIDAY') {
1556 if ($a->datep !== $b->datep) {
1557 return (
int) ($a->datep - $b->datep);
1561 if ((!is_numeric($b->datef)) || (!is_numeric($a->datef))) {
1566 if ($b->datef === $a->datef) {
1571 return (
int) ($b->datef - $a->datef);
1586 if ($a->percentage < 0) {
1590 if ($b->percentage < 0) {
1594 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.
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_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
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...
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.
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.