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';
1107 $event->datep = $db->jdate($obj->date_start) + (empty($obj->halfday) || $obj->halfday == 1 ? 0 : 12) * 60 * 60;
1108 $event->datef = $db->jdate($obj->date_end) + (empty($obj->halfday) || $obj->halfday == -1 ? 24 : 12) * 60 * 60 - 1;
1109 $event->date_start_in_calendar = $event->datep;
1110 $event->date_end_in_calendar = $event->datef;
1112 $event->transparency = 1;
1114 $event->userownerid = $obj->uid;
1115 $event->userassigned = array($obj->uid => array(
'id' => $obj->uid,
'transparency' => 1));
1117 if ($obj->status == 3) {
1119 $event->percentage = -1;
1120 } elseif ($obj->status == 2) {
1122 $event->percentage = 0;
1126 $daycursor = $event->date_start_in_calendar;
1131 $daycursorend = $event->date_end_in_calendar;
1132 $anneeend = (int)
dol_print_date($daycursorend,
'%Y',
'tzuserrel');
1133 $moisend = (int)
dol_print_date($daycursorend,
'%m',
'tzuserrel');
1134 $jourend = (int)
dol_print_date($daycursorend,
'%d',
'tzuserrel');
1137 $daykey =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
1138 $daykeygmt =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
1143 $firstdayofholiday = ($ifornbofdays == 1);
1144 $lastdayofholiday = ($daykeygmt ==
dol_get_first_hour($event->date_end_in_calendar,
'gmt'));
1148 if ((in_array($obj->halfday, array(1, 2)) == 1 && $lastdayofholiday) || (in_array($obj->halfday, array(-1, 2)) && $firstdayofholiday)) {
1151 if (in_array($obj->halfday, array(1, 2)) && $lastdayofholiday) {
1152 $newevent->label .=
' ('.$langs->trans(
"Morning").
')';
1153 } elseif (in_array($obj->halfday, array(-1, 2)) && $firstdayofholiday) {
1154 $newevent->label .=
' ('.$langs->trans(
"Afternoon").
')';
1156 $eventarray[$daykey][] = $newevent;
1158 $eventarray[$daykey][] = $event;
1161 $daykey += 60 * 60 * 24;
1162 $daykeygmt += 60 * 60 * 24;
1163 }
while ($daykey <= $event->date_end_in_calendar);
1172if (count($listofextcals)) {
1173 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/ical.class.php';
1175 foreach ($listofextcals as $key => $extcal) {
1176 $url = $extcal[
'src'];
1177 $namecal = $extcal[
'name'];
1178 $offsettz = $extcal[
'offsettz'];
1179 $colorcal = $extcal[
'color'];
1180 $buggedfile = $extcal[
'buggedfile'];
1186 $ical->parse($url, $pathforcachefile, $DELAYFORCACHE);
1189 $listofextcals[$key][
'error'] = $ical->error;
1190 $s .=
'<br><div class="warning">'.dol_escape_htmltag($listofextcals[$key][
'name']).
': '.$url.
'<br>Error message: '.
dol_escape_htmltag($ical->error).
'</div>';
1195 $icalevents = array();
1196 if (is_array($ical->get_event_list())) {
1197 $icalevents = array_merge($icalevents, $ical->get_event_list());
1199 if (is_array($ical->get_freebusy_list())) {
1200 $icalevents = array_merge($icalevents, $ical->get_freebusy_list());
1203 if (count($icalevents) > 0) {
1205 $moreicalevents = array();
1206 foreach ($icalevents as $icalevent) {
1207 if (isset($icalevent[
'RRULE']) && is_array($icalevent[
'RRULE'])) {
1210 if ($icalevent[
'DTSTART;VALUE=DATE']) {
1213 } elseif (is_array($icalevent[
'DTSTART']) && !empty($icalevent[
'DTSTART'][
'unixtime'])) {
1214 $datecurstart = $icalevent[
'DTSTART'][
'unixtime'];
1215 $datecurend = $icalevent[
'DTEND'][
'unixtime'];
1216 if (!empty($ical->cal[
'DAYLIGHT'][
'DTSTART']) ) {
1218 $tmpcurstart = $datecurstart;
1219 $tmpcurend = $datecurend;
1220 $tmpdaylightstart =
dol_mktime(0, 0, 0, 1, 1, 1970, 1) + (int) $ical->cal[
'DAYLIGHT'][
'DTSTART'];
1221 $tmpdaylightend =
dol_mktime(0, 0, 0, 1, 1, 1970, 1) + (int) $ical->cal[
'STANDARD'][
'DTSTART'];
1224 if ($tmpcurstart >= $tmpdaylightstart && $tmpcurstart < $tmpdaylightend) {
1225 $datecurstart -= ((int) $ical->cal[
'DAYLIGHT'][
'TZOFFSETTO']) * 36;
1227 $datecurstart -= ((int) $ical->cal[
'STANDARD'][
'TZOFFSETTO']) * 36;
1229 if ($tmpcurend >= $tmpdaylightstart && $tmpcurstart < $tmpdaylightend) {
1230 $datecurend -= ((int) $ical->cal[
'DAYLIGHT'][
'TZOFFSETTO']) * 36;
1232 $datecurend -= ((int) $ical->cal[
'STANDARD'][
'TZOFFSETTO']) * 36;
1239 dol_syslog(
"Found a not recognized repeatable record with unknown date start", LOG_ERR);
1244 $interval = (empty($icalevent[
'RRULE'][
'INTERVAL']) ? 1 : $icalevent[
'RRULE'][
'INTERVAL']);
1245 $until = empty($icalevent[
'RRULE'][
'UNTIL']) ? 0 :
dol_stringtotime($icalevent[
'RRULE'][
'UNTIL'], 1);
1246 $maxrepeat = empty($icalevent[
'RRULE'][
'COUNT']) ? 0 : $icalevent[
'RRULE'][
'COUNT'];
1247 if ($until && ($until + ($datecurend - $datecurstart)) < $firstdaytoshow) {
1250 if ($datecurstart >= $lastdaytoshow) {
1255 while (($datecurstart < $lastdaytoshow) && (empty($maxrepeat) || ($numofevent < $maxrepeat))) {
1256 if ($datecurend >= $firstdaytoshow) {
1257 $newevent = $icalevent;
1258 unset($newevent[
'RRULE']);
1259 if ($icalevent[
'DTSTART;VALUE=DATE']) {
1260 $newevent[
'DTSTART;VALUE=DATE'] =
dol_print_date($datecurstart,
'%Y%m%d');
1261 $newevent[
'DTEND;VALUE=DATE'] =
dol_print_date($datecurend + 1,
'%Y%m%d');
1263 $newevent[
'DTSTART'] = $datecurstart;
1264 $newevent[
'DTEND'] = $datecurend;
1266 $moreicalevents[] = $newevent;
1270 $savdatecurstart = $datecurstart;
1271 if ($icalevent[
'RRULE'][
'FREQ'] ==
'DAILY') {
1275 if ($icalevent[
'RRULE'][
'FREQ'] ==
'WEEKLY') {
1278 } elseif ($icalevent[
'RRULE'][
'FREQ'] ==
'MONTHLY') {
1281 } elseif ($icalevent[
'RRULE'][
'FREQ'] ==
'YEARLY') {
1286 if ($savdatecurstart >= $datecurstart) {
1287 dol_syslog(
"Found a rule freq ".$icalevent[
'RRULE'][
'FREQ'].
" not managed by dolibarr code. Assume 1 week frequency.", LOG_ERR);
1288 $datecurstart += 3600 * 24 * 7;
1289 $datecurend += 3600 * 24 * 7;
1294 $icalevents = array_merge($icalevents, $moreicalevents);
1297 foreach ($icalevents as $icalevent) {
1302 if (!empty($icalevent[
'RRULE'])) {
1311 if (isset($icalevent[
'DTSTART;VALUE=DATE'])) {
1314 if (empty($icalevent[
'DTEND;VALUE=DATE'])) {
1315 $dateend = $datestart + 86400 - 1;
1321 $event->fulldayevent = 1;
1323 } elseif (!is_array($icalevent[
'DTSTART'])) {
1324 $datestart = $icalevent[
'DTSTART'];
1325 $dateend = empty($icalevent[
'DTEND']) ? $datestart : $icalevent[
'DTEND'];
1327 $datestart += +($offsettz * 3600);
1328 $dateend += +($offsettz * 3600);
1333 } elseif (isset($icalevent[
'DTSTART'][
'unixtime'])) {
1334 $datestart = $icalevent[
'DTSTART'][
'unixtime'];
1335 $dateend = $icalevent[
'DTEND'][
'unixtime'];
1337 $datestart += +($offsettz * 3600);
1338 $dateend += +($offsettz * 3600);
1341 if ($buggedfile ===
'uselocalandtznodaylight') {
1345 if ($buggedfile ===
'uselocalandtzdaylight') {
1346 $localtzs =
new DateTimeZone(preg_replace(
'/"/',
'', $icalevent[
'DTSTART'][
'TZID']));
1347 $localtze =
new DateTimeZone(preg_replace(
'/"/',
'', $icalevent[
'DTEND'][
'TZID']));
1348 $localdts =
new DateTime(
dol_print_date($datestart,
'dayrfc',
'gmt'), $localtzs);
1349 $localdte =
new DateTime(
dol_print_date($dateend,
'dayrfc',
'gmt'), $localtze);
1350 $tmps = -1 * $localtzs->getOffset($localdts);
1351 $tmpe = -1 * $localtze->getOffset($localdte);
1352 $datestart += $tmps;
1359 if ($addevent && $datestart !==
null && $dateend !==
null) {
1360 $event->id = $icalevent[
'UID'];
1361 $event->ref = (string) $event->id;
1362 $userstatic =
new User($db);
1363 $userId = $userstatic->findUserIdByEmail($namecal);
1364 if (!empty($userId) && $userId > 0) {
1365 $event->userassigned[$userId] = [
1367 'transparency' => 1,
1369 $event->percentage = -1;
1372 $event->type_code =
"ICALEVENT";
1373 $event->type_label = $namecal;
1374 $event->type_color = $colorcal;
1375 $event->type =
'icalevent';
1376 $event->type_picto =
'rss';
1378 $event->icalname = $namecal;
1379 $event->icalcolor = $colorcal;
1381 $event->datep = $datestart + $usertime;
1382 $event->datef = $dateend + $usertime;
1384 if (isset($icalevent[
'SUMMARY']) && $icalevent[
'SUMMARY']) {
1386 } elseif (isset($icalevent[
'DESCRIPTION']) && $icalevent[
'DESCRIPTION']) {
1389 $event->label = $langs->trans(
"ExtSiteNoLabel");
1396 if (!empty($icalevent[
'PRIORITY'])) {
1397 $event->priority = $icalevent[
'PRIORITY'];
1401 if (!empty($icalevent[
'TRANSP'])) {
1402 if ($icalevent[
'TRANSP'] ==
"TRANSPARENT") {
1403 $event->transparency = 0;
1405 if ($icalevent[
'TRANSP'] ==
"OPAQUE") {
1406 $event->transparency = 1;
1417 if (!empty($icalevent[
'LOCATION'])) {
1418 $event->location = $icalevent[
'LOCATION'];
1421 $event->date_start_in_calendar = $event->datep;
1423 if ($event->datef !=
'' && $event->datef >= $event->datep) {
1424 $event->date_end_in_calendar = $event->datef;
1426 $event->date_end_in_calendar = $event->datep;
1430 if ($event->date_end_in_calendar < $firstdaytoshow || $event->date_start_in_calendar >= $lastdaytoshow) {
1436 if ($event->date_start_in_calendar < $firstdaytoshow) {
1437 $event->date_start_in_calendar = $firstdaytoshow;
1439 if ($event->date_end_in_calendar >= $lastdaytoshow) {
1440 $event->date_end_in_calendar = ($lastdaytoshow - 1);
1444 $daycursor = $event->date_start_in_calendar;
1453 $daykey =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
1454 $daykeygmt =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
1457 $eventarray[$daykey][] = $event;
1458 $daykey += 60 * 60 * 24;
1459 $daykeygmt += 60 * 60 * 24;
1460 if (($event->fulldayevent ? $daykeygmt : $daykey) > $event->date_end_in_calendar) {
1472$parameters = array();
1474$reshook = $hookmanager->executeHooks(
'getCalendarEvents', $parameters, $object, $action);
1475if (!empty($hookmanager->resArray[
'eventarray'])) {
1476 foreach ($hookmanager->resArray[
'eventarray'] as $keyDate => $events) {
1477 if (!isset($eventarray[$keyDate])) {
1478 $eventarray[$keyDate] = array();
1480 $eventarray[$keyDate] = array_merge($eventarray[$keyDate], $events);
1492$cachethirdparties = array();
1493$cachecontacts = array();
1497 array(137, 86, 161),
1498 array(60, 147, 183),
1499 array(250, 190, 80),
1501 array(190, 190, 100),
1502 array(91, 115, 247),
1503 array(140, 140, 220),
1504 array(190, 120, 120),
1505 array(115, 125, 150),
1506 array(100, 170, 20),
1507 array(150, 135, 125),
1508 array(85, 135, 150),
1509 array(150, 135, 80),
1513$color_file = DOL_DOCUMENT_ROOT.
"/theme/".$conf->theme.
"/theme_vars.inc.php";
1514if (is_readable($color_file)) {
1515 include $color_file;
1519$massactionbutton =
'';
1523print_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);
1531print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1532print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday,
'', (
string) $filtert,
'', $pid, $socid, $action, -1, $actioncode, $usergroup,
'', $resourceid, $search_categ_cus);
1537$newparam = preg_replace(
'/showbirthday=/i',
'showbirthday_=', $newparam);
1538$newparam = preg_replace(
'/mode=show_month&?/i',
'', $newparam);
1539$newparam = preg_replace(
'/mode=show_week&?/i',
'', $newparam);
1540$newparam = preg_replace(
'/day=[0-9]+&?/i',
'', $newparam);
1541$newparam = preg_replace(
'/month=[0-9]+&?/i',
'', $newparam);
1542$newparam = preg_replace(
'/year=[0-9]+&?/i',
'', $newparam);
1543$newparam = preg_replace(
'/viewweek=[0-9]+&?/i',
'', $newparam);
1544$newparam = preg_replace(
'/showbirthday_=/i',
'showbirthday=', $newparam);
1545$newparam .=
'&viewweek=1';
1547echo
'<input type="hidden" name="actionmove" value="mupdate">';
1548echo
'<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($_SERVER[
'PHP_SELF']).
'?'.
dol_escape_htmltag($_SERVER[
'QUERY_STRING']).
'">';
1549echo
'<input type="hidden" name="newdate" id="newdate">';
1556$currentdaytoshow = $firstdaytoshow;
1557echo
'<div class="div-table-responsive">';
1560$colorsbytype = array();
1562while ($currentdaytoshow < $lastdaytoshow) {
1563 echo
'<table class="centpercent noborder nocellnopadd cal_month cal_peruser listwithfilterbefore">';
1565 echo
'<tr class="liste_titre">';
1566 echo
'<td class="nopaddingtopimp nopaddingbottomimp nowraponsmartphone">';
1570 print
'<span class="hideonsmartphone" title="'.$langs->trans(
"VisibleDaysRange").
'">';
1571 print
img_picto(
'',
'clock',
'class="fawidth30 inline-block marginleftonly"');
1572 print $langs->trans(
"DaysOfWeek").
'</span>';
1574 print
'<div class="ui-grid-a inline-block"><div class="ui-block-a nowraponall">';
1575 print
'<input type="number" class="shortbis" name="begin_d" value="'.$begin_d.
'" min="1" max="7">';
1576 if (empty($conf->dol_use_jmobile)) {
1579 print
'</div><div class="ui-block-b">';
1581 print
'<input type="number" class="shortbis" name="end_d" value="'.$end_d.
'" min="1" max="7">';
1582 print
'</div></div>';
1588 if (($i + 1) < $begin_d || ($i + 1) > $end_d) {
1592 echo
'<td align="center" colspan="'.($end_h - $begin_h).
'">';
1593 echo
'<span class="bold spandayofweek">'.$langs->trans(
"Day".(($i +
getDolGlobalInt(
'MAIN_START_WEEK', 1)) % 7)).
'</span>';
1598 $valtoshow = $currentdaytoshow;
1601 echo
'<span class="badgeneutral">';
1603 print
dol_print_date($valtoshow,
'dayreduceformat',
'tzuserrel');
1612 echo
'<tr class="liste_titre">';
1616 print
'<span class="hideonsmartphone" title="'.$langs->trans(
"VisibleTimeRange").
'">';
1617 print
img_picto(
'',
'clock',
'class="fawidth30 inline-block marginleftonly"');
1618 print $langs->trans(
"Hours").
'</span>';
1620 print
'<div class="ui-grid-a inline-block"><div class="ui-block-a nowraponall">';
1621 print
'<input type="number" class="shortbis" name="begin_h" value="'.$begin_h.
'" min="0" max="23">';
1622 if (empty($conf->dol_use_jmobile)) {
1625 print
'</div><div class="ui-block-b">';
1627 print
'<input type="number" class="shortbis" name="end_h" value="'.$end_h.
'" min="1" max="24">';
1628 if (empty($conf->dol_use_jmobile)) {
1629 print
' '.$langs->trans(
"HourShort");
1631 print
'</div></div>';
1636 if (($i + 1) < $begin_d || ($i + 1) > $end_d) {
1640 for ($h = $begin_h; $h < $end_h; $h++) {
1641 echo
'<td class="center">';
1642 print
'<small style="font-family: courier">'.sprintf(
"%02d", $h).
'</small>';
1652 $usernames = array();
1653 $usernamesid = array();
1656 foreach ($eventarray as $daykey => $notused) {
1658 foreach ($eventarray[$daykey] as $index => $event) {
1659 $event->fetch_userassigned();
1660 $listofuserid = $event->userassigned;
1661 foreach ($listofuserid as $userid => $tmp) {
1662 if (!in_array($userid, $usernamesid)) {
1663 $usernamesid[$userid] = $userid;
1670 $sql =
"SELECT u.rowid, u.lastname as lastname, u.firstname, u.statut, u.login, u.admin, u.entity";
1671 $sql .=
" FROM ".$db->prefix().
"user as u";
1673 $sql .=
" WHERE u.rowid IN (";
1674 $sql .=
" SELECT ug.fk_user FROM ".$db->prefix().
"usergroup_user as ug";
1675 $sql .=
" WHERE ug.entity IN (".getEntity(
'usergroup').
")";
1676 if ($usergroup > 0) {
1677 $sql .=
" AND ug.fk_usergroup = ".((int) $usergroup);
1681 if ($usergroup > 0) {
1682 $sql .=
" LEFT JOIN ".$db->prefix().
"usergroup_user as ug ON u.rowid = ug.fk_user";
1684 $sql .=
" WHERE u.entity IN (".getEntity(
'user').
")";
1685 if ($usergroup > 0) {
1686 $sql .=
" AND ug.fk_usergroup = ".((int) $usergroup);
1689 $sql .=
" AND u.statut = 1";
1691 $sql .=
" AND u.rowid = ".((int) $filtert);
1693 if ($usergroup > 0) {
1694 $sql .=
" AND ug.fk_usergroup = ".((int) $usergroup);
1696 if ($user->socid > 0) {
1698 $sql .=
" AND u.fk_soc = ".((int) $user->socid);
1701 if (!$canedit || $filtert ==
'-3') {
1702 if (!$user->hasRight(
'user',
'user',
'lire') || $filtert ==
'-3') {
1703 $usersInHierarchy = $user->getAllChildIds(1);
1704 $sql .=
" AND u.rowid IN (".$db->sanitize(implode(
',', $usersInHierarchy)).
")";
1709 $resql = $db->query($sql);
1711 $num = $db->num_rows($resql);
1715 $obj = $db->fetch_object($resql);
1716 $usernamesid[$obj->rowid] = $obj->rowid;
1725 foreach ($usernamesid as
$id) {
1726 $tmpuser =
new User($db);
1727 $result = $tmpuser->fetch(
$id);
1728 $usernames[] = $tmpuser;
1732 $labelbytype = array();
1733 $sql =
"SELECT code, color, libelle as label FROM ".MAIN_DB_PREFIX.
"c_actioncomm ORDER BY position";
1734 $resql = $db->query($sql);
1735 while ($obj = $db->fetch_object($resql)) {
1736 $colorsbytype[$obj->code] = $obj->color;
1737 $labelbytype[$obj->code] = $obj->label;
1745 foreach ($usernames as $username) {
1751 echo
'<td class="tdoverflowmax100 cal_current_month cal_peruserviewname'.($var ?
' cal_impair' :
'').
' nopaddingtopimp nopaddingbottomimp noheightimp">';
1752 print
'<span class="paddingrightimp">';
1753 print $username->getNomUrl(-1,
'', 0, 0, 20, 1,
'',
'paddingleft');
1760 for ($iter_day = 0; $iter_day < 8; $iter_day++) {
1761 if (($i + 1) < $begin_d || ($i + 1) > $end_d) {
1774 $style =
'cal_current_month';
1775 if ($iter_day == 6) {
1776 $style .=
' cal_other_month';
1779 if ($todayarray[
'mday'] == $tmpday && $todayarray[
'mon'] == $tmpmonth && $todayarray[
'year'] == $tmpyear) {
1783 $style =
'cal_today_peruser';
1786 show_day_events2($username, $tmpday, $tmpmonth, $tmpyear, 0, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, $showheader, $colorsbytype, $var);
1791 $showheader =
false;
1803 $langs->load(
"commercial");
1804 print
'<br>'.$langs->trans(
"Legend").
': <br>';
1805 foreach ($colorsbytype as $code => $color) {
1807 print
'<div style="float: left; padding: 2px; margin-right: 6px;"><div style="background: #'.$color.
'; width:16px; float: left; margin-right: 4px;"> </div>';
1808 print $langs->trans(
"Action".$code) !=
"Action".$code ? $langs->trans(
"Action".$code) : $labelbytype[$code];
1814 print
'<div style="float: left; padding: 2px; margin-right: 6px;"><div class="peruser_busy" style="width:16px; float: left; margin-right: 4px;"> </div>';
1815 print $langs->trans(
"Other");
1824print
"\n".
'</form>';
1829print
'<script type="text/javascript">
1830jQuery(document).ready(function() {
1831 jQuery(".onclickopenref").click(function() {
1832 var ref=$(this).attr(\'ref\');
1833 var res = ref.split("_");
1835 var userid = res[1];
1843 console.log("We click on a class onclickopenref in page peruser with ref="+ref+" type="+type);
1845 if (ids == \'none\') /* No event */
1847 /* alert(\'no event\'); */
1848 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 :
'')).
'"
1849 window.location.href = url;
1851 else if (ids.indexOf(",") > -1) /* There is several events */
1853 /* alert(\'several events\'); */
1854 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;
1855 window.location.href = url;
1856 } else { /* One event */
1857 /* alert(\'one event\'); */
1858 if (type == \'holiday\') {
1859 url = "'.DOL_URL_ROOT.
'/holiday/card.php?id="+ids
1861 url = "'.DOL_URL_ROOT.
'/comm/action/card.php?action=view&id="+ids
1863 window.location.href = url;
1896function 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)
1899 global $user, $conf, $langs, $hookmanager, $action;
1900 global $filter, $filtert, $status, $actioncode;
1902 global $cachethirdparties, $cachecontacts,
$cacheusers, $cacheprojects, $colorindexused;
1903 global $begin_h, $end_h;
1917 @phan-var-force array<int,array<int,array<string,string|int|bool>>> $cases1
1918 @phan-var-force array<int,array<int,array<string,string|int|bool>>> $cases2
1919 @phan-var-force array<int,array<int,array<string,string|int|bool>>> $cases3
1920 @phan-var-force array<int,array<int,array<string,string|int|bool>>> $cases4
1927 $numicals = array();
1930 $colorindexused[$user->id] = 0;
1931 $nextindextouse = count($colorindexused);
1938 foreach ($eventarray as $daykey => $notused) {
1945 if ($day == $jour && (
int) $month == $mois && $year == $annee) {
1949 foreach ($eventarray[$daykey] as $index => $event) {
1953 $keysofuserassigned = array_keys($event->userassigned);
1955 if (!in_array($username->id, $keysofuserassigned)) {
1960 $parameters = array();
1961 $reshook = $hookmanager->executeHooks(
'formatEvent', $parameters, $event, $action);
1971 if ($event->type_code ==
'HOLIDAY') {
1972 $cssclass =
'family_holiday';
1975 if (in_array($user->id, $keysofuserassigned)) {
1976 $cssclass =
'family_mytasks';
1978 if (empty($cacheusers[$event->userownerid])) {
1979 $newuser =
new User($db);
1980 $newuser->fetch($event->userownerid);
1986 if (!empty($cacheusers[$event->userownerid]->color)) {
1991 $color = $event->type_color;
1993 } elseif ($event->type_code ==
'ICALEVENT') {
1995 if (!empty($event->icalname)) {
2002 $color = $event->icalcolor;
2003 $cssclass = (!empty($event->icalname) ?
'family_ext'.md5($event->icalname) :
'family_other unsortable');
2004 } elseif ($event->type_code ==
'BIRTHDAY') {
2007 $cssclass =
'family_birthday unsortable';
2008 $color = sprintf(
"%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
2011 $color = ($event->icalcolor ? $event->icalcolor : -1);
2012 $cssclass = (!empty($event->icalname) ?
'family_ext'.md5($event->icalname) :
'family_other');
2014 if (empty($cacheusers[$event->userownerid])) {
2015 $newuser =
new User($db);
2016 $newuser->fetch($event->userownerid);
2022 if (!empty($cacheusers[$event->userownerid]->color)) {
2027 $color = $event->type_color;
2033 $idusertouse = ($event->userownerid ? $event->userownerid : 0);
2034 if (isset($colorindexused[$idusertouse])) {
2035 $colorindex = $colorindexused[$idusertouse];
2037 $colorindex = $nextindextouse;
2038 $colorindexused[$idusertouse] = $colorindex;
2039 if (!empty($theme_datacolor[$nextindextouse + 1])) {
2044 $color = sprintf(
"%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
2048 for ($h = $begin_h; $h < $end_h; $h++) {
2051 if (empty($event->fulldayevent)) {
2052 $a =
dol_mktime((
int) $h, 0, 0, $month, $day, $year,
'tzuserrel', 0);
2053 $b =
dol_mktime((
int) $h, 15, 0, $month, $day, $year,
'tzuserrel', 0);
2054 $b1 =
dol_mktime((
int) $h, 30, 0, $month, $day, $year,
'tzuserrel', 0);
2055 $b2 =
dol_mktime((
int) $h, 45, 0, $month, $day, $year,
'tzuserrel', 0);
2056 $c =
dol_mktime((
int) $h + 1, 0, 0, $month, $day, $year,
'tzuserrel', 0);
2058 $dateendtouse = $event->date_end_in_calendar;
2059 if ($dateendtouse == $event->date_start_in_calendar) {
2064 if ($event->date_start_in_calendar < $b && $dateendtouse > $a) {
2065 $busy = $event->transparency;
2066 $cases1[$h][$event->id][
'busy'] = $busy;
2067 $cases1[$h][$event->id][
'string'] =
dol_print_date($event->date_start_in_calendar,
'dayhour',
'tzuserrel');
2068 if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) {
2069 $tmpa =
dol_getdate($event->date_start_in_calendar,
true);
2070 $tmpb =
dol_getdate($event->date_end_in_calendar,
true);
2071 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) {
2072 $cases1[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'hour',
'tzuserrel');
2074 $cases1[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'dayhour',
'tzuserrel');
2077 if ($event->label) {
2078 $cases1[$h][$event->id][
'string'] .=
' - '.$event->label;
2080 $cases1[$h][$event->id][
'typecode'] = $event->type_code;
2081 if ($event->type_code ==
'HOLIDAY') {
2082 $cases1[$h][$event->id][
'css'] =
'peruser_holiday ';
2084 $cases1[$h][$event->id][
'css'] .=
'peruser_holiday_imp ';
2087 $cases1[$h][$event->id][
'color'] = $color;
2089 if ($event->fk_project > 0) {
2090 if (empty($cacheprojects[$event->fk_project])) {
2092 $tmpproj->fetch($event->fk_project);
2093 $cacheprojects[$event->fk_project] = $tmpproj;
2095 $cases1[$h][$event->id][
'string'] .=
', '.$langs->trans(
"Project").
': '.$cacheprojects[$event->fk_project]->ref.
' - '.$cacheprojects[$event->fk_project]->title;
2097 if ($event->socid > 0) {
2098 if (empty($cachethirdparties[$event->socid])) {
2099 $tmpthirdparty =
new Societe($db);
2100 $tmpthirdparty->fetch($event->socid);
2101 $cachethirdparties[$event->socid] = $tmpthirdparty;
2103 $cases1[$h][$event->id][
'string'] .=
', '.$cachethirdparties[$event->socid]->name;
2105 if ($event->contact_id > 0) {
2106 if (empty($cachecontacts[$event->contact_id])) {
2107 $tmpcontact =
new Contact($db);
2108 $tmpcontact->fetch($event->contact_id);
2109 $cachecontacts[$event->contact_id] = $tmpcontact;
2111 $cases1[$h][$event->id][
'string'] .=
', '.$cachecontacts[$event->contact_id]->getFullName($langs);
2115 if ($event->date_start_in_calendar < $b1 && $dateendtouse > $b) {
2116 $busy = $event->transparency;
2117 $cases2[$h][$event->id][
'busy'] = $busy;
2118 $cases2[$h][$event->id][
'string'] =
dol_print_date($event->date_start_in_calendar,
'dayhour',
'tzuserrel');
2119 if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) {
2120 $tmpa =
dol_getdate($event->date_start_in_calendar,
true);
2121 $tmpb =
dol_getdate($event->date_end_in_calendar,
true);
2122 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) {
2123 $cases2[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'hour',
'tzuserrel');
2125 $cases2[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'dayhour',
'tzuserrel');
2128 if ($event->label) {
2129 $cases2[$h][$event->id][
'string'] .=
' - '.$event->label;
2131 $cases2[$h][$event->id][
'typecode'] = $event->type_code;
2132 if ($event->type_code ==
'HOLIDAY') {
2133 $cases2[$h][$event->id][
'css'] =
'peruser_holiday ';
2135 $cases2[$h][$event->id][
'css'] .=
'peruser_holiday_imp ';
2138 $cases2[$h][$event->id][
'color'] = $color;
2140 if ($event->fk_project > 0) {
2141 if (empty($cacheprojects[$event->fk_project])) {
2143 $tmpproj->fetch($event->fk_project);
2144 $cacheprojects[$event->fk_project] = $tmpproj;
2146 $cases2[$h][$event->id][
'string'] .=
', '.$langs->trans(
"Project").
': '.$cacheprojects[$event->fk_project]->ref.
' - '.$cacheprojects[$event->fk_project]->title;
2148 if ($event->socid > 0) {
2149 if (empty($cachethirdparties[$event->socid])) {
2150 $tmpthirdparty =
new Societe($db);
2151 $tmpthirdparty->fetch($event->socid);
2152 $cachethirdparties[$event->socid] = $tmpthirdparty;
2154 $cases2[$h][$event->id][
'string'] .=
', '.$cachethirdparties[$event->socid]->name;
2156 if ($event->contact_id > 0) {
2157 if (empty($cachecontacts[$event->contact_id])) {
2158 $tmpcontact =
new Contact($db);
2159 $tmpcontact->fetch($event->contact_id);
2160 $cachecontacts[$event->contact_id] = $tmpcontact;
2162 $cases2[$h][$event->id][
'string'] .=
', '.$cachecontacts[$event->contact_id]->getFullName($langs);
2166 if ($event->date_start_in_calendar < $b2 && $dateendtouse > $b1) {
2167 $busy = $event->transparency;
2168 $cases3[$h][$event->id][
'busy'] = $busy;
2169 $cases3[$h][$event->id][
'string'] =
dol_print_date($event->date_start_in_calendar,
'dayhour',
'tzuserrel');
2170 if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) {
2171 $tmpa =
dol_getdate($event->date_start_in_calendar,
true);
2172 $tmpb =
dol_getdate($event->date_end_in_calendar,
true);
2173 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) {
2174 $cases3[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'hour',
'tzuserrel');
2176 $cases3[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'dayhour',
'tzuserrel');
2179 if ($event->label) {
2180 $cases3[$h][$event->id][
'string'] .=
' - '.$event->label;
2182 $cases3[$h][$event->id][
'typecode'] = $event->type_code;
2183 if ($event->type_code ==
'HOLIDAY') {
2184 $cases3[$h][$event->id][
'css'] .=
'peruser_holiday ';
2186 $cases3[$h][$event->id][
'css'] .=
'peruser_holiday_imp ';
2189 $cases3[$h][$event->id][
'color'] = $color;
2191 if ($event->fk_project > 0) {
2192 if (empty($cacheprojects[$event->fk_project])) {
2194 $tmpproj->fetch($event->fk_project);
2195 $cacheprojects[$event->fk_project] = $tmpproj;
2197 $cases3[$h][$event->id][
'string'] .=
', '.$langs->trans(
"Project").
': '.$cacheprojects[$event->fk_project]->ref.
' - '.$cacheprojects[$event->fk_project]->title;
2199 if ($event->socid > 0) {
2200 if (empty($cachethirdparties[$event->socid])) {
2201 $tmpthirdparty =
new Societe($db);
2202 $tmpthirdparty->fetch($event->socid);
2203 $cachethirdparties[$event->socid] = $tmpthirdparty;
2205 $cases3[$h][$event->id][
'string'] .=
', '.$cachethirdparties[$event->socid]->name;
2207 if ($event->contact_id > 0) {
2208 if (empty($cachecontacts[$event->contact_id])) {
2209 $tmpcontact =
new Contact($db);
2210 $tmpcontact->fetch($event->contact_id);
2211 $cachecontacts[$event->contact_id] = $tmpcontact;
2213 $cases3[$h][$event->id][
'string'] .=
', '.$cachecontacts[$event->contact_id]->getFullName($langs);
2217 if ($event->date_start_in_calendar <
$c && $dateendtouse > $b2) {
2218 $busy = $event->transparency;
2219 $cases4[$h][$event->id][
'busy'] = $busy;
2220 $cases4[$h][$event->id][
'string'] =
dol_print_date($event->date_start_in_calendar,
'dayhour',
'tzuserrel');
2221 if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) {
2222 $tmpa =
dol_getdate($event->date_start_in_calendar,
true);
2223 $tmpb =
dol_getdate($event->date_end_in_calendar,
true);
2224 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) {
2225 $cases4[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'hour',
'tzuserrel');
2227 $cases4[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'dayhour',
'tzuserrel');
2230 if ($event->label) {
2231 $cases4[$h][$event->id][
'string'] .=
' - '.$event->label;
2233 $cases4[$h][$event->id][
'typecode'] = $event->type_code;
2234 if ($event->type_code ==
'HOLIDAY') {
2235 $cases4[$h][$event->id][
'css'] =
'peruser_holiday ';
2237 $cases4[$h][$event->id][
'css'] .=
'peruser_holiday_imp ';
2240 $cases4[$h][$event->id][
'color'] = $color;
2242 if ($event->fk_project > 0) {
2243 if (empty($cacheprojects[$event->fk_project])) {
2245 $tmpproj->fetch($event->fk_project);
2246 $cacheprojects[$event->fk_project] = $tmpproj;
2248 $cases4[$h][$event->id][
'string'] .=
', '.$langs->trans(
"Project").
': '.$cacheprojects[$event->fk_project]->ref.
' - '.$cacheprojects[$event->fk_project]->title;
2250 if ($event->socid > 0) {
2251 if (empty($cachethirdparties[$event->socid])) {
2252 $tmpthirdparty =
new Societe($db);
2253 $tmpthirdparty->fetch($event->socid);
2254 $cachethirdparties[$event->socid] = $tmpthirdparty;
2256 $cases4[$h][$event->id][
'string'] .=
', '.$cachethirdparties[$event->socid]->name;
2258 if ($event->contact_id > 0) {
2259 if (empty($cachecontacts[$event->contact_id])) {
2260 $tmpcontact =
new Contact($db);
2261 $tmpcontact->fetch($event->contact_id);
2262 $cachecontacts[$event->contact_id] = $tmpcontact;
2264 $cases4[$h][$event->id][
'string'] .=
', '.$cachecontacts[$event->contact_id]->getFullName($langs);
2269 $busy = $event->transparency;
2270 $cases1[$h][$event->id][
'busy'] = $busy;
2271 $cases2[$h][$event->id][
'busy'] = $busy;
2272 $cases3[$h][$event->id][
'busy'] = $busy;
2273 $cases4[$h][$event->id][
'busy'] = $busy;
2274 $cases1[$h][$event->id][
'string'] = $event->label;
2275 $cases2[$h][$event->id][
'string'] = $event->label;
2276 $cases3[$h][$event->id][
'string'] = $event->label;
2277 $cases4[$h][$event->id][
'string'] = $event->label;
2278 $cases1[$h][$event->id][
'typecode'] = $event->type_code;
2279 $cases2[$h][$event->id][
'typecode'] = $event->type_code;
2280 $cases3[$h][$event->id][
'typecode'] = $event->type_code;
2281 $cases4[$h][$event->id][
'typecode'] = $event->type_code;
2282 $cases1[$h][$event->id][
'color'] = $color;
2283 $cases2[$h][$event->id][
'color'] = $color;
2284 $cases3[$h][$event->id][
'color'] = $color;
2285 $cases4[$h][$event->id][
'color'] = $color;
2286 $cases1[$h][$event->id][
'css'] =
'';
2287 $cases2[$h][$event->id][
'css'] =
'';
2288 $cases3[$h][$event->id][
'css'] =
'';
2289 $cases4[$h][$event->id][
'css'] =
'';
2300 for ($h = $begin_h; $h < $end_h; $h++) {
2305 $style1 =
'onclickopenref ';
2306 $style2 =
'onclickopenref ';
2307 $style3 =
'onclickopenref ';
2308 $style4 =
'onclickopenref ';
2309 $string1 =
' ';
2310 $string2 =
' ';
2311 $string3 =
' ';
2312 $string4 =
' ';
2317 if (isset($cases1[$h])) {
2319 if (count($cases1[$h]) > 1) {
2320 $title1 .= count($cases1[$h]).
' '.(count($cases1[$h]) == 1 ? $langs->trans(
"Event") : $langs->trans(
"Events"));
2323 foreach ($cases1[$h] as
$id => $ev) {
2324 if (!empty($ev[
'busy']) && !
getDolGlobalString(
'AGENDA_NO_TRANSPARENT_ON_NOT_BUSY')) {
2325 $style1 .=
' peruser_busy';
2327 $style1 .=
'peruser_notbusy ';
2329 if (!empty($ev[
'css'])) {
2330 $style1 .= $ev[
'css'].
' ';
2334 if (isset($cases2[$h])) {
2336 if (count($cases2[$h]) > 1) {
2337 $title2 .= count($cases2[$h]).
' '.(count($cases2[$h]) == 1 ? $langs->trans(
"Event") : $langs->trans(
"Events"));
2340 foreach ($cases2[$h] as
$id => $ev) {
2341 if (!empty($ev[
'busy']) && !
getDolGlobalString(
'AGENDA_NO_TRANSPARENT_ON_NOT_BUSY')) {
2342 $style2 .=
' peruser_busy';
2344 $style2 .=
'peruser_notbusy ';
2346 if (!empty($ev[
'css'])) {
2347 $style2 .= $ev[
'css'].
' ';
2351 if (isset($cases3[$h])) {
2353 if (count($cases3[$h]) > 1) {
2354 $title3 .= count($cases3[$h]).
' '.(count($cases3[$h]) == 1 ? $langs->trans(
"Event") : $langs->trans(
"Events"));
2357 foreach ($cases3[$h] as
$id => $ev) {
2358 if (!empty($ev[
'busy']) && !
getDolGlobalString(
'AGENDA_NO_TRANSPARENT_ON_NOT_BUSY')) {
2359 $style3 .=
' peruser_busy';
2361 $style3 .=
'peruser_notbusy ';
2363 if (!empty($ev[
'css'])) {
2364 $style3 .= $ev[
'css'].
' ';
2368 if (isset($cases4[$h])) {
2370 if (count($cases4[$h]) > 1) {
2371 $title4 .= count($cases4[$h]).
' '.(count($cases4[$h]) == 1 ? $langs->trans(
"Event") : $langs->trans(
"Events"));
2374 foreach ($cases4[$h] as
$id => $ev) {
2375 if (!empty($ev[
'busy']) && !
getDolGlobalString(
'AGENDA_NO_TRANSPARENT_ON_NOT_BUSY')) {
2376 $style4 .=
' peruser_busy';
2378 $style4 .=
'peruser_notbusy ';
2380 if (!empty($ev[
'css'])) {
2381 $style4 .= $ev[
'css'].
' ';
2390 if (!empty($cases1[$h]) && is_array($cases1[$h]) && count($cases1[$h]) && array_keys($cases1[$h])) {
2391 $ids1 = implode(
', ', array_keys($cases1[$h]));
2393 if (!empty($cases2[$h]) && is_array($cases2[$h]) && count($cases2[$h]) && array_keys($cases2[$h])) {
2394 $ids2 = implode(
', ', array_keys($cases2[$h]));
2396 if (!empty($cases3[$h]) && is_array($cases3[$h]) && count($cases3[$h]) && array_keys($cases3[$h])) {
2397 $ids3 = implode(
',', array_keys($cases3[$h]));
2399 if (!empty($cases4[$h]) && is_array($cases4[$h]) && count($cases4[$h]) && array_keys($cases4[$h])) {
2400 $ids4 = implode(
',', array_keys($cases4[$h]));
2403 if ($h == $begin_h) {
2404 echo
'<td class="'.$style.
'_peruserleft cal_peruser'.($var ?
' cal_impair '.$style.
'_impair' :
'').
'">';
2406 echo
'<td class="'.$style.
' cal_peruser'.($var ?
' cal_impair '.$style.
'_impair' :
'').
'">';
2411 if (!empty($cases1[$h]) && is_array($cases1[$h]) && count($cases1[$h]) == 1) {
2412 $output = array_slice($cases1[$h], 0, 1);
2413 if ($output[0][
'typecode'] ==
'HOLIDAY') {
2415 $title1 = $langs->trans(
"Holiday");
2417 $title1 = $langs->trans(
"Ref").
' '.$ids1.($title1 ?
' - '.$title1 :
'');
2418 if ($output[0][
'string']) {
2419 $title1 .=
' - '.$output[0][
'string'];
2422 if ($output[0][
'color']) {
2423 $color1 = $output[0][
'color'];
2425 } elseif (!empty($cases1[$h]) && is_array($cases1[$h]) && count($cases1[$h]) > 1) {
2426 $title1 = $langs->trans(
"Ref").
' '.$ids1.($title1 ?
' - '.$title1 :
'');
2432 if (!empty($cases2[$h]) && is_array($cases2[$h]) && count($cases2[$h]) == 1) {
2433 $output = array_slice($cases2[$h], 0, 1);
2434 if ($output[0][
'typecode'] ==
'HOLIDAY') {
2436 $title2 = $langs->trans(
"Holiday");
2438 $title2 = $langs->trans(
"Ref").
' '.$ids2.($title2 ?
' - '.$title2 :
'');
2439 if ($output[0][
'string']) {
2440 $title2 .=
' - '.$output[0][
'string'];
2443 if ($output[0][
'color']) {
2444 $color2 = $output[0][
'color'];
2446 } elseif (!empty($cases2[$h]) && is_array($cases2[$h]) && count($cases2[$h]) > 1) {
2447 $title2 = $langs->trans(
"Ref").
' '.$ids2.($title2 ?
' - '.$title2 :
'');
2453 if (!empty($cases3[$h]) && is_array($cases3[$h]) && count($cases3[$h]) == 1) {
2454 $output = array_slice($cases3[$h], 0, 1);
2455 if ($output[0][
'typecode'] ==
'HOLIDAY') {
2457 $title3 = $langs->trans(
"Holiday");
2459 $title3 = $langs->trans(
"Ref").
' '.$ids3.($title3 ?
' - '.$title3 :
'');
2460 if ($output[0][
'string']) {
2461 $title3 .=
' - '.$output[0][
'string'];
2464 if ($output[0][
'color']) {
2465 $color3 = $output[0][
'color'];
2467 } elseif (!empty($cases3[$h]) && is_array($cases3[$h]) && count($cases3[$h]) > 1) {
2468 $title3 = $langs->trans(
"Ref").
' '.$ids3.($title3 ?
' - '.$title3 :
'');
2474 if (!empty($cases4[$h]) && is_array($cases4[$h]) && count($cases4[$h]) == 1) {
2475 $output = array_slice($cases4[$h], 0, 1);
2476 if ($output[0][
'typecode'] ==
'HOLIDAY') {
2478 $title4 = $langs->trans(
"Holiday");
2480 $title4 = $langs->trans(
"Ref").
' '.$ids4.($title4 ?
' - '.$title4 :
'');
2481 if ($output[0][
'string']) {
2482 $title4 .=
' - '.$output[0][
'string'];
2485 if ($output[0][
'color']) {
2486 $color4 = $output[0][
'color'];
2488 } elseif (!empty($cases4[$h]) && is_array($cases4[$h]) && count($cases4[$h]) > 1) {
2489 $title4 = $langs->trans(
"Ref").
' '.$ids4.($title4 ?
' - '.$title4 :
'');
2493 print
'<table class="nobordernopadding case centpercent">';
2496 if (preg_match(
'/peruser_notbusy/', $style1)) {
2497 print
'style="border: 1px solid #'.($color1 ? $color1 :
"888").
' !important" ';
2498 } elseif ($color1) {
2499 print
'style="background: #'.$color1.
'; "';
2503 print
'center'.($title1 ?
' classfortooltip' :
'').($title1 ?
' cursorpointer' :
'').
'"';
2504 print
'ref="'.$ref1.
'_'.$username->id.
'_'.sprintf(
"%04d", $year).
'_'.sprintf(
"%02d", $month).
'_'.sprintf(
"%02d", $day).
'_'.sprintf(
"%02d", $h).
'_00_'.($ids1 ? $ids1 :
'none').
'"';
2505 print ($title1 ?
' title="'.$title1.
'"' :
'').
'>';
2510 if (preg_match(
'/peruser_notbusy/', $style2)) {
2511 print
'style="border: 1px solid #'.($color2 ? $color2 :
"888").
' !important" ';
2512 } elseif ($color2) {
2513 print
'style="background: #'.$color2.
'; "';
2517 print
'center'.($title2 ?
' classfortooltip' :
'').($title2 ?
' cursorpointer' :
'').
'"';
2518 print
' ref="'.$ref2.
'_'.$username->id.
'_'.sprintf(
"%04d", $year).
'_'.sprintf(
"%02d", $month).
'_'.sprintf(
"%02d", $day).
'_'.sprintf(
"%02d", $h).
'_15_'.($ids2 ? $ids2 :
'none').
'"';
2519 print ($title2 ?
' title="'.$title2.
'"' :
'').
'>';
2524 if (preg_match(
'/peruser_notbusy/', $style3)) {
2525 print
'style="border: 1px solid #'.($color3 ? $color3 :
"888").
' !important" ';
2526 } elseif ($color3) {
2527 print
'style="background: #'.$color3.
'; "';
2531 print
'center'.($title3 ?
' classfortooltip' :
'').($title3 ?
' cursorpointer' :
'').
'"';
2532 print
' ref="'.$ref3.
'_'.$username->id.
'_'.sprintf(
"%04d", $year).
'_'.sprintf(
"%02d", $month).
'_'.sprintf(
"%02d", $day).
'_'.sprintf(
"%02d", $h).
'_30_'.($ids3 ? $ids3 :
'none').
'"';
2533 print ($title3 ?
' title="'.$title3.
'"' :
'').
'>';
2538 if (preg_match(
'/peruser_notbusy/', $style4)) {
2539 print
'style="border: 1px solid #'.($color4 ? $color4 :
"888").
' !important" ';
2540 } elseif ($color4) {
2541 print
'style="background: #'.$color4.
'; "';
2545 print
'center'.($title4 ?
' classfortooltip' :
'').($title4 ?
' cursorpointer' :
'').
'"';
2546 print
' ref="'.$ref4.
'_'.$username->id.
'_'.sprintf(
"%04d", $year).
'_'.sprintf(
"%02d", $month).
'_'.sprintf(
"%02d", $day).
'_'.sprintf(
"%02d", $h).
'_45_'.($ids4 ? $ids4 :
'none').
'"';
2547 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.