35require
'../../main.inc.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.
'/comm/action/class/actioncomm.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/lib/agenda.lib.php';
41if (isModEnabled(
'project')) {
42 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
45if (!isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) {
46 $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW = 3;
50 $conf->global->AGENDA_EXT_NB = 5;
55$disabledefaultvalues =
GETPOSTINT(
'disabledefaultvalues');
58$filter =
GETPOST(
"search_filter",
'alpha', 3) ?
GETPOST(
"search_filter",
'alpha', 3) :
GETPOST(
"filter",
'alpha', 3);
59$filtert =
GETPOST(
"search_filtert",
"intcomma", 3) ?
GETPOST(
"search_filtert",
"intcomma", 3) :
GETPOST(
"filtert",
"intcomma", 3);
60$usergroup =
GETPOST(
"search_usergroup",
"intcomma", 3) ?
GETPOST(
"search_usergroup",
"intcomma", 3) :
GETPOST(
"usergroup",
"intcomma", 3);
61$showbirthday = empty($conf->use_javascript_ajax) ?
GETPOSTINT(
"showbirthday") : 1;
62$search_categ_cus =
GETPOST(
"search_categ_cus",
'intcomma', 3) ?
GETPOST(
"search_categ_cus",
'intcomma', 3) : 0;
71$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
72$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
74if (empty($page) || $page == -1) {
78$offset = $limit * $page;
83 $sortfield =
"a.datec";
89 $socid = $user->socid;
96if (!$user->hasRight(
'agenda',
'myactions',
'read')) {
99if (!$user->hasRight(
'agenda',
'allactions',
'read')) {
102if (!$user->hasRight(
'agenda',
'allactions',
'read') || $filter ==
'mine') {
103 $filtert = $user->id;
106$action =
GETPOST(
'action',
'aZ09');
108$mode =
GETPOST(
'mode',
'aZ09');
109if (empty($mode) && preg_match(
'/show_/', $action)) {
112$resourceid =
GETPOST(
"search_resourceid",
'int');
118$status = GETPOSTISSET(
"search_status") ?
GETPOST(
"search_status",
'aZ09') :
GETPOST(
"status",
'aZ09');
119$type = GETPOSTISSET(
"search_type") ?
GETPOST(
"search_type",
'aZ09') :
GETPOST(
"type",
'aZ09');
121$optioncss =
GETPOST(
'optioncss',
'aZ');
124if ($dateselect > 0) {
131if (
GETPOST(
'search_actioncode',
'array:aZ09')) {
132 $actioncode =
GETPOST(
'search_actioncode',
'array:aZ09', 3);
133 if (!count($actioncode)) {
137 $actioncode =
GETPOST(
"search_actioncode",
"alpha", 3) ?
GETPOST(
"search_actioncode",
"alpha", 3) : (
GETPOST(
"search_actioncode") ==
'0' ?
'0' : ((!
getDolGlobalString(
'AGENDA_DEFAULT_FILTER_TYPE') || $disabledefaultvalues) ?
'' :
getDolGlobalString(
'AGENDA_DEFAULT_FILTER_TYPE')));
140if ($status ==
'' && !GETPOSTISSET(
'search_status')) {
141 $status = ((!
getDolGlobalString(
'AGENDA_DEFAULT_FILTER_STATUS') || $disabledefaultvalues) ?
'' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS);
146if (empty($mode) && !GETPOSTISSET(
'mode')) {
147 $mode = $defaultview;
149if ($mode ==
'default') {
150 $mode = (($defaultview !=
'show_list') ? $defaultview :
'show_month');
153 $mode =
'show_month';
158 $week = ($week ? $week : date(
"W"));
159 $day = ($day ? $day : date(
"d"));
163 $day = ($day ? $day : date(
"d"));
169$langs->loadLangs(array(
'agenda',
'other',
'commercial'));
172$hookmanager->initHooks(array(
'agenda'));
174$result =
restrictedArea($user,
'agenda', 0,
'actioncomm&societe',
'myactions|allactions',
'fk_soc',
'id');
175if ($user->socid && $socid) {
184if (
GETPOST(
"viewlist",
'alpha') || $mode ==
'show_list') {
186 if (is_array($_POST)) {
187 foreach ($_POST as $key => $val) {
188 if ($key ==
'token') {
191 $param .=
'&'.$key.
'='.urlencode($val);
194 if (!preg_match(
'/action=/', $param)) {
195 $param .= ($param ?
'&' :
'').
'mode=show_list';
198 header(
"Location: ".DOL_URL_ROOT.
'/comm/action/list.php?'.$param);
202if (
GETPOST(
"viewperuser",
'alpha') || $mode ==
'show_peruser') {
204 if (is_array($_POST)) {
205 foreach ($_POST as $key => $val) {
206 if ($key ==
'token') {
209 $param .=
'&'.$key.
'='.urlencode($val);
213 header(
"Location: ".DOL_URL_ROOT.
'/comm/action/peruser.php?'.$param);
229 'maxprint' => $maxprint,
231 'filtert' => $filtert,
232 'showbirthday' => $showbirthday,
233 'canedit' => $canedit,
234 'optioncss' => $optioncss,
235 'actioncode' => $actioncode,
237 'resourceid' => $resourceid,
238 'usergroup' => $usergroup,
240$reshook = $hookmanager->executeHooks(
'beforeAgenda', $parameters, $object, $action);
245$help_url =
'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda|DE:Modul_Terminplanung';
246llxHeader(
'', $langs->trans(
"Agenda"), $help_url);
248$form =
new Form($db);
249$companystatic =
new Societe($db);
250$contactstatic =
new Contact($db);
251$userstatic =
new User($db);
255$nowyear = $nowarray[
'year'];
256$nowmonth = $nowarray[
'mon'];
257$nowday = $nowarray[
'mday'];
259$listofextcals = array();
264 while ($i < $MAXAGENDA) {
266 $source =
'AGENDA_EXT_SRC'.$i;
267 $name =
'AGENDA_EXT_NAME'.$i;
268 $offsettz =
'AGENDA_EXT_OFFSETTZ'.$i;
269 $color =
'AGENDA_EXT_COLOR'.$i;
270 $default =
'AGENDA_EXT_ACTIVEBYDEFAULT'.$i;
271 $buggedfile =
'AGENDA_EXT_BUGGEDFILE'.$i;
274 $listofextcals[] = array(
275 'type' =>
'globalsetup',
289if (empty($user->conf->AGENDA_DISABLE_EXT)) {
291 while ($i < $MAXAGENDA) {
293 $source =
'AGENDA_EXT_SRC_'.$user->id.
'_'.$i;
294 $name =
'AGENDA_EXT_NAME_'.$user->id.
'_'.$i;
295 $offsettz =
'AGENDA_EXT_OFFSETTZ_'.$user->id.
'_'.$i;
296 $color =
'AGENDA_EXT_COLOR_'.$user->id.
'_'.$i;
297 $enabled =
'AGENDA_EXT_ENABLED_'.$user->id.
'_'.$i;
298 $default =
'AGENDA_EXT_ACTIVEBYDEFAULT_'.$user->id.
'_'.$i;
299 $buggedfile =
'AGENDA_EXT_BUGGEDFILE_'.$user->id.
'_'.$i;
303 $listofextcals[] = array(
304 'type' =>
'usersetup',
307 'offsettz' => (
int) (empty($user->conf->$offsettz) ? 0 : $user->
conf->$offsettz),
317if (empty($mode) || $mode ==
'show_month') {
319 $prev_year = $prev[
'year'];
320 $prev_month = $prev[
'month'];
322 $next_year = $next[
'year'];
323 $next_month = $next[
'month'];
325 $max_day_in_prev_month = (int) date(
"t",
dol_mktime(12, 0, 0, $prev_month, 1, $prev_year,
'gmt'));
326 $max_day_in_month = (int) date(
"t",
dol_mktime(12, 0, 0, $month, 1, $year,
'gmt'));
328 $tmpday = - (int) date(
"w",
dol_mktime(12, 0, 0, $month, 1, $year,
'gmt')) + 2;
329 $tmpday += ((isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1) - 1);
334 $firstdaytoshow =
dol_mktime(0, 0, 0, $prev_month, $max_day_in_prev_month + $tmpday, $prev_year,
'tzuserrel');
335 $next_day = 7 - ($max_day_in_month + 1 - $tmpday) % 7;
339 $lastdaytoshow =
dol_mktime(0, 0, 0, $next_month, $next_day, $next_year,
'tzuserrel');
341if ($mode ==
'show_week') {
343 $prev_year = $prev[
'prev_year'];
344 $prev_month = $prev[
'prev_month'];
345 $prev_day = $prev[
'prev_day'];
346 $first_day = $prev[
'first_day'];
347 $first_month = $prev[
'first_month'];
348 $first_year = $prev[
'first_year'];
350 $week = $prev[
'week'];
354 $next_year = $next[
'year'];
355 $next_month = $next[
'month'];
356 $next_day = $next[
'day'];
359 $firstdaytoshow =
dol_mktime(0, 0, 0, $first_month, $first_day, $first_year,
'tzuserrel');
362 $max_day_in_month = date(
"t",
dol_mktime(0, 0, 0, $month, 1, $year,
'gmt'));
364 $tmpday = $first_day;
366if ($mode ==
'show_day') {
368 $prev_year = $prev[
'year'];
369 $prev_month = $prev[
'month'];
370 $prev_day = $prev[
'day'];
372 $next_year = $next[
'year'];
373 $next_month = $next[
'month'];
374 $next_day = $next[
'day'];
376 $firstdaytoshow =
dol_mktime(0, 0, 0, $prev_month, $prev_day, $prev_year,
'tzuserrel');
377 $lastdaytoshow =
dol_mktime(0, 0, 0, $next_month, $next_day, $next_year,
'tzuserrel');
389if ($actioncode || GETPOSTISSET(
'search_actioncode')) {
390 if (is_array($actioncode)) {
391 foreach ($actioncode as $str_action) {
392 $param .=
"&search_actioncode[]=".urlencode($str_action);
395 $param .=
"&search_actioncode=".urlencode($actioncode);
398if ($resourceid > 0) {
399 $param .=
"&search_resourceid=".urlencode((
string) ($resourceid));
401if ($status || GETPOSTISSET(
'status') || GETPOSTISSET(
'search_status')) {
402 $param .=
"&search_status=".urlencode($status);
405 $param .=
"&search_filter=".urlencode($filter);
408 $param .=
"&search_filtert=".urlencode($filtert);
411 $param .=
"&search_usergroup=".urlencode((
string) ($usergroup));
414 $param .=
"&search_socid=".urlencode((
string) ($socid));
417 $param .=
"&search_showbirthday=1";
420 $param .=
"&search_projectid=".urlencode((
string) ($pid));
423 $param .=
"&search_type=".urlencode($type);
425$param .=
"&maxprint=".urlencode((
string) ($maxprint));
426if ($mode ==
'show_day' || $mode ==
'show_week' || $mode ==
'show_month') {
427 $param .=
'&mode='.urlencode($mode);
429if ($search_categ_cus != 0) {
430 $param .=
'&search_categ_cus='.urlencode((
string) ($search_categ_cus));
435$nav .=
'<div class="navselectiondate inline-block nowraponall">';
436if (empty($mode) || $mode ==
'show_month') {
437 $nav .=
"<a href=\"?year=".$prev_year.
"&month=".$prev_month.$param.
"\"><i class=\"fa fa-chevron-left\"></i></a> \n";
438 $nav .=
" <span id=\"month_name\">".dol_print_date(
dol_mktime(0, 0, 0, $month, 1, $year),
"%b %Y");
439 $nav .=
" </span>\n";
440 $nav .=
" <a href=\"?year=".$next_year.
"&month=".$next_month.$param.
"\"><i class=\"fa fa-chevron-right\"></i></a>\n";
443if ($mode ==
'show_week') {
444 $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";
445 $nav .=
" <span id=\"month_name\">".dol_print_date(
dol_mktime(0, 0, 0, $first_month, $first_day, $first_year),
"%Y").
", ".$langs->trans(
"WeekShort").
" ".$week;
446 $nav .=
" </span>\n";
447 $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";
448 $picto =
'calendarweek';
450if ($mode ==
'show_day') {
451 $nav .=
"<a href=\"?year=".$prev_year.
"&month=".$prev_month.
"&day=".$prev_day.$param.
"\"><i class=\"fa fa-chevron-left\"></i></a> \n";
452 $nav .=
" <span id=\"month_name\">".dol_print_date(
dol_mktime(0, 0, 0, $month, $day, $year),
"daytextshort");
453 $nav .=
" </span>\n";
454 $nav .=
" <a href=\"?year=".$next_year.
"&month=".$next_month.
"&day=".$next_day.$param.
"\"><i class=\"fa fa-chevron-right\"></i></a>\n";
455 $picto =
'calendarday';
457if (empty($conf->dol_optimize_smallscreen)) {
458 $nav .=
' <a href="?year='.$nowyear.
'&month='.$nowmonth.
'&day='.$nowday.$param.
'" class="datenowlink">'.$langs->trans(
"Today").
'</a> ';
462$nav .= $form->selectDate($dateselect,
'dateselect', 0, 0, 1,
'', 1, 0);
464$nav .=
'<button type="submit" class="liste_titre button_search valignmiddle" name="button_search_x" value="x"><span class="fa fa-search"></span></button>';
467$paramnodate = $param;
468$param .=
'&year='.$year.
'&month='.$month.($day ?
'&day='.$day :
'');
483$paramnoaction = preg_replace(
'/mode=[a-z_]+/',
'', preg_replace(
'/action=[a-z_]+/',
'', $param));
484$paramnoactionodate = preg_replace(
'/mode=[a-z_]+/',
'', preg_replace(
'/action=[a-z_]+/',
'', $paramnodate));
488print
'<form method="POST" id="searchFormList" class="listactionsfilter" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
489if ($optioncss !=
'') {
490 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
492print
'<input type="hidden" name="token" value="'.newToken().
'">';
493print
'<input type="hidden" name="mode" value="'.$mode.
'">';
496$viewmode =
'<div class="navmode inline-block">';
498$viewmode .=
'<a class="btnTitle'.($mode ==
'list' ?
' btnTitleSelected' :
'').
' reposition" href="'.DOL_URL_ROOT.
'/comm/action/list.php?mode=show_list&restore_lastsearch_values=1'.$paramnoactionodate.
'">';
500$viewmode .=
img_picto($langs->trans(
"List"),
'object_calendarlist',
'class="imgforviewmode pictoactionview block"');
502$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow">'.$langs->trans(
"ViewList").
'</span></a>';
504$viewmode .=
'<a class="btnTitle'.($mode ==
'show_month' ?
' btnTitleSelected' :
'').
' reposition" href="'.DOL_URL_ROOT.
'/comm/action/index.php?mode=show_month&year='.(isset(
$object->datep) ?
dol_print_date(
$object->datep,
'%Y') : $year).
'&month='.(isset(
$object->datep) ?
dol_print_date(
$object->datep,
'%m') : $month).
'&day='.(isset(
$object->datep) ?
dol_print_date(
$object->datep,
'%d') : $day).$paramnoactionodate.
'">';
506$viewmode .=
img_picto($langs->trans(
"ViewCal"),
'object_calendarmonth',
'class="pictoactionview block"');
508$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow">'.$langs->trans(
"ViewCal").
'</span></a>';
510$viewmode .=
'<a class="btnTitle'.($mode ==
'show_week' ?
' btnTitleSelected' :
'').
' reposition" href="'.DOL_URL_ROOT.
'/comm/action/index.php?mode=show_week&year='.(isset(
$object->datep) ?
dol_print_date(
$object->datep,
'%Y') : $year).
'&month='.(isset(
$object->datep) ?
dol_print_date(
$object->datep,
'%m') : $month).
'&day='.(isset(
$object->datep) ?
dol_print_date(
$object->datep,
'%d') : $day).$paramnoactionodate.
'">';
512$viewmode .=
img_picto($langs->trans(
"ViewWeek"),
'object_calendarweek',
'class="pictoactionview block"');
514$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow">'.$langs->trans(
"ViewWeek").
'</span></a>';
516$viewmode .=
'<a class="btnTitle'.($mode ==
'show_day' ?
' btnTitleSelected' :
'').
' reposition" href="'.DOL_URL_ROOT.
'/comm/action/index.php?mode=show_day&year='.(isset(
$object->datep) ?
dol_print_date(
$object->datep,
'%Y') : $year).
'&month='.(isset(
$object->datep) ?
dol_print_date(
$object->datep,
'%m') : $month).
'&day='.(isset(
$object->datep) ?
dol_print_date(
$object->datep,
'%d') : $day).$paramnoactionodate.
'">';
518$viewmode .=
img_picto($langs->trans(
"ViewDay"),
'object_calendarday',
'class="pictoactionview block"');
520$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow">'.$langs->trans(
"ViewDay").
'</span></a>';
522$viewmode .=
'<a class="btnTitle'.($mode ==
'show_peruser' ?
' btnTitleSelected' :
'').
' reposition" href="'.DOL_URL_ROOT.
'/comm/action/peruser.php?mode=show_peruser&year='.(isset(
$object->datep) ?
dol_print_date(
$object->datep,
'%Y') : $year).
'&month='.(isset(
$object->datep) ?
dol_print_date(
$object->datep,
'%m') : $month).
'&day='.(isset(
$object->datep) ?
dol_print_date(
$object->datep,
'%d') : $day).$paramnoactionodate.
'">';
524$viewmode .=
img_picto($langs->trans(
"ViewPerUser"),
'object_calendarperuser',
'class="pictoactionview block"');
526$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow" title="'.dolPrintHTML($langs->trans(
"ViewPerUser")).
'">'.$langs->trans(
"ViewPerUser").
'</span></a>';
529$parameters = array();
531$reshook = $hookmanager->executeHooks(
'addCalendarView', $parameters, $object, $action);
532if (empty($reshook)) {
533 $viewmode .= $hookmanager->resPrint;
534} elseif ($reshook > 1) {
535 $viewmode = $hookmanager->resPrint;
538$viewmode .=
'</div>';
540$viewmode .=
'<span class="marginrightonly"></span>';
545if ($user->hasRight(
'agenda',
'myactions',
'create') || $user->hasRight(
'agenda',
'allactions',
'create')) {
548 $newparam .=
'&month='.((int) $month).
'&year='.((int) $tmpforcreatebutton[
'year']).
'&mode='.urlencode($mode);
553 $urltocreateaction = DOL_URL_ROOT.
'/comm/action/card.php?action=create';
554 $urltocreateaction .=
'&apyear='.$tmpforcreatebutton[
'year'].
'&apmonth='.$tmpforcreatebutton[
'mon'].
'&apday='.$tmpforcreatebutton[
'mday'].
'&aphour='.$tmpforcreatebutton[
'hours'].
'&apmin='.$tmpforcreatebutton[
'minutes'];
555 $urltocreateaction .=
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].($newparam ?
'?'.$newparam :
''));
557 $newcardbutton .=
dolGetButtonTitle($langs->trans(
"AddAction"),
'',
'fa fa-plus-circle', $urltocreateaction);
565$showextcals = $listofextcals;
566$bookcalcalendars = array();
569if (isModEnabled(
"bookcal")) {
570 $sql =
"SELECT ba.rowid, bc.label, bc.ref, bc.rowid as id_cal";
571 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bookcal_availabilities as ba";
572 $sql .=
" JOIN ".MAIN_DB_PREFIX.
"bookcal_calendar as bc";
573 $sql .=
" ON bc.rowid = ba.fk_bookcal_calendar";
574 $sql .=
" WHERE bc.status = 1";
575 $sql .=
" AND ba.status = 1";
576 if (!empty($filtert) && $filtert != -1) {
577 $sql .=
" AND bc.visibility = ".(int) $filtert ;
579 $resql = $db->query($sql);
581 $num = $db->num_rows($resql);
584 $objp = $db->fetch_object($resql);
585 $label = !empty($objp->label) ? $objp->label : $objp->ref;
586 $bookcalcalendars[
"calendars"][] = array(
"id" => $objp->id_cal,
"label" => $label);
587 $bookcalcalendars[
"availabilitieslink"][$objp->rowid] = $objp->id_cal;
595if (!empty($conf->use_javascript_ajax)) {
596 $s .=
"\n".
'<!-- Div to calendars selectors -->'.
"\n";
598 $s .=
'<script type="text/javascript">'.
"\n";
599 $s .=
'jQuery(document).ready(function () {'.
"\n";
600 $s .=
'jQuery(".check_birthday").click(function() { console.log("Toggle birthdays"); jQuery(".family_birthday").toggle(); });'.
"\n";
601 $s .=
'jQuery(".check_holiday").click(function() { console.log("Toggle holidays"); jQuery(".family_holiday").toggle(); });'.
"\n";
602 if (isModEnabled(
"bookcal") && !empty($bookcalcalendars[
"calendars"])) {
603 foreach ($bookcalcalendars[
"calendars"] as $key => $value) {
604 $s .=
'jQuery(".check_bookcal_calendar_'.$value[
'id'].
'").click(function() { console.log("Toggle Bookcal Calendar '.$value[
'id'].
'"); jQuery(".family_bookcal_calendar_'.$value[
'id'].
'").toggle(); });'.
"\n";
607 if ($mode ==
"show_week" || $mode ==
"show_month" || empty($mode)) {
609 $s .=
'jQuery( "div.sortable" ).sortable({connectWith: ".sortable", placeholder: "ui-state-highlight", items: "div.movable", receive: function( event, ui ) {'.
"\n";
611 $s .=
'console.log("submit form to record new event");'.
"\n";
613 $s .=
'var newval = jQuery(event.target).closest("div.dayevent").attr("id");'.
"\n";
614 $s .=
'console.log("found parent div.dayevent with id = "+newval);'.
"\n";
615 $s .=
'var frm=jQuery("#searchFormList");'.
"\n";
616 $s .=
'var newurl = ui.item.find("a.cal_event").attr("href");'.
"\n";
617 $s .=
'console.log("Found url on href of a.cal_event"+newurl+", we submit form with actionmove=mupdate");'.
"\n";
618 $s .=
'frm.attr("action", newurl).children("#newdate").val(newval);frm.submit();}'.
"\n";
622 $s .=
'</script>'.
"\n";
625 $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>';
628 if ($user->hasRight(
"holiday",
"read")) {
630 <div class="nowrap inline-block minheight30"><input type="checkbox" id="check_holiday" name="check_holiday" value="1" class="check_holiday"' . ($check_holiday
631 ?
' checked' :
'') .
'>
632 <label for="check_holiday" class="labelcalendar">
633 <span class="check_holiday_text">' . $langs->trans(
"Holidays") .
'</span>
639 if (is_array($showextcals) && count($showextcals) > 0) {
640 $s .=
'<script type="text/javascript">'.
"\n";
641 $s .=
'jQuery(document).ready(function () {
642 jQuery("div input[name^=\"check_ext\"]").each(function(index, elem) {
643 var name = jQuery(elem).attr("name");
644 if (jQuery(elem).is(":checked")) {
645 jQuery(".family_ext" + name.replace("check_ext", "")).show();
647 jQuery(".family_ext" + name.replace("check_ext", "")).hide();
651 jQuery("div input[name^=\"check_ext\"]").click(function() {
652 var name = $(this).attr("name");
653 jQuery(".family_ext" + name.replace("check_ext", "")).toggle();
656 $s .=
'</script>'.
"\n";
658 foreach ($showextcals as $val) {
659 $htmlname = md5($val[
'name']);
661 if (!empty($val[
'default']) ||
GETPOSTINT(
'check_ext'.$htmlname)) {
662 $default =
"checked";
667 $tooltip = $langs->trans(
"Cache").
' '.round($DELAYFORCACHE / 60).
'mn';
669 $s .=
'<div class="nowrap inline-block minheight30"><input type="checkbox" id="check_ext'.$htmlname.
'" name="check_ext'.$htmlname.
'" value="1" '.$default.
'><label for="check_ext'.$htmlname.
'" title="'.
dol_escape_htmltag($tooltip).
'" class="labelcalendar">'.
dol_escape_htmltag($val[
'name']).
'</label> </div>';
674 $s .=
'<div class="nowrap inline-block minheight30"><input type="checkbox" id="check_birthday" name="check_birthday" class="check_birthday"><label for="check_birthday" class="labelcalendar"> <span class="check_birthday_text">'.$langs->trans(
"AgendaShowBirthdayEvents").
'</span></label> </div>';
677 if (isModEnabled(
"bookcal")) {
678 if (!empty($bookcalcalendars[
"calendars"])) {
679 foreach ($bookcalcalendars[
"calendars"] as $key => $value) {
680 $label = $value[
'label'];
681 $s .=
'<div class="nowrap inline-block minheight30"><input '.(GETPOST(
'check_bookcal_calendar_'.$value[
'id']) ?
"checked" :
"").
' type="checkbox" id="check_bookcal_calendar_'.$value[
'id'].
'" name="check_bookcal_calendar_'.$value[
'id'].
'" class="check_bookcal_calendar_'.$value[
'id'].
'"><label for="check_bookcal_calendar_'.$value[
'id'].
'" class="labelcalendar"> <span class="check_bookcal_calendar_'.$value[
'id'].
'_text">'.$langs->trans(
"AgendaShowBookcalCalendar", $label).
'</span></label> </div>';
687 $parameters = array();
688 $reshook = $hookmanager->executeHooks(
'addCalendarChoice', $parameters, $object, $action);
689 if (empty($reshook)) {
690 $s .= $hookmanager->resPrint;
691 } elseif ($reshook > 1) {
692 $s = $hookmanager->resPrint;
695 $s .=
"\n".
'<!-- End div to calendars selectors -->'.
"\n";
698 $newparam = preg_replace(
'/showbirthday=[0-1]/i',
'showbirthday='.(empty($showbirthday) ? 1 : 0), $newparam);
699 if (!preg_match(
'/showbirthday=/i', $newparam)) {
700 $newparam .=
'&showbirthday=1';
704 if (empty($showbirthday)) {
705 $link .= $langs->trans(
"AgendaShowBirthdayEvents");
707 $link .= $langs->trans(
"AgendaHideBirthdayEvents");
714$eventarray = array();
722$sql .=
' a.id, a.label,';
725$sql .=
' a.percent,';
726$sql .=
' a.fk_user_author,a.fk_user_action,';
727$sql .=
' a.transparency, a.priority, a.fulldayevent, a.location,';
728$sql .=
' a.fk_soc, a.fk_contact, a.fk_project, a.fk_bookcal_calendar,';
729$sql .=
' a.fk_element, a.elementtype,';
730$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';
732$parameters = array();
733$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
734$sql .= $hookmanager->resPrint;
736$sql .=
' FROM '.MAIN_DB_PREFIX.
'c_actioncomm as ca, '.MAIN_DB_PREFIX.
"actioncomm as a";
738if ($resourceid > 0) {
739 $sql .=
", ".MAIN_DB_PREFIX.
"element_resources as r";
742if ($filtert > 0 || $usergroup > 0) {
743 $sql .=
", ".MAIN_DB_PREFIX.
"actioncomm_resources as ar";
746 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"usergroup_user as ugu ON ugu.fk_user = ar.fk_element";
748$sql .=
' WHERE a.fk_action = ca.id';
749$sql .=
' AND a.entity IN ('.getEntity(
'agenda').
')';
751if (!empty($actioncode)) {
753 if ($actioncode ==
'AC_NON_AUTO') {
754 $sql .=
" AND ca.type != 'systemauto'";
755 } elseif ($actioncode ==
'AC_ALL_AUTO') {
756 $sql .=
" AND ca.type = 'systemauto'";
758 if ($actioncode ==
'AC_OTH') {
759 $sql .=
" AND ca.type != 'systemauto'";
761 if ($actioncode ==
'AC_OTH_AUTO') {
762 $sql .=
" AND ca.type = 'systemauto'";
766 if ($actioncode ==
'AC_NON_AUTO') {
767 $sql .=
" AND ca.type != 'systemauto'";
768 } elseif ($actioncode ==
'AC_ALL_AUTO') {
769 $sql .=
" AND ca.type = 'systemauto'";
771 if (is_array($actioncode)) {
772 $sql .=
" AND ca.code IN (".$db->sanitize(
"'".implode(
"','", $actioncode).
"'", 1).
")";
774 $sql .=
" AND ca.code IN (".$db->sanitize(
"'".implode(
"','", explode(
',', $actioncode)).
"'", 1).
")";
779if ($resourceid > 0) {
780 $sql .=
" AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".((int) $resourceid);
783 $sql .=
" AND a.fk_project=".((int) $pid);
787if (!$user->hasRight(
'societe',
'client',
'voir')) {
788 $search_sale = $user->id;
791if ($search_sale && $search_sale !=
'-1') {
792 if ($search_sale == -2) {
793 $sql .=
" AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = a.fk_soc)";
794 } elseif ($search_sale > 0) {
795 $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).
")";
800 $sql .=
" AND a.fk_soc = ".((int) $socid);
803if ($filtert > 0 || $usergroup > 0) {
804 $sql .=
" AND ar.fk_actioncomm = a.id AND ar.element_type='user'";
807if ($mode ==
'show_day') {
809 $sql .=
" (a.datep BETWEEN '".$db->idate(
dol_mktime(0, 0, 0, $month, $day, $year,
'tzuserrel')).
"'";
810 $sql .=
" AND '".$db->idate(
dol_mktime(23, 59, 59, $month, $day, $year,
'tzuserrel')).
"')";
812 $sql .=
" (a.datep2 BETWEEN '".$db->idate(
dol_mktime(0, 0, 0, $month, $day, $year,
'tzuserrel')).
"'";
813 $sql .=
" AND '".$db->idate(
dol_mktime(23, 59, 59, $month, $day, $year,
'tzuserrel')).
"')";
815 $sql .=
" (a.datep < '".$db->idate(
dol_mktime(0, 0, 0, $month, $day, $year,
'tzuserrel')).
"'";
816 $sql .=
" AND a.datep2 > '".$db->idate(
dol_mktime(23, 59, 59, $month, $day, $year,
'tzuserrel')).
"')";
821 $sql .=
" (a.datep BETWEEN '".$db->idate(
dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7)).
"'";
822 $sql .=
" AND '".$db->idate(
dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10)).
"')";
824 $sql .=
" (a.datep2 BETWEEN '".$db->idate(
dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7)).
"'";
825 $sql .=
" AND '".$db->idate(
dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10)).
"')";
827 $sql .=
" (a.datep < '".$db->idate(
dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7)).
"'";
828 $sql .=
" AND a.datep2 > '".$db->idate(
dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10)).
"')";
832 $sql .=
" AND ca.id = ".((int) $type);
836 $sql .=
" AND a.percent = 0";
838if ($status ==
'na') {
840 $sql .=
" AND a.percent = -1";
842if ($status ==
'50') {
844 $sql .=
" AND (a.percent > 0 AND a.percent < 100)";
846if ($status ==
'done' || $status ==
'100') {
847 $sql .=
" AND (a.percent = 100)";
849if ($status ==
'todo') {
850 $sql .=
" AND (a.percent >= 0 AND a.percent < 100)";
853if ($filtert > 0 || $usergroup > 0) {
856 $sql .=
"ar.fk_element = ".((int) $filtert);
858 if ($usergroup > 0) {
859 $sql .= ($filtert > 0 ?
" OR " :
"").
" ugu.fk_usergroup = ".((
int) $usergroup);
865if ($search_categ_cus != -1) {
866 if ($search_categ_cus == -2) {
867 $sql .=
" AND NOT EXISTS (SELECT ca.fk_actioncomm FROM ".MAIN_DB_PREFIX.
"categorie_actioncomm as ca WHERE ca.fk_actioncomm = a.id)";
868 } elseif ($search_categ_cus > 0) {
869 $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).
"))";
874$sql .=
' ORDER BY datep';
877dol_syslog(
"comm/action/index.php", LOG_DEBUG);
878$resql = $db->query($sql);
880 $num = $db->num_rows($resql);
882 $MAXONSAMEPAGE = 10000;
884 while ($i < $num && $i < $MAXONSAMEPAGE) {
885 $obj = $db->fetch_object($resql);
888 if (
getDolGlobalString(
'AGENDA_ALWAYS_HIDE_AUTO') && $obj->type_code ==
'AC_OTH_AUTO') {
896 $event->id = $obj->id;
897 $event->ref = $event->id;
899 $event->fulldayevent = $obj->fulldayevent;
902 if ($event->fulldayevent) {
904 $event->datep = $db->jdate($obj->datep, $tzforfullday ?
'tzuser' :
'tzserver');
905 $event->datef = $db->jdate($obj->datep2, $tzforfullday ?
'tzuser' :
'tzserver');
908 $event->datep = $db->jdate($obj->datep,
'tzserver');
909 $event->datef = $db->jdate($obj->datep2,
'tzserver');
915 $event->type_code = $obj->type_code;
916 $event->type_label = $obj->type_label;
917 $event->type_color = $obj->type_color;
918 $event->type = $obj->type_type;
919 $event->type_picto = $obj->type_picto;
921 $event->label = $obj->label;
922 $event->percentage = $obj->percent;
924 $event->authorid = $obj->fk_user_author;
925 $event->userownerid = $obj->fk_user_action;
926 $event->fetch_userassigned();
928 $event->priority = $obj->priority;
929 $event->location = $obj->location;
930 $event->transparency = $obj->transparency;
931 $event->fk_element = $obj->fk_element;
932 $event->elementtype = $obj->elementtype;
934 $event->fk_project = $obj->fk_project;
936 $event->socid = $obj->fk_soc;
937 $event->contact_id = $obj->fk_contact;
938 $event->fk_bookcal_calendar = $obj->fk_bookcal_calendar;
939 if (!empty($event->fk_bookcal_calendar)) {
940 $event->type =
"bookcal_calendar";
945 $event->date_start_in_calendar = $event->datep;
946 if ($event->datef !=
'' && $event->datef >= $event->datep) {
947 $event->date_end_in_calendar = $event->datef;
949 $event->date_end_in_calendar = $event->datep;
953 if ($event->date_end_in_calendar < $firstdaytoshow || $event->date_start_in_calendar >= $lastdaytoshow) {
956 if ($event->date_start_in_calendar < $firstdaytoshow) {
957 $event->date_start_in_calendar = $firstdaytoshow;
959 if ($event->date_end_in_calendar >= $lastdaytoshow) {
960 $event->date_end_in_calendar = ($lastdaytoshow - 1);
964 $daycursor = $event->date_start_in_calendar;
969 $daycursorend = $event->date_end_in_calendar;
981 $daykey =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
982 $daykeyend =
dol_mktime(0, 0, 0, $moisend, $jourend, $anneeend,
'gmt');
996 $eventarray[$daykey][] = $event;
999 $daykey += 60 * 60 * 24;
1001 if ($daykey > $daykeyend) {
1010 $parameters[
'obj'] = $obj;
1011 $reshook = $hookmanager->executeHooks(
'hookEventElements', $parameters, $event, $action);
1012 $event = $hookmanager->resPrint;
1029 $sql =
'SELECT sp.rowid, sp.lastname, sp.firstname, sp.birthday';
1030 $sql .=
' FROM '.MAIN_DB_PREFIX.
'socpeople as sp';
1031 $sql .=
' WHERE (priv=0 OR (priv=1 AND fk_user_creat='.((int) $user->id).
'))';
1032 $sql .=
" AND sp.entity IN (".getEntity(
'contact').
")";
1033 if ($mode ==
'show_day') {
1034 $sql .=
' AND MONTH(birthday) = '.((int) $month);
1035 $sql .=
' AND DAY(birthday) = '.((int) $day);
1037 $sql .=
' AND MONTH(birthday) = '.((int) $month);
1039 $sql .=
' ORDER BY birthday';
1041 dol_syslog(
"comm/action/index.php", LOG_DEBUG);
1042 $resql = $db->query($sql);
1044 $num = $db->num_rows($resql);
1047 $obj = $db->fetch_object($resql);
1051 $event->id = $obj->rowid;
1052 $event->ref = $event->id;
1057 $event->datep =
dol_mktime(0, 0, 0, $datearray[
'mon'], $datearray[
'mday'], $year,
true);
1058 $event->datef = $event->datep;
1060 $event->type_code =
'BIRTHDAY';
1061 $event->type_label =
'';
1062 $event->type_color =
'';
1063 $event->type =
'birthdate';
1064 $event->type_picto =
'birthdate';
1066 $event->label = $langs->trans(
"Birthday").
' '.
dolGetFirstLastname($obj->firstname, $obj->lastname);
1067 $event->percentage = 100;
1068 $event->fulldayevent = 1;
1070 $event->contact_id = $obj->rowid;
1072 $event->date_start_in_calendar = $db->jdate($event->datep);
1073 $event->date_end_in_calendar = $db->jdate($event->datef);
1076 $daycursor = $event->datep;
1081 $daykey =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
1083 $eventarray[$daykey][] = $event;
1100if ($user->hasRight(
"holiday",
"read")) {
1102 $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";
1103 $sql .=
" FROM ".MAIN_DB_PREFIX.
"holiday as x, ".MAIN_DB_PREFIX.
"user as u";
1104 $sql .=
" WHERE u.rowid = x.fk_user";
1105 $sql .=
" AND u.statut = '1'";
1106 $sql .=
" AND (x.statut = '2' OR x.statut = '3')";
1108 if ($mode ==
'show_day') {
1110 $sql .=
" AND '".$db->escape($year).
"-".$db->escape($month).
"-".$db->escape($day).
"' BETWEEN x.date_debut AND x.date_fin";
1111 } elseif ($mode ==
'show_week') {
1113 $sql .=
" AND date_debut < '".$db->idate(
dol_get_last_day($year, $month)).
"'";
1115 } elseif ($mode ==
'show_month') {
1117 $sql .=
" AND date_debut <= '".$db->idate(
dol_get_last_day($year, $month)).
"'";
1121 $resql = $db->query($sql);
1123 $num = $db->num_rows($resql);
1127 $obj = $db->fetch_object($resql);
1132 $event->id = $obj->rowid;
1133 $event->ref = $event->id;
1135 $event->type_code =
'HOLIDAY';
1136 $event->type_label =
'';
1137 $event->type_color =
'';
1138 $event->type =
'holiday';
1139 $event->type_picto =
'holiday';
1141 $event->datep = $db->jdate($obj->date_start) + (empty($halfday) || $halfday == 1 ? 0 : 12 * 60 * 60 - 1);
1142 $event->datef = $db->jdate($obj->date_end) + (empty($halfday) || $halfday == -1 ? 24 : 12) * 60 * 60 - 1;
1143 $event->date_start_in_calendar = $event->datep;
1144 $event->date_end_in_calendar = $event->datef;
1146 if ($obj->status == 3) {
1148 $event->percentage = -1;
1149 } elseif ($obj->status == 2) {
1151 $event->percentage = 0;
1154 if ($obj->halfday == 1) {
1155 $event->label = $obj->lastname.
' ('.$langs->trans(
"Morning").
')';
1156 } elseif ($obj->halfday == -1) {
1157 $event->label = $obj->lastname.
' ('.$langs->trans(
"Afternoon").
')';
1159 $event->label = $obj->lastname;
1162 $daycursor = $event->date_start_in_calendar;
1167 $daykey =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
1169 $eventarray[$daykey][] = $event;
1171 $daykey += 60 * 60 * 24;
1172 }
while ($daykey <= $event->date_end_in_calendar);
1181if (count($listofextcals)) {
1182 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/ical.class.php';
1184 foreach ($listofextcals as $key => $extcal) {
1185 $url = $extcal[
'src'];
1186 $namecal = $extcal[
'name'];
1187 $offsettz = $extcal[
'offsettz'];
1188 $colorcal = $extcal[
'color'];
1189 $buggedfile = $extcal[
'buggedfile'];
1195 $ical->parse($url, $pathforcachefile, $DELAYFORCACHE);
1198 $listofextcals[$key][
'error'] = $ical->error;
1199 $s .=
'<br><div class="warning">'.dol_escape_htmltag($listofextcals[$key][
'name']).
': '.$url.
'<br>Error message: '.
dol_escape_htmltag($ical->error).
'</div>';
1204 $icalevents = array();
1205 if (is_array($ical->get_event_list())) {
1206 $icalevents = array_merge($icalevents, $ical->get_event_list());
1208 if (is_array($ical->get_freebusy_list())) {
1209 $icalevents = array_merge($icalevents, $ical->get_freebusy_list());
1212 if (count($icalevents) > 0) {
1214 $moreicalevents = array();
1215 foreach ($icalevents as $icalevent) {
1216 if (isset($icalevent[
'RRULE']) && is_array($icalevent[
'RRULE'])) {
1219 if ($icalevent[
'DTSTART;VALUE=DATE']) {
1222 } elseif (is_array($icalevent[
'DTSTART']) && !empty($icalevent[
'DTSTART'][
'unixtime'])) {
1223 $datecurstart = $icalevent[
'DTSTART'][
'unixtime'];
1224 $datecurend = $icalevent[
'DTEND'][
'unixtime'];
1225 if (!empty($ical->cal[
'DAYLIGHT'][
'DTSTART']) && $datecurstart) {
1227 $tmpcurstart = $datecurstart;
1228 $tmpcurend = $datecurend;
1229 $tmpdaylightstart =
dol_mktime(0, 0, 0, 1, 1, 1970, 1) + (int) $ical->cal[
'DAYLIGHT'][
'DTSTART'];
1230 $tmpdaylightend =
dol_mktime(0, 0, 0, 1, 1, 1970, 1) + (int) $ical->cal[
'STANDARD'][
'DTSTART'];
1233 if ($tmpcurstart >= $tmpdaylightstart && $tmpcurstart < $tmpdaylightend) {
1234 $datecurstart -= ((int) $ical->cal[
'DAYLIGHT'][
'TZOFFSETTO']) * 36;
1236 $datecurstart -= ((int) $ical->cal[
'STANDARD'][
'TZOFFSETTO']) * 36;
1238 if ($tmpcurend >= $tmpdaylightstart && $tmpcurstart < $tmpdaylightend) {
1239 $datecurend -= ((int) $ical->cal[
'DAYLIGHT'][
'TZOFFSETTO']) * 36;
1241 $datecurend -= ((int) $ical->cal[
'STANDARD'][
'TZOFFSETTO']) * 36;
1248 dol_syslog(
"Found a not recognized repeatable record with unknown date start", LOG_ERR);
1253 $interval = (empty($icalevent[
'RRULE'][
'INTERVAL']) ? 1 : $icalevent[
'RRULE'][
'INTERVAL']);
1254 $until = empty($icalevent[
'RRULE'][
'UNTIL']) ? 0 :
dol_stringtotime($icalevent[
'RRULE'][
'UNTIL'], 1);
1255 $maxrepeat = empty($icalevent[
'RRULE'][
'COUNT']) ? 0 : $icalevent[
'RRULE'][
'COUNT'];
1256 if ($until && ($until + ($datecurend - $datecurstart)) < $firstdaytoshow) {
1259 if ($datecurstart >= $lastdaytoshow) {
1264 while (($datecurstart < $lastdaytoshow) && (empty($maxrepeat) || ($numofevent < $maxrepeat))) {
1265 if ($datecurend >= $firstdaytoshow) {
1266 $newevent = $icalevent;
1267 unset($newevent[
'RRULE']);
1268 if ($icalevent[
'DTSTART;VALUE=DATE']) {
1269 $newevent[
'DTSTART;VALUE=DATE'] =
dol_print_date($datecurstart,
'%Y%m%d');
1270 $newevent[
'DTEND;VALUE=DATE'] =
dol_print_date($datecurend + 1,
'%Y%m%d');
1272 $newevent[
'DTSTART'] = $datecurstart;
1273 $newevent[
'DTEND'] = $datecurend;
1275 $moreicalevents[] = $newevent;
1279 $savdatecurstart = $datecurstart;
1280 if ($icalevent[
'RRULE'][
'FREQ'] ==
'DAILY') {
1284 if ($icalevent[
'RRULE'][
'FREQ'] ==
'WEEKLY') {
1287 } elseif ($icalevent[
'RRULE'][
'FREQ'] ==
'MONTHLY') {
1290 } elseif ($icalevent[
'RRULE'][
'FREQ'] ==
'YEARLY') {
1295 if ($savdatecurstart >= $datecurstart) {
1296 dol_syslog(
"Found a rule freq ".$icalevent[
'RRULE'][
'FREQ'].
" not managed by dolibarr code. Assume 1 week frequency.", LOG_ERR);
1297 $datecurstart += 3600 * 24 * 7;
1298 $datecurend += 3600 * 24 * 7;
1303 $icalevents = array_merge($icalevents, $moreicalevents);
1306 foreach ($icalevents as $icalevent) {
1311 if (!empty($icalevent[
'RRULE'])) {
1318 if (isset($icalevent[
'DTSTART;VALUE=DATE'])) {
1321 if (empty($icalevent[
'DTEND;VALUE=DATE'])) {
1322 $dateend = $datestart + 86400 - 1;
1328 $event->fulldayevent = 1;
1330 } elseif (!is_array($icalevent[
'DTSTART'])) {
1331 $datestart = $icalevent[
'DTSTART'];
1332 $dateend = empty($icalevent[
'DTEND']) ? $datestart : $icalevent[
'DTEND'];
1334 $datestart += +($offsettz * 3600);
1335 $dateend += +($offsettz * 3600);
1340 } elseif (isset($icalevent[
'DTSTART'][
'unixtime'])) {
1341 $datestart = $icalevent[
'DTSTART'][
'unixtime'];
1342 $dateend = $icalevent[
'DTEND'][
'unixtime'];
1344 $datestart += +($offsettz * 3600);
1345 $dateend += +($offsettz * 3600);
1348 if ($buggedfile ===
'uselocalandtznodaylight') {
1352 if ($buggedfile ===
'uselocalandtzdaylight') {
1353 $localtzs =
new DateTimeZone(preg_replace(
'/"/',
'', $icalevent[
'DTSTART'][
'TZID']));
1354 $localtze =
new DateTimeZone(preg_replace(
'/"/',
'', $icalevent[
'DTEND'][
'TZID']));
1355 $localdts =
new DateTime(
dol_print_date($datestart,
'dayrfc',
'gmt'), $localtzs);
1356 $localdte =
new DateTime(
dol_print_date($dateend,
'dayrfc',
'gmt'), $localtze);
1357 $tmps = -1 * $localtzs->getOffset($localdts);
1358 $tmpe = -1 * $localtze->getOffset($localdte);
1359 $datestart += $tmps;
1367 $event->id = $icalevent[
'UID'];
1368 $event->ref = $event->id;
1369 $userId = $userstatic->findUserIdByEmail($namecal);
1370 if (!empty($userId) && $userId > 0) {
1371 $event->userassigned[$userId] = $userId;
1372 $event->percentage = -1;
1375 $event->type_code =
"ICALEVENT";
1376 $event->type_label = $namecal;
1377 $event->type_color = $colorcal;
1378 $event->type =
'icalevent';
1379 $event->type_picto =
'rss';
1381 $event->icalname = $namecal;
1382 $event->icalcolor = $colorcal;
1384 $event->datep = $datestart + $usertime;
1385 $event->datef = $dateend + $usertime;
1387 if (isset($icalevent[
'SUMMARY']) && $icalevent[
'SUMMARY']) {
1389 } elseif (isset($icalevent[
'DESCRIPTION']) && $icalevent[
'DESCRIPTION']) {
1392 $event->label = $langs->trans(
"ExtSiteNoLabel");
1399 if (!empty($icalevent[
'PRIORITY'])) {
1400 $event->priority = $icalevent[
'PRIORITY'];
1404 if (!empty($icalevent[
'TRANSP'])) {
1405 if ($icalevent[
'TRANSP'] ==
"TRANSPARENT") {
1406 $event->transparency = 0;
1408 if ($icalevent[
'TRANSP'] ==
"OPAQUE") {
1409 $event->transparency = 1;
1420 if (!empty($icalevent[
'LOCATION'])) {
1421 $event->location = $icalevent[
'LOCATION'];
1424 $event->date_start_in_calendar = $event->datep;
1426 if ($event->datef !=
'' && $event->datef >= $event->datep) {
1427 $event->date_end_in_calendar = $event->datef;
1429 $event->date_end_in_calendar = $event->datep;
1433 if ($event->date_end_in_calendar < $firstdaytoshow || $event->date_start_in_calendar >= $lastdaytoshow) {
1439 if ($event->date_start_in_calendar < $firstdaytoshow) {
1440 $event->date_start_in_calendar = $firstdaytoshow;
1442 if ($event->date_end_in_calendar >= $lastdaytoshow) {
1443 $event->date_end_in_calendar = ($lastdaytoshow - 1);
1447 $daycursor = $event->date_start_in_calendar;
1456 $daykey =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
1457 $daykeygmt =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
1460 $eventarray[$daykey][] = $event;
1461 $daykey += 60 * 60 * 24;
1462 $daykeygmt += 60 * 60 * 24;
1463 if (($event->fulldayevent ? $daykeygmt : $daykey) > $event->date_end_in_calendar) {
1475$parameters = array();
1477$reshook = $hookmanager->executeHooks(
'getCalendarEvents', $parameters, $object, $action);
1478if (!empty($hookmanager->resArray[
'eventarray'])) {
1479 foreach ($hookmanager->resArray[
'eventarray'] as $keyDate => $events) {
1480 if (!isset($eventarray[$keyDate])) {
1481 $eventarray[$keyDate] = array();
1483 $eventarray[$keyDate] = array_merge($eventarray[$keyDate], $events);
1488foreach ($eventarray as $keyDate => &$dateeventarray) {
1489 usort($dateeventarray,
'sort_events_by_date');
1494$cachethirdparties = array();
1495$cachecontacts = array();
1496$cacheusers = array();
1499$color_file = DOL_DOCUMENT_ROOT.
"/theme/".$conf->theme.
"/theme_vars.inc.php";
1500if (is_readable($color_file)) {
1501 include $color_file;
1503if (!is_array($theme_datacolor)) {
1504 $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));
1507$massactionbutton =
'';
1509print_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);
1515if (empty($mode) || $mode ==
'show_month') {
1517 $newparam = preg_replace(
'/showbirthday=/i',
'showbirthday_=', $newparam);
1518 $newparam = preg_replace(
'/mode=show_month&?/i',
'', $newparam);
1519 $newparam = preg_replace(
'/mode=show_week&?/i',
'', $newparam);
1520 $newparam = preg_replace(
'/day=[0-9]+&?/i',
'', $newparam);
1521 $newparam = preg_replace(
'/month=[0-9]+&?/i',
'', $newparam);
1522 $newparam = preg_replace(
'/year=[0-9]+&?/i',
'', $newparam);
1523 $newparam = preg_replace(
'/viewcal=[0-9]+&?/i',
'', $newparam);
1524 $newparam = preg_replace(
'/showbirthday_=/i',
'showbirthday=', $newparam);
1525 $newparam .=
'&viewcal=1';
1527 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1528 print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup,
'', $resourceid, $search_categ_cus);
1531 print
'<div class="div-table-responsive-no-min sectioncalendarbymonth maxscreenheightless300">';
1532 print
'<table class="centpercent noborder nocellnopadd cal_pannel cal_month">';
1533 print
' <tr class="liste_titre">';
1535 echo
' <td class="center">#</td>';
1538 print
' <td class="center bold uppercase tdfordaytitle'.($i == 0 ?
' borderleft' :
'').
'">';
1539 $numdayinweek = (($i + (isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1)) % 7);
1540 if (!empty($conf->dol_optimize_smallscreen)) {
1541 $labelshort = array(0 =>
'SundayMin', 1 =>
'MondayMin', 2 =>
'TuesdayMin', 3 =>
'WednesdayMin', 4 =>
'ThursdayMin', 5 =>
'FridayMin', 6 =>
'SaturdayMin');
1542 print $langs->trans($labelshort[$numdayinweek]);
1544 print $langs->trans(
"Day".$numdayinweek);
1546 print
' </td>'.
"\n";
1552 $todaytms =
dol_mktime(0, 0, 0, $todayarray[
'mon'], $todayarray[
'mday'], $todayarray[
'year']);
1556 for ($iter_week = 0; $iter_week < 6; $iter_week++) {
1560 $currdate0 = sprintf(
"%04d", $prev_year).sprintf(
"%02d", $prev_month).sprintf(
"%02d", $max_day_in_prev_month + $tmpday);
1561 } elseif ($tmpday <= $max_day_in_month) {
1562 $currdate0 = sprintf(
"%04d", $year).sprintf(
"%02d", $month).sprintf(
"%02d", $tmpday);
1564 $currdate0 = sprintf(
"%04d", $next_year).sprintf(
"%02d", $next_month).sprintf(
"%02d", $tmpday - $max_day_in_month);
1567 $numweek0 = date(
"W", strtotime(date($currdate0)));
1569 echo
' <td class="center weeknumber opacitymedium" width="2%">'.$numweek0.
'</td>';
1571 for ($iter_day = 0; $iter_day < 7; $iter_day++) {
1574 $style =
'cal_other_month cal_past';
1575 if ($iter_day == 6) {
1576 $style .=
' cal_other_month_right';
1578 echo
' <td class="'.$style.
' nowrap tdtop" width="14%">';
1580 show_day_events($db, $max_day_in_prev_month + $tmpday, $prev_month, $prev_year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam);
1582 } elseif ($tmpday <= $max_day_in_month) {
1584 $curtime =
dol_mktime(0, 0, 0, $month, $tmpday, $year);
1585 $style =
'cal_current_month';
1586 if ($iter_day == 6) {
1587 $style .=
' cal_current_month_right';
1590 if ($todayarray[
'mday'] == $tmpday && $todayarray[
'mon'] == $month && $todayarray[
'year'] == $year) {
1594 $style =
'cal_today';
1596 if ($curtime < $todaytms) {
1597 $style .=
' cal_past';
1600 echo
' <td class="'.$style.
' nowrap tdtop" width="14%">';
1602 show_day_events($db, $tmpday, $month, $year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam, 0, 60, 0, $bookcalcalendars);
1606 $style =
'cal_other_month';
1607 if ($iter_day == 6) {
1608 $style .=
' cal_other_month_right';
1610 echo
' <td class="'.$style.
' nowrap tdtop" width="14%">';
1612 show_day_events($db, $tmpday - $max_day_in_month, $next_month, $next_year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam);
1622 print
'<input type="hidden" name="actionmove" value="mupdate">';
1623 print
'<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($_SERVER[
'PHP_SELF']).
'?mode=show_month&'.
dol_escape_htmltag($_SERVER[
'QUERY_STRING']).
'">';
1624 print
'<input type="hidden" name="newdate" id="newdate">';
1625} elseif ($mode ==
'show_week') {
1628 $newparam = preg_replace(
'/showbirthday=/i',
'showbirthday_=', $newparam);
1629 $newparam = preg_replace(
'/mode=show_month&?/i',
'', $newparam);
1630 $newparam = preg_replace(
'/mode=show_week&?/i',
'', $newparam);
1631 $newparam = preg_replace(
'/day=[0-9]+&?/i',
'', $newparam);
1632 $newparam = preg_replace(
'/month=[0-9]+&?/i',
'', $newparam);
1633 $newparam = preg_replace(
'/year=[0-9]+&?/i',
'', $newparam);
1634 $newparam = preg_replace(
'/viewweek=[0-9]+&?/i',
'', $newparam);
1635 $newparam = preg_replace(
'/showbirthday_=/i',
'showbirthday=', $newparam);
1636 $newparam .=
'&viewweek=1';
1638 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1639 print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup,
'', $resourceid);
1642 print
'<div class="div-table-responsive-no-min sectioncalendarbyweek maxscreenheightless300">';
1643 print
'<table class="centpercent noborder nocellnopadd cal_pannel cal_month">';
1644 print
' <tr class="liste_titre">';
1647 echo
' <td class="center bold uppercase tdfordaytitle">'.$langs->trans(
"Day".(($i + (isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1)) % 7)).
"</td>\n";
1654 for ($iter_day = 0; $iter_day < 7; $iter_day++) {
1661 $style =
'cal_current_month';
1662 if ($iter_day == 6) {
1663 $style .=
' cal_other_month_right';
1668 if ($todayarray[
'mday'] == $tmpday && $todayarray[
'mon'] == $tmpmonth && $todayarray[
'year'] == $tmpyear) {
1672 $style =
'cal_today';
1675 echo
' <td class="'.$style.
'" width="14%" valign="top">';
1677 show_day_events($db, $tmpday, $tmpmonth, $tmpyear, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 0, $bookcalcalendars);
1685 echo
'<input type="hidden" name="actionmove" value="mupdate">';
1686 echo
'<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($_SERVER[
'PHP_SELF']).
'?mode=show_week&'.
dol_escape_htmltag($_SERVER[
'QUERY_STRING']).
'">';
1687 echo
'<input type="hidden" name="newdate" id="newdate">';
1690 $newparam = preg_replace(
'/mode=show_month&?/i',
'', $newparam);
1691 $newparam = preg_replace(
'/mode=show_week&?/i',
'', $newparam);
1692 $newparam = preg_replace(
'/viewday=[0-9]+&?/i',
'', $newparam);
1693 $newparam .=
'&viewday=1';
1695 $style =
'cal_current_month cal_current_month_oneday';
1698 if ($todayarray[
'mday'] == $day && $todayarray[
'mon'] == $month && $todayarray[
'year'] == $year) {
1703 $timestamp =
dol_mktime(12, 0, 0, $month, $day, $year);
1706 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1707 print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup,
'', $resourceid);
1710 print
'<div class="div-table-responsive-no-min sectioncalendarbyday maxscreenheightless300">';
1711 echo
'<table class="tagtable centpercent noborder nocellnopadd cal_pannel cal_month noborderbottom" style="margin-bottom: 5px !important;">';
1713 echo
' <tr class="tagtr liste_titre">';
1714 echo
' <td class="tagtd center bold uppercase">'.$langs->trans(
"Day".$arraytimestamp[
'wday']).
"</td>\n";
1732 print
'<div class="div-table-responsive-no-min borderbottom">';
1734 $maxheightwin = (isset($_SESSION[
"dol_screenheight"]) && $_SESSION[
"dol_screenheight"] > 500) ? ($_SESSION[
"dol_screenheight"] - 200) : 660;
1736 echo
'<div style="max-height: '.$maxheightwin.
'px;">';
1737 echo
'<div class="tagtable centpercent calendarviewcontainer">';
1742 $minhour = round((
float) $tmp[0], 0);
1743 $maxhour = round((
float) $tmp[1], 0);
1744 if ($minhour > 23) {
1750 if ($maxhour <= $minhour) {
1751 $maxhour = $minhour + 1;
1757 echo
' <div class="tagtr calendarviewcontainertr">'.
"\n";
1758 echo
' <div class="tagtd width100 tdtop">'.dol_print_date($i * 3600,
'hour',
'gmt').
'</div>';
1759 echo
' <div class="tagtd '.$style.
' tdtop"></div>'.
"\n";
1760 echo
' </div>'.
"\n";
1765 echo
'</div></div>';
1768 show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 1, $bookcalcalendars);
1772 print
'<div class="div-table-responsive-no-min borderbottom">';
1775 show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 0, $bookcalcalendars);
1781print
"\n".
'</form>';
1807function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventarray, $maxprint = 0, $maxnbofchar = 16, $newparam =
'', $showinfo = 0, $minheight = 60, $nonew = 0, $bookcalcalendarsarray = array())
1809 global $user, $conf, $langs;
1810 global $action, $mode, $filter, $filtert, $status, $actioncode, $usergroup;
1811 global $theme_datacolor;
1812 global $cachethirdparties, $cachecontacts, $cacheusers, $colorindexused;
1813 global $hookmanager;
1815 '@phan-var-force array{0:array{0:int,1:int,2:int},1:array{0:int,1:int,2:int},2:array{0:int,1:int,2:int},3:array{0:int,1:int,2:int}} $theme_datacolor
1816 @phan-var-force User[] $cacheusers
1817 @phan-var-force array<int<0,3>> $colorindexused';
1819 if ($conf->use_javascript_ajax) {
1820 $conf->global->MAIN_JS_SWITCH_AGENDA = 1;
1823 $dateint = sprintf(
"%04d", $year).sprintf(
"%02d", $month).sprintf(
"%02d", $day);
1829 $curtime =
dol_mktime(0, 0, 0, $month, $day, $year);
1830 $urltoshow = DOL_URL_ROOT.
'/comm/action/index.php?mode=show_day&day='.str_pad((
string) $day, 2,
"0", STR_PAD_LEFT).
'&month='.str_pad((
string) $month, 2,
"0", STR_PAD_LEFT).
'&year='.$year.$newparam;
1832 if ($user->hasRight(
'agenda',
'myactions',
'create') || $user->hasRight(
'agenda',
'allactions',
'create')) {
1833 $newparam .=
'&month='.str_pad((
string) $month, 2,
"0", STR_PAD_LEFT).
'&year='.$year;
1834 $hourminsec =
'100000';
1835 $urltocreate = DOL_URL_ROOT.
'/comm/action/card.php?action=create&datep='.sprintf(
"%04d%02d%02d", $year, $month, $day).$hourminsec.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].($newparam ?
'?'.$newparam :
''));
1839 print
'<div id="dayevent_'.$dateint.
'" class="dayevent tagtable centpercent nobordernopadding">'.
"\n";
1842 print
'<div class="tagtr cursorpointer" onclick="window.location=\''.$urltocreate.
'\';
"><div class="nowrap tagtd
"><div class="left
inline-block
">';
1843 print '<a class="dayevent-aday
" style="color: #666
" href="'.$urltoshow.'">';
1845 print dol_print_date($curtime, 'daytextshort');
1847 print dol_print_date($curtime, '%d');
1850 print '</div><div class="nowrap floatright
inline-block marginrightonly
">';
1851 if ($user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create')) {
1852 print '<a class="cursoradd
" href="'.$urltocreate.'">'; // Explicit link, useful for nojs interfaces
1853 print img_picto($langs->trans("NewAction
"), 'edit_add.png');
1856 print '</div></div></div>'."\n
";
1864 // Line with td contains all div of each events
1865 print '<div class="tagtr
">';
1866 print '<div class="tagtd centpercent agendacell sortable
">';
1868 //$curtime = dol_mktime (0, 0, 0, $month, $day, $year);
1875 $numicals = array();
1876 $ymd = sprintf("%04d
", $year).sprintf("%02d
", $month).sprintf("%02d
", $day);
1878 $colorindexused[$user->id] = 0; // Color index for current user (user->id) is always 0
1879 $nextindextouse = is_array($colorindexused) ? count($colorindexused) : 0; // At first run this is 0, so fist user has 0, next 1, ...
1880 //var_dump($colorindexused);
1882 include_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php';
1883 $tmpholiday = new Holiday($db);
1885 foreach ($eventarray as $daykey => $notused) { // daykey is the 'YYYYMMDD' to show according to user
1886 $annee = dol_print_date($daykey, '%Y', 'gmt'); // We use gmt because we want the value represented by string 'YYYYMMDD'
1887 $mois = dol_print_date($daykey, '%m', 'gmt'); // We use gmt because we want the value represented by string 'YYYYMMDD'
1888 $jour = dol_print_date($daykey, '%d', 'gmt'); // We use gmt because we want the value represented by string 'YYYYMMDD'
1890 //print 'event daykey='.$daykey.' dol_print_date(daykey)='.dol_print_date($daykey, 'dayhour', 'gmt').' jour='.$jour.' mois='.$mois.' annee='.$annee."<br>\n
";
1891 //print 'event daykey='.$daykey.' dol_print_date(daykey)='.dol_print_date($daykey, 'dayhour', 'gmt').' day='.$day.' month='.$month.' year='.$year."<br>\n
";
1893 if ($day == $jour && $month == $mois && $year == $annee) {
1894 foreach ($eventarray[$daykey] as $index => $event) {
1895 if ($i < $maxprint || $maxprint == 0 || getDolGlobalString('MAIN_JS_SWITCH_AGENDA')) {
1896 $keysofuserassigned = array_keys($event->userassigned);
1897 $ponct = ($event->date_start_in_calendar == $event->date_end_in_calendar);
1899 // Define $color (Hex string like '0088FF') and $cssclass of event
1903 if (in_array($user->id, $keysofuserassigned)) {
1904 $cssclass = 'family_mytasks';
1906 if (empty($cacheusers[$event->userownerid])) {
1907 $newuser = new User($db);
1908 $newuser->fetch($event->userownerid);
1909 $cacheusers[$event->userownerid] = $newuser;
1911 //var_dump($cacheusers[$event->userownerid]->color);
1913 // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event)
1914 if (!empty($cacheusers[$event->userownerid]->color)) {
1915 $color = $cacheusers[$event->userownerid]->color;
1917 } elseif ($event->type_code == 'ICALEVENT') { // Event come from external ical file
1919 if (!empty($event->icalname)) {
1920 if (!isset($numicals[dol_string_nospecial($event->icalname)])) {
1921 $numicals[dol_string_nospecial($event->icalname)] = 0;
1923 $numicals[dol_string_nospecial($event->icalname)]++;
1926 $color = ($event->icalcolor ? $event->icalcolor : -1);
1927 $cssclass = (!empty($event->icalname) ? 'family_ext'.md5($event->icalname) : 'family_other');
1928 } elseif ($event->type_code == 'BIRTHDAY') {
1931 $cssclass = 'family_birthday ';
1932 $color = sprintf("%02x%02x%02x
", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
1933 } elseif ($event->type == 'bookcal_calendar') {
1936 $cssclass = 'family_bookcal_calendar_'.(!empty($bookcalcalendarsarray["availabilitieslink
"]) ? $bookcalcalendarsarray["availabilitieslink
"][$event->fk_bookcal_calendar] : "");
1937 $color = sprintf("%02x%02x%02x
", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
1940 $color = ($event->icalcolor ? $event->icalcolor : -1);
1941 $cssclass = (!empty($event->icalname) ? 'family_ext'.md5($event->icalname) : 'family_other');
1943 if (empty($cacheusers[$event->userownerid])) {
1944 $newuser = new User($db);
1945 $newuser->fetch($event->userownerid);
1946 $cacheusers[$event->userownerid] = $newuser;
1948 //var_dump($cacheusers[$event->userownerid]->color);
1950 // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event)
1951 if (!empty($cacheusers[$event->userownerid]->color)) {
1952 $color = $cacheusers[$event->userownerid]->color;
1956 if ($color < 0) { // Color was not set on user card. Set color according to color index.
1957 // Define color index if not yet defined
1958 $idusertouse = ($event->userownerid ? $event->userownerid : 0);
1959 if (isset($colorindexused[$idusertouse])) {
1960 $colorindex = $colorindexused[$idusertouse]; // Color already assigned to this user
1962 $colorindex = $nextindextouse;
1963 $colorindexused[$idusertouse] = $colorindex;
1964 if (!empty($theme_datacolor[$nextindextouse + 1])) {
1965 $nextindextouse++; // Prepare to use next color
1968 //print '|'.($color).'='.($idusertouse?$idusertouse:0).'='.$colorindex.'<br>';
1969 // Define color // @suppress-next-line PhanPluginPrintfIncompatibleArgumentType
1970 $color = sprintf("%02x%02x%02x
", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
1972 $cssclass = $cssclass.' eventday_'.$ymd;
1974 // Defined style to disable drag and drop feature
1975 if ($event->type_code == 'AC_OTH_AUTO') {
1976 $cssclass .= " unmovable
";
1977 } elseif ($event->type_code == 'HOLIDAY') {
1978 $cssclass .= " unmovable
";
1979 } elseif ($event->type_code == 'BIRTHDAY') {
1980 $cssclass .= " unmovable
";
1981 } elseif ($event->type_code == 'ICALEVENT') {
1982 $cssclass .= " unmovable
";
1983 } elseif ($event->date_start_in_calendar && $event->date_end_in_calendar && date('Ymd', $event->date_start_in_calendar) != date('Ymd', $event->date_end_in_calendar)) {
1984 // If the event is on several days
1985 $tmpyearend = dol_print_date($event->date_start_in_calendar, '%Y', 'tzuserrel');
1986 $tmpmonthend = dol_print_date($event->date_start_in_calendar, '%m', 'tzuserrel');
1987 $tmpdayend = dol_print_date($event->date_start_in_calendar, '%d', 'tzuserrel');
1988 //var_dump($tmpyearend.' '.$tmpmonthend.' '.$tmpdayend);
1989 if ($tmpyearend != $annee || $tmpmonthend != $mois || $tmpdayend != $jour) {
1990 $cssclass .= " unmovable unmovable-mustusefirstdaytodrag
";
1992 $cssclass .= ' movable cursormove';
1995 if ($user->hasRight('agenda', 'allactions', 'create') ||
1996 (($event->authorid == $user->id || $event->userownerid == $user->id) && $user->hasRight('agenda', 'myactions', 'create'))) {
1997 $cssclass .= " movable cursormove
";
1999 $cssclass .= " unmovable
";
2005 if ($mode == 'show_day') {
2006 $h = 'height: 100%; ';
2009 if ($mode == 'show_week') {
2010 $h = 'height: 100%; ';
2016 print '<!-- start event '.$i.' -->'."\n
";
2019 if ($maxprint && $ireallyshown >= $maxprint) {
2020 $morecss = 'showifmore';
2022 if ($event->type == 'birthdate' && !GETPOST('check_birthday')) {
2023 $morecss = 'hidden';
2025 if ($event->type == 'holiday' && !GETPOST('check_holiday')) {
2026 $morecss = 'hidden';
2028 /* I comment this because it hides event recorded from bookcal online page
2029 if ($event->type == 'bookcal_calendar' && !GETPOST('check_bookcal_calendar_'.$bookcalcalendarsarray["availabilitieslink
"][$event->fk_bookcal_calendar])) {
2030 $morecss = 'hidden';
2032 if ($morecss != 'hidden') {
2035 if ($morecss != 'showifmore' && $morecss != 'hidden') {
2039 //var_dump($event->type.' - '.$morecss.' - '.$cssclass.' - '.$i.' - '.$ireallyshown.' - '.$itoshow);
2040 if (isModEnabled("bookcal
") && $event->type == 'bookcal_calendar') {
2041 print '<div id="event_
'.$ymd.'_
'.$i.'" class="event family_
'.$event->type.'_
'.$bookcalcalendarsarray["availabilitieslink"][$event->fk_bookcal_calendar].' '.$cssclass.($morecss ? ' '.$morecss : '').'"';
2043 print '<div id="event_
'.$ymd.'_
'.$i.'" class="event family_
'.$event->type.' '.$cssclass.($morecss ? ' '.$morecss : '').'"';
2045 //print ' style="height: 100px;
';
2046 //print ' position: absolute; top: 40px; width: 50%;
';
2050 //var_dump($event->userassigned);
2051 //var_dump($event->transparency);
2052 print '<table class="centpercent cal_event
';
2053 print(empty($event->transparency) ? ' cal_event_notbusy
' : ' cal_event_busy
');
2054 //if (empty($event->transparency) && empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) print ' opacitymedium
'; // Not busy
2055 print '" style="'.$h;
2056 $colortouse = $color;
2057 // If colortouse is similar than background, we force to change it.
2058 if (empty($event->transparency) && !getDolGlobalString('AGENDA_NO_TRANSPARENT_ON_NOT_BUSY
')) {
2059 print 'background: #f0f0f0;
';
2060 print 'border-left: 5px solid #
'.$colortouse.';
';
2062 print 'background: #f0f0f0;
';
2063 print 'border-left: 5px solid #
'.dol_color_minus($colortouse, -3).';
';
2064 //print 'background: -webkit-gradient(linear, left top, left bottom, from(#
'.dol_color_minus($colortouse, -3).'), to(#
'.dol_color_minus($colortouse, -1).'));
';
2066 //print 'background: #
'.$colortouse.';
';
2067 //print 'background: -webkit-gradient(linear, left top, left bottom, from(#
'.dol_color_minus($color, -3).'), to(#
'.dol_color_minus($color, -1).'));
';
2068 //if (!empty($event->transparency)) print 'background: #
'.$color.'; background: -webkit-gradient(linear, left top, left bottom, from(#
'.$color.'), to(#
'.dol_color_minus($color,1).'));
';
2069 //else print 'background-color: transparent !important; background: none; border: 1px solid #bbb;
';
2070 //print ' -moz-border-radius:4px;
"';
2071 //print 'border: 1px solid #ccc" width=
"100%"';
2074 print '<td class="tdoverflow nobottom small centpercent
'.($nowrapontd ? 'nowrap
' : '').'cal_event
'.($event->type_code == 'BIRTHDAY
' ? ' cal_event_birthday
' : '').'">';
2075 print '<!-- left section of event -->';
2079 if ($event->type_code == 'BIRTHDAY') {
2080 // It's birthday calendar
2081 $picb = '<i class="fas fa-birthday-cake
inline-block valignmiddle
"></i>';
2082 //$pice = '<i class="fas fa-briefcase
inline-block
"></i>';
2083 //$typea = ($objp->typea == 'birth') ? $picb : $pice;
2085 print $picb.' '.$langs->trans("Birthday
").'<br>';
2086 //print img_picto($langs->trans("Birthday
"), 'birthday-cake').' ';
2088 $tmpid = $event->id;
2090 if (empty($cachecontacts[$tmpid])) {
2091 $newcontact = new Contact($db);
2092 $newcontact->fetch($tmpid);
2093 $cachecontacts[$tmpid] = $newcontact;
2095 print $cachecontacts[$tmpid]->getNomUrl(1, '', 0, '', -1, 0, 'valignmiddle inline-block');
2097 //$event->picto = 'birthday-cake';
2098 //print $event->getNomUrl(1, $maxnbofchar, 'cal_event', 'birthday', 'contact');
2099 /*$listofcontacttoshow = '';
2100 $listofcontacttoshow .= '<br>'.$cacheusers[$tmpid]->getNomUrl(-1, '', 0, 0, 0, 0, '', 'paddingright valignmiddle');
2101 print $listofcontacttoshow;
2103 } elseif ($event->type_code == 'HOLIDAY') {
2104 // It's holiday calendar
2105 $tmpholiday->fetch($event->id);
2107 print $tmpholiday->getNomUrl(1, -1, 0, 'valignmiddle inline-block');
2109 $tmpid = $tmpholiday->fk_user;
2110 if (empty($cacheusers[$tmpid])) {
2111 $newuser = new User($db);
2112 $newuser->fetch($tmpid);
2113 $cacheusers[$tmpid] = $newuser;
2116 $listofusertoshow = '';
2117 $listofusertoshow .= '<br>'.$cacheusers[$tmpid]->getNomUrl(-1, '', 0, 0, 0, 0, '', 'paddingright valignmiddle inline-block');
2118 print $listofusertoshow;
2121 $parameters = array();
2122 $reshook = $hookmanager->executeHooks('eventOptions', $parameters, $event, $action); // Note that $action and $object may have been modified by some hooks
2124 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2126 '@phan-var-force ActionComm $event';
2127 if (empty($reshook)) {
2129 if (empty($event->fulldayevent)) {
2130 //print $event->getNomUrl(2).' ';
2134 if (empty($event->fulldayevent)) {
2135 // Show hours (start ... end)
2136 $tmpyearstart = dol_print_date($event->date_start_in_calendar, '%Y', 'tzuserrel');
2137 $tmpmonthstart = dol_print_date($event->date_start_in_calendar, '%m', 'tzuserrel');
2138 $tmpdaystart = dol_print_date($event->date_start_in_calendar, '%d', 'tzuserrel');
2139 $tmpyearend = dol_print_date($event->date_end_in_calendar, '%Y', 'tzuserrel');
2140 $tmpmonthend = dol_print_date($event->date_end_in_calendar, '%m', 'tzuserrel');
2141 $tmpdayend = dol_print_date($event->date_end_in_calendar, '%d', 'tzuserrel');
2144 if ($tmpyearstart == $annee && $tmpmonthstart == $mois && $tmpdaystart == $jour) {
2145 $daterange .= dol_print_date($event->date_start_in_calendar, 'hour', 'tzuserrel');
2146 if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) {
2147 if ($tmpyearstart == $tmpyearend && $tmpmonthstart == $tmpmonthend && $tmpdaystart == $tmpdayend) {
2154 if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) {
2155 if ($tmpyearstart != $tmpyearend || $tmpmonthstart != $tmpmonthend || $tmpdaystart != $tmpdayend) {
2156 $daterange .= '...';
2160 if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) {
2161 if ($tmpyearend == $annee && $tmpmonthend == $mois && $tmpdayend == $jour) {
2162 $daterange .= dol_print_date($event->date_end_in_calendar, 'hour', 'tzuserrel');
2167 print $langs->trans("EventOnFullDay
")."<br>\n
";
2172 $titletoshow = $daterange;
2173 $titletoshow .= ($titletoshow ? ' ' : '').dol_escape_htmltag($event->label);
2175 if ($event->type_code != 'ICALEVENT') {
2176 $savlabel = $event->label;
2177 $event->label = $titletoshow;
2178 // Note: List of users are inside $event->userassigned. Link may be clickable depending on permissions of user.
2179 $titletoshow = (($event->type_picto || $event->type_code) ? $event->getTypePicto() : '');
2180 $titletoshow .= $event->getNomUrl(0, $maxnbofchar, 'cal_event cal_event_title valignmiddle', '', 0, 0); // do not add 'inline-block' in css here: it makes the title transformed completely into '...'
2181 $event->label = $savlabel;
2184 // Loop on each assigned user
2185 $listofusertoshow = '';
2186 $posuserassigned = 0;
2187 foreach ($event->userassigned as $tmpid => $tmpdata) {
2188 if (!$posuserassigned && $titletoshow) {
2189 $listofusertoshow .= '<br>';
2192 if (empty($cacheusers[$tmpid])) {
2193 $newuser = new User($db);
2194 $newuser->fetch($tmpid);
2195 $cacheusers[$tmpid] = $newuser;
2198 $listofusertoshow .= $cacheusers[$tmpid]->getNomUrl(-3, '', 0, 0, 0, 0, '', 'valignmiddle inline-block');
2202 print $listofusertoshow.' ';
2204 if ($event->type_code == 'ICALEVENT') {
2205 print '<br>('.dol_trunc($event->icalname, $maxnbofchar).')';
2208 $thirdparty_id = ($event->socid > 0 ? $event->socid : ((is_object($event->societe) && $event->societe->id > 0) ? $event->societe->id : 0));
2209 $contact_id = ($event->contact_id > 0 ? $event->contact_id : ((is_object($event->contact) && $event->contact->id > 0) ? $event->contact->id : 0));
2211 // If action related to company / contact
2212 $linerelatedto = '';
2213 if ($thirdparty_id > 0) {
2214 if (!isset($cachethirdparties[$thirdparty_id]) || !is_object($cachethirdparties[$thirdparty_id])) {
2215 $thirdparty = new Societe($db);
2216 $thirdparty->fetch($thirdparty_id);
2217 $cachethirdparties[$thirdparty_id] = $thirdparty;
2219 $thirdparty = $cachethirdparties[$thirdparty_id];
2221 if (!empty($thirdparty->id)) {
2222 $linerelatedto .= $thirdparty->getNomUrl(1, '', 0, 0, -1, 0, '', 'valignmiddle inline-block');
2225 if (!empty($contact_id) && $contact_id > 0) {
2226 if (empty($cachecontacts[$contact_id]) || !is_object($cachecontacts[$contact_id])) {
2227 $contact = new Contact($db);
2228 $contact->fetch($contact_id);
2229 $cachecontacts[$contact_id] = $contact;
2231 $contact = $cachecontacts[$contact_id];
2233 if ($linerelatedto) {
2234 $linerelatedto .= ' ';
2236 if (!empty($contact->id)) {
2237 $linerelatedto .= $contact->getNomUrl(1, '', 0, '', -1, 0, 'valignmiddle inline-block');
2240 if (!empty($event->fk_element) && $event->fk_element > 0 && !empty($event->elementtype) && getDolGlobalString('AGENDA_SHOW_LINKED_OBJECT')) {
2241 include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
2242 if ($linerelatedto) {
2243 $linerelatedto .= '<br>';
2245 $linerelatedto .= dolGetElementUrl($event->fk_element, $event->elementtype, 1);
2247 if ($linerelatedto) {
2248 print ' '.$linerelatedto;
2250 } elseif (!empty($reshook)) {
2251 print $hookmanager->resPrint;
2257 if ($event->location) {
2259 print $langs->trans("Location
").': '.$event->location;
2266 if ($event->type_code != 'BIRTHDAY' && $event->type_code != 'ICALEVENT') {
2268 if ($event->percentage >= 0) {
2272 print '<td class="nobottom right nowrap cal_event_right
'.($withstatus >= 2 ? ' cal_event_right_status
' : '').'">';
2274 print $event->getLibStatut(3, 1);
2278 print '</td></tr></table>';
2279 print '</div><!-- end event '.$i.' -->'."\n
";
2283 print '<a href="'.DOL_URL_ROOT.'/comm/action/index.php?mode=
'.$mode.'&maxprint=0&month=
'.((int) $monthshown).'&year=
'.((int) $year);
2284 print($status ? '&
status=
'.$status : '').($filter ? '&filter=
'.urlencode($filter) : '');
2285 print($filtert ? '&search_filtert=
'.urlencode((string) $filtert) : '');
2286 print($usergroup ? '&search_usergroup=
'.urlencode($usergroup) : '');
2287 print($actioncode != '' ? '&search_actioncode=
'.urlencode($actioncode) : '');
2288 print '">'.img_picto("all
", "1downarrow_selected.png
").' ...';
2289 print ' +'.(count($eventarray[$daykey]) - $maxprint);
2292 //$ok=false; // To avoid to show twice the link
2299 if (!$i) { // No events
2303 if (getDolGlobalString('MAIN_JS_SWITCH_AGENDA') && $itoshow > $ireallyshown && $maxprint) {
2304 print '<div class="center cursorpointer
" id="more_
'.$ymd.'">'.img_picto("All
", "angle-
double-down
", 'class="warning
"').' +'.($itoshow - $ireallyshown).'</div>';
2305 //print ' +'.(count($eventarray[$daykey])-$maxprint);
2307 print '<script type="text/javascript
">'."\n
";
2308 print 'jQuery(document).ready(function () {'."\n
";
2309 print ' var open=0;'."\n
";
2310 print ' jQuery("#more_
'.$ymd.'").click(function() { console.log("Click on showmore
for '.$ymd.'"); reinit_day_'.$ymd.'(); event.stopImmediatePropagation(); });'."\n
";
2311 print ' function reinit_day_'.$ymd.'() {'."\n
";
2312 print ' jQuery(".eventday_
'.$ymd.'.showifmore
").toggle();'."\n
";
2313 print ' open = open + 1; if (open > 1) { open = 0; }'."\n
";
2314 print ' if (open) { ';
2315 print ' jQuery("#more_
'.$ymd.'").html(\''.img_picto("All
", "angle-
double-up
", 'class="warning
"').'\');'."\n
";
2317 print ' jQuery("#more_
'.$ymd.'").html(\''.img_picto("All
", "angle-
double-down
", 'class="warning
"').' +'.($itoshow - $ireallyshown).'\');'."\n
";
2321 print '</script>'."\n
";
2324 print '</div></div>'; // td tr
2326 print '</div>'; // table
2339function dol_color_minus($color, $minus, $minusunit = 16)
2342 if ($minusunit == 16) {
2343 $newcolor[0] = dechex(max(min(hexdec($newcolor[0]) - $minus, 15), 0));
2344 $newcolor[2] = dechex(max(min(hexdec($newcolor[2]) - $minus, 15), 0));
2345 $newcolor[4] = dechex(max(min(hexdec($newcolor[4]) - $minus, 15), 0));
2347 // Not yet implemented
2359function sort_events_by_date($a, $b)
2361 // Sort holidays at first
2362 if ($a->type_code === 'HOLIDAY') {
2365 if ($b->type_code === 'HOLIDAY') {
2369 // datep => Event start time
2370 // datef => Event end time
2372 // Events have different start time
2373 if ($a->datep !== $b->datep) {
2374 return $a->datep - $b->datep;
2377 // Events have same start time and no end time
2378 if ((!is_numeric($b->datef)) || (!is_numeric($a->datef))) {
2379 return sort_events_by_percentage($a, $b);
2382 // Events have the same start time and same end time
2383 if ($b->datef === $a->datef) {
2384 return sort_events_by_percentage($a, $b);
2387 // Events have the same start time, but have different end time -> longest event first
2388 return $b->datef - $a->datef;
2398function sort_events_by_percentage($a, $b)
2400 // Sort events with no percentage before each other
2401 // (useful to sort holidays, sick days or similar on the top)
2403 if ($a->percentage < 0) {
2407 if ($b->percentage < 0) {
2411 return $b->percentage - $a->percentage;
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
print $langs trans("AuditedSecurityEvents").'</strong >< span class="opacitymedium"></span >< br > status
Or an array listing all the potential status of the object: array: int of the status => translated la...
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.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage agenda events (actions)
Class to read/parse ICal calendars.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventarray, $maxprint=0, $maxnbofchar=16, $newparam='', $showinfo=0, $minheight=60, $nonew=0, $bookcalcalendarsarray=array())
Show event of a particular day.
dol_get_prev_month($month, $year)
Return previous month.
dol_get_next_day($day, $month, $year)
Return next day.
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_prev_day($day, $month, $year)
Return previous day.
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
dol_get_next_month($month, $year)
Return next month.
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...
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
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_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.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
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 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)
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.