33 require
'../../main.inc.php';
34 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/lib/agenda.lib.php';
39 if (!empty($conf->projet->enabled)) {
40 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
43 if (!isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW = 3;
45 if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB = 5;
46 $MAXAGENDA = $conf->global->AGENDA_EXT_NB;
48 $filter =
GETPOST(
"search_filter",
'alpha', 3) ?
GETPOST(
"search_filter",
'alpha', 3) :
GETPOST(
"filter",
'alpha', 3);
49 $filtert =
GETPOST(
"search_filtert",
"int", 3) ?
GETPOST(
"search_filtert",
"int", 3) :
GETPOST(
"filtert",
"int", 3);
50 $usergroup =
GETPOST(
"search_usergroup",
"int", 3) ?
GETPOST(
"search_usergroup",
"int", 3) :
GETPOST(
"usergroup",
"int", 3);
51 $showbirthday = empty($conf->use_javascript_ajax) ?
GETPOST(
"showbirthday",
"int") : 1;
54 if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS))
59 $sortfield =
GETPOST(
"sortfield",
'alpha');
60 $sortorder =
GETPOST(
"sortorder",
'alpha');
62 if (empty($page) || $page == -1) { $page = 0; }
63 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
64 $offset = $limit * $page;
65 if (!$sortorder) $sortorder =
"ASC";
66 if (!$sortfield) $sortfield =
"a.datec";
70 if ($user->socid) $socid = $user->socid;
72 if ($socid < 0) $socid =
'';
76 if (!$user->rights->agenda->allactions->read) $canedit = 0;
77 if (!$user->rights->agenda->allactions->read || $filter ==
'mine')
82 $action =
GETPOST(
'action',
'aZ09');
83 $resourceid =
GETPOST(
"search_resourceid",
"int");
84 $year =
GETPOST(
"year",
"int") ?
GETPOST(
"year",
"int") : date(
"Y");
85 $month =
GETPOST(
"month",
"int") ?
GETPOST(
"month",
"int") : date(
"m");
86 $week =
GETPOST(
"week",
"int") ?
GETPOST(
"week",
"int") : date(
"W");
88 $pid =
GETPOST(
"search_projectid",
"int", 3) ?
GETPOST(
"search_projectid",
"int", 3) :
GETPOST(
"projectid",
"int", 3);
89 $status =
GETPOST(
"search_status",
'aZ09') ?
GETPOST(
"search_status",
'aZ09') :
GETPOST(
"status",
'aZ09');
91 $maxprint = (isset($_GET[
"maxprint"]) ?
GETPOST(
"maxprint") : $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW);
92 $optioncss =
GETPOST(
'optioncss',
'aZ');
97 $day =
GETPOST(
'dateselectday',
'int');
98 $month =
GETPOST(
'dateselectmonth',
'int');
99 $year =
GETPOST(
'dateselectyear',
'int');
103 if (
GETPOST(
'search_actioncode',
'array'))
105 $actioncode =
GETPOST(
'search_actioncode',
'array', 3);
106 if (!count($actioncode)) $actioncode =
'0';
108 $actioncode =
GETPOST(
"search_actioncode",
"alpha", 3) ?
GETPOST(
"search_actioncode",
"alpha", 3) : (
GETPOST(
"search_actioncode") ==
'0' ?
'0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ?
'' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE));
110 if ($actioncode ==
'' && empty($actioncodearray)) $actioncode = (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ?
'' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE);
112 if ($status ==
'' && !
GETPOSTISSET(
'search_status')) $status = (empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) ?
'' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS);
114 $defaultview = (empty($conf->global->AGENDA_DEFAULT_VIEW) ?
'show_month' : $conf->global->AGENDA_DEFAULT_VIEW);
115 $defaultview = (empty($user->conf->AGENDA_DEFAULT_VIEW) ? $defaultview : $user->conf->AGENDA_DEFAULT_VIEW);
116 if (empty($action) && !
GETPOSTISSET(
'action')) $action = $defaultview;
117 if ($action ==
'default')
119 $action = (($defaultview !=
'show_list') ? $defaultview :
'show_month');
121 if (
GETPOST(
'viewcal',
'restricthtml') &&
GETPOST(
'action',
'alpha') !=
'show_day' &&
GETPOST(
'action',
'alpha') !=
'show_week') {
122 $action =
'show_month'; $day =
'';
124 if (
GETPOST(
'viewweek',
'restricthtml') ||
GETPOST(
'action',
'alpha') ==
'show_week') {
125 $action =
'show_week'; $week = ($week ? $week : date(
"W")); $day = ($day ? $day : date(
"d"));
127 if (
GETPOST(
'viewday',
'restricthtml') ||
GETPOST(
'action',
'alpha') ==
'show_day') {
128 $action =
'show_day'; $day = ($day ? $day : date(
"d"));
132 $langs->loadLangs(array(
'agenda',
'other',
'commercial'));
135 $hookmanager->initHooks(array(
'agenda'));
142 if (
GETPOST(
"viewlist",
'alpha') || $action ==
'show_list')
145 if (is_array($_POST))
147 foreach ($_POST as $key => $val)
149 if ($key ==
'token')
continue;
150 $param .=
'&'.$key.
'='.urlencode($val);
153 if (!preg_match(
'/action=/', $param)) $param .= ($param ?
'&' :
'').
'action=show_list';
155 header(
"Location: ".DOL_URL_ROOT.
'/comm/action/list.php?'.$param);
159 if (
GETPOST(
"viewperuser",
'alpha') || $action ==
'show_peruser')
162 if (is_array($_POST))
164 foreach ($_POST as $key => $val)
166 if ($key ==
'token')
continue;
167 $param .=
'&'.$key.
'='.urlencode($val);
171 header(
"Location: ".DOL_URL_ROOT.
'/comm/action/peruser.php?'.$param);
175 if ($action ==
'delete_action')
178 $event->fetch($actionid);
179 $event->fetch_optionals();
180 $event->fetch_userassigned();
181 $event->oldcopy = clone $event;
183 $result = $event->delete();
197 'maxprint' => $maxprint,
199 'filtert' => $filtert,
200 'showbirthday' => $showbirthday,
201 'canedit' => $canedit,
202 'optioncss' => $optioncss,
203 'actioncode' => $actioncode,
205 'resourceid' => $resourceid,
206 'usergroup' => $usergroup,
208 $reshook = $hookmanager->executeHooks(
'beforeAgenda', $parameters, $object, $action);
209 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
211 $help_url =
'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda';
212 llxHeader(
'', $langs->trans(
"Agenda"), $help_url);
214 $form =
new Form($db);
215 $companystatic =
new Societe($db);
216 $contactstatic =
new Contact($db);
217 $userstatic =
new User($db);
221 $nowyear = $nowarray[
'year'];
222 $nowmonth = $nowarray[
'mon'];
223 $nowday = $nowarray[
'mday'];
225 $listofextcals = array();
228 if (empty($conf->global->AGENDA_DISABLE_EXT))
231 while ($i < $MAXAGENDA)
234 $source =
'AGENDA_EXT_SRC'.$i;
235 $name =
'AGENDA_EXT_NAME'.$i;
236 $offsettz =
'AGENDA_EXT_OFFSETTZ'.$i;
237 $color =
'AGENDA_EXT_COLOR'.$i;
238 $buggedfile =
'AGENDA_EXT_BUGGEDFILE'.$i;
239 if (!empty($conf->global->$source) && !empty($conf->global->$name))
242 $listofextcals[] = array(
'src'=>$conf->global->$source,
'name'=>$conf->global->$name,
'offsettz'=>$conf->global->$offsettz,
'color'=>$conf->global->$color,
'buggedfile'=>(isset($conf->global->buggedfile) ? $conf->global->buggedfile : 0));
247 if (empty($user->conf->AGENDA_DISABLE_EXT))
250 while ($i < $MAXAGENDA)
253 $source =
'AGENDA_EXT_SRC_'.$user->id.
'_'.$i;
254 $name =
'AGENDA_EXT_NAME_'.$user->id.
'_'.$i;
255 $offsettz =
'AGENDA_EXT_OFFSETTZ_'.$user->id.
'_'.$i;
256 $color =
'AGENDA_EXT_COLOR_'.$user->id.
'_'.$i;
257 $enabled =
'AGENDA_EXT_ENABLED_'.$user->id.
'_'.$i;
258 $buggedfile =
'AGENDA_EXT_BUGGEDFILE_'.$user->id.
'_'.$i;
259 if (!empty($user->conf->$source) && !empty($user->conf->$name))
262 $listofextcals[] = array(
'src'=>$user->conf->$source,
'name'=>$user->conf->$name,
'offsettz'=>$user->conf->$offsettz,
'color'=>$user->conf->$color,
'buggedfile'=>(isset($user->conf->buggedfile) ? $user->conf->buggedfile : 0));
267 if (empty($action) || $action ==
'show_month')
270 $prev_year = $prev[
'year'];
271 $prev_month = $prev[
'month'];
273 $next_year = $next[
'year'];
274 $next_month = $next[
'month'];
276 $max_day_in_prev_month = date(
"t",
dol_mktime(0, 0, 0, $prev_month, 1, $prev_year,
'gmt'));
277 $max_day_in_month = date(
"t",
dol_mktime(0, 0, 0, $month, 1, $year));
279 $tmpday = -date(
"w",
dol_mktime(12, 0, 0, $month, 1, $year,
'gmt')) + 2;
280 $tmpday += ((isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1) - 1);
281 if ($tmpday >= 1) $tmpday -= 7;
283 $firstdaytoshow =
dol_mktime(0, 0, 0, $prev_month, $max_day_in_prev_month + $tmpday, $prev_year,
'tzuserrel');
284 $next_day = 7 - ($max_day_in_month + 1 - $tmpday) % 7;
285 if ($next_day < 6) $next_day += 7;
286 $lastdaytoshow =
dol_mktime(0, 0, 0, $next_month, $next_day, $next_year,
'tzuserrel');
288 if ($action ==
'show_week')
291 $prev_year = $prev[
'prev_year'];
292 $prev_month = $prev[
'prev_month'];
293 $prev_day = $prev[
'prev_day'];
294 $first_day = $prev[
'first_day'];
295 $first_month = $prev[
'first_month'];
296 $first_year = $prev[
'first_year'];
298 $week = $prev[
'week'];
302 $next_year = $next[
'year'];
303 $next_month = $next[
'month'];
304 $next_day = $next[
'day'];
307 $firstdaytoshow =
dol_mktime(0, 0, 0, $first_month, $first_day, $first_year,
'tzuserrel');
310 $max_day_in_month = date(
"t",
dol_mktime(0, 0, 0, $month, 1, $year,
'gmt'));
312 $tmpday = $first_day;
314 if ($action ==
'show_day')
317 $prev_year = $prev[
'year'];
318 $prev_month = $prev[
'month'];
319 $prev_day = $prev[
'day'];
321 $next_year = $next[
'year'];
322 $next_month = $next[
'month'];
323 $next_day = $next[
'day'];
326 $firstdaytoshow =
dol_mktime(0, 0, 0, $prev_month, $prev_day, $prev_year,
'tzuserrel');
327 $lastdaytoshow =
dol_mktime(0, 0, 0, $next_month, $next_day, $next_year,
'tzuserrel');
341 if (is_array($actioncode)) {
342 foreach ($actioncode as $str_action) $param .=
"&search_actioncode[]=".urlencode($str_action);
343 }
else $param .=
"&search_actioncode=".urlencode($actioncode);
345 if ($resourceid > 0) $param .=
"&search_resourceid=".urlencode($resourceid);
346 if ($status ||
GETPOSTISSET(
'status')) $param .=
"&search_status=".urlencode($status);
347 if ($filter) $param .=
"&search_filter=".urlencode($filter);
348 if ($filtert) $param .=
"&search_filtert=".urlencode($filtert);
349 if ($usergroup) $param .=
"&search_usergroup=".urlencode($usergroup);
350 if ($socid) $param .=
"&search_socid=".urlencode($socid);
351 if ($showbirthday) $param .=
"&search_showbirthday=1";
352 if ($pid) $param .=
"&search_projectid=".urlencode($pid);
353 if ($type) $param .=
"&search_type=".urlencode($type);
354 if ($action ==
'show_day' || $action ==
'show_week' || $action ==
'show_month') $param .=
'&action='.urlencode($action);
355 $param .=
"&maxprint=".urlencode($maxprint);
358 if (empty($action) || $action ==
'show_month')
360 $nav =
"<a href=\"?year=".$prev_year.
"&month=".$prev_month.$param.
"\"><i class=\"fa fa-chevron-left\"></i></a> \n";
361 $nav .=
" <span id=\"month_name\">".dol_print_date(
dol_mktime(0, 0, 0, $month, 1, $year),
"%b %Y");
362 $nav .=
" </span>\n";
363 $nav .=
" <a href=\"?year=".$next_year.
"&month=".$next_month.$param.
"\"><i class=\"fa fa-chevron-right\"></i></a>\n";
364 if (empty($conf->dol_optimize_smallscreen)) {
365 $nav .=
" <a href=\"?year=".$nowyear.
"&month=".$nowmonth.$param.
"\">".$langs->trans(
"Today").
"</a> ";
369 if ($action ==
'show_week')
371 $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";
372 $nav .=
" <span id=\"month_name\">".dol_print_date(
dol_mktime(0, 0, 0, $first_month, $first_day, $first_year),
"%Y").
", ".$langs->trans(
"Week").
" ".$week;
373 $nav .=
" </span>\n";
374 $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";
375 if (empty($conf->dol_optimize_smallscreen)) {
376 $nav .=
" <a href=\"?year=".$nowyear.
"&month=".$nowmonth.
"&day=".$nowday.$param.
"\">".$langs->trans(
"Today").
"</a> ";
378 $picto =
'calendarweek';
380 if ($action ==
'show_day')
382 $nav =
"<a href=\"?year=".$prev_year.
"&month=".$prev_month.
"&day=".$prev_day.$param.
"\"><i class=\"fa fa-chevron-left\"></i></a> \n";
383 $nav .=
" <span id=\"month_name\">".dol_print_date(
dol_mktime(0, 0, 0, $month, $day, $year),
"daytextshort");
384 $nav .=
" </span>\n";
385 $nav .=
" <a href=\"?year=".$next_year.
"&month=".$next_month.
"&day=".$next_day.$param.
"\"><i class=\"fa fa-chevron-right\"></i></a>\n";
386 if (empty($conf->dol_optimize_smallscreen)) {
387 $nav .=
" <a href=\"?year=".$nowyear.
"&month=".$nowmonth.
"&day=".$nowday.$param.
"\">".$langs->trans(
"Today").
"</a> ";
389 $picto =
'calendarday';
392 $nav .= $form->selectDate($dateselect,
'dateselect', 0, 0, 1,
'', 1, 0);
394 $nav .=
'<button type="submit" class="liste_titre button_search" name="button_search_x" value="x"><span class="fa fa-search"></span></button>';
397 $param .=
'&year='.$year.
'&month='.$month.($day ?
'&day='.$day :
'');
412 $paramnoaction = preg_replace(
'/action=[a-z_]+/',
'', $param);
416 print '<form method="POST" id="searchFormList" class="listactionsfilter" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
417 if ($optioncss !=
'')
print '<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
418 print '<input type="hidden" name="token" value="'.newToken().
'">';
425 $viewmode .=
'<a class="btnTitle reposition" href="'.DOL_URL_ROOT.
'/comm/action/list.php?action=show_list&restore_lastsearch_values=1">';
427 $viewmode .=
img_picto($langs->trans(
"List"),
'object_list-alt',
'class="pictoactionview block"');
429 $viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans(
"ViewList").
'</span></a>';
431 $viewmode .=
'<a class="btnTitle'.($action ==
'show_month' ?
' btnTitleSelected' :
'').
' reposition" href="'.DOL_URL_ROOT.
'/comm/action/index.php?action=show_month&year='.
dol_print_date($object->datep,
'%Y').
'&month='.
dol_print_date($object->datep,
'%m').
'&day='.
dol_print_date($object->datep,
'%d').
'">';
433 $viewmode .=
img_picto($langs->trans(
"ViewCal"),
'object_calendar',
'class="pictoactionview block"');
435 $viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans(
"ViewCal").
'</span></a>';
437 $viewmode .=
'<a class="btnTitle'.($action ==
'show_week' ?
' btnTitleSelected' :
'').
' reposition" href="'.DOL_URL_ROOT.
'/comm/action/index.php?action=show_week&year='.
dol_print_date($object->datep,
'%Y').
'&month='.
dol_print_date($object->datep,
'%m').
'&day='.
dol_print_date($object->datep,
'%d').
'">';
439 $viewmode .=
img_picto($langs->trans(
"ViewWeek"),
'object_calendarweek',
'class="pictoactionview block"');
441 $viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans(
"ViewWeek").
'</span></a>';
443 $viewmode .=
'<a class="btnTitle'.($action ==
'show_day' ?
' btnTitleSelected' :
'').
' reposition" href="'.DOL_URL_ROOT.
'/comm/action/index.php?action=show_day&year='.
dol_print_date($object->datep,
'%Y').
'&month='.
dol_print_date($object->datep,
'%m').
'&day='.
dol_print_date($object->datep,
'%d').
'">';
445 $viewmode .=
img_picto($langs->trans(
"ViewDay"),
'object_calendarday',
'class="pictoactionview block"');
447 $viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans(
"ViewDay").
'</span></a>';
449 $viewmode .=
'<a class="btnTitle reposition marginrightonly" href="'.DOL_URL_ROOT.
'/comm/action/peruser.php?action=show_peruser&year='.
dol_print_date($object->datep,
'%Y').
'&month='.
dol_print_date($object->datep,
'%m').
'&day='.
dol_print_date($object->datep,
'%d').
'">';
451 $viewmode .=
img_picto($langs->trans(
"ViewPerUser"),
'object_calendarperuser',
'class="pictoactionview block"');
453 $viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans(
"ViewPerUser").
'</span></a>';
455 $viewmode .=
'<span class="marginrightonly"></span>';
458 $parameters = array(); $object = null;
459 $reshook = $hookmanager->executeHooks(
'addCalendarView', $parameters, $object, $action);
460 if (empty($reshook)) {
461 $viewmode .= $hookmanager->resPrint;
462 } elseif ($reshook > 1) {
463 $viewmode = $hookmanager->resPrint;
468 if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create)
472 $newparam .=
'&month='.str_pad($month, 2,
"0", STR_PAD_LEFT).
'&year='.$tmpforcreatebutton[
'year'];
475 $hourminsec =
'100000';
476 $newcardbutton .=
dolGetButtonTitle($langs->trans(
"AddAction"),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/comm/action/card.php?action=create&datep='.sprintf(
"%04d%02d%02d", $tmpforcreatebutton[
'year'], $tmpforcreatebutton[
'mon'], $tmpforcreatebutton[
'mday']).$hourminsec.
'&backtopage='.urlencode(
$_SERVER[
"PHP_SELF"].($newparam ?
'?'.$newparam :
'')));
482 $showextcals = $listofextcals;
484 if (!empty($conf->use_javascript_ajax))
486 $s .=
"\n".
'<!-- Div to calendars selectors -->'.
"\n";
487 $s .=
'<script type="text/javascript">'.
"\n";
488 $s .=
'jQuery(document).ready(function () {'.
"\n";
489 $s .=
'jQuery(".check_birthday").click(function() { console.log("Toggle birthday"); jQuery(".family_birthday").toggle(); });'.
"\n";
490 $s .=
'jQuery(".family_birthday").toggle();'.
"\n";
491 if ($action ==
"show_week" || $action ==
"show_month" || empty($action))
494 $s .=
'jQuery( "div.sortable" ).sortable({connectWith: ".sortable", placeholder: "ui-state-highlight", items: "div.movable", receive: function( event, ui ) {'.
"\n";
496 $s .=
'console.log("submit form to record new event");'.
"\n";
498 $s .=
'var newval = jQuery(event.target).closest("div.dayevent").attr("id");'.
"\n";
499 $s .=
'console.log("found parent div.dayevent with id = "+newval);'.
"\n";
500 $s .=
'var frm=jQuery("#searchFormList");'.
"\n";
501 $s .=
'var newurl = ui.item.find("a.cal_event").attr("href");'.
"\n";
502 $s .=
'console.log(newurl);'.
"\n";
503 $s .=
'frm.attr("action", newurl).children("#newdate").val(newval);frm.submit();}'.
"\n";
507 $s .=
'</script>'.
"\n";
510 $s .=
'<div class="nowrap inline-block minheight30"><input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> '.$langs->trans(
"LocalAgenda").
' </div>';
513 if (is_array($showextcals) && count($showextcals) > 0)
515 $s .=
'<script type="text/javascript">'.
"\n";
516 $s .=
'jQuery(document).ready(function () {
517 jQuery("div input[name^=\"check_ext\"]").click(function() {
518 var name = $(this).attr("name");
519 jQuery(".family_ext" + name.replace("check_ext", "")).toggle();
522 $s .=
'</script>'.
"\n";
524 foreach ($showextcals as $val)
526 $htmlname = md5($val[
'name']);
527 $s .=
'<div class="nowrap inline-block"><input type="checkbox" id="check_ext'.$htmlname.
'" name="check_ext'.$htmlname.
'" checked> <label for="check_ext'.$htmlname.
'">'.$val[
'name'].
'</label> </div>';
532 $s .=
'<div class="nowrap inline-block"><input type="checkbox" id="check_birthday" name="check_birthday" class="check_birthday"><label for="check_birthday"> <span class="check_birthday_text">'.$langs->trans(
"AgendaShowBirthdayEvents").
'</span></label> </div>';
535 $parameters = array(); $object = null;
536 $reshook = $hookmanager->executeHooks(
'addCalendarChoice', $parameters, $object, $action);
539 $s .= $hookmanager->resPrint;
540 } elseif ($reshook > 1)
542 $s = $hookmanager->resPrint;
547 $newparam = preg_replace(
'/showbirthday=[0-1]/i',
'showbirthday='.(empty($showbirthday) ? 1 : 0), $newparam);
548 if (!preg_match(
'/showbirthday=/i', $newparam)) $newparam .=
'&showbirthday=1';
549 $link =
'<a href="'.dol_escape_htmltag(
$_SERVER[
'PHP_SELF']);
550 $link .=
'?'.dol_escape_htmltag($newparam);
552 if (empty($showbirthday)) $link .= $langs->trans(
"AgendaShowBirthdayEvents");
553 else $link .= $langs->trans(
"AgendaHideBirthdayEvents");
558 $eventarray = array();
561 if ($usergroup > 0) $sql .=
" DISTINCT";
562 $sql .=
' a.id, a.label,';
564 $sql .=
' a.datep2,';
565 $sql .=
' a.percent,';
566 $sql .=
' a.fk_user_author,a.fk_user_action,';
567 $sql .=
' a.transparency, a.priority, a.fulldayevent, a.location,';
568 $sql .=
' a.fk_soc, a.fk_contact, a.fk_project,';
569 $sql .=
' a.fk_element, a.elementtype,';
570 $sql .=
' ca.code as type_code, ca.libelle as type_label, ca.color as type_color';
571 $sql .=
' FROM '.MAIN_DB_PREFIX.
'c_actioncomm as ca, '.MAIN_DB_PREFIX.
"actioncomm as a";
572 if (!$user->rights->societe->client->voir && !$socid) $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
574 if ($resourceid > 0) $sql .=
", ".MAIN_DB_PREFIX.
"element_resources as r";
576 if ($filtert > 0 || $usergroup > 0) $sql .=
", ".MAIN_DB_PREFIX.
"actioncomm_resources as ar";
577 if ($usergroup > 0) $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"usergroup_user as ugu ON ugu.fk_user = ar.fk_element";
578 $sql .=
' WHERE a.fk_action = ca.id';
579 $sql .=
' AND a.entity IN ('.getEntity(
'agenda').
')';
581 if (!empty($actioncode))
583 if (empty($conf->global->AGENDA_USE_EVENT_TYPE))
585 if ($actioncode ==
'AC_NON_AUTO') $sql .=
" AND ca.type != 'systemauto'";
586 elseif ($actioncode ==
'AC_ALL_AUTO') $sql .= " AND ca.
type = 'systemauto'";
588 if ($actioncode ==
'AC_OTH') $sql .=
" AND ca.type != 'systemauto'";
589 if ($actioncode ==
'AC_OTH_AUTO') $sql .=
" AND ca.type = 'systemauto'";
592 if ($actioncode ==
'AC_NON_AUTO') $sql .=
" AND ca.type != 'systemauto'";
593 elseif ($actioncode ==
'AC_ALL_AUTO') $sql .= " AND ca.
type = 'systemauto'";
595 if (is_array($actioncode))
597 $sql .=
" AND ca.code IN ('".implode(
"','", $actioncode).
"')";
599 $sql .=
" AND ca.code IN ('".implode(
"','", explode(
',', $actioncode)).
"')";
604 if ($resourceid > 0) $sql .=
" AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid);
605 if ($pid) $sql .=
" AND a.fk_project=".$db->escape($pid);
606 if (!$user->rights->societe->client->voir && !$socid) $sql .=
" AND (a.fk_soc IS NULL OR sc.fk_user = ".$user->id.
")";
607 if ($socid > 0) $sql .=
' AND a.fk_soc = '.$socid;
609 if ($filtert > 0 || $usergroup > 0) $sql .=
" AND ar.fk_actioncomm = a.id AND ar.element_type='user'";
611 if ($action ==
'show_day')
614 $sql .=
" (a.datep BETWEEN '".$db->idate(
dol_mktime(0, 0, 0, $month, $day, $year,
'tzuserrel')).
"'";
615 $sql .=
" AND '".$db->idate(
dol_mktime(23, 59, 59, $month, $day, $year,
'tzuserrel')).
"')";
617 $sql .=
" (a.datep2 BETWEEN '".$db->idate(
dol_mktime(0, 0, 0, $month, $day, $year,
'tzuserrel')).
"'";
618 $sql .=
" AND '".$db->idate(
dol_mktime(23, 59, 59, $month, $day, $year,
'tzuserrel')).
"')";
620 $sql .=
" (a.datep < '".$db->idate(
dol_mktime(0, 0, 0, $month, $day, $year,
'tzuserrel')).
"'";
621 $sql .=
" AND a.datep2 > '".$db->idate(
dol_mktime(23, 59, 59, $month, $day, $year,
'tzuserrel')).
"')";
626 $sql .=
" (a.datep BETWEEN '".$db->idate(
dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7)).
"'";
627 $sql .=
" AND '".$db->idate(
dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10)).
"')";
629 $sql .=
" (a.datep2 BETWEEN '".$db->idate(
dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7)).
"'";
630 $sql .=
" AND '".$db->idate(
dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10)).
"')";
632 $sql .=
" (a.datep < '".$db->idate(
dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7)).
"'";
633 $sql .=
" AND a.datep2 > '".$db->idate(
dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10)).
"')";
636 if ($type) $sql .=
" AND ca.id = ".$type;
637 if ($status ==
'0') { $sql .=
" AND a.percent = 0"; }
638 if ($status ==
'-1') { $sql .=
" AND a.percent = -1"; }
639 if ($status ==
'50') { $sql .=
" AND (a.percent > 0 AND a.percent < 100)"; }
640 if ($status ==
'done' || $status ==
'100') { $sql .=
" AND (a.percent = 100)"; }
641 if ($status ==
'todo') { $sql .=
" AND (a.percent >= 0 AND a.percent < 100)"; }
643 if ($filtert > 0 || $usergroup > 0)
646 if ($filtert > 0) $sql .=
"ar.fk_element = ".$filtert;
647 if ($usergroup > 0) $sql .= ($filtert > 0 ?
" OR " :
"").
" ugu.fk_usergroup = ".$usergroup;
651 $sql .=
' ORDER BY datep';
655 dol_syslog(
"comm/action/index.php", LOG_DEBUG);
656 $resql = $db->query($sql);
659 $num = $db->num_rows(
$resql);
661 $MAXONSAMEPAGE = 10000;
663 while ($i < $num && $i < $MAXONSAMEPAGE)
665 $obj = $db->fetch_object(
$resql);
668 if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->type_code ==
'AC_OTH_AUTO')
677 $event->id = $obj->id;
678 $event->ref = $event->id;
680 $event->datep = $db->jdate($obj->datep);
681 $event->datef = $db->jdate($obj->datep2);
685 $event->type_code = $obj->type_code;
686 $event->type_label = $obj->type_label;
687 $event->type_color = $obj->type_color;
689 $event->libelle = $obj->label;
690 $event->label = $obj->label;
691 $event->percentage = $obj->percent;
692 $event->authorid = $obj->fk_user_author;
693 $event->userownerid = $obj->fk_user_action;
694 $event->fetch_userassigned();
695 $event->priority = $obj->priority;
696 $event->fulldayevent = $obj->fulldayevent;
697 $event->location = $obj->location;
698 $event->transparency = $obj->transparency;
699 $event->fk_element = $obj->fk_element;
700 $event->elementtype = $obj->elementtype;
702 $event->fk_project = $obj->fk_project;
704 $event->thirdparty_id = $obj->fk_soc;
705 $event->contact_id = $obj->fk_contact;
709 $event->date_start_in_calendar = $event->datep;
710 if ($event->datef !=
'' && $event->datef >= $event->datep) $event->date_end_in_calendar = $event->datef;
711 else $event->date_end_in_calendar = $event->datep;
713 if ($event->date_start_in_calendar == $event->date_end_in_calendar)
715 $event->ponctuel = 1;
719 if ($event->date_end_in_calendar < $firstdaytoshow || $event->date_start_in_calendar >= $lastdaytoshow) {
722 if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar = $firstdaytoshow;
723 if ($event->date_end_in_calendar >= $lastdaytoshow) $event->date_end_in_calendar = ($lastdaytoshow - 1);
726 $daycursor = $event->date_start_in_calendar;
734 $loop =
true; $j = 0;
735 $daykey =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
739 $eventarray[$daykey][] = $event;
742 $daykey += 60 * 60 * 24;
743 if ($daykey > $event->date_end_in_calendar) $loop =
false;
759 $sql =
'SELECT sp.rowid, sp.lastname, sp.firstname, sp.birthday';
760 $sql .=
' FROM '.MAIN_DB_PREFIX.
'socpeople as sp';
761 $sql .=
' WHERE (priv=0 OR (priv=1 AND fk_user_creat='.$user->id.
'))';
762 $sql .=
" AND sp.entity IN (".getEntity(
'socpeople').
")";
763 if ($action ==
'show_day')
765 $sql .=
' AND MONTH(birthday) = '.$month;
766 $sql .=
' AND DAY(birthday) = '.$day;
768 $sql .=
' AND MONTH(birthday) = '.$month;
770 $sql .=
' ORDER BY birthday';
772 dol_syslog(
"comm/action/index.php", LOG_DEBUG);
773 $resql = $db->query($sql);
776 $num = $db->num_rows(
$resql);
780 $obj = $db->fetch_object(
$resql);
783 $event->id = $obj->rowid;
784 $event->ref = $event->id;
789 $event->datep =
dol_mktime(0, 0, 0, $datearray[
'mon'], $datearray[
'mday'], $year,
true);
790 $event->datef = $event->datep;
791 $event->type_code =
'BIRTHDAY';
792 $event->label = $langs->trans(
"Birthday").
' '.
dolGetFirstLastname($obj->firstname, $obj->lastname);
793 $event->percentage = 100;
794 $event->fulldayevent = 1;
796 $event->date_start_in_calendar = $event->datep;
797 $event->date_end_in_calendar = $event->datef;
798 $event->ponctuel = 0;
801 $daycursor = $event->date_start_in_calendar;
807 $daykey =
dol_mktime(0, 0, 0, $mois, $jour, $annee);
809 $eventarray[$daykey][] = $event;
810 $daykey += 60 * 60 * 24;
811 if ($daykey > $event->date_end_in_calendar) $loop =
false;
820 if ($conf->global->AGENDA_SHOW_HOLIDAYS)
822 $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";
823 $sql .=
" FROM ".MAIN_DB_PREFIX.
"holiday as x, ".MAIN_DB_PREFIX.
"user as u";
824 $sql .=
" WHERE u.rowid = x.fk_user";
825 $sql .=
" AND u.statut = '1'";
826 $sql .=
" AND (x.statut = '2' OR x.statut = '3')";
828 if ($action ==
'show_day')
831 $sql .=
" AND '".$db->escape($year).
"-".$db->escape($month).
"-".$db->escape($day).
"' BETWEEN x.date_debut AND x.date_fin";
832 } elseif ($action ==
'show_week')
835 } elseif ($action ==
'show_month')
840 $resql = $db->query($sql);
843 $num = $db->num_rows(
$resql);
848 $obj = $db->fetch_object(
$resql);
856 $event->id = $obj->rowid;
857 $event->ref = $event->id;
859 $event->type_code =
'HOLIDAY';
860 $event->datep =
dol_mktime(0, 0, 0, $dateStartArray[
'mon'], $dateStartArray[
'mday'], $dateStartArray[
'year'],
true);
861 $event->datef =
dol_mktime(0, 0, 0, $dateEndArray[
'mon'], $dateEndArray[
'mday'], $dateEndArray[
'year'],
true);
862 $event->date_start_in_calendar = $event->datep;
863 $event->date_end_in_calendar = $event->datef;
865 if ($obj->status == 3)
868 $event->percentage = -1;
869 } elseif ($obj->status == 2)
872 $event->percentage = 0;
875 if ($obj->halfday == 1)
877 $event->label = $obj->lastname.
' ('.$langs->trans(
"Morning").
')';
878 } elseif ($obj->halfday == -1)
880 $event->label = $obj->lastname.
' ('.$langs->trans(
"Afternoon").
')';
882 $event->label = $obj->lastname;
885 $daycursor = $event->date_start_in_calendar;
890 $daykey =
dol_mktime(0, 0, 0, $mois, $jour, $annee);
893 $eventarray[$daykey][] = $event;
895 $daykey += 60 * 60 * 24;
896 }
while ($daykey <= $event->date_end_in_calendar);
904 if (count($listofextcals))
906 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/ical.class.php';
907 foreach ($listofextcals as $extcal)
909 $url = $extcal[
'src'];
910 $namecal = $extcal[
'name'];
911 $offsettz = $extcal[
'offsettz'];
912 $colorcal = $extcal[
'color'];
913 $buggedfile = $extcal[
'buggedfile'];
920 $icalevents = array();
921 if (is_array($ical->get_event_list())) $icalevents = array_merge($icalevents, $ical->get_event_list());
922 if (is_array($ical->get_freebusy_list())) $icalevents = array_merge($icalevents, $ical->get_freebusy_list());
924 if (count($icalevents) > 0)
927 $moreicalevents = array();
928 foreach ($icalevents as $icalevent)
930 if (isset($icalevent[
'RRULE']) && is_array($icalevent[
'RRULE']))
934 if ($icalevent[
'DTSTART;VALUE=DATE'])
938 } elseif (is_array($icalevent[
'DTSTART']) && !empty($icalevent[
'DTSTART'][
'unixtime']))
940 $datecurstart = $icalevent[
'DTSTART'][
'unixtime'];
941 $datecurend = $icalevent[
'DTEND'][
'unixtime'];
942 if (!empty($ical->cal[
'DAYLIGHT'][
'DTSTART']) && $datecurstart)
945 $tmpcurstart = $datecurstart;
946 $tmpcurend = $datecurend;
947 $tmpdaylightstart =
dol_mktime(0, 0, 0, 1, 1, 1970, 1) + (int) $ical->cal[
'DAYLIGHT'][
'DTSTART'];
948 $tmpdaylightend =
dol_mktime(0, 0, 0, 1, 1, 1970, 1) + (int) $ical->cal[
'STANDARD'][
'DTSTART'];
951 if ($tmpcurstart >= $tmpdaylightstart && $tmpcurstart < $tmpdaylightend) $datecurstart -= ((int) $ical->cal[
'DAYLIGHT'][
'TZOFFSETTO']) * 36;
952 else $datecurstart -= ((int) $ical->cal[
'STANDARD'][
'TZOFFSETTO']) * 36;
953 if ($tmpcurend >= $tmpdaylightstart && $tmpcurstart < $tmpdaylightend) $datecurend -= ((int) $ical->cal[
'DAYLIGHT'][
'TZOFFSETTO']) * 36;
954 else $datecurend -= ((int) $ical->cal[
'STANDARD'][
'TZOFFSETTO']) * 36;
960 dol_syslog(
"Found a not recognized repeatable record with unknown date start", LOG_ERR);
965 $interval = (empty($icalevent[
'RRULE'][
'INTERVAL']) ? 1 : $icalevent[
'RRULE'][
'INTERVAL']);
966 $until = empty($icalevent[
'RRULE'][
'UNTIL']) ? 0 :
dol_stringtotime($icalevent[
'RRULE'][
'UNTIL'], 1);
967 $maxrepeat = empty($icalevent[
'RRULE'][
'COUNT']) ? 0 : $icalevent[
'RRULE'][
'COUNT'];
968 if ($until && ($until + ($datecurend - $datecurstart)) < $firstdaytoshow)
continue;
969 if ($datecurstart >= $lastdaytoshow)
continue;
972 while (($datecurstart < $lastdaytoshow) && (empty($maxrepeat) || ($numofevent < $maxrepeat)))
974 if ($datecurend >= $firstdaytoshow)
976 $newevent = $icalevent;
977 unset($newevent[
'RRULE']);
978 if ($icalevent[
'DTSTART;VALUE=DATE'])
980 $newevent[
'DTSTART;VALUE=DATE'] =
dol_print_date($datecurstart,
'%Y%m%d');
981 $newevent[
'DTEND;VALUE=DATE'] =
dol_print_date($datecurend + 1,
'%Y%m%d');
983 $newevent[
'DTSTART'] = $datecurstart;
984 $newevent[
'DTEND'] = $datecurend;
986 $moreicalevents[] = $newevent;
990 $savdatecurstart = $datecurstart;
991 if ($icalevent[
'RRULE'][
'FREQ'] ==
'DAILY')
996 if ($icalevent[
'RRULE'][
'FREQ'] ==
'WEEKLY')
1000 } elseif ($icalevent[
'RRULE'][
'FREQ'] ==
'MONTHLY')
1004 } elseif ($icalevent[
'RRULE'][
'FREQ'] ==
'YEARLY')
1010 if ($savdatecurstart >= $datecurstart)
1012 dol_syslog(
"Found a rule freq ".$icalevent[
'RRULE'][
'FREQ'].
" not managed by dolibarr code. Assume 1 week frequency.", LOG_ERR);
1013 $datecurstart += 3600 * 24 * 7;
1014 $datecurend += 3600 * 24 * 7;
1019 $icalevents = array_merge($icalevents, $moreicalevents);
1022 foreach ($icalevents as $icalevent)
1027 if (!empty($icalevent[
'RRULE']))
continue;
1032 if (isset($icalevent[
'DTSTART;VALUE=DATE']))
1039 $event->fulldayevent = 1;
1041 } elseif (!is_array($icalevent[
'DTSTART']))
1043 $datestart = $icalevent[
'DTSTART'];
1044 $dateend = $icalevent[
'DTEND'];
1046 $datestart += +($offsettz * 3600);
1047 $dateend += +($offsettz * 3600);
1052 } elseif (isset($icalevent[
'DTSTART'][
'unixtime']))
1054 $datestart = $icalevent[
'DTSTART'][
'unixtime'];
1055 $dateend = $icalevent[
'DTEND'][
'unixtime'];
1057 $datestart += +($offsettz * 3600);
1058 $dateend += +($offsettz * 3600);
1061 if ($buggedfile ===
'uselocalandtznodaylight')
1066 if ($buggedfile ===
'uselocalandtzdaylight')
1068 $localtzs =
new DateTimeZone(preg_replace(
'/"/',
'', $icalevent[
'DTSTART'][
'TZID']));
1069 $localtze =
new DateTimeZone(preg_replace(
'/"/',
'', $icalevent[
'DTEND'][
'TZID']));
1070 $localdts =
new DateTime(
dol_print_date($datestart,
'dayrfc',
'gmt'), $localtzs);
1071 $localdte =
new DateTime(
dol_print_date($dateend,
'dayrfc',
'gmt'), $localtze);
1072 $tmps = -1 * $localtzs->getOffset($localdts);
1073 $tmpe = -1 * $localtze->getOffset($localdte);
1074 $datestart += $tmps;
1083 $event->id = $icalevent[
'UID'];
1084 $event->ref = $event->id;
1085 $userId = $userstatic->findUserIdByEmail($namecal);
1086 if (!empty($userId) && $userId > 0)
1088 $event->userassigned[$userId] = $userId;
1089 $event->percentage = -1;
1092 $event->type_code =
"ICALEVENT";
1095 $event->icalname = $namecal;
1096 $event->icalcolor = $colorcal;
1098 $event->datep = $datestart + $usertime;
1099 $event->datef = $dateend + $usertime;
1101 if ($icalevent[
'SUMMARY']) $event->label = $icalevent[
'SUMMARY'];
1102 elseif ($icalevent[
'DESCRIPTION']) $event->label =
dol_nl2br($icalevent['DESCRIPTION'], 1);
1103 else $event->label = $langs->trans("ExtSiteNoLabel");
1109 if ($icalevent['PRIORITY']) $event->priority = $icalevent['PRIORITY'];
1112 if ($icalevent['TRANSP'])
1114 if ($icalevent[
'TRANSP'] ==
"TRANSPARENT") $event->transparency = 0;
1115 if ($icalevent[
'TRANSP'] ==
"OPAQUE") $event->transparency = 1;
1125 if ($icalevent[
'LOCATION']) $event->location = $icalevent[
'LOCATION'];
1127 $event->date_start_in_calendar = $event->datep;
1129 if ($event->datef !=
'' && $event->datef >= $event->datep) $event->date_end_in_calendar = $event->datef;
1130 else $event->date_end_in_calendar = $event->datep;
1133 if ($event->date_start_in_calendar == $event->date_end_in_calendar)
1135 $event->ponctuel = 1;
1140 if ($event->date_end_in_calendar < $firstdaytoshow || $event->date_start_in_calendar >= $lastdaytoshow)
1147 if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar = $firstdaytoshow;
1148 if ($event->date_end_in_calendar >= $lastdaytoshow) $event->date_end_in_calendar = ($lastdaytoshow - 1);
1151 $daycursor = $event->date_start_in_calendar;
1152 $annee = date(
'Y', $daycursor);
1153 $mois = date(
'm', $daycursor);
1154 $jour = date(
'd', $daycursor);
1157 $loop =
true; $j = 0;
1159 $daykey =
dol_mktime(0, 0, 0, $mois, $jour, $annee);
1160 $daykeygmt =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
true, 0);
1163 $eventarray[$daykey][] = $event;
1164 $daykey += 60 * 60 * 24; $daykeygmt += 60 * 60 * 24;
1165 if (($event->fulldayevent ? $daykeygmt : $daykey) > $event->date_end_in_calendar) $loop =
false;
1177 $parameters = array(); $object = null;
1178 $reshook = $hookmanager->executeHooks(
'getCalendarEvents', $parameters, $object, $action);
1179 if (!empty($hookmanager->resArray[
'eventarray'])) {
1180 foreach ($hookmanager->resArray[
'eventarray'] as $keyDate => $events) {
1181 if (!isset($eventarray[$keyDate])) {
1182 $eventarray[$keyDate] = array();
1184 $eventarray[$keyDate] = array_merge($eventarray[$keyDate], $events);
1189 foreach ($eventarray as $keyDate => &$dateeventarray)
1191 usort($dateeventarray,
'sort_events_by_date');
1196 $cachethirdparties = array();
1197 $cachecontacts = array();
1198 $cacheusers = array();
1201 $color_file = DOL_DOCUMENT_ROOT.
"/theme/".$conf->theme.
"/theme_vars.inc.php";
1202 if (is_readable($color_file))
1204 include_once $color_file;
1206 if (!is_array($theme_datacolor)) $theme_datacolor = array(array(120, 130, 150), array(200, 160, 180), array(190, 190, 220));
1209 print_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);
1214 if (empty($action) || $action ==
'show_month')
1217 $newparam = preg_replace(
'/showbirthday=/i',
'showbirthday_=', $newparam);
1218 $newparam = preg_replace(
'/action=show_month&?/i',
'', $newparam);
1219 $newparam = preg_replace(
'/action=show_week&?/i',
'', $newparam);
1220 $newparam = preg_replace(
'/day=[0-9]+&?/i',
'', $newparam);
1221 $newparam = preg_replace(
'/month=[0-9]+&?/i',
'', $newparam);
1222 $newparam = preg_replace(
'/year=[0-9]+&?/i',
'', $newparam);
1223 $newparam = preg_replace(
'/viewcal=[0-9]+&?/i',
'', $newparam);
1224 $newparam = preg_replace(
'/showbirthday_=/i',
'showbirthday=', $newparam);
1225 $newparam .=
'&viewcal=1';
1227 print '<div class="liste_titre liste_titre_bydiv centpercent">';
1228 print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup,
'', $resourceid);
1231 print '<div class="div-table-responsive-no-min sectioncalendarbymonth maxscreenheightless300">';
1232 print '<table width="100%" class="noborder nocellnopadd cal_pannel cal_month">';
1233 print ' <tr class="liste_titre">';
1235 echo
' <td align="center">#</td>';
1239 print ' <td class="center bold uppercase tdfordaytitle">';
1240 $numdayinweek = (($i + (isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1)) % 7);
1241 if (!empty($conf->dol_optimize_smallscreen))
1243 $labelshort = array(0=>
'SundayMin', 1=>
'MondayMin', 2=>
'TuesdayMin', 3=>
'WednesdayMin', 4=>
'ThursdayMin', 5=>
'FridayMin', 6=>
'SaturdayMin');
1244 print $langs->trans($labelshort[$numdayinweek]);
1245 }
else print $langs->trans(
"Day".$numdayinweek);
1246 print ' </td>'.
"\n";
1252 $todaytms =
dol_mktime(0, 0, 0, $todayarray[
'mon'], $todayarray[
'mday'], $todayarray[
'year']);
1256 for ($iter_week = 0; $iter_week < 6; $iter_week++) {
1261 $currdate0 = sprintf(
"%04d", $prev_year).sprintf(
"%02d", $prev_month).sprintf(
"%02d", $max_day_in_prev_month + $tmpday);
1263 elseif ($tmpday <= $max_day_in_month)
1265 $currdate0 = sprintf(
"%04d", $year).sprintf(
"%02d", $month).sprintf(
"%02d", $tmpday);
1269 $currdate0 = sprintf(
"%04d", $next_year).sprintf(
"%02d", $next_month).sprintf(
"%02d", $tmpday - $max_day_in_month);
1272 $numweek0 = date(
"W", strtotime(date($currdate0)));
1274 echo
' <td class="center weeknumber opacitymedium" width="2%">'.$numweek0.
'</td>';
1276 for ($iter_day = 0; $iter_day < 7; $iter_day++) {
1279 $style =
'cal_other_month cal_past';
1280 if ($iter_day == 6) $style .=
' cal_other_month_right';
1281 echo
' <td class="'.$style.
' nowrap tdtop" width="14%">';
1282 show_day_events($db, $max_day_in_prev_month + $tmpday, $prev_month, $prev_year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam);
1284 } elseif ($tmpday <= $max_day_in_month) {
1286 $curtime =
dol_mktime(0, 0, 0, $month, $tmpday, $year);
1287 $style =
'cal_current_month';
1288 if ($iter_day == 6) $style .=
' cal_current_month_right';
1290 if ($todayarray[
'mday'] == $tmpday && $todayarray[
'mon'] == $month && $todayarray[
'year'] == $year) $today = 1;
1291 if ($today) $style =
'cal_today';
1292 if ($curtime < $todaytms) $style .=
' cal_past';
1294 echo
' <td class="'.$style.
' nowrap tdtop" width="14%">';
1295 show_day_events($db, $tmpday, $month, $year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam);
1299 $style =
'cal_other_month';
1300 if ($iter_day == 6) $style .=
' cal_other_month_right';
1301 echo
' <td class="'.$style.
' nowrap tdtop" width="14%">';
1302 show_day_events($db, $tmpday - $max_day_in_month, $next_month, $next_year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam);
1312 print '<input type="hidden" name="actionmove" value="mupdate">';
1313 print '<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($_SERVER[
'PHP_SELF']).
'?'.
dol_escape_htmltag($_SERVER[
'QUERY_STRING']).
'">';
1314 print '<input type="hidden" name="newdate" id="newdate">';
1315 } elseif ($action ==
'show_week') {
1318 $newparam = preg_replace(
'/showbirthday=/i',
'showbirthday_=', $newparam);
1319 $newparam = preg_replace(
'/action=show_month&?/i',
'', $newparam);
1320 $newparam = preg_replace(
'/action=show_week&?/i',
'', $newparam);
1321 $newparam = preg_replace(
'/day=[0-9]+&?/i',
'', $newparam);
1322 $newparam = preg_replace(
'/month=[0-9]+&?/i',
'', $newparam);
1323 $newparam = preg_replace(
'/year=[0-9]+&?/i',
'', $newparam);
1324 $newparam = preg_replace(
'/viewweek=[0-9]+&?/i',
'', $newparam);
1325 $newparam = preg_replace(
'/showbirthday_=/i',
'showbirthday=', $newparam);
1326 $newparam .=
'&viewweek=1';
1328 print '<div class="liste_titre liste_titre_bydiv centpercent"><div class="divsearchfield">';
1329 print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup,
'', $resourceid);
1330 print '</div></div>';
1332 print '<div class="div-table-responsive-no-min sectioncalendarbyweek maxscreenheightless300">';
1333 print '<table width="100%" class="noborder nocellnopadd cal_pannel cal_month">';
1334 print ' <tr class="liste_titre">';
1337 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";
1344 for ($iter_day = 0; $iter_day < 7; $iter_day++) {
1351 $style =
'cal_current_month';
1352 if ($iter_day == 6) $style .=
' cal_other_month_right';
1356 if ($todayarray[
'mday'] == $tmpday && $todayarray[
'mon'] == $tmpmonth && $todayarray[
'year'] == $tmpyear) $today = 1;
1357 if ($today) $style =
'cal_today';
1359 echo
' <td class="'.$style.
'" width="14%" valign="top">';
1360 show_day_events($db, $tmpday, $tmpmonth, $tmpyear, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300);
1368 echo
'<input type="hidden" name="actionmove" value="mupdate">';
1369 echo
'<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($_SERVER[
'PHP_SELF']).
'?'.
dol_escape_htmltag($_SERVER[
'QUERY_STRING']).
'">';
1370 echo
'<input type="hidden" name="newdate" id="newdate">';
1374 $newparam = preg_replace(
'/action=show_month&?/i',
'', $newparam);
1375 $newparam = preg_replace(
'/action=show_week&?/i',
'', $newparam);
1376 $newparam = preg_replace(
'/viewday=[0-9]+&?/i',
'', $newparam);
1377 $newparam .=
'&viewday=1';
1379 $style =
'cal_current_month cal_current_month_oneday';
1382 if ($todayarray[
'mday'] == $day && $todayarray[
'mon'] == $month && $todayarray[
'year'] == $year) $today = 1;
1385 $timestamp =
dol_mktime(12, 0, 0, $month, $day, $year);
1388 print '<div class="liste_titre liste_titre_bydiv centpercent"><div class="divsearchfield">';
1389 print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup,
'', $resourceid);
1390 print '</div></div>';
1392 print '<div class="div-table-responsive-no-min sectioncalendarbyday maxscreenheightless300">';
1393 echo
'<table class="tagtable centpercent noborder nocellnopadd cal_pannel cal_month noborderbottom" style="margin-bottom: 5px !important;">';
1395 echo
' <tr class="tagtr liste_titre">';
1396 echo
' <td class="tagtd center bold uppercase">'.$langs->trans(
"Day".$arraytimestamp[
'wday']).
"</td>\n";
1415 print '<div class="div-table-responsive-no-min borderbottom">';
1417 $maxheightwin = (isset($_SESSION[
"dol_screenheight"]) && $_SESSION[
"dol_screenheight"] > 500) ? ($_SESSION[
"dol_screenheight"] - 200) : 660;
1419 echo
'<div style="max-height: '.$maxheightwin.
'px;">';
1420 echo
'<div class="tagtable centpercent calendarviewcontainer">';
1424 $tmp = explode(
'-', $conf->global->MAIN_DEFAULT_WORKING_HOURS);
1425 $minhour = round($tmp[0], 0);
1426 $maxhour = round($tmp[1], 0);
1427 if ($minhour > 23) $minhour = 23;
1428 if ($maxhour < 1) $maxhour = 1;
1429 if ($maxhour <= $minhour) { $maxhour = $minhour + 1; }
1435 echo
' <div class="tagtr calendarviewcontainertr">'.
"\n";
1436 echo
' <div class="tagtd width100 tdtop">'.dol_print_date($i * 3600,
'hour',
'gmt').
'</div>';
1437 echo
' <div class="tagtd '.$style.
' tdtop"></div>'.
"\n";
1438 echo
' </div>'.
"\n";
1443 echo
'</div></div>';
1445 show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 1);
1449 print '<div class="div-table-responsive-no-min">';
1451 show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 0);
1457 print "\n".
'</form>';
1482 function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventarray, $maxprint = 0, $maxnbofchar = 16, $newparam =
'', $showinfo = 0, $minheight = 60, $nonew = 0)
1484 global $user, $conf, $langs;
1485 global $action, $filter, $filtert, $status, $actioncode, $usergroup;
1486 global $theme_datacolor;
1487 global $cachethirdparties, $cachecontacts, $cacheusers, $colorindexused;
1489 $dateint = sprintf(
"%04d", $year).sprintf(
"%02d", $month).sprintf(
"%02d", $day);
1493 $curtime =
dol_mktime(0, 0, 0, $month, $day, $year);
1494 $urltoshow = DOL_URL_ROOT.
'/comm/action/index.php?action=show_day&day='.str_pad($day, 2,
"0", STR_PAD_LEFT).
'&month='.str_pad($month, 2,
"0", STR_PAD_LEFT).
'&year='.$year.$newparam;
1496 if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create)
1498 $newparam .=
'&month='.str_pad($month, 2,
"0", STR_PAD_LEFT).
'&year='.$year;
1499 $hourminsec =
'100000';
1500 $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 :
''));
1504 print '<div id="dayevent_'.$dateint.
'" class="dayevent tagtable centpercent nobordernopadding">'.
"\n";
1508 print '<div class="tagtr cursorpointer" onclick="window.location=\''.$urltocreate.
'\';
"><div class="nowrap tagtd
"><div class="left
inline-block
">';
1509 print '<a class="dayevent-aday
" style="color: #666
" href="'.$urltoshow.'">';
1510 if ($showinfo) print dol_print_date($curtime, 'daytextshort');
1511 else print dol_print_date($curtime, '%d');
1513 print '</div><div class="nowrap floatright
inline-block marginrightonly
">';
1514 if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create)
1516 print '<a class="cursoradd
" href="'.$urltocreate.'">'; // Explicit link, usefull for nojs interfaces
1517 print img_picto($langs->trans("NewAction
"), 'edit_add.png');
1520 print '</div></div></div>'."\n";
1529 // Line with td contains all div of each events
1530 print '<div class="tagtr
">';
1531 print '<div class="tagtd centpercent agendacell sortable
">';
1533 //$curtime = dol_mktime (0, 0, 0, $month, $day, $year);
1534 $i = 0; $numother = 0; $numbirthday = 0; $numical = 0; $numicals = array();
1535 $ymd = sprintf("%04d
", $year).sprintf("%02d
", $month).sprintf("%02d
", $day);
1537 $colorindexused[$user->id] = 0; // Color index for current user (user->id) is always 0
1538 $nextindextouse = is_array($colorindexused) ?count($colorindexused) : 0; // At first run this is 0, so fist user has 0, next 1, ...
1539 //var_dump($colorindexused);
1541 foreach ($eventarray as $daykey => $notused)
1543 $annee = dol_print_date($daykey, '%Y');
1544 $mois = dol_print_date($daykey, '%m');
1545 $jour = dol_print_date($daykey, '%d');
1547 if ($day == $jour && $month == $mois && $year == $annee)
1549 foreach ($eventarray[$daykey] as $index => $event)
1551 if ($i < $maxprint || $maxprint == 0 || !empty($conf->global->MAIN_JS_SWITCH_AGENDA))
1553 $keysofuserassigned = array_keys($event->userassigned);
1554 $ponct = ($event->date_start_in_calendar == $event->date_end_in_calendar);
1556 // Define $color (Hex string like '0088FF') and $cssclass of event
1557 $color = -1; $cssclass = ''; $colorindex = -1;
1558 if (in_array($user->id, $keysofuserassigned))
1560 $cssclass = 'family_mytasks';
1562 if (empty($cacheusers[$event->userownerid]))
1564 $newuser = new User($db);
1565 $newuser->fetch($event->userownerid);
1566 $cacheusers[$event->userownerid] = $newuser;
1568 //var_dump($cacheusers[$event->userownerid]->color);
1570 // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event)
1571 if (!empty($cacheusers[$event->userownerid]->color)) $color = $cacheusers[$event->userownerid]->color;
1572 } elseif ($event->type_code == 'ICALEVENT') // Event come from external ical file
1575 if (!empty($event->icalname)) {
1576 if (!isset($numicals[dol_string_nospecial($event->icalname)])) {
1577 $numicals[dol_string_nospecial($event->icalname)] = 0;
1579 $numicals[dol_string_nospecial($event->icalname)]++;
1582 $color = ($event->icalcolor ? $event->icalcolor : -1);
1583 $cssclass = (!empty($event->icalname) ? 'family_ext'.md5($event->icalname) : 'family_other');
1584 } elseif ($event->type_code == 'BIRTHDAY')
1586 $numbirthday++; $colorindex = 2; $cssclass = 'family_birthday unmovable'; $color = sprintf("%02x%02x%02x
", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
1589 $color = ($event->icalcolor ? $event->icalcolor : -1);
1590 $cssclass = (!empty($event->icalname) ? 'family_ext'.md5($event->icalname) : 'family_other');
1592 if (empty($cacheusers[$event->userownerid]))
1594 $newuser = new User($db);
1595 $newuser->fetch($event->userownerid);
1596 $cacheusers[$event->userownerid] = $newuser;
1598 //var_dump($cacheusers[$event->userownerid]->color);
1600 // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event)
1601 if (!empty($cacheusers[$event->userownerid]->color)) $color = $cacheusers[$event->userownerid]->color;
1604 if ($color < 0) // Color was not set on user card. Set color according to color index.
1606 // Define color index if not yet defined
1607 $idusertouse = ($event->userownerid ? $event->userownerid : 0);
1608 if (isset($colorindexused[$idusertouse]))
1610 $colorindex = $colorindexused[$idusertouse]; // Color already assigned to this user
1612 $colorindex = $nextindextouse;
1613 $colorindexused[$idusertouse] = $colorindex;
1614 if (!empty($theme_datacolor[$nextindextouse + 1])) $nextindextouse++; // Prepare to use next color
1616 //print '|'.($color).'='.($idusertouse?$idusertouse:0).'='.$colorindex.'<br>';
1618 $color = sprintf("%02x%02x%02x
", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
1620 $cssclass = $cssclass.' '.$cssclass.'_day_'.$ymd;
1622 // Defined style to disable drag and drop feature
1623 if ($event->type_code == 'AC_OTH_AUTO')
1625 $cssclass .= " unmovable
";
1626 } elseif ($event->type_code == 'ICALEVENT')
1628 $cssclass .= " unmovable
";
1629 } elseif ($event->date_end_in_calendar && date('Ymd', $event->date_start_in_calendar) != date('Ymd', $event->date_end_in_calendar)) {
1630 $tmpyearend = date('Y', $event->date_end_in_calendar);
1631 $tmpmonthend = date('m', $event->date_end_in_calendar);
1632 $tmpdayend = date('d', $event->date_end_in_calendar);
1633 if ($tmpyearend != $annee || $tmpmonthend != $mois || $tmpdayend != $jour)
1635 $cssclass .= " unmovable
";
1638 if ($user->rights->agenda->allactions->create ||
1639 (($event->authorid == $user->id || $event->userownerid == $user->id) && $user->rights->agenda->myactions->create))
1641 $cssclass .= " movable cursormove
";
1643 $cssclass .= " unmovable
";
1647 $h = ''; $nowrapontd = 1;
1648 if ($action == 'show_day') { $h = 'height: 100%; '; $nowrapontd = 0; }
1649 if ($action == 'show_week') { $h = 'height: 100%; '; $nowrapontd = 0; }
1651 // Show rect of event
1653 print '<!-- start event '.$i.' -->'."\n";
1654 print '<div id="event_
'.$ymd.'_
'.$i.'" class="event '.$cssclass.'"';
1655 //print ' style="height: 100px;
';
1656 //print ' position: absolute; top: 40px; width: 50%;
';
1660 //var_dump($event->userassigned);
1661 //var_dump($event->transparency);
1662 print '<table class="centpercent cal_event
';
1663 print (empty($event->transparency) ? ' cal_event_notbusy
' : ' cal_event_busy
');
1664 //if (empty($event->transparency) && empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) print ' opacitymedium
'; // Not busy
1665 print '" style="'.$h;
1666 $colortouse = $color;
1667 // If colortouse is similar than background, we force to change it.
1668 if (empty($event->transparency) && empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY))
1670 print 'background: #f0f0f0;
';
1671 print 'border-left: 5px solid #
'.$colortouse.';
';
1673 print 'background: #f0f0f0;
';
1674 print 'border-left: 5px solid #
'.dol_color_minus($colortouse, -3).';
';
1675 //print 'background: -webkit-gradient(linear, left top, left bottom, from(#
'.dol_color_minus($colortouse, -3).'), to(#
'.dol_color_minus($colortouse, -1).'));
';
1677 //print 'background: #
'.$colortouse.';
';
1678 //print 'background: -webkit-gradient(linear, left top, left bottom, from(#
'.dol_color_minus($color, -3).'), to(#
'.dol_color_minus($color, -1).'));
';
1679 //if (! empty($event->transparency)) print 'background: #
'.$color.'; background: -webkit-gradient(linear, left top, left bottom, from(#
'.$color.'), to(#
'.dol_color_minus($color,1).'));
';
1680 //else print 'background-color: transparent !important; background: none; border: 1px solid #bbb;
';
1681 //print ' -moz-border-radius:4px;
"';
1682 //print 'border: 1px solid #ccc" width=
"100%"';
1685 print '<td class="tdoverflow nobottom centpercent
'.($nowrapontd ? 'nowrap
' : '').'cal_event
'.($event->type_code == 'BIRTHDAY
' ? ' cal_event_birthday
' : '').'">';
1689 if ($event->type_code == 'BIRTHDAY') // It's a birthday
1691 print $event->getNomUrl(1, $maxnbofchar, 'cal_event', 'birthday', 'contact');
1692 } elseif ($event->type_code == 'HOLIDAY')
1694 print $event->getNomUrl(1, $maxnbofchar, 'cal_event', 'holiday', 'user');
1695 } elseif ($event->type_code != 'BIRTHDAY' && $event->type_code != 'HOLIDAY')
1698 if (empty($event->fulldayevent))
1700 //print $event->getNomUrl(2).' ';
1704 if (empty($event->fulldayevent))
1706 // Show hours (start ... end)
1707 $tmpyearstart = dol_print_date($event->date_start_in_calendar, '%Y', 'tzuserrel');
1708 $tmpmonthstart = dol_print_date($event->date_start_in_calendar, '%m', 'tzuserrel');
1709 $tmpdaystart = dol_print_date($event->date_start_in_calendar, '%d', 'tzuserrel');
1710 $tmpyearend = dol_print_date($event->date_end_in_calendar, '%Y', 'tzuserrel');
1711 $tmpmonthend = dol_print_date($event->date_end_in_calendar, '%m', 'tzuserrel');
1712 $tmpdayend = dol_print_date($event->date_end_in_calendar, '%d', 'tzuserrel');
1715 if ($tmpyearstart == $annee && $tmpmonthstart == $mois && $tmpdaystart == $jour)
1717 $daterange .= dol_print_date($event->date_start_in_calendar, 'hour', 'tzuserrel');
1718 if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar)
1720 if ($tmpyearstart == $tmpyearend && $tmpmonthstart == $tmpmonthend && $tmpdaystart == $tmpdayend)
1726 if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar)
1728 if ($tmpyearstart != $tmpyearend || $tmpmonthstart != $tmpmonthend || $tmpdaystart != $tmpdayend)
1730 $daterange .= '...';
1734 if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar)
1736 if ($tmpyearend == $annee && $tmpmonthend == $mois && $tmpdayend == $jour)
1737 $daterange .= dol_print_date($event->date_end_in_calendar, 'hour', 'tzuserrel');
1742 print $langs->trans("EventOnFullDay
")."<br>
\n";
1747 $titletoshow = $daterange;
1748 $titletoshow .= ($titletoshow ? ' ' : '').($event->label ? $event->label : $event->libelle);
1750 if ($event->type_code != 'ICALEVENT') {
1751 $savlabel = $event->label ? $event->label : $event->libelle;
1752 $event->label = $titletoshow;
1753 $event->libelle = $titletoshow;
1754 // Note: List of users are inside $event->userassigned. Link may be clickable depending on permissions of user.
1755 $titletoshow = $event->getNomUrl(0, $maxnbofchar, 'cal_event cal_event_title', '', 0, 0);
1756 $event->label = $savlabel;
1757 $event->libelle = $savlabel;
1760 // Loop on each assigned user
1761 $listofusertoshow = '';
1762 $posuserassigned = 0;
1763 foreach ($event->userassigned as $tmpid => $tmpdata)
1765 if (!$posuserassigned && $titletoshow) $listofusertoshow .= '<br>';
1767 if (empty($cacheusers[$tmpid]))
1769 $newuser = new User($db);
1770 $newuser->fetch($tmpid);
1771 $cacheusers[$tmpid] = $newuser;
1774 $listofusertoshow .= $cacheusers[$tmpid]->getNomUrl(-3, '', 0, 0, 0, 0, '', 'paddingright valigntextbottom');
1778 print $listofusertoshow;
1780 if ($event->type_code == 'ICALEVENT') print '<br>('.dol_trunc($event->icalname, $maxnbofchar).')';
1782 $thirdparty_id = ($event->thirdparty_id > 0 ? $event->thirdparty_id : ((is_object($event->societe) && $event->societe->id > 0) ? $event->societe->id : 0));
1783 $contact_id = ($event->contact_id > 0 ? $event->contact_id : ((is_object($event->contact) && $event->contact->id > 0) ? $event->contact->id : 0));
1785 // If action related to company / contact
1786 $linerelatedto = '';
1787 if ($thirdparty_id > 0)
1789 if (!isset($cachethirdparties[$thirdparty_id]) || !is_object($cachethirdparties[$thirdparty_id]))
1791 $thirdparty = new Societe($db);
1792 $thirdparty->fetch($thirdparty_id);
1793 $cachethirdparties[$thirdparty_id] = $thirdparty;
1794 } else $thirdparty = $cachethirdparties[$thirdparty_id];
1795 if (!empty($thirdparty->id)) $linerelatedto .= $thirdparty->getNomUrl(1, '', 0);
1797 if (!empty($contact_id) && $contact_id > 0)
1799 if (!is_object($cachecontacts[$contact_id]))
1801 $contact = new Contact($db);
1802 $contact->fetch($contact_id);
1803 $cachecontacts[$contact_id] = $contact;
1804 } else $contact = $cachecontacts[$contact_id];
1805 if ($linerelatedto) $linerelatedto .= ' ';
1806 if (!empty($contact->id)) $linerelatedto .= $contact->getNomUrl(1, '', 0);
1808 if (!empty($event->fk_element) && $event->fk_element > 0 && !empty($event->elementtype) && !empty($conf->global->AGENDA_SHOW_LINKED_OBJECT))
1810 include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
1811 if ($linerelatedto) $linerelatedto .= '<br>';
1812 $linerelatedto .= dolGetElementUrl($event->fk_element, $event->elementtype, 1);
1814 if ($linerelatedto) print '<br>'.$linerelatedto;
1820 if ($event->location)
1823 print $langs->trans("Location
").': '.$event->location;
1830 if ($event->type_code != 'BIRTHDAY' && $event->type_code != 'ICALEVENT')
1833 if ($event->percentage >= 0) $withstatus = 2;
1835 print '<td class="nobottom right nowrap cal_event_right
'.($withstatus >= 2 ? ' cal_event_right_status
' : '').'">';
1836 if ($withstatus) print $event->getLibStatut(3, 1);
1837 else print ' ';
1838 print '</td></tr></table>';
1839 print '</div><!-- end event '.$i.' -->'."\n";
1842 print '<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=
'.$action.'&maxprint=0&month=
'.$monthshown.'&year=
'.$year;
1843 print ($status ? '&status=
'.$status : '').($filter ? '&filter=
'.$filter : '');
1844 print ($filtert ? '&search_filtert=
'.$filtert : '');
1845 print ($usergroup ? '&search_usergroup=
'.$usergroup : '');
1846 print ($actioncode != '' ? '&search_actioncode=
'.$actioncode : '');
1847 print '">'.img_picto("all
", "1downarrow_selected.png
").' ...';
1848 print ' +'.(count($eventarray[$daykey]) - $maxprint);
1851 //$ok=false; // To avoid to show twice the link
1858 if (!$i) { // No events
1862 if (!empty($conf->global->MAIN_JS_SWITCH_AGENDA) && $i > $maxprint && $maxprint)
1864 print '<div id="more_
'.$ymd.'">'.img_picto("all
", "1downarrow_selected.png
").' +'.$langs->trans("More
").'...</div>';
1865 //print ' +'.(count($eventarray[$daykey])-$maxprint);
1866 print '<script type="text/javascript
">'."\n";
1867 print 'jQuery(document).ready(function () {'."\n";
1868 print 'jQuery("#more_
'.$ymd.'").click(function() { reinit_day_'.$ymd.'(); });'."\n";
1870 print 'function reinit_day_'.$ymd.'() {'."\n";
1871 print 'var nb=0;'."\n";
1872 // TODO Loop on each element of day $ymd and start to toggle once $maxprint has been reached
1873 print 'jQuery(".family_mytasks_day_
'.$ymd.'").toggle();';
1878 print '</script>'."\n";
1881 print '</div></div>'; // td tr
1883 print '</div>'; // table
1896 function dol_color_minus($color, $minus, $minusunit = 16)
1899 if ($minusunit == 16)
1901 $newcolor[0] = dechex(max(min(hexdec($newcolor[0]) - $minus, 15), 0));
1902 $newcolor[2] = dechex(max(min(hexdec($newcolor[2]) - $minus, 15), 0));
1903 $newcolor[4] = dechex(max(min(hexdec($newcolor[4]) - $minus, 15), 0));
1905 // Not yet implemented
1917 function sort_events_by_date($a, $b)
1919 // Sort holidays at first
1920 if ($a->type_code === 'HOLIDAY')
1925 if ($b->type_code === 'HOLIDAY')
1930 // datep => Event start time
1931 // datef => Event end time
1933 // Events have different start time
1934 if ($a->datep !== $b->datep)
1936 return $a->datep - $b->datep;
1939 // Events have same start time and no end time
1940 if ((!is_numeric($b->datef)) || (!is_numeric($a->datef)))
1942 return sort_events_by_percentage($a, $b);
1945 // Events have the same start time and same end time
1946 if ($b->datef === $a->datef)
1948 return sort_events_by_percentage($a, $b);
1951 // Events have the same start time, but have different end time -> longest event first
1952 return $b->datef - $a->datef;
1962 function sort_events_by_percentage($a, $b)
1964 // Sort events with no percentage before each other
1965 // (usefull to sort holidays, sick days or similar on the top)
1967 if ($a->percentage < 0)
1972 if ($b->percentage < 0)
1977 return $b->percentage - $a->percentage;
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm= 'auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
dol_get_prev_month($month, $year)
Return previous month.
Class to manage agenda events (actions)
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_get_first_day_week($day, $month, $year, $gm=false)
Return first day of week for a date.
dol_now($mode= 'auto')
Return date for now.
calendars_prepare_head($param)
Define head array for tabs of agenda setup pages.
Class to manage Dolibarr users.
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_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
dol_get_prev_day($day, $month, $year)
Return previous day.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
print_barre_liste($titre, $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.
dol_get_next_week($day, $week, $month, $year)
Return next week.
Class to read/parse ICal calendars.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
Class to manage third parties objects (customers, suppliers, prospects...)
dol_get_next_month($month, $year)
Return next month.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
dol_get_next_day($day, $month, $year)
Return next day.
dol_getdate($timestamp, $fast=false, $forcetimezone= '')
Return an array with locale date info.
print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, $filtera, $filtert, $filterd, $pid, $socid, $action, $showextcals=array(), $actioncode= '', $usergroupid= '', $excludetype= '', $resourceid=0)
Show filter form in agenda view.
if(!GETPOST('transkey', 'alphanohtml')&&!GETPOST('transphrase', 'alphanohtml')) else
View.
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=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 Calling this function terminate execution ...
print $_SERVER["PHP_SELF"]
Edit parameters.
print
Draft customers invoices.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
print $_SERVER["PHP_SELF"] n
Edit parameters.
dol_time_plus_duree($time, $duration_value, $duration_unit)
Add a delay to a date.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
dolGetFirstLastname($firstname, $lastname, $nameorder=-1)
Return firstname and lastname in correct order.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...