34require
'../../main.inc.php';
35require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/user/class/usergroup.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/lib/agenda.lib.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
55$disabledefaultvalues =
GETPOSTINT(
'disabledefaultvalues');
57$action =
GETPOST(
'action',
'aZ09');
60$filter =
GETPOST(
"search_filter",
'alpha', 3) ?
GETPOST(
"search_filter",
'alpha', 3) :
GETPOST(
"filter",
'alpha', 3);
61$filtert =
GETPOST(
"search_filtert",
"intcomma", 3) ?
GETPOST(
"search_filtert",
"intcomma", 3) :
GETPOST(
"filtert",
"intcomma", 3);
65$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
66$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
68if (empty($page) || $page == -1) {
72$offset = $limit * $page;
77 $sortfield =
"a.datec";
83 $socid = $user->socid;
90if (!$user->hasRight(
'agenda',
'myactions',
'read')) {
93if (!$user->hasRight(
'agenda',
'allactions',
'read')) {
96if (!$user->hasRight(
'agenda',
'allactions',
'read') || $filter ==
'mine') {
97 $filtert = (string) $user->id;
100$mode =
'show_peruser';
106$pid = GETPOSTISSET(
"search_projectid") ?
GETPOSTINT(
"search_projectid", 3) :
GETPOSTINT(
"projectid", 3);
107$status = GETPOSTISSET(
"search_status") ?
GETPOST(
"search_status",
'aZ09') :
GETPOST(
"status",
'aZ09');
108$type = GETPOSTISSET(
"search_type") ?
GETPOST(
"search_type",
'aZ09') :
GETPOST(
"type",
'aZ09');
110$optioncss =
GETPOST(
'optioncss',
'aZ');
113if (
GETPOST(
'search_actioncode',
'array:aZ09')) {
114 $actioncode =
GETPOST(
'search_actioncode',
'array:aZ09', 3);
115 if (!count($actioncode)) {
119 $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')));
123if ($dateselect > 0) {
131$tmp = str_replace(
' ',
'', $tmp);
132$tmparray = explode(
'-', $tmp);
133$begin_h = GETPOSTISSET(
'begin_h') ?
GETPOSTINT(
'begin_h') : ($tmparray[0] !=
'' ? $tmparray[0] : 9);
134$end_h = GETPOSTISSET(
'end_h') ?
GETPOSTINT(
'end_h') : ($tmparray[1] !=
'' ? $tmparray[1] : 18);
135if ($begin_h < 0 || $begin_h > 23) {
138if ($end_h < 1 || $end_h > 24) {
141if ($end_h <= $begin_h) {
142 $end_h = $begin_h + 1;
147$tmp = str_replace(
' ',
'', $tmp);
148$tmparray = explode(
'-', $tmp);
149$begin_d = GETPOSTISSET(
'begin_d') ?
GETPOSTINT(
'begin_d') : ($tmparray[0] !=
'' ? $tmparray[0] : 1);
150$end_d = GETPOSTISSET(
'end_d') ?
GETPOSTINT(
'end_d') : ($tmparray[1] !=
'' ? $tmparray[1] : 5);
151if ($begin_d < 1 || $begin_d > 7) {
154if ($end_d < 1 || $end_d > 7) {
157if ($end_d < $begin_d) {
158 $end_d = $begin_d + 1;
161if ($status ==
'' && !GETPOSTISSET(
'search_status')) {
165if (empty($mode) && !GETPOSTISSET(
'mode')) {
170if (
GETPOST(
'viewcal',
'alpha') && $mode !=
'show_day' && $mode !=
'show_week' && $mode !=
'show_peruser') {
171 $mode =
'show_month';
175if (
GETPOST(
'viewweek',
'alpha') || $mode ==
'show_week') {
177 $week = ($week ? $week : date(
"W"));
178 $day = ($day ? $day : date(
"d"));
181if (
GETPOST(
'viewday',
'alpha') || $mode ==
'show_day') {
183 $day = ($day ? $day : date(
"d"));
189$langs->loadLangs(array(
'users',
'agenda',
'other',
'commercial'));
192$hookmanager->initHooks(array(
'agenda'));
194$result =
restrictedArea($user,
'agenda', 0,
'actioncomm&societe',
'myactions|allactions',
'fk_soc',
'id');
195if ($user->socid && $socid) {
199$search_status = $status;
220 'maxprint' => $maxprint,
222 'filtert' => $filtert,
223 'showbirthday' => $showbirthday,
224 'canedit' => $canedit,
225 'optioncss' => $optioncss,
226 'actioncode' => $actioncode,
228 'resourceid' => $resourceid,
229 'usergroup' => $usergroup,
231$reshook = $hookmanager->executeHooks(
'beforeAgendaPerUser', $parameters, $object, $action);
236$form =
new Form($db);
237$companystatic =
new Societe($db);
239$help_url =
'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda|DE:Modul_Terminplanung';
240llxHeader(
'', $langs->trans(
"Agenda"), $help_url);
244$nowyear = $nowarray[
'year'];
245$nowmonth = $nowarray[
'mon'];
246$nowday = $nowarray[
'mday'];
249$listofextcals = array();
254 while ($i < $MAXAGENDA) {
256 $source =
'AGENDA_EXT_SRC'.$i;
257 $name =
'AGENDA_EXT_NAME'.$i;
258 $offsettz =
'AGENDA_EXT_OFFSETTZ'.$i;
259 $color =
'AGENDA_EXT_COLOR'.$i;
260 $default =
'AGENDA_EXT_ACTIVEBYDEFAULT'.$i;
261 $buggedfile =
'AGENDA_EXT_BUGGEDFILE'.$i;
264 $listofextcals[] = array(
265 'type' =>
'globalsetup',
281 while ($i < $MAXAGENDA) {
283 $source =
'AGENDA_EXT_SRC_'.$user->id.
'_'.$i;
284 $name =
'AGENDA_EXT_NAME_'.$user->id.
'_'.$i;
285 $offsettz =
'AGENDA_EXT_OFFSETTZ_'.$user->id.
'_'.$i;
286 $color =
'AGENDA_EXT_COLOR_'.$user->id.
'_'.$i;
287 $enabled =
'AGENDA_EXT_ENABLED_'.$user->id.
'_'.$i;
288 $default =
'AGENDA_EXT_ACTIVEBYDEFAULT_'.$user->id.
'_'.$i;
289 $buggedfile =
'AGENDA_EXT_BUGGEDFILE_'.$user->id.
'_'.$i;
293 $listofextcals[] = array(
294 'type' =>
'usersetup',
297 '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));
393$param .=
"&maxprint=".urlencode((
string) ($maxprint));
395$paramnoactionodate = $param;
400$prev_year = $prev[
'prev_year'];
401$prev_month = $prev[
'prev_month'];
402$prev_day = $prev[
'prev_day'];
403$first_day = $prev[
'first_day'];
404$first_month = $prev[
'first_month'];
405$first_year = $prev[
'first_year'];
407$week = $prev[
'week'];
411$next_year = $next[
'year'];
412$next_month = $next[
'month'];
413$next_day = $next[
'day'];
417$firstdaytoshow =
dol_mktime(0, 0, 0, $first_month, $first_day, $first_year,
'tzuserrel');
418$nb_weeks_to_show = (
getDolGlobalString(
'AGENDA_NB_WEEKS_IN_VIEW_PER_USER')) ? ((
int)
$conf->global->AGENDA_NB_WEEKS_IN_VIEW_PER_USER * 7) : 7;
424$max_day_in_month = idate(
"t",
dol_mktime(0, 0, 0, $month, 1, $year,
'gmt'));
427$picto =
'calendarweek';
430$nav =
'<div class="navselectiondate inline-block nowraponall">';
431$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";
432$nav .=
" <span id=\"month_name\">".dol_print_date(
dol_mktime(0, 0, 0, $first_month, $first_day, $first_year),
"%Y").
", ".$langs->trans(
"Week").
" ".$week;
434$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";
435if (empty(
$conf->dol_optimize_smallscreen)) {
436 $nav .=
' <a href="?year='.$nowyear.
'&month='.$nowmonth.
'&day='.$nowday.$param.
'" class="datenowlink marginleftonly marginrightonly">'.$langs->trans(
"Today").
'</a> ';
439$nav .= $form->selectDate($dateselect,
'dateselect', 0, 0, 1,
'', 1, 0);
441$nav .=
'<button type="submit" class="liste_titre button_search valignmiddle" name="button_search_x" value="x"><span class="fa fa-search"></span></button>';
444$paramnodate = $param;
445$param .=
'&year='.$year.
'&month='.$month.($day ?
'&day='.$day :
'');
449$paramnoaction = preg_replace(
'/mode=[a-z_]+/',
'', preg_replace(
'/action=[a-z_]+/',
'', $param));
450$paramnoactionodate = preg_replace(
'/mode=[a-z_]+/',
'', preg_replace(
'/action=[a-z_]+/',
'', $paramnodate));
454print
'<form method="POST" id="searchFormList" class="listactionsfilter" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
455if ($optioncss !=
'') {
456 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
458print
'<input type="hidden" name="token" value="'.newToken().
'">';
459print
'<input type="hidden" name="mode" value="'.$mode.
'">';
462$mode =
'show_peruser';
463$massactionbutton =
'';
466$viewmode =
'<div class="navmode inline-block">';
468$viewmode .=
'<a class="btnTitle reposition" href="'.DOL_URL_ROOT.
'/comm/action/list.php?mode=show_list&restore_lastsearch_values=1'.$paramnoactionodate.
'">';
470$viewmode .=
img_picto($langs->trans(
"List"),
'object_calendarlist',
'class="imgforviewmode pictoactionview block"');
472$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow">'.$langs->trans(
"ViewList").
'</span></a>';
476$viewmode .=
img_picto($langs->trans(
"ViewCal"),
'object_calendarmonth',
'class="pictoactionview block"');
478$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow">'.$langs->trans(
"ViewCal").
'</span></a>';
482$viewmode .=
img_picto($langs->trans(
"ViewWeek"),
'object_calendarweek',
'class="pictoactionview block"');
484$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow">'.$langs->trans(
"ViewWeek").
'</span></a>';
488$viewmode .=
img_picto($langs->trans(
"ViewDay"),
'object_calendarday',
'class="pictoactionview block"');
490$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow">'.$langs->trans(
"ViewDay").
'</span></a>';
494$viewmode .=
img_picto($langs->trans(
"ViewPerUser"),
'object_calendarperuser',
'class="pictoactionview block"');
496$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow" title="'.dolPrintHTML($langs->trans(
"ViewPerUser")).
'">'.$langs->trans(
"ViewPerUser").
'</span></a>';
499$parameters = array();
501$reshook = $hookmanager->executeHooks(
'addCalendarView', $parameters, $object, $action);
502if (empty($reshook)) {
503 $viewmode .= $hookmanager->resPrint;
504} elseif ($reshook > 1) {
505 $viewmode = $hookmanager->resPrint;
508$viewmode .=
'</div>';
510$viewmode .=
'<span class="marginrightonly"></span>';
515if ($user->hasRight(
'agenda',
'myactions',
'create') || $user->hasRight(
'agenda',
'allactions',
'create')) {
518 $newparam .=
'&month='.urlencode(str_pad((
string) $month, 2,
"0", STR_PAD_LEFT)).
'&year='.((int) $tmpforcreatebutton[
'year']);
519 if ($begin_h !==
'') {
520 $newparam .=
'&begin_h='.((int) $begin_h);
523 $newparam .=
'&end_h='.((int) $end_h);
525 if ($begin_d !==
'') {
526 $newparam .=
'&begin_d='.((int) $begin_d);
529 $newparam .=
'&end_d='.((int) $end_d);
532 $urltocreateaction = DOL_URL_ROOT.
'/comm/action/card.php?action=create';
533 $urltocreateaction .=
'&apyear='.$tmpforcreatebutton[
'year'].
'&apmonth='.$tmpforcreatebutton[
'mon'].
'&apday='.$tmpforcreatebutton[
'mday'].
'&aphour='.$tmpforcreatebutton[
'hours'].
'&apmin='.$tmpforcreatebutton[
'minutes'];
534 $urltocreateaction .=
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?'.$newparam);
536 $newcardbutton .=
dolGetButtonTitle($langs->trans(
"AddAction"),
'',
'fa fa-plus-circle', $urltocreateaction);
545$showextcals = $listofextcals;
546$bookcalcalendars = array();
549if (isModEnabled(
"bookcal")) {
550 $sql =
"SELECT ba.rowid, bc.label, bc.ref, bc.rowid as id_cal";
551 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bookcal_availabilities as ba";
552 $sql .=
" JOIN ".MAIN_DB_PREFIX.
"bookcal_calendar as bc";
553 $sql .=
" ON bc.rowid = ba.fk_bookcal_calendar";
554 $sql .=
" WHERE bc.status = 1";
555 $sql .=
" AND ba.status = 1";
556 $sql .=
" AND bc.entity IN (".getEntity(
'agenda').
")";
557 if (!empty($filtert) && $filtert !=
'-1' && $filtert !=
'-2') {
558 $sql .=
" AND bc.visibility IN (".$db->sanitize($filtert, 0, 0, 0, 0).
")";
560 $resql = $db->query($sql);
562 $num = $db->num_rows($resql);
565 $objp = $db->fetch_object($resql);
566 $label = !empty($objp->label) ? $objp->label : $objp->ref;
567 $bookcalcalendars[
"calendars"][] = array(
"id" => $objp->id_cal,
"label" => $label);
568 $bookcalcalendars[
"availabilitieslink"][$objp->rowid] = $objp->id_cal;
576if (!empty(
$conf->use_javascript_ajax)) {
577 $s .=
"\n".
'<!-- Div to calendars selectors -->'.
"\n";
579 $s .=
'<script type="text/javascript">'.
"\n";
580 $s .=
'jQuery(document).ready(function () {'.
"\n";
581 $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";
582 $s .=
'jQuery(".check_holiday").click(function() { console.log("Click on .check_holiday so we toggle class .peruser_holiday"); if (jQuery(".peruser_holiday").hasClass("peruser_holiday_imp")) { jQuery(".peruser_holiday").removeClass("peruser_holiday_imp"); } else { jQuery(".peruser_holiday").addClass("peruser_holiday_imp"); } });'.
"\n";
583 if (isModEnabled(
"bookcal") && !empty($bookcalcalendars[
"calendars"])) {
584 foreach ($bookcalcalendars[
"calendars"] as $key => $value) {
585 $s .=
'jQuery(".check_bookcal_calendar_'.$value[
'id'].
'").click(function() { console.log("Toggle Bookcal Calendar '.$value[
'id'].
'"); jQuery(".family_bookcal_calendar_'.$value[
'id'].
'").toggle(); });'.
"\n";
589 $s .=
'</script>'.
"\n";
592 $s .=
'<div class="nowrap inline-block minheight30"><input type="checkbox" id="check_mytasks" name="check_mytasks" value="1" checked disabled><label class="labelcalendar"><span class="check_holiday_text"> '.$langs->trans(
"LocalAgenda").
' </span></label></div>';
595 if ($user->hasRight(
"holiday",
"read")) {
597 <div class="nowrap inline-block minheight30"><input type="checkbox" id="check_holiday" name="check_holiday" value="1" class="check_holiday"' . ($check_holiday ?
' checked' :
'') .
'>
598 <label for="check_holiday" class="labelcalendar">
599 <span class="check_holiday_text">' . $langs->trans(
"Holidays") .
'</span>
605 if (count($showextcals) > 0) {
606 foreach ($showextcals as $val) {
607 $htmlname = md5($val[
'name']);
609 $s .=
'<script type="text/javascript">'.
"\n";
610 $s .=
'jQuery(document).ready(function () {'.
"\n";
611 $s .=
' jQuery("#check_ext'.$htmlname.
'").click(function() {';
612 $s .=
' /* alert("'.$htmlname.
'"); */';
613 $s .=
' jQuery(".family_ext'.$htmlname.
'").toggle();';
616 $s .=
'</script>'.
"\n";
617 $s .=
'<div class="nowrap float"><input type="checkbox" id="check_ext'.$htmlname.
'" name="check_ext'.$htmlname.
'" checked> '.$val [
'name'].
' </div>';
641 $parameters = array();
642 $reshook = $hookmanager->executeHooks(
'addCalendarChoice', $parameters, $object, $action);
643 if (empty($reshook)) {
644 $s .= $hookmanager->resPrint;
645 } elseif ($reshook > 1) {
646 $s = $hookmanager->resPrint;
649 $s .=
"\n".
'<!-- End div to calendars selectors -->'.
"\n";
652 $newparam = preg_replace(
'/showbirthday=[0-1]/i',
'showbirthday='.($showbirthday ?
'1' :
'0'), $newparam);
653 if (!preg_match(
'/showbirthday=/i', $newparam)) {
654 $newparam .=
'&showbirthday=1';
659 $link .= $langs->trans(
"AgendaShowBirthdayEvents");
661 $link .= $langs->trans(
"AgendaHideBirthdayEvents");
668$eventarray = array();
676$sql .=
" a.id, a.label,";
679$sql .=
" a.percent,";
680$sql .=
" a.fk_user_author, a.fk_user_action,";
681$sql .=
" a.transparency, a.priority, a.fulldayevent, a.location,";
682$sql .=
" a.fk_soc, a.fk_contact, a.fk_project, a.fk_bookcal_calendar,";
683$sql .=
" a.fk_element, a.elementtype,";
684$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";
686$parameters = array();
687$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
688$sql .= $hookmanager->resPrint;
690$sql .=
" FROM ".MAIN_DB_PREFIX.
"c_actioncomm as ca, ".MAIN_DB_PREFIX.
"actioncomm as a";
692if ($resourceid > 0) {
693 $sql .=
", ".MAIN_DB_PREFIX.
"element_resources as r";
697if (($filtert !=
'-1' && $filtert !=
'-2') || $usergroup > 0) {
699 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"actioncomm_resources as ar";
700 $sql .=
" ON ar.fk_actioncomm = a.id AND ar.element_type = 'user'";
701 if ($filtert !=
'' && $filtert !=
'-1' && $filtert !=
'-2' && $filtert !=
'-3') {
702 $sql .=
" AND ar.fk_element IN (".$db->sanitize($filtert).
")";
703 } elseif ($filtert ==
'-3') {
704 $sql .=
" AND ar.fk_element IN (".$db->sanitize(implode(
',', $user->getAllChildIds(1))).
")";
706 if ($usergroup > 0) {
707 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"usergroup_user as ugu ON ugu.fk_user = ar.fk_element AND ugu.fk_usergroup = ".((int) $usergroup);
711$sql .=
" WHERE a.fk_action = ca.id";
712$sql .=
" AND a.entity IN (".getEntity(
'agenda').
")";
715if (!empty($actioncode)) {
717 if ((is_array($actioncode) && in_array(
'AC_NON_AUTO', $actioncode)) || $actioncode ==
'AC_NON_AUTO') {
718 $sql .=
" AND ca.type != 'systemauto'";
719 } elseif ((is_array($actioncode) && in_array(
'AC_ALL_AUTO', $actioncode)) || $actioncode ==
'AC_ALL_AUTO') {
720 $sql .=
" AND ca.type = 'systemauto'";
722 if ((is_array($actioncode) && in_array(
'AC_OTH', $actioncode)) || $actioncode ==
'AC_OTH') {
723 $sql .=
" AND ca.type != 'systemauto'";
725 if ((is_array($actioncode) && in_array(
'AC_OTH_AUTO', $actioncode)) || $actioncode ==
'AC_OTH_AUTO') {
726 $sql .=
" AND ca.type = 'systemauto'";
730 if ((is_array($actioncode) && in_array(
'AC_NON_AUTO', $actioncode)) || $actioncode ===
'AC_NON_AUTO') {
731 $sql .=
" AND ca.type != 'systemauto'";
732 } elseif ((is_array($actioncode) && in_array(
'AC_ALL_AUTO', $actioncode)) || $actioncode ===
'AC_ALL_AUTO') {
733 $sql .=
" AND ca.type = 'systemauto'";
734 } elseif ((is_array($actioncode) && !in_array(
'-1', $actioncode) && !in_array(
'-3', $actioncode)) || ($actioncode !==
'-1' && $actioncode !==
'-3')) {
735 if (is_array($actioncode)) {
736 foreach ($actioncode as $key => $val) {
737 if ($val ==
'-1' || $val ==
'-2') {
738 unset($actioncode[$key]);
741 if (!empty($actioncode)) {
742 $sql .=
" AND ca.code IN (".$db->sanitize(
"'".implode(
"','", $actioncode).
"'", 1).
")";
745 $sql .=
" AND ca.code IN (".$db->sanitize(
"'".implode(
"','", explode(
',', $actioncode)).
"'", 1).
")";
750if ($resourceid > 0) {
751 $sql .=
" AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".((int) $resourceid);
754 $sql .=
" AND a.fk_project = ".((int) $pid);
758if (isModEnabled(
"societe") && !$user->hasRight(
'societe',
'client',
'voir')) {
759 $search_sale = $user->id;
762if ($search_sale && $search_sale !=
'-1') {
763 if ($search_sale == -2) {
764 $sql .=
" AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = a.fk_soc)";
765 } elseif ($search_sale > 0) {
766 $sql .=
" AND 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).
")";
771 $sql .=
" AND a.fk_soc = ".((int) $socid);
774if ($mode ==
'show_day') {
776 $sql .=
" (a.datep BETWEEN '".$db->idate(
dol_mktime(0, 0, 0, $month, $day, $year,
'tzuserrel')).
"'";
777 $sql .=
" AND '".$db->idate(
dol_mktime(23, 59, 59, $month, $day, $year,
'tzuserrel')).
"')";
779 $sql .=
" (a.datep2 BETWEEN '".$db->idate(
dol_mktime(0, 0, 0, $month, $day, $year,
'tzuserrel')).
"'";
780 $sql .=
" AND '".$db->idate(
dol_mktime(23, 59, 59, $month, $day, $year,
'tzuserrel')).
"')";
782 $sql .=
" (a.datep < '".$db->idate(
dol_mktime(0, 0, 0, $month, $day, $year,
'tzuserrel')).
"'";
783 $sql .=
" AND a.datep2 > '".$db->idate(
dol_mktime(23, 59, 59, $month, $day, $year,
'tzuserrel')).
"')";
788 $sql .=
" (a.datep BETWEEN '".$db->idate($firstdaytoshow - (60 * 60 * 24 * 2)).
"'";
789 $sql .=
" AND '".$db->idate($lastdaytoshow + (60 * 60 * 24 * 2)).
"')";
791 $sql .=
" (a.datep2 BETWEEN '".$db->idate($firstdaytoshow - (60 * 60 * 24 * 2)).
"'";
792 $sql .=
" AND '".$db->idate($lastdaytoshow + (60 * 60 * 24 * 2)).
"')";
794 $sql .=
" (a.datep < '".$db->idate($firstdaytoshow - (60 * 60 * 24 * 2)).
"'";
795 $sql .=
" AND a.datep2 > '".$db->idate($lastdaytoshow + (60 * 60 * 24 * 2)).
"')";
799 $sql .=
" AND ca.id = ".((int) $type);
803 $sql .=
" AND a.percent = 0";
805if ($status ===
'na') {
807 $sql .=
" AND a.percent = -1";
809if ($status ==
'50') {
811 $sql .=
" AND (a.percent > 0 AND a.percent < 100)";
813if ($status ==
'done' || $status ==
'100') {
814 $sql .=
" AND (a.percent = 100)";
816if ($status ==
'todo') {
817 $sql .=
" AND (a.percent >= 0 AND a.percent < 100)";
820if (($filtert > 0 || $filtert == -3) || $usergroup > 0) {
824 $sql .=
"ar.fk_element = ".((int) $filtert);
825 } elseif ($filtert == -3) {
826 $sql .=
"ar.fk_element IN (".$db->sanitize(implode(
',', $user->getAllChildIds(1))).
")";
828 if ($usergroup > 0) {
829 $sql .= ($filtert > 0 ?
" OR " :
"").
" ugu.fk_usergroup = ".((
int) $usergroup);
835if ($search_categ_cus != -1) {
836 if ($search_categ_cus == -2) {
837 $sql .=
" AND NOT EXISTS (SELECT ca.fk_actioncomm FROM ".MAIN_DB_PREFIX.
"categorie_actioncomm as ca WHERE ca.fk_actioncomm = a.id)";
838 } elseif ($search_categ_cus > 0) {
839 $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).
"))";
843$sql .= $db->order(
"fk_user_action, datep");
846dol_syslog(
"comm/action/peruser.php", LOG_DEBUG);
847$resql = $db->query($sql);
849 $num = $db->num_rows($resql);
851 $MAXONSAMEPAGE = 10000;
853 while ($i < $num && $i < $MAXONSAMEPAGE) {
854 $obj = $db->fetch_object($resql);
858 if (
getDolGlobalString(
'AGENDA_ALWAYS_HIDE_AUTO') && $obj->type_code ==
'AC_OTH_AUTO') {
863 $datep = $db->jdate($obj->datep);
864 $datep2 = $db->jdate($obj->datep2);
870 $event->id = $obj->id;
871 $event->ref = (string) $event->id;
873 $event->fulldayevent = $obj->fulldayevent;
876 if ($event->fulldayevent) {
878 $event->datep = $db->jdate($obj->datep, $tzforfullday ?
'tzuser' :
'tzserver');
879 $event->datef = $db->jdate($obj->datep2, $tzforfullday ?
'tzuser' :
'tzserver');
882 $event->datep = $db->jdate($obj->datep,
'tzserver');
883 $event->datef = $db->jdate($obj->datep2,
'tzserver');
889 $event->type_code = $obj->type_code;
890 $event->type_label = $obj->type_label;
891 $event->type_color = $obj->type_color;
892 $event->type = $obj->type_type;
893 $event->type_picto = $obj->type_picto;
895 $event->label = $obj->label;
896 $event->percentage = $obj->percent;
897 $event->authorid = $obj->fk_user_author;
898 $event->userownerid = $obj->fk_user_action;
899 $event->fetch_userassigned();
901 $event->priority = $obj->priority;
902 $event->location = $obj->location;
903 $event->transparency = $obj->transparency;
904 $event->fk_element = $obj->fk_element;
905 $event->elementid = $obj->fk_element;
906 $event->elementtype = $obj->elementtype;
908 $event->fk_project = $obj->fk_project;
910 $event->socid = $obj->fk_soc;
911 $event->contact_id = $obj->fk_contact;
912 $event->fk_bookcal_calendar = $obj->fk_bookcal_calendar;
913 if (!empty($event->fk_bookcal_calendar)) {
914 $event->type =
"bookcal_calendar";
919 $event->date_start_in_calendar = $event->datep;
920 if ($event->datef !=
'' && $event->datef >= $event->datep) {
921 $event->date_end_in_calendar = $event->datef;
923 $event->date_end_in_calendar = $event->datep;
929 if ($event->date_end_in_calendar < $firstdaytoshow || $event->date_start_in_calendar >= $lastdaytoshow) {
933 if ($event->date_start_in_calendar < $firstdaytoshow) {
934 $event->date_start_in_calendar = $firstdaytoshow;
936 if ($event->date_end_in_calendar >= $lastdaytoshow) {
937 $event->date_end_in_calendar = ($lastdaytoshow - 1);
941 $daycursor = $event->date_start_in_calendar;
946 $daycursorend = $event->date_end_in_calendar;
947 $anneeend = (int)
dol_print_date($daycursorend,
'%Y',
'tzuserrel');
948 $moisend = (int)
dol_print_date($daycursorend,
'%m',
'tzuserrel');
949 $jourend = (int)
dol_print_date($daycursorend,
'%d',
'tzuserrel');
954 $daykey =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
955 $daykeyend =
dol_mktime(0, 0, 0, $moisend, $jourend, $anneeend,
'gmt');
969 $eventarray[$daykey][] = $event;
972 $daykey += 60 * 60 * 24;
974 if ($daykey > $daykeyend) {
983 $parameters[
'obj'] = $obj;
984 $reshook = $hookmanager->executeHooks(
'hookEventElements', $parameters, $event, $action);
985 $event = $hookmanager->resPrint;
1003 $sql =
'SELECT sp.rowid, sp.lastname, sp.firstname, sp.birthday';
1004 $sql .=
' FROM '.MAIN_DB_PREFIX.
'socpeople as sp';
1005 $sql .=
' WHERE (priv=0 OR (priv=1 AND fk_user_creat='.((int) $user->id).
'))';
1006 $sql .=
" AND sp.entity IN (".getEntity(
'contact').
")";
1007 if ($mode ==
'show_day') {
1008 $sql .=
' AND MONTH(birthday) = '.((int) $month);
1009 $sql .=
' AND DAY(birthday) = '.((int) $day);
1011 $sql .=
' AND MONTH(birthday) = '.((int) $month);
1013 $sql .=
' ORDER BY birthday';
1015 dol_syslog(
"comm/action/index.php", LOG_DEBUG);
1016 $resql = $db->query($sql);
1018 $num = $db->num_rows($resql);
1021 $obj = $db->fetch_object($resql);
1025 $event->id = $obj->rowid;
1026 $event->ref = (string) $event->id;
1031 $event->datep =
dol_mktime(0, 0, 0, $datearray[
'mon'], $datearray[
'mday'], $year,
true);
1032 $event->datef = $event->datep;
1034 $event->type_code =
'BIRTHDAY';
1035 $event->type_label =
'';
1036 $event->type_color =
'';
1037 $event->type =
'birthdate';
1038 $event->type_picto =
'birthdate';
1040 $event->label = $langs->trans(
"Birthday").
' '.
dolGetFirstLastname($obj->firstname, $obj->lastname);
1041 $event->percentage = 100;
1042 $event->fulldayevent = 1;
1044 $event->contact_id = $obj->rowid;
1046 $event->date_start_in_calendar = $db->jdate($event->datep);
1047 $event->date_end_in_calendar = $db->jdate($event->datef);
1050 $daycursor = $event->datep;
1055 $daykey =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
1057 $eventarray[$daykey][] = $event;
1075if ($user->hasRight(
"holiday",
"read")) {
1076 $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";
1077 $sql .=
" FROM ".MAIN_DB_PREFIX.
"holiday as x, ".MAIN_DB_PREFIX.
"user as u";
1078 $sql .=
" WHERE u.rowid = x.fk_user";
1079 $sql .=
" AND u.statut = '1'";
1080 $sql .=
" AND (x.statut = '2' OR x.statut = '3')";
1082 $sql .=
" AND x.date_debut < '".$db->idate(
dol_get_last_day($year, $month)).
"'";
1083 $sql .=
" AND x.date_fin >= '".$db->idate(
dol_get_first_day($year, $month)).
"'";
1084 if (!$user->hasRight(
'holiday',
'readall')) {
1085 $sql .=
" AND x.fk_user IN(".$db->sanitize(implode(
", ", $user->getAllChildIds(1))).
") ";
1088 $resql = $db->query($sql);
1090 $num = $db->num_rows($resql);
1094 $obj = $db->fetch_object($resql);
1099 $event->id = $obj->rowid;
1100 $event->ref = (string) $event->id;
1102 $event->type_code =
'HOLIDAY';
1103 $event->type_label =
'';
1104 $event->type_color =
'';
1105 $event->type =
'holiday';
1106 $event->type_picto =
'holiday';
1108 $event->datep = $db->jdate($obj->date_start) + (empty($obj->halfday) || $obj->halfday == 1 ? 0 : 12) * 60 * 60;
1109 $event->datef = $db->jdate($obj->date_end) + (empty($obj->halfday) || $obj->halfday == -1 ? 24 : 12) * 60 * 60 - 1;
1110 $event->date_start_in_calendar = $event->datep;
1111 $event->date_end_in_calendar = $event->datef;
1113 $event->transparency = 1;
1115 $event->userownerid = $obj->uid;
1116 $event->userassigned = array($obj->uid => array(
'id' => $obj->uid,
'transparency' => 1));
1118 if ($obj->status == 3) {
1120 $event->percentage = -1;
1121 } elseif ($obj->status == 2) {
1123 $event->percentage = 0;
1127 $daycursor = $event->date_start_in_calendar;
1132 $daycursorend = $event->date_end_in_calendar;
1133 $anneeend = (int)
dol_print_date($daycursorend,
'%Y',
'tzuserrel');
1134 $moisend = (int)
dol_print_date($daycursorend,
'%m',
'tzuserrel');
1135 $jourend = (int)
dol_print_date($daycursorend,
'%d',
'tzuserrel');
1138 $daykey =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
1139 $daykeygmt =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
1144 $firstdayofholiday = ($ifornbofdays == 1);
1145 $lastdayofholiday = ($daykeygmt ==
dol_get_first_hour($event->date_end_in_calendar,
'gmt'));
1149 if ((in_array($obj->halfday, array(1, 2)) == 1 && $lastdayofholiday) || (in_array($obj->halfday, array(-1, 2)) && $firstdayofholiday)) {
1152 if (in_array($obj->halfday, array(1, 2)) && $lastdayofholiday) {
1153 $newevent->label .=
' ('.$langs->trans(
"Morning").
')';
1154 } elseif (in_array($obj->halfday, array(-1, 2)) && $firstdayofholiday) {
1155 $newevent->label .=
' ('.$langs->trans(
"Afternoon").
')';
1157 $eventarray[$daykey][] = $newevent;
1159 $eventarray[$daykey][] = $event;
1162 $daykey += 60 * 60 * 24;
1163 $daykeygmt += 60 * 60 * 24;
1164 }
while ($daykey <= $event->date_end_in_calendar);
1173if (count($listofextcals)) {
1174 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/ical.class.php';
1176 foreach ($listofextcals as $key => $extcal) {
1177 $url = $extcal[
'src'];
1178 $namecal = $extcal[
'name'];
1179 $offsettz = $extcal[
'offsettz'];
1180 $colorcal = $extcal[
'color'];
1181 $buggedfile = $extcal[
'buggedfile'];
1187 $ical->parse($url, $pathforcachefile, $DELAYFORCACHE);
1190 $listofextcals[$key][
'error'] = $ical->error;
1191 $s .=
'<br><div class="warning">'.dol_escape_htmltag($listofextcals[$key][
'name']).
': '.$url.
'<br>Error message: '.
dol_escape_htmltag($ical->error).
'</div>';
1196 $icalevents = array();
1197 if (is_array($ical->get_event_list())) {
1198 $icalevents = array_merge($icalevents, $ical->get_event_list());
1200 if (is_array($ical->get_freebusy_list())) {
1201 $icalevents = array_merge($icalevents, $ical->get_freebusy_list());
1204 if (count($icalevents) > 0) {
1206 $moreicalevents = array();
1207 foreach ($icalevents as $icalevent) {
1208 if (isset($icalevent[
'RRULE']) && is_array($icalevent[
'RRULE'])) {
1211 if ($icalevent[
'DTSTART;VALUE=DATE']) {
1214 } elseif (is_array($icalevent[
'DTSTART']) && !empty($icalevent[
'DTSTART'][
'unixtime'])) {
1215 $datecurstart = $icalevent[
'DTSTART'][
'unixtime'];
1216 $datecurend = $icalevent[
'DTEND'][
'unixtime'];
1217 if (!empty($ical->cal[
'DAYLIGHT'][
'DTSTART']) ) {
1219 $tmpcurstart = $datecurstart;
1220 $tmpcurend = $datecurend;
1221 $tmpdaylightstart =
dol_mktime(0, 0, 0, 1, 1, 1970, 1) + (int) $ical->cal[
'DAYLIGHT'][
'DTSTART'];
1222 $tmpdaylightend =
dol_mktime(0, 0, 0, 1, 1, 1970, 1) + (int) $ical->cal[
'STANDARD'][
'DTSTART'];
1225 if ($tmpcurstart >= $tmpdaylightstart && $tmpcurstart < $tmpdaylightend) {
1226 $datecurstart -= ((int) $ical->cal[
'DAYLIGHT'][
'TZOFFSETTO']) * 36;
1228 $datecurstart -= ((int) $ical->cal[
'STANDARD'][
'TZOFFSETTO']) * 36;
1230 if ($tmpcurend >= $tmpdaylightstart && $tmpcurstart < $tmpdaylightend) {
1231 $datecurend -= ((int) $ical->cal[
'DAYLIGHT'][
'TZOFFSETTO']) * 36;
1233 $datecurend -= ((int) $ical->cal[
'STANDARD'][
'TZOFFSETTO']) * 36;
1240 dol_syslog(
"Found a not recognized repeatable record with unknown date start", LOG_ERR);
1245 $interval = (empty($icalevent[
'RRULE'][
'INTERVAL']) ? 1 : $icalevent[
'RRULE'][
'INTERVAL']);
1246 $until = empty($icalevent[
'RRULE'][
'UNTIL']) ? 0 :
dol_stringtotime($icalevent[
'RRULE'][
'UNTIL'], 1);
1247 $maxrepeat = empty($icalevent[
'RRULE'][
'COUNT']) ? 0 : $icalevent[
'RRULE'][
'COUNT'];
1248 if ($until && ($until + ($datecurend - $datecurstart)) < $firstdaytoshow) {
1251 if ($datecurstart >= $lastdaytoshow) {
1256 while (($datecurstart < $lastdaytoshow) && (empty($maxrepeat) || ($numofevent < $maxrepeat))) {
1257 if ($datecurend >= $firstdaytoshow) {
1258 $newevent = $icalevent;
1259 unset($newevent[
'RRULE']);
1260 if ($icalevent[
'DTSTART;VALUE=DATE']) {
1261 $newevent[
'DTSTART;VALUE=DATE'] =
dol_print_date($datecurstart,
'%Y%m%d');
1262 $newevent[
'DTEND;VALUE=DATE'] =
dol_print_date($datecurend + 1,
'%Y%m%d');
1264 $newevent[
'DTSTART'] = $datecurstart;
1265 $newevent[
'DTEND'] = $datecurend;
1267 $moreicalevents[] = $newevent;
1271 $savdatecurstart = $datecurstart;
1272 if ($icalevent[
'RRULE'][
'FREQ'] ==
'DAILY') {
1276 if ($icalevent[
'RRULE'][
'FREQ'] ==
'WEEKLY') {
1279 } elseif ($icalevent[
'RRULE'][
'FREQ'] ==
'MONTHLY') {
1282 } elseif ($icalevent[
'RRULE'][
'FREQ'] ==
'YEARLY') {
1287 if ($savdatecurstart >= $datecurstart) {
1288 dol_syslog(
"Found a rule freq ".$icalevent[
'RRULE'][
'FREQ'].
" not managed by dolibarr code. Assume 1 week frequency.", LOG_ERR);
1289 $datecurstart += 3600 * 24 * 7;
1290 $datecurend += 3600 * 24 * 7;
1295 $icalevents = array_merge($icalevents, $moreicalevents);
1298 foreach ($icalevents as $icalevent) {
1303 if (!empty($icalevent[
'RRULE'])) {
1312 if (isset($icalevent[
'DTSTART;VALUE=DATE'])) {
1315 if (empty($icalevent[
'DTEND;VALUE=DATE'])) {
1316 $dateend = $datestart + 86400 - 1;
1322 $event->fulldayevent = 1;
1324 } elseif (!is_array($icalevent[
'DTSTART'])) {
1325 $datestart = $icalevent[
'DTSTART'];
1326 $dateend = empty($icalevent[
'DTEND']) ? $datestart : $icalevent[
'DTEND'];
1328 $datestart += +($offsettz * 3600);
1329 $dateend += +($offsettz * 3600);
1334 } elseif (isset($icalevent[
'DTSTART'][
'unixtime'])) {
1335 $datestart = $icalevent[
'DTSTART'][
'unixtime'];
1336 $dateend = $icalevent[
'DTEND'][
'unixtime'];
1338 $datestart += +($offsettz * 3600);
1339 $dateend += +($offsettz * 3600);
1342 if ($buggedfile ===
'uselocalandtznodaylight') {
1346 if ($buggedfile ===
'uselocalandtzdaylight') {
1347 $localtzs =
new DateTimeZone(preg_replace(
'/"/',
'', $icalevent[
'DTSTART'][
'TZID']));
1348 $localtze =
new DateTimeZone(preg_replace(
'/"/',
'', $icalevent[
'DTEND'][
'TZID']));
1349 $localdts =
new DateTime(
dol_print_date($datestart,
'dayrfc',
'gmt'), $localtzs);
1350 $localdte =
new DateTime(
dol_print_date($dateend,
'dayrfc',
'gmt'), $localtze);
1351 $tmps = -1 * $localtzs->getOffset($localdts);
1352 $tmpe = -1 * $localtze->getOffset($localdte);
1353 $datestart += $tmps;
1360 if ($addevent && $datestart !==
null && $dateend !==
null) {
1361 $event->id = $icalevent[
'UID'];
1362 $event->ref = (string) $event->id;
1363 $userstatic =
new User($db);
1364 $userId = $userstatic->findUserIdByEmail($namecal);
1365 if (!empty($userId) && $userId > 0) {
1366 $event->userassigned[$userId] = [
1368 'transparency' => 1,
1370 $event->percentage = -1;
1373 $event->type_code =
"ICALEVENT";
1374 $event->type_label = $namecal;
1375 $event->type_color = $colorcal;
1376 $event->type =
'icalevent';
1377 $event->type_picto =
'rss';
1379 $event->icalname = $namecal;
1380 $event->icalcolor = $colorcal;
1382 $event->datep = $datestart + $usertime;
1383 $event->datef = $dateend + $usertime;
1385 if (isset($icalevent[
'SUMMARY']) && $icalevent[
'SUMMARY']) {
1387 } elseif (isset($icalevent[
'DESCRIPTION']) && $icalevent[
'DESCRIPTION']) {
1390 $event->label = $langs->trans(
"ExtSiteNoLabel");
1397 if (!empty($icalevent[
'PRIORITY'])) {
1398 $event->priority = $icalevent[
'PRIORITY'];
1402 if (!empty($icalevent[
'TRANSP'])) {
1403 if ($icalevent[
'TRANSP'] ==
"TRANSPARENT") {
1404 $event->transparency = 0;
1406 if ($icalevent[
'TRANSP'] ==
"OPAQUE") {
1407 $event->transparency = 1;
1418 if (!empty($icalevent[
'LOCATION'])) {
1419 $event->location = $icalevent[
'LOCATION'];
1422 $event->date_start_in_calendar = $event->datep;
1424 if ($event->datef !=
'' && $event->datef >= $event->datep) {
1425 $event->date_end_in_calendar = $event->datef;
1427 $event->date_end_in_calendar = $event->datep;
1431 if ($event->date_end_in_calendar < $firstdaytoshow || $event->date_start_in_calendar >= $lastdaytoshow) {
1437 if ($event->date_start_in_calendar < $firstdaytoshow) {
1438 $event->date_start_in_calendar = $firstdaytoshow;
1440 if ($event->date_end_in_calendar >= $lastdaytoshow) {
1441 $event->date_end_in_calendar = ($lastdaytoshow - 1);
1445 $daycursor = $event->date_start_in_calendar;
1454 $daykey =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
1455 $daykeygmt =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
1458 $eventarray[$daykey][] = $event;
1459 $daykey += 60 * 60 * 24;
1460 $daykeygmt += 60 * 60 * 24;
1461 if (($event->fulldayevent ? $daykeygmt : $daykey) > $event->date_end_in_calendar) {
1473$parameters = array();
1475$reshook = $hookmanager->executeHooks(
'getCalendarEvents', $parameters, $object, $action);
1476if (!empty($hookmanager->resArray[
'eventarray'])) {
1477 foreach ($hookmanager->resArray[
'eventarray'] as $keyDate => $events) {
1478 if (!isset($eventarray[$keyDate])) {
1479 $eventarray[$keyDate] = array();
1481 $eventarray[$keyDate] = array_merge($eventarray[$keyDate], $events);
1493$cachethirdparties = array();
1494$cachecontacts = array();
1495$cacheusers = array();
1498$color_file = DOL_DOCUMENT_ROOT.
"/theme/".
$conf->theme.
"/theme_vars.inc.php";
1499if (is_readable($color_file)) {
1500 include $color_file;
1502if (!is_array($theme_datacolor)) {
1503 $theme_datacolor = array(array(137, 86, 161), array(60, 147, 183), array(250, 190, 80), array(80, 166, 90), array(190, 190, 100), array(91, 115, 247), array(140, 140, 220), array(190, 120, 120), array(115, 125, 150), array(100, 170, 20), array(150, 135, 125), array(85, 135, 150), array(150, 135, 80), array(150, 80, 150));
1506$massactionbutton =
'';
1510print_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);
1518print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1519print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday,
'', (
string) $filtert,
'', $pid, $socid, $action, -1, $actioncode, $usergroup,
'', $resourceid, $search_categ_cus);
1524$newparam = preg_replace(
'/showbirthday=/i',
'showbirthday_=', $newparam);
1525$newparam = preg_replace(
'/mode=show_month&?/i',
'', $newparam);
1526$newparam = preg_replace(
'/mode=show_week&?/i',
'', $newparam);
1527$newparam = preg_replace(
'/day=[0-9]+&?/i',
'', $newparam);
1528$newparam = preg_replace(
'/month=[0-9]+&?/i',
'', $newparam);
1529$newparam = preg_replace(
'/year=[0-9]+&?/i',
'', $newparam);
1530$newparam = preg_replace(
'/viewweek=[0-9]+&?/i',
'', $newparam);
1531$newparam = preg_replace(
'/showbirthday_=/i',
'showbirthday=', $newparam);
1532$newparam .=
'&viewweek=1';
1534echo
'<input type="hidden" name="actionmove" value="mupdate">';
1535echo
'<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($_SERVER[
'PHP_SELF']).
'?'.
dol_escape_htmltag($_SERVER[
'QUERY_STRING']).
'">';
1536echo
'<input type="hidden" name="newdate" id="newdate">';
1543$currentdaytoshow = $firstdaytoshow;
1544echo
'<div class="div-table-responsive">';
1547$colorsbytype = array();
1549while ($currentdaytoshow < $lastdaytoshow) {
1550 echo
'<table class="centpercent noborder nocellnopadd cal_month cal_peruser listwithfilterbefore">';
1552 echo
'<tr class="liste_titre">';
1553 echo
'<td class="nopaddingtopimp nopaddingbottomimp nowraponsmartphone">';
1557 print
'<span class="hideonsmartphone" title="'.$langs->trans(
"VisibleDaysRange").
'">';
1558 print
img_picto(
'',
'clock',
'class="fawidth30 inline-block marginleftonly"');
1559 print $langs->trans(
"DaysOfWeek").
'</span>';
1561 print
'<div class="ui-grid-a inline-block"><div class="ui-block-a nowraponall">';
1562 print
'<input type="number" class="shortbis" name="begin_d" value="'.$begin_d.
'" min="1" max="7">';
1563 if (empty(
$conf->dol_use_jmobile)) {
1566 print
'</div><div class="ui-block-b">';
1568 print
'<input type="number" class="shortbis" name="end_d" value="'.$end_d.
'" min="1" max="7">';
1569 print
'</div></div>';
1575 if (($i + 1) < $begin_d || ($i + 1) > $end_d) {
1579 echo
'<td align="center" colspan="'.($end_h - $begin_h).
'">';
1580 echo
'<span class="bold spandayofweek">'.$langs->trans(
"Day".(($i + (isset(
$conf->global->MAIN_START_WEEK) ?
$conf->global->MAIN_START_WEEK : 1)) % 7)).
'</span>';
1592 echo
'<tr class="liste_titre">';
1596 print
'<span class="hideonsmartphone" title="'.$langs->trans(
"VisibleTimeRange").
'">';
1597 print
img_picto(
'',
'clock',
'class="fawidth30 inline-block marginleftonly"');
1598 print $langs->trans(
"Hours").
'</span>';
1600 print
'<div class="ui-grid-a inline-block"><div class="ui-block-a nowraponall">';
1601 print
'<input type="number" class="shortbis" name="begin_h" value="'.$begin_h.
'" min="0" max="23">';
1602 if (empty(
$conf->dol_use_jmobile)) {
1605 print
'</div><div class="ui-block-b">';
1607 print
'<input type="number" class="shortbis" name="end_h" value="'.$end_h.
'" min="1" max="24">';
1608 if (empty(
$conf->dol_use_jmobile)) {
1609 print
' '.$langs->trans(
"HourShort");
1611 print
'</div></div>';
1616 if (($i + 1) < $begin_d || ($i + 1) > $end_d) {
1620 for ($h = $begin_h; $h < $end_h; $h++) {
1621 echo
'<td class="center">';
1622 print
'<small style="font-family: courier">'.sprintf(
"%02d", $h).
'</small>';
1632 $usernames = array();
1633 $usernamesid = array();
1636 foreach ($eventarray as $daykey => $notused) {
1638 foreach ($eventarray[$daykey] as $index => $event) {
1639 $event->fetch_userassigned();
1640 $listofuserid = $event->userassigned;
1641 foreach ($listofuserid as $userid => $tmp) {
1642 if (!in_array($userid, $usernamesid)) {
1643 $usernamesid[$userid] = $userid;
1650 $sql =
"SELECT u.rowid, u.lastname as lastname, u.firstname, u.statut, u.login, u.admin, u.entity";
1651 $sql .=
" FROM ".$db->prefix().
"user as u";
1652 if (isModEnabled(
'multicompany') &&
getDolGlobalInt(
'MULTICOMPANY_TRANSVERSE_MODE')) {
1653 $sql .=
" WHERE u.rowid IN (";
1654 $sql .=
" SELECT ug.fk_user FROM ".$db->prefix().
"usergroup_user as ug";
1655 $sql .=
" WHERE ug.entity IN (".getEntity(
'usergroup').
")";
1656 if ($usergroup > 0) {
1657 $sql .=
" AND ug.fk_usergroup = ".((int) $usergroup);
1661 if ($usergroup > 0) {
1662 $sql .=
" LEFT JOIN ".$db->prefix().
"usergroup_user as ug ON u.rowid = ug.fk_user";
1664 $sql .=
" WHERE u.entity IN (".getEntity(
'user').
")";
1665 if ($usergroup > 0) {
1666 $sql .=
" AND ug.fk_usergroup = ".((int) $usergroup);
1669 $sql .=
" AND u.statut = 1";
1671 $sql .=
" AND u.rowid = ".((int) $filtert);
1673 if ($usergroup > 0) {
1674 $sql .=
" AND ug.fk_usergroup = ".((int) $usergroup);
1676 if ($user->socid > 0) {
1678 $sql .=
" AND u.fk_soc = ".((int) $user->socid);
1681 if (!$canedit || $filtert ==
'-3') {
1682 if (!$user->hasRight(
'user',
'user',
'lire') || $filtert ==
'-3') {
1683 $usersInHierarchy = $user->getAllChildIds(1);
1684 $sql .=
" AND u.rowid IN (".$db->sanitize(implode(
',', $usersInHierarchy)).
")";
1689 $resql = $db->query($sql);
1691 $num = $db->num_rows($resql);
1695 $obj = $db->fetch_object($resql);
1696 $usernamesid[$obj->rowid] = $obj->rowid;
1705 foreach ($usernamesid as
$id) {
1706 $tmpuser =
new User($db);
1707 $result = $tmpuser->fetch(
$id);
1708 $usernames[] = $tmpuser;
1712 $labelbytype = array();
1713 $sql =
"SELECT code, color, libelle as label FROM ".MAIN_DB_PREFIX.
"c_actioncomm ORDER BY position";
1714 $resql = $db->query($sql);
1715 while ($obj = $db->fetch_object($resql)) {
1716 $colorsbytype[$obj->code] = $obj->color;
1717 $labelbytype[$obj->code] = $obj->label;
1725 foreach ($usernames as $username) {
1731 echo
'<td class="tdoverflowmax100 cal_current_month cal_peruserviewname'.($var ?
' cal_impair' :
'').
'">';
1732 print
'<span class="paddingrightimp">';
1733 print $username->getNomUrl(-1,
'', 0, 0, 20, 1,
'',
'paddingleft');
1740 for ($iter_day = 0; $iter_day < 8; $iter_day++) {
1741 if (($i + 1) < $begin_d || ($i + 1) > $end_d) {
1754 $style =
'cal_current_month';
1755 if ($iter_day == 6) {
1756 $style .=
' cal_other_month';
1759 if ($todayarray[
'mday'] == $tmpday && $todayarray[
'mon'] == $tmpmonth && $todayarray[
'year'] == $tmpyear) {
1763 $style =
'cal_today_peruser';
1766 show_day_events2($username, $tmpday, $tmpmonth, $tmpyear, 0, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, $showheader, $colorsbytype, $var);
1771 $showheader =
false;
1783 $langs->load(
"commercial");
1784 print
'<br>'.$langs->trans(
"Legend").
': <br>';
1785 foreach ($colorsbytype as $code => $color) {
1787 print
'<div style="float: left; padding: 2px; margin-right: 6px;"><div style="background: #'.$color.
'; width:16px; float: left; margin-right: 4px;"> </div>';
1788 print $langs->trans(
"Action".$code) !=
"Action".$code ? $langs->trans(
"Action".$code) : $labelbytype[$code];
1794 print
'<div style="float: left; padding: 2px; margin-right: 6px;"><div class="peruser_busy" style="width:16px; float: left; margin-right: 4px;"> </div>';
1795 print $langs->trans(
"Other");
1804print
"\n".
'</form>';
1809print
'<script type="text/javascript">
1810jQuery(document).ready(function() {
1811 jQuery(".onclickopenref").click(function() {
1812 var ref=$(this).attr(\'ref\');
1813 var res = ref.split("_");
1815 var userid = res[1];
1823 console.log("We click on a class onclickopenref in page peruser with ref="+ref+" type="+type);
1825 if (ids == \'none\') /* No event */
1827 /* alert(\'no event\'); */
1828 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 :
'')).
'"
1829 window.location.href = url;
1831 else if (ids.indexOf(",") > -1) /* There is several events */
1833 /* alert(\'several events\'); */
1834 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;
1835 window.location.href = url;
1836 } else { /* One event */
1837 /* alert(\'one event\'); */
1838 if (type == \'holiday\') {
1839 url = "'.DOL_URL_ROOT.
'/holiday/card.php?id="+ids
1841 url = "'.DOL_URL_ROOT.
'/comm/action/card.php?action=view&id="+ids
1843 window.location.href = url;
1876function 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)
1879 global $user,
$conf, $langs, $hookmanager, $action;
1880 global $filter, $filtert, $status, $actioncode;
1881 global $theme_datacolor;
1882 global $cachethirdparties, $cachecontacts, $cacheusers, $cacheprojects, $colorindexused;
1883 global $begin_h, $end_h;
1894 $numicals = array();
1897 $colorindexused[$user->id] = 0;
1898 $nextindextouse = count($colorindexused);
1905 foreach ($eventarray as $daykey => $notused) {
1912 if ($day == $jour && (
int) $month == $mois && $year == $annee) {
1916 foreach ($eventarray[$daykey] as $index => $event) {
1920 $keysofuserassigned = array_keys($event->userassigned);
1922 if (!in_array($username->id, $keysofuserassigned)) {
1927 $parameters = array();
1928 $reshook = $hookmanager->executeHooks(
'formatEvent', $parameters, $event, $action);
1938 if ($event->type_code ==
'HOLIDAY') {
1939 $cssclass =
'family_holiday';
1942 if (in_array($user->id, $keysofuserassigned)) {
1943 $cssclass =
'family_mytasks';
1945 if (empty($cacheusers[$event->userownerid])) {
1946 $newuser =
new User($db);
1947 $newuser->fetch($event->userownerid);
1948 $cacheusers[$event->userownerid] = $newuser;
1953 if (!empty($cacheusers[$event->userownerid]->color)) {
1954 $color = $cacheusers[$event->userownerid]->color;
1958 $color = $event->type_color;
1960 } elseif ($event->type_code ==
'ICALEVENT') {
1962 if (!empty($event->icalname)) {
1969 $color = $event->icalcolor;
1970 $cssclass = (!empty($event->icalname) ?
'family_ext'.md5($event->icalname) :
'family_other unsortable');
1971 } elseif ($event->type_code ==
'BIRTHDAY') {
1974 $cssclass =
'family_birthday unsortable';
1975 $color = sprintf(
"%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
1978 $color = ($event->icalcolor ? $event->icalcolor : -1);
1979 $cssclass = (!empty($event->icalname) ?
'family_ext'.md5($event->icalname) :
'family_other');
1981 if (empty($cacheusers[$event->userownerid])) {
1982 $newuser =
new User($db);
1983 $newuser->fetch($event->userownerid);
1984 $cacheusers[$event->userownerid] = $newuser;
1989 if (!empty($cacheusers[$event->userownerid]->color)) {
1990 $color = $cacheusers[$event->userownerid]->color;
1994 $color = $event->type_color;
2000 $idusertouse = ($event->userownerid ? $event->userownerid : 0);
2001 if (isset($colorindexused[$idusertouse])) {
2002 $colorindex = $colorindexused[$idusertouse];
2004 $colorindex = $nextindextouse;
2005 $colorindexused[$idusertouse] = $colorindex;
2006 if (!empty($theme_datacolor[$nextindextouse + 1])) {
2011 $color = sprintf(
"%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
2015 for ($h = $begin_h; $h < $end_h; $h++) {
2018 if (empty($event->fulldayevent)) {
2019 $a =
dol_mktime((
int) $h, 0, 0, $month, $day, $year,
'tzuserrel', 0);
2020 $b =
dol_mktime((
int) $h, 15, 0, $month, $day, $year,
'tzuserrel', 0);
2021 $b1 =
dol_mktime((
int) $h, 30, 0, $month, $day, $year,
'tzuserrel', 0);
2022 $b2 =
dol_mktime((
int) $h, 45, 0, $month, $day, $year,
'tzuserrel', 0);
2023 $c =
dol_mktime((
int) $h + 1, 0, 0, $month, $day, $year,
'tzuserrel', 0);
2025 $dateendtouse = $event->date_end_in_calendar;
2026 if ($dateendtouse == $event->date_start_in_calendar) {
2032 if ($event->date_start_in_calendar < $b && $dateendtouse > $a) {
2033 $busy = $event->transparency;
2034 $cases1[$h][$event->id][
'busy'] = $busy;
2035 $cases1[$h][$event->id][
'string'] =
dol_print_date($event->date_start_in_calendar,
'dayhour',
'tzuserrel');
2036 if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) {
2037 $tmpa =
dol_getdate($event->date_start_in_calendar,
true);
2038 $tmpb =
dol_getdate($event->date_end_in_calendar,
true);
2039 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) {
2040 $cases1[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'hour',
'tzuserrel');
2042 $cases1[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'dayhour',
'tzuserrel');
2045 if ($event->label) {
2046 $cases1[$h][$event->id][
'string'] .=
' - '.$event->label;
2048 $cases1[$h][$event->id][
'typecode'] = $event->type_code;
2049 if ($event->type_code ==
'HOLIDAY') {
2050 $cases1[$h][$event->id][
'css'] =
'peruser_holiday ';
2052 $cases1[$h][$event->id][
'css'] .=
'peruser_holiday_imp ';
2055 $cases1[$h][$event->id][
'color'] = $color;
2057 if ($event->fk_project > 0) {
2058 if (empty($cacheprojects[$event->fk_project])) {
2060 $tmpproj->fetch($event->fk_project);
2061 $cacheprojects[$event->fk_project] = $tmpproj;
2063 $cases1[$h][$event->id][
'string'] .=
', '.$langs->trans(
"Project").
': '.$cacheprojects[$event->fk_project]->ref.
' - '.$cacheprojects[$event->fk_project]->title;
2065 if ($event->socid > 0) {
2066 if (empty($cachethirdparties[$event->socid])) {
2067 $tmpthirdparty =
new Societe($db);
2068 $tmpthirdparty->fetch($event->socid);
2069 $cachethirdparties[$event->socid] = $tmpthirdparty;
2071 $cases1[$h][$event->id][
'string'] .=
', '.$cachethirdparties[$event->socid]->name;
2073 if ($event->contact_id > 0) {
2074 if (empty($cachecontacts[$event->contact_id])) {
2075 $tmpcontact =
new Contact($db);
2076 $tmpcontact->fetch($event->contact_id);
2077 $cachecontacts[$event->contact_id] = $tmpcontact;
2079 $cases1[$h][$event->id][
'string'] .=
', '.$cachecontacts[$event->contact_id]->getFullName($langs);
2083 if ($event->date_start_in_calendar < $b1 && $dateendtouse > $b) {
2084 $busy = $event->transparency;
2085 $cases2[$h][$event->id][
'busy'] = $busy;
2086 $cases2[$h][$event->id][
'string'] =
dol_print_date($event->date_start_in_calendar,
'dayhour',
'tzuserrel');
2087 if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) {
2088 $tmpa =
dol_getdate($event->date_start_in_calendar,
true);
2089 $tmpb =
dol_getdate($event->date_end_in_calendar,
true);
2090 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) {
2091 $cases2[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'hour',
'tzuserrel');
2093 $cases2[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'dayhour',
'tzuserrel');
2096 if ($event->label) {
2097 $cases2[$h][$event->id][
'string'] .=
' - '.$event->label;
2099 $cases2[$h][$event->id][
'typecode'] = $event->type_code;
2100 if ($event->type_code ==
'HOLIDAY') {
2101 $cases2[$h][$event->id][
'css'] =
'peruser_holiday ';
2103 $cases2[$h][$event->id][
'css'] .=
'peruser_holiday_imp ';
2106 $cases2[$h][$event->id][
'color'] = $color;
2108 if ($event->fk_project > 0) {
2109 if (empty($cacheprojects[$event->fk_project])) {
2111 $tmpproj->fetch($event->fk_project);
2112 $cacheprojects[$event->fk_project] = $tmpproj;
2114 $cases2[$h][$event->id][
'string'] .=
', '.$langs->trans(
"Project").
': '.$cacheprojects[$event->fk_project]->ref.
' - '.$cacheprojects[$event->fk_project]->title;
2116 if ($event->socid > 0) {
2117 if (empty($cachethirdparties[$event->socid])) {
2118 $tmpthirdparty =
new Societe($db);
2119 $tmpthirdparty->fetch($event->socid);
2120 $cachethirdparties[$event->socid] = $tmpthirdparty;
2122 $cases2[$h][$event->id][
'string'] .=
', '.$cachethirdparties[$event->socid]->name;
2124 if ($event->contact_id > 0) {
2125 if (empty($cachecontacts[$event->contact_id])) {
2126 $tmpcontact =
new Contact($db);
2127 $tmpcontact->fetch($event->contact_id);
2128 $cachecontacts[$event->contact_id] = $tmpcontact;
2130 $cases2[$h][$event->id][
'string'] .=
', '.$cachecontacts[$event->contact_id]->getFullName($langs);
2134 if ($event->date_start_in_calendar < $b2 && $dateendtouse > $b1) {
2135 $busy = $event->transparency;
2136 $cases3[$h][$event->id][
'busy'] = $busy;
2137 $cases3[$h][$event->id][
'string'] =
dol_print_date($event->date_start_in_calendar,
'dayhour',
'tzuserrel');
2138 if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) {
2139 $tmpa =
dol_getdate($event->date_start_in_calendar,
true);
2140 $tmpb =
dol_getdate($event->date_end_in_calendar,
true);
2141 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) {
2142 $cases3[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'hour',
'tzuserrel');
2144 $cases3[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'dayhour',
'tzuserrel');
2147 if ($event->label) {
2148 $cases3[$h][$event->id][
'string'] .=
' - '.$event->label;
2150 $cases3[$h][$event->id][
'typecode'] = $event->type_code;
2151 if ($event->type_code ==
'HOLIDAY') {
2152 $cases3[$h][$event->id][
'css'] .=
'peruser_holiday ';
2154 $cases3[$h][$event->id][
'css'] .=
'peruser_holiday_imp ';
2157 $cases3[$h][$event->id][
'color'] = $color;
2159 if ($event->fk_project > 0) {
2160 if (empty($cacheprojects[$event->fk_project])) {
2162 $tmpproj->fetch($event->fk_project);
2163 $cacheprojects[$event->fk_project] = $tmpproj;
2165 $cases3[$h][$event->id][
'string'] .=
', '.$langs->trans(
"Project").
': '.$cacheprojects[$event->fk_project]->ref.
' - '.$cacheprojects[$event->fk_project]->title;
2167 if ($event->socid > 0) {
2168 if (empty($cachethirdparties[$event->socid])) {
2169 $tmpthirdparty =
new Societe($db);
2170 $tmpthirdparty->fetch($event->socid);
2171 $cachethirdparties[$event->socid] = $tmpthirdparty;
2173 $cases3[$h][$event->id][
'string'] .=
', '.$cachethirdparties[$event->socid]->name;
2175 if ($event->contact_id > 0) {
2176 if (empty($cachecontacts[$event->contact_id])) {
2177 $tmpcontact =
new Contact($db);
2178 $tmpcontact->fetch($event->contact_id);
2179 $cachecontacts[$event->contact_id] = $tmpcontact;
2181 $cases3[$h][$event->id][
'string'] .=
', '.$cachecontacts[$event->contact_id]->getFullName($langs);
2185 if ($event->date_start_in_calendar <
$c && $dateendtouse > $b2) {
2186 $busy = $event->transparency;
2187 $cases4[$h][$event->id][
'busy'] = $busy;
2188 $cases4[$h][$event->id][
'string'] =
dol_print_date($event->date_start_in_calendar,
'dayhour',
'tzuserrel');
2189 if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) {
2190 $tmpa =
dol_getdate($event->date_start_in_calendar,
true);
2191 $tmpb =
dol_getdate($event->date_end_in_calendar,
true);
2192 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) {
2193 $cases4[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'hour',
'tzuserrel');
2195 $cases4[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'dayhour',
'tzuserrel');
2198 if ($event->label) {
2199 $cases4[$h][$event->id][
'string'] .=
' - '.$event->label;
2201 $cases4[$h][$event->id][
'typecode'] = $event->type_code;
2202 if ($event->type_code ==
'HOLIDAY') {
2203 $cases4[$h][$event->id][
'css'] =
'peruser_holiday ';
2205 $cases4[$h][$event->id][
'css'] .=
'peruser_holiday_imp ';
2208 $cases4[$h][$event->id][
'color'] = $color;
2210 if ($event->fk_project > 0) {
2211 if (empty($cacheprojects[$event->fk_project])) {
2213 $tmpproj->fetch($event->fk_project);
2214 $cacheprojects[$event->fk_project] = $tmpproj;
2216 $cases4[$h][$event->id][
'string'] .=
', '.$langs->trans(
"Project").
': '.$cacheprojects[$event->fk_project]->ref.
' - '.$cacheprojects[$event->fk_project]->title;
2218 if ($event->socid > 0) {
2219 if (empty($cachethirdparties[$event->socid])) {
2220 $tmpthirdparty =
new Societe($db);
2221 $tmpthirdparty->fetch($event->socid);
2222 $cachethirdparties[$event->socid] = $tmpthirdparty;
2224 $cases4[$h][$event->id][
'string'] .=
', '.$cachethirdparties[$event->socid]->name;
2226 if ($event->contact_id > 0) {
2227 if (empty($cachecontacts[$event->contact_id])) {
2228 $tmpcontact =
new Contact($db);
2229 $tmpcontact->fetch($event->contact_id);
2230 $cachecontacts[$event->contact_id] = $tmpcontact;
2232 $cases4[$h][$event->id][
'string'] .=
', '.$cachecontacts[$event->contact_id]->getFullName($langs);
2237 $busy = $event->transparency;
2238 $cases1[$h][$event->id][
'busy'] = $busy;
2239 $cases2[$h][$event->id][
'busy'] = $busy;
2240 $cases3[$h][$event->id][
'busy'] = $busy;
2241 $cases4[$h][$event->id][
'busy'] = $busy;
2242 $cases1[$h][$event->id][
'string'] = $event->label;
2243 $cases2[$h][$event->id][
'string'] = $event->label;
2244 $cases3[$h][$event->id][
'string'] = $event->label;
2245 $cases4[$h][$event->id][
'string'] = $event->label;
2246 $cases1[$h][$event->id][
'typecode'] = $event->type_code;
2247 $cases2[$h][$event->id][
'typecode'] = $event->type_code;
2248 $cases3[$h][$event->id][
'typecode'] = $event->type_code;
2249 $cases4[$h][$event->id][
'typecode'] = $event->type_code;
2250 $cases1[$h][$event->id][
'color'] = $color;
2251 $cases2[$h][$event->id][
'color'] = $color;
2252 $cases3[$h][$event->id][
'color'] = $color;
2253 $cases4[$h][$event->id][
'color'] = $color;
2254 $cases1[$h][$event->id][
'css'] =
'';
2255 $cases2[$h][$event->id][
'css'] =
'';
2256 $cases3[$h][$event->id][
'css'] =
'';
2257 $cases4[$h][$event->id][
'css'] =
'';
2268 for ($h = $begin_h; $h < $end_h; $h++) {
2273 $style1 =
'onclickopenref ';
2274 $style2 =
'onclickopenref ';
2275 $style3 =
'onclickopenref ';
2276 $style4 =
'onclickopenref ';
2277 $string1 =
' ';
2278 $string2 =
' ';
2279 $string3 =
' ';
2280 $string4 =
' ';
2285 if (isset($cases1[$h]) && $cases1[$h] !=
'') {
2287 if (count($cases1[$h]) > 1) {
2288 $title1 .= count($cases1[$h]).
' '.(count($cases1[$h]) == 1 ? $langs->trans(
"Event") : $langs->trans(
"Events"));
2292 $style1 .=
'peruser_notbusy ';
2294 $style1 .=
'peruser_busy ';
2296 foreach ($cases1[$h] as
$id => $ev) {
2297 if (!empty($ev[
'busy'])) {
2298 $style1 =
'onclickopenref peruser_busy';
2300 if (!empty($ev[
'css'])) {
2301 $style1 .=
' '.$ev[
'css'];
2305 if (isset($cases2[$h]) && $cases2[$h] !=
'') {
2307 if (count($cases2[$h]) > 1) {
2308 $title2 .= count($cases2[$h]).
' '.(count($cases2[$h]) == 1 ? $langs->trans(
"Event") : $langs->trans(
"Events"));
2312 $style2 .=
'peruser_notbusy ';
2314 $style2 .=
'peruser_busy ';
2316 foreach ($cases2[$h] as
$id => $ev) {
2317 if (!empty($ev[
'busy'])) {
2318 $style2 =
'onclickopenref peruser_busy';
2320 if (!empty($ev[
'css'])) {
2321 $style2 .=
' '.$ev[
'css'];
2325 if (isset($cases3[$h]) && $cases3[$h] !=
'') {
2327 if (count($cases3[$h]) > 1) {
2328 $title3 .= count($cases3[$h]).
' '.(count($cases3[$h]) == 1 ? $langs->trans(
"Event") : $langs->trans(
"Events"));
2332 $style3 .=
'peruser_notbusy ';
2334 $style3 .=
'peruser_busy ';
2336 foreach ($cases3[$h] as
$id => $ev) {
2337 if (!empty($ev[
'busy'])) {
2338 $style3 =
'onclickopenref peruser_busy';
2340 if (!empty($ev[
'css'])) {
2341 $style3 .=
' '.$ev[
'css'];
2345 if (isset($cases4[$h]) && $cases4[$h] !=
'') {
2347 if (count($cases4[$h]) > 1) {
2348 $title4 .= count($cases4[$h]).
' '.(count($cases4[$h]) == 1 ? $langs->trans(
"Event") : $langs->trans(
"Events"));
2352 $style4 .=
'peruser_notbusy ';
2354 $style4 .=
'peruser_busy ';
2356 foreach ($cases4[$h] as
$id => $ev) {
2357 if (!empty($ev[
'busy'])) {
2358 $style4 =
'onclickopenref peruser_busy';
2360 if (!empty($ev[
'css'])) {
2361 $style4 .=
' '.$ev[
'css'];
2370 if (!empty($cases1[$h]) && is_array($cases1[$h]) && count($cases1[$h]) && array_keys($cases1[$h])) {
2371 $ids1 = implode(
', ', array_keys($cases1[$h]));
2373 if (!empty($cases2[$h]) && is_array($cases2[$h]) && count($cases2[$h]) && array_keys($cases2[$h])) {
2374 $ids2 = implode(
', ', array_keys($cases2[$h]));
2376 if (!empty($cases3[$h]) && is_array($cases3[$h]) && count($cases3[$h]) && array_keys($cases3[$h])) {
2377 $ids3 = implode(
',', array_keys($cases3[$h]));
2379 if (!empty($cases4[$h]) && is_array($cases4[$h]) && count($cases4[$h]) && array_keys($cases4[$h])) {
2380 $ids4 = implode(
',', array_keys($cases4[$h]));
2383 if ($h == $begin_h) {
2384 echo
'<td class="'.$style.
'_peruserleft cal_peruser'.($var ?
' cal_impair '.$style.
'_impair' :
'').
'">';
2386 echo
'<td class="'.$style.
' cal_peruser'.($var ?
' cal_impair '.$style.
'_impair' :
'').
'">';
2391 if (!empty($cases1[$h]) && is_array($cases1[$h]) && count($cases1[$h]) == 1) {
2392 $output = array_slice($cases1[$h], 0, 1);
2393 if ($output[0][
'typecode'] ==
'HOLIDAY') {
2395 $title1 = $langs->trans(
"Holiday");
2397 $title1 = $langs->trans(
"Ref").
' '.$ids1.($title1 ?
' - '.$title1 :
'');
2398 if ($output[0][
'string']) {
2399 $title1 .=
' - '.$output[0][
'string'];
2402 if ($output[0][
'color']) {
2403 $color1 = $output[0][
'color'];
2405 } elseif (!empty($cases1[$h]) && is_array($cases1[$h]) && count($cases1[$h]) > 1) {
2406 $title1 = $langs->trans(
"Ref").
' '.$ids1.($title1 ?
' - '.$title1 :
'');
2412 if (!empty($cases2[$h]) && is_array($cases2[$h]) && count($cases2[$h]) == 1) {
2413 $output = array_slice($cases2[$h], 0, 1);
2414 if ($output[0][
'typecode'] ==
'HOLIDAY') {
2416 $title2 = $langs->trans(
"Holiday");
2418 $title2 = $langs->trans(
"Ref").
' '.$ids2.($title2 ?
' - '.$title2 :
'');
2419 if ($output[0][
'string']) {
2420 $title2 .=
' - '.$output[0][
'string'];
2423 if ($output[0][
'color']) {
2424 $color2 = $output[0][
'color'];
2426 } elseif (!empty($cases2[$h]) && is_array($cases2[$h]) && count($cases2[$h]) > 1) {
2427 $title2 = $langs->trans(
"Ref").
' '.$ids2.($title2 ?
' - '.$title2 :
'');
2433 if (!empty($cases3[$h]) && is_array($cases3[$h]) && count($cases3[$h]) == 1) {
2434 $output = array_slice($cases3[$h], 0, 1);
2435 if ($output[0][
'typecode'] ==
'HOLIDAY') {
2437 $title3 = $langs->trans(
"Holiday");
2439 $title3 = $langs->trans(
"Ref").
' '.$ids3.($title3 ?
' - '.$title3 :
'');
2440 if ($output[0][
'string']) {
2441 $title3 .=
' - '.$output[0][
'string'];
2444 if ($output[0][
'color']) {
2445 $color3 = $output[0][
'color'];
2447 } elseif (!empty($cases3[$h]) && is_array($cases3[$h]) && count($cases3[$h]) > 1) {
2448 $title3 = $langs->trans(
"Ref").
' '.$ids3.($title3 ?
' - '.$title3 :
'');
2454 if (!empty($cases4[$h]) && is_array($cases4[$h]) && count($cases4[$h]) == 1) {
2455 $output = array_slice($cases4[$h], 0, 1);
2456 if ($output[0][
'typecode'] ==
'HOLIDAY') {
2458 $title4 = $langs->trans(
"Holiday");
2460 $title4 = $langs->trans(
"Ref").
' '.$ids3.($title4 ?
' - '.$title4 :
'');
2461 if ($output[0][
'string']) {
2462 $title4 .=
' - '.$output[0][
'string'];
2465 if ($output[0][
'color']) {
2466 $color4 = $output[0][
'color'];
2468 } elseif (!empty($cases4[$h]) && is_array($cases4[$h]) && count($cases4[$h]) > 1) {
2469 $title4 = $langs->trans(
"Ref").
' '.$ids4.($title4 ?
' - '.$title4 :
'');
2473 print
'<table class="nobordernopadding case centpercent">';
2476 if ($style1 ==
'peruser_notbusy') {
2477 print
'style="border: 1px solid #'.($color1 ? $color1 :
"888").
' !important" ';
2478 } elseif ($color1) {
2479 print
'style="background: #'.$color1.
'; "';
2483 print
'center'.($title1 ?
' classfortooltip' :
'').($title1 ?
' cursorpointer' :
'').
'"';
2484 print
'ref="'.$ref1.
'_'.$username->id.
'_'.sprintf(
"%04d", $year).
'_'.sprintf(
"%02d", $month).
'_'.sprintf(
"%02d", $day).
'_'.sprintf(
"%02d", $h).
'_00_'.($ids1 ? $ids1 :
'none').
'"';
2485 print ($title1 ?
' title="'.$title1.
'"' :
'').
'>';
2490 if ($style2 ==
'peruser_notbusy') {
2491 print
'style="border: 1px solid #'.($color2 ? $color2 :
"888").
' !important" ';
2492 } elseif ($color2) {
2493 print
'style="background: #'.$color2.
'; "';
2497 print
'center'.($title2 ?
' classfortooltip' :
'').($title2 ?
' cursorpointer' :
'').
'"';
2498 print
' ref="'.$ref2.
'_'.$username->id.
'_'.sprintf(
"%04d", $year).
'_'.sprintf(
"%02d", $month).
'_'.sprintf(
"%02d", $day).
'_'.sprintf(
"%02d", $h).
'_15_'.($ids2 ? $ids2 :
'none').
'"';
2499 print ($title2 ?
' title="'.$title2.
'"' :
'').
'>';
2504 if ($style3 ==
'peruser_notbusy') {
2505 print
'style="border: 1px solid #'.($color3 ? $color3 :
"888").
' !important" ';
2506 } elseif ($color3) {
2507 print
'style="background: #'.$color3.
'; "';
2511 print
'center'.($title3 ?
' classfortooltip' :
'').($title3 ?
' cursorpointer' :
'').
'"';
2512 print
' ref="'.$ref3.
'_'.$username->id.
'_'.sprintf(
"%04d", $year).
'_'.sprintf(
"%02d", $month).
'_'.sprintf(
"%02d", $day).
'_'.sprintf(
"%02d", $h).
'_30_'.($ids3 ? $ids3 :
'none').
'"';
2513 print ($title3 ?
' title="'.$title3.
'"' :
'').
'>';
2518 if ($style4 ==
'peruser_notbusy') {
2519 print
'style="border: 1px solid #'.($color4 ? $color4 :
"888").
' !important" ';
2520 } elseif ($color4) {
2521 print
'style="background: #'.$color4.
'; "';
2525 print
'center'.($title4 ?
' classfortooltip' :
'').($title4 ?
' cursorpointer' :
'').
'"';
2526 print
' ref="'.$ref4.
'_'.$username->id.
'_'.sprintf(
"%04d", $year).
'_'.sprintf(
"%02d", $month).
'_'.sprintf(
"%02d", $day).
'_'.sprintf(
"%02d", $h).
'_45_'.($ids4 ? $ids4 :
'none').
'"';
2527 print ($title4 ?
' title="'.$title4.
'"' :
'').
'>';
$id
Support class for third parties, contacts, members, users or resources.
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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)
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_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
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)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
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_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.
getDolUserString($key, $default='', $tmpuser=null)
Return Dolibarr user constant string value.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dolGetFirstLastname($firstname, $lastname, $nameorder=-1)
Return firstname and lastname in correct order.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_clone($object, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_sanitizePathName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a path name.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
conf($dolibarr_main_document_root)
Load conf file (file must exists)
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.