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);
64$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
65$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
67if (empty($page) || $page == -1) {
71$offset = $limit * $page;
76 $sortfield =
"a.datec";
82 $socid = $user->socid;
89if (!$user->hasRight(
'agenda',
'myactions',
'read')) {
92if (!$user->hasRight(
'agenda',
'allactions',
'read')) {
95if (!$user->hasRight(
'agenda',
'allactions',
'read') || $filter ==
'mine') {
96 $filtert = (string) $user->id;
99$mode =
'show_peruser';
105$pid = GETPOSTISSET(
"search_projectid") ?
GETPOSTINT(
"search_projectid", 3) :
GETPOSTINT(
"projectid", 3);
106$status = GETPOSTISSET(
"search_status") ?
GETPOST(
"search_status",
'aZ09') :
GETPOST(
"status",
'aZ09');
107$type = GETPOSTISSET(
"search_type") ?
GETPOST(
"search_type",
'aZ09') :
GETPOST(
"type",
'aZ09');
109$optioncss =
GETPOST(
'optioncss',
'aZ');
112if (
GETPOST(
'search_actioncode',
'array:aZ09')) {
113 $actioncode =
GETPOST(
'search_actioncode',
'array:aZ09', 3);
114 if (!count($actioncode)) {
118 $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')));
122if ($dateselect > 0) {
130$tmp = str_replace(
' ',
'', $tmp);
131$tmparray = explode(
'-', $tmp);
132$begin_h = GETPOSTISSET(
'begin_h') ?
GETPOSTINT(
'begin_h') : ($tmparray[0] !=
'' ? $tmparray[0] : 9);
133$end_h = GETPOSTISSET(
'end_h') ?
GETPOSTINT(
'end_h') : ($tmparray[1] !=
'' ? $tmparray[1] : 18);
134if ($begin_h < 0 || $begin_h > 23) {
137if ($end_h < 1 || $end_h > 24) {
140if ($end_h <= $begin_h) {
141 $end_h = $begin_h + 1;
146$tmp = str_replace(
' ',
'', $tmp);
147$tmparray = explode(
'-', $tmp);
148$begin_d = GETPOSTISSET(
'begin_d') ?
GETPOSTINT(
'begin_d') : ($tmparray[0] !=
'' ? $tmparray[0] : 1);
149$end_d = GETPOSTISSET(
'end_d') ?
GETPOSTINT(
'end_d') : ($tmparray[1] !=
'' ? $tmparray[1] : 5);
150if ($begin_d < 1 || $begin_d > 7) {
153if ($end_d < 1 || $end_d > 7) {
156if ($end_d < $begin_d) {
157 $end_d = $begin_d + 1;
160if ($status ==
'' && !GETPOSTISSET(
'search_status')) {
164if (empty($mode) && !GETPOSTISSET(
'mode')) {
169if (
GETPOST(
'viewcal',
'alpha') && $mode !=
'show_day' && $mode !=
'show_week' && $mode !=
'show_peruser') {
170 $mode =
'show_month';
174if (
GETPOST(
'viewweek',
'alpha') || $mode ==
'show_week') {
176 $week = ($week ? $week :
date(
"W"));
177 $day = ($day ? $day :
date(
"d"));
180if (
GETPOST(
'viewday',
'alpha') || $mode ==
'show_day') {
182 $day = ($day ? $day :
date(
"d"));
188$langs->loadLangs(array(
'users',
'agenda',
'other',
'commercial'));
191$hookmanager->initHooks(array(
'agenda'));
193$result =
restrictedArea($user,
'agenda', 0,
'actioncomm&societe',
'myactions|allactions',
'fk_soc',
'id');
194if ($user->socid && $socid) {
198$search_status = $status;
219 'maxprint' => $maxprint,
221 'filtert' => $filtert,
222 'showbirthday' => $showbirthday,
223 'canedit' => $canedit,
224 'optioncss' => $optioncss,
225 'actioncode' => $actioncode,
227 'resourceid' => $resourceid,
228 'usergroup' => $usergroup,
230$reshook = $hookmanager->executeHooks(
'beforeAgendaPerUser', $parameters, $object, $action);
235$form =
new Form($db);
236$companystatic =
new Societe($db);
238$help_url =
'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda|DE:Modul_Terminplanung';
239llxHeader(
'', $langs->trans(
"Agenda"), $help_url);
243$nowyear = $nowarray[
'year'];
244$nowmonth = $nowarray[
'mon'];
245$nowday = $nowarray[
'mday'];
248$listofextcals = array();
253 while ($i < $MAXAGENDA) {
255 $source =
'AGENDA_EXT_SRC'.$i;
256 $name =
'AGENDA_EXT_NAME'.$i;
257 $offsettz =
'AGENDA_EXT_OFFSETTZ'.$i;
258 $color =
'AGENDA_EXT_COLOR'.$i;
259 $default =
'AGENDA_EXT_ACTIVEBYDEFAULT'.$i;
260 $buggedfile =
'AGENDA_EXT_BUGGEDFILE'.$i;
263 $listofextcals[] = array(
264 'type' =>
'globalsetup',
280 while ($i < $MAXAGENDA) {
282 $source =
'AGENDA_EXT_SRC_'.$user->id.
'_'.$i;
283 $name =
'AGENDA_EXT_NAME_'.$user->id.
'_'.$i;
284 $offsettz =
'AGENDA_EXT_OFFSETTZ_'.$user->id.
'_'.$i;
285 $color =
'AGENDA_EXT_COLOR_'.$user->id.
'_'.$i;
286 $enabled =
'AGENDA_EXT_ENABLED_'.$user->id.
'_'.$i;
287 $default =
'AGENDA_EXT_ACTIVEBYDEFAULT_'.$user->id.
'_'.$i;
288 $buggedfile =
'AGENDA_EXT_BUGGEDFILE_'.$user->id.
'_'.$i;
292 $listofextcals[] = array(
293 'type' =>
'usersetup',
296 'offsettz' => (
int) (empty($user->conf->$offsettz) ? 0 : $user->
conf->$offsettz),
308$first_day = $prev[
'first_day'];
309$first_month = $prev[
'first_month'];
310$first_year = $prev[
'first_year'];
312$week = $prev[
'week'];
316$next_year = $next[
'year'];
317$next_month = $next[
'month'];
318$next_day = $next[
'day'];
320$max_day_in_month =
date(
"t",
dol_mktime(0, 0, 0, $month, 1, $year));
326$title = $langs->trans(
"DoneAndToDoActions");
327if ($status ==
'done') {
328 $title = $langs->trans(
"DoneActions");
330if ($status ==
'todo') {
331 $title = $langs->trans(
"ToDoActions");
335if (($actioncode && $actioncode !==
'-1') || GETPOSTISSET(
'search_actioncode')) {
336 if (is_array($actioncode)) {
337 foreach ($actioncode as $str_action) {
338 if ($str_action !=
'-1') {
339 $param .=
"&search_actioncode[]=".urlencode($str_action);
343 $param .=
"&search_actioncode=".urlencode($actioncode);
346if ($resourceid > 0) {
347 $param .=
"&search_resourceid=".urlencode((
string) ($resourceid));
350if ($status || GETPOSTISSET(
'status') || GETPOSTISSET(
'search_status')) {
351 $param .=
"&search_status=".urlencode($status);
354 $param .=
"&search_filter=".urlencode((
string) $filter);
357 $param .=
"&search_filtert=".urlencode((
string) $filtert);
360 $param .=
"&search_usergroup=".urlencode((
string) ($usergroup));
363 $param .=
"&search_socid=".urlencode((
string) ($socid));
366 $param .=
"&search_showbirthday=1";
369 $param .=
"&search_projectid=".urlencode((
string) ($pid));
372 $param .=
"&search_type=".urlencode($type);
374if ($mode !=
'show_peruser') {
375 $param .=
'&mode='.urlencode((
string) $mode);
378 $param .=
'&begin_h='.((int) $begin_h);
381 $param .=
'&end_h='.((int) $end_h);
384 $param .=
'&begin_d='.((int) $begin_d);
387 $param .=
'&end_d='.((int) $end_d);
389if ($search_categ_cus != 0) {
390 $param .=
'&search_categ_cus='.urlencode((
string) ($search_categ_cus));
392$param .=
"&maxprint=".urlencode((
string) ($maxprint));
394$paramnoactionodate = $param;
399$prev_year = $prev[
'prev_year'];
400$prev_month = $prev[
'prev_month'];
401$prev_day = $prev[
'prev_day'];
402$first_day = $prev[
'first_day'];
403$first_month = $prev[
'first_month'];
404$first_year = $prev[
'first_year'];
406$week = $prev[
'week'];
410$next_year = $next[
'year'];
411$next_month = $next[
'month'];
412$next_day = $next[
'day'];
416$firstdaytoshow =
dol_mktime(0, 0, 0, $first_month, $first_day, $first_year,
'tzuserrel');
417$nb_weeks_to_show = (
getDolGlobalString(
'AGENDA_NB_WEEKS_IN_VIEW_PER_USER')) ? ((
int) $conf->global->AGENDA_NB_WEEKS_IN_VIEW_PER_USER * 7) : 7;
423$max_day_in_month = idate(
"t",
dol_mktime(0, 0, 0, $month, 1, $year,
'gmt'));
426$picto =
'calendarweek';
429$nav =
'<div class="navselectiondate inline-block nowraponall">';
430$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";
431$nav .=
" <span id=\"month_name\">".dol_print_date(
dol_mktime(0, 0, 0, $first_month, $first_day, $first_year),
"%Y").
", ".$langs->trans(
"WeekShort").
" ".$week;
433$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";
434if (empty($conf->dol_optimize_smallscreen)) {
435 $nav .=
' <a href="?year='.$nowyear.
'&month='.$nowmonth.
'&day='.$nowday.$param.
'" class="datenowlink marginleftonly marginrightonly">'.$langs->trans(
"Today").
'</a> ';
438$nav .= $form->selectDate($dateselect,
'dateselect', 0, 0, 1,
'', 1, 0);
440$nav .=
'<button type="submit" class="liste_titre button_search valignmiddle" name="button_search_x" value="x"><span class="fa fa-search"></span></button>';
443$paramnodate = $param;
444$param .=
'&year='.$year.
'&month='.$month.($day ?
'&day='.$day :
'');
448$paramnoaction = preg_replace(
'/mode=[a-z_]+/',
'', preg_replace(
'/action=[a-z_]+/',
'', $param));
449$paramnoactionodate = preg_replace(
'/mode=[a-z_]+/',
'', preg_replace(
'/action=[a-z_]+/',
'', $paramnodate));
453print
'<form method="POST" id="searchFormList" class="listactionsfilter" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
454if ($optioncss !=
'') {
455 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
457print
'<input type="hidden" name="token" value="'.newToken().
'">';
458print
'<input type="hidden" name="mode" value="'.$mode.
'">';
461$mode =
'show_peruser';
462$massactionbutton =
'';
465$viewmode =
'<div class="navmode inline-block">';
467$viewmode .=
'<a class="btnTitle reposition" href="'.DOL_URL_ROOT.
'/comm/action/list.php?mode=show_list&restore_lastsearch_values=1'.$paramnoactionodate.
'">';
469$viewmode .=
img_picto($langs->trans(
"List"),
'object_calendarlist',
'class="imgforviewmode pictoactionview block"');
471$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow">'.$langs->trans(
"ViewList").
'</span></a>';
475$viewmode .=
img_picto($langs->trans(
"ViewCal"),
'object_calendarmonth',
'class="pictoactionview block"');
477$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow">'.$langs->trans(
"ViewCal").
'</span></a>';
481$viewmode .=
img_picto($langs->trans(
"ViewWeek"),
'object_calendarweek',
'class="pictoactionview block"');
483$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow">'.$langs->trans(
"ViewWeek").
'</span></a>';
487$viewmode .=
img_picto($langs->trans(
"ViewDay"),
'object_calendarday',
'class="pictoactionview block"');
489$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow">'.$langs->trans(
"ViewDay").
'</span></a>';
493$viewmode .=
img_picto($langs->trans(
"ViewPerUser"),
'object_calendarperuser',
'class="pictoactionview block"');
495$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow" title="'.dolPrintHTML($langs->trans(
"ViewPerUser")).
'">'.$langs->trans(
"ViewPerUser").
'</span></a>';
498$parameters = array();
500$reshook = $hookmanager->executeHooks(
'addCalendarView', $parameters, $object, $action);
501if (empty($reshook)) {
502 $viewmode .= $hookmanager->resPrint;
503} elseif ($reshook > 1) {
504 $viewmode = $hookmanager->resPrint;
507$viewmode .=
'</div>';
509$viewmode .=
'<span class="marginrightonly"></span>';
514if ($user->hasRight(
'agenda',
'myactions',
'create') || $user->hasRight(
'agenda',
'allactions',
'create')) {
517 $newparam .=
'&month='.urlencode(str_pad((
string) $month, 2,
"0", STR_PAD_LEFT)).
'&year='.((int) $tmpforcreatebutton[
'year']);
518 if ($begin_h !==
'') {
519 $newparam .=
'&begin_h='.((int) $begin_h);
522 $newparam .=
'&end_h='.((int) $end_h);
524 if ($begin_d !==
'') {
525 $newparam .=
'&begin_d='.((int) $begin_d);
528 $newparam .=
'&end_d='.((int) $end_d);
531 $urltocreateaction = DOL_URL_ROOT.
'/comm/action/card.php?action=create';
532 $urltocreateaction .=
'&apyear='.$tmpforcreatebutton[
'year'].
'&apmonth='.$tmpforcreatebutton[
'mon'].
'&apday='.$tmpforcreatebutton[
'mday'].
'&aphour='.$tmpforcreatebutton[
'hours'].
'&apmin='.$tmpforcreatebutton[
'minutes'];
533 $urltocreateaction .=
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?'.$newparam);
535 $newcardbutton .=
dolGetButtonTitle($langs->trans(
"AddAction"),
'',
'fa fa-plus-circle', $urltocreateaction);
544$showextcals = $listofextcals;
545$bookcalcalendars = array();
549 $sql =
"SELECT ba.rowid, bc.label, bc.ref, bc.rowid as id_cal";
550 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bookcal_availabilities as ba";
551 $sql .=
" JOIN ".MAIN_DB_PREFIX.
"bookcal_calendar as bc";
552 $sql .=
" ON bc.rowid = ba.fk_bookcal_calendar";
553 $sql .=
" WHERE bc.status = 1";
554 $sql .=
" AND ba.status = 1";
555 $sql .=
" AND bc.entity IN (".getEntity(
'agenda').
")";
556 if (!empty($filtert) && $filtert !=
'-1' && $filtert !=
'-2') {
557 $sql .=
" AND bc.visibility IN (".$db->sanitize($filtert, 0, 0, 0, 0).
")";
559 $resql = $db->query($sql);
561 $num = $db->num_rows($resql);
564 $objp = $db->fetch_object($resql);
565 $label = !empty($objp->label) ? $objp->label : $objp->ref;
566 $bookcalcalendars[
"calendars"][] = array(
"id" => $objp->id_cal,
"label" => $label);
567 $bookcalcalendars[
"availabilitieslink"][$objp->rowid] = $objp->id_cal;
575if (!empty($conf->use_javascript_ajax)) {
576 $s .=
"\n".
'<!-- Div to calendars selectors -->'.
"\n";
578 $s .=
'<script type="text/javascript">'.
"\n";
579 $s .=
'jQuery(document).ready(function () {'.
"\n";
580 $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";
581 $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";
582 if (
isModEnabled(
"bookcal") && !empty($bookcalcalendars[
"calendars"])) {
583 foreach ($bookcalcalendars[
"calendars"] as $key => $value) {
584 $s .=
'jQuery(".check_bookcal_calendar_'.$value[
'id'].
'").click(function() { console.log("Toggle Bookcal Calendar '.$value[
'id'].
'"); jQuery(".family_bookcal_calendar_'.$value[
'id'].
'").toggle(); });'.
"\n";
588 $s .=
'</script>'.
"\n";
591 $s .=
'<div class="nowrap inline-block minheight30"><input type="checkbox" id="check_mytasks" name="check_mytasks" value="1" class="check_mytasks" checked disabled><label class="labelcalendar"><span class="check_holiday_text"> '.$langs->trans(
"LocalAgenda").
' </span></label></div>';
594 if ($user->hasRight(
"holiday",
"read")) {
596 <div class="nowrap inline-block minheight30"><input type="checkbox" id="check_holiday" name="check_holiday" value="1" class="marginleftonly check_holiday"' . ($check_holiday ?
' checked' :
'') .
'>
597 <label for="check_holiday" class="labelcalendar">
598 <span class="check_holiday_text">' . $langs->trans(
"Holidays") .
'</span>
604 if (count($showextcals) > 0) {
605 foreach ($showextcals as $val) {
606 $htmlname = md5($val[
'name']);
608 $s .=
'<script type="text/javascript">'.
"\n";
609 $s .=
'jQuery(document).ready(function () {'.
"\n";
610 $s .=
' jQuery("#check_ext'.$htmlname.
'").click(function() {';
611 $s .=
' /* alert("'.$htmlname.
'"); */';
612 $s .=
' jQuery(".family_ext'.$htmlname.
'").toggle();';
615 $s .=
'</script>'.
"\n";
616 $s .=
'<div class="nowrap float"><input type="checkbox" id="check_ext'.$htmlname.
'" name="check_ext'.$htmlname.
'" checked> '.$val [
'name'].
' </div>';
640 $parameters = array();
641 $reshook = $hookmanager->executeHooks(
'addCalendarChoice', $parameters, $object, $action);
642 if (empty($reshook)) {
643 $s .= $hookmanager->resPrint;
644 } elseif ($reshook > 1) {
645 $s = $hookmanager->resPrint;
648 $s .=
"\n".
'<!-- End div to calendars selectors -->'.
"\n";
651 $newparam = preg_replace(
'/showbirthday=[0-1]/i',
'showbirthday='.($showbirthday ?
'1' :
'0'), $newparam);
652 if (!preg_match(
'/showbirthday=/i', $newparam)) {
653 $newparam .=
'&showbirthday=1';
658 $link .= $langs->trans(
"AgendaShowBirthdayEvents");
660 $link .= $langs->trans(
"AgendaHideBirthdayEvents");
667$eventarray = array();
675$sql .=
" a.id, a.label,";
678$sql .=
" a.percent,";
679$sql .=
" a.fk_user_author, a.fk_user_action,";
680$sql .=
" a.transparency, a.priority, a.fulldayevent, a.location,";
681$sql .=
" a.fk_soc, a.fk_contact, a.fk_project, a.fk_bookcal_calendar,";
682$sql .=
" a.fk_element, a.elementtype,";
683$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";
685$parameters = array();
686$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
687$sql .= $hookmanager->resPrint;
689$sql .=
" FROM ".MAIN_DB_PREFIX.
"c_actioncomm as ca, ".MAIN_DB_PREFIX.
"actioncomm as a";
691if ($resourceid > 0) {
692 $sql .=
", ".MAIN_DB_PREFIX.
"element_resources as r";
696if (($filtert !=
'-1' && $filtert !=
'-2') || $usergroup > 0) {
698 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"actioncomm_resources as ar";
699 $sql .=
" ON ar.fk_actioncomm = a.id AND ar.element_type = 'user'";
700 if ($filtert !=
'' && $filtert !=
'-1' && $filtert !=
'-2' && $filtert !=
'-3') {
701 $sql .=
" AND ar.fk_element IN (".$db->sanitize($filtert).
")";
702 } elseif ($filtert ==
'-3') {
703 $sql .=
" AND ar.fk_element IN (".$db->sanitize(implode(
',', $user->getAllChildIds(1))).
")";
705 if ($usergroup > 0) {
706 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"usergroup_user as ugu ON ugu.fk_user = ar.fk_element AND ugu.fk_usergroup = ".((int) $usergroup);
710$sql .=
" WHERE a.fk_action = ca.id";
711$sql .=
" AND a.entity IN (".getEntity(
'agenda').
")";
714if (!empty($actioncode)) {
716 if ((is_array($actioncode) && in_array(
'AC_NON_AUTO', $actioncode)) || $actioncode ==
'AC_NON_AUTO') {
717 $sql .=
" AND ca.type != 'systemauto'";
718 } elseif ((is_array($actioncode) && in_array(
'AC_ALL_AUTO', $actioncode)) || $actioncode ==
'AC_ALL_AUTO') {
719 $sql .=
" AND ca.type = 'systemauto'";
721 if ((is_array($actioncode) && in_array(
'AC_OTH', $actioncode)) || $actioncode ==
'AC_OTH') {
722 $sql .=
" AND ca.type != 'systemauto'";
724 if ((is_array($actioncode) && in_array(
'AC_OTH_AUTO', $actioncode)) || $actioncode ==
'AC_OTH_AUTO') {
725 $sql .=
" AND ca.type = 'systemauto'";
729 if ((is_array($actioncode) && in_array(
'AC_NON_AUTO', $actioncode)) || $actioncode ===
'AC_NON_AUTO') {
730 $sql .=
" AND ca.type != 'systemauto'";
731 } elseif ((is_array($actioncode) && in_array(
'AC_ALL_AUTO', $actioncode)) || $actioncode ===
'AC_ALL_AUTO') {
732 $sql .=
" AND ca.type = 'systemauto'";
733 } elseif ((is_array($actioncode) && !in_array(
'-1', $actioncode) && !in_array(
'-3', $actioncode)) || ($actioncode !==
'-1' && $actioncode !==
'-3')) {
734 if (is_array($actioncode)) {
735 foreach ($actioncode as $key => $val) {
736 if ($val ==
'-1' || $val ==
'-2') {
737 unset($actioncode[$key]);
740 if (!empty($actioncode)) {
741 $sql .=
" AND ca.code IN (".$db->sanitize(
"'".implode(
"','", $actioncode).
"'", 1).
")";
744 $sql .=
" AND ca.code IN (".$db->sanitize(
"'".implode(
"','", explode(
',', $actioncode)).
"'", 1).
")";
749if ($resourceid > 0) {
750 $sql .=
" AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".((int) $resourceid);
753 $sql .=
" AND a.fk_project = ".((int) $pid);
757if (
isModEnabled(
"societe") && !$user->hasRight(
'societe',
'client',
'voir')) {
758 $search_sale = $user->id;
761if ($search_sale && $search_sale !=
'-1') {
762 if ($search_sale == -2) {
763 $sql .=
" AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = a.fk_soc)";
764 } elseif ($search_sale > 0) {
765 $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).
"))";
770 $sql .=
" AND a.fk_soc = ".((int) $socid);
773if ($mode ==
'show_day') {
775 $sql .=
" (a.datep BETWEEN '".$db->idate(
dol_mktime(0, 0, 0, $month, $day, $year,
'tzuserrel')).
"'";
776 $sql .=
" AND '".$db->idate(
dol_mktime(23, 59, 59, $month, $day, $year,
'tzuserrel')).
"')";
778 $sql .=
" (a.datep2 BETWEEN '".$db->idate(
dol_mktime(0, 0, 0, $month, $day, $year,
'tzuserrel')).
"'";
779 $sql .=
" AND '".$db->idate(
dol_mktime(23, 59, 59, $month, $day, $year,
'tzuserrel')).
"')";
781 $sql .=
" (a.datep < '".$db->idate(
dol_mktime(0, 0, 0, $month, $day, $year,
'tzuserrel')).
"'";
782 $sql .=
" AND a.datep2 > '".$db->idate(
dol_mktime(23, 59, 59, $month, $day, $year,
'tzuserrel')).
"')";
787 $sql .=
" (a.datep BETWEEN '".$db->idate($firstdaytoshow - (60 * 60 * 24 * 2)).
"'";
788 $sql .=
" AND '".$db->idate($lastdaytoshow + (60 * 60 * 24 * 2)).
"')";
790 $sql .=
" (a.datep2 BETWEEN '".$db->idate($firstdaytoshow - (60 * 60 * 24 * 2)).
"'";
791 $sql .=
" AND '".$db->idate($lastdaytoshow + (60 * 60 * 24 * 2)).
"')";
793 $sql .=
" (a.datep < '".$db->idate($firstdaytoshow - (60 * 60 * 24 * 2)).
"'";
794 $sql .=
" AND a.datep2 > '".$db->idate($lastdaytoshow + (60 * 60 * 24 * 2)).
"')";
798 $sql .=
" AND ca.id = ".((int) $type);
802 $sql .=
" AND a.percent = 0";
804if ($status ===
'na') {
806 $sql .=
" AND a.percent = -1";
808if ($status ==
'50') {
810 $sql .=
" AND (a.percent > 0 AND a.percent < 100)";
812if ($status ==
'done' || $status ==
'100') {
813 $sql .=
" AND (a.percent = 100)";
815if ($status ==
'todo') {
816 $sql .=
" AND (a.percent >= 0 AND a.percent < 100)";
819if (($filtert > 0 || $filtert == -3) || $usergroup > 0) {
823 $sql .=
"ar.fk_element = ".((int) $filtert);
824 } elseif ($filtert == -3) {
825 $sql .=
"ar.fk_element IN (".$db->sanitize(implode(
',', $user->getAllChildIds(1))).
")";
827 if ($usergroup > 0) {
828 $sql .= ($filtert > 0 ?
" OR " :
"").
" ugu.fk_usergroup = ".((
int) $usergroup);
834if ($search_categ_cus != -1) {
835 if ($search_categ_cus == -2) {
836 $sql .=
" AND NOT EXISTS (SELECT ca.fk_actioncomm FROM ".MAIN_DB_PREFIX.
"categorie_actioncomm as ca WHERE ca.fk_actioncomm = a.id)";
837 } elseif ($search_categ_cus > 0) {
838 $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).
"))";
842$sql .= $db->order(
"fk_user_action, datep");
845dol_syslog(
"comm/action/peruser.php", LOG_DEBUG);
846$resql = $db->query($sql);
848 $num = $db->num_rows($resql);
850 $MAXONSAMEPAGE = 10000;
852 while ($i < $num && $i < $MAXONSAMEPAGE) {
853 $obj = $db->fetch_object($resql);
857 if (
getDolGlobalString(
'AGENDA_ALWAYS_HIDE_AUTO') && $obj->type_code ==
'AC_OTH_AUTO') {
862 $datep = $db->jdate($obj->datep);
863 $datep2 = $db->jdate($obj->datep2);
869 $event->id = $obj->id;
870 $event->ref = (string) $event->id;
872 $event->fulldayevent = $obj->fulldayevent;
875 if ($event->fulldayevent) {
877 $event->datep = $db->jdate($obj->datep, $tzforfullday ?
'tzuser' :
'tzserver');
878 $event->datef = $db->jdate($obj->datep2, $tzforfullday ?
'tzuser' :
'tzserver');
881 $event->datep = $db->jdate($obj->datep,
'tzserver');
882 $event->datef = $db->jdate($obj->datep2,
'tzserver');
888 $event->type_code = $obj->type_code;
889 $event->type_label = $obj->type_label;
890 $event->type_color = $obj->type_color;
891 $event->type = $obj->type_type;
892 $event->type_picto = $obj->type_picto;
894 $event->label = $obj->label;
895 $event->percentage = $obj->percent;
896 $event->authorid = $obj->fk_user_author;
897 $event->userownerid = $obj->fk_user_action;
898 $event->fetch_userassigned();
900 $event->priority = $obj->priority;
901 $event->location = $obj->location;
902 $event->transparency = $obj->transparency;
903 $event->fk_element = $obj->fk_element;
904 $event->elementid = $obj->fk_element;
905 $event->elementtype = $obj->elementtype;
907 $event->fk_project = $obj->fk_project;
909 $event->socid = $obj->fk_soc;
910 $event->contact_id = $obj->fk_contact;
911 $event->fk_bookcal_calendar = $obj->fk_bookcal_calendar;
912 if (!empty($event->fk_bookcal_calendar)) {
913 $event->type =
"bookcal_calendar";
918 $event->date_start_in_calendar = $event->datep;
919 if ($event->datef !=
'' && $event->datef >= $event->datep) {
920 $event->date_end_in_calendar = $event->datef;
922 $event->date_end_in_calendar = $event->datep;
928 if ($event->date_end_in_calendar < $firstdaytoshow || $event->date_start_in_calendar >= $lastdaytoshow) {
932 if ($event->date_start_in_calendar < $firstdaytoshow) {
933 $event->date_start_in_calendar = $firstdaytoshow;
935 if ($event->date_end_in_calendar >= $lastdaytoshow) {
936 $event->date_end_in_calendar = ($lastdaytoshow - 1);
940 $daycursor = $event->date_start_in_calendar;
945 $daycursorend = $event->date_end_in_calendar;
946 $anneeend = (int)
dol_print_date($daycursorend,
'%Y',
'tzuserrel');
947 $moisend = (int)
dol_print_date($daycursorend,
'%m',
'tzuserrel');
948 $jourend = (int)
dol_print_date($daycursorend,
'%d',
'tzuserrel');
953 $daykey =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
954 $daykeyend =
dol_mktime(0, 0, 0, $moisend, $jourend, $anneeend,
'gmt');
968 $eventarray[$daykey][] = $event;
971 $daykey += 60 * 60 * 24;
973 if ($daykey > $daykeyend) {
982 $parameters[
'obj'] = $obj;
983 $reshook = $hookmanager->executeHooks(
'hookEventElements', $parameters, $event, $action);
984 $event = $hookmanager->resPrint;
1002 $sql =
'SELECT sp.rowid, sp.lastname, sp.firstname, sp.birthday';
1003 $sql .=
' FROM '.MAIN_DB_PREFIX.
'socpeople as sp';
1004 $sql .=
' WHERE (priv=0 OR (priv=1 AND fk_user_creat='.((int) $user->id).
'))';
1005 $sql .=
" AND sp.entity IN (".getEntity(
'contact').
")";
1006 if ($mode ==
'show_day') {
1007 $sql .=
' AND MONTH(birthday) = '.((int) $month);
1008 $sql .=
' AND DAY(birthday) = '.((int) $day);
1010 $sql .=
' AND MONTH(birthday) = '.((int) $month);
1012 $sql .=
' ORDER BY birthday';
1014 dol_syslog(
"comm/action/index.php", LOG_DEBUG);
1015 $resql = $db->query($sql);
1017 $num = $db->num_rows($resql);
1020 $obj = $db->fetch_object($resql);
1024 $event->id = $obj->rowid;
1025 $event->ref = (string) $event->id;
1030 $event->datep =
dol_mktime(0, 0, 0, $datearray[
'mon'], $datearray[
'mday'], $year,
true);
1031 $event->datef = $event->datep;
1033 $event->type_code =
'BIRTHDAY';
1034 $event->type_label =
'';
1035 $event->type_color =
'';
1036 $event->type =
'birthdate';
1037 $event->type_picto =
'birthdate';
1039 $event->label = $langs->trans(
"Birthday").
' '.
dolGetFirstLastname($obj->firstname, $obj->lastname);
1040 $event->percentage = 100;
1041 $event->fulldayevent = 1;
1043 $event->contact_id = $obj->rowid;
1045 $event->date_start_in_calendar = $db->jdate($event->datep);
1046 $event->date_end_in_calendar = $db->jdate($event->datef);
1049 $daycursor = $event->datep;
1054 $daykey =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
1056 $eventarray[$daykey][] = $event;
1074if ($user->hasRight(
"holiday",
"read")) {
1075 $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";
1076 $sql .=
" FROM ".MAIN_DB_PREFIX.
"holiday as x, ".MAIN_DB_PREFIX.
"user as u";
1077 $sql .=
" WHERE u.rowid = x.fk_user";
1078 $sql .=
" AND u.statut = '1'";
1079 $sql .=
" AND (x.statut = '2' OR x.statut = '3')";
1081 $sql .=
" AND x.date_debut < '".$db->idate(
dol_get_last_day($year, $month)).
"'";
1082 $sql .=
" AND x.date_fin >= '".$db->idate(
dol_get_first_day($year, $month)).
"'";
1083 if (!$user->hasRight(
'holiday',
'readall')) {
1084 $sql .=
" AND x.fk_user IN(".$db->sanitize(implode(
", ", $user->getAllChildIds(1))).
") ";
1087 $resql = $db->query($sql);
1089 $num = $db->num_rows($resql);
1093 $obj = $db->fetch_object($resql);
1098 $event->id = $obj->rowid;
1099 $event->ref = (string) $event->id;
1101 $event->type_code =
'HOLIDAY';
1102 $event->type_label =
'';
1103 $event->type_color =
'';
1104 $event->type =
'holiday';
1105 $event->type_picto =
'holiday';
1109 $event->datep = $db->jdate($obj->date_start,
'gmt') + (empty($obj->halfday) || $obj->halfday == 1 ? 0 : 12) * 60 * 60;
1110 $event->datef = $db->jdate($obj->date_end,
'gmt') + (empty($obj->halfday) || $obj->halfday == -1 ? 24 : 12) * 60 * 60 - 1;
1111 $event->date_start_in_calendar = $event->datep;
1112 $event->date_end_in_calendar = $event->datef;
1114 $event->transparency = 1;
1116 $event->userownerid = $obj->uid;
1117 $event->userassigned = array($obj->uid => array(
'id' => $obj->uid,
'transparency' => 1));
1119 if ($obj->status == 3) {
1121 $event->percentage = -1;
1122 } elseif ($obj->status == 2) {
1124 $event->percentage = 0;
1128 $daycursor = $event->date_start_in_calendar;
1133 $daycursorend = $event->date_end_in_calendar;
1139 $daykey =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
1140 $daykeygmt =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
1145 $firstdayofholiday = ($ifornbofdays == 1);
1146 $lastdayofholiday = ($daykeygmt ==
dol_get_first_hour($event->date_end_in_calendar,
'gmt'));
1150 if ((in_array($obj->halfday, array(1, 2)) == 1 && $lastdayofholiday) || (in_array($obj->halfday, array(-1, 2)) && $firstdayofholiday)) {
1153 if (in_array($obj->halfday, array(1, 2)) && $lastdayofholiday) {
1154 $newevent->label .=
' ('.$langs->trans(
"Morning").
')';
1155 } elseif (in_array($obj->halfday, array(-1, 2)) && $firstdayofholiday) {
1156 $newevent->label .=
' ('.$langs->trans(
"Afternoon").
')';
1158 $eventarray[$daykey][] = $newevent;
1160 $eventarray[$daykey][] = $event;
1163 $daykey += 60 * 60 * 24;
1164 $daykeygmt += 60 * 60 * 24;
1165 }
while ($daykey <= $event->date_end_in_calendar);
1174if (count($listofextcals)) {
1175 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/ical.class.php';
1177 foreach ($listofextcals as $key => $extcal) {
1178 $url = $extcal[
'src'];
1179 $namecal = $extcal[
'name'];
1180 $offsettz = $extcal[
'offsettz'];
1181 $colorcal = $extcal[
'color'];
1182 $buggedfile = $extcal[
'buggedfile'];
1188 $ical->parse($url, $pathforcachefile, $DELAYFORCACHE);
1191 $listofextcals[$key][
'error'] = $ical->error;
1192 $s .=
'<br><div class="warning">'.dol_escape_htmltag($listofextcals[$key][
'name']).
': '.$url.
'<br>Error message: '.
dol_escape_htmltag($ical->error).
'</div>';
1197 $icalevents = array();
1198 if (is_array($ical->get_event_list())) {
1199 $icalevents = array_merge($icalevents, $ical->get_event_list());
1201 if (is_array($ical->get_freebusy_list())) {
1202 $icalevents = array_merge($icalevents, $ical->get_freebusy_list());
1205 if (count($icalevents) > 0) {
1207 $moreicalevents = array();
1208 foreach ($icalevents as $icalevent) {
1209 if (isset($icalevent[
'RRULE']) && is_array($icalevent[
'RRULE'])) {
1212 if ($icalevent[
'DTSTART;VALUE=DATE']) {
1215 } elseif (is_array($icalevent[
'DTSTART']) && !empty($icalevent[
'DTSTART'][
'unixtime'])) {
1216 $datecurstart = $icalevent[
'DTSTART'][
'unixtime'];
1217 $datecurend = $icalevent[
'DTEND'][
'unixtime'];
1218 if (!empty($ical->cal[
'DAYLIGHT'][
'DTSTART']) ) {
1220 $tmpcurstart = $datecurstart;
1221 $tmpcurend = $datecurend;
1222 $tmpdaylightstart =
dol_mktime(0, 0, 0, 1, 1, 1970, 1) + (int) $ical->cal[
'DAYLIGHT'][
'DTSTART'];
1223 $tmpdaylightend =
dol_mktime(0, 0, 0, 1, 1, 1970, 1) + (int) $ical->cal[
'STANDARD'][
'DTSTART'];
1226 if ($tmpcurstart >= $tmpdaylightstart && $tmpcurstart < $tmpdaylightend) {
1227 $datecurstart -= ((int) $ical->cal[
'DAYLIGHT'][
'TZOFFSETTO']) * 36;
1229 $datecurstart -= ((int) $ical->cal[
'STANDARD'][
'TZOFFSETTO']) * 36;
1231 if ($tmpcurend >= $tmpdaylightstart && $tmpcurstart < $tmpdaylightend) {
1232 $datecurend -= ((int) $ical->cal[
'DAYLIGHT'][
'TZOFFSETTO']) * 36;
1234 $datecurend -= ((int) $ical->cal[
'STANDARD'][
'TZOFFSETTO']) * 36;
1241 dol_syslog(
"Found a not recognized repeatable record with unknown date start", LOG_ERR);
1246 $interval = (empty($icalevent[
'RRULE'][
'INTERVAL']) ? 1 : $icalevent[
'RRULE'][
'INTERVAL']);
1247 $until = empty($icalevent[
'RRULE'][
'UNTIL']) ? 0 :
dol_stringtotime($icalevent[
'RRULE'][
'UNTIL'], 1);
1248 $maxrepeat = empty($icalevent[
'RRULE'][
'COUNT']) ? 0 : $icalevent[
'RRULE'][
'COUNT'];
1249 if ($until && ($until + ($datecurend - $datecurstart)) < $firstdaytoshow) {
1252 if ($datecurstart >= $lastdaytoshow) {
1257 while (($datecurstart < $lastdaytoshow) && (empty($maxrepeat) || ($numofevent < $maxrepeat))) {
1258 if ($datecurend >= $firstdaytoshow) {
1259 $newevent = $icalevent;
1260 unset($newevent[
'RRULE']);
1261 if ($icalevent[
'DTSTART;VALUE=DATE']) {
1262 $newevent[
'DTSTART;VALUE=DATE'] =
dol_print_date($datecurstart,
'%Y%m%d');
1263 $newevent[
'DTEND;VALUE=DATE'] =
dol_print_date($datecurend + 1,
'%Y%m%d');
1265 $newevent[
'DTSTART'] = $datecurstart;
1266 $newevent[
'DTEND'] = $datecurend;
1268 $moreicalevents[] = $newevent;
1272 $savdatecurstart = $datecurstart;
1273 if ($icalevent[
'RRULE'][
'FREQ'] ==
'DAILY') {
1277 if ($icalevent[
'RRULE'][
'FREQ'] ==
'WEEKLY') {
1280 } elseif ($icalevent[
'RRULE'][
'FREQ'] ==
'MONTHLY') {
1283 } elseif ($icalevent[
'RRULE'][
'FREQ'] ==
'YEARLY') {
1288 if ($savdatecurstart >= $datecurstart) {
1289 dol_syslog(
"Found a rule freq ".$icalevent[
'RRULE'][
'FREQ'].
" not managed by dolibarr code. Assume 1 week frequency.", LOG_ERR);
1290 $datecurstart += 3600 * 24 * 7;
1291 $datecurend += 3600 * 24 * 7;
1296 $icalevents = array_merge($icalevents, $moreicalevents);
1299 foreach ($icalevents as $icalevent) {
1304 if (!empty($icalevent[
'RRULE'])) {
1313 if (isset($icalevent[
'DTSTART;VALUE=DATE'])) {
1316 if (empty($icalevent[
'DTEND;VALUE=DATE'])) {
1317 $dateend = $datestart + 86400 - 1;
1323 $event->fulldayevent = 1;
1325 } elseif (!is_array($icalevent[
'DTSTART'])) {
1326 $datestart = $icalevent[
'DTSTART'];
1327 $dateend = empty($icalevent[
'DTEND']) ? $datestart : $icalevent[
'DTEND'];
1329 $datestart += +($offsettz * 3600);
1330 $dateend += +($offsettz * 3600);
1335 } elseif (isset($icalevent[
'DTSTART'][
'unixtime'])) {
1336 $datestart = $icalevent[
'DTSTART'][
'unixtime'];
1337 $dateend = $icalevent[
'DTEND'][
'unixtime'];
1339 $datestart += +($offsettz * 3600);
1340 $dateend += +($offsettz * 3600);
1343 if ($buggedfile ===
'uselocalandtznodaylight') {
1347 if ($buggedfile ===
'uselocalandtzdaylight') {
1348 $localtzs =
new DateTimeZone(preg_replace(
'/"/',
'', $icalevent[
'DTSTART'][
'TZID']));
1349 $localtze =
new DateTimeZone(preg_replace(
'/"/',
'', $icalevent[
'DTEND'][
'TZID']));
1350 $localdts =
new DateTime(
dol_print_date($datestart,
'dayrfc',
'gmt'), $localtzs);
1351 $localdte =
new DateTime(
dol_print_date($dateend,
'dayrfc',
'gmt'), $localtze);
1352 $tmps = -1 * $localtzs->getOffset($localdts);
1353 $tmpe = -1 * $localtze->getOffset($localdte);
1354 $datestart += $tmps;
1361 if ($addevent && $datestart !==
null && $dateend !==
null) {
1362 $event->id = $icalevent[
'UID'];
1363 $event->ref = (string) $event->id;
1364 $userstatic =
new User($db);
1365 $userId = $userstatic->findUserIdByEmail($namecal);
1366 if (!empty($userId) && $userId > 0) {
1367 $event->userassigned[$userId] = [
1369 'transparency' => 1,
1371 $event->percentage = -1;
1374 $event->type_code =
"ICALEVENT";
1375 $event->type_label = $namecal;
1376 $event->type_color = $colorcal;
1377 $event->type =
'icalevent';
1378 $event->type_picto =
'rss';
1380 $event->icalname = $namecal;
1381 $event->icalcolor = $colorcal;
1383 $event->datep = $datestart + $usertime;
1384 $event->datef = $dateend + $usertime;
1386 if (isset($icalevent[
'SUMMARY']) && $icalevent[
'SUMMARY']) {
1388 } elseif (isset($icalevent[
'DESCRIPTION']) && $icalevent[
'DESCRIPTION']) {
1391 $event->label = $langs->trans(
"ExtSiteNoLabel");
1398 if (!empty($icalevent[
'PRIORITY'])) {
1399 $event->priority = $icalevent[
'PRIORITY'];
1403 if (!empty($icalevent[
'TRANSP'])) {
1404 if ($icalevent[
'TRANSP'] ==
"TRANSPARENT") {
1405 $event->transparency = 0;
1407 if ($icalevent[
'TRANSP'] ==
"OPAQUE") {
1408 $event->transparency = 1;
1419 if (!empty($icalevent[
'LOCATION'])) {
1420 $event->location = $icalevent[
'LOCATION'];
1423 $event->date_start_in_calendar = $event->datep;
1425 if ($event->datef !=
'' && $event->datef >= $event->datep) {
1426 $event->date_end_in_calendar = $event->datef;
1428 $event->date_end_in_calendar = $event->datep;
1432 if ($event->date_end_in_calendar < $firstdaytoshow || $event->date_start_in_calendar >= $lastdaytoshow) {
1438 if ($event->date_start_in_calendar < $firstdaytoshow) {
1439 $event->date_start_in_calendar = $firstdaytoshow;
1441 if ($event->date_end_in_calendar >= $lastdaytoshow) {
1442 $event->date_end_in_calendar = ($lastdaytoshow - 1);
1446 $daycursor = $event->date_start_in_calendar;
1455 $daykey =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
1456 $daykeygmt =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
1459 $eventarray[$daykey][] = $event;
1460 $daykey += 60 * 60 * 24;
1461 $daykeygmt += 60 * 60 * 24;
1462 if (($event->fulldayevent ? $daykeygmt : $daykey) > $event->date_end_in_calendar) {
1474$parameters = array();
1476$reshook = $hookmanager->executeHooks(
'getCalendarEvents', $parameters, $object, $action);
1477if (!empty($hookmanager->resArray[
'eventarray'])) {
1478 foreach ($hookmanager->resArray[
'eventarray'] as $keyDate => $events) {
1479 if (!isset($eventarray[$keyDate])) {
1480 $eventarray[$keyDate] = array();
1482 $eventarray[$keyDate] = array_merge($eventarray[$keyDate], $events);
1494$cachethirdparties = array();
1495$cachecontacts = array();
1499 array(137, 86, 161),
1500 array(60, 147, 183),
1501 array(250, 190, 80),
1503 array(190, 190, 100),
1504 array(91, 115, 247),
1505 array(140, 140, 220),
1506 array(190, 120, 120),
1507 array(115, 125, 150),
1508 array(100, 170, 20),
1509 array(150, 135, 125),
1510 array(85, 135, 150),
1511 array(150, 135, 80),
1515$color_file = DOL_DOCUMENT_ROOT.
"/theme/".$conf->theme.
"/theme_vars.inc.php";
1516if (is_readable($color_file)) {
1517 include $color_file;
1521$massactionbutton =
'';
1525print_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);
1533print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1534print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday,
'', (
string) $filtert,
'', $pid, $socid, $action, -1, $actioncode, $usergroup,
'', $resourceid, $search_categ_cus);
1539$newparam = preg_replace(
'/showbirthday=/i',
'showbirthday_=', $newparam);
1540$newparam = preg_replace(
'/mode=show_month&?/i',
'', $newparam);
1541$newparam = preg_replace(
'/mode=show_week&?/i',
'', $newparam);
1542$newparam = preg_replace(
'/day=[0-9]+&?/i',
'', $newparam);
1543$newparam = preg_replace(
'/month=[0-9]+&?/i',
'', $newparam);
1544$newparam = preg_replace(
'/year=[0-9]+&?/i',
'', $newparam);
1545$newparam = preg_replace(
'/viewweek=[0-9]+&?/i',
'', $newparam);
1546$newparam = preg_replace(
'/showbirthday_=/i',
'showbirthday=', $newparam);
1547$newparam .=
'&viewweek=1';
1549echo
'<input type="hidden" name="actionmove" value="mupdate">';
1550echo
'<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($_SERVER[
'PHP_SELF']).
'?'.
dol_escape_htmltag($_SERVER[
'QUERY_STRING']).
'">';
1551echo
'<input type="hidden" name="newdate" id="newdate">';
1558$currentdaytoshow = $firstdaytoshow;
1559echo
'<div class="div-table-responsive">';
1562$colorsbytype = array();
1564while ($currentdaytoshow < $lastdaytoshow) {
1565 echo
'<table class="centpercent noborder nocellnopadd cal_month cal_peruser listwithfilterbefore">';
1567 echo
'<tr class="liste_titre">';
1568 echo
'<td class="nopaddingtopimp nopaddingbottomimp nowraponsmartphone">';
1572 print
'<span class="hideonsmartphone" title="'.$langs->trans(
"VisibleDaysRange").
'">';
1573 print
img_picto(
'',
'clock',
'class="fawidth30 inline-block marginleftonly"');
1574 print $langs->trans(
"DaysOfWeek").
'</span>';
1576 print
'<div class="ui-grid-a inline-block"><div class="ui-block-a nowraponall">';
1577 print
'<input type="number" class="shortbis" name="begin_d" value="'.$begin_d.
'" min="1" max="7">';
1578 if (empty($conf->dol_use_jmobile)) {
1581 print
'</div><div class="ui-block-b">';
1583 print
'<input type="number" class="shortbis" name="end_d" value="'.$end_d.
'" min="1" max="7">';
1584 print
'</div></div>';
1590 if (($i + 1) < $begin_d || ($i + 1) > $end_d) {
1594 echo
'<td align="center" colspan="'.($end_h - $begin_h).
'">';
1595 echo
'<span class="bold spandayofweek">'.$langs->trans(
"Day".(($i +
getDolGlobalInt(
'MAIN_START_WEEK', 1)) % 7)).
'</span>';
1600 $valtoshow = $currentdaytoshow;
1603 echo
'<span class="badgeneutral">';
1605 print
dol_print_date($valtoshow,
'dayreduceformat',
'tzuserrel');
1614 echo
'<tr class="liste_titre">';
1618 print
'<span class="hideonsmartphone" title="'.$langs->trans(
"VisibleTimeRange").
'">';
1619 print
img_picto(
'',
'clock',
'class="fawidth30 inline-block marginleftonly"');
1620 print $langs->trans(
"Hours").
'</span>';
1622 print
'<div class="ui-grid-a inline-block"><div class="ui-block-a nowraponall">';
1623 print
'<input type="number" class="shortbis" name="begin_h" value="'.$begin_h.
'" min="0" max="23">';
1624 if (empty($conf->dol_use_jmobile)) {
1627 print
'</div><div class="ui-block-b">';
1629 print
'<input type="number" class="shortbis" name="end_h" value="'.$end_h.
'" min="1" max="24">';
1630 if (empty($conf->dol_use_jmobile)) {
1631 print
' '.$langs->trans(
"HourShort");
1633 print
'</div></div>';
1638 if (($i + 1) < $begin_d || ($i + 1) > $end_d) {
1642 for ($h = $begin_h; $h < $end_h; $h++) {
1643 echo
'<td class="center">';
1644 print
'<small style="font-family: courier">'.sprintf(
"%02d", $h).
'</small>';
1654 $usernames = array();
1655 $usernamesid = array();
1658 foreach ($eventarray as $daykey => $notused) {
1660 foreach ($eventarray[$daykey] as $index => $event) {
1661 $event->fetch_userassigned();
1662 $listofuserid = $event->userassigned;
1663 foreach ($listofuserid as $userid => $tmp) {
1664 if (!in_array($userid, $usernamesid)) {
1665 $usernamesid[$userid] = $userid;
1672 $sql =
"SELECT u.rowid, u.lastname as lastname, u.firstname, u.statut, u.login, u.admin, u.entity";
1673 $sql .=
" FROM ".$db->prefix().
"user as u";
1675 $sql .=
" WHERE u.rowid IN (";
1676 $sql .=
" SELECT ug.fk_user FROM ".$db->prefix().
"usergroup_user as ug";
1677 $sql .=
" WHERE ug.entity IN (".getEntity(
'usergroup').
")";
1678 if ($usergroup > 0) {
1679 $sql .=
" AND ug.fk_usergroup = ".((int) $usergroup);
1683 if ($usergroup > 0) {
1684 $sql .=
" LEFT JOIN ".$db->prefix().
"usergroup_user as ug ON u.rowid = ug.fk_user";
1686 $sql .=
" WHERE u.entity IN (".getEntity(
'user').
")";
1687 if ($usergroup > 0) {
1688 $sql .=
" AND ug.fk_usergroup = ".((int) $usergroup);
1691 $sql .=
" AND u.statut = 1";
1693 $sql .=
" AND u.rowid = ".((int) $filtert);
1695 if ($usergroup > 0) {
1696 $sql .=
" AND ug.fk_usergroup = ".((int) $usergroup);
1698 if ($user->socid > 0) {
1700 $sql .=
" AND u.fk_soc = ".((int) $user->socid);
1703 if (!$canedit || $filtert ==
'-3') {
1704 if (!$user->hasRight(
'user',
'user',
'lire') || $filtert ==
'-3') {
1705 $usersInHierarchy = $user->getAllChildIds(1);
1706 $sql .=
" AND u.rowid IN (".$db->sanitize(implode(
',', $usersInHierarchy)).
")";
1711 $resql = $db->query($sql);
1713 $num = $db->num_rows($resql);
1717 $obj = $db->fetch_object($resql);
1718 $usernamesid[$obj->rowid] = $obj->rowid;
1727 foreach ($usernamesid as
$id) {
1728 $tmpuser =
new User($db);
1729 $result = $tmpuser->fetch(
$id);
1730 $usernames[] = $tmpuser;
1734 $labelbytype = array();
1735 $sql =
"SELECT code, color, libelle as label FROM ".MAIN_DB_PREFIX.
"c_actioncomm ORDER BY position";
1736 $resql = $db->query($sql);
1737 while ($obj = $db->fetch_object($resql)) {
1738 $colorsbytype[$obj->code] = $obj->color;
1739 $labelbytype[$obj->code] = $obj->label;
1747 foreach ($usernames as $username) {
1753 echo
'<td class="tdoverflowmax100 cal_current_month cal_peruserviewname'.($var ?
' cal_impair' :
'').
' nopaddingtopimp nopaddingbottomimp noheightimp">';
1754 print
'<span class="paddingrightimp">';
1755 print $username->getNomUrl(-1,
'', 0, 0, 20, 1,
'',
'paddingleft');
1762 for ($iter_day = 0; $iter_day < 8; $iter_day++) {
1763 if (($i + 1) < $begin_d || ($i + 1) > $end_d) {
1776 $style =
'cal_current_month';
1777 if ($iter_day == 6) {
1778 $style .=
' cal_other_month';
1781 if ($todayarray[
'mday'] == $tmpday && $todayarray[
'mon'] == $tmpmonth && $todayarray[
'year'] == $tmpyear) {
1785 $style =
'cal_today_peruser';
1788 show_day_events2($username, $tmpday, $tmpmonth, $tmpyear, 0, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, $showheader, $colorsbytype, $var);
1793 $showheader =
false;
1805 $langs->load(
"commercial");
1806 print
'<br>'.$langs->trans(
"Legend").
': <br>';
1807 foreach ($colorsbytype as $code => $color) {
1809 print
'<div style="float: left; padding: 2px; margin-right: 6px;"><div style="background: #'.$color.
'; width:16px; float: left; margin-right: 4px;"> </div>';
1810 print $langs->trans(
"Action".$code) !=
"Action".$code ? $langs->trans(
"Action".$code) : $labelbytype[$code];
1816 print
'<div style="float: left; padding: 2px; margin-right: 6px;"><div class="peruser_busy" style="width:16px; float: left; margin-right: 4px;"> </div>';
1817 print $langs->trans(
"Other");
1826print
"\n".
'</form>';
1831print
'<script type="text/javascript">
1832jQuery(document).ready(function() {
1833 jQuery(".onclickopenref").click(function() {
1834 var ref=$(this).attr(\'ref\');
1835 var res = ref.split("_");
1837 var userid = res[1];
1845 console.log("We click on a class onclickopenref in page peruser with ref="+ref+" type="+type);
1847 if (ids == \'none\') /* No event */
1849 /* alert(\'no event\'); */
1850 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 :
'')).
'"
1851 window.location.href = url;
1853 else if (ids.indexOf(",") > -1) /* There is several events */
1855 /* alert(\'several events\'); */
1856 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;
1857 window.location.href = url;
1858 } else { /* One event */
1859 /* alert(\'one event\'); */
1860 if (type == \'holiday\') {
1861 url = "'.DOL_URL_ROOT.
'/holiday/card.php?id="+ids
1863 url = "'.DOL_URL_ROOT.
'/comm/action/card.php?action=view&id="+ids
1865 window.location.href = url;
1898function 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)
1901 global $user, $conf, $langs, $hookmanager, $action;
1902 global $filter, $filtert, $status, $actioncode;
1904 global $cachethirdparties, $cachecontacts,
$cacheusers, $cacheprojects, $colorindexused;
1905 global $begin_h, $end_h;
1919 @phan-var-force array<int,array<int,array<string,string|int|bool>>> $cases1
1920 @phan-var-force array<int,array<int,array<string,string|int|bool>>> $cases2
1921 @phan-var-force array<int,array<int,array<string,string|int|bool>>> $cases3
1922 @phan-var-force array<int,array<int,array<string,string|int|bool>>> $cases4
1929 $numicals = array();
1932 $colorindexused[$user->id] = 0;
1933 $nextindextouse = count($colorindexused);
1940 foreach ($eventarray as $daykey => $notused) {
1947 if ($day == $jour && (
int) $month == $mois && $year == $annee) {
1951 foreach ($eventarray[$daykey] as $index => $event) {
1955 $keysofuserassigned = array_keys($event->userassigned);
1957 if (!in_array($username->id, $keysofuserassigned)) {
1962 $parameters = array();
1963 $reshook = $hookmanager->executeHooks(
'formatEvent', $parameters, $event, $action);
1973 if ($event->type_code ==
'HOLIDAY') {
1974 $cssclass =
'family_holiday';
1977 if (in_array($user->id, $keysofuserassigned)) {
1978 $cssclass =
'family_mytasks';
1980 if (empty($cacheusers[$event->userownerid])) {
1981 $newuser =
new User($db);
1982 $newuser->fetch($event->userownerid);
1988 if (!empty($cacheusers[$event->userownerid]->color)) {
1993 $color = $event->type_color;
1995 } elseif ($event->type_code ==
'ICALEVENT') {
1997 if (!empty($event->icalname)) {
2004 $color = $event->icalcolor;
2005 $cssclass = (!empty($event->icalname) ?
'family_ext'.md5($event->icalname) :
'family_other unsortable');
2006 } elseif ($event->type_code ==
'BIRTHDAY') {
2009 $cssclass =
'family_birthday unsortable';
2010 $color = sprintf(
"%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
2013 $color = ($event->icalcolor ? $event->icalcolor : -1);
2014 $cssclass = (!empty($event->icalname) ?
'family_ext'.md5($event->icalname) :
'family_other');
2016 if (empty($cacheusers[$event->userownerid])) {
2017 $newuser =
new User($db);
2018 $newuser->fetch($event->userownerid);
2024 if (!empty($cacheusers[$event->userownerid]->color)) {
2029 $color = $event->type_color;
2035 $idusertouse = ($event->userownerid ? $event->userownerid : 0);
2036 if (isset($colorindexused[$idusertouse])) {
2037 $colorindex = $colorindexused[$idusertouse];
2039 $colorindex = $nextindextouse;
2040 $colorindexused[$idusertouse] = $colorindex;
2041 if (!empty($theme_datacolor[$nextindextouse + 1])) {
2046 $color = sprintf(
"%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
2050 for ($h = $begin_h; $h < $end_h; $h++) {
2053 if (empty($event->fulldayevent)) {
2054 $a =
dol_mktime((
int) $h, 0, 0, $month, $day, $year,
'tzuserrel', 0);
2055 $b =
dol_mktime((
int) $h, 15, 0, $month, $day, $year,
'tzuserrel', 0);
2056 $b1 =
dol_mktime((
int) $h, 30, 0, $month, $day, $year,
'tzuserrel', 0);
2057 $b2 =
dol_mktime((
int) $h, 45, 0, $month, $day, $year,
'tzuserrel', 0);
2058 $c =
dol_mktime((
int) $h + 1, 0, 0, $month, $day, $year,
'tzuserrel', 0);
2060 $dateendtouse = $event->date_end_in_calendar;
2061 if ($dateendtouse == $event->date_start_in_calendar) {
2066 if ($event->date_start_in_calendar < $b && $dateendtouse > $a) {
2067 $busy = $event->transparency;
2068 $cases1[$h][$event->id][
'busy'] = $busy;
2069 $cases1[$h][$event->id][
'string'] =
dol_print_date($event->date_start_in_calendar,
'dayhour',
'tzuserrel');
2070 if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) {
2071 $tmpa =
dol_getdate($event->date_start_in_calendar,
true);
2072 $tmpb =
dol_getdate($event->date_end_in_calendar,
true);
2073 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) {
2074 $cases1[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'hour',
'tzuserrel');
2076 $cases1[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'dayhour',
'tzuserrel');
2079 if ($event->label) {
2080 $cases1[$h][$event->id][
'string'] .=
' - '.$event->label;
2082 $cases1[$h][$event->id][
'typecode'] = $event->type_code;
2083 if ($event->type_code ==
'HOLIDAY') {
2084 $cases1[$h][$event->id][
'css'] =
'peruser_holiday ';
2086 $cases1[$h][$event->id][
'css'] .=
'peruser_holiday_imp ';
2089 $cases1[$h][$event->id][
'color'] = $color;
2091 if ($event->fk_project > 0) {
2092 if (empty($cacheprojects[$event->fk_project])) {
2094 $tmpproj->fetch($event->fk_project);
2095 $cacheprojects[$event->fk_project] = $tmpproj;
2097 $cases1[$h][$event->id][
'string'] .=
', '.$langs->trans(
"Project").
': '.$cacheprojects[$event->fk_project]->ref.
' - '.$cacheprojects[$event->fk_project]->title;
2099 if ($event->socid > 0) {
2100 if (empty($cachethirdparties[$event->socid])) {
2101 $tmpthirdparty =
new Societe($db);
2102 $tmpthirdparty->fetch($event->socid);
2103 $cachethirdparties[$event->socid] = $tmpthirdparty;
2105 $cases1[$h][$event->id][
'string'] .=
', '.$cachethirdparties[$event->socid]->name;
2107 if ($event->contact_id > 0) {
2108 if (empty($cachecontacts[$event->contact_id])) {
2109 $tmpcontact =
new Contact($db);
2110 $tmpcontact->fetch($event->contact_id);
2111 $cachecontacts[$event->contact_id] = $tmpcontact;
2113 $cases1[$h][$event->id][
'string'] .=
', '.$cachecontacts[$event->contact_id]->getFullName($langs);
2117 if ($event->date_start_in_calendar < $b1 && $dateendtouse > $b) {
2118 $busy = $event->transparency;
2119 $cases2[$h][$event->id][
'busy'] = $busy;
2120 $cases2[$h][$event->id][
'string'] =
dol_print_date($event->date_start_in_calendar,
'dayhour',
'tzuserrel');
2121 if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) {
2122 $tmpa =
dol_getdate($event->date_start_in_calendar,
true);
2123 $tmpb =
dol_getdate($event->date_end_in_calendar,
true);
2124 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) {
2125 $cases2[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'hour',
'tzuserrel');
2127 $cases2[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'dayhour',
'tzuserrel');
2130 if ($event->label) {
2131 $cases2[$h][$event->id][
'string'] .=
' - '.$event->label;
2133 $cases2[$h][$event->id][
'typecode'] = $event->type_code;
2134 if ($event->type_code ==
'HOLIDAY') {
2135 $cases2[$h][$event->id][
'css'] =
'peruser_holiday ';
2137 $cases2[$h][$event->id][
'css'] .=
'peruser_holiday_imp ';
2140 $cases2[$h][$event->id][
'color'] = $color;
2142 if ($event->fk_project > 0) {
2143 if (empty($cacheprojects[$event->fk_project])) {
2145 $tmpproj->fetch($event->fk_project);
2146 $cacheprojects[$event->fk_project] = $tmpproj;
2148 $cases2[$h][$event->id][
'string'] .=
', '.$langs->trans(
"Project").
': '.$cacheprojects[$event->fk_project]->ref.
' - '.$cacheprojects[$event->fk_project]->title;
2150 if ($event->socid > 0) {
2151 if (empty($cachethirdparties[$event->socid])) {
2152 $tmpthirdparty =
new Societe($db);
2153 $tmpthirdparty->fetch($event->socid);
2154 $cachethirdparties[$event->socid] = $tmpthirdparty;
2156 $cases2[$h][$event->id][
'string'] .=
', '.$cachethirdparties[$event->socid]->name;
2158 if ($event->contact_id > 0) {
2159 if (empty($cachecontacts[$event->contact_id])) {
2160 $tmpcontact =
new Contact($db);
2161 $tmpcontact->fetch($event->contact_id);
2162 $cachecontacts[$event->contact_id] = $tmpcontact;
2164 $cases2[$h][$event->id][
'string'] .=
', '.$cachecontacts[$event->contact_id]->getFullName($langs);
2168 if ($event->date_start_in_calendar < $b2 && $dateendtouse > $b1) {
2169 $busy = $event->transparency;
2170 $cases3[$h][$event->id][
'busy'] = $busy;
2171 $cases3[$h][$event->id][
'string'] =
dol_print_date($event->date_start_in_calendar,
'dayhour',
'tzuserrel');
2172 if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) {
2173 $tmpa =
dol_getdate($event->date_start_in_calendar,
true);
2174 $tmpb =
dol_getdate($event->date_end_in_calendar,
true);
2175 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) {
2176 $cases3[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'hour',
'tzuserrel');
2178 $cases3[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'dayhour',
'tzuserrel');
2181 if ($event->label) {
2182 $cases3[$h][$event->id][
'string'] .=
' - '.$event->label;
2184 $cases3[$h][$event->id][
'typecode'] = $event->type_code;
2185 if ($event->type_code ==
'HOLIDAY') {
2186 $cases3[$h][$event->id][
'css'] .=
'peruser_holiday ';
2188 $cases3[$h][$event->id][
'css'] .=
'peruser_holiday_imp ';
2191 $cases3[$h][$event->id][
'color'] = $color;
2193 if ($event->fk_project > 0) {
2194 if (empty($cacheprojects[$event->fk_project])) {
2196 $tmpproj->fetch($event->fk_project);
2197 $cacheprojects[$event->fk_project] = $tmpproj;
2199 $cases3[$h][$event->id][
'string'] .=
', '.$langs->trans(
"Project").
': '.$cacheprojects[$event->fk_project]->ref.
' - '.$cacheprojects[$event->fk_project]->title;
2201 if ($event->socid > 0) {
2202 if (empty($cachethirdparties[$event->socid])) {
2203 $tmpthirdparty =
new Societe($db);
2204 $tmpthirdparty->fetch($event->socid);
2205 $cachethirdparties[$event->socid] = $tmpthirdparty;
2207 $cases3[$h][$event->id][
'string'] .=
', '.$cachethirdparties[$event->socid]->name;
2209 if ($event->contact_id > 0) {
2210 if (empty($cachecontacts[$event->contact_id])) {
2211 $tmpcontact =
new Contact($db);
2212 $tmpcontact->fetch($event->contact_id);
2213 $cachecontacts[$event->contact_id] = $tmpcontact;
2215 $cases3[$h][$event->id][
'string'] .=
', '.$cachecontacts[$event->contact_id]->getFullName($langs);
2219 if ($event->date_start_in_calendar <
$c && $dateendtouse > $b2) {
2220 $busy = $event->transparency;
2221 $cases4[$h][$event->id][
'busy'] = $busy;
2222 $cases4[$h][$event->id][
'string'] =
dol_print_date($event->date_start_in_calendar,
'dayhour',
'tzuserrel');
2223 if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) {
2224 $tmpa =
dol_getdate($event->date_start_in_calendar,
true);
2225 $tmpb =
dol_getdate($event->date_end_in_calendar,
true);
2226 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) {
2227 $cases4[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'hour',
'tzuserrel');
2229 $cases4[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'dayhour',
'tzuserrel');
2232 if ($event->label) {
2233 $cases4[$h][$event->id][
'string'] .=
' - '.$event->label;
2235 $cases4[$h][$event->id][
'typecode'] = $event->type_code;
2236 if ($event->type_code ==
'HOLIDAY') {
2237 $cases4[$h][$event->id][
'css'] =
'peruser_holiday ';
2239 $cases4[$h][$event->id][
'css'] .=
'peruser_holiday_imp ';
2242 $cases4[$h][$event->id][
'color'] = $color;
2244 if ($event->fk_project > 0) {
2245 if (empty($cacheprojects[$event->fk_project])) {
2247 $tmpproj->fetch($event->fk_project);
2248 $cacheprojects[$event->fk_project] = $tmpproj;
2250 $cases4[$h][$event->id][
'string'] .=
', '.$langs->trans(
"Project").
': '.$cacheprojects[$event->fk_project]->ref.
' - '.$cacheprojects[$event->fk_project]->title;
2252 if ($event->socid > 0) {
2253 if (empty($cachethirdparties[$event->socid])) {
2254 $tmpthirdparty =
new Societe($db);
2255 $tmpthirdparty->fetch($event->socid);
2256 $cachethirdparties[$event->socid] = $tmpthirdparty;
2258 $cases4[$h][$event->id][
'string'] .=
', '.$cachethirdparties[$event->socid]->name;
2260 if ($event->contact_id > 0) {
2261 if (empty($cachecontacts[$event->contact_id])) {
2262 $tmpcontact =
new Contact($db);
2263 $tmpcontact->fetch($event->contact_id);
2264 $cachecontacts[$event->contact_id] = $tmpcontact;
2266 $cases4[$h][$event->id][
'string'] .=
', '.$cachecontacts[$event->contact_id]->getFullName($langs);
2271 $busy = $event->transparency;
2272 $cases1[$h][$event->id][
'busy'] = $busy;
2273 $cases2[$h][$event->id][
'busy'] = $busy;
2274 $cases3[$h][$event->id][
'busy'] = $busy;
2275 $cases4[$h][$event->id][
'busy'] = $busy;
2276 $cases1[$h][$event->id][
'string'] = $event->label;
2277 $cases2[$h][$event->id][
'string'] = $event->label;
2278 $cases3[$h][$event->id][
'string'] = $event->label;
2279 $cases4[$h][$event->id][
'string'] = $event->label;
2280 $cases1[$h][$event->id][
'typecode'] = $event->type_code;
2281 $cases2[$h][$event->id][
'typecode'] = $event->type_code;
2282 $cases3[$h][$event->id][
'typecode'] = $event->type_code;
2283 $cases4[$h][$event->id][
'typecode'] = $event->type_code;
2284 $cases1[$h][$event->id][
'color'] = $color;
2285 $cases2[$h][$event->id][
'color'] = $color;
2286 $cases3[$h][$event->id][
'color'] = $color;
2287 $cases4[$h][$event->id][
'color'] = $color;
2288 $cases1[$h][$event->id][
'css'] =
'';
2289 $cases2[$h][$event->id][
'css'] =
'';
2290 $cases3[$h][$event->id][
'css'] =
'';
2291 $cases4[$h][$event->id][
'css'] =
'';
2302 for ($h = $begin_h; $h < $end_h; $h++) {
2307 $style1 =
'onclickopenref ';
2308 $style2 =
'onclickopenref ';
2309 $style3 =
'onclickopenref ';
2310 $style4 =
'onclickopenref ';
2311 $string1 =
' ';
2312 $string2 =
' ';
2313 $string3 =
' ';
2314 $string4 =
' ';
2319 if (isset($cases1[$h])) {
2321 if (count($cases1[$h]) > 1) {
2322 $title1 .= count($cases1[$h]).
' '.(count($cases1[$h]) == 1 ? $langs->trans(
"Event") : $langs->trans(
"Events"));
2325 foreach ($cases1[$h] as
$id => $ev) {
2326 if (!empty($ev[
'busy']) && !
getDolGlobalString(
'AGENDA_NO_TRANSPARENT_ON_NOT_BUSY')) {
2327 $style1 .=
' peruser_busy';
2329 $style1 .=
'peruser_notbusy ';
2331 if (!empty($ev[
'css'])) {
2332 $style1 .= $ev[
'css'].
' ';
2336 if (isset($cases2[$h])) {
2338 if (count($cases2[$h]) > 1) {
2339 $title2 .= count($cases2[$h]).
' '.(count($cases2[$h]) == 1 ? $langs->trans(
"Event") : $langs->trans(
"Events"));
2342 foreach ($cases2[$h] as
$id => $ev) {
2343 if (!empty($ev[
'busy']) && !
getDolGlobalString(
'AGENDA_NO_TRANSPARENT_ON_NOT_BUSY')) {
2344 $style2 .=
' peruser_busy';
2346 $style2 .=
'peruser_notbusy ';
2348 if (!empty($ev[
'css'])) {
2349 $style2 .= $ev[
'css'].
' ';
2353 if (isset($cases3[$h])) {
2355 if (count($cases3[$h]) > 1) {
2356 $title3 .= count($cases3[$h]).
' '.(count($cases3[$h]) == 1 ? $langs->trans(
"Event") : $langs->trans(
"Events"));
2359 foreach ($cases3[$h] as
$id => $ev) {
2360 if (!empty($ev[
'busy']) && !
getDolGlobalString(
'AGENDA_NO_TRANSPARENT_ON_NOT_BUSY')) {
2361 $style3 .=
' peruser_busy';
2363 $style3 .=
'peruser_notbusy ';
2365 if (!empty($ev[
'css'])) {
2366 $style3 .= $ev[
'css'].
' ';
2370 if (isset($cases4[$h])) {
2372 if (count($cases4[$h]) > 1) {
2373 $title4 .= count($cases4[$h]).
' '.(count($cases4[$h]) == 1 ? $langs->trans(
"Event") : $langs->trans(
"Events"));
2376 foreach ($cases4[$h] as
$id => $ev) {
2377 if (!empty($ev[
'busy']) && !
getDolGlobalString(
'AGENDA_NO_TRANSPARENT_ON_NOT_BUSY')) {
2378 $style4 .=
' peruser_busy';
2380 $style4 .=
'peruser_notbusy ';
2382 if (!empty($ev[
'css'])) {
2383 $style4 .= $ev[
'css'].
' ';
2392 if (!empty($cases1[$h]) && is_array($cases1[$h]) && count($cases1[$h]) && array_keys($cases1[$h])) {
2393 $ids1 = implode(
', ', array_keys($cases1[$h]));
2395 if (!empty($cases2[$h]) && is_array($cases2[$h]) && count($cases2[$h]) && array_keys($cases2[$h])) {
2396 $ids2 = implode(
', ', array_keys($cases2[$h]));
2398 if (!empty($cases3[$h]) && is_array($cases3[$h]) && count($cases3[$h]) && array_keys($cases3[$h])) {
2399 $ids3 = implode(
',', array_keys($cases3[$h]));
2401 if (!empty($cases4[$h]) && is_array($cases4[$h]) && count($cases4[$h]) && array_keys($cases4[$h])) {
2402 $ids4 = implode(
',', array_keys($cases4[$h]));
2405 if ($h == $begin_h) {
2406 echo
'<td class="'.$style.
'_peruserleft cal_peruser'.($var ?
' cal_impair '.$style.
'_impair' :
'').
'">';
2408 echo
'<td class="'.$style.
' cal_peruser'.($var ?
' cal_impair '.$style.
'_impair' :
'').
'">';
2413 if (!empty($cases1[$h]) && is_array($cases1[$h]) && count($cases1[$h]) == 1) {
2414 $output = array_slice($cases1[$h], 0, 1);
2415 if ($output[0][
'typecode'] ==
'HOLIDAY') {
2417 $title1 = $langs->trans(
"Holiday");
2419 $title1 = $langs->trans(
"Ref").
' '.$ids1.($title1 ?
' - '.$title1 :
'');
2420 if ($output[0][
'string']) {
2421 $title1 .=
' - '.$output[0][
'string'];
2424 if ($output[0][
'color']) {
2425 $color1 = $output[0][
'color'];
2427 } elseif (!empty($cases1[$h]) && is_array($cases1[$h]) && count($cases1[$h]) > 1) {
2428 $title1 = $langs->trans(
"Ref").
' '.$ids1.($title1 ?
' - '.$title1 :
'');
2434 if (!empty($cases2[$h]) && is_array($cases2[$h]) && count($cases2[$h]) == 1) {
2435 $output = array_slice($cases2[$h], 0, 1);
2436 if ($output[0][
'typecode'] ==
'HOLIDAY') {
2438 $title2 = $langs->trans(
"Holiday");
2440 $title2 = $langs->trans(
"Ref").
' '.$ids2.($title2 ?
' - '.$title2 :
'');
2441 if ($output[0][
'string']) {
2442 $title2 .=
' - '.$output[0][
'string'];
2445 if ($output[0][
'color']) {
2446 $color2 = $output[0][
'color'];
2448 } elseif (!empty($cases2[$h]) && is_array($cases2[$h]) && count($cases2[$h]) > 1) {
2449 $title2 = $langs->trans(
"Ref").
' '.$ids2.($title2 ?
' - '.$title2 :
'');
2455 if (!empty($cases3[$h]) && is_array($cases3[$h]) && count($cases3[$h]) == 1) {
2456 $output = array_slice($cases3[$h], 0, 1);
2457 if ($output[0][
'typecode'] ==
'HOLIDAY') {
2459 $title3 = $langs->trans(
"Holiday");
2461 $title3 = $langs->trans(
"Ref").
' '.$ids3.($title3 ?
' - '.$title3 :
'');
2462 if ($output[0][
'string']) {
2463 $title3 .=
' - '.$output[0][
'string'];
2466 if ($output[0][
'color']) {
2467 $color3 = $output[0][
'color'];
2469 } elseif (!empty($cases3[$h]) && is_array($cases3[$h]) && count($cases3[$h]) > 1) {
2470 $title3 = $langs->trans(
"Ref").
' '.$ids3.($title3 ?
' - '.$title3 :
'');
2476 if (!empty($cases4[$h]) && is_array($cases4[$h]) && count($cases4[$h]) == 1) {
2477 $output = array_slice($cases4[$h], 0, 1);
2478 if ($output[0][
'typecode'] ==
'HOLIDAY') {
2480 $title4 = $langs->trans(
"Holiday");
2482 $title4 = $langs->trans(
"Ref").
' '.$ids4.($title4 ?
' - '.$title4 :
'');
2483 if ($output[0][
'string']) {
2484 $title4 .=
' - '.$output[0][
'string'];
2487 if ($output[0][
'color']) {
2488 $color4 = $output[0][
'color'];
2490 } elseif (!empty($cases4[$h]) && is_array($cases4[$h]) && count($cases4[$h]) > 1) {
2491 $title4 = $langs->trans(
"Ref").
' '.$ids4.($title4 ?
' - '.$title4 :
'');
2495 print
'<table class="nobordernopadding case centpercent">';
2498 if (preg_match(
'/peruser_notbusy/', $style1)) {
2499 print
'style="border: 1px solid #'.($color1 ? $color1 :
"888").
' !important" ';
2500 } elseif ($color1) {
2501 print
'style="background: #'.$color1.
'; "';
2505 print
'center'.($title1 ?
' classfortooltip' :
'').($title1 ?
' cursorpointer' :
'').
'"';
2506 print
'ref="'.$ref1.
'_'.$username->id.
'_'.sprintf(
"%04d", $year).
'_'.sprintf(
"%02d", $month).
'_'.sprintf(
"%02d", $day).
'_'.sprintf(
"%02d", $h).
'_00_'.($ids1 ? $ids1 :
'none').
'"';
2507 print ($title1 ?
' title="'.$title1.
'"' :
'').
'>';
2512 if (preg_match(
'/peruser_notbusy/', $style2)) {
2513 print
'style="border: 1px solid #'.($color2 ? $color2 :
"888").
' !important" ';
2514 } elseif ($color2) {
2515 print
'style="background: #'.$color2.
'; "';
2519 print
'center'.($title2 ?
' classfortooltip' :
'').($title2 ?
' cursorpointer' :
'').
'"';
2520 print
' ref="'.$ref2.
'_'.$username->id.
'_'.sprintf(
"%04d", $year).
'_'.sprintf(
"%02d", $month).
'_'.sprintf(
"%02d", $day).
'_'.sprintf(
"%02d", $h).
'_15_'.($ids2 ? $ids2 :
'none').
'"';
2521 print ($title2 ?
' title="'.$title2.
'"' :
'').
'>';
2526 if (preg_match(
'/peruser_notbusy/', $style3)) {
2527 print
'style="border: 1px solid #'.($color3 ? $color3 :
"888").
' !important" ';
2528 } elseif ($color3) {
2529 print
'style="background: #'.$color3.
'; "';
2533 print
'center'.($title3 ?
' classfortooltip' :
'').($title3 ?
' cursorpointer' :
'').
'"';
2534 print
' ref="'.$ref3.
'_'.$username->id.
'_'.sprintf(
"%04d", $year).
'_'.sprintf(
"%02d", $month).
'_'.sprintf(
"%02d", $day).
'_'.sprintf(
"%02d", $h).
'_30_'.($ids3 ? $ids3 :
'none').
'"';
2535 print ($title3 ?
' title="'.$title3.
'"' :
'').
'>';
2540 if (preg_match(
'/peruser_notbusy/', $style4)) {
2541 print
'style="border: 1px solid #'.($color4 ? $color4 :
"888").
' !important" ';
2542 } elseif ($color4) {
2543 print
'style="background: #'.$color4.
'; "';
2547 print
'center'.($title4 ?
' classfortooltip' :
'').($title4 ?
' cursorpointer' :
'').
'"';
2548 print
' ref="'.$ref4.
'_'.$username->id.
'_'.sprintf(
"%04d", $year).
'_'.sprintf(
"%02d", $month).
'_'.sprintf(
"%02d", $day).
'_'.sprintf(
"%02d", $h).
'_45_'.($ids4 ? $ids4 :
'none').
'"';
2549 print ($title4 ?
' title="'.$title4.
'"' :
'').
'>';
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $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, $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...
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.
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.
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($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).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
dol_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)
if(getDolGlobalString( 'TAKEPOS_SHOW_CUSTOMER')) print $langs trans('Date')." left Label right Qty right Price right TotalHT right TotalTTC right right right right right right right right right centpercent right TotalHT right n right VAT right n right TotalVAT right n No sujeto a RE IRPF right TotalLT1 right n right TotalLT2 right n right TotalTTC right n takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency right TotalTTC takeposcustomercurrency right takeposcustomercurrency n right PaymentTypeShortLIQ right SELECT p pos_change as p datep as date
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.