34require
'../../main.inc.php';
42require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
44require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
45require_once DOL_DOCUMENT_ROOT.
'/user/class/usergroup.class.php';
46require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
47require_once DOL_DOCUMENT_ROOT.
'/core/lib/agenda.lib.php';
48require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
49require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
54$disabledefaultvalues =
GETPOSTINT(
'disabledefaultvalues');
56$action =
GETPOST(
'action',
'aZ09');
59$filter =
GETPOST(
"search_filter",
'alpha', 3) ?
GETPOST(
"search_filter",
'alpha', 3) :
GETPOST(
"filter",
'alpha', 3);
60$filtert =
GETPOST(
"search_filtert",
"intcomma", 3) ?
GETPOST(
"search_filtert",
"intcomma", 3) :
GETPOST(
"filtert",
"intcomma", 3);
66$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
67$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
69if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
73$offset = $limit * $page;
78 $sortfield =
"a.datec";
84 $socid = $user->socid;
91if (!$user->hasRight(
'agenda',
'myactions',
'read')) {
94if (!$user->hasRight(
'agenda',
'allactions',
'read')) {
97if (!$user->hasRight(
'agenda',
'allactions',
'read') || $filter ==
'mine') {
98 $filtert = (
string) $user->id;
101$mode =
'show_peruser';
107$pid = GETPOSTISSET(
"search_projectid") ?
GETPOSTINT(
"search_projectid", 3) :
GETPOSTINT(
"projectid", 3);
108$status = GETPOSTISSET(
"search_status") ?
GETPOST(
"search_status",
'aZ09') :
GETPOST(
"status",
'aZ09');
109$type = GETPOSTISSET(
"search_type") ?
GETPOST(
"search_type",
'aZ09') :
GETPOST(
"type",
'aZ09');
111$optioncss =
GETPOST(
'optioncss',
'aZ');
114if (
GETPOST(
'search_actioncode',
'array:aZ09')) {
115 $actioncode =
GETPOST(
'search_actioncode',
'array:aZ09', 3);
116 if (!count($actioncode)) {
120 $actioncode =
GETPOST(
"search_actioncode",
"alpha", 3) ?
GETPOST(
"search_actioncode",
"alpha", 3) : (
GETPOST(
"search_actioncode",
"alpha") ==
'0' ?
'0' : ((!
getDolGlobalString(
'AGENDA_DEFAULT_FILTER_TYPE') || $disabledefaultvalues) ?
'' :
getDolGlobalString(
'AGENDA_DEFAULT_FILTER_TYPE')));
124if ($dateselect > 0) {
132$tmp = str_replace(
' ',
'', $tmp);
133$tmparray = explode(
'-', $tmp);
134$begin_h = GETPOSTISSET(
'begin_h') ?
GETPOSTINT(
'begin_h') : ($tmparray[0] !=
'' ? $tmparray[0] : 9);
135$end_h = GETPOSTISSET(
'end_h') ?
GETPOSTINT(
'end_h') : ($tmparray[1] !=
'' ? $tmparray[1] : 18);
136if ($begin_h < 0 || $begin_h > 23) {
139if ($end_h < 1 || $end_h > 24) {
142if ($end_h <= $begin_h) {
143 $end_h = $begin_h + 1;
148$tmp = str_replace(
' ',
'', $tmp);
149$tmparray = explode(
'-', $tmp);
150$begin_d = GETPOSTISSET(
'begin_d') ?
GETPOSTINT(
'begin_d') : ($tmparray[0] !=
'' ? $tmparray[0] : 1);
151$end_d = GETPOSTISSET(
'end_d') ?
GETPOSTINT(
'end_d') : ($tmparray[1] !=
'' ? $tmparray[1] : 5);
152if ($begin_d < 1 || $begin_d > 7) {
155if ($end_d < 1 || $end_d > 7) {
158if ($end_d < $begin_d) {
159 $end_d = $begin_d + 1;
162if ($status ==
'' && !GETPOSTISSET(
'search_status')) {
166if (empty($mode) && !GETPOSTISSET(
'mode')) {
171if (
GETPOST(
'viewcal',
'alpha') && $mode !=
'show_day' && $mode !=
'show_week' && $mode !=
'show_peruser') {
172 $mode =
'show_month';
176if (
GETPOST(
'viewweek',
'alpha') || $mode ==
'show_week') {
178 $week = ($week ? $week :
date(
"W"));
179 $day = ($day ? $day :
date(
"d"));
182if (
GETPOST(
'viewday',
'alpha') || $mode ==
'show_day') {
184 $day = ($day ? $day :
date(
"d"));
187$labelbytype = array();
192$langs->loadLangs(array(
'users',
'agenda',
'other',
'commercial'));
195$hookmanager->initHooks(array(
'agenda'));
197$result =
restrictedArea($user,
'agenda', 0,
'actioncomm&societe',
'myactions|allactions',
'fk_soc',
'id');
198if ($user->socid && $socid) {
202$search_status = $status;
223 'maxprint' => $maxprint,
225 'filtert' => $filtert,
226 'showbirthday' => $showbirthday,
227 'canedit' => $canedit,
228 'optioncss' => $optioncss,
229 'actioncode' => $actioncode,
231 'resourceid' => $resourceid,
232 'usergroup' => $usergroup,
234$reshook = $hookmanager->executeHooks(
'beforeAgendaPerUser', $parameters, $object, $action);
242$help_url =
'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda|DE:Modul_Terminplanung';
243llxHeader(
'', $langs->trans(
"Agenda"), $help_url);
247$nowyear = $nowarray[
'year'];
248$nowmonth = $nowarray[
'mon'];
249$nowday = $nowarray[
'mday'];
252$listofextcals = array();
256while ($i < $MAXAGENDA) {
258 $source =
'AGENDA_EXT_SRC'.$i;
259 $name =
'AGENDA_EXT_NAME'.$i;
260 $offsettz =
'AGENDA_EXT_OFFSETTZ'.$i;
261 $color =
'AGENDA_EXT_COLOR'.$i;
262 $enabled =
'AGENDA_EXT_ENABLED'.$i;
263 $default =
'AGENDA_EXT_ACTIVEBYDEFAULT'.$i;
264 $buggedfile =
'AGENDA_EXT_BUGGEDFILE'.$i;
267 $listofextcals[] = array(
268 'type' =>
'globalsetup',
282while ($i < $MAXAGENDA) {
284 $source =
'AGENDA_EXT_SRC_'.$user->id.
'_'.$i;
285 $name =
'AGENDA_EXT_NAME_'.$user->id.
'_'.$i;
286 $offsettz =
'AGENDA_EXT_OFFSETTZ_'.$user->id.
'_'.$i;
287 $color =
'AGENDA_EXT_COLOR_'.$user->id.
'_'.$i;
288 $enabled =
'AGENDA_EXT_ENABLED_'.$user->id.
'_'.$i;
289 $default =
'AGENDA_EXT_ACTIVEBYDEFAULT_'.$user->id.
'_'.$i;
290 $buggedfile =
'AGENDA_EXT_BUGGEDFILE_'.$user->id.
'_'.$i;
294 $listofextcals[] = array(
295 'type' =>
'usersetup',
298 'offsettz' => (
int) (empty($user->conf->$offsettz) ? 0 : $user->
conf->$offsettz),
309$first_day = $prev[
'first_day'];
310$first_month = $prev[
'first_month'];
311$first_year = $prev[
'first_year'];
313$week = $prev[
'week'];
317$next_year = $next[
'year'];
318$next_month = $next[
'month'];
319$next_day = $next[
'day'];
321$max_day_in_month =
date(
"t",
dol_mktime(0, 0, 0, $month, 1, $year));
327$title = $langs->trans(
"DoneAndToDoActions");
328if ($status ==
'done') {
329 $title = $langs->trans(
"DoneActions");
331if ($status ==
'todo') {
332 $title = $langs->trans(
"ToDoActions");
336if (($actioncode && $actioncode !==
'-1') || GETPOSTISSET(
'search_actioncode')) {
337 if (is_array($actioncode)) {
338 foreach ($actioncode as $str_action) {
339 if ($str_action !=
'-1') {
340 $param .=
"&search_actioncode[]=".urlencode($str_action);
344 $param .=
"&search_actioncode=".urlencode($actioncode);
347if ($resourceid > 0) {
348 $param .=
"&search_resourceid=".urlencode((
string) ($resourceid));
351if ($status || GETPOSTISSET(
'status') || GETPOSTISSET(
'search_status')) {
352 $param .=
"&search_status=".urlencode($status);
355 $param .=
"&search_filter=".urlencode((
string) $filter);
358 $param .=
"&search_filtert=".urlencode((
string) $filtert);
361 $param .=
"&search_usergroup=".urlencode((
string) ($usergroup));
364 $param .=
"&search_socid=".urlencode((
string) ($socid));
367 $param .=
"&search_showbirthday=1";
370 $param .=
"&search_projectid=".urlencode((
string) ($pid));
373 $param .=
"&search_type=".urlencode($type);
375if ($mode !=
'show_peruser') {
376 $param .=
'&mode='.urlencode((
string) $mode);
379 $param .=
'&begin_h='.((int) $begin_h);
382 $param .=
'&end_h='.((int) $end_h);
385 $param .=
'&begin_d='.((int) $begin_d);
388 $param .=
'&end_d='.((int) $end_d);
390if ($search_categ_cus != 0) {
391 $param .=
'&search_categ_cus='.urlencode((
string) ($search_categ_cus));
394 $param .=
'&check_holiday=1';
396$param .=
"&maxprint=".urlencode((
string) ($maxprint));
398$paramnoactionodate = $param;
403$prev_year = $prev[
'prev_year'];
404$prev_month = $prev[
'prev_month'];
405$prev_day = $prev[
'prev_day'];
406$first_day = $prev[
'first_day'];
407$first_month = $prev[
'first_month'];
408$first_year = $prev[
'first_year'];
410$week = $prev[
'week'];
414$next_year = $next[
'year'];
415$next_month = $next[
'month'];
416$next_day = $next[
'day'];
420$firstdaytoshow =
dol_mktime(0, 0, 0, $first_month, $first_day, $first_year,
'tzuserrel');
421$nb_weeks_to_show = (
getDolGlobalString(
'AGENDA_NB_WEEKS_IN_VIEW_PER_USER')) ? ((
int)
$conf->global->AGENDA_NB_WEEKS_IN_VIEW_PER_USER * 7) : 7;
427$max_day_in_month = idate(
"t",
dol_mktime(0, 0, 0, $month, 1, $year,
'gmt'));
430$picto =
'calendarweek';
433$nav =
'<div class="navselectiondate inline-block nowraponall">';
434$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";
435$nav .=
" <span id=\"month_name\">".dol_print_date(
dol_mktime(0, 0, 0, $first_month, $first_day, $first_year),
"%Y").
", ".$langs->trans(
"WeekShort").
" ".$week;
437$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";
438if (empty(
$conf->dol_optimize_smallscreen)) {
439 $nav .=
' <a href="?year='.$nowyear.
'&month='.$nowmonth.
'&day='.$nowday.$param.
'" class="datenowlink marginleftonly marginrightonly">'.$langs->trans(
"Today").
'</a> ';
442$nav .= $form->selectDate($dateselect,
'dateselect', 0, 0, 1,
'', 1, 0);
444$nav .=
'<button type="submit" class="liste_titre button_search valignmiddle" name="button_search_x" value="x"><span class="fa fa-search"></span></button>';
447$paramnodate = $param;
448$param .=
'&year='.$year.
'&month='.$month.($day ?
'&day='.$day :
'');
452$paramnoaction = preg_replace(
'/mode=[a-z_]+/',
'', preg_replace(
'/action=[a-z_]+/',
'', $param));
453$paramnoactionodate = preg_replace(
'/mode=[a-z_]+/',
'', preg_replace(
'/action=[a-z_]+/',
'', $paramnodate));
457print
'<form method="POST" id="searchFormList" class="listactionsfilter" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
458if ($optioncss !=
'') {
459 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
461print
'<input type="hidden" name="token" value="'.newToken().
'">';
462print
'<input type="hidden" name="mode" value="'.$mode.
'">';
465$mode =
'show_peruser';
466$massactionbutton =
'';
469$viewmode =
'<div class="navmode inline-block">';
471$viewmode .=
'<a class="btnTitle reposition" href="'.DOL_URL_ROOT.
'/comm/action/list.php?mode=show_list&restore_lastsearch_values=1'.$paramnoactionodate.
'">';
473$viewmode .=
img_picto($langs->trans(
"List"),
'object_calendarlist',
'class="imgforviewmode pictoactionview block"');
475$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow">'.$langs->trans(
"ViewList").
'</span></a>';
479$viewmode .=
img_picto($langs->trans(
"ViewCal"),
'object_calendarmonth',
'class="pictoactionview block"');
481$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow">'.$langs->trans(
"ViewCal").
'</span></a>';
485$viewmode .=
img_picto($langs->trans(
"ViewWeek"),
'object_calendarweek',
'class="pictoactionview block"');
487$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow">'.$langs->trans(
"ViewWeek").
'</span></a>';
491$viewmode .=
img_picto($langs->trans(
"ViewDay"),
'object_calendarday',
'class="pictoactionview block"');
493$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow">'.$langs->trans(
"ViewDay").
'</span></a>';
497$viewmode .=
img_picto($langs->trans(
"ViewPerUser"),
'object_calendarperuser',
'class="pictoactionview block"');
499$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow" title="'.dolPrintHTML($langs->trans(
"ViewPerUser")).
'">'.$langs->trans(
"ViewPerUser").
'</span></a>';
502$parameters = array();
504$reshook = $hookmanager->executeHooks(
'addCalendarView', $parameters, $object, $action);
505if (empty($reshook)) {
506 $viewmode .= $hookmanager->resPrint;
507} elseif ($reshook > 1) {
508 $viewmode = $hookmanager->resPrint;
511$viewmode .=
'</div>';
513$viewmode .=
'<span class="marginrightonly"></span>';
518if ($user->hasRight(
'agenda',
'myactions',
'create') || $user->hasRight(
'agenda',
'allactions',
'create')) {
521 $newparam .=
'&month='.urlencode(str_pad((
string) $month, 2,
"0", STR_PAD_LEFT)).
'&year='.((int) $tmpforcreatebutton[
'year']);
522 if ($begin_h !==
'') {
523 $newparam .=
'&begin_h='.((int) $begin_h);
526 $newparam .=
'&end_h='.((int) $end_h);
528 if ($begin_d !==
'') {
529 $newparam .=
'&begin_d='.((int) $begin_d);
532 $newparam .=
'&end_d='.((int) $end_d);
535 $urltocreateaction = DOL_URL_ROOT.
'/comm/action/card.php?action=create';
536 $urltocreateaction .=
'&apyear='.$tmpforcreatebutton[
'year'].
'&apmonth='.$tmpforcreatebutton[
'mon'].
'&apday='.$tmpforcreatebutton[
'mday'].
'&aphour='.$tmpforcreatebutton[
'hours'].
'&apmin='.$tmpforcreatebutton[
'minutes'];
537 $urltocreateaction .=
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?'.$newparam);
539 $newcardbutton .=
dolGetButtonTitle($langs->trans(
"AddAction"),
'',
'fa fa-plus-circle', $urltocreateaction);
548$showextcals = $listofextcals;
549$bookcalcalendars = array();
553 $sql =
"SELECT ba.rowid, bc.label, bc.ref, bc.rowid as id_cal";
554 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bookcal_availabilities as ba";
555 $sql .=
" JOIN ".MAIN_DB_PREFIX.
"bookcal_calendar as bc";
556 $sql .=
" ON bc.rowid = ba.fk_bookcal_calendar";
557 $sql .=
" WHERE bc.status = 1";
558 $sql .=
" AND ba.status = 1";
559 $sql .=
" AND bc.entity IN (".getEntity(
'agenda').
")";
560 if (!empty($filtert) && $filtert !=
'-1' && $filtert !=
'-2') {
561 $sql .=
" AND bc.visibility IN (".$db->sanitize($filtert, 0, 0, 0, 0).
")";
563 $resql =
$db->query($sql);
565 $num =
$db->num_rows($resql);
568 $objp =
$db->fetch_object($resql);
569 $label = !empty($objp->label) ? $objp->label : $objp->ref;
570 $bookcalcalendars[
"calendars"][$objp->id_cal] = array(
"id" => $objp->id_cal,
"label" => $label);
571 $bookcalcalendars[
"availabilitieslink"][$objp->rowid] = $objp->id_cal;
579if (!empty(
$conf->use_javascript_ajax)) {
580 $s .=
"\n".
'<!-- Div to calendars selectors -->'.
"\n";
582 $s .=
'<script type="text/javascript">'.
"\n";
583 $s .=
'jQuery(document).ready(function () {'.
"\n";
584 $s .=
'jQuery(".check_birthday").click(function() { console.log("Click on .check_birthday so we toggle class .peruser_birthday"); jQuery(".peruser_birthday").addClass("peruser_birthday_imp"); });'.
"\n";
586 $s .=
'jQuery(".check_holiday").click(function() {';
587 $s .=
' console.log("Click on .check_holiday so we toggle class .peruser_holiday");';
588 $s .=
' if (jQuery(".peruser_holiday").hasClass("peruser_holiday_imp")) {';
589 $s .=
' jQuery(".peruser_holiday").removeClass("peruser_holiday_imp");';
591 $s .=
' jQuery(".peruser_holiday").addClass("peruser_holiday_imp");';
594 $s .=
' var checkHoliday = jQuery(this).is(":checked") ? 1 : 0;';
595 $s .=
' jQuery(".navselectiondate a, .navmode a").each(function(index, elem) { ';
596 $s .=
' var navLinkElem = jQuery(elem);';
597 $s .=
' var navLinkHref = navLinkElem.attr("href");';
598 $s .=
' var navLinkParts = navLinkHref.split("?");';
599 $s .=
' var navLinkPath = navLinkParts[0];';
600 $s .=
' var navLinkParams = new URLSearchParams(navLinkParts[1] || "");';
601 $s .=
' navLinkParams.set("check_holiday", checkHoliday);';
602 $s .=
' navLinkElem.attr("href", navLinkPath + "?" + navLinkParams.toString());';
606 if (
isModEnabled(
"bookcal") && !empty($bookcalcalendars[
"calendars"])) {
607 foreach ($bookcalcalendars[
"calendars"] as $key => $value) {
608 $s .=
'jQuery(".check_bookcal_calendar_'.$value[
'id'].
'").click(function() { console.log("Toggle Bookcal Calendar '.$value[
'id'].
'"); jQuery(".family_bookcal_calendar_'.$value[
'id'].
'").toggle(); });'.
"\n";
612 $s .=
'</script>'.
"\n";
615 $s .=
'<div class="nowrap inline-block minheight30 hideonsmartphone"><input type="checkbox" id="check_mytasks" name="check_mytasks" value="1" class="check_mytasks" checked disabled><label class="labelcalendar"><span class="check_local_text small"> '.$langs->trans(
"LocalAgenda").
' </span></label></div>';
618 if ($user->hasRight(
"holiday",
"read")) {
620 <div class="nowrap inline-block minheight30"><input type="checkbox" id="check_holiday" name="check_holiday small" value="1" class="marginleftonly check_holiday"' . ($check_holiday ?
' checked' :
'') .
'>
621 <label for="check_holiday" class="labelcalendar">
622 <span class="check_holiday_text small">' . $langs->trans(
"Holidays") .
'</span>
628 if (is_array($showextcals) && count($showextcals) > 0) {
629 $s .=
'<script type="text/javascript">'.
"\n";
630 $s .=
'jQuery(document).ready(function () {
631 jQuery("div input[name^=\"check_ext\"]").each(function(index, elem) {
632 var name = jQuery(elem).attr("name");
633 if (jQuery(elem).is(":checked")) {
634 jQuery(".family_ext" + name.replace("check_ext", "")).show();
636 jQuery(".family_ext" + name.replace("check_ext", "")).hide();
640 jQuery("div input[name^=\"check_ext\"]").click(function() {
641 var name = $(this).attr("name");
642 jQuery(".family_ext" + name.replace("check_ext", "")).toggle();
645 $s .=
'</script>'.
"\n";
647 foreach ($showextcals as $val) {
648 $htmlname = md5($val[
'name']);
650 if (!empty($val[
'default']) ||
GETPOSTINT(
'check_ext'.$htmlname)) {
651 $default =
"checked";
656 $tooltip = $langs->trans(
"Cache").
' '.round($DELAYFORCACHE / 60).
'mn';
658 $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>';
682 $parameters = array();
683 $reshook = $hookmanager->executeHooks(
'addCalendarChoice', $parameters, $object, $action);
684 if (empty($reshook)) {
685 $s .= $hookmanager->resPrint;
686 } elseif ($reshook > 1) {
687 $s = $hookmanager->resPrint;
690 $s .=
"\n".
'<!-- End div to calendars selectors -->'.
"\n";
693 $newparam = preg_replace(
'/showbirthday=[0-1]/i',
'showbirthday='.($showbirthday ?
'1' :
'0'), $newparam);
694 if (!preg_match(
'/showbirthday=/i', $newparam)) {
695 $newparam .=
'&showbirthday=1';
700 $link .= $langs->trans(
"AgendaShowBirthdayEvents");
702 $link .= $langs->trans(
"AgendaHideBirthdayEvents");
709$eventarray = array();
717$sql .=
" a.id, a.label,";
720$sql .=
" a.percent,";
721$sql .=
" a.fk_user_author, a.fk_user_action,";
722$sql .=
" a.transparency, a.priority, a.fulldayevent, a.location,";
723$sql .=
" a.fk_soc, a.fk_contact, a.fk_project, a.fk_bookcal_calendar,";
724$sql .=
" a.fk_element, a.elementtype,";
725$sql .=
" ca.code as type_code, ca.libelle as type_label, ca.color as type_color, ca.type as type_type, ca.picto as type_picto";
728$parameters = array();
729$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
730$sql .= $hookmanager->resPrint;
734$sql .=
" FROM ".MAIN_DB_PREFIX.
"c_actioncomm as ca, ".MAIN_DB_PREFIX.
"actioncomm as a";
736if ($resourceid > 0) {
737 $sql .=
", ".MAIN_DB_PREFIX.
"element_resources as r";
741if (($filtert !=
'-1' && $filtert !=
'-2') || $usergroup > 0) {
743 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"actioncomm_resources as ar";
744 $sql .=
" ON ar.fk_actioncomm = a.id AND ar.element_type = 'user'";
745 if ($filtert !=
'' && $filtert !=
'-1' && $filtert !=
'-2' && $filtert !=
'-3') {
746 $sql .=
" AND ar.fk_element IN (".$db->sanitize($filtert).
")";
747 } elseif ($filtert ==
'-3') {
748 $sql .=
" AND ar.fk_element IN (".$db->sanitize(implode(
',', $user->getAllChildIds(1))).
")";
750 if ($usergroup > 0) {
751 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"usergroup_user as ugu ON ugu.fk_user = ar.fk_element AND ugu.fk_usergroup = ".((int) $usergroup);
756$parameters = array();
757$reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object, $action);
758$sql .= $hookmanager->resPrint;
760$sql .=
" WHERE a.fk_action = ca.id";
761$sql .=
" AND a.entity IN (".getEntity(
'agenda').
")";
764if (!empty($actioncode)) {
766 if ((is_array($actioncode) && in_array(
'AC_NON_AUTO', $actioncode)) || $actioncode ==
'AC_NON_AUTO') {
767 $sql .=
" AND ca.type != 'systemauto'";
768 } elseif ((is_array($actioncode) && in_array(
'AC_ALL_AUTO', $actioncode)) || $actioncode ==
'AC_ALL_AUTO') {
769 $sql .=
" AND ca.type = 'systemauto'";
771 if ((is_array($actioncode) && in_array(
'AC_OTH', $actioncode)) || $actioncode ==
'AC_OTH') {
772 $sql .=
" AND ca.type != 'systemauto'";
774 if ((is_array($actioncode) && in_array(
'AC_OTH_AUTO', $actioncode)) || $actioncode ==
'AC_OTH_AUTO') {
775 $sql .=
" AND ca.type = 'systemauto'";
779 if ((is_array($actioncode) && in_array(
'AC_NON_AUTO', $actioncode)) || $actioncode ===
'AC_NON_AUTO') {
780 $sql .=
" AND ca.type != 'systemauto'";
781 } elseif ((is_array($actioncode) && in_array(
'AC_ALL_AUTO', $actioncode)) || $actioncode ===
'AC_ALL_AUTO') {
782 $sql .=
" AND ca.type = 'systemauto'";
783 } elseif ((is_array($actioncode) && !in_array(
'-1', $actioncode) && !in_array(
'-3', $actioncode)) || ($actioncode !==
'-1' && $actioncode !==
'-3')) {
784 if (is_array($actioncode)) {
785 foreach ($actioncode as $key => $val) {
786 if ($val ==
'-1' || $val ==
'-2') {
787 unset($actioncode[$key]);
790 if (!empty($actioncode)) {
791 $sql .=
" AND ca.code IN (".$db->sanitize(
"'".implode(
"','", $actioncode).
"'", 1).
")";
794 $sql .=
" AND ca.code IN (".$db->sanitize(
"'".implode(
"','", explode(
',', $actioncode)).
"'", 1).
")";
799if ($resourceid > 0) {
800 $sql .=
" AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".((int) $resourceid);
803 $sql .=
" AND a.fk_project = ".((int) $pid);
807if (
isModEnabled(
"societe") && !$user->hasRight(
'societe',
'client',
'voir')) {
808 $search_sale = $user->id;
811if ($search_sale && $search_sale !=
'-1') {
812 if ($search_sale == -2) {
813 $sql .=
" AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = a.fk_soc)";
814 } elseif ($search_sale > 0) {
815 $sql .=
" AND (a.fk_soc IS NULL OR EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = a.fk_soc AND sc.fk_user = ".((int) $search_sale).
"))";
820 $sql .=
" AND a.fk_soc = ".((int) $socid);
823if ($mode ==
'show_day') {
825 $sql .=
" (a.datep BETWEEN '".$db->idate(
dol_mktime(0, 0, 0, $month, $day, $year,
'tzuserrel')).
"'";
826 $sql .=
" AND '".$db->idate(
dol_mktime(23, 59, 59, $month, $day, $year,
'tzuserrel')).
"')";
828 $sql .=
" (a.datep2 BETWEEN '".$db->idate(
dol_mktime(0, 0, 0, $month, $day, $year,
'tzuserrel')).
"'";
829 $sql .=
" AND '".$db->idate(
dol_mktime(23, 59, 59, $month, $day, $year,
'tzuserrel')).
"')";
831 $sql .=
" (a.datep < '".$db->idate(
dol_mktime(0, 0, 0, $month, $day, $year,
'tzuserrel')).
"'";
832 $sql .=
" AND a.datep2 > '".$db->idate(
dol_mktime(23, 59, 59, $month, $day, $year,
'tzuserrel')).
"')";
837 $sql .=
" (a.datep BETWEEN '".$db->idate($firstdaytoshow - (60 * 60 * 24 * 2)).
"'";
838 $sql .=
" AND '".$db->idate($lastdaytoshow + (60 * 60 * 24 * 2)).
"')";
840 $sql .=
" (a.datep2 BETWEEN '".$db->idate($firstdaytoshow - (60 * 60 * 24 * 2)).
"'";
841 $sql .=
" AND '".$db->idate($lastdaytoshow + (60 * 60 * 24 * 2)).
"')";
843 $sql .=
" (a.datep < '".$db->idate($firstdaytoshow - (60 * 60 * 24 * 2)).
"'";
844 $sql .=
" AND a.datep2 > '".$db->idate($lastdaytoshow + (60 * 60 * 24 * 2)).
"')";
848 $sql .=
" AND ca.id = ".((int) $type);
852 $sql .=
" AND a.percent = 0";
854if ($status ===
'na') {
856 $sql .=
" AND a.percent = -1";
858if ($status ==
'50') {
860 $sql .=
" AND (a.percent > 0 AND a.percent < 100)";
862if ($status ==
'done' || $status ==
'100') {
863 $sql .=
" AND (a.percent = 100)";
865if ($status ==
'todo') {
866 $sql .=
" AND (a.percent >= 0 AND a.percent < 100)";
869if (($filtert > 0 || $filtert == -3) || $usergroup > 0) {
873 $sql .=
"ar.fk_element = ".((int) $filtert);
874 } elseif ($filtert == -3) {
875 $sql .=
"ar.fk_element IN (".$db->sanitize(implode(
',', $user->getAllChildIds(1))).
")";
877 if ($usergroup > 0) {
878 $sql .= ($filtert > 0 ?
" OR " :
"").
" ugu.fk_usergroup = ".((
int) $usergroup);
884if ($search_categ_cus != -1) {
885 if ($search_categ_cus == -2) {
886 $sql .=
" AND NOT EXISTS (SELECT ca.fk_actioncomm FROM ".MAIN_DB_PREFIX.
"categorie_actioncomm as ca WHERE ca.fk_actioncomm = a.id)";
887 } elseif ($search_categ_cus > 0) {
888 $sql .=
" AND EXISTS (SELECT ca.fk_actioncomm FROM ".MAIN_DB_PREFIX.
"categorie_actioncomm as ca WHERE ca.fk_actioncomm = a.id AND ca.fk_categorie IN (".
$db->sanitize((
string) $search_categ_cus).
"))";
892$sql .=
$db->order(
"fk_user_action, datep");
895dol_syslog(
"comm/action/peruser.php", LOG_DEBUG);
896$resql =
$db->query($sql);
898 $num =
$db->num_rows($resql);
902 while ($i < $num && $i < $MAXONSAMEPAGE) {
903 $obj =
$db->fetch_object($resql);
907 if (
getDolGlobalString(
'AGENDA_ALWAYS_HIDE_AUTO') && $obj->type_code ==
'AC_OTH_AUTO') {
912 $datep =
$db->jdate($obj->datep);
913 $datep2 =
$db->jdate($obj->datep2);
919 $event->id = $obj->id;
920 $event->ref = (
string) $event->id;
922 $event->fulldayevent = $obj->fulldayevent;
925 if ($event->fulldayevent) {
927 $event->datep =
$db->jdate($obj->datep, $tzforfullday ?
'tzuser' :
'tzserver');
928 $event->datef =
$db->jdate($obj->datep2, $tzforfullday ?
'tzuser' :
'tzserver');
931 $event->datep =
$db->jdate($obj->datep,
'tzserver');
932 $event->datef =
$db->jdate($obj->datep2,
'tzserver');
938 $event->type_code = $obj->type_code;
939 $event->type_label = $obj->type_label;
940 $event->type_color = $obj->type_color;
941 $event->type = $obj->type_type;
942 $event->type_picto = $obj->type_picto;
944 $event->label = $obj->label;
945 $event->percentage = $obj->percent;
946 $event->authorid = $obj->fk_user_author;
947 $event->userownerid = $obj->fk_user_action;
948 $event->fetch_userassigned();
950 $event->priority = $obj->priority;
951 $event->location = $obj->location;
952 $event->transparency = $obj->transparency;
953 $event->fk_element = $obj->fk_element;
954 $event->elementid = $obj->fk_element;
955 $event->elementtype = $obj->elementtype;
957 $event->fk_project = $obj->fk_project;
959 $event->socid = $obj->fk_soc;
960 $event->contact_id = $obj->fk_contact;
961 $event->fk_bookcal_calendar = $obj->fk_bookcal_calendar;
962 if (!empty($event->fk_bookcal_calendar)) {
963 $event->type =
"bookcal_calendar";
968 $event->date_start_in_calendar = $event->datep;
969 if ($event->datef !=
'' && $event->datef >= $event->datep) {
970 $event->date_end_in_calendar = $event->datef;
972 $event->date_end_in_calendar = $event->datep;
978 if ($event->date_end_in_calendar < $firstdaytoshow || $event->date_start_in_calendar >= $lastdaytoshow) {
982 if ($event->date_start_in_calendar < $firstdaytoshow) {
983 $event->date_start_in_calendar = $firstdaytoshow;
985 if ($event->date_end_in_calendar >= $lastdaytoshow) {
986 $event->date_end_in_calendar = ($lastdaytoshow - 1);
990 $daycursor = $event->date_start_in_calendar;
995 $daycursorend = $event->date_end_in_calendar;
996 $anneeend = (int)
dol_print_date($daycursorend,
'%Y',
'tzuserrel');
997 $moisend = (int)
dol_print_date($daycursorend,
'%m',
'tzuserrel');
998 $jourend = (int)
dol_print_date($daycursorend,
'%d',
'tzuserrel');
1003 $daykey =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
1004 $daykeyend =
dol_mktime(0, 0, 0, $moisend, $jourend, $anneeend,
'gmt');
1018 $eventarray[$daykey][] = $event;
1021 $daykey += 60 * 60 * 24;
1023 if ($daykey > $daykeyend) {
1032 $parameters[
'obj'] = $obj;
1033 $reshook = $hookmanager->executeHooks(
'hookEventElements', $parameters, $event, $action);
1034 $event = $hookmanager->resPrint;
1055if ($user->hasRight(
"holiday",
"read")) {
1056 $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";
1057 $sql .=
" FROM ".MAIN_DB_PREFIX.
"holiday as x, ".MAIN_DB_PREFIX.
"user as u";
1058 $sql .=
" WHERE u.rowid = x.fk_user";
1059 $sql .=
" AND u.statut = '1'";
1060 $sql .=
" AND (x.statut = '2' OR x.statut = '3')";
1062 $sql .=
" AND x.date_debut < '".$db->idate(
dol_get_last_day($year, $month)).
"'";
1063 $sql .=
" AND x.date_fin >= '".$db->idate(
dol_get_first_day($year, $month)).
"'";
1064 if (!$user->hasRight(
'holiday',
'readall')) {
1065 $sql .=
" AND x.fk_user IN(".$db->sanitize(implode(
", ", $user->getAllChildIds(1))).
") ";
1068 $resql =
$db->query($sql);
1070 $num =
$db->num_rows($resql);
1074 $obj =
$db->fetch_object($resql);
1079 $event->id = $obj->rowid;
1080 $event->ref = (
string) $event->id;
1082 $event->type_code =
'HOLIDAY';
1083 $event->type_label =
'';
1084 $event->type_color =
'';
1085 $event->type =
'holiday';
1086 $event->type_picto =
'holiday';
1090 $event->datep = (int)
$db->jdate($obj->date_start,
'gmt') + ((empty($obj->halfday) || $obj->halfday == 1) ? 0 : 12) * 60 * 60;
1091 $event->datef = (int)
$db->jdate($obj->date_end,
'gmt') + ((empty($obj->halfday) || $obj->halfday == -1) ? 24 : 12) * 60 * 60 - 1;
1092 $event->date_start_in_calendar = $event->datep;
1093 $event->date_end_in_calendar = $event->datef;
1095 $event->transparency = 1;
1097 $event->userownerid = $obj->uid;
1098 $event->userassigned = array($obj->uid => array(
'id' => $obj->uid,
'transparency' => 1));
1100 if ($obj->status == 3) {
1102 $event->percentage = -1;
1103 } elseif ($obj->status == 2) {
1105 $event->percentage = 0;
1109 $daycursor = $event->date_start_in_calendar;
1114 $daycursorend = $event->date_end_in_calendar;
1120 $daykey =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
1121 $daykeygmt =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
1126 $firstdayofholiday = ($ifornbofdays == 1);
1127 $lastdayofholiday = ($daykeygmt ==
dol_get_first_hour($event->date_end_in_calendar,
'gmt'));
1131 if ((in_array($obj->halfday, array(1, 2)) == 1 && $lastdayofholiday) || (in_array($obj->halfday, array(-1, 2)) && $firstdayofholiday)) {
1134 if (in_array($obj->halfday, array(1, 2)) && $lastdayofholiday) {
1135 $newevent->label .=
' ('.$langs->trans(
"Morning").
')';
1136 } elseif (in_array($obj->halfday, array(-1, 2)) && $firstdayofholiday) {
1137 $newevent->label .=
' ('.$langs->trans(
"Afternoon").
')';
1139 $eventarray[$daykey][] = $newevent;
1141 $eventarray[$daykey][] = $event;
1144 $daykey += 60 * 60 * 24;
1145 $daykeygmt += 60 * 60 * 24;
1146 }
while ($daykey <= $event->date_end_in_calendar);
1155if (count($listofextcals)) {
1156 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/ical.class.php';
1158 foreach ($listofextcals as $key => $extcal) {
1159 $url = $extcal[
'src'];
1160 $namecal = $extcal[
'name'];
1161 $offsettz = $extcal[
'offsettz'];
1162 $colorcal = $extcal[
'color'];
1163 $buggedfile = $extcal[
'buggedfile'];
1169 $ical->parse($url, $pathforcachefile, $DELAYFORCACHE);
1172 $listofextcals[$key][
'error'] = $ical->error;
1173 $s .=
'<br><div class="warning">'.dol_escape_htmltag($listofextcals[$key][
'name']).
': '.$url.
'<br>Error message: '.
dol_escape_htmltag($ical->error).
'</div>';
1178 $icalevents = array();
1179 if (is_array($ical->get_event_list())) {
1180 $icalevents = array_merge($icalevents, $ical->get_event_list());
1182 if (is_array($ical->get_freebusy_list())) {
1183 $icalevents = array_merge($icalevents, $ical->get_freebusy_list());
1186 if (count($icalevents) > 0) {
1188 $moreicalevents = array();
1189 foreach ($icalevents as $icalevent) {
1190 if (isset($icalevent[
'RRULE']) && is_array($icalevent[
'RRULE'])) {
1193 if ($icalevent[
'DTSTART;VALUE=DATE']) {
1196 } elseif (is_array($icalevent[
'DTSTART']) && !empty($icalevent[
'DTSTART'][
'unixtime'])) {
1197 $datecurstart = $icalevent[
'DTSTART'][
'unixtime'];
1198 $datecurend = $icalevent[
'DTEND'][
'unixtime'];
1199 if (!empty($ical->cal[
'DAYLIGHT'][
'DTSTART']) ) {
1201 $tmpcurstart = $datecurstart;
1202 $tmpcurend = $datecurend;
1203 $tmpdaylightstart =
dol_mktime(0, 0, 0, 1, 1, 1970, 1) + (int) $ical->cal[
'DAYLIGHT'][
'DTSTART'];
1204 $tmpdaylightend =
dol_mktime(0, 0, 0, 1, 1, 1970, 1) + (int) $ical->cal[
'STANDARD'][
'DTSTART'];
1207 if ($tmpcurstart >= $tmpdaylightstart && $tmpcurstart < $tmpdaylightend) {
1208 $datecurstart -= ((int) $ical->cal[
'DAYLIGHT'][
'TZOFFSETTO']) * 36;
1210 $datecurstart -= ((int) $ical->cal[
'STANDARD'][
'TZOFFSETTO']) * 36;
1212 if ($tmpcurend >= $tmpdaylightstart && $tmpcurstart < $tmpdaylightend) {
1213 $datecurend -= ((int) $ical->cal[
'DAYLIGHT'][
'TZOFFSETTO']) * 36;
1215 $datecurend -= ((int) $ical->cal[
'STANDARD'][
'TZOFFSETTO']) * 36;
1222 dol_syslog(
"Found a not recognized repeatable record with unknown date start", LOG_ERR);
1227 $interval = (empty($icalevent[
'RRULE'][
'INTERVAL']) ? 1 : $icalevent[
'RRULE'][
'INTERVAL']);
1228 $until = empty($icalevent[
'RRULE'][
'UNTIL']) ? 0 :
dol_stringtotime($icalevent[
'RRULE'][
'UNTIL'], 1);
1229 $maxrepeat = empty($icalevent[
'RRULE'][
'COUNT']) ? 0 : $icalevent[
'RRULE'][
'COUNT'];
1230 if ($until && ($until + ($datecurend - $datecurstart)) < $firstdaytoshow) {
1233 if ($datecurstart >= $lastdaytoshow) {
1238 while (($datecurstart < $lastdaytoshow) && (empty($maxrepeat) || ($numofevent < $maxrepeat))) {
1239 if ($datecurend >= $firstdaytoshow) {
1240 $newevent = $icalevent;
1241 unset($newevent[
'RRULE']);
1242 if ($icalevent[
'DTSTART;VALUE=DATE']) {
1243 $newevent[
'DTSTART;VALUE=DATE'] =
dol_print_date($datecurstart,
'%Y%m%d');
1244 $newevent[
'DTEND;VALUE=DATE'] =
dol_print_date($datecurend + 1,
'%Y%m%d');
1246 $newevent[
'DTSTART'] = $datecurstart;
1247 $newevent[
'DTEND'] = $datecurend;
1249 $moreicalevents[] = $newevent;
1253 $savdatecurstart = $datecurstart;
1254 if ($icalevent[
'RRULE'][
'FREQ'] ==
'DAILY') {
1258 if ($icalevent[
'RRULE'][
'FREQ'] ==
'WEEKLY') {
1261 } elseif ($icalevent[
'RRULE'][
'FREQ'] ==
'MONTHLY') {
1264 } elseif ($icalevent[
'RRULE'][
'FREQ'] ==
'YEARLY') {
1269 if ($savdatecurstart >= $datecurstart) {
1270 dol_syslog(
"Found a rule freq ".$icalevent[
'RRULE'][
'FREQ'].
" not managed by dolibarr code. Assume 1 week frequency.", LOG_ERR);
1271 $datecurstart += 3600 * 24 * 7;
1272 $datecurend += 3600 * 24 * 7;
1277 $icalevents = array_merge($icalevents, $moreicalevents);
1280 foreach ($icalevents as $icalevent) {
1285 if (!empty($icalevent[
'RRULE'])) {
1294 if (isset($icalevent[
'DTSTART;VALUE=DATE'])) {
1297 if (empty($icalevent[
'DTEND;VALUE=DATE'])) {
1298 $dateend = $datestart + 86400 - 1;
1304 $event->fulldayevent = 1;
1306 } elseif (!is_array($icalevent[
'DTSTART'])) {
1307 $datestart = $icalevent[
'DTSTART'];
1308 $dateend = empty($icalevent[
'DTEND']) ? $datestart : $icalevent[
'DTEND'];
1310 $datestart += +($offsettz * 3600);
1311 $dateend += +($offsettz * 3600);
1316 } elseif (isset($icalevent[
'DTSTART'][
'unixtime'])) {
1317 $datestart = $icalevent[
'DTSTART'][
'unixtime'];
1318 $dateend = $icalevent[
'DTEND'][
'unixtime'];
1320 $datestart += +($offsettz * 3600);
1321 $dateend += +($offsettz * 3600);
1324 if ($buggedfile ===
'uselocalandtznodaylight') {
1328 if ($buggedfile ===
'uselocalandtzdaylight') {
1329 $localtzs =
new DateTimeZone((
string) preg_replace(
'/"/',
'', $icalevent[
'DTSTART'][
'TZID']));
1330 $localtze =
new DateTimeZone((
string) preg_replace(
'/"/',
'', $icalevent[
'DTEND'][
'TZID']));
1331 $localdts =
new DateTime(
dol_print_date($datestart,
'dayrfc',
'gmt'), $localtzs);
1332 $localdte =
new DateTime(
dol_print_date($dateend,
'dayrfc',
'gmt'), $localtze);
1333 $tmps = -1 * $localtzs->getOffset($localdts);
1334 $tmpe = -1 * $localtze->getOffset($localdte);
1335 $datestart += $tmps;
1342 if ($addevent && $datestart !==
null && $dateend !==
null) {
1343 $event->id = $icalevent[
'UID'];
1344 $event->ref = (
string) $event->id;
1346 $userId = $userstatic->findUserIdByEmail($namecal);
1347 if (!empty($userId) && $userId > 0) {
1348 $event->userassigned[$userId] = [
1350 'transparency' => 1,
1352 $event->percentage = -1;
1355 $event->type_code =
"ICALEVENT";
1356 $event->type_label = $namecal;
1357 $event->type_color = $colorcal;
1358 $event->type =
'icalevent';
1359 $event->type_picto =
'rss';
1361 $event->icalname = $namecal;
1362 $event->icalcolor = $colorcal;
1364 $event->datep = (int) ($datestart + $usertime);
1365 $event->datef = (int) ($dateend + $usertime);
1367 if (isset($icalevent[
'SUMMARY']) && $icalevent[
'SUMMARY']) {
1369 } elseif (isset($icalevent[
'DESCRIPTION']) && $icalevent[
'DESCRIPTION']) {
1372 $event->label = $langs->trans(
"ExtSiteNoLabel");
1379 if (!empty($icalevent[
'PRIORITY'])) {
1380 $event->priority = $icalevent[
'PRIORITY'];
1384 if (!empty($icalevent[
'TRANSP'])) {
1385 if ($icalevent[
'TRANSP'] ==
"TRANSPARENT") {
1386 $event->transparency = 0;
1388 if ($icalevent[
'TRANSP'] ==
"OPAQUE") {
1389 $event->transparency = 1;
1400 if (!empty($icalevent[
'LOCATION'])) {
1401 $event->location = $icalevent[
'LOCATION'];
1404 $event->date_start_in_calendar = $event->datep;
1406 if ((
int) $event->datef != 0 && $event->datef >= $event->datep) {
1407 $event->date_end_in_calendar = $event->datef;
1409 $event->date_end_in_calendar = $event->datep;
1413 if ($event->date_end_in_calendar < $firstdaytoshow || $event->date_start_in_calendar >= $lastdaytoshow) {
1419 if ($event->date_start_in_calendar < $firstdaytoshow) {
1420 $event->date_start_in_calendar = $firstdaytoshow;
1422 if ($event->date_end_in_calendar >= $lastdaytoshow) {
1423 $event->date_end_in_calendar = ($lastdaytoshow - 1);
1427 $daycursor = $event->date_start_in_calendar;
1436 $daykey =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
1437 $daykeygmt =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
1440 $eventarray[$daykey][] = $event;
1441 $daykey += 60 * 60 * 24;
1442 $daykeygmt += 60 * 60 * 24;
1443 if (($event->fulldayevent ? $daykeygmt : $daykey) > $event->date_end_in_calendar) {
1455$parameters = array();
1457$reshook = $hookmanager->executeHooks(
'getCalendarEvents', $parameters, $object, $action);
1458if (!empty($hookmanager->resArray[
'eventarray'])) {
1459 foreach ($hookmanager->resArray[
'eventarray'] as $keyDate => $events) {
1460 if (!isset($eventarray[$keyDate])) {
1461 $eventarray[$keyDate] = array();
1463 $eventarray[$keyDate] = array_merge($eventarray[$keyDate], $events);
1475$cachethirdparties = array();
1476$cachecontacts = array();
1480 array(137, 86, 161),
1481 array(60, 147, 183),
1482 array(250, 190, 80),
1484 array(190, 190, 100),
1485 array(91, 115, 247),
1486 array(140, 140, 220),
1487 array(190, 120, 120),
1488 array(115, 125, 150),
1489 array(100, 170, 20),
1490 array(150, 135, 125),
1491 array(85, 135, 150),
1492 array(150, 135, 80),
1496$color_file = DOL_DOCUMENT_ROOT.
"/theme/".
$conf->theme.
"/theme_vars.inc.php";
1497if (is_readable($color_file)) {
1498 include $color_file;
1502$massactionbutton =
'';
1506print_barre_liste($langs->trans(
"Agenda"), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, -1,
'object_action', 0, $nav.
'<span class="marginleftonly"></span>'.$newcardbutton,
'', $limit, 1, 0, 1, $viewmode);
1514print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1515print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday,
'', (
string) $filtert,
'', $pid, $socid, $action, -1, $actioncode, $usergroup,
'', $resourceid, $search_categ_cus);
1520$newparam = preg_replace(
'/showbirthday=/i',
'showbirthday_=', $newparam);
1521$newparam = preg_replace(
'/mode=show_month&?/i',
'', $newparam);
1522$newparam = preg_replace(
'/mode=show_week&?/i',
'', $newparam);
1523$newparam = preg_replace(
'/day=[0-9]+&?/i',
'', $newparam);
1524$newparam = preg_replace(
'/month=[0-9]+&?/i',
'', $newparam);
1525$newparam = preg_replace(
'/year=[0-9]+&?/i',
'', $newparam);
1526$newparam = preg_replace(
'/viewweek=[0-9]+&?/i',
'', $newparam);
1527$newparam = preg_replace(
'/showbirthday_=/i',
'showbirthday=', $newparam);
1528$newparam .=
'&viewweek=1';
1530echo
'<input type="hidden" name="actionmove" value="mupdate">';
1531echo
'<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($_SERVER[
'PHP_SELF']).
'?'.
dol_escape_htmltag($_SERVER[
'QUERY_STRING']).
'">';
1532echo
'<input type="hidden" name="newdate" id="newdate">';
1539$currentdaytoshow = $firstdaytoshow;
1540echo
'<div class="div-table-responsive">';
1543$colorsbytype = array();
1545while ($currentdaytoshow < $lastdaytoshow) {
1546 echo
'<table class="centpercent noborder nocellnopadd cal_month cal_peruser listwithfilterbefore">';
1548 echo
'<tr class="liste_titre">';
1549 echo
'<td class="nopaddingtopimp nopaddingbottomimp nowraponsmartphone">';
1553 print
'<span class="hideonsmartphone" title="'.$langs->trans(
"VisibleDaysRange").
'">';
1554 print
img_picto(
'',
'clock',
'class="fawidth30 inline-block marginleftonly"');
1555 print $langs->trans(
"DaysOfWeek").
'</span>';
1557 print
'<div class="ui-grid-a inline-block"><div class="ui-block-a nowraponall">';
1558 print
'<input type="number" class="shortbis" name="begin_d" value="'.$begin_d.
'" min="1" max="7">';
1559 if (empty(
$conf->dol_use_jmobile)) {
1562 print
'</div><div class="ui-block-b">';
1564 print
'<input type="number" class="shortbis" name="end_d" value="'.$end_d.
'" min="1" max="7">';
1565 print
'</div></div>';
1571 if (($i + 1) < $begin_d || ($i + 1) > $end_d) {
1575 echo
'<td align="center" colspan="'.($end_h - $begin_h).
'">';
1576 echo
'<span class="bold spandayofweek">'.$langs->trans(
"Day".(($i +
getDolGlobalInt(
'MAIN_START_WEEK', 1)) % 7)).
'</span>';
1581 $valtoshow = $currentdaytoshow;
1584 echo
'<span class="badgeliketopmenu">';
1586 print
dol_print_date($valtoshow,
'dayreduceformat',
'tzuserrel');
1595 echo
'<tr class="liste_titre">';
1599 print
'<span class="hideonsmartphone" title="'.$langs->trans(
"VisibleTimeRange").
'">';
1600 print
img_picto(
'',
'clock',
'class="fawidth30 inline-block marginleftonly"');
1601 print $langs->trans(
"Hours").
'</span>';
1603 print
'<div class="ui-grid-a inline-block"><div class="ui-block-a nowraponall">';
1604 print
'<input type="number" class="shortbis" name="begin_h" value="'.$begin_h.
'" min="0" max="23">';
1605 if (empty(
$conf->dol_use_jmobile)) {
1608 print
'</div><div class="ui-block-b">';
1610 print
'<input type="number" class="shortbis" name="end_h" value="'.$end_h.
'" min="1" max="24">';
1611 if (empty(
$conf->dol_use_jmobile)) {
1612 print
' '.$langs->trans(
"HourShort");
1614 print
'</div></div>';
1619 if (($i + 1) < $begin_d || ($i + 1) > $end_d) {
1623 for ($h = $begin_h; $h < $end_h; $h++) {
1624 echo
'<td class="center">';
1625 print
'<small style="font-family: courier">'.sprintf(
"%02d", $h).
'</small>';
1635 $usernames = array();
1636 $usernamesid = array();
1639 foreach ($eventarray as $daykey => $notused) {
1641 foreach ($eventarray[$daykey] as $index => $event) {
1642 $event->fetch_userassigned();
1643 $listofuserid = $event->userassigned;
1644 foreach ($listofuserid as $userid => $tmp) {
1645 if (!in_array($userid, $usernamesid)) {
1646 $usernamesid[$userid] = $userid;
1653 $sql =
"SELECT u.rowid, u.lastname as lastname, u.firstname, u.statut, u.login, u.admin, u.entity";
1654 $sql .=
" FROM ".$db->prefix().
"user as u";
1656 $sql .=
" WHERE u.rowid IN (";
1657 $sql .=
" SELECT ug.fk_user FROM ".$db->prefix().
"usergroup_user as ug";
1658 $sql .=
" WHERE ug.entity IN (".getEntity(
'usergroup').
")";
1659 if ($usergroup > 0) {
1660 $sql .=
" AND ug.fk_usergroup = ".((int) $usergroup);
1664 if ($usergroup > 0) {
1665 $sql .=
" LEFT JOIN ".$db->prefix().
"usergroup_user as ug ON u.rowid = ug.fk_user";
1667 $sql .=
" WHERE u.entity IN (".getEntity(
'user').
")";
1668 if ($usergroup > 0) {
1669 $sql .=
" AND ug.fk_usergroup = ".((int) $usergroup);
1672 $sql .=
" AND u.statut = 1";
1674 $sql .=
" AND u.rowid = ".((int) $filtert);
1676 if ($usergroup > 0) {
1677 $sql .=
" AND ug.fk_usergroup = ".((int) $usergroup);
1679 if ($user->socid > 0) {
1681 $sql .=
" AND u.fk_soc = ".((int) $user->socid);
1684 if (!$canedit || $filtert ==
'-3') {
1685 if (!$user->hasRight(
'user',
'user',
'lire') || $filtert ==
'-3') {
1686 $usersInHierarchy = $user->getAllChildIds(1);
1687 $sql .=
" AND u.rowid IN (".$db->sanitize(implode(
',', $usersInHierarchy)).
")";
1692 $resql =
$db->query($sql);
1694 $num =
$db->num_rows($resql);
1698 $obj =
$db->fetch_object($resql);
1699 $usernamesid[$obj->rowid] = $obj->rowid;
1708 foreach ($usernamesid as
$id) {
1710 $result = $tmpuser->fetch(
$id);
1711 $usernames[] = $tmpuser;
1715 $labelbytype = array();
1716 $sql =
"SELECT code, color, libelle as label FROM ".MAIN_DB_PREFIX.
"c_actioncomm ORDER BY position";
1717 $resql =
$db->query($sql);
1718 while ($obj =
$db->fetch_object($resql)) {
1719 $colorsbytype[$obj->code] = $obj->color;
1720 $labelbytype[$obj->code] = $obj->label;
1728 foreach ($usernames as $username) {
1734 echo
'<td class="tdoverflowmax100 cal_current_month cal_peruserviewname'.($var ?
' cal_impair' :
'').
' nopaddingtopimp nopaddingbottomimp noheightimp">';
1735 print
'<span class="paddingrightimp">';
1736 print $username->getNomUrl(-1,
'', 0, 0, 20, 1,
'',
'paddingleft');
1743 for ($iter_day = 0; $iter_day < 8; $iter_day++) {
1744 if (($i + 1) < $begin_d || ($i + 1) > $end_d) {
1757 $style =
'cal_current_month';
1758 if ($iter_day == 6) {
1759 $style .=
' cal_other_month';
1762 if ($todayarray[
'mday'] == $tmpday && $todayarray[
'mon'] == $tmpmonth && $todayarray[
'year'] == $tmpyear) {
1766 $style =
'cal_today_peruser';
1769 show_day_events2($username, $tmpday, $tmpmonth, $tmpyear, 0, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, $showheader, $colorsbytype, $var);
1774 $showheader =
false;
1786 $langs->load(
"commercial");
1787 print
'<br>'.$langs->trans(
"Legend").
': <br>';
1788 foreach ($colorsbytype as $code => $color) {
1790 print
'<div style="float: left; padding: 2px; margin-right: 6px;"><div style="background: #'.$color.
'; width:16px; float: left; margin-right: 4px;"> </div>';
1791 print $langs->trans(
"Action".$code) !=
"Action".$code ? $langs->trans(
"Action".$code) : $labelbytype[$code];
1797 print
'<div style="float: left; padding: 2px; margin-right: 6px;"><div class="peruser_busy" style="width:16px; float: left; margin-right: 4px;"> </div>';
1798 print $langs->trans(
"Other");
1807print
"\n".
'</form>';
1812print
'<script type="text/javascript">
1813jQuery(document).ready(function() {
1814 jQuery(".onclickopenref").click(function() {
1815 var ref=$(this).attr(\'ref\');
1816 var res = ref.split("_");
1818 var userid = res[1];
1826 console.log("We click on a class onclickopenref in page peruser with ref="+ref+" type="+type);
1828 if (ids == \'none\') /* No event */
1830 /* alert(\'no event\'); */
1831 url = "'.DOL_URL_ROOT.
'/comm/action/card.php?action=create&assignedtouser="+userid+"&datep="+year+month+day+hour+min+"00&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?year='.$year.
'&month='.$month.
'&day='.$day.($begin_h !==
'' ?
'&begin_h='.$begin_h :
'').($end_h !==
'' ?
'&end_h='.$end_h :
'').($begin_d !==
'' ?
'&begin_d='.$begin_d :
'').($end_d !==
'' ?
'&end_d='.$end_d :
'')).
'"
1832 window.location.href = url;
1834 else if (ids.indexOf(",") > -1) /* There is several events */
1836 /* alert(\'several events\'); */
1837 url = "'.DOL_URL_ROOT.
'/comm/action/list.php?mode=show_list&search_actioncode="+jQuery("#search_actioncode").val()+"&search_status="+jQuery("#selectsearch_status").val()+"&filtert="+userid+"&dateselectyear="+year+"&dateselectmonth="+month+"&dateselectday="+day;
1838 window.location.href = url;
1839 } else { /* One event */
1840 /* alert(\'one event\'); */
1841 if (type == \'holiday\') {
1842 url = "'.DOL_URL_ROOT.
'/holiday/card.php?id="+ids
1844 url = "'.DOL_URL_ROOT.
'/comm/action/card.php?action=view&id="+ids
1846 window.location.href = url;
1879function show_day_events2($username, $day, $month, $year, $monthshown, $style, &$eventarray, $maxprint = 0, $maxnbofchar = 16, $newparam =
'', $showinfo = 0, $minheight = 60, $showheader =
false, $colorsbytype = array(), $var =
false)
1882 global $user,
$conf, $langs, $hookmanager, $action;
1883 global $filter, $filtert, $status, $actioncode;
1885 global $cachethirdparties, $cachecontacts,
$cacheusers, $cacheprojects, $colorindexused;
1886 global $begin_h, $end_h;
1900 @phan-var-force array<int,array<int,array<string,string|int|bool>>> $cases1
1901 @phan-var-force array<int,array<int,array<string,string|int|bool>>> $cases2
1902 @phan-var-force array<int,array<int,array<string,string|int|bool>>> $cases3
1903 @phan-var-force array<int,array<int,array<string,string|int|bool>>> $cases4
1910 $numicals = array();
1913 $colorindexused[$user->id] = 0;
1914 $nextindextouse = count($colorindexused);
1921 foreach ($eventarray as $daykey => $notused) {
1928 if ($day == $jour && (
int) $month == $mois && $year == $annee) {
1932 foreach ($eventarray[$daykey] as $index => $event) {
1936 $keysofuserassigned = array_keys($event->userassigned);
1938 if (!in_array($username->id, $keysofuserassigned)) {
1943 $parameters = array();
1944 $reshook = $hookmanager->executeHooks(
'formatEvent', $parameters, $event, $action);
1954 if ($event->type_code ==
'HOLIDAY') {
1955 $cssclass =
'family_holiday';
1958 if (in_array($user->id, $keysofuserassigned)) {
1959 $cssclass =
'family_mytasks';
1961 if (empty($cacheusers[$event->userownerid])) {
1963 $newuser->fetch($event->userownerid);
1969 if (!empty($cacheusers[$event->userownerid]->color)) {
1974 $color = $event->type_color;
1976 } elseif ($event->type_code ==
'ICALEVENT') {
1978 if (!empty($event->icalname)) {
1985 $color = $event->icalcolor;
1986 $cssclass = (!empty($event->icalname) ?
'family_ext'.md5($event->icalname) :
'family_other unsortable');
1987 } elseif ($event->type_code ==
'BIRTHDAY') {
1990 $cssclass =
'family_birthday unsortable';
1991 $color = sprintf(
"%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
1994 $color = ($event->icalcolor ? $event->icalcolor : -1);
1995 $cssclass = (!empty($event->icalname) ?
'family_ext'.md5($event->icalname) :
'family_other');
1997 if (empty($cacheusers[$event->userownerid])) {
1999 $newuser->fetch($event->userownerid);
2005 if (!empty($cacheusers[$event->userownerid]->color)) {
2010 $color = $event->type_color;
2016 $idusertouse = ($event->userownerid ? $event->userownerid : 0);
2017 if (isset($colorindexused[$idusertouse])) {
2018 $colorindex = $colorindexused[$idusertouse];
2020 $colorindex = $nextindextouse;
2021 $colorindexused[$idusertouse] = $colorindex;
2022 if (!empty($theme_datacolor[$nextindextouse + 1])) {
2027 $color = sprintf(
"%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
2031 for ($h = $begin_h; $h < $end_h; $h++) {
2034 if (empty($event->fulldayevent)) {
2035 $a =
dol_mktime((
int) $h, 0, 0, $month, $day, $year,
'tzuserrel', 0);
2036 $b =
dol_mktime((
int) $h, 15, 0, $month, $day, $year,
'tzuserrel', 0);
2037 $b1 =
dol_mktime((
int) $h, 30, 0, $month, $day, $year,
'tzuserrel', 0);
2038 $b2 =
dol_mktime((
int) $h, 45, 0, $month, $day, $year,
'tzuserrel', 0);
2039 $c =
dol_mktime((
int) $h + 1, 0, 0, $month, $day, $year,
'tzuserrel', 0);
2041 $dateendtouse = $event->date_end_in_calendar;
2042 if ($dateendtouse == $event->date_start_in_calendar) {
2047 if ($event->date_start_in_calendar < $b && $dateendtouse > $a) {
2048 $busy = $event->transparency;
2049 $cases1[$h][$event->id][
'busy'] = $busy;
2050 $cases1[$h][$event->id][
'string'] =
dol_print_date($event->date_start_in_calendar,
'dayhour',
'tzuserrel');
2051 if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) {
2052 $tmpa =
dol_getdate($event->date_start_in_calendar,
true);
2053 $tmpb =
dol_getdate($event->date_end_in_calendar,
true);
2054 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) {
2055 $cases1[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'hour',
'tzuserrel');
2057 $cases1[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'dayhour',
'tzuserrel');
2060 if ($event->label) {
2061 $cases1[$h][$event->id][
'string'] .=
' - '.$event->label;
2063 $cases1[$h][$event->id][
'typecode'] = $event->type_code;
2064 if ($event->type_code ==
'HOLIDAY') {
2065 $cases1[$h][$event->id][
'css'] =
'peruser_holiday ';
2067 $cases1[$h][$event->id][
'css'] .=
'peruser_holiday_imp ';
2070 $cases1[$h][$event->id][
'color'] = $color;
2072 if ($event->fk_project > 0) {
2073 if (empty($cacheprojects[$event->fk_project])) {
2075 $tmpproj->fetch($event->fk_project);
2076 $cacheprojects[$event->fk_project] = $tmpproj;
2078 $cases1[$h][$event->id][
'string'] .=
', '.$langs->trans(
"Project").
': '.$cacheprojects[$event->fk_project]->ref.
' - '.$cacheprojects[$event->fk_project]->title;
2080 if ($event->socid > 0) {
2081 if (empty($cachethirdparties[$event->socid])) {
2083 $tmpthirdparty->fetch($event->socid);
2084 $cachethirdparties[$event->socid] = $tmpthirdparty;
2086 $cases1[$h][$event->id][
'string'] .=
', '.$cachethirdparties[$event->socid]->name;
2088 if ($event->contact_id > 0) {
2089 if (empty($cachecontacts[$event->contact_id])) {
2091 $tmpcontact->fetch($event->contact_id);
2092 $cachecontacts[$event->contact_id] = $tmpcontact;
2094 $cases1[$h][$event->id][
'string'] .=
', '.$cachecontacts[$event->contact_id]->getFullName($langs);
2098 if ($event->date_start_in_calendar < $b1 && $dateendtouse > $b) {
2099 $busy = $event->transparency;
2100 $cases2[$h][$event->id][
'busy'] = $busy;
2101 $cases2[$h][$event->id][
'string'] =
dol_print_date($event->date_start_in_calendar,
'dayhour',
'tzuserrel');
2102 if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) {
2103 $tmpa =
dol_getdate($event->date_start_in_calendar,
true);
2104 $tmpb =
dol_getdate($event->date_end_in_calendar,
true);
2105 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) {
2106 $cases2[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'hour',
'tzuserrel');
2108 $cases2[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'dayhour',
'tzuserrel');
2111 if ($event->label) {
2112 $cases2[$h][$event->id][
'string'] .=
' - '.$event->label;
2114 $cases2[$h][$event->id][
'typecode'] = $event->type_code;
2115 if ($event->type_code ==
'HOLIDAY') {
2116 $cases2[$h][$event->id][
'css'] =
'peruser_holiday ';
2118 $cases2[$h][$event->id][
'css'] .=
'peruser_holiday_imp ';
2121 $cases2[$h][$event->id][
'color'] = $color;
2123 if ($event->fk_project > 0) {
2124 if (empty($cacheprojects[$event->fk_project])) {
2126 $tmpproj->fetch($event->fk_project);
2127 $cacheprojects[$event->fk_project] = $tmpproj;
2129 $cases2[$h][$event->id][
'string'] .=
', '.$langs->trans(
"Project").
': '.$cacheprojects[$event->fk_project]->ref.
' - '.$cacheprojects[$event->fk_project]->title;
2131 if ($event->socid > 0) {
2132 if (empty($cachethirdparties[$event->socid])) {
2134 $tmpthirdparty->fetch($event->socid);
2135 $cachethirdparties[$event->socid] = $tmpthirdparty;
2137 $cases2[$h][$event->id][
'string'] .=
', '.$cachethirdparties[$event->socid]->name;
2139 if ($event->contact_id > 0) {
2140 if (empty($cachecontacts[$event->contact_id])) {
2142 $tmpcontact->fetch($event->contact_id);
2143 $cachecontacts[$event->contact_id] = $tmpcontact;
2145 $cases2[$h][$event->id][
'string'] .=
', '.$cachecontacts[$event->contact_id]->getFullName($langs);
2149 if ($event->date_start_in_calendar < $b2 && $dateendtouse > $b1) {
2150 $busy = $event->transparency;
2151 $cases3[$h][$event->id][
'busy'] = $busy;
2152 $cases3[$h][$event->id][
'string'] =
dol_print_date($event->date_start_in_calendar,
'dayhour',
'tzuserrel');
2153 if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) {
2154 $tmpa =
dol_getdate($event->date_start_in_calendar,
true);
2155 $tmpb =
dol_getdate($event->date_end_in_calendar,
true);
2156 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) {
2157 $cases3[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'hour',
'tzuserrel');
2159 $cases3[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'dayhour',
'tzuserrel');
2162 if ($event->label) {
2163 $cases3[$h][$event->id][
'string'] .=
' - '.$event->label;
2165 $cases3[$h][$event->id][
'typecode'] = $event->type_code;
2166 if ($event->type_code ==
'HOLIDAY') {
2167 $cases3[$h][$event->id][
'css'] .=
'peruser_holiday ';
2169 $cases3[$h][$event->id][
'css'] .=
'peruser_holiday_imp ';
2172 $cases3[$h][$event->id][
'color'] = $color;
2174 if ($event->fk_project > 0) {
2175 if (empty($cacheprojects[$event->fk_project])) {
2177 $tmpproj->fetch($event->fk_project);
2178 $cacheprojects[$event->fk_project] = $tmpproj;
2180 $cases3[$h][$event->id][
'string'] .=
', '.$langs->trans(
"Project").
': '.$cacheprojects[$event->fk_project]->ref.
' - '.$cacheprojects[$event->fk_project]->title;
2182 if ($event->socid > 0) {
2183 if (empty($cachethirdparties[$event->socid])) {
2185 $tmpthirdparty->fetch($event->socid);
2186 $cachethirdparties[$event->socid] = $tmpthirdparty;
2188 $cases3[$h][$event->id][
'string'] .=
', '.$cachethirdparties[$event->socid]->name;
2190 if ($event->contact_id > 0) {
2191 if (empty($cachecontacts[$event->contact_id])) {
2193 $tmpcontact->fetch($event->contact_id);
2194 $cachecontacts[$event->contact_id] = $tmpcontact;
2196 $cases3[$h][$event->id][
'string'] .=
', '.$cachecontacts[$event->contact_id]->getFullName($langs);
2200 if ($event->date_start_in_calendar <
$c && $dateendtouse > $b2) {
2201 $busy = $event->transparency;
2202 $cases4[$h][$event->id][
'busy'] = $busy;
2203 $cases4[$h][$event->id][
'string'] =
dol_print_date($event->date_start_in_calendar,
'dayhour',
'tzuserrel');
2204 if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) {
2205 $tmpa =
dol_getdate($event->date_start_in_calendar,
true);
2206 $tmpb =
dol_getdate($event->date_end_in_calendar,
true);
2207 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) {
2208 $cases4[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'hour',
'tzuserrel');
2210 $cases4[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'dayhour',
'tzuserrel');
2213 if ($event->label) {
2214 $cases4[$h][$event->id][
'string'] .=
' - '.$event->label;
2216 $cases4[$h][$event->id][
'typecode'] = $event->type_code;
2217 if ($event->type_code ==
'HOLIDAY') {
2218 $cases4[$h][$event->id][
'css'] =
'peruser_holiday ';
2220 $cases4[$h][$event->id][
'css'] .=
'peruser_holiday_imp ';
2223 $cases4[$h][$event->id][
'color'] = $color;
2225 if ($event->fk_project > 0) {
2226 if (empty($cacheprojects[$event->fk_project])) {
2228 $tmpproj->fetch($event->fk_project);
2229 $cacheprojects[$event->fk_project] = $tmpproj;
2231 $cases4[$h][$event->id][
'string'] .=
', '.$langs->trans(
"Project").
': '.$cacheprojects[$event->fk_project]->ref.
' - '.$cacheprojects[$event->fk_project]->title;
2233 if ($event->socid > 0) {
2234 if (empty($cachethirdparties[$event->socid])) {
2236 $tmpthirdparty->fetch($event->socid);
2237 $cachethirdparties[$event->socid] = $tmpthirdparty;
2239 $cases4[$h][$event->id][
'string'] .=
', '.$cachethirdparties[$event->socid]->name;
2241 if ($event->contact_id > 0) {
2242 if (empty($cachecontacts[$event->contact_id])) {
2244 $tmpcontact->fetch($event->contact_id);
2245 $cachecontacts[$event->contact_id] = $tmpcontact;
2247 $cases4[$h][$event->id][
'string'] .=
', '.$cachecontacts[$event->contact_id]->getFullName($langs);
2252 $busy = $event->transparency;
2253 $cases1[$h][$event->id][
'busy'] = $busy;
2254 $cases2[$h][$event->id][
'busy'] = $busy;
2255 $cases3[$h][$event->id][
'busy'] = $busy;
2256 $cases4[$h][$event->id][
'busy'] = $busy;
2257 $cases1[$h][$event->id][
'string'] = $event->label;
2258 $cases2[$h][$event->id][
'string'] = $event->label;
2259 $cases3[$h][$event->id][
'string'] = $event->label;
2260 $cases4[$h][$event->id][
'string'] = $event->label;
2261 $cases1[$h][$event->id][
'typecode'] = $event->type_code;
2262 $cases2[$h][$event->id][
'typecode'] = $event->type_code;
2263 $cases3[$h][$event->id][
'typecode'] = $event->type_code;
2264 $cases4[$h][$event->id][
'typecode'] = $event->type_code;
2265 $cases1[$h][$event->id][
'color'] = $color;
2266 $cases2[$h][$event->id][
'color'] = $color;
2267 $cases3[$h][$event->id][
'color'] = $color;
2268 $cases4[$h][$event->id][
'color'] = $color;
2269 $cases1[$h][$event->id][
'css'] =
'';
2270 $cases2[$h][$event->id][
'css'] =
'';
2271 $cases3[$h][$event->id][
'css'] =
'';
2272 $cases4[$h][$event->id][
'css'] =
'';
2283 for ($h = $begin_h; $h < $end_h; $h++) {
2288 $style1 =
'onclickopenref ';
2289 $style2 =
'onclickopenref ';
2290 $style3 =
'onclickopenref ';
2291 $style4 =
'onclickopenref ';
2292 $string1 =
' ';
2293 $string2 =
' ';
2294 $string3 =
' ';
2295 $string4 =
' ';
2300 if (isset($cases1[$h])) {
2302 if (count($cases1[$h]) > 1) {
2303 $title1 .= count($cases1[$h]).
' '.(count($cases1[$h]) == 1 ? $langs->trans(
"Event") : $langs->trans(
"Events"));
2306 $peruserbusyadded = 0;
2307 $perusernotbusyadded = 0;
2308 foreach ($cases1[$h] as
$id => $ev) {
2309 if (!empty($ev[
'busy']) && !
getDolGlobalString(
'AGENDA_NO_TRANSPARENT_ON_NOT_BUSY')) {
2310 $style1 .= $peruserbusyadded ?
'' :
' peruser_busy';
2311 $peruserbusyadded++;
2313 $style1 .= $perusernotbusyadded ?
'' :
'peruser_notbusy ';
2314 $perusernotbusyadded++;
2316 if (!empty($ev[
'css'])) {
2317 $style1 .= $ev[
'css'].
' ';
2321 if (isset($cases2[$h])) {
2323 if (count($cases2[$h]) > 1) {
2324 $title2 .= count($cases2[$h]).
' '.(count($cases2[$h]) == 1 ? $langs->trans(
"Event") : $langs->trans(
"Events"));
2327 $peruserbusyadded = 0;
2328 $perusernotbusyadded = 0;
2329 foreach ($cases2[$h] as
$id => $ev) {
2330 if (!empty($ev[
'busy']) && !
getDolGlobalString(
'AGENDA_NO_TRANSPARENT_ON_NOT_BUSY')) {
2331 $style2 .= $peruserbusyadded ?
'' :
' peruser_busy';
2332 $peruserbusyadded++;
2334 $style2 .= $perusernotbusyadded ?
'' :
'peruser_notbusy ';
2335 $perusernotbusyadded++;
2337 if (!empty($ev[
'css'])) {
2338 $style2 .= $ev[
'css'].
' ';
2342 if (isset($cases3[$h])) {
2344 if (count($cases3[$h]) > 1) {
2345 $title3 .= count($cases3[$h]).
' '.(count($cases3[$h]) == 1 ? $langs->trans(
"Event") : $langs->trans(
"Events"));
2348 $peruserbusyadded = 0;
2349 $perusernotbusyadded = 0;
2350 foreach ($cases3[$h] as
$id => $ev) {
2351 if (!empty($ev[
'busy']) && !
getDolGlobalString(
'AGENDA_NO_TRANSPARENT_ON_NOT_BUSY')) {
2352 $style3 .= $peruserbusyadded ?
'' :
' peruser_busy';
2353 $peruserbusyadded++;
2355 $style3 .= $perusernotbusyadded ?
'' :
'peruser_notbusy ';
2356 $perusernotbusyadded++;
2358 if (!empty($ev[
'css'])) {
2359 $style3 .= $ev[
'css'].
' ';
2363 if (isset($cases4[$h])) {
2365 if (count($cases4[$h]) > 1) {
2366 $title4 .= count($cases4[$h]).
' '.(count($cases4[$h]) == 1 ? $langs->trans(
"Event") : $langs->trans(
"Events"));
2369 $peruserbusyadded = 0;
2370 $perusernotbusyadded = 0;
2371 foreach ($cases4[$h] as
$id => $ev) {
2372 if (!empty($ev[
'busy']) && !
getDolGlobalString(
'AGENDA_NO_TRANSPARENT_ON_NOT_BUSY')) {
2373 $style4 .= $peruserbusyadded ?
'' :
' peruser_busy';
2374 $peruserbusyadded++;
2376 $style4 .= $perusernotbusyadded ?
'' :
'peruser_notbusy ';
2377 $perusernotbusyadded++;
2379 if (!empty($ev[
'css'])) {
2380 $style4 .= $ev[
'css'].
' ';
2389 if (!empty($cases1[$h]) && is_array($cases1[$h]) && count($cases1[$h]) && array_keys($cases1[$h])) {
2390 $ids1 = implode(
', ', array_keys($cases1[$h]));
2392 if (!empty($cases2[$h]) && is_array($cases2[$h]) && count($cases2[$h]) && array_keys($cases2[$h])) {
2393 $ids2 = implode(
', ', array_keys($cases2[$h]));
2395 if (!empty($cases3[$h]) && is_array($cases3[$h]) && count($cases3[$h]) && array_keys($cases3[$h])) {
2396 $ids3 = implode(
',', array_keys($cases3[$h]));
2398 if (!empty($cases4[$h]) && is_array($cases4[$h]) && count($cases4[$h]) && array_keys($cases4[$h])) {
2399 $ids4 = implode(
',', array_keys($cases4[$h]));
2402 if ($h == $begin_h) {
2403 echo
'<td class="'.$style.
'_peruserleft cal_peruser'.($var ?
' cal_impair '.$style.
'_impair' :
'').
'">';
2405 echo
'<td class="'.$style.
' cal_peruser'.($var ?
' cal_impair '.$style.
'_impair' :
'').
'">';
2410 if (!empty($cases1[$h]) && is_array($cases1[$h]) && count($cases1[$h]) == 1) {
2411 $output = array_slice($cases1[$h], 0, 1);
2412 if ($output[0][
'typecode'] ==
'HOLIDAY') {
2414 $title1 = $langs->trans(
"Holiday");
2416 $title1 = $langs->trans(
"Ref").
' '.$ids1.($title1 ?
' - '.$title1 :
'');
2417 if ($output[0][
'string']) {
2418 $title1 .=
' - '.$output[0][
'string'];
2421 if ($output[0][
'color']) {
2422 $color1 = $output[0][
'color'];
2424 } elseif (!empty($cases1[$h]) && is_array($cases1[$h]) && count($cases1[$h]) > 1) {
2425 $title1 = $langs->trans(
"Ref").
' '.$ids1.($title1 ?
' - '.$title1 :
'');
2431 if (!empty($cases2[$h]) && is_array($cases2[$h]) && count($cases2[$h]) == 1) {
2432 $output = array_slice($cases2[$h], 0, 1);
2433 if ($output[0][
'typecode'] ==
'HOLIDAY') {
2435 $title2 = $langs->trans(
"Holiday");
2437 $title2 = $langs->trans(
"Ref").
' '.$ids2.($title2 ?
' - '.$title2 :
'');
2438 if ($output[0][
'string']) {
2439 $title2 .=
' - '.$output[0][
'string'];
2442 if ($output[0][
'color']) {
2443 $color2 = $output[0][
'color'];
2445 } elseif (!empty($cases2[$h]) && is_array($cases2[$h]) && count($cases2[$h]) > 1) {
2446 $title2 = $langs->trans(
"Ref").
' '.$ids2.($title2 ?
' - '.$title2 :
'');
2452 if (!empty($cases3[$h]) && is_array($cases3[$h]) && count($cases3[$h]) == 1) {
2453 $output = array_slice($cases3[$h], 0, 1);
2454 if ($output[0][
'typecode'] ==
'HOLIDAY') {
2456 $title3 = $langs->trans(
"Holiday");
2458 $title3 = $langs->trans(
"Ref").
' '.$ids3.($title3 ?
' - '.$title3 :
'');
2459 if ($output[0][
'string']) {
2460 $title3 .=
' - '.$output[0][
'string'];
2463 if ($output[0][
'color']) {
2464 $color3 = $output[0][
'color'];
2466 } elseif (!empty($cases3[$h]) && is_array($cases3[$h]) && count($cases3[$h]) > 1) {
2467 $title3 = $langs->trans(
"Ref").
' '.$ids3.($title3 ?
' - '.$title3 :
'');
2473 if (!empty($cases4[$h]) && is_array($cases4[$h]) && count($cases4[$h]) == 1) {
2474 $output = array_slice($cases4[$h], 0, 1);
2475 if ($output[0][
'typecode'] ==
'HOLIDAY') {
2477 $title4 = $langs->trans(
"Holiday");
2479 $title4 = $langs->trans(
"Ref").
' '.$ids4.($title4 ?
' - '.$title4 :
'');
2480 if ($output[0][
'string']) {
2481 $title4 .=
' - '.$output[0][
'string'];
2484 if ($output[0][
'color']) {
2485 $color4 = $output[0][
'color'];
2487 } elseif (!empty($cases4[$h]) && is_array($cases4[$h]) && count($cases4[$h]) > 1) {
2488 $title4 = $langs->trans(
"Ref").
' '.$ids4.($title4 ?
' - '.$title4 :
'');
2492 print
'<table class="nobordernopadding case centpercent">';
2495 if (preg_match(
'/peruser_notbusy/', $style1)) {
2496 print
'style="border: 1px solid #'.($color1 ? $color1 :
"888").
' !important" ';
2497 } elseif ($color1) {
2498 print
'style="background: #'.$color1.
'; "';
2502 print
'center'.($title1 ?
' classfortooltip' :
'').($title1 ?
' cursorpointer' :
'').
'"';
2503 print
'ref="'.$ref1.
'_'.$username->id.
'_'.sprintf(
"%04d", $year).
'_'.sprintf(
"%02d", $month).
'_'.sprintf(
"%02d", $day).
'_'.sprintf(
"%02d", $h).
'_00_'.($ids1 ? $ids1 :
'none').
'"';
2504 print ($title1 ?
' title="'.$title1.
'"' :
'').
'>';
2509 if (preg_match(
'/peruser_notbusy/', $style2)) {
2510 print
'style="border: 1px solid #'.($color2 ? $color2 :
"888").
' !important" ';
2511 } elseif ($color2) {
2512 print
'style="background: #'.$color2.
'; "';
2516 print
'center'.($title2 ?
' classfortooltip' :
'').($title2 ?
' cursorpointer' :
'').
'"';
2517 print
' ref="'.$ref2.
'_'.$username->id.
'_'.sprintf(
"%04d", $year).
'_'.sprintf(
"%02d", $month).
'_'.sprintf(
"%02d", $day).
'_'.sprintf(
"%02d", $h).
'_15_'.($ids2 ? $ids2 :
'none').
'"';
2518 print ($title2 ?
' title="'.$title2.
'"' :
'').
'>';
2523 if (preg_match(
'/peruser_notbusy/', $style3)) {
2524 print
'style="border: 1px solid #'.($color3 ? $color3 :
"888").
' !important" ';
2525 } elseif ($color3) {
2526 print
'style="background: #'.$color3.
'; "';
2530 print
'center'.($title3 ?
' classfortooltip' :
'').($title3 ?
' cursorpointer' :
'').
'"';
2531 print
' ref="'.$ref3.
'_'.$username->id.
'_'.sprintf(
"%04d", $year).
'_'.sprintf(
"%02d", $month).
'_'.sprintf(
"%02d", $day).
'_'.sprintf(
"%02d", $h).
'_30_'.($ids3 ? $ids3 :
'none').
'"';
2532 print ($title3 ?
' title="'.$title3.
'"' :
'').
'>';
2537 if (preg_match(
'/peruser_notbusy/', $style4)) {
2538 print
'style="border: 1px solid #'.($color4 ? $color4 :
"888").
' !important" ';
2539 } elseif ($color4) {
2540 print
'style="background: #'.$color4.
'; "';
2544 print
'center'.($title4 ?
' classfortooltip' :
'').($title4 ?
' cursorpointer' :
'').
'"';
2545 print
' ref="'.$ref4.
'_'.$username->id.
'_'.sprintf(
"%04d", $year).
'_'.sprintf(
"%02d", $month).
'_'.sprintf(
"%02d", $day).
'_'.sprintf(
"%02d", $h).
'_45_'.($ids4 ? $ids4 :
'none').
'"';
2546 print ($title4 ?
' title="'.$title4.
'"' :
'').
'>';
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
agenda_get_birthday_events($db, $langs, $user, $mode, $month, $day, $year, &$eventarray, &$nbevents)
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.
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 projects.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
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_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_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
dol_stringtotime($string, $gm=1)
Convert a string date into a GM Timestamps date Warning: YYYY-MM-DDTHH:MM:SS+02:00 (RFC3339) is not s...
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
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_string_nospecial($str, $newstr='_', $badcharstoreplace='', $badcharstoremove='', $keepspaces=0)
Clean a string from all punctuation characters to use it as a ref or login.
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).
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
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.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
conf($dolibarr_main_document_root, $realpathconf=null)
Load conf file (file must exists)
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
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, $mode=0)
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.