34require
'../../main.inc.php';
35require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/user/class/usergroup.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/lib/agenda.lib.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
55$disabledefaultvalues =
GETPOSTINT(
'disabledefaultvalues');
58$filter =
GETPOST(
"search_filter",
'alpha', 3) ?
GETPOST(
"search_filter",
'alpha', 3) :
GETPOST(
"filter",
'alpha', 3);
70$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
71$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
73if (empty($page) || $page == -1) {
77$offset = $limit * $page;
82 $sortfield =
"a.datec";
88 $socid = $user->socid;
95if (!$user->hasRight(
'agenda',
'myactions',
'read')) {
98if (!$user->hasRight(
'agenda',
'allactions',
'read')) {
101if (!$user->hasRight(
'agenda',
'allactions',
'read') || $filter ==
'mine') {
102 $filtert = (string) $user->id;
105$action =
GETPOST(
'action',
'aZ09');
107$mode =
'show_peruser';
113$pid = GETPOSTISSET(
"search_projectid") ?
GETPOSTINT(
"search_projectid", 3) :
GETPOSTINT(
"projectid", 3);
114$status = GETPOSTISSET(
"search_status") ?
GETPOST(
"search_status",
'aZ09') :
GETPOST(
"status",
'aZ09');
115$type = GETPOSTISSET(
"search_type") ?
GETPOST(
"search_type",
'aZ09') :
GETPOST(
"type",
'aZ09');
117$optioncss =
GETPOST(
'optioncss',
'aZ');
120if (
GETPOST(
'search_actioncode',
'array:aZ09')) {
121 $actioncode =
GETPOST(
'search_actioncode',
'array:aZ09', 3);
122 if (!count($actioncode)) {
126 $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')));
130if ($dateselect > 0) {
137$tmp = str_replace(
' ',
'', $tmp);
138$tmparray = explode(
'-', $tmp);
139$begin_h = GETPOSTISSET(
'begin_h') ?
GETPOSTINT(
'begin_h') : ($tmparray[0] !=
'' ? $tmparray[0] : 9);
140$end_h = GETPOSTISSET(
'end_h') ?
GETPOSTINT(
'end_h') : ($tmparray[1] !=
'' ? $tmparray[1] : 18);
141if ($begin_h < 0 || $begin_h > 23) {
144if ($end_h < 1 || $end_h > 24) {
147if ($end_h <= $begin_h) {
148 $end_h = $begin_h + 1;
152$tmp = str_replace(
' ',
'', $tmp);
153$tmparray = explode(
'-', $tmp);
154$begin_d = GETPOSTISSET(
'begin_d') ?
GETPOSTINT(
'begin_d') : ($tmparray[0] !=
'' ? $tmparray[0] : 1);
155$end_d = GETPOSTISSET(
'end_d') ?
GETPOSTINT(
'end_d') : ($tmparray[1] !=
'' ? $tmparray[1] : 5);
156if ($begin_d < 1 || $begin_d > 7) {
159if ($end_d < 1 || $end_d > 7) {
162if ($end_d < $begin_d) {
163 $end_d = $begin_d + 1;
166if ($status ==
'' && !GETPOSTISSET(
'search_status')) {
170if (empty($mode) && !GETPOSTISSET(
'mode')) {
174if (
GETPOST(
'viewcal',
'alpha') && $mode !=
'show_day' && $mode !=
'show_week' && $mode !=
'show_peruser') {
175 $mode =
'show_month';
178if (
GETPOST(
'viewweek',
'alpha') || $mode ==
'show_week') {
180 $week = ($week ? $week : date(
"W"));
181 $day = ($day ? $day : date(
"d"));
183if (
GETPOST(
'viewday',
'alpha') || $mode ==
'show_day') {
185 $day = ($day ? $day : date(
"d"));
191$langs->loadLangs(array(
'users',
'agenda',
'other',
'commercial'));
194$hookmanager->initHooks(array(
'agenda'));
196$result =
restrictedArea($user,
'agenda', 0,
'actioncomm&societe',
'myactions|allactions',
'fk_soc',
'id');
197if ($user->socid && $socid) {
201$search_status = $status;
222 'maxprint' => $maxprint,
224 'filtert' => $filtert,
225 'showbirthday' => $showbirthday,
226 'canedit' => $canedit,
227 'optioncss' => $optioncss,
228 'actioncode' => $actioncode,
230 'resourceid' => $resourceid,
231 'usergroup' => $usergroup,
233$reshook = $hookmanager->executeHooks(
'beforeAgendaPerUser', $parameters, $object, $action);
238$form =
new Form($db);
239$companystatic =
new Societe($db);
241$help_url =
'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda|DE:Modul_Terminplanung';
242llxHeader(
'', $langs->trans(
"Agenda"), $help_url);
246$nowyear = $nowarray[
'year'];
247$nowmonth = $nowarray[
'mon'];
248$nowday = $nowarray[
'mday'];
251$listofextcals = array();
256 while ($i < $MAXAGENDA) {
258 $source =
'AGENDA_EXT_SRC'.$i;
259 $name =
'AGENDA_EXT_NAME'.$i;
260 $offsettz =
'AGENDA_EXT_OFFSETTZ'.$i;
261 $color =
'AGENDA_EXT_COLOR'.$i;
262 $default =
'AGENDA_EXT_ACTIVEBYDEFAULT'.$i;
263 $buggedfile =
'AGENDA_EXT_BUGGEDFILE'.$i;
266 $listofextcals[] = array(
267 'type' =>
'globalsetup',
283 while ($i < $MAXAGENDA) {
285 $source =
'AGENDA_EXT_SRC_'.$user->id.
'_'.$i;
286 $name =
'AGENDA_EXT_NAME_'.$user->id.
'_'.$i;
287 $offsettz =
'AGENDA_EXT_OFFSETTZ_'.$user->id.
'_'.$i;
288 $color =
'AGENDA_EXT_COLOR_'.$user->id.
'_'.$i;
289 $enabled =
'AGENDA_EXT_ENABLED_'.$user->id.
'_'.$i;
290 $default =
'AGENDA_EXT_ACTIVEBYDEFAULT_'.$user->id.
'_'.$i;
291 $buggedfile =
'AGENDA_EXT_BUGGEDFILE_'.$user->id.
'_'.$i;
295 $listofextcals[] = array(
296 'type' =>
'usersetup',
299 'offsettz' => (
int) (empty($user->conf->$offsettz) ? 0 : $user->
conf->$offsettz),
311$first_day = $prev[
'first_day'];
312$first_month = $prev[
'first_month'];
313$first_year = $prev[
'first_year'];
315$week = $prev[
'week'];
319$next_year = $next[
'year'];
320$next_month = $next[
'month'];
321$next_day = $next[
'day'];
323$max_day_in_month = date(
"t",
dol_mktime(0, 0, 0, $month, 1, $year));
329$title = $langs->trans(
"DoneAndToDoActions");
330if ($status ==
'done') {
331 $title = $langs->trans(
"DoneActions");
333if ($status ==
'todo') {
334 $title = $langs->trans(
"ToDoActions");
338if ($actioncode || GETPOSTISSET(
'search_actioncode')) {
339 if (is_array($actioncode)) {
340 foreach ($actioncode as $str_action) {
341 $param .=
"&search_actioncode[]=".urlencode($str_action);
344 $param .=
"&search_actioncode=".urlencode($actioncode);
347if ($resourceid > 0) {
348 $param .=
"&search_resourceid=".urlencode((
string) ($resourceid));
351if ($status || GETPOSTISSET(
'status') || GETPOSTISSET(
'search_status')) {
352 $param .=
"&search_status=".urlencode($status);
355 $param .=
"&search_filter=".urlencode((
string) $filter);
358 $param .=
"&search_filtert=".urlencode((
string) $filtert);
361 $param .=
"&search_usergroup=".urlencode((
string) ($usergroup));
364 $param .=
"&search_socid=".urlencode((
string) ($socid));
367 $param .=
"&search_showbirthday=1";
370 $param .=
"&search_projectid=".urlencode((
string) ($pid));
373 $param .=
"&search_type=".urlencode($type);
375if ($mode !=
'show_peruser') {
376 $param .=
'&mode='.urlencode((
string) $mode);
379 $param .=
'&begin_h='.((int) $begin_h);
382 $param .=
'&end_h='.((int) $end_h);
385 $param .=
'&begin_d='.((int) $begin_d);
388 $param .=
'&end_d='.((int) $end_d);
390if ($search_categ_cus != 0) {
391 $param .=
'&search_categ_cus='.urlencode((
string) ($search_categ_cus));
393$param .=
"&maxprint=".urlencode((
string) ($maxprint));
395$paramnoactionodate = $param;
400$prev_year = $prev[
'prev_year'];
401$prev_month = $prev[
'prev_month'];
402$prev_day = $prev[
'prev_day'];
403$first_day = $prev[
'first_day'];
404$first_month = $prev[
'first_month'];
405$first_year = $prev[
'first_year'];
407$week = $prev[
'week'];
411$next_year = $next[
'year'];
412$next_month = $next[
'month'];
413$next_day = $next[
'day'];
417$firstdaytoshow =
dol_mktime(0, 0, 0, $first_month, $first_day, $first_year,
'tzuserrel');
418$nb_weeks_to_show = (
getDolGlobalString(
'AGENDA_NB_WEEKS_IN_VIEW_PER_USER')) ? ((
int)
$conf->global->AGENDA_NB_WEEKS_IN_VIEW_PER_USER * 7) : 7;
424$max_day_in_month = idate(
"t",
dol_mktime(0, 0, 0, $month, 1, $year,
'gmt'));
427$picto =
'calendarweek';
430$nav =
'<div class="navselectiondate inline-block nowraponall">';
431$nav .=
"<a href=\"?year=".$prev_year.
"&month=".$prev_month.
"&day=".$prev_day.$param.
"\"><i class=\"fa fa-chevron-left\" title=\"".
dol_escape_htmltag($langs->trans(
"Previous")).
"\"></i></a> \n";
432$nav .=
" <span id=\"month_name\">".dol_print_date(
dol_mktime(0, 0, 0, $first_month, $first_day, $first_year),
"%Y").
", ".$langs->trans(
"Week").
" ".$week;
434$nav .=
" <a href=\"?year=".$next_year.
"&month=".$next_month.
"&day=".$next_day.$param.
"\"><i class=\"fa fa-chevron-right\" title=\"".
dol_escape_htmltag($langs->trans(
"Next")).
"\"></i></a>\n";
435if (empty(
$conf->dol_optimize_smallscreen)) {
436 $nav .=
' <a href="?year='.$nowyear.
'&month='.$nowmonth.
'&day='.$nowday.$param.
'" class="datenowlink marginleftonly marginrightonly">'.$langs->trans(
"Today").
'</a> ';
439$nav .= $form->selectDate($dateselect,
'dateselect', 0, 0, 1,
'', 1, 0);
441$nav .=
'<button type="submit" class="liste_titre button_search valignmiddle" name="button_search_x" value="x"><span class="fa fa-search"></span></button>';
444$paramnodate = $param;
445$param .=
'&year='.$year.
'&month='.$month.($day ?
'&day='.$day :
'');
449$paramnoaction = preg_replace(
'/mode=[a-z_]+/',
'', preg_replace(
'/action=[a-z_]+/',
'', $param));
450$paramnoactionodate = preg_replace(
'/mode=[a-z_]+/',
'', preg_replace(
'/action=[a-z_]+/',
'', $paramnodate));
454print
'<form method="POST" id="searchFormList" class="listactionsfilter" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
455if ($optioncss !=
'') {
456 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
458print
'<input type="hidden" name="token" value="'.newToken().
'">';
459print
'<input type="hidden" name="mode" value="'.$mode.
'">';
462$mode =
'show_peruser';
463$massactionbutton =
'';
466$viewmode =
'<div class="navmode inline-block">';
468$viewmode .=
'<a class="btnTitle reposition" href="'.DOL_URL_ROOT.
'/comm/action/list.php?mode=show_list&restore_lastsearch_values=1'.$paramnoactionodate.
'">';
470$viewmode .=
img_picto($langs->trans(
"List"),
'object_calendarlist',
'class="imgforviewmode pictoactionview block"');
472$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow">'.$langs->trans(
"ViewList").
'</span></a>';
476$viewmode .=
img_picto($langs->trans(
"ViewCal"),
'object_calendarmonth',
'class="pictoactionview block"');
478$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow">'.$langs->trans(
"ViewCal").
'</span></a>';
482$viewmode .=
img_picto($langs->trans(
"ViewWeek"),
'object_calendarweek',
'class="pictoactionview block"');
484$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow">'.$langs->trans(
"ViewWeek").
'</span></a>';
488$viewmode .=
img_picto($langs->trans(
"ViewDay"),
'object_calendarday',
'class="pictoactionview block"');
490$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow">'.$langs->trans(
"ViewDay").
'</span></a>';
494$viewmode .=
img_picto($langs->trans(
"ViewPerUser"),
'object_calendarperuser',
'class="pictoactionview block"');
496$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow" title="'.dolPrintHTML($langs->trans(
"ViewPerUser")).
'">'.$langs->trans(
"ViewPerUser").
'</span></a>';
499$parameters = array();
501$reshook = $hookmanager->executeHooks(
'addCalendarView', $parameters, $object, $action);
502if (empty($reshook)) {
503 $viewmode .= $hookmanager->resPrint;
504} elseif ($reshook > 1) {
505 $viewmode = $hookmanager->resPrint;
508$viewmode .=
'</div>';
510$viewmode .=
'<span class="marginrightonly"></span>';
515if ($user->hasRight(
'agenda',
'myactions',
'create') || $user->hasRight(
'agenda',
'allactions',
'create')) {
518 $newparam .=
'&month='.urlencode(str_pad((
string) $month, 2,
"0", STR_PAD_LEFT)).
'&year='.((int) $tmpforcreatebutton[
'year']);
519 if ($begin_h !==
'') {
520 $newparam .=
'&begin_h='.((int) $begin_h);
523 $newparam .=
'&end_h='.((int) $end_h);
525 if ($begin_d !==
'') {
526 $newparam .=
'&begin_d='.((int) $begin_d);
529 $newparam .=
'&end_d='.((int) $end_d);
532 $urltocreateaction = DOL_URL_ROOT.
'/comm/action/card.php?action=create';
533 $urltocreateaction .=
'&apyear='.$tmpforcreatebutton[
'year'].
'&apmonth='.$tmpforcreatebutton[
'mon'].
'&apday='.$tmpforcreatebutton[
'mday'].
'&aphour='.$tmpforcreatebutton[
'hours'].
'&apmin='.$tmpforcreatebutton[
'minutes'];
534 $urltocreateaction .=
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"] . $newparam);
536 $newcardbutton .=
dolGetButtonTitle($langs->trans(
"AddAction"),
'',
'fa fa-plus-circle', $urltocreateaction);
545$showextcals = $listofextcals;
546$bookcalcalendars = array();
549if (isModEnabled(
"bookcal")) {
550 $sql =
"SELECT ba.rowid, bc.label, bc.ref, bc.rowid as id_cal";
551 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bookcal_availabilities as ba";
552 $sql .=
" JOIN ".MAIN_DB_PREFIX.
"bookcal_calendar as bc";
553 $sql .=
" ON bc.rowid = ba.fk_bookcal_calendar";
554 $sql .=
" WHERE bc.status = 1";
555 $sql .=
" AND ba.status = 1";
556 $sql .=
" AND bc.entity IN (".getEntity(
'agenda').
")";
557 if (!empty($filtert) && $filtert !=
'-1') {
558 $sql .=
" AND bc.visibility IN (".$db->sanitize($filtert, 0, 0, 0, 0).
")";
560 $resql = $db->query($sql);
562 $num = $db->num_rows($resql);
565 $objp = $db->fetch_object($resql);
566 $label = !empty($objp->label) ? $objp->label : $objp->ref;
567 $bookcalcalendars[
"calendars"][] = array(
"id" => $objp->id_cal,
"label" => $label);
568 $bookcalcalendars[
"availabilitieslink"][$objp->rowid] = $objp->id_cal;
576if (!empty(
$conf->use_javascript_ajax)) {
577 $s .=
"\n".
'<!-- Div to calendars selectors -->'.
"\n";
579 $s .=
'<script type="text/javascript">'.
"\n";
580 $s .=
'jQuery(document).ready(function () {'.
"\n";
581 $s .=
'jQuery(".check_birthday").click(function() { console.log("Toggle class .peruser_birthday"); jQuery(".peruser_birthday").addClass("peruser_birthday_imp"); });'.
"\n";
582 $s .=
'jQuery(".check_holiday").click(function() { console.log("Toggle class .peruser_holiday"); if (jQuery(".peruser_holiday").hasClass("peruser_holiday_imp")) { jQuery(".peruser_holiday").removeClass("peruser_holiday_imp"); } else { jQuery(".peruser_holiday").addClass("peruser_holiday_imp"); } });'.
"\n";
583 if (isModEnabled(
"bookcal") && !empty($bookcalcalendars[
"calendars"])) {
584 foreach ($bookcalcalendars[
"calendars"] as $key => $value) {
585 $s .=
'jQuery(".check_bookcal_calendar_'.$value[
'id'].
'").click(function() { console.log("Toggle Bookcal Calendar '.$value[
'id'].
'"); jQuery(".family_bookcal_calendar_'.$value[
'id'].
'").toggle(); });'.
"\n";
589 $s .=
'</script>'.
"\n";
592 $s .=
'<div class="nowrap inline-block minheight30"><input type="checkbox" id="check_mytasks" name="check_mytasks" value="1" checked disabled><label class="labelcalendar"><span class="check_holiday_text"> '.$langs->trans(
"LocalAgenda").
' </span></label></div>';
595 if ($user->hasRight(
"holiday",
"read")) {
597 <div class="nowrap inline-block minheight30"><input type="checkbox" id="check_holiday" name="check_holiday" value="1" class="check_holiday"' . ($check_holiday ?
' checked' :
'') .
'>
598 <label for="check_holiday" class="labelcalendar">
599 <span class="check_holiday_text">' . $langs->trans(
"Holidays") .
'</span>
605 if (count($showextcals) > 0) {
606 foreach ($showextcals as $val) {
607 $htmlname = md5($val[
'name']);
609 $s .=
'<script type="text/javascript">'.
"\n";
610 $s .=
'jQuery(document).ready(function () {'.
"\n";
611 $s .=
' jQuery("#check_ext'.$htmlname.
'").click(function() {';
612 $s .=
' /* alert("'.$htmlname.
'"); */';
613 $s .=
' jQuery(".family_ext'.$htmlname.
'").toggle();';
616 $s .=
'</script>'.
"\n";
617 $s .=
'<div class="nowrap float"><input type="checkbox" id="check_ext'.$htmlname.
'" name="check_ext'.$htmlname.
'" checked> '.$val [
'name'].
' </div>';
641 $parameters = array();
642 $reshook = $hookmanager->executeHooks(
'addCalendarChoice', $parameters, $object, $action);
643 if (empty($reshook)) {
644 $s .= $hookmanager->resPrint;
645 } elseif ($reshook > 1) {
646 $s = $hookmanager->resPrint;
649 $s .=
"\n".
'<!-- End div to calendars selectors -->'.
"\n";
652 $newparam = preg_replace(
'/showbirthday=[0-1]/i',
'showbirthday='.(empty($showbirthday) ? 1 : 0), $newparam);
653 if (!preg_match(
'/showbirthday=/i', $newparam)) {
654 $newparam .=
'&showbirthday=1';
658 if (empty($showbirthday)) {
659 $link .= $langs->trans(
"AgendaShowBirthdayEvents");
661 $link .= $langs->trans(
"AgendaHideBirthdayEvents");
668$eventarray = array();
676$sql .=
" a.id, a.label,";
679$sql .=
" a.percent,";
680$sql .=
" a.fk_user_author,a.fk_user_action,";
681$sql .=
" a.transparency, a.priority, a.fulldayevent, a.location,";
682$sql .=
" a.fk_soc, a.fk_contact, a.fk_project, a.fk_bookcal_calendar,";
683$sql .=
" a.fk_element, a.elementtype,";
684$sql .=
" ca.code as type_code, ca.libelle as type_label, ca.color as type_color, ca.type as type_type, ca.picto as type_picto";
686$parameters = array();
687$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
688$sql .= $hookmanager->resPrint;
690$sql .=
" FROM ".MAIN_DB_PREFIX.
"c_actioncomm as ca, ".MAIN_DB_PREFIX.
"actioncomm as a";
692if ($resourceid > 0) {
693 $sql .=
", ".MAIN_DB_PREFIX.
"element_resources as r";
696if ($filtert > 0 || $usergroup > 0) {
697 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"actioncomm_resources as ar";
698 $sql .=
" ON ar.fk_actioncomm = a.id AND ar.element_type='user'";
700 $sql .=
" AND ar.fk_element = ".((int) $filtert);
702 if ($usergroup > 0) {
703 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"usergroup_user as ugu ON ugu.fk_user = ar.fk_element AND ugu.fk_usergroup = ".((int) $usergroup);
707$sql .=
" WHERE a.fk_action = ca.id";
708$sql .=
" AND a.entity IN (".getEntity(
'agenda').
")";
710if (!empty($actioncode)) {
712 if ($actioncode ==
'AC_NON_AUTO') {
713 $sql .=
" AND ca.type != 'systemauto'";
714 } elseif ($actioncode ==
'AC_ALL_AUTO') {
715 $sql .=
" AND ca.type = 'systemauto'";
717 if ($actioncode ==
'AC_OTH') {
718 $sql .=
" AND ca.type != 'systemauto'";
720 if ($actioncode ==
'AC_OTH_AUTO') {
721 $sql .=
" AND ca.type = 'systemauto'";
725 if ($actioncode ==
'AC_NON_AUTO') {
726 $sql .=
" AND ca.type != 'systemauto'";
727 } elseif ($actioncode ==
'AC_ALL_AUTO') {
728 $sql .=
" AND ca.type = 'systemauto'";
729 } elseif ( $actioncode !==
'-1') {
730 if (is_array($actioncode)) {
731 $sql .=
" AND ca.code IN (".$db->sanitize(
"'".implode(
"','", $actioncode).
"'", 1).
")";
733 $sql .=
" AND ca.code IN (".$db->sanitize(
"'".implode(
"','", explode(
',', $actioncode)).
"'", 1).
")";
738if ($resourceid > 0) {
739 $sql .=
" AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".((int) $resourceid);
742 $sql .=
" AND a.fk_project = ".((int) $pid);
746if (isModEnabled(
"societe") && !$user->hasRight(
'societe',
'client',
'voir')) {
747 $search_sale = $user->id;
750if ($search_sale && $search_sale !=
'-1') {
751 if ($search_sale == -2) {
752 $sql .=
" AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = a.fk_soc)";
753 } elseif ($search_sale > 0) {
754 $sql .=
" AND EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = a.fk_soc AND sc.fk_user = ".((int) $search_sale).
")";
759 $sql .=
" AND a.fk_soc = ".((int) $socid);
762if ($mode ==
'show_day') {
764 $sql .=
" (a.datep BETWEEN '".$db->idate(
dol_mktime(0, 0, 0, $month, $day, $year,
'tzuserrel')).
"'";
765 $sql .=
" AND '".$db->idate(
dol_mktime(23, 59, 59, $month, $day, $year,
'tzuserrel')).
"')";
767 $sql .=
" (a.datep2 BETWEEN '".$db->idate(
dol_mktime(0, 0, 0, $month, $day, $year,
'tzuserrel')).
"'";
768 $sql .=
" AND '".$db->idate(
dol_mktime(23, 59, 59, $month, $day, $year,
'tzuserrel')).
"')";
770 $sql .=
" (a.datep < '".$db->idate(
dol_mktime(0, 0, 0, $month, $day, $year,
'tzuserrel')).
"'";
771 $sql .=
" AND a.datep2 > '".$db->idate(
dol_mktime(23, 59, 59, $month, $day, $year,
'tzuserrel')).
"')";
776 $sql .=
" (a.datep BETWEEN '".$db->idate($firstdaytoshow - (60 * 60 * 24 * 2)).
"'";
777 $sql .=
" AND '".$db->idate($lastdaytoshow + (60 * 60 * 24 * 2)).
"')";
779 $sql .=
" (a.datep2 BETWEEN '".$db->idate($firstdaytoshow - (60 * 60 * 24 * 2)).
"'";
780 $sql .=
" AND '".$db->idate($lastdaytoshow + (60 * 60 * 24 * 2)).
"')";
782 $sql .=
" (a.datep < '".$db->idate($firstdaytoshow - (60 * 60 * 24 * 2)).
"'";
783 $sql .=
" AND a.datep2 > '".$db->idate($lastdaytoshow + (60 * 60 * 24 * 2)).
"')";
787 $sql .=
" AND ca.id = ".((int) $type);
791 $sql .=
" AND a.percent = 0";
793if ($status ===
'na') {
795 $sql .=
" AND a.percent = -1";
797if ($status ==
'50') {
799 $sql .=
" AND (a.percent > 0 AND a.percent < 100)";
801if ($status ==
'done' || $status ==
'100') {
802 $sql .=
" AND (a.percent = 100)";
804if ($status ==
'todo') {
805 $sql .=
" AND (a.percent >= 0 AND a.percent < 100)";
808if ($filtert > 0 || $usergroup > 0) {
811 $sql .=
"ar.fk_element = ".((int) $filtert);
813 if ($usergroup > 0) {
814 $sql .= ($filtert > 0 ?
" OR " :
"").
" ugu.fk_usergroup = ".((
int) $usergroup);
820if ($search_categ_cus != -1) {
821 if ($search_categ_cus == -2) {
822 $sql .=
" AND NOT EXISTS (SELECT ca.fk_actioncomm FROM ".MAIN_DB_PREFIX.
"categorie_actioncomm as ca WHERE ca.fk_actioncomm = a.id)";
823 } elseif ($search_categ_cus > 0) {
824 $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($search_categ_cus).
"))";
828$sql .= $db->order(
"fk_user_action, datep");
831dol_syslog(
"comm/action/peruser.php", LOG_DEBUG);
832$resql = $db->query($sql);
834 $num = $db->num_rows($resql);
836 $MAXONSAMEPAGE = 10000;
838 while ($i < $num && $i < $MAXONSAMEPAGE) {
839 $obj = $db->fetch_object($resql);
843 if (
getDolGlobalString(
'AGENDA_ALWAYS_HIDE_AUTO') && $obj->type_code ==
'AC_OTH_AUTO') {
848 $datep = $db->jdate($obj->datep);
849 $datep2 = $db->jdate($obj->datep2);
855 $event->id = $obj->id;
856 $event->ref = (string) $event->id;
858 $event->fulldayevent = $obj->fulldayevent;
861 if ($event->fulldayevent) {
863 $event->datep = $db->jdate($obj->datep, $tzforfullday ?
'tzuser' :
'tzserver');
864 $event->datef = $db->jdate($obj->datep2, $tzforfullday ?
'tzuser' :
'tzserver');
867 $event->datep = $db->jdate($obj->datep,
'tzserver');
868 $event->datef = $db->jdate($obj->datep2,
'tzserver');
874 $event->type_code = $obj->type_code;
875 $event->type_label = $obj->type_label;
876 $event->type_color = $obj->type_color;
877 $event->type = $obj->type_type;
878 $event->type_picto = $obj->type_picto;
880 $event->label = $obj->label;
881 $event->percentage = $obj->percent;
882 $event->authorid = $obj->fk_user_author;
883 $event->userownerid = $obj->fk_user_action;
884 $event->fetch_userassigned();
886 $event->priority = $obj->priority;
887 $event->location = $obj->location;
888 $event->transparency = $obj->transparency;
889 $event->fk_element = $obj->fk_element;
890 $event->elementid = $obj->fk_element;
891 $event->elementtype = $obj->elementtype;
893 $event->fk_project = $obj->fk_project;
895 $event->socid = $obj->fk_soc;
896 $event->contact_id = $obj->fk_contact;
897 $event->fk_bookcal_calendar = $obj->fk_bookcal_calendar;
898 if (!empty($event->fk_bookcal_calendar)) {
899 $event->type =
"bookcal_calendar";
904 $event->date_start_in_calendar = $event->datep;
905 if ($event->datef !=
'' && $event->datef >= $event->datep) {
906 $event->date_end_in_calendar = $event->datef;
908 $event->date_end_in_calendar = $event->datep;
914 if ($event->date_end_in_calendar < $firstdaytoshow || $event->date_start_in_calendar >= $lastdaytoshow) {
918 if ($event->date_start_in_calendar < $firstdaytoshow) {
919 $event->date_start_in_calendar = $firstdaytoshow;
921 if ($event->date_end_in_calendar >= $lastdaytoshow) {
922 $event->date_end_in_calendar = ($lastdaytoshow - 1);
926 $daycursor = $event->date_start_in_calendar;
931 $daycursorend = $event->date_end_in_calendar;
932 $anneeend = (int)
dol_print_date($daycursorend,
'%Y',
'tzuserrel');
933 $moisend = (int)
dol_print_date($daycursorend,
'%m',
'tzuserrel');
934 $jourend = (int)
dol_print_date($daycursorend,
'%d',
'tzuserrel');
939 $daykey =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
940 $daykeyend =
dol_mktime(0, 0, 0, $moisend, $jourend, $anneeend,
'gmt');
954 $eventarray[$daykey][] = $event;
957 $daykey += 60 * 60 * 24;
959 if ($daykey > $daykeyend) {
968 $parameters[
'obj'] = $obj;
969 $reshook = $hookmanager->executeHooks(
'hookEventElements', $parameters, $event, $action);
970 $event = $hookmanager->resPrint;
988 $sql =
'SELECT sp.rowid, sp.lastname, sp.firstname, sp.birthday';
989 $sql .=
' FROM '.MAIN_DB_PREFIX.
'socpeople as sp';
990 $sql .=
' WHERE (priv=0 OR (priv=1 AND fk_user_creat='.((int) $user->id).
'))';
991 $sql .=
" AND sp.entity IN (".getEntity(
'contact').
")";
992 if ($mode ==
'show_day') {
993 $sql .=
' AND MONTH(birthday) = '.((int) $month);
994 $sql .=
' AND DAY(birthday) = '.((int) $day);
996 $sql .=
' AND MONTH(birthday) = '.((int) $month);
998 $sql .=
' ORDER BY birthday';
1000 dol_syslog(
"comm/action/index.php", LOG_DEBUG);
1001 $resql = $db->query($sql);
1003 $num = $db->num_rows($resql);
1006 $obj = $db->fetch_object($resql);
1010 $event->id = $obj->rowid;
1011 $event->ref = (string) $event->id;
1016 $event->datep =
dol_mktime(0, 0, 0, $datearray[
'mon'], $datearray[
'mday'], $year,
true);
1017 $event->datef = $event->datep;
1019 $event->type_code =
'BIRTHDAY';
1020 $event->type_label =
'';
1021 $event->type_color =
'';
1022 $event->type =
'birthdate';
1023 $event->type_picto =
'birthdate';
1025 $event->label = $langs->trans(
"Birthday").
' '.
dolGetFirstLastname($obj->firstname, $obj->lastname);
1026 $event->percentage = 100;
1027 $event->fulldayevent = 1;
1029 $event->contact_id = $obj->rowid;
1031 $event->date_start_in_calendar = $db->jdate($event->datep);
1032 $event->date_end_in_calendar = $db->jdate($event->datef);
1035 $daycursor = $event->datep;
1040 $daykey =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
1042 $eventarray[$daykey][] = $event;
1059if ($user->hasRight(
"holiday",
"read")) {
1061 $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";
1062 $sql .=
" FROM ".MAIN_DB_PREFIX.
"holiday as x, ".MAIN_DB_PREFIX.
"user as u";
1063 $sql .=
" WHERE u.rowid = x.fk_user";
1064 $sql .=
" AND u.statut = '1'";
1065 $sql .=
" AND (x.statut = '2' OR x.statut = '3')";
1067 $sql .=
" AND x.date_debut < '".$db->idate(
dol_get_last_day($year, $month)).
"'";
1068 $sql .=
" AND x.date_fin >= '".$db->idate(
dol_get_first_day($year, $month)).
"'";
1069 if (!$user->hasRight(
'holiday',
'readall')) {
1070 $sql.=
" AND x.fk_user IN(".$db->sanitize(implode(
", ", $user->getAllChildIds(1))).
") ";
1073 $resql = $db->query($sql);
1075 $num = $db->num_rows($resql);
1079 $obj = $db->fetch_object($resql);
1084 $event->id = $obj->rowid;
1085 $event->ref = (string) $event->id;
1087 $event->type_code =
'HOLIDAY';
1088 $event->type_label =
'';
1089 $event->type_color =
'';
1090 $event->type =
'holiday';
1091 $event->type_picto =
'holiday';
1093 $event->datep = $db->jdate($obj->date_start) + (empty($obj->halfday) || $obj->halfday == 1 ? 0 : 12) * 60 * 60;
1094 $event->datef = $db->jdate($obj->date_end) + (empty($obj->halfday) || $obj->halfday == -1 ? 24 : 12) * 60 * 60 - 1;
1095 $event->date_start_in_calendar = $event->datep;
1096 $event->date_end_in_calendar = $event->datef;
1098 $event->transparency = 1;
1100 $event->userownerid = $obj->uid;
1101 $event->userassigned = array($obj->uid => array(
'id' => $obj->uid,
'transparency' => 1));
1103 if ($obj->status == 3) {
1105 $event->percentage = -1;
1106 } elseif ($obj->status == 2) {
1108 $event->percentage = 0;
1112 $daycursor = $event->date_start_in_calendar;
1117 $daycursorend = $event->date_end_in_calendar;
1118 $anneeend = (int)
dol_print_date($daycursorend,
'%Y',
'tzuserrel');
1119 $moisend = (int)
dol_print_date($daycursorend,
'%m',
'tzuserrel');
1120 $jourend = (int)
dol_print_date($daycursorend,
'%d',
'tzuserrel');
1123 $daykey =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
1124 $daykeygmt =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
1129 $firstdayofholiday = ($ifornbofdays == 1);
1130 $lastdayofholiday = ($daykeygmt ==
dol_get_first_hour($event->date_end_in_calendar,
'gmt'));
1134 if ((in_array($obj->halfday, array(1, 2)) == 1 && $lastdayofholiday) || (in_array($obj->halfday, array(-1, 2)) && $firstdayofholiday)) {
1137 if (in_array($obj->halfday, array(1, 2)) && $lastdayofholiday) {
1138 $newevent->label .=
' ('.$langs->trans(
"Morning").
')';
1139 } elseif (in_array($obj->halfday, array(-1, 2)) && $firstdayofholiday) {
1140 $newevent->label .=
' ('.$langs->trans(
"Afternoon").
')';
1142 $eventarray[$daykey][] = $newevent;
1144 $eventarray[$daykey][] = $event;
1147 $daykey += 60 * 60 * 24;
1148 $daykeygmt += 60 * 60 * 24;
1149 }
while ($daykey <= $event->date_end_in_calendar);
1158if (count($listofextcals)) {
1159 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/ical.class.php';
1161 foreach ($listofextcals as $key => $extcal) {
1162 $url = $extcal[
'src'];
1163 $namecal = $extcal[
'name'];
1164 $offsettz = $extcal[
'offsettz'];
1165 $colorcal = $extcal[
'color'];
1166 $buggedfile = $extcal[
'buggedfile'];
1172 $ical->parse($url, $pathforcachefile, $DELAYFORCACHE);
1175 $listofextcals[$key][
'error'] = $ical->error;
1176 $s .=
'<br><div class="warning">'.dol_escape_htmltag($listofextcals[$key][
'name']).
': '.$url.
'<br>Error message: '.
dol_escape_htmltag($ical->error).
'</div>';
1181 $icalevents = array();
1182 if (is_array($ical->get_event_list())) {
1183 $icalevents = array_merge($icalevents, $ical->get_event_list());
1185 if (is_array($ical->get_freebusy_list())) {
1186 $icalevents = array_merge($icalevents, $ical->get_freebusy_list());
1189 if (count($icalevents) > 0) {
1191 $moreicalevents = array();
1192 foreach ($icalevents as $icalevent) {
1193 if (isset($icalevent[
'RRULE']) && is_array($icalevent[
'RRULE'])) {
1196 if ($icalevent[
'DTSTART;VALUE=DATE']) {
1199 } elseif (is_array($icalevent[
'DTSTART']) && !empty($icalevent[
'DTSTART'][
'unixtime'])) {
1200 $datecurstart = $icalevent[
'DTSTART'][
'unixtime'];
1201 $datecurend = $icalevent[
'DTEND'][
'unixtime'];
1202 if (!empty($ical->cal[
'DAYLIGHT'][
'DTSTART']) ) {
1204 $tmpcurstart = $datecurstart;
1205 $tmpcurend = $datecurend;
1206 $tmpdaylightstart =
dol_mktime(0, 0, 0, 1, 1, 1970, 1) + (int) $ical->cal[
'DAYLIGHT'][
'DTSTART'];
1207 $tmpdaylightend =
dol_mktime(0, 0, 0, 1, 1, 1970, 1) + (int) $ical->cal[
'STANDARD'][
'DTSTART'];
1210 if ($tmpcurstart >= $tmpdaylightstart && $tmpcurstart < $tmpdaylightend) {
1211 $datecurstart -= ((int) $ical->cal[
'DAYLIGHT'][
'TZOFFSETTO']) * 36;
1213 $datecurstart -= ((int) $ical->cal[
'STANDARD'][
'TZOFFSETTO']) * 36;
1215 if ($tmpcurend >= $tmpdaylightstart && $tmpcurstart < $tmpdaylightend) {
1216 $datecurend -= ((int) $ical->cal[
'DAYLIGHT'][
'TZOFFSETTO']) * 36;
1218 $datecurend -= ((int) $ical->cal[
'STANDARD'][
'TZOFFSETTO']) * 36;
1225 dol_syslog(
"Found a not recognized repeatable record with unknown date start", LOG_ERR);
1230 $interval = (empty($icalevent[
'RRULE'][
'INTERVAL']) ? 1 : $icalevent[
'RRULE'][
'INTERVAL']);
1231 $until = empty($icalevent[
'RRULE'][
'UNTIL']) ? 0 :
dol_stringtotime($icalevent[
'RRULE'][
'UNTIL'], 1);
1232 $maxrepeat = empty($icalevent[
'RRULE'][
'COUNT']) ? 0 : $icalevent[
'RRULE'][
'COUNT'];
1233 if ($until && ($until + ($datecurend - $datecurstart)) < $firstdaytoshow) {
1236 if ($datecurstart >= $lastdaytoshow) {
1241 while (($datecurstart < $lastdaytoshow) && (empty($maxrepeat) || ($numofevent < $maxrepeat))) {
1242 if ($datecurend >= $firstdaytoshow) {
1243 $newevent = $icalevent;
1244 unset($newevent[
'RRULE']);
1245 if ($icalevent[
'DTSTART;VALUE=DATE']) {
1246 $newevent[
'DTSTART;VALUE=DATE'] =
dol_print_date($datecurstart,
'%Y%m%d');
1247 $newevent[
'DTEND;VALUE=DATE'] =
dol_print_date($datecurend + 1,
'%Y%m%d');
1249 $newevent[
'DTSTART'] = $datecurstart;
1250 $newevent[
'DTEND'] = $datecurend;
1252 $moreicalevents[] = $newevent;
1256 $savdatecurstart = $datecurstart;
1257 if ($icalevent[
'RRULE'][
'FREQ'] ==
'DAILY') {
1261 if ($icalevent[
'RRULE'][
'FREQ'] ==
'WEEKLY') {
1264 } elseif ($icalevent[
'RRULE'][
'FREQ'] ==
'MONTHLY') {
1267 } elseif ($icalevent[
'RRULE'][
'FREQ'] ==
'YEARLY') {
1272 if ($savdatecurstart >= $datecurstart) {
1273 dol_syslog(
"Found a rule freq ".$icalevent[
'RRULE'][
'FREQ'].
" not managed by dolibarr code. Assume 1 week frequency.", LOG_ERR);
1274 $datecurstart += 3600 * 24 * 7;
1275 $datecurend += 3600 * 24 * 7;
1280 $icalevents = array_merge($icalevents, $moreicalevents);
1283 foreach ($icalevents as $icalevent) {
1288 if (!empty($icalevent[
'RRULE'])) {
1297 if (isset($icalevent[
'DTSTART;VALUE=DATE'])) {
1300 if (empty($icalevent[
'DTEND;VALUE=DATE'])) {
1301 $dateend = $datestart + 86400 - 1;
1307 $event->fulldayevent = 1;
1309 } elseif (!is_array($icalevent[
'DTSTART'])) {
1310 $datestart = $icalevent[
'DTSTART'];
1311 $dateend = empty($icalevent[
'DTEND']) ? $datestart : $icalevent[
'DTEND'];
1313 $datestart += +($offsettz * 3600);
1314 $dateend += +($offsettz * 3600);
1319 } elseif (isset($icalevent[
'DTSTART'][
'unixtime'])) {
1320 $datestart = $icalevent[
'DTSTART'][
'unixtime'];
1321 $dateend = $icalevent[
'DTEND'][
'unixtime'];
1323 $datestart += +($offsettz * 3600);
1324 $dateend += +($offsettz * 3600);
1327 if ($buggedfile ===
'uselocalandtznodaylight') {
1331 if ($buggedfile ===
'uselocalandtzdaylight') {
1332 $localtzs =
new DateTimeZone(preg_replace(
'/"/',
'', $icalevent[
'DTSTART'][
'TZID']));
1333 $localtze =
new DateTimeZone(preg_replace(
'/"/',
'', $icalevent[
'DTEND'][
'TZID']));
1334 $localdts =
new DateTime(
dol_print_date($datestart,
'dayrfc',
'gmt'), $localtzs);
1335 $localdte =
new DateTime(
dol_print_date($dateend,
'dayrfc',
'gmt'), $localtze);
1336 $tmps = -1 * $localtzs->getOffset($localdts);
1337 $tmpe = -1 * $localtze->getOffset($localdte);
1338 $datestart += $tmps;
1346 $event->id = $icalevent[
'UID'];
1347 $event->ref = (string) $event->id;
1348 $userstatic =
new User($db);
1349 $userId = $userstatic->findUserIdByEmail($namecal);
1350 if (!empty($userId) && $userId > 0) {
1351 $event->userassigned[$userId] = [
1353 'transparency' => 1,
1355 $event->percentage = -1;
1358 $event->type_code =
"ICALEVENT";
1359 $event->type_label = $namecal;
1360 $event->type_color = $colorcal;
1361 $event->type =
'icalevent';
1362 $event->type_picto =
'rss';
1364 $event->icalname = $namecal;
1365 $event->icalcolor = $colorcal;
1367 $event->datep = $datestart + $usertime;
1368 $event->datef = $dateend + $usertime;
1370 if (isset($icalevent[
'SUMMARY']) && $icalevent[
'SUMMARY']) {
1372 } elseif (isset($icalevent[
'DESCRIPTION']) && $icalevent[
'DESCRIPTION']) {
1375 $event->label = $langs->trans(
"ExtSiteNoLabel");
1382 if (!empty($icalevent[
'PRIORITY'])) {
1383 $event->priority = $icalevent[
'PRIORITY'];
1387 if (!empty($icalevent[
'TRANSP'])) {
1388 if ($icalevent[
'TRANSP'] ==
"TRANSPARENT") {
1389 $event->transparency = 0;
1391 if ($icalevent[
'TRANSP'] ==
"OPAQUE") {
1392 $event->transparency = 1;
1403 if (!empty($icalevent[
'LOCATION'])) {
1404 $event->location = $icalevent[
'LOCATION'];
1407 $event->date_start_in_calendar = $event->datep;
1409 if ($event->datef !=
'' && $event->datef >= $event->datep) {
1410 $event->date_end_in_calendar = $event->datef;
1412 $event->date_end_in_calendar = $event->datep;
1416 if ($event->date_end_in_calendar < $firstdaytoshow || $event->date_start_in_calendar >= $lastdaytoshow) {
1422 if ($event->date_start_in_calendar < $firstdaytoshow) {
1423 $event->date_start_in_calendar = $firstdaytoshow;
1425 if ($event->date_end_in_calendar >= $lastdaytoshow) {
1426 $event->date_end_in_calendar = ($lastdaytoshow - 1);
1430 $daycursor = $event->date_start_in_calendar;
1439 $daykey =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
1440 $daykeygmt =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
1443 $eventarray[$daykey][] = $event;
1444 $daykey += 60 * 60 * 24;
1445 $daykeygmt += 60 * 60 * 24;
1446 if (($event->fulldayevent ? $daykeygmt : $daykey) > $event->date_end_in_calendar) {
1458$parameters = array();
1460$reshook = $hookmanager->executeHooks(
'getCalendarEvents', $parameters, $object, $action);
1461if (!empty($hookmanager->resArray[
'eventarray'])) {
1462 foreach ($hookmanager->resArray[
'eventarray'] as $keyDate => $events) {
1463 if (!isset($eventarray[$keyDate])) {
1464 $eventarray[$keyDate] = array();
1466 $eventarray[$keyDate] = array_merge($eventarray[$keyDate], $events);
1478$cachethirdparties = array();
1479$cachecontacts = array();
1480$cacheusers = array();
1483$color_file = DOL_DOCUMENT_ROOT.
"/theme/".
$conf->theme.
"/theme_vars.inc.php";
1484if (is_readable($color_file)) {
1485 include $color_file;
1487if (!is_array($theme_datacolor)) {
1488 $theme_datacolor = array(array(137, 86, 161), array(60, 147, 183), array(250, 190, 80), array(80, 166, 90), array(190, 190, 100), array(91, 115, 247), array(140, 140, 220), array(190, 120, 120), array(115, 125, 150), array(100, 170, 20), array(150, 135, 125), array(85, 135, 150), array(150, 135, 80), array(150, 80, 150));
1491$massactionbutton =
'';
1495print_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);
1502print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1503print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday,
'', (
string) $filtert,
'', $pid, $socid, $action, -1, $actioncode, $usergroup,
'', $resourceid, $search_categ_cus);
1508$newparam = preg_replace(
'/showbirthday=/i',
'showbirthday_=', $newparam);
1509$newparam = preg_replace(
'/mode=show_month&?/i',
'', $newparam);
1510$newparam = preg_replace(
'/mode=show_week&?/i',
'', $newparam);
1511$newparam = preg_replace(
'/day=[0-9]+&?/i',
'', $newparam);
1512$newparam = preg_replace(
'/month=[0-9]+&?/i',
'', $newparam);
1513$newparam = preg_replace(
'/year=[0-9]+&?/i',
'', $newparam);
1514$newparam = preg_replace(
'/viewweek=[0-9]+&?/i',
'', $newparam);
1515$newparam = preg_replace(
'/showbirthday_=/i',
'showbirthday=', $newparam);
1516$newparam .=
'&viewweek=1';
1518echo
'<input type="hidden" name="actionmove" value="mupdate">';
1519echo
'<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($_SERVER[
'PHP_SELF']).
'?'.
dol_escape_htmltag($_SERVER[
'QUERY_STRING']).
'">';
1520echo
'<input type="hidden" name="newdate" id="newdate">';
1527$currentdaytoshow = $firstdaytoshow;
1528echo
'<div class="div-table-responsive">';
1531$colorsbytype = array();
1533while ($currentdaytoshow < $lastdaytoshow) {
1534 echo
'<table class="centpercent noborder nocellnopadd cal_month cal_peruser listwithfilterbefore">';
1536 echo
'<tr class="liste_titre">';
1537 echo
'<td class="nopaddingtopimp nopaddingbottomimp nowraponsmartphone">';
1541 print
'<span class="hideonsmartphone" title="'.$langs->trans(
"VisibleDaysRange").
'">';
1542 print
img_picto(
'',
'clock',
'class="fawidth30 inline-block marginleftonly"');
1543 print $langs->trans(
"DaysOfWeek").
'</span>';
1545 print
'<div class="ui-grid-a inline-block"><div class="ui-block-a nowraponall">';
1546 print
'<input type="number" class="short" name="begin_d" value="'.$begin_d.
'" min="1" max="7">';
1547 if (empty(
$conf->dol_use_jmobile)) {
1550 print
'</div><div class="ui-block-b">';
1552 print
'<input type="number" class="short" name="end_d" value="'.$end_d.
'" min="1" max="7">';
1553 print
'</div></div>';
1559 if (($i + 1) < $begin_d || ($i + 1) > $end_d) {
1563 echo
'<td align="center" colspan="'.($end_h - $begin_h).
'">';
1564 echo
'<span class="bold spandayofweek">'.$langs->trans(
"Day".(($i + (isset(
$conf->global->MAIN_START_WEEK) ?
$conf->global->MAIN_START_WEEK : 1)) % 7)).
'</span>';
1576 echo
'<tr class="liste_titre">';
1580 print
'<span class="hideonsmartphone" title="'.$langs->trans(
"VisibleTimeRange").
'">';
1581 print
img_picto(
'',
'clock',
'class="fawidth30 inline-block marginleftonly"');
1582 print $langs->trans(
"Hours").
'</span>';
1584 print
'<div class="ui-grid-a inline-block"><div class="ui-block-a nowraponall">';
1585 print
'<input type="number" class="short" name="begin_h" value="'.$begin_h.
'" min="0" max="23">';
1586 if (empty(
$conf->dol_use_jmobile)) {
1589 print
'</div><div class="ui-block-b">';
1591 print
'<input type="number" class="short" name="end_h" value="'.$end_h.
'" min="1" max="24">';
1592 if (empty(
$conf->dol_use_jmobile)) {
1593 print
' '.$langs->trans(
"H");
1595 print
'</div></div>';
1600 if (($i + 1) < $begin_d || ($i + 1) > $end_d) {
1604 for ($h = $begin_h; $h < $end_h; $h++) {
1605 echo
'<td class="center">';
1606 print
'<small style="font-family: courier">'.sprintf(
"%02d", $h).
'</small>';
1616 $usernames = array();
1617 $usernamesid = array();
1620 foreach ($eventarray as $daykey => $notused) {
1622 foreach ($eventarray[$daykey] as $index => $event) {
1623 $event->fetch_userassigned();
1624 $listofuserid = $event->userassigned;
1625 foreach ($listofuserid as $userid => $tmp) {
1626 if (!in_array($userid, $usernamesid)) {
1627 $usernamesid[$userid] = $userid;
1634 $sql =
"SELECT u.rowid, u.lastname as lastname, u.firstname, u.statut, u.login, u.admin, u.entity";
1635 $sql .=
" FROM ".$db->prefix().
"user as u";
1636 if (isModEnabled(
'multicompany') &&
getDolGlobalInt(
'MULTICOMPANY_TRANSVERSE_MODE')) {
1637 $sql .=
" WHERE u.rowid IN (";
1638 $sql .=
" SELECT ug.fk_user FROM ".$db->prefix().
"usergroup_user as ug";
1639 $sql .=
" WHERE ug.entity IN (".getEntity(
'usergroup').
")";
1640 if ($usergroup > 0) {
1641 $sql .=
" AND ug.fk_usergroup = ".((int) $usergroup);
1645 if ($usergroup > 0) {
1646 $sql .=
" LEFT JOIN ".$db->prefix().
"usergroup_user as ug ON u.rowid = ug.fk_user";
1648 $sql .=
" WHERE u.entity IN (".getEntity(
'user').
")";
1649 if ($usergroup > 0) {
1650 $sql .=
" AND ug.fk_usergroup = ".((int) $usergroup);
1653 $sql .=
" AND u.statut = 1";
1655 $sql .=
" AND u.rowid = ".((int) $filtert);
1657 if ($usergroup > 0) {
1658 $sql .=
" AND ug.fk_usergroup = ".((int) $usergroup);
1660 if ($user->socid > 0) {
1662 $sql .=
" AND u.fk_soc = ".((int) $user->socid);
1666 $resql = $db->query($sql);
1668 $num = $db->num_rows($resql);
1672 $obj = $db->fetch_object($resql);
1673 $usernamesid[$obj->rowid] = $obj->rowid;
1682 foreach ($usernamesid as
$id) {
1683 $tmpuser =
new User($db);
1684 $result = $tmpuser->fetch(
$id);
1685 $usernames[] = $tmpuser;
1689 $labelbytype = array();
1690 $sql =
"SELECT code, color, libelle as label FROM ".MAIN_DB_PREFIX.
"c_actioncomm ORDER BY position";
1691 $resql = $db->query($sql);
1692 while ($obj = $db->fetch_object($resql)) {
1693 $colorsbytype[$obj->code] = $obj->color;
1694 $labelbytype[$obj->code] = $obj->label;
1702 foreach ($usernames as $username) {
1708 echo
'<td class="tdoverflowmax100 cal_current_month cal_peruserviewname'.($var ?
' cal_impair' :
'').
'">';
1709 print
'<span class="paddingrightimp">';
1710 print $username->getNomUrl(-1,
'', 0, 0, 20, 1,
'',
'paddingleft');
1717 for ($iter_day = 0; $iter_day < 8; $iter_day++) {
1718 if (($i + 1) < $begin_d || ($i + 1) > $end_d) {
1731 $style =
'cal_current_month';
1732 if ($iter_day == 6) {
1733 $style .=
' cal_other_month';
1736 if ($todayarray[
'mday'] == $tmpday && $todayarray[
'mon'] == $tmpmonth && $todayarray[
'year'] == $tmpyear) {
1740 $style =
'cal_today_peruser';
1743 show_day_events2($username, $tmpday, $tmpmonth, $tmpyear, 0, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, $showheader, $colorsbytype, $var);
1748 $showheader =
false;
1760 $langs->load(
"commercial");
1761 print
'<br>'.$langs->trans(
"Legend").
': <br>';
1762 foreach ($colorsbytype as $code => $color) {
1764 print
'<div style="float: left; padding: 2px; margin-right: 6px;"><div style="background: #'.$color.
'; width:16px; float: left; margin-right: 4px;"> </div>';
1765 print $langs->trans(
"Action".$code) !=
"Action".$code ? $langs->trans(
"Action".$code) : $labelbytype[$code];
1771 print
'<div style="float: left; padding: 2px; margin-right: 6px;"><div class="peruser_busy" style="width:16px; float: left; margin-right: 4px;"> </div>';
1772 print $langs->trans(
"Other");
1781print
"\n".
'</form>';
1786print
'<script type="text/javascript">
1787jQuery(document).ready(function() {
1788 jQuery(".onclickopenref").click(function() {
1789 console.log("We click on a class onclickopenref");
1791 var ref=$(this).attr(\'ref\');
1792 var res = ref.split("_");
1793 var userid = res[1];
1800 if (ids == \'none\') /* No event */
1802 /* alert(\'no event\'); */
1803 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 :
'')).
'"
1804 window.location.href = url;
1806 else if (ids.indexOf(",") > -1) /* There is several events */
1808 /* alert(\'several events\'); */
1809 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;
1810 window.location.href = url;
1812 else /* One event */
1814 /* alert(\'one event\'); */
1815 url = "'.DOL_URL_ROOT.
'/comm/action/card.php?action=view&id="+ids
1816 window.location.href = url;
1849function 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)
1852 global $user,
$conf, $langs, $hookmanager, $action;
1853 global $filter, $filtert, $status, $actioncode;
1854 global $theme_datacolor;
1855 global $cachethirdparties, $cachecontacts, $cacheusers, $cacheprojects, $colorindexused;
1856 global $begin_h, $end_h;
1867 $numicals = array();
1870 $colorindexused[$user->id] = 0;
1871 $nextindextouse = count($colorindexused);
1878 foreach ($eventarray as $daykey => $notused) {
1885 if ($day == $jour && (
int) $month == $mois && $year == $annee) {
1889 foreach ($eventarray[$daykey] as $index => $event) {
1893 $keysofuserassigned = array_keys($event->userassigned);
1895 if (!in_array($username->id, $keysofuserassigned)) {
1900 $parameters = array();
1901 $reshook = $hookmanager->executeHooks(
'formatEvent', $parameters, $event, $action);
1911 if ($event->type_code ==
'HOLIDAY') {
1912 $cssclass =
'family_holiday';
1915 if (in_array($user->id, $keysofuserassigned)) {
1916 $cssclass =
'family_mytasks';
1918 if (empty($cacheusers[$event->userownerid])) {
1919 $newuser =
new User($db);
1920 $newuser->fetch($event->userownerid);
1921 $cacheusers[$event->userownerid] = $newuser;
1926 if (!empty($cacheusers[$event->userownerid]->color)) {
1927 $color = $cacheusers[$event->userownerid]->color;
1931 $color = $event->type_color;
1933 } elseif ($event->type_code ==
'ICALEVENT') {
1935 if (!empty($event->icalname)) {
1942 $color = $event->icalcolor;
1943 $cssclass = (!empty($event->icalname) ?
'family_ext'.md5($event->icalname) :
'family_other unsortable');
1944 } elseif ($event->type_code ==
'BIRTHDAY') {
1947 $cssclass =
'family_birthday unsortable';
1948 $color = sprintf(
"%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
1951 $color = ($event->icalcolor ? $event->icalcolor : -1);
1952 $cssclass = (!empty($event->icalname) ?
'family_ext'.md5($event->icalname) :
'family_other');
1954 if (empty($cacheusers[$event->userownerid])) {
1955 $newuser =
new User($db);
1956 $newuser->fetch($event->userownerid);
1957 $cacheusers[$event->userownerid] = $newuser;
1962 if (!empty($cacheusers[$event->userownerid]->color)) {
1963 $color = $cacheusers[$event->userownerid]->color;
1967 $color = $event->type_color;
1973 $idusertouse = ($event->userownerid ? $event->userownerid : 0);
1974 if (isset($colorindexused[$idusertouse])) {
1975 $colorindex = $colorindexused[$idusertouse];
1977 $colorindex = $nextindextouse;
1978 $colorindexused[$idusertouse] = $colorindex;
1979 if (!empty($theme_datacolor[$nextindextouse + 1])) {
1984 $color = sprintf(
"%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
1988 for ($h = $begin_h; $h < $end_h; $h++) {
1991 if (empty($event->fulldayevent)) {
1992 $a =
dol_mktime((
int) $h, 0, 0, $month, $day, $year,
'tzuserrel', 0);
1993 $b =
dol_mktime((
int) $h, 15, 0, $month, $day, $year,
'tzuserrel', 0);
1994 $b1 =
dol_mktime((
int) $h, 30, 0, $month, $day, $year,
'tzuserrel', 0);
1995 $b2 =
dol_mktime((
int) $h, 45, 0, $month, $day, $year,
'tzuserrel', 0);
1996 $c =
dol_mktime((
int) $h + 1, 0, 0, $month, $day, $year,
'tzuserrel', 0);
1998 $dateendtouse = $event->date_end_in_calendar;
1999 if ($dateendtouse == $event->date_start_in_calendar) {
2005 if ($event->date_start_in_calendar < $b && $dateendtouse > $a) {
2006 $busy = $event->transparency;
2007 $cases1[$h][$event->id][
'busy'] = $busy;
2008 $cases1[$h][$event->id][
'string'] =
dol_print_date($event->date_start_in_calendar,
'dayhour',
'tzuserrel');
2009 if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) {
2010 $tmpa =
dol_getdate($event->date_start_in_calendar,
true);
2011 $tmpb =
dol_getdate($event->date_end_in_calendar,
true);
2012 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) {
2013 $cases1[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'hour',
'tzuserrel');
2015 $cases1[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'dayhour',
'tzuserrel');
2018 if ($event->label) {
2019 $cases1[$h][$event->id][
'string'] .=
' - '.$event->label;
2021 $cases1[$h][$event->id][
'typecode'] = $event->type_code;
2022 if ($event->type_code ==
'HOLIDAY') {
2023 $cases1[$h][$event->id][
'css'] =
'peruser_holiday ';
2025 $cases1[$h][$event->id][
'color'] = $color;
2027 if ($event->fk_project > 0) {
2028 if (empty($cacheprojects[$event->fk_project])) {
2030 $tmpproj->fetch($event->fk_project);
2031 $cacheprojects[$event->fk_project] = $tmpproj;
2033 $cases1[$h][$event->id][
'string'] .=
', '.$langs->trans(
"Project").
': '.$cacheprojects[$event->fk_project]->ref.
' - '.$cacheprojects[$event->fk_project]->title;
2035 if ($event->socid > 0) {
2036 if (empty($cachethirdparties[$event->socid])) {
2037 $tmpthirdparty =
new Societe($db);
2038 $tmpthirdparty->fetch($event->socid);
2039 $cachethirdparties[$event->socid] = $tmpthirdparty;
2041 $cases1[$h][$event->id][
'string'] .=
', '.$cachethirdparties[$event->socid]->name;
2043 if ($event->contact_id > 0) {
2044 if (empty($cachecontacts[$event->contact_id])) {
2045 $tmpcontact =
new Contact($db);
2046 $tmpcontact->fetch($event->contact_id);
2047 $cachecontacts[$event->contact_id] = $tmpcontact;
2049 $cases1[$h][$event->id][
'string'] .=
', '.$cachecontacts[$event->contact_id]->getFullName($langs);
2053 if ($event->date_start_in_calendar < $b1 && $dateendtouse > $b) {
2054 $busy = $event->transparency;
2055 $cases2[$h][$event->id][
'busy'] = $busy;
2056 $cases2[$h][$event->id][
'string'] =
dol_print_date($event->date_start_in_calendar,
'dayhour',
'tzuserrel');
2057 if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) {
2058 $tmpa =
dol_getdate($event->date_start_in_calendar,
true);
2059 $tmpb =
dol_getdate($event->date_end_in_calendar,
true);
2060 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) {
2061 $cases2[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'hour',
'tzuserrel');
2063 $cases2[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'dayhour',
'tzuserrel');
2066 if ($event->label) {
2067 $cases2[$h][$event->id][
'string'] .=
' - '.$event->label;
2069 $cases2[$h][$event->id][
'typecode'] = $event->type_code;
2070 if ($event->type_code ==
'HOLIDAY') {
2071 $cases2[$h][$event->id][
'css'] =
'peruser_holiday ';
2073 $cases2[$h][$event->id][
'color'] = $color;
2075 if ($event->fk_project > 0) {
2076 if (empty($cacheprojects[$event->fk_project])) {
2078 $tmpproj->fetch($event->fk_project);
2079 $cacheprojects[$event->fk_project] = $tmpproj;
2081 $cases2[$h][$event->id][
'string'] .=
', '.$langs->trans(
"Project").
': '.$cacheprojects[$event->fk_project]->ref.
' - '.$cacheprojects[$event->fk_project]->title;
2083 if ($event->socid > 0) {
2084 if (empty($cachethirdparties[$event->socid])) {
2085 $tmpthirdparty =
new Societe($db);
2086 $tmpthirdparty->fetch($event->socid);
2087 $cachethirdparties[$event->socid] = $tmpthirdparty;
2089 $cases2[$h][$event->id][
'string'] .=
', '.$cachethirdparties[$event->socid]->name;
2091 if ($event->contact_id > 0) {
2092 if (empty($cachecontacts[$event->contact_id])) {
2093 $tmpcontact =
new Contact($db);
2094 $tmpcontact->fetch($event->contact_id);
2095 $cachecontacts[$event->contact_id] = $tmpcontact;
2097 $cases2[$h][$event->id][
'string'] .=
', '.$cachecontacts[$event->contact_id]->getFullName($langs);
2101 if ($event->date_start_in_calendar < $b2 && $dateendtouse > $b1) {
2102 $busy = $event->transparency;
2103 $cases3[$h][$event->id][
'busy'] = $busy;
2104 $cases3[$h][$event->id][
'string'] =
dol_print_date($event->date_start_in_calendar,
'dayhour',
'tzuserrel');
2105 if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) {
2106 $tmpa =
dol_getdate($event->date_start_in_calendar,
true);
2107 $tmpb =
dol_getdate($event->date_end_in_calendar,
true);
2108 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) {
2109 $cases3[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'hour',
'tzuserrel');
2111 $cases3[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'dayhour',
'tzuserrel');
2114 if ($event->label) {
2115 $cases3[$h][$event->id][
'string'] .=
' - '.$event->label;
2117 $cases3[$h][$event->id][
'typecode'] = $event->type_code;
2118 if ($event->type_code ==
'HOLIDAY') {
2119 $cases3[$h][$event->id][
'css'] .=
'peruser_holiday ';
2121 $cases3[$h][$event->id][
'color'] = $color;
2123 if ($event->fk_project > 0) {
2124 if (empty($cacheprojects[$event->fk_project])) {
2126 $tmpproj->fetch($event->fk_project);
2127 $cacheprojects[$event->fk_project] = $tmpproj;
2129 $cases3[$h][$event->id][
'string'] .=
', '.$langs->trans(
"Project").
': '.$cacheprojects[$event->fk_project]->ref.
' - '.$cacheprojects[$event->fk_project]->title;
2131 if ($event->socid > 0) {
2132 if (empty($cachethirdparties[$event->socid])) {
2133 $tmpthirdparty =
new Societe($db);
2134 $tmpthirdparty->fetch($event->socid);
2135 $cachethirdparties[$event->socid] = $tmpthirdparty;
2137 $cases3[$h][$event->id][
'string'] .=
', '.$cachethirdparties[$event->socid]->name;
2139 if ($event->contact_id > 0) {
2140 if (empty($cachecontacts[$event->contact_id])) {
2141 $tmpcontact =
new Contact($db);
2142 $tmpcontact->fetch($event->contact_id);
2143 $cachecontacts[$event->contact_id] = $tmpcontact;
2145 $cases3[$h][$event->id][
'string'] .=
', '.$cachecontacts[$event->contact_id]->getFullName($langs);
2149 if ($event->date_start_in_calendar <
$c && $dateendtouse > $b2) {
2150 $busy = $event->transparency;
2151 $cases4[$h][$event->id][
'busy'] = $busy;
2152 $cases4[$h][$event->id][
'string'] =
dol_print_date($event->date_start_in_calendar,
'dayhour',
'tzuserrel');
2153 if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) {
2154 $tmpa =
dol_getdate($event->date_start_in_calendar,
true);
2155 $tmpb =
dol_getdate($event->date_end_in_calendar,
true);
2156 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) {
2157 $cases4[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'hour',
'tzuserrel');
2159 $cases4[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'dayhour',
'tzuserrel');
2162 if ($event->label) {
2163 $cases4[$h][$event->id][
'string'] .=
' - '.$event->label;
2165 $cases4[$h][$event->id][
'typecode'] = $event->type_code;
2166 if ($event->type_code ==
'HOLIDAY') {
2167 $cases4[$h][$event->id][
'css'] =
'peruser_holiday ';
2169 $cases4[$h][$event->id][
'color'] = $color;
2171 if ($event->fk_project > 0) {
2172 if (empty($cacheprojects[$event->fk_project])) {
2174 $tmpproj->fetch($event->fk_project);
2175 $cacheprojects[$event->fk_project] = $tmpproj;
2177 $cases4[$h][$event->id][
'string'] .=
', '.$langs->trans(
"Project").
': '.$cacheprojects[$event->fk_project]->ref.
' - '.$cacheprojects[$event->fk_project]->title;
2179 if ($event->socid > 0) {
2180 if (empty($cachethirdparties[$event->socid])) {
2181 $tmpthirdparty =
new Societe($db);
2182 $tmpthirdparty->fetch($event->socid);
2183 $cachethirdparties[$event->socid] = $tmpthirdparty;
2185 $cases4[$h][$event->id][
'string'] .=
', '.$cachethirdparties[$event->socid]->name;
2187 if ($event->contact_id > 0) {
2188 if (empty($cachecontacts[$event->contact_id])) {
2189 $tmpcontact =
new Contact($db);
2190 $tmpcontact->fetch($event->contact_id);
2191 $cachecontacts[$event->contact_id] = $tmpcontact;
2193 $cases4[$h][$event->id][
'string'] .=
', '.$cachecontacts[$event->contact_id]->getFullName($langs);
2198 $busy = $event->transparency;
2199 $cases1[$h][$event->id][
'busy'] = $busy;
2200 $cases2[$h][$event->id][
'busy'] = $busy;
2201 $cases3[$h][$event->id][
'busy'] = $busy;
2202 $cases4[$h][$event->id][
'busy'] = $busy;
2203 $cases1[$h][$event->id][
'string'] = $event->label;
2204 $cases2[$h][$event->id][
'string'] = $event->label;
2205 $cases3[$h][$event->id][
'string'] = $event->label;
2206 $cases4[$h][$event->id][
'string'] = $event->label;
2207 $cases1[$h][$event->id][
'typecode'] = $event->type_code;
2208 $cases2[$h][$event->id][
'typecode'] = $event->type_code;
2209 $cases3[$h][$event->id][
'typecode'] = $event->type_code;
2210 $cases4[$h][$event->id][
'typecode'] = $event->type_code;
2211 $cases1[$h][$event->id][
'color'] = $color;
2212 $cases2[$h][$event->id][
'color'] = $color;
2213 $cases3[$h][$event->id][
'color'] = $color;
2214 $cases4[$h][$event->id][
'color'] = $color;
2215 $cases1[$h][$event->id][
'css'] =
'';
2216 $cases2[$h][$event->id][
'css'] =
'';
2217 $cases3[$h][$event->id][
'css'] =
'';
2218 $cases4[$h][$event->id][
'css'] =
'';
2229 for ($h = $begin_h; $h < $end_h; $h++) {
2234 $style1 =
'onclickopenref ';
2235 $style2 =
'onclickopenref ';
2236 $style3 =
'onclickopenref ';
2237 $style4 =
'onclickopenref ';
2238 $string1 =
' ';
2239 $string2 =
' ';
2240 $string3 =
' ';
2241 $string4 =
' ';
2246 if (isset($cases1[$h]) && $cases1[$h] !=
'') {
2248 if (count($cases1[$h]) > 1) {
2249 $title1 .= count($cases1[$h]).
' '.(count($cases1[$h]) == 1 ? $langs->trans(
"Event") : $langs->trans(
"Events"));
2253 $style1 .=
'peruser_notbusy ';
2255 $style1 .=
'peruser_busy ';
2257 foreach ($cases1[$h] as
$id => $ev) {
2259 $style1 =
'onclickopenref peruser_busy';
2262 $style1 .=
' '.$ev[
'css'];
2266 if (isset($cases2[$h]) && $cases2[$h] !=
'') {
2268 if (count($cases2[$h]) > 1) {
2269 $title2 .= count($cases2[$h]).
' '.(count($cases2[$h]) == 1 ? $langs->trans(
"Event") : $langs->trans(
"Events"));
2273 $style2 .=
'peruser_notbusy ';
2275 $style2 .=
'peruser_busy ';
2277 foreach ($cases2[$h] as
$id => $ev) {
2279 $style2 =
'onclickopenref peruser_busy';
2282 $style2 .=
' '.$ev[
'css'];
2286 if (isset($cases3[$h]) && $cases3[$h] !=
'') {
2288 if (count($cases3[$h]) > 1) {
2289 $title3 .= count($cases3[$h]).
' '.(count($cases3[$h]) == 1 ? $langs->trans(
"Event") : $langs->trans(
"Events"));
2293 $style3 .=
'peruser_notbusy ';
2295 $style3 .=
'peruser_busy ';
2297 foreach ($cases3[$h] as
$id => $ev) {
2299 $style3 =
'onclickopenref peruser_busy';
2302 $style3 .=
' '.$ev[
'css'];
2306 if (isset($cases4[$h]) && $cases4[$h] !=
'') {
2308 if (count($cases4[$h]) > 1) {
2309 $title4 .= count($cases4[$h]).
' '.(count($cases4[$h]) == 1 ? $langs->trans(
"Event") : $langs->trans(
"Events"));
2313 $style4 .=
'peruser_notbusy ';
2315 $style4 .=
'peruser_busy ';
2317 foreach ($cases4[$h] as
$id => $ev) {
2319 $style4 =
'onclickopenref peruser_busy';
2322 $style4 .=
' '.$ev[
'css'];
2331 if (!empty($cases1[$h]) && is_array($cases1[$h]) && count($cases1[$h]) && array_keys($cases1[$h])) {
2332 $ids1 = implode(
', ', array_keys($cases1[$h]));
2334 if (!empty($cases2[$h]) && is_array($cases2[$h]) && count($cases2[$h]) && array_keys($cases2[$h])) {
2335 $ids2 = implode(
', ', array_keys($cases2[$h]));
2337 if (!empty($cases3[$h]) && is_array($cases3[$h]) && count($cases3[$h]) && array_keys($cases3[$h])) {
2338 $ids3 = implode(
',', array_keys($cases3[$h]));
2340 if (!empty($cases4[$h]) && is_array($cases4[$h]) && count($cases4[$h]) && array_keys($cases4[$h])) {
2341 $ids4 = implode(
',', array_keys($cases4[$h]));
2344 if ($h == $begin_h) {
2345 echo
'<td class="'.$style.
'_peruserleft cal_peruser'.($var ?
' cal_impair '.$style.
'_impair' :
'').
'">';
2347 echo
'<td class="'.$style.
' cal_peruser'.($var ?
' cal_impair '.$style.
'_impair' :
'').
'">';
2350 if (!empty($cases1[$h]) && is_array($cases1[$h]) && count($cases1[$h]) == 1) {
2351 $output = array_slice($cases1[$h], 0, 1);
2352 $title1 = $langs->trans(
"Ref").
' '.$ids1.($title1 ?
' - '.$title1 :
'');
2353 if ($output[0][
'string']) {
2354 $title1 .= ($title1 ?
' - ' :
'').$output[0][
'string'];
2356 if ($output[0][
'color']) {
2357 $color1 = $output[0][
'color'];
2359 } elseif (!empty($cases1[$h]) && is_array($cases1[$h]) && count($cases1[$h]) > 1) {
2360 $title1 = $langs->trans(
"Ref").
' '.$ids1.($title1 ?
' - '.$title1 :
'');
2365 if (!empty($cases2[$h]) && is_array($cases2[$h]) && count($cases2[$h]) == 1) {
2366 $output = array_slice($cases2[$h], 0, 1);
2367 $title2 = $langs->trans(
"Ref").
' '.$ids2.($title2 ?
' - '.$title2 :
'');
2368 if ($output[0][
'string']) {
2369 $title2 .= ($title2 ?
' - ' :
'').$output[0][
'string'];
2371 if ($output[0][
'color']) {
2372 $color2 = $output[0][
'color'];
2374 } elseif (!empty($cases2[$h]) && is_array($cases2[$h]) && count($cases2[$h]) > 1) {
2375 $title2 = $langs->trans(
"Ref").
' '.$ids2.($title2 ?
' - '.$title2 :
'');
2380 if (!empty($cases3[$h]) && is_array($cases3[$h]) && count($cases3[$h]) == 1) {
2381 $output = array_slice($cases3[$h], 0, 1);
2382 $title3 = $langs->trans(
"Ref").
' '.$ids3.($title3 ?
' - '.$title3 :
'');
2383 if ($output[0][
'string']) {
2384 $title3 .= ($title3 ?
' - ' :
'').$output[0][
'string'];
2386 if ($output[0][
'color']) {
2387 $color3 = $output[0][
'color'];
2389 } elseif (!empty($cases3[$h]) && is_array($cases3[$h]) && count($cases3[$h]) > 1) {
2390 $title3 = $langs->trans(
"Ref").
' '.$ids3.($title3 ?
' - '.$title3 :
'');
2395 if (!empty($cases4[$h]) && is_array($cases4[$h]) && count($cases4[$h]) == 1) {
2396 $output = array_slice($cases4[$h], 0, 1);
2397 $title4 = $langs->trans(
"Ref").
' '.$ids3.($title4 ?
' - '.$title4 :
'');
2398 if ($output[0][
'string']) {
2399 $title4 .= ($title4 ?
' - ' :
'').$output[0][
'string'];
2401 if ($output[0][
'color']) {
2402 $color4 = $output[0][
'color'];
2404 } elseif (!empty($cases4[$h]) && is_array($cases4[$h]) && count($cases4[$h]) > 1) {
2405 $title4 = $langs->trans(
"Ref").
' '.$ids4.($title4 ?
' - '.$title4 :
'');
2409 print
'<table class="nobordernopadding case centpercent">';
2412 if ($style1 ==
'peruser_notbusy') {
2413 print
'style="border: 1px solid #'.($color1 ? $color1 :
"888").
' !important" ';
2414 } elseif ($color1) {
2415 print
'style="background: #'.$color1.
'; "';
2418 print($style1 ? $style1.
' ' :
'');
2419 print
'center'.($title2 ?
' classfortooltip' :
'').($title1 ?
' cursorpointer' :
'').
'" ref="ref_'.$username->id.
'_'.sprintf(
"%04d", $year).
'_'.sprintf(
"%02d", $month).
'_'.sprintf(
"%02d", $day).
'_'.sprintf(
"%02d", $h).
'_00_'.($ids1 ? $ids1 :
'none').
'"'.($title1 ?
' title="'.$title1.
'"' :
'').
'>';
2424 if ($style2 ==
'peruser_notbusy') {
2425 print
'style="border: 1px solid #'.($color2 ? $color2 :
"888").
' !important" ';
2426 } elseif ($color2) {
2427 print
'style="background: #'.$color2.
'; "';
2430 print($style2 ? $style2.
' ' :
'');
2431 print
'center'.($title2 ?
' classfortooltip' :
'').($title1 ?
' cursorpointer' :
'').
'" ref="ref_'.$username->id.
'_'.sprintf(
"%04d", $year).
'_'.sprintf(
"%02d", $month).
'_'.sprintf(
"%02d", $day).
'_'.sprintf(
"%02d", $h).
'_15_'.($ids2 ? $ids2 :
'none').
'"'.($title2 ?
' title="'.$title2.
'"' :
'').
'>';
2436 if ($style3 ==
'peruser_notbusy') {
2437 print
'style="border: 1px solid #'.($color3 ? $color3 :
"888").
' !important" ';
2438 } elseif ($color3) {
2439 print
'style="background: #'.$color3.
'; "';
2442 print($style3 ? $style3.
' ' :
'');
2443 print
'center'.($title2 ?
' classfortooltip' :
'').($title3 ?
' cursorpointer' :
'').
'" ref="ref_'.$username->id.
'_'.sprintf(
"%04d", $year).
'_'.sprintf(
"%02d", $month).
'_'.sprintf(
"%02d", $day).
'_'.sprintf(
"%02d", $h).
'_30_'.($ids3 ? $ids3 :
'none').
'"'.($title3 ?
' title="'.$title3.
'"' :
'').
'>';
2448 if ($style4 ==
'peruser_notbusy') {
2449 print
'style="border: 1px solid #'.($color4 ? $color4 :
"888").
' !important" ';
2450 } elseif ($color4) {
2451 print
'style="background: #'.$color4.
'; "';
2454 print($style4 ? $style4.
' ' :
'');
2455 print
'center'.($title3 ?
' classfortooltip' :
'').($title4 ?
' cursorpointer' :
'').
'" ref="ref_'.$username->id.
'_'.sprintf(
"%04d", $year).
'_'.sprintf(
"%02d", $month).
'_'.sprintf(
"%02d", $day).
'_'.sprintf(
"%02d", $h).
'_45_'.($ids4 ? $ids4 :
'none').
'"'.($title4 ?
' title="'.$title4.
'"' :
'').
'>';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
print_actions_filter( $form, $canedit, $status, $year, $month, $day, $showbirthday, $filtera, $filtert, $filtered, $pid, $socid, $action, $showextcals=array(), $actioncode='', $usergroupid=0, $excludetype='', $resourceid=0, $search_categ_cus=0)
Show filter form in agenda view.
calendars_prepare_head($param)
Define head array for tabs of agenda setup pages.
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage agenda events (actions)
Class to read/parse ICal calendars.
Class to manage projects.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
dol_get_first_hour($date, $gm='tzserver')
Return GMT time for first hour of a given GMT date (it removes hours, min and second part)
dol_get_next_week($day, $week, $month, $year)
Return next week.
dol_get_first_day_week($day, $month, $year, $gm=false)
Return first day of week for a date.
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
dol_stringtotime($string, $gm=1)
Convert a string date into a GM Timestamps date Warning: YYYY-MM-DDTHH:MM:SS+02:00 (RFC3339) is not s...
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_string_nospecial($str, $newstr='_', $badcharstoreplace='', $badcharstoremove='', $keepspaces=0)
Clean a string from all punctuation characters to use it as a ref or login.
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
getDolUserString($key, $default='', $tmpuser=null)
Return Dolibarr user constant string value.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dolGetFirstLastname($firstname, $lastname, $nameorder=-1)
Return firstname and lastname in correct order.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_clone($object, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_sanitizePathName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a path name.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
conf($dolibarr_main_document_root)
Load conf file (file must exists)
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.