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->project->enabled)) {
40 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
43 if (!isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) {
44 $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW = 3;
47 if (empty($conf->global->AGENDA_EXT_NB)) {
48 $conf->global->AGENDA_EXT_NB = 5;
50 $MAXAGENDA = $conf->global->AGENDA_EXT_NB;
52 $disabledefaultvalues =
GETPOST(
'disabledefaultvalues',
'int');
54 $check_holiday =
GETPOST(
'check_holiday',
'int');
55 $filter =
GETPOST(
"search_filter",
'alpha', 3) ?
GETPOST(
"search_filter",
'alpha', 3) :
GETPOST(
"filter",
'alpha', 3);
56 $filtert =
GETPOST(
"search_filtert",
"int", 3) ?
GETPOST(
"search_filtert",
"int", 3) :
GETPOST(
"filtert",
"int", 3);
57 $usergroup =
GETPOST(
"search_usergroup",
"int", 3) ?
GETPOST(
"search_usergroup",
"int", 3) :
GETPOST(
"usergroup",
"int", 3);
58 $showbirthday = empty($conf->use_javascript_ajax) ?
GETPOST(
"showbirthday",
"int") : 1;
61 if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS)) {
67 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
68 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
70 if (empty($page) || $page == -1) {
73 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
74 $offset = $limit * $page;
79 $sortfield =
"a.datec";
85 $socid = $user->socid;
92 if (empty($user->rights->agenda->myactions->read)) {
95 if (empty($user->rights->agenda->allactions->read)) {
98 if (empty($user->rights->agenda->allactions->read) || $filter ==
'mine') {
102 $action =
GETPOST(
'action',
'aZ09');
104 $mode =
GETPOST(
'mode',
'aZ09');
105 if (empty($mode) && preg_match(
'/show_/', $action)) {
108 $resourceid =
GETPOST(
"search_resourceid",
"int");
109 $year =
GETPOST(
"year",
"int") ?
GETPOST(
"year",
"int") : date(
"Y");
110 $month =
GETPOST(
"month",
"int") ?
GETPOST(
"month",
"int") : date(
"m");
111 $week =
GETPOST(
"week",
"int") ?
GETPOST(
"week",
"int") : date(
"W");
113 $pid =
GETPOST(
"search_projectid",
"int", 3) ?
GETPOST(
"search_projectid",
"int", 3) :
GETPOST(
"projectid",
"int", 3);
116 $maxprint =
GETPOSTISSET(
"maxprint") ?
GETPOST(
"maxprint",
'int') : $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW;
117 $optioncss =
GETPOST(
'optioncss',
'aZ');
120 if ($dateselect > 0) {
121 $day =
GETPOST(
'dateselectday',
'int');
122 $month =
GETPOST(
'dateselectmonth',
'int');
123 $year =
GETPOST(
'dateselectyear',
'int');
127 if (
GETPOST(
'search_actioncode',
'array:aZ09')) {
128 $actioncode =
GETPOST(
'search_actioncode',
'array:aZ09', 3);
129 if (!count($actioncode)) {
133 $actioncode =
GETPOST(
"search_actioncode",
"alpha", 3) ?
GETPOST(
"search_actioncode",
"alpha", 3) : (
GETPOST(
"search_actioncode") ==
'0' ?
'0' : ((empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) || $disabledefaultvalues) ?
'' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE));
137 $status = ((empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) || $disabledefaultvalues) ?
'' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS);
140 $defaultview = (empty($conf->global->AGENDA_DEFAULT_VIEW) ?
'show_month' : $conf->global->AGENDA_DEFAULT_VIEW);
141 $defaultview = (empty($user->conf->AGENDA_DEFAULT_VIEW) ? $defaultview : $user->conf->AGENDA_DEFAULT_VIEW);
143 $mode = $defaultview;
145 if ($mode ==
'default') {
146 $mode = (($defaultview !=
'show_list') ? $defaultview :
'show_month');
148 if (
GETPOST(
'viewcal',
'int') &&
GETPOST(
'mode',
'alpha') !=
'show_day' &&
GETPOST(
'mode',
'alpha') !=
'show_week') {
149 $mode =
'show_month'; $day =
'';
151 if (
GETPOST(
'viewweek',
'int') ||
GETPOST(
'mode',
'alpha') ==
'show_week') {
152 $mode =
'show_week'; $week = ($week ? $week : date(
"W")); $day = ($day ? $day : date(
"d"));
154 if (
GETPOST(
'viewday',
'int') ||
GETPOST(
'mode',
'alpha') ==
'show_day') {
155 $mode =
'show_day'; $day = ($day ? $day : date(
"d"));
161 $langs->loadLangs(array(
'agenda',
'other',
'commercial'));
164 $hookmanager->initHooks(array(
'agenda'));
166 $result =
restrictedArea($user,
'agenda', 0,
'actioncomm&societe',
'myactions|allactions',
'fk_soc',
'id');
167 if ($user->socid && $socid) {
176 if (
GETPOST(
"viewlist",
'alpha') || $mode ==
'show_list') {
178 if (is_array($_POST)) {
179 foreach ($_POST as $key => $val) {
180 if ($key ==
'token') {
183 $param .=
'&'.$key.
'='.urlencode($val);
186 if (!preg_match(
'/action=/', $param)) {
187 $param .= ($param ?
'&' :
'').
'mode=show_list';
190 header(
"Location: ".DOL_URL_ROOT.
'/comm/action/list.php?'.$param);
194 if (
GETPOST(
"viewperuser",
'alpha') || $mode ==
'show_peruser') {
196 if (is_array($_POST)) {
197 foreach ($_POST as $key => $val) {
198 if ($key ==
'token') {
201 $param .=
'&'.$key.
'='.urlencode($val);
205 header(
"Location: ".DOL_URL_ROOT.
'/comm/action/peruser.php?'.$param);
233 'maxprint' => $maxprint,
235 'filtert' => $filtert,
236 'showbirthday' => $showbirthday,
237 'canedit' => $canedit,
238 'optioncss' => $optioncss,
239 'actioncode' => $actioncode,
241 'resourceid' => $resourceid,
242 'usergroup' => $usergroup,
244 $reshook = $hookmanager->executeHooks(
'beforeAgenda', $parameters, $object, $action);
249 $help_url =
'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda';
253 $companystatic =
new Societe($db);
254 $contactstatic =
new Contact($db);
255 $userstatic =
new User($db);
259 $nowyear = $nowarray[
'year'];
260 $nowmonth = $nowarray[
'mon'];
261 $nowday = $nowarray[
'mday'];
263 $listofextcals = array();
266 if (empty($conf->global->AGENDA_DISABLE_EXT)) {
268 while ($i < $MAXAGENDA) {
270 $source =
'AGENDA_EXT_SRC'.$i;
271 $name =
'AGENDA_EXT_NAME'.$i;
272 $offsettz =
'AGENDA_EXT_OFFSETTZ'.$i;
273 $color =
'AGENDA_EXT_COLOR'.$i;
274 $default =
'AGENDA_EXT_ACTIVEBYDEFAULT'.$i;
275 $buggedfile =
'AGENDA_EXT_BUGGEDFILE'.$i;
276 if (!empty($conf->global->$source) && !empty($conf->global->$name)) {
278 $listofextcals[] = array(
281 'offsettz' => (!empty($conf->global->$offsettz) ? $conf->global->$offsettz : 0),
284 'buggedfile' => (isset($conf->global->buggedfile) ? $conf->global->buggedfile : 0)
290 if (empty($user->conf->AGENDA_DISABLE_EXT)) {
292 while ($i < $MAXAGENDA) {
294 $source =
'AGENDA_EXT_SRC_'.$user->id.
'_'.$i;
295 $name =
'AGENDA_EXT_NAME_'.$user->id.
'_'.$i;
296 $offsettz =
'AGENDA_EXT_OFFSETTZ_'.$user->id.
'_'.$i;
297 $color =
'AGENDA_EXT_COLOR_'.$user->id.
'_'.$i;
298 $enabled =
'AGENDA_EXT_ENABLED_'.$user->id.
'_'.$i;
299 $default =
'AGENDA_EXT_ACTIVEBYDEFAULT_'.$user->id.
'_'.$i;
300 $buggedfile =
'AGENDA_EXT_BUGGEDFILE_'.$user->id.
'_'.$i;
301 if (!empty($user->conf->$source) && !empty($user->conf->$name)) {
303 $listofextcals[] = array(
304 'src' => $user->conf->$source,
305 'name' => $user->conf->$name,
306 'offsettz' => (!empty($user->conf->$offsettz) ? $user->conf->$offsettz : 0),
307 'color' => $user->conf->$color,
308 'default' => $user->conf->$default,
309 'buggedfile' => (isset($user->conf->buggedfile) ? $user->conf->buggedfile : 0)
315 if (empty($mode) || $mode ==
'show_month') {
317 $prev_year = $prev[
'year'];
318 $prev_month = $prev[
'month'];
320 $next_year = $next[
'year'];
321 $next_month = $next[
'month'];
323 $max_day_in_prev_month = date(
"t",
dol_mktime(0, 0, 0, $prev_month, 1, $prev_year,
'gmt'));
324 $max_day_in_month = date(
"t",
dol_mktime(0, 0, 0, $month, 1, $year));
326 $tmpday = -date(
"w",
dol_mktime(12, 0, 0, $month, 1, $year,
'gmt')) + 2;
327 $tmpday += ((isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1) - 1);
332 $firstdaytoshow =
dol_mktime(0, 0, 0, $prev_month, $max_day_in_prev_month + $tmpday, $prev_year,
'tzuserrel');
333 $next_day = 7 - ($max_day_in_month + 1 - $tmpday) % 7;
337 $lastdaytoshow =
dol_mktime(0, 0, 0, $next_month, $next_day, $next_year,
'tzuserrel');
339 if ($mode ==
'show_week') {
341 $prev_year = $prev[
'prev_year'];
342 $prev_month = $prev[
'prev_month'];
343 $prev_day = $prev[
'prev_day'];
344 $first_day = $prev[
'first_day'];
345 $first_month = $prev[
'first_month'];
346 $first_year = $prev[
'first_year'];
348 $week = $prev[
'week'];
352 $next_year = $next[
'year'];
353 $next_month = $next[
'month'];
354 $next_day = $next[
'day'];
357 $firstdaytoshow =
dol_mktime(0, 0, 0, $first_month, $first_day, $first_year,
'tzuserrel');
360 $max_day_in_month = date(
"t",
dol_mktime(0, 0, 0, $month, 1, $year,
'gmt'));
362 $tmpday = $first_day;
364 if ($mode ==
'show_day') {
366 $prev_year = $prev[
'year'];
367 $prev_month = $prev[
'month'];
368 $prev_day = $prev[
'day'];
370 $next_year = $next[
'year'];
371 $next_month = $next[
'month'];
372 $next_day = $next[
'day'];
374 $firstdaytoshow =
dol_mktime(0, 0, 0, $prev_month, $prev_day, $prev_year,
'tzuserrel');
375 $lastdaytoshow =
dol_mktime(0, 0, 0, $next_month, $next_day, $next_year,
'tzuserrel');
388 if (is_array($actioncode)) {
389 foreach ($actioncode as $str_action) {
390 $param .=
"&search_actioncode[]=".urlencode($str_action);
393 $param .=
"&search_actioncode=".urlencode($actioncode);
396 if ($resourceid > 0) {
397 $param .=
"&search_resourceid=".urlencode($resourceid);
400 $param .=
"&search_status=".urlencode($status);
403 $param .=
"&search_filter=".urlencode($filter);
406 $param .=
"&search_filtert=".urlencode($filtert);
408 if ($usergroup > 0) {
409 $param .=
"&search_usergroup=".urlencode($usergroup);
412 $param .=
"&search_socid=".urlencode($socid);
415 $param .=
"&search_showbirthday=1";
418 $param .=
"&search_projectid=".urlencode($pid);
421 $param .=
"&search_type=".urlencode($type);
423 $param .=
"&maxprint=".urlencode($maxprint);
424 if ($mode ==
'show_day' || $mode ==
'show_week' || $mode ==
'show_month') {
425 $param .=
'&mode='.urlencode($mode);
429 if (empty($mode) || $mode ==
'show_month') {
430 $nav =
"<a href=\"?year=".$prev_year.
"&month=".$prev_month.$param.
"\"><i class=\"fa fa-chevron-left\"></i></a> \n";
431 $nav .=
" <span id=\"month_name\">".dol_print_date(
dol_mktime(0, 0, 0, $month, 1, $year),
"%b %Y");
432 $nav .=
" </span>\n";
433 $nav .=
" <a href=\"?year=".$next_year.
"&month=".$next_month.$param.
"\"><i class=\"fa fa-chevron-right\"></i></a>\n";
434 if (empty($conf->dol_optimize_smallscreen)) {
435 $nav .=
" <a href=\"?year=".$nowyear.
"&month=".$nowmonth.$param.
"\">".$langs->trans(
"Today").
"</a> ";
439 if ($mode ==
'show_week') {
440 $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";
441 $nav .=
" <span id=\"month_name\">".dol_print_date(
dol_mktime(0, 0, 0, $first_month, $first_day, $first_year),
"%Y").
", ".$langs->trans(
"Week").
" ".$week;
442 $nav .=
" </span>\n";
443 $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";
444 if (empty($conf->dol_optimize_smallscreen)) {
445 $nav .=
" <a href=\"?year=".$nowyear.
"&month=".$nowmonth.
"&day=".$nowday.$param.
"\">".$langs->trans(
"Today").
"</a> ";
447 $picto =
'calendarweek';
449 if ($mode ==
'show_day') {
450 $nav =
"<a href=\"?year=".$prev_year.
"&month=".$prev_month.
"&day=".$prev_day.$param.
"\"><i class=\"fa fa-chevron-left\"></i></a> \n";
451 $nav .=
" <span id=\"month_name\">".dol_print_date(
dol_mktime(0, 0, 0, $month, $day, $year),
"daytextshort");
452 $nav .=
" </span>\n";
453 $nav .=
" <a href=\"?year=".$next_year.
"&month=".$next_month.
"&day=".$next_day.$param.
"\"><i class=\"fa fa-chevron-right\"></i></a>\n";
454 if (empty($conf->dol_optimize_smallscreen)) {
455 $nav .=
" <a href=\"?year=".$nowyear.
"&month=".$nowmonth.
"&day=".$nowday.$param.
"\">".$langs->trans(
"Today").
"</a> ";
457 $picto =
'calendarday';
460 $nav .= $form->selectDate($dateselect,
'dateselect', 0, 0, 1,
'', 1, 0);
462 $nav .=
'<button type="submit" class="liste_titre button_search valignmiddle" name="button_search_x" value="x"><span class="fa fa-search"></span></button>';
465 $paramnodate = $param;
466 $param .=
'&year='.$year.
'&month='.$month.($day ?
'&day='.$day :
'');
481 $paramnoaction = preg_replace(
'/mode=[a-z_]+/',
'', preg_replace(
'/action=[a-z_]+/',
'', $param));
482 $paramnoactionodate = preg_replace(
'/mode=[a-z_]+/',
'', preg_replace(
'/action=[a-z_]+/',
'', $paramnodate));
486 print
'<form method="POST" id="searchFormList" class="listactionsfilter" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
487 if ($optioncss !=
'') {
488 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
490 print
'<input type="hidden" name="token" value="'.newToken().
'">';
491 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
498 $viewmode .=
'<a class="btnTitle 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">'.$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">'.$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">'.$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">'.$langs->trans(
"ViewDay").
'</span></a>';
522 $viewmode .=
'<a class="btnTitle 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">'.$langs->trans(
"ViewPerUser").
'</span></a>';
529 $parameters = array(); $object = null;
530 $reshook = $hookmanager->executeHooks(
'addCalendarView', $parameters, $object, $action);
531 if (empty($reshook)) {
532 $viewmode .= $hookmanager->resPrint;
533 } elseif ($reshook > 1) {
534 $viewmode = $hookmanager->resPrint;
537 $viewmode .=
'<span class="marginrightonly"></span>';
542 if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) {
545 $newparam .=
'&month='.((int) $month).
'&year='.((int) $tmpforcreatebutton[
'year']).
'&mode='.urlencode($mode);
550 $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 :
'')));
556 $showextcals = $listofextcals;
558 if (!empty($conf->use_javascript_ajax)) {
559 $s .=
"\n".
'<!-- Div to calendars selectors -->'.
"\n";
560 $s .=
'<script type="text/javascript">'.
"\n";
561 $s .=
'jQuery(document).ready(function () {'.
"\n";
562 $s .=
'jQuery(".check_birthday").click(function() { console.log("Toggle birthdays"); jQuery(".family_birthday").toggle(); });'.
"\n";
563 $s .=
'jQuery(".check_holiday").click(function() { console.log("Toggle holidays"); jQuery(".family_holiday").toggle(); });'.
"\n";
564 if ($mode ==
"show_week" || $mode ==
"show_month" || empty($mode)) {
566 $s .=
'jQuery( "div.sortable" ).sortable({connectWith: ".sortable", placeholder: "ui-state-highlight", items: "div.movable", receive: function( event, ui ) {'.
"\n";
568 $s .=
'console.log("submit form to record new event");'.
"\n";
570 $s .=
'var newval = jQuery(event.target).closest("div.dayevent").attr("id");'.
"\n";
571 $s .=
'console.log("found parent div.dayevent with id = "+newval);'.
"\n";
572 $s .=
'var frm=jQuery("#searchFormList");'.
"\n";
573 $s .=
'var newurl = ui.item.find("a.cal_event").attr("href");'.
"\n";
574 $s .=
'console.log("Found url on href of a.cal_event"+newurl+", we submit form with actionmove=mupdate");'.
"\n";
575 $s .=
'frm.attr("action", newurl).children("#newdate").val(newval);frm.submit();}'.
"\n";
579 $s .=
'</script>'.
"\n";
582 $s .=
'<div class="nowrap inline-block minheight30"><input type="checkbox" id="check_mytasks" name="check_mytasks" value="1" checked disabled> '.$langs->trans(
"LocalAgenda").
' </div>';
585 $s .=
'<div class="nowrap inline-block minheight30"><input type="checkbox" id="check_holiday" name="check_holiday" value="1" class="check_holiday"'.($check_holiday ?
' checked' :
'').
'><label for="check_holiday"> <span class="check_holiday_text">'.$langs->trans(
"Holidays").
'</span></label> </div>';
588 if (is_array($showextcals) && count($showextcals) > 0) {
589 $s .=
'<script type="text/javascript">'.
"\n";
590 $s .=
'jQuery(document).ready(function () {
591 jQuery("div input[name^=\"check_ext\"]").each(function(index, elem) {
592 var name = jQuery(elem).attr("name");
593 if (jQuery(elem).is(":checked")) {
594 jQuery(".family_ext" + name.replace("check_ext", "")).show();
596 jQuery(".family_ext" + name.replace("check_ext", "")).hide();
600 jQuery("div input[name^=\"check_ext\"]").click(function() {
601 var name = $(this).attr("name");
602 jQuery(".family_ext" + name.replace("check_ext", "")).toggle();
605 $s .=
'</script>'.
"\n";
607 foreach ($showextcals as $val) {
608 $htmlname = md5($val[
'name']);
610 if (!empty($val[
'default']) ||
GETPOST(
'check_ext'.$htmlname,
'int')) {
611 $default =
"checked";
616 $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.
'">'.$val[
'name'].
'</label> </div>';
621 $s .=
'<div class="nowrap inline-block minheight30"><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>';
624 $parameters = array();
625 $reshook = $hookmanager->executeHooks(
'addCalendarChoice', $parameters, $object, $action);
626 if (empty($reshook)) {
627 $s .= $hookmanager->resPrint;
628 } elseif ($reshook > 1) {
629 $s = $hookmanager->resPrint;
632 $s .=
"\n".
'<!-- End div to calendars selectors -->'.
"\n";
635 $newparam = preg_replace(
'/showbirthday=[0-1]/i',
'showbirthday='.(empty($showbirthday) ? 1 : 0), $newparam);
636 if (!preg_match(
'/showbirthday=/i', $newparam)) {
637 $newparam .=
'&showbirthday=1';
639 $link =
'<a href="'.dol_escape_htmltag($_SERVER[
'PHP_SELF']);
640 $link .=
'?'.dol_escape_htmltag($newparam);
642 if (empty($showbirthday)) {
643 $link .= $langs->trans(
"AgendaShowBirthdayEvents");
645 $link .= $langs->trans(
"AgendaHideBirthdayEvents");
652 $eventarray = array();
657 if ($usergroup > 0) {
660 $sql .=
' a.id, a.label,';
662 $sql .=
' a.datep2,';
663 $sql .=
' a.percent,';
664 $sql .=
' a.fk_user_author,a.fk_user_action,';
665 $sql .=
' a.transparency, a.priority, a.fulldayevent, a.location,';
666 $sql .=
' a.fk_soc, a.fk_contact, a.fk_project,';
667 $sql .=
' a.fk_element, a.elementtype,';
668 $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';
669 $sql .=
' FROM '.MAIN_DB_PREFIX.
'c_actioncomm as ca, '.MAIN_DB_PREFIX.
"actioncomm as a";
670 if (empty($user->rights->societe->client->voir) && !$socid) {
671 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
674 if ($resourceid > 0) {
675 $sql .=
", ".MAIN_DB_PREFIX.
"element_resources as r";
678 if ($filtert > 0 || $usergroup > 0) {
679 $sql .=
", ".MAIN_DB_PREFIX.
"actioncomm_resources as ar";
681 if ($usergroup > 0) {
682 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"usergroup_user as ugu ON ugu.fk_user = ar.fk_element";
684 $sql .=
' WHERE a.fk_action = ca.id';
685 $sql .=
' AND a.entity IN ('.getEntity(
'agenda').
')';
687 if (!empty($actioncode)) {
688 if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
689 if ($actioncode ==
'AC_NON_AUTO') {
690 $sql .=
" AND ca.type != 'systemauto'";
691 } elseif ($actioncode ==
'AC_ALL_AUTO') {
692 $sql .=
" AND ca.type = 'systemauto'";
694 if ($actioncode ==
'AC_OTH') {
695 $sql .=
" AND ca.type != 'systemauto'";
697 if ($actioncode ==
'AC_OTH_AUTO') {
698 $sql .=
" AND ca.type = 'systemauto'";
702 if ($actioncode ==
'AC_NON_AUTO') {
703 $sql .=
" AND ca.type != 'systemauto'";
704 } elseif ($actioncode ==
'AC_ALL_AUTO') {
705 $sql .=
" AND ca.type = 'systemauto'";
707 if (is_array($actioncode)) {
708 $sql .=
" AND ca.code IN (".$db->sanitize(
"'".implode(
"','", $actioncode).
"'", 1).
")";
710 $sql .=
" AND ca.code IN (".$db->sanitize(
"'".implode(
"','", explode(
',', $actioncode)).
"'", 1).
")";
715 if ($resourceid > 0) {
716 $sql .=
" AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".((int) $resourceid);
719 $sql .=
" AND a.fk_project=".((int) $pid);
721 if (empty($user->rights->societe->client->voir) && !$socid) {
722 $sql .=
" AND (a.fk_soc IS NULL OR sc.fk_user = ".((int) $user->id).
")";
725 $sql .=
" AND a.fk_soc = ".((int) $socid);
728 if ($filtert > 0 || $usergroup > 0) {
729 $sql .=
" AND ar.fk_actioncomm = a.id AND ar.element_type='user'";
732 if ($mode ==
'show_day') {
734 $sql .=
" (a.datep BETWEEN '".$db->idate(
dol_mktime(0, 0, 0, $month, $day, $year,
'tzuserrel')).
"'";
735 $sql .=
" AND '".$db->idate(
dol_mktime(23, 59, 59, $month, $day, $year,
'tzuserrel')).
"')";
737 $sql .=
" (a.datep2 BETWEEN '".$db->idate(
dol_mktime(0, 0, 0, $month, $day, $year,
'tzuserrel')).
"'";
738 $sql .=
" AND '".$db->idate(
dol_mktime(23, 59, 59, $month, $day, $year,
'tzuserrel')).
"')";
740 $sql .=
" (a.datep < '".$db->idate(
dol_mktime(0, 0, 0, $month, $day, $year,
'tzuserrel')).
"'";
741 $sql .=
" AND a.datep2 > '".$db->idate(
dol_mktime(23, 59, 59, $month, $day, $year,
'tzuserrel')).
"')";
746 $sql .=
" (a.datep BETWEEN '".$db->idate(
dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7)).
"'";
747 $sql .=
" AND '".$db->idate(
dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10)).
"')";
749 $sql .=
" (a.datep2 BETWEEN '".$db->idate(
dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7)).
"'";
750 $sql .=
" AND '".$db->idate(
dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10)).
"')";
752 $sql .=
" (a.datep < '".$db->idate(
dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7)).
"'";
753 $sql .=
" AND a.datep2 > '".$db->idate(
dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10)).
"')";
757 $sql .=
" AND ca.id = ".((int) $type);
759 if ($status ==
'0') {
760 $sql .=
" AND a.percent = 0";
762 if ($status ==
'-1' || $status ==
'na') {
764 $sql .=
" AND a.percent = -1";
766 if ($status ==
'50') {
768 $sql .=
" AND (a.percent > 0 AND a.percent < 100)";
770 if ($status ==
'done' || $status ==
'100') {
771 $sql .=
" AND (a.percent = 100)";
773 if ($status ==
'todo') {
774 $sql .=
" AND (a.percent >= 0 AND a.percent < 100)";
777 if ($filtert > 0 || $usergroup > 0) {
780 $sql .=
"ar.fk_element = ".((int) $filtert);
782 if ($usergroup > 0) {
783 $sql .= ($filtert > 0 ?
" OR " :
"").
" ugu.fk_usergroup = ".((
int) $usergroup);
788 $sql .=
' ORDER BY datep';
792 dol_syslog(
"comm/action/index.php", LOG_DEBUG);
793 $resql = $db->query($sql);
795 $num = $db->num_rows(
$resql);
797 $MAXONSAMEPAGE = 10000;
799 while ($i < $num && $i < $MAXONSAMEPAGE) {
800 $obj = $db->fetch_object(
$resql);
803 if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->type_code ==
'AC_OTH_AUTO') {
811 $event->id = $obj->id;
812 $event->ref = $event->id;
814 $event->fulldayevent = $obj->fulldayevent;
817 if ($event->fulldayevent) {
819 $event->datep = $db->jdate($obj->datep, $tzforfullday ?
'tzuser' :
'tzserver');
820 $event->datef = $db->jdate($obj->datep2, $tzforfullday ?
'tzuser' :
'tzserver');
823 $event->datep = $db->jdate($obj->datep,
'tzserver');
824 $event->datef = $db->jdate($obj->datep2,
'tzserver');
830 $event->type_code = $obj->type_code;
831 $event->type_label = $obj->type_label;
832 $event->type_color = $obj->type_color;
833 $event->type = $obj->type_type;
834 $event->type_picto = $obj->type_picto;
836 $event->libelle = $obj->label;
837 $event->label = $obj->label;
838 $event->percentage = $obj->percent;
840 $event->authorid = $obj->fk_user_author;
841 $event->userownerid = $obj->fk_user_action;
842 $event->fetch_userassigned();
844 $event->priority = $obj->priority;
845 $event->location = $obj->location;
846 $event->transparency = $obj->transparency;
847 $event->fk_element = $obj->fk_element;
848 $event->elementtype = $obj->elementtype;
850 $event->fk_project = $obj->fk_project;
852 $event->socid = $obj->fk_soc;
853 $event->contact_id = $obj->fk_contact;
857 $event->date_start_in_calendar = $event->datep;
858 if ($event->datef !=
'' && $event->datef >= $event->datep) {
859 $event->date_end_in_calendar = $event->datef;
861 $event->date_end_in_calendar = $event->datep;
865 if ($event->date_end_in_calendar < $firstdaytoshow || $event->date_start_in_calendar >= $lastdaytoshow) {
868 if ($event->date_start_in_calendar < $firstdaytoshow) {
869 $event->date_start_in_calendar = $firstdaytoshow;
871 if ($event->date_end_in_calendar >= $lastdaytoshow) {
872 $event->date_end_in_calendar = ($lastdaytoshow - 1);
876 $daycursor = $event->date_start_in_calendar;
881 $daycursorend = $event->date_end_in_calendar;
891 $loop =
true; $j = 0;
892 $daykey =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
893 $daykeyend =
dol_mktime(0, 0, 0, $moisend, $jourend, $anneeend,
'gmt');
907 $eventarray[$daykey][] = $event;
910 $daykey += 60 * 60 * 24;
912 if ($daykey > $daykeyend) {
931 $sql =
'SELECT sp.rowid, sp.lastname, sp.firstname, sp.birthday';
932 $sql .=
' FROM '.MAIN_DB_PREFIX.
'socpeople as sp';
933 $sql .=
' WHERE (priv=0 OR (priv=1 AND fk_user_creat='.((int) $user->id).
'))';
934 $sql .=
" AND sp.entity IN (".getEntity(
'contact').
")";
935 if ($mode ==
'show_day') {
936 $sql .=
' AND MONTH(birthday) = '.((int) $month);
937 $sql .=
' AND DAY(birthday) = '.((int) $day);
939 $sql .=
' AND MONTH(birthday) = '.((int) $month);
941 $sql .=
' ORDER BY birthday';
943 dol_syslog(
"comm/action/index.php", LOG_DEBUG);
944 $resql = $db->query($sql);
946 $num = $db->num_rows(
$resql);
949 $obj = $db->fetch_object(
$resql);
953 $event->id = $obj->rowid;
954 $event->ref = $event->id;
959 $event->datep =
dol_mktime(0, 0, 0, $datearray[
'mon'], $datearray[
'mday'], $year,
true);
960 $event->datef = $event->datep;
962 $event->type_code =
'BIRTHDAY';
963 $event->type_label =
'';
964 $event->type_color =
'';
965 $event->type =
'birthdate';
966 $event->type_picto =
'birthdate';
968 $event->label = $langs->trans(
"Birthday").
' '.
dolGetFirstLastname($obj->firstname, $obj->lastname);
969 $event->percentage = 100;
970 $event->fulldayevent = 1;
972 $event->date_start_in_calendar = $db->jdate($event->datep);
973 $event->date_end_in_calendar = $db->jdate($event->datef);
976 $daycursor = $event->datep;
981 $daykey =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
983 $eventarray[$daykey][] = $event;
1001 $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";
1002 $sql .=
" FROM ".MAIN_DB_PREFIX.
"holiday as x, ".MAIN_DB_PREFIX.
"user as u";
1003 $sql .=
" WHERE u.rowid = x.fk_user";
1004 $sql .=
" AND u.statut = '1'";
1005 $sql .=
" AND (x.statut = '2' OR x.statut = '3')";
1007 if ($mode ==
'show_day') {
1009 $sql .=
" AND '".$db->escape($year).
"-".$db->escape($month).
"-".$db->escape($day).
"' BETWEEN x.date_debut AND x.date_fin";
1010 } elseif ($mode ==
'show_week') {
1012 } elseif ($mode ==
'show_month') {
1016 $resql = $db->query($sql);
1018 $num = $db->num_rows(
$resql);
1022 $obj = $db->fetch_object(
$resql);
1027 $event->id = $obj->rowid;
1028 $event->ref = $event->id;
1030 $event->type_code =
'HOLIDAY';
1031 $event->type_label =
'';
1032 $event->type_color =
'';
1033 $event->type =
'holiday';
1034 $event->type_picto =
'holiday';
1036 $event->datep = $db->jdate($obj->date_start) + (empty($halfday) || $halfday == 1 ? 0 : 12 * 60 * 60 - 1);
1037 $event->datef = $db->jdate($obj->date_end) + (empty($halfday) || $halfday == -1 ? 24 : 12) * 60 * 60 - 1;
1038 $event->date_start_in_calendar = $event->datep;
1039 $event->date_end_in_calendar = $event->datef;
1041 if ($obj->status == 3) {
1043 $event->percentage = -1;
1044 } elseif ($obj->status == 2) {
1046 $event->percentage = 0;
1049 if ($obj->halfday == 1) {
1050 $event->label = $obj->lastname.
' ('.$langs->trans(
"Morning").
')';
1051 } elseif ($obj->halfday == -1) {
1052 $event->label = $obj->lastname.
' ('.$langs->trans(
"Afternoon").
')';
1054 $event->label = $obj->lastname;
1057 $daycursor = $event->date_start_in_calendar;
1062 $daykey =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
1064 $eventarray[$daykey][] = $event;
1066 $daykey += 60 * 60 * 24;
1067 }
while ($daykey <= $event->date_end_in_calendar);
1075 if (count($listofextcals)) {
1076 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/ical.class.php';
1077 foreach ($listofextcals as $extcal) {
1078 $url = $extcal[
'src'];
1079 $namecal = $extcal[
'name'];
1080 $offsettz = $extcal[
'offsettz'];
1081 $colorcal = $extcal[
'color'];
1082 $buggedfile = $extcal[
'buggedfile'];
1089 $icalevents = array();
1090 if (is_array($ical->get_event_list())) {
1091 $icalevents = array_merge($icalevents, $ical->get_event_list());
1093 if (is_array($ical->get_freebusy_list())) {
1094 $icalevents = array_merge($icalevents, $ical->get_freebusy_list());
1097 if (count($icalevents) > 0) {
1099 $moreicalevents = array();
1100 foreach ($icalevents as $icalevent) {
1101 if (isset($icalevent[
'RRULE']) && is_array($icalevent[
'RRULE'])) {
1104 if ($icalevent[
'DTSTART;VALUE=DATE']) {
1107 } elseif (is_array($icalevent[
'DTSTART']) && !empty($icalevent[
'DTSTART'][
'unixtime'])) {
1108 $datecurstart = $icalevent[
'DTSTART'][
'unixtime'];
1109 $datecurend = $icalevent[
'DTEND'][
'unixtime'];
1110 if (!empty($ical->cal[
'DAYLIGHT'][
'DTSTART']) && $datecurstart) {
1112 $tmpcurstart = $datecurstart;
1113 $tmpcurend = $datecurend;
1114 $tmpdaylightstart =
dol_mktime(0, 0, 0, 1, 1, 1970, 1) + (int) $ical->cal[
'DAYLIGHT'][
'DTSTART'];
1115 $tmpdaylightend =
dol_mktime(0, 0, 0, 1, 1, 1970, 1) + (int) $ical->cal[
'STANDARD'][
'DTSTART'];
1118 if ($tmpcurstart >= $tmpdaylightstart && $tmpcurstart < $tmpdaylightend) {
1119 $datecurstart -= ((int) $ical->cal[
'DAYLIGHT'][
'TZOFFSETTO']) * 36;
1121 $datecurstart -= ((int) $ical->cal[
'STANDARD'][
'TZOFFSETTO']) * 36;
1123 if ($tmpcurend >= $tmpdaylightstart && $tmpcurstart < $tmpdaylightend) {
1124 $datecurend -= ((int) $ical->cal[
'DAYLIGHT'][
'TZOFFSETTO']) * 36;
1126 $datecurend -= ((int) $ical->cal[
'STANDARD'][
'TZOFFSETTO']) * 36;
1133 dol_syslog(
"Found a not recognized repeatable record with unknown date start", LOG_ERR);
1138 $interval = (empty($icalevent[
'RRULE'][
'INTERVAL']) ? 1 : $icalevent[
'RRULE'][
'INTERVAL']);
1139 $until = empty($icalevent[
'RRULE'][
'UNTIL']) ? 0 :
dol_stringtotime($icalevent[
'RRULE'][
'UNTIL'], 1);
1140 $maxrepeat = empty($icalevent[
'RRULE'][
'COUNT']) ? 0 : $icalevent[
'RRULE'][
'COUNT'];
1141 if ($until && ($until + ($datecurend - $datecurstart)) < $firstdaytoshow) {
1144 if ($datecurstart >= $lastdaytoshow) {
1149 while (($datecurstart < $lastdaytoshow) && (empty($maxrepeat) || ($numofevent < $maxrepeat))) {
1150 if ($datecurend >= $firstdaytoshow) {
1151 $newevent = $icalevent;
1152 unset($newevent[
'RRULE']);
1153 if ($icalevent[
'DTSTART;VALUE=DATE']) {
1154 $newevent[
'DTSTART;VALUE=DATE'] =
dol_print_date($datecurstart,
'%Y%m%d');
1155 $newevent[
'DTEND;VALUE=DATE'] =
dol_print_date($datecurend + 1,
'%Y%m%d');
1157 $newevent[
'DTSTART'] = $datecurstart;
1158 $newevent[
'DTEND'] = $datecurend;
1160 $moreicalevents[] = $newevent;
1164 $savdatecurstart = $datecurstart;
1165 if ($icalevent[
'RRULE'][
'FREQ'] ==
'DAILY') {
1169 if ($icalevent[
'RRULE'][
'FREQ'] ==
'WEEKLY') {
1172 } elseif ($icalevent[
'RRULE'][
'FREQ'] ==
'MONTHLY') {
1175 } elseif ($icalevent[
'RRULE'][
'FREQ'] ==
'YEARLY') {
1180 if ($savdatecurstart >= $datecurstart) {
1181 dol_syslog(
"Found a rule freq ".$icalevent[
'RRULE'][
'FREQ'].
" not managed by dolibarr code. Assume 1 week frequency.", LOG_ERR);
1182 $datecurstart += 3600 * 24 * 7;
1183 $datecurend += 3600 * 24 * 7;
1188 $icalevents = array_merge($icalevents, $moreicalevents);
1191 foreach ($icalevents as $icalevent) {
1196 if (!empty($icalevent[
'RRULE'])) {
1203 if (isset($icalevent[
'DTSTART;VALUE=DATE'])) {
1206 if (empty($icalevent[
'DTEND;VALUE=DATE'])) {
1207 $dateend = $datestart + 86400 - 1;
1213 $event->fulldayevent = 1;
1215 } elseif (!is_array($icalevent[
'DTSTART'])) {
1216 $datestart = $icalevent[
'DTSTART'];
1217 $dateend = empty($icalevent[
'DTEND']) ? $datestart : $icalevent[
'DTEND'];
1219 $datestart += +($offsettz * 3600);
1220 $dateend += +($offsettz * 3600);
1225 } elseif (isset($icalevent[
'DTSTART'][
'unixtime'])) {
1226 $datestart = $icalevent[
'DTSTART'][
'unixtime'];
1227 $dateend = $icalevent[
'DTEND'][
'unixtime'];
1229 $datestart += +($offsettz * 3600);
1230 $dateend += +($offsettz * 3600);
1233 if ($buggedfile ===
'uselocalandtznodaylight') {
1237 if ($buggedfile ===
'uselocalandtzdaylight') {
1238 $localtzs =
new DateTimeZone(preg_replace(
'/"/',
'', $icalevent[
'DTSTART'][
'TZID']));
1239 $localtze =
new DateTimeZone(preg_replace(
'/"/',
'', $icalevent[
'DTEND'][
'TZID']));
1240 $localdts =
new DateTime(
dol_print_date($datestart,
'dayrfc',
'gmt'), $localtzs);
1241 $localdte =
new DateTime(
dol_print_date($dateend,
'dayrfc',
'gmt'), $localtze);
1242 $tmps = -1 * $localtzs->getOffset($localdts);
1243 $tmpe = -1 * $localtze->getOffset($localdte);
1244 $datestart += $tmps;
1252 $event->id = $icalevent[
'UID'];
1253 $event->ref = $event->id;
1254 $userId = $userstatic->findUserIdByEmail($namecal);
1255 if (!empty($userId) && $userId > 0) {
1256 $event->userassigned[$userId] = $userId;
1257 $event->percentage = -1;
1260 $event->type_code =
"ICALEVENT";
1261 $event->type_label = $namecal;
1262 $event->type_color = $colorcal;
1263 $event->type =
'icalevent';
1264 $event->type_picto =
'rss';
1266 $event->icalname = $namecal;
1267 $event->icalcolor = $colorcal;
1269 $event->datep = $datestart + $usertime;
1270 $event->datef = $dateend + $usertime;
1272 if ($icalevent[
'SUMMARY']) {
1273 $event->label = $icalevent[
'SUMMARY'];
1274 } elseif ($icalevent[
'DESCRIPTION']) {
1275 $event->label =
dol_nl2br($icalevent[
'DESCRIPTION'], 1);
1277 $event->label = $langs->trans(
"ExtSiteNoLabel");
1284 if (!empty($icalevent[
'PRIORITY'])) {
1285 $event->priority = $icalevent[
'PRIORITY'];
1289 if ($icalevent[
'TRANSP']) {
1290 if ($icalevent[
'TRANSP'] ==
"TRANSPARENT") {
1291 $event->transparency = 0;
1293 if ($icalevent[
'TRANSP'] ==
"OPAQUE") {
1294 $event->transparency = 1;
1305 if (!empty($icalevent[
'LOCATION'])) {
1306 $event->location = $icalevent[
'LOCATION'];
1309 $event->date_start_in_calendar = $event->datep;
1311 if ($event->datef !=
'' && $event->datef >= $event->datep) {
1312 $event->date_end_in_calendar = $event->datef;
1314 $event->date_end_in_calendar = $event->datep;
1318 if ($event->date_end_in_calendar < $firstdaytoshow || $event->date_start_in_calendar >= $lastdaytoshow) {
1324 if ($event->date_start_in_calendar < $firstdaytoshow) {
1325 $event->date_start_in_calendar = $firstdaytoshow;
1327 if ($event->date_end_in_calendar >= $lastdaytoshow) {
1328 $event->date_end_in_calendar = ($lastdaytoshow - 1);
1332 $daycursor = $event->date_start_in_calendar;
1338 $loop =
true; $j = 0;
1340 $daykey =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
1341 $daykeygmt =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
1344 $eventarray[$daykey][] = $event;
1345 $daykey += 60 * 60 * 24; $daykeygmt += 60 * 60 * 24;
1346 if (($event->fulldayevent ? $daykeygmt : $daykey) > $event->date_end_in_calendar) {
1360 $parameters = array(); $object = null;
1361 $reshook = $hookmanager->executeHooks(
'getCalendarEvents', $parameters, $object, $action);
1362 if (!empty($hookmanager->resArray[
'eventarray'])) {
1363 foreach ($hookmanager->resArray[
'eventarray'] as $keyDate => $events) {
1364 if (!isset($eventarray[$keyDate])) {
1365 $eventarray[$keyDate] = array();
1367 $eventarray[$keyDate] = array_merge($eventarray[$keyDate], $events);
1372 foreach ($eventarray as $keyDate => &$dateeventarray) {
1373 usort($dateeventarray,
'sort_events_by_date');
1378 $cachethirdparties = array();
1379 $cachecontacts = array();
1380 $cacheusers = array();
1383 $color_file = DOL_DOCUMENT_ROOT.
"/theme/".$conf->theme.
"/theme_vars.inc.php";
1384 if (is_readable($color_file)) {
1385 include $color_file;
1387 if (!is_array($theme_datacolor)) {
1388 $theme_datacolor = array(array(120, 130, 150), array(200, 160, 180), array(190, 190, 220));
1391 $massactionbutton =
'';
1393 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);
1399 if (empty($mode) || $mode ==
'show_month') {
1401 $newparam = preg_replace(
'/showbirthday=/i',
'showbirthday_=', $newparam);
1402 $newparam = preg_replace(
'/mode=show_month&?/i',
'', $newparam);
1403 $newparam = preg_replace(
'/mode=show_week&?/i',
'', $newparam);
1404 $newparam = preg_replace(
'/day=[0-9]+&?/i',
'', $newparam);
1405 $newparam = preg_replace(
'/month=[0-9]+&?/i',
'', $newparam);
1406 $newparam = preg_replace(
'/year=[0-9]+&?/i',
'', $newparam);
1407 $newparam = preg_replace(
'/viewcal=[0-9]+&?/i',
'', $newparam);
1408 $newparam = preg_replace(
'/showbirthday_=/i',
'showbirthday=', $newparam);
1409 $newparam .=
'&viewcal=1';
1411 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1412 print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup,
'', $resourceid);
1415 print
'<div class="div-table-responsive-no-min sectioncalendarbymonth maxscreenheightless300">';
1416 print
'<table class="centpercent noborder nocellnopadd cal_pannel cal_month">';
1417 print
' <tr class="liste_titre">';
1419 echo
' <td class="center">#</td>';
1422 print
' <td class="center bold uppercase tdfordaytitle'.($i == 0 ?
' borderleft' :
'').
'">';
1423 $numdayinweek = (($i + (isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1)) % 7);
1424 if (!empty($conf->dol_optimize_smallscreen)) {
1425 $labelshort = array(0=>
'SundayMin', 1=>
'MondayMin', 2=>
'TuesdayMin', 3=>
'WednesdayMin', 4=>
'ThursdayMin', 5=>
'FridayMin', 6=>
'SaturdayMin');
1426 print $langs->trans($labelshort[$numdayinweek]);
1428 print $langs->trans(
"Day".$numdayinweek);
1430 print
' </td>'.
"\n";
1436 $todaytms =
dol_mktime(0, 0, 0, $todayarray[
'mon'], $todayarray[
'mday'], $todayarray[
'year']);
1440 for ($iter_week = 0; $iter_week < 6; $iter_week++) {
1444 $currdate0 = sprintf(
"%04d", $prev_year).sprintf(
"%02d", $prev_month).sprintf(
"%02d", $max_day_in_prev_month + $tmpday);
1445 } elseif ($tmpday <= $max_day_in_month) {
1446 $currdate0 = sprintf(
"%04d", $year).sprintf(
"%02d", $month).sprintf(
"%02d", $tmpday);
1449 $currdate0 = sprintf(
"%04d", $next_year).sprintf(
"%02d", $next_month).sprintf(
"%02d", $tmpday - $max_day_in_month);
1452 $numweek0 = date(
"W", strtotime(date($currdate0)));
1454 echo
' <td class="center weeknumber opacitymedium" width="2%">'.$numweek0.
'</td>';
1456 for ($iter_day = 0; $iter_day < 7; $iter_day++) {
1459 $style =
'cal_other_month cal_past';
1460 if ($iter_day == 6) {
1461 $style .=
' cal_other_month_right';
1463 echo
' <td class="'.$style.
' nowrap tdtop" width="14%">';
1464 show_day_events($db, $max_day_in_prev_month + $tmpday, $prev_month, $prev_year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam);
1466 } elseif ($tmpday <= $max_day_in_month) {
1468 $curtime =
dol_mktime(0, 0, 0, $month, $tmpday, $year);
1469 $style =
'cal_current_month';
1470 if ($iter_day == 6) {
1471 $style .=
' cal_current_month_right';
1474 if ($todayarray[
'mday'] == $tmpday && $todayarray[
'mon'] == $month && $todayarray[
'year'] == $year) {
1478 $style =
'cal_today';
1480 if ($curtime < $todaytms) {
1481 $style .=
' cal_past';
1484 echo
' <td class="'.$style.
' nowrap tdtop" width="14%">';
1485 show_day_events($db, $tmpday, $month, $year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam);
1489 $style =
'cal_other_month';
1490 if ($iter_day == 6) {
1491 $style .=
' cal_other_month_right';
1493 echo
' <td class="'.$style.
' nowrap tdtop" width="14%">';
1494 show_day_events($db, $tmpday - $max_day_in_month, $next_month, $next_year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam);
1504 print
'<input type="hidden" name="actionmove" value="mupdate">';
1505 print
'<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($_SERVER[
'PHP_SELF']).
'?mode=show_month&'.
dol_escape_htmltag($_SERVER[
'QUERY_STRING']).
'">';
1506 print
'<input type="hidden" name="newdate" id="newdate">';
1507 } elseif ($mode ==
'show_week') {
1510 $newparam = preg_replace(
'/showbirthday=/i',
'showbirthday_=', $newparam);
1511 $newparam = preg_replace(
'/mode=show_month&?/i',
'', $newparam);
1512 $newparam = preg_replace(
'/mode=show_week&?/i',
'', $newparam);
1513 $newparam = preg_replace(
'/day=[0-9]+&?/i',
'', $newparam);
1514 $newparam = preg_replace(
'/month=[0-9]+&?/i',
'', $newparam);
1515 $newparam = preg_replace(
'/year=[0-9]+&?/i',
'', $newparam);
1516 $newparam = preg_replace(
'/viewweek=[0-9]+&?/i',
'', $newparam);
1517 $newparam = preg_replace(
'/showbirthday_=/i',
'showbirthday=', $newparam);
1518 $newparam .=
'&viewweek=1';
1520 print
'<div class="liste_titre liste_titre_bydiv centpercent"><div class="divsearchfield">';
1521 print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup,
'', $resourceid);
1522 print
'</div></div>';
1524 print
'<div class="div-table-responsive-no-min sectioncalendarbyweek maxscreenheightless300">';
1525 print
'<table class="centpercent noborder nocellnopadd cal_pannel cal_month">';
1526 print
' <tr class="liste_titre">';
1529 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";
1536 for ($iter_day = 0; $iter_day < 7; $iter_day++) {
1543 $style =
'cal_current_month';
1544 if ($iter_day == 6) {
1545 $style .=
' cal_other_month_right';
1550 if ($todayarray[
'mday'] == $tmpday && $todayarray[
'mon'] == $tmpmonth && $todayarray[
'year'] == $tmpyear) {
1554 $style =
'cal_today';
1557 echo
' <td class="'.$style.
'" width="14%" valign="top">';
1558 show_day_events($db, $tmpday, $tmpmonth, $tmpyear, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300);
1566 echo
'<input type="hidden" name="actionmove" value="mupdate">';
1567 echo
'<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($_SERVER[
'PHP_SELF']).
'?mode=show_week&'.
dol_escape_htmltag($_SERVER[
'QUERY_STRING']).
'">';
1568 echo
'<input type="hidden" name="newdate" id="newdate">';
1571 $newparam = preg_replace(
'/mode=show_month&?/i',
'', $newparam);
1572 $newparam = preg_replace(
'/mode=show_week&?/i',
'', $newparam);
1573 $newparam = preg_replace(
'/viewday=[0-9]+&?/i',
'', $newparam);
1574 $newparam .=
'&viewday=1';
1576 $style =
'cal_current_month cal_current_month_oneday';
1579 if ($todayarray[
'mday'] == $day && $todayarray[
'mon'] == $month && $todayarray[
'year'] == $year) {
1584 $timestamp =
dol_mktime(12, 0, 0, $month, $day, $year);
1587 print
'<div class="liste_titre liste_titre_bydiv centpercent"><div class="divsearchfield">';
1588 print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup,
'', $resourceid);
1589 print
'</div></div>';
1591 print
'<div class="div-table-responsive-no-min sectioncalendarbyday maxscreenheightless300">';
1592 echo
'<table class="tagtable centpercent noborder nocellnopadd cal_pannel cal_month noborderbottom" style="margin-bottom: 5px !important;">';
1594 echo
' <tr class="tagtr liste_titre">';
1595 echo
' <td class="tagtd center bold uppercase">'.$langs->trans(
"Day".$arraytimestamp[
'wday']).
"</td>\n";
1613 print
'<div class="div-table-responsive-no-min borderbottom">';
1615 $maxheightwin = (isset($_SESSION[
"dol_screenheight"]) && $_SESSION[
"dol_screenheight"] > 500) ? ($_SESSION[
"dol_screenheight"] - 200) : 660;
1617 echo
'<div style="max-height: '.$maxheightwin.
'px;">';
1618 echo
'<div class="tagtable centpercent calendarviewcontainer">';
1622 $tmp = explode(
'-', $conf->global->MAIN_DEFAULT_WORKING_HOURS);
1623 $minhour = round($tmp[0], 0);
1624 $maxhour = round($tmp[1], 0);
1625 if ($minhour > 23) {
1631 if ($maxhour <= $minhour) {
1632 $maxhour = $minhour + 1;
1638 echo
' <div class="tagtr calendarviewcontainertr">'.
"\n";
1639 echo
' <div class="tagtd width100 tdtop">'.dol_print_date($i * 3600,
'hour',
'gmt').
'</div>';
1640 echo
' <div class="tagtd '.$style.
' tdtop"></div>'.
"\n";
1641 echo
' </div>'.
"\n";
1646 echo
'</div></div>';
1648 show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 1);
1652 print
'<div class="div-table-responsive-no-min">';
1654 show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 0);
1660 print
"\n".
'</form>';
1685 function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventarray, $maxprint = 0, $maxnbofchar = 16, $newparam =
'', $showinfo = 0, $minheight = 60, $nonew = 0)
1687 global $user, $conf, $langs;
1688 global $action, $mode, $filter, $filtert, $status, $actioncode, $usergroup;
1689 global $theme_datacolor;
1690 global $cachethirdparties, $cachecontacts, $cacheusers, $colorindexused;
1692 if ($conf->use_javascript_ajax) {
1693 $conf->global->MAIN_JS_SWITCH_AGENDA = 1;
1696 $dateint = sprintf(
"%04d", $year).sprintf(
"%02d", $month).sprintf(
"%02d", $day);
1702 $curtime =
dol_mktime(0, 0, 0, $month, $day, $year);
1703 $urltoshow = DOL_URL_ROOT.
'/comm/action/index.php?mode=show_day&day='.str_pad($day, 2,
"0", STR_PAD_LEFT).
'&month='.str_pad($month, 2,
"0", STR_PAD_LEFT).
'&year='.$year.$newparam;
1705 if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) {
1706 $newparam .=
'&month='.str_pad($month, 2,
"0", STR_PAD_LEFT).
'&year='.$year;
1707 $hourminsec =
'100000';
1708 $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 :
''));
1712 print
'<div id="dayevent_'.$dateint.
'" class="dayevent tagtable centpercent nobordernopadding">'.
"\n";
1715 print
'<div class="tagtr cursorpointer" onclick="window.location=\''.$urltocreate.
'\';
"><div class="nowrap tagtd
"><div class="left
inline-block
">';
1716 print '<a class="dayevent-aday
" style="color: #666
" href="'.$urltoshow.'">';
1718 print dol_print_date($curtime, 'daytextshort');
1720 print dol_print_date($curtime, '%d');
1723 print '</div><div class="nowrap floatright
inline-block marginrightonly
">';
1724 if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) {
1725 print '<a class="cursoradd
" href="'.$urltocreate.'">'; // Explicit link, usefull for nojs interfaces
1726 print img_picto($langs->trans("NewAction
"), 'edit_add.png');
1729 print '</div></div></div>'."\n
";
1737 // Line with td contains all div of each events
1738 print '<div class="tagtr
">';
1739 print '<div class="tagtd centpercent agendacell sortable
">';
1741 //$curtime = dol_mktime (0, 0, 0, $month, $day, $year);
1742 $i = 0; $ireallyshown = 0; $itoshow = 0; $numother = 0; $numbirthday = 0; $numical = 0; $numicals = array();
1743 $ymd = sprintf("%04d
", $year).sprintf("%02d
", $month).sprintf("%02d
", $day);
1745 $colorindexused[$user->id] = 0; // Color index for current user (user->id) is always 0
1746 $nextindextouse = is_array($colorindexused) ?count($colorindexused) : 0; // At first run this is 0, so fist user has 0, next 1, ...
1747 //var_dump($colorindexused);
1749 include_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php';
1750 $tmpholiday = new Holiday($db);
1752 foreach ($eventarray as $daykey => $notused) { // daykey is the 'YYYYMMDD' to show according to user
1753 $annee = dol_print_date($daykey, '%Y', 'gmt'); // We use gmt because we want the value represented by string 'YYYYMMDD'
1754 $mois = dol_print_date($daykey, '%m', 'gmt'); // We use gmt because we want the value represented by string 'YYYYMMDD'
1755 $jour = dol_print_date($daykey, '%d', 'gmt'); // We use gmt because we want the value represented by string 'YYYYMMDD'
1757 //print 'event daykey='.$daykey.' dol_print_date(daykey)='.dol_print_date($daykey, 'dayhour', 'gmt').' jour='.$jour.' mois='.$mois.' annee='.$annee."<br>\n
";
1759 if ($day == $jour && $month == $mois && $year == $annee) {
1760 foreach ($eventarray[$daykey] as $index => $event) {
1761 if ($i < $maxprint || $maxprint == 0 || !empty($conf->global->MAIN_JS_SWITCH_AGENDA)) {
1762 $keysofuserassigned = array_keys($event->userassigned);
1763 $ponct = ($event->date_start_in_calendar == $event->date_end_in_calendar);
1765 // Define $color (Hex string like '0088FF') and $cssclass of event
1766 $color = -1; $cssclass = ''; $colorindex = -1;
1767 if (in_array($user->id, $keysofuserassigned)) {
1768 $cssclass = 'family_mytasks';
1770 if (empty($cacheusers[$event->userownerid])) {
1771 $newuser = new User($db);
1772 $newuser->fetch($event->userownerid);
1773 $cacheusers[$event->userownerid] = $newuser;
1775 //var_dump($cacheusers[$event->userownerid]->color);
1777 // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event)
1778 if (!empty($cacheusers[$event->userownerid]->color)) {
1779 $color = $cacheusers[$event->userownerid]->color;
1781 } elseif ($event->type_code == 'ICALEVENT') { // Event come from external ical file
1783 if (!empty($event->icalname)) {
1784 if (!isset($numicals[dol_string_nospecial($event->icalname)])) {
1785 $numicals[dol_string_nospecial($event->icalname)] = 0;
1787 $numicals[dol_string_nospecial($event->icalname)]++;
1790 $color = ($event->icalcolor ? $event->icalcolor : -1);
1791 $cssclass = (!empty($event->icalname) ? 'family_ext'.md5($event->icalname) : 'family_other');
1792 } elseif ($event->type_code == 'BIRTHDAY') {
1793 $numbirthday++; $colorindex = 2; $cssclass = 'family_birthday '; $color = sprintf("%02x%02x%02x
", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
1796 $color = ($event->icalcolor ? $event->icalcolor : -1);
1797 $cssclass = (!empty($event->icalname) ? 'family_ext'.md5($event->icalname) : 'family_other');
1799 if (empty($cacheusers[$event->userownerid])) {
1800 $newuser = new User($db);
1801 $newuser->fetch($event->userownerid);
1802 $cacheusers[$event->userownerid] = $newuser;
1804 //var_dump($cacheusers[$event->userownerid]->color);
1806 // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event)
1807 if (!empty($cacheusers[$event->userownerid]->color)) {
1808 $color = $cacheusers[$event->userownerid]->color;
1812 if ($color < 0) { // Color was not set on user card. Set color according to color index.
1813 // Define color index if not yet defined
1814 $idusertouse = ($event->userownerid ? $event->userownerid : 0);
1815 if (isset($colorindexused[$idusertouse])) {
1816 $colorindex = $colorindexused[$idusertouse]; // Color already assigned to this user
1818 $colorindex = $nextindextouse;
1819 $colorindexused[$idusertouse] = $colorindex;
1820 if (!empty($theme_datacolor[$nextindextouse + 1])) {
1821 $nextindextouse++; // Prepare to use next color
1824 //print '|'.($color).'='.($idusertouse?$idusertouse:0).'='.$colorindex.'<br>';
1826 $color = sprintf("%02x%02x%02x
", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
1828 $cssclass = $cssclass.' eventday_'.$ymd;
1830 // Defined style to disable drag and drop feature
1831 if ($event->type_code == 'AC_OTH_AUTO') {
1832 $cssclass .= " unmovable
";
1833 } elseif ($event->type_code == 'HOLIDAY') {
1834 $cssclass .= " unmovable
";
1835 } elseif ($event->type_code == 'BIRTHDAY') {
1836 $cssclass .= " unmovable
";
1837 } elseif ($event->type_code == 'ICALEVENT') {
1838 $cssclass .= " unmovable
";
1839 } 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)) {
1840 // If the event is on several days
1841 $tmpyearend = dol_print_date($event->date_start_in_calendar, '%Y', 'tzuserrel');
1842 $tmpmonthend = dol_print_date($event->date_start_in_calendar, '%m', 'tzuserrel');
1843 $tmpdayend = dol_print_date($event->date_start_in_calendar, '%d', 'tzuserrel');
1844 //var_dump($tmpyearend.' '.$tmpmonthend.' '.$tmpdayend);
1845 if ($tmpyearend != $annee || $tmpmonthend != $mois || $tmpdayend != $jour) {
1846 $cssclass .= " unmovable unmovable-mustusefirstdaytodrag
";
1848 $cssclass .= ' movable cursormove';
1851 if ($user->rights->agenda->allactions->create ||
1852 (($event->authorid == $user->id || $event->userownerid == $user->id) && $user->rights->agenda->myactions->create)) {
1853 $cssclass .= " movable cursormove
";
1855 $cssclass .= " unmovable
";
1859 $h = ''; $nowrapontd = 1;
1860 if ($mode == 'show_day') {
1861 $h = 'height: 100%; '; $nowrapontd = 0;
1863 if ($mode == 'show_week') {
1864 $h = 'height: 100%; '; $nowrapontd = 0;
1869 print '<!-- start event '.$i.' -->'."\n
";
1872 if ($maxprint && $ireallyshown >= $maxprint) {
1873 $morecss = 'showifmore';
1875 if ($event->type == 'birthdate' && !GETPOST('check_birthday')) {
1876 $morecss = 'hidden';
1878 if ($event->type == 'holiday' && !GETPOST('check_holiday')) {
1879 $morecss = 'hidden';
1881 if ($morecss != 'hidden') {
1884 if ($morecss != 'showifmore' && $morecss != 'hidden') {
1887 //var_dump($event->type.' - '.$morecss.' - '.$cssclass.' - '.$i.' - '.$ireallyshown.' - '.$itoshow);
1889 print '<div id="event_
'.$ymd.'_
'.$i.'" class="event family_
'.$event->type.' '.$cssclass.($morecss ? ' '.$morecss : '').'"';
1890 //print ' style="height: 100px;
';
1891 //print ' position: absolute; top: 40px; width: 50%;
';
1895 //var_dump($event->userassigned);
1896 //var_dump($event->transparency);
1897 print '<table class="centpercent cal_event
';
1898 print (empty($event->transparency) ? ' cal_event_notbusy
' : ' cal_event_busy
');
1899 //if (empty($event->transparency) && empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) print ' opacitymedium
'; // Not busy
1900 print '" style="'.$h;
1901 $colortouse = $color;
1902 // If colortouse is similar than background, we force to change it.
1903 if (empty($event->transparency) && empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) {
1904 print 'background: #f0f0f0;
';
1905 print 'border-left: 5px solid #
'.$colortouse.';
';
1907 print 'background: #f0f0f0;
';
1908 print 'border-left: 5px solid #
'.dol_color_minus($colortouse, -3).';
';
1909 //print 'background: -webkit-gradient(linear, left top, left bottom, from(#
'.dol_color_minus($colortouse, -3).'), to(#
'.dol_color_minus($colortouse, -1).'));
';
1911 //print 'background: #
'.$colortouse.';
';
1912 //print 'background: -webkit-gradient(linear, left top, left bottom, from(#
'.dol_color_minus($color, -3).'), to(#
'.dol_color_minus($color, -1).'));
';
1913 //if (! empty($event->transparency)) print 'background: #
'.$color.'; background: -webkit-gradient(linear, left top, left bottom, from(#
'.$color.'), to(#
'.dol_color_minus($color,1).'));
';
1914 //else print 'background-color: transparent !important; background: none; border: 1px solid #bbb;
';
1915 //print ' -moz-border-radius:4px;
"';
1916 //print 'border: 1px solid #ccc" width=
"100%"';
1919 print '<td class="tdoverflow nobottom centpercent
'.($nowrapontd ? 'nowrap
' : '').'cal_event
'.($event->type_code == 'BIRTHDAY
' ? ' cal_event_birthday
' : '').'">';
1923 if ($event->type_code == 'BIRTHDAY') { // It's birthday calendar
1924 print $event->getNomUrl(1, $maxnbofchar, 'cal_event', 'birthday', 'contact');
1925 } elseif ($event->type_code == 'HOLIDAY') { // It's holiday calendar
1926 $tmpholiday->fetch($event->id);
1928 print $tmpholiday->getNomUrl(1);
1930 $tmpid = $tmpholiday->fk_user;
1931 if (empty($cacheusers[$tmpid])) {
1932 $newuser = new User($db);
1933 $newuser->fetch($tmpid);
1934 $cacheusers[$tmpid] = $newuser;
1937 $listofusertoshow = '';
1938 $listofusertoshow .= '<br>'.$cacheusers[$tmpid]->getNomUrl(-1, '', 0, 0, 0, 0, '', 'paddingright valigntextbottom');
1939 print $listofusertoshow;
1940 } else { // Other calendar
1942 if (empty($event->fulldayevent)) {
1943 //print $event->getNomUrl(2).' ';
1947 if (empty($event->fulldayevent)) {
1948 // Show hours (start ... end)
1949 $tmpyearstart = dol_print_date($event->date_start_in_calendar, '%Y', 'tzuserrel');
1950 $tmpmonthstart = dol_print_date($event->date_start_in_calendar, '%m', 'tzuserrel');
1951 $tmpdaystart = dol_print_date($event->date_start_in_calendar, '%d', 'tzuserrel');
1952 $tmpyearend = dol_print_date($event->date_end_in_calendar, '%Y', 'tzuserrel');
1953 $tmpmonthend = dol_print_date($event->date_end_in_calendar, '%m', 'tzuserrel');
1954 $tmpdayend = dol_print_date($event->date_end_in_calendar, '%d', 'tzuserrel');
1957 if ($tmpyearstart == $annee && $tmpmonthstart == $mois && $tmpdaystart == $jour) {
1958 $daterange .= dol_print_date($event->date_start_in_calendar, 'hour', 'tzuserrel');
1959 if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) {
1960 if ($tmpyearstart == $tmpyearend && $tmpmonthstart == $tmpmonthend && $tmpdaystart == $tmpdayend) {
1967 if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) {
1968 if ($tmpyearstart != $tmpyearend || $tmpmonthstart != $tmpmonthend || $tmpdaystart != $tmpdayend) {
1969 $daterange .= '...';
1973 if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) {
1974 if ($tmpyearend == $annee && $tmpmonthend == $mois && $tmpdayend == $jour) {
1975 $daterange .= dol_print_date($event->date_end_in_calendar, 'hour', 'tzuserrel');
1980 print $langs->trans("EventOnFullDay
")."<br>\n
";
1985 $titletoshow = $daterange;
1986 $titletoshow .= ($titletoshow ? ' ' : '').($event->label ? $event->label : $event->libelle);
1988 if ($event->type_code != 'ICALEVENT') {
1989 $savlabel = $event->label ? $event->label : $event->libelle;
1990 $event->label = $titletoshow;
1991 $event->libelle = $titletoshow; // deprecatd
1992 // Note: List of users are inside $event->userassigned. Link may be clickable depending on permissions of user.
1993 $titletoshow = (($event->type_picto || $event->type_code) ? $event->getTypePicto() : '');
1994 $titletoshow .= $event->getNomUrl(0, $maxnbofchar, 'cal_event cal_event_title', '', 0, 0);
1995 $event->label = $savlabel;
1996 $event->libelle = $savlabel;
1999 // Loop on each assigned user
2000 $listofusertoshow = '';
2001 $posuserassigned = 0;
2002 foreach ($event->userassigned as $tmpid => $tmpdata) {
2003 if (!$posuserassigned && $titletoshow) {
2004 $listofusertoshow .= '<br>';
2007 if (empty($cacheusers[$tmpid])) {
2008 $newuser = new User($db);
2009 $newuser->fetch($tmpid);
2010 $cacheusers[$tmpid] = $newuser;
2013 $listofusertoshow .= $cacheusers[$tmpid]->getNomUrl(-3, '', 0, 0, 0, 0, '', 'paddingright valigntextbottom');
2017 print $listofusertoshow;
2019 if ($event->type_code == 'ICALEVENT') {
2020 print '<br>('.dol_trunc($event->icalname, $maxnbofchar).')';
2023 $thirdparty_id = ($event->socid > 0 ? $event->socid : ((is_object($event->societe) && $event->societe->id > 0) ? $event->societe->id : 0));
2024 $contact_id = ($event->contact_id > 0 ? $event->contact_id : ((is_object($event->contact) && $event->contact->id > 0) ? $event->contact->id : 0));
2026 // If action related to company / contact
2027 $linerelatedto = '';
2028 if ($thirdparty_id > 0) {
2029 if (!isset($cachethirdparties[$thirdparty_id]) || !is_object($cachethirdparties[$thirdparty_id])) {
2030 $thirdparty = new Societe($db);
2031 $thirdparty->fetch($thirdparty_id);
2032 $cachethirdparties[$thirdparty_id] = $thirdparty;
2034 $thirdparty = $cachethirdparties[$thirdparty_id];
2036 if (!empty($thirdparty->id)) {
2037 $linerelatedto .= $thirdparty->getNomUrl(1, '', 0);
2040 if (!empty($contact_id) && $contact_id > 0) {
2041 if (!is_object($cachecontacts[$contact_id])) {
2042 $contact = new Contact($db);
2043 $contact->fetch($contact_id);
2044 $cachecontacts[$contact_id] = $contact;
2046 $contact = $cachecontacts[$contact_id];
2048 if ($linerelatedto) {
2049 $linerelatedto .= ' ';
2051 if (!empty($contact->id)) {
2052 $linerelatedto .= $contact->getNomUrl(1, '', 0);
2055 if (!empty($event->fk_element) && $event->fk_element > 0 && !empty($event->elementtype) && !empty($conf->global->AGENDA_SHOW_LINKED_OBJECT)) {
2056 include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
2057 if ($linerelatedto) {
2058 $linerelatedto .= '<br>';
2060 $linerelatedto .= dolGetElementUrl($event->fk_element, $event->elementtype, 1);
2062 if ($linerelatedto) {
2063 print '<br>'.$linerelatedto;
2069 if ($event->location) {
2071 print $langs->trans("Location
").': '.$event->location;
2078 if ($event->type_code != 'BIRTHDAY' && $event->type_code != 'ICALEVENT') {
2080 if ($event->percentage >= 0) {
2084 print '<td class="nobottom right nowrap cal_event_right
'.($withstatus >= 2 ? ' cal_event_right_status
' : '').'">';
2086 print $event->getLibStatut(3, 1);
2090 print '</td></tr></table>';
2091 print '</div><!-- end event '.$i.' -->'."\n
";
2095 print '<a href="'.DOL_URL_ROOT.'/comm/action/index.php?mode=
'.$mode.'&maxprint=0&month=
'.((int) $monthshown).'&year=
'.((int) $year);
2096 print ($status ? '&status=
'.$status : '').($filter ? '&filter=
'.urlencode($filter) : '');
2097 print ($filtert ? '&search_filtert=
'.urlencode($filtert) : '');
2098 print ($usergroup ? '&search_usergroup=
'.urlencode($usergroup) : '');
2099 print ($actioncode != '' ? '&search_actioncode=
'.urlencode($actioncode) : '');
2100 print '">'.img_picto("all
", "1downarrow_selected.png
").' ...';
2101 print ' +'.(count($eventarray[$daykey]) - $maxprint);
2104 //$ok=false; // To avoid to show twice the link
2111 if (!$i) { // No events
2115 if (!empty($conf->global->MAIN_JS_SWITCH_AGENDA) && $itoshow > $ireallyshown && $maxprint) {
2116 print '<div class="center cursorpointer
" id="more_
'.$ymd.'">'.img_picto("All
", "angle-
double-down
", 'class="warning
"').' +'.($itoshow - $ireallyshown).'</div>';
2117 //print ' +'.(count($eventarray[$daykey])-$maxprint);
2119 print '<script type="text/javascript
">'."\n
";
2120 print 'jQuery(document).ready(function () {'."\n
";
2121 print ' var open=0;'."\n
";
2122 print ' jQuery("#more_
'.$ymd.'").click(function() { console.log("Click on showmore
for '.$ymd.'"); reinit_day_'.$ymd.'(); event.stopImmediatePropagation(); });'."\n
";
2123 print ' function reinit_day_'.$ymd.'() {'."\n
";
2124 print ' jQuery(".eventday_
'.$ymd.'.showifmore
").toggle();'."\n
";
2125 print ' open = open + 1; if (open > 1) { open = 0; }'."\n
";
2126 print ' if (open) { ';
2127 print ' jQuery("#more_
'.$ymd.'").html(\''.img_picto("All
", "angle-
double-up
", 'class="warning
"').'\');'."\n
";
2129 print ' jQuery("#more_
'.$ymd.'").html(\''.img_picto("All
", "angle-
double-down
", 'class="warning
"').' +'.($itoshow - $ireallyshown).'\');'."\n
";
2133 print '</script>'."\n
";
2136 print '</div></div>'; // td tr
2138 print '</div>'; // table
2151 function dol_color_minus($color, $minus, $minusunit = 16)
2154 if ($minusunit == 16) {
2155 $newcolor[0] = dechex(max(min(hexdec($newcolor[0]) - $minus, 15), 0));
2156 $newcolor[2] = dechex(max(min(hexdec($newcolor[2]) - $minus, 15), 0));
2157 $newcolor[4] = dechex(max(min(hexdec($newcolor[4]) - $minus, 15), 0));
2159 // Not yet implemented
2171 function sort_events_by_date($a, $b)
2173 // Sort holidays at first
2174 if ($a->type_code === 'HOLIDAY') {
2177 if ($b->type_code === 'HOLIDAY') {
2181 // datep => Event start time
2182 // datef => Event end time
2184 // Events have different start time
2185 if ($a->datep !== $b->datep) {
2186 return $a->datep - $b->datep;
2189 // Events have same start time and no end time
2190 if ((!is_numeric($b->datef)) || (!is_numeric($a->datef))) {
2191 return sort_events_by_percentage($a, $b);
2194 // Events have the same start time and same end time
2195 if ($b->datef === $a->datef) {
2196 return sort_events_by_percentage($a, $b);
2199 // Events have the same start time, but have different end time -> longest event first
2200 return $b->datef - $a->datef;
2210 function sort_events_by_percentage($a, $b)
2212 // Sort events with no percentage before each other
2213 // (usefull to sort holidays, sick days or similar on the top)
2215 if ($a->percentage < 0) {
2219 if ($b->percentage < 0) {
2223 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.
if($cancel &&!$id) if($action== 'add'&&!$cancel) if($action== 'delete') if($id) $form
Actions.
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.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default= '')
Return dolibarr global constant string value.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
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_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...
dol_get_prev_day($day, $month, $year)
Return previous day.
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save"&&empty($cancel)) $help_url
View.
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
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 from a POST of a form...
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)
show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventarray, $maxprint=0, $maxnbofchar=16, $newparam= '', $showinfo=0, $minheight=60, $nonew=0)
Show event of a particular day.
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.
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 ...
restrictedArea($user, $features, $objectid=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.
if(isModEnabled('facture')&&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur')&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)&&$user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice')&&$user->rights->supplier_invoice->lire)) if(isModEnabled('don')&&!empty($user->rights->don->lire)) if(isModEnabled('tax')&&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture')&&isModEnabled('commande')&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dolGetFirstLastname($firstname, $lastname, $nameorder=-1)
Return firstname and lastname in correct order.