34 require
'../../main.inc.php';
35 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
39 require_once DOL_DOCUMENT_ROOT.
'/core/lib/agenda.lib.php';
41 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
44 if (!isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) {
45 $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW = 3;
48 if (empty($conf->global->AGENDA_EXT_NB)) {
49 $conf->global->AGENDA_EXT_NB = 5;
51 $MAXAGENDA = $conf->global->AGENDA_EXT_NB;
53 $disabledefaultvalues =
GETPOST(
'disabledefaultvalues',
'int');
55 $check_holiday =
GETPOST(
'check_holiday',
'int');
56 $filter =
GETPOST(
"search_filter",
'alpha', 3) ?
GETPOST(
"search_filter",
'alpha', 3) :
GETPOST(
"filter",
'alpha', 3);
57 $filtert =
GETPOST(
"search_filtert",
"int", 3) ?
GETPOST(
"search_filtert",
"int", 3) :
GETPOST(
"filtert",
"int", 3);
58 $usergroup =
GETPOST(
"search_usergroup",
"int", 3) ?
GETPOST(
"search_usergroup",
"int", 3) :
GETPOST(
"usergroup",
"int", 3);
59 $showbirthday = empty($conf->use_javascript_ajax) ?
GETPOST(
"showbirthday",
"int") : 1;
62 if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS)) {
68 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
69 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
71 if (empty($page) || $page == -1) {
74 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
75 $offset = $limit * $page;
80 $sortfield =
"a.datec";
86 $socid = $user->socid;
93 if (empty($user->rights->agenda->myactions->read)) {
96 if (empty($user->rights->agenda->allactions->read)) {
99 if (empty($user->rights->agenda->allactions->read) || $filter ==
'mine') {
100 $filtert = $user->id;
103 $action =
GETPOST(
'action',
'aZ09');
105 $mode =
GETPOST(
'mode',
'aZ09');
106 if (empty($mode) && preg_match(
'/show_/', $action)) {
109 $resourceid =
GETPOST(
"search_resourceid",
"int");
110 $year =
GETPOST(
"year",
"int") ?
GETPOST(
"year",
"int") : date(
"Y");
111 $month =
GETPOST(
"month",
"int") ?
GETPOST(
"month",
"int") : date(
"m");
112 $week =
GETPOST(
"week",
"int") ?
GETPOST(
"week",
"int") : date(
"W");
114 $pid =
GETPOST(
"search_projectid",
"int", 3) ?
GETPOST(
"search_projectid",
"int", 3) :
GETPOST(
"projectid",
"int", 3);
117 $maxprint =
GETPOSTISSET(
"maxprint") ?
GETPOST(
"maxprint",
'int') : $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW;
118 $optioncss =
GETPOST(
'optioncss',
'aZ');
121 if ($dateselect > 0) {
122 $day =
GETPOST(
'dateselectday',
'int');
123 $month =
GETPOST(
'dateselectmonth',
'int');
124 $year =
GETPOST(
'dateselectyear',
'int');
128 if (
GETPOST(
'search_actioncode',
'array:aZ09')) {
129 $actioncode =
GETPOST(
'search_actioncode',
'array:aZ09', 3);
130 if (!count($actioncode)) {
134 $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));
138 $status = ((empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) || $disabledefaultvalues) ?
'' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS);
141 $defaultview = (empty($conf->global->AGENDA_DEFAULT_VIEW) ?
'show_month' : $conf->global->AGENDA_DEFAULT_VIEW);
142 $defaultview = (empty($user->conf->AGENDA_DEFAULT_VIEW) ? $defaultview : $user->conf->AGENDA_DEFAULT_VIEW);
144 $mode = $defaultview;
146 if ($mode ==
'default') {
147 $mode = (($defaultview !=
'show_list') ? $defaultview :
'show_month');
149 if (
GETPOST(
'viewcal',
'int') &&
GETPOST(
'mode',
'alpha') !=
'show_day' &&
GETPOST(
'mode',
'alpha') !=
'show_week') {
150 $mode =
'show_month'; $day =
'';
152 if (
GETPOST(
'viewweek',
'int') ||
GETPOST(
'mode',
'alpha') ==
'show_week') {
153 $mode =
'show_week'; $week = ($week ? $week : date(
"W")); $day = ($day ? $day : date(
"d"));
155 if (
GETPOST(
'viewday',
'int') ||
GETPOST(
'mode',
'alpha') ==
'show_day') {
156 $mode =
'show_day'; $day = ($day ? $day : date(
"d"));
162 $langs->loadLangs(array(
'agenda',
'other',
'commercial'));
165 $hookmanager->initHooks(array(
'agenda'));
167 $result =
restrictedArea($user,
'agenda', 0,
'actioncomm&societe',
'myactions|allactions',
'fk_soc',
'id');
168 if ($user->socid && $socid) {
177 if (
GETPOST(
"viewlist",
'alpha') || $mode ==
'show_list') {
179 if (is_array($_POST)) {
180 foreach ($_POST as $key => $val) {
181 if ($key ==
'token') {
184 $param .=
'&'.$key.
'='.urlencode($val);
187 if (!preg_match(
'/action=/', $param)) {
188 $param .= ($param ?
'&' :
'').
'mode=show_list';
191 header(
"Location: ".DOL_URL_ROOT.
'/comm/action/list.php?'.$param);
195 if (
GETPOST(
"viewperuser",
'alpha') || $mode ==
'show_peruser') {
197 if (is_array($_POST)) {
198 foreach ($_POST as $key => $val) {
199 if ($key ==
'token') {
202 $param .=
'&'.$key.
'='.urlencode($val);
206 header(
"Location: ".DOL_URL_ROOT.
'/comm/action/peruser.php?'.$param);
234 'maxprint' => $maxprint,
236 'filtert' => $filtert,
237 'showbirthday' => $showbirthday,
238 'canedit' => $canedit,
239 'optioncss' => $optioncss,
240 'actioncode' => $actioncode,
242 'resourceid' => $resourceid,
243 'usergroup' => $usergroup,
245 $reshook = $hookmanager->executeHooks(
'beforeAgenda', $parameters, $object, $action);
250 $help_url =
'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda';
254 $companystatic =
new Societe($db);
255 $contactstatic =
new Contact($db);
256 $userstatic =
new User($db);
260 $nowyear = $nowarray[
'year'];
261 $nowmonth = $nowarray[
'mon'];
262 $nowday = $nowarray[
'mday'];
264 $listofextcals = array();
267 if (empty($conf->global->AGENDA_DISABLE_EXT)) {
269 while ($i < $MAXAGENDA) {
271 $source =
'AGENDA_EXT_SRC'.$i;
272 $name =
'AGENDA_EXT_NAME'.$i;
273 $offsettz =
'AGENDA_EXT_OFFSETTZ'.$i;
274 $color =
'AGENDA_EXT_COLOR'.$i;
275 $default =
'AGENDA_EXT_ACTIVEBYDEFAULT'.$i;
276 $buggedfile =
'AGENDA_EXT_BUGGEDFILE'.$i;
279 $listofextcals[] = array(
291 if (empty($user->conf->AGENDA_DISABLE_EXT)) {
293 while ($i < $MAXAGENDA) {
295 $source =
'AGENDA_EXT_SRC_'.$user->id.
'_'.$i;
296 $name =
'AGENDA_EXT_NAME_'.$user->id.
'_'.$i;
297 $offsettz =
'AGENDA_EXT_OFFSETTZ_'.$user->id.
'_'.$i;
298 $color =
'AGENDA_EXT_COLOR_'.$user->id.
'_'.$i;
299 $enabled =
'AGENDA_EXT_ENABLED_'.$user->id.
'_'.$i;
300 $default =
'AGENDA_EXT_ACTIVEBYDEFAULT_'.$user->id.
'_'.$i;
301 $buggedfile =
'AGENDA_EXT_BUGGEDFILE_'.$user->id.
'_'.$i;
304 $listofextcals[] = array(
307 'offsettz' => (
int) (empty($user->conf->$offsettz) ? 0 : $user->conf->$offsettz),
310 'buggedfile' =>
dol_string_nohtmltag(isset($user->conf->buggedfile) ? $user->conf->buggedfile :
'')
316 if (empty($mode) || $mode ==
'show_month') {
318 $prev_year = $prev[
'year'];
319 $prev_month = $prev[
'month'];
321 $next_year = $next[
'year'];
322 $next_month = $next[
'month'];
324 $max_day_in_prev_month = date(
"t",
dol_mktime(0, 0, 0, $prev_month, 1, $prev_year,
'gmt'));
325 $max_day_in_month = date(
"t",
dol_mktime(0, 0, 0, $month, 1, $year));
327 $tmpday = -date(
"w",
dol_mktime(12, 0, 0, $month, 1, $year,
'gmt')) + 2;
328 $tmpday += ((isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1) - 1);
333 $firstdaytoshow =
dol_mktime(0, 0, 0, $prev_month, $max_day_in_prev_month + $tmpday, $prev_year,
'tzuserrel');
334 $next_day = 7 - ($max_day_in_month + 1 - $tmpday) % 7;
338 $lastdaytoshow =
dol_mktime(0, 0, 0, $next_month, $next_day, $next_year,
'tzuserrel');
340 if ($mode ==
'show_week') {
342 $prev_year = $prev[
'prev_year'];
343 $prev_month = $prev[
'prev_month'];
344 $prev_day = $prev[
'prev_day'];
345 $first_day = $prev[
'first_day'];
346 $first_month = $prev[
'first_month'];
347 $first_year = $prev[
'first_year'];
349 $week = $prev[
'week'];
353 $next_year = $next[
'year'];
354 $next_month = $next[
'month'];
355 $next_day = $next[
'day'];
358 $firstdaytoshow =
dol_mktime(0, 0, 0, $first_month, $first_day, $first_year,
'tzuserrel');
361 $max_day_in_month = date(
"t",
dol_mktime(0, 0, 0, $month, 1, $year,
'gmt'));
363 $tmpday = $first_day;
365 if ($mode ==
'show_day') {
367 $prev_year = $prev[
'year'];
368 $prev_month = $prev[
'month'];
369 $prev_day = $prev[
'day'];
371 $next_year = $next[
'year'];
372 $next_month = $next[
'month'];
373 $next_day = $next[
'day'];
375 $firstdaytoshow =
dol_mktime(0, 0, 0, $prev_month, $prev_day, $prev_year,
'tzuserrel');
376 $lastdaytoshow =
dol_mktime(0, 0, 0, $next_month, $next_day, $next_year,
'tzuserrel');
389 if (is_array($actioncode)) {
390 foreach ($actioncode as $str_action) {
391 $param .=
"&search_actioncode[]=".urlencode($str_action);
394 $param .=
"&search_actioncode=".urlencode($actioncode);
397 if ($resourceid > 0) {
398 $param .=
"&search_resourceid=".urlencode($resourceid);
401 $param .=
"&search_status=".urlencode($status);
404 $param .=
"&search_filter=".urlencode($filter);
407 $param .=
"&search_filtert=".urlencode($filtert);
409 if ($usergroup > 0) {
410 $param .=
"&search_usergroup=".urlencode($usergroup);
413 $param .=
"&search_socid=".urlencode($socid);
416 $param .=
"&search_showbirthday=1";
419 $param .=
"&search_projectid=".urlencode($pid);
422 $param .=
"&search_type=".urlencode($type);
424 $param .=
"&maxprint=".urlencode($maxprint);
425 if ($mode ==
'show_day' || $mode ==
'show_week' || $mode ==
'show_month') {
426 $param .=
'&mode='.urlencode($mode);
430 if (empty($mode) || $mode ==
'show_month') {
431 $nav =
"<a href=\"?year=".$prev_year.
"&month=".$prev_month.$param.
"\"><i class=\"fa fa-chevron-left\"></i></a> \n";
432 $nav .=
" <span id=\"month_name\">".dol_print_date(
dol_mktime(0, 0, 0, $month, 1, $year),
"%b %Y");
433 $nav .=
" </span>\n";
434 $nav .=
" <a href=\"?year=".$next_year.
"&month=".$next_month.$param.
"\"><i class=\"fa fa-chevron-right\"></i></a>\n";
435 if (empty($conf->dol_optimize_smallscreen)) {
436 $nav .=
" <a href=\"?year=".$nowyear.
"&month=".$nowmonth.$param.
"\">".$langs->trans(
"Today").
"</a> ";
440 if ($mode ==
'show_week') {
441 $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";
442 $nav .=
" <span id=\"month_name\">".dol_print_date(
dol_mktime(0, 0, 0, $first_month, $first_day, $first_year),
"%Y").
", ".$langs->trans(
"Week").
" ".$week;
443 $nav .=
" </span>\n";
444 $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";
445 if (empty($conf->dol_optimize_smallscreen)) {
446 $nav .=
" <a href=\"?year=".$nowyear.
"&month=".$nowmonth.
"&day=".$nowday.$param.
"\">".$langs->trans(
"Today").
"</a> ";
448 $picto =
'calendarweek';
450 if ($mode ==
'show_day') {
451 $nav =
"<a href=\"?year=".$prev_year.
"&month=".$prev_month.
"&day=".$prev_day.$param.
"\"><i class=\"fa fa-chevron-left\"></i></a> \n";
452 $nav .=
" <span id=\"month_name\">".dol_print_date(
dol_mktime(0, 0, 0, $month, $day, $year),
"daytextshort");
453 $nav .=
" </span>\n";
454 $nav .=
" <a href=\"?year=".$next_year.
"&month=".$next_month.
"&day=".$next_day.$param.
"\"><i class=\"fa fa-chevron-right\"></i></a>\n";
455 if (empty($conf->dol_optimize_smallscreen)) {
456 $nav .=
" <a href=\"?year=".$nowyear.
"&month=".$nowmonth.
"&day=".$nowday.$param.
"\">".$langs->trans(
"Today").
"</a> ";
458 $picto =
'calendarday';
461 $nav .=
$form->selectDate($dateselect,
'dateselect', 0, 0, 1,
'', 1, 0);
463 $nav .=
'<button type="submit" class="liste_titre button_search valignmiddle" name="button_search_x" value="x"><span class="fa fa-search"></span></button>';
466 $paramnodate = $param;
467 $param .=
'&year='.$year.
'&month='.$month.($day ?
'&day='.$day :
'');
482 $paramnoaction = preg_replace(
'/mode=[a-z_]+/',
'', preg_replace(
'/action=[a-z_]+/',
'', $param));
483 $paramnoactionodate = preg_replace(
'/mode=[a-z_]+/',
'', preg_replace(
'/action=[a-z_]+/',
'', $paramnodate));
487 print
'<form method="POST" id="searchFormList" class="listactionsfilter" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
488 if ($optioncss !=
'') {
489 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
491 print
'<input type="hidden" name="token" value="'.newToken().
'">';
492 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
499 $viewmode .=
'<a class="btnTitle reposition" href="'.DOL_URL_ROOT.
'/comm/action/list.php?mode=show_list&restore_lastsearch_values=1'.$paramnoactionodate.
'">';
501 $viewmode .=
img_picto($langs->trans(
"List"),
'object_calendarlist',
'class="imgforviewmode pictoactionview block"');
503 $viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans(
"ViewList").
'</span></a>';
505 $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.
'">';
507 $viewmode .=
img_picto($langs->trans(
"ViewCal"),
'object_calendarmonth',
'class="pictoactionview block"');
509 $viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans(
"ViewCal").
'</span></a>';
511 $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.
'">';
513 $viewmode .=
img_picto($langs->trans(
"ViewWeek"),
'object_calendarweek',
'class="pictoactionview block"');
515 $viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans(
"ViewWeek").
'</span></a>';
517 $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.
'">';
519 $viewmode .=
img_picto($langs->trans(
"ViewDay"),
'object_calendarday',
'class="pictoactionview block"');
521 $viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans(
"ViewDay").
'</span></a>';
523 $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.
'">';
525 $viewmode .=
img_picto($langs->trans(
"ViewPerUser"),
'object_calendarperuser',
'class="pictoactionview block"');
527 $viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans(
"ViewPerUser").
'</span></a>';
530 $parameters = array(); $object =
null;
531 $reshook = $hookmanager->executeHooks(
'addCalendarView', $parameters, $object, $action);
532 if (empty($reshook)) {
533 $viewmode .= $hookmanager->resPrint;
534 } elseif ($reshook > 1) {
535 $viewmode = $hookmanager->resPrint;
538 $viewmode .=
'<span class="marginrightonly"></span>';
543 if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) {
546 $newparam .=
'&month='.((int) $month).
'&year='.((int) $tmpforcreatebutton[
'year']).
'&mode='.urlencode($mode);
551 $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 :
'')));
557 $showextcals = $listofextcals;
559 if (!empty($conf->use_javascript_ajax)) {
560 $s .=
"\n".
'<!-- Div to calendars selectors -->'.
"\n";
561 $s .=
'<script type="text/javascript">'.
"\n";
562 $s .=
'jQuery(document).ready(function () {'.
"\n";
563 $s .=
'jQuery(".check_birthday").click(function() { console.log("Toggle birthdays"); jQuery(".family_birthday").toggle(); });'.
"\n";
564 $s .=
'jQuery(".check_holiday").click(function() { console.log("Toggle holidays"); jQuery(".family_holiday").toggle(); });'.
"\n";
565 if ($mode ==
"show_week" || $mode ==
"show_month" || empty($mode)) {
567 $s .=
'jQuery( "div.sortable" ).sortable({connectWith: ".sortable", placeholder: "ui-state-highlight", items: "div.movable", receive: function( event, ui ) {'.
"\n";
569 $s .=
'console.log("submit form to record new event");'.
"\n";
571 $s .=
'var newval = jQuery(event.target).closest("div.dayevent").attr("id");'.
"\n";
572 $s .=
'console.log("found parent div.dayevent with id = "+newval);'.
"\n";
573 $s .=
'var frm=jQuery("#searchFormList");'.
"\n";
574 $s .=
'var newurl = ui.item.find("a.cal_event").attr("href");'.
"\n";
575 $s .=
'console.log("Found url on href of a.cal_event"+newurl+", we submit form with actionmove=mupdate");'.
"\n";
576 $s .=
'frm.attr("action", newurl).children("#newdate").val(newval);frm.submit();}'.
"\n";
580 $s .=
'</script>'.
"\n";
583 $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 if ($user->rights->holiday->read) {
588 <div class="nowrap inline-block minheight30"><input type="checkbox" id="check_holiday" name="check_holiday" value="1" class="check_holiday"' . ($check_holiday
589 ?
' checked' :
'') .
'>
590 <label for="check_holiday">
591 <span class="check_holiday_text">' . $langs->trans(
"Holidays") .
'</span>
597 if (is_array($showextcals) && count($showextcals) > 0) {
598 $s .=
'<script type="text/javascript">'.
"\n";
599 $s .=
'jQuery(document).ready(function () {
600 jQuery("div input[name^=\"check_ext\"]").each(function(index, elem) {
601 var name = jQuery(elem).attr("name");
602 if (jQuery(elem).is(":checked")) {
603 jQuery(".family_ext" + name.replace("check_ext", "")).show();
605 jQuery(".family_ext" + name.replace("check_ext", "")).hide();
609 jQuery("div input[name^=\"check_ext\"]").click(function() {
610 var name = $(this).attr("name");
611 jQuery(".family_ext" + name.replace("check_ext", "")).toggle();
614 $s .=
'</script>'.
"\n";
616 foreach ($showextcals as $val) {
617 $htmlname = md5($val[
'name']);
619 if (!empty($val[
'default']) ||
GETPOST(
'check_ext'.$htmlname,
'int')) {
620 $default =
"checked";
625 $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.
'">'.
dol_escape_htmltag($val[
'name']).
'</label> </div>';
630 $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>';
633 $parameters = array();
634 $reshook = $hookmanager->executeHooks(
'addCalendarChoice', $parameters, $object, $action);
635 if (empty($reshook)) {
636 $s .= $hookmanager->resPrint;
637 } elseif ($reshook > 1) {
638 $s = $hookmanager->resPrint;
641 $s .=
"\n".
'<!-- End div to calendars selectors -->'.
"\n";
644 $newparam = preg_replace(
'/showbirthday=[0-1]/i',
'showbirthday='.(empty($showbirthday) ? 1 : 0), $newparam);
645 if (!preg_match(
'/showbirthday=/i', $newparam)) {
646 $newparam .=
'&showbirthday=1';
650 if (empty($showbirthday)) {
651 $link .= $langs->trans(
"AgendaShowBirthdayEvents");
653 $link .= $langs->trans(
"AgendaHideBirthdayEvents");
660 $eventarray = array();
665 if ($usergroup > 0) {
668 $sql .=
' a.id, a.label,';
670 $sql .=
' a.datep2,';
671 $sql .=
' a.percent,';
672 $sql .=
' a.fk_user_author,a.fk_user_action,';
673 $sql .=
' a.transparency, a.priority, a.fulldayevent, a.location,';
674 $sql .=
' a.fk_soc, a.fk_contact, a.fk_project,';
675 $sql .=
' a.fk_element, a.elementtype,';
676 $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';
677 $sql .=
' FROM '.MAIN_DB_PREFIX.
'c_actioncomm as ca, '.MAIN_DB_PREFIX.
"actioncomm as a";
678 if (empty($user->rights->societe->client->voir) && !$socid) {
679 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
682 if ($resourceid > 0) {
683 $sql .=
", ".MAIN_DB_PREFIX.
"element_resources as r";
686 if ($filtert > 0 || $usergroup > 0) {
687 $sql .=
", ".MAIN_DB_PREFIX.
"actioncomm_resources as ar";
689 if ($usergroup > 0) {
690 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"usergroup_user as ugu ON ugu.fk_user = ar.fk_element";
692 $sql .=
' WHERE a.fk_action = ca.id';
693 $sql .=
' AND a.entity IN ('.getEntity(
'agenda').
')';
695 if (!empty($actioncode)) {
696 if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
697 if ($actioncode ==
'AC_NON_AUTO') {
698 $sql .=
" AND ca.type != 'systemauto'";
699 } elseif ($actioncode ==
'AC_ALL_AUTO') {
700 $sql .=
" AND ca.type = 'systemauto'";
702 if ($actioncode ==
'AC_OTH') {
703 $sql .=
" AND ca.type != 'systemauto'";
705 if ($actioncode ==
'AC_OTH_AUTO') {
706 $sql .=
" AND ca.type = 'systemauto'";
710 if ($actioncode ==
'AC_NON_AUTO') {
711 $sql .=
" AND ca.type != 'systemauto'";
712 } elseif ($actioncode ==
'AC_ALL_AUTO') {
713 $sql .=
" AND ca.type = 'systemauto'";
715 if (is_array($actioncode)) {
716 $sql .=
" AND ca.code IN (".$db->sanitize(
"'".implode(
"','", $actioncode).
"'", 1).
")";
718 $sql .=
" AND ca.code IN (".$db->sanitize(
"'".implode(
"','", explode(
',', $actioncode)).
"'", 1).
")";
723 if ($resourceid > 0) {
724 $sql .=
" AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".((int) $resourceid);
727 $sql .=
" AND a.fk_project=".((int) $pid);
729 if (empty($user->rights->societe->client->voir) && !$socid) {
730 $sql .=
" AND (a.fk_soc IS NULL OR sc.fk_user = ".((int) $user->id).
")";
733 $sql .=
" AND a.fk_soc = ".((int) $socid);
736 if ($filtert > 0 || $usergroup > 0) {
737 $sql .=
" AND ar.fk_actioncomm = a.id AND ar.element_type='user'";
740 if ($mode ==
'show_day') {
742 $sql .=
" (a.datep BETWEEN '".$db->idate(
dol_mktime(0, 0, 0, $month, $day, $year,
'tzuserrel')).
"'";
743 $sql .=
" AND '".$db->idate(
dol_mktime(23, 59, 59, $month, $day, $year,
'tzuserrel')).
"')";
745 $sql .=
" (a.datep2 BETWEEN '".$db->idate(
dol_mktime(0, 0, 0, $month, $day, $year,
'tzuserrel')).
"'";
746 $sql .=
" AND '".$db->idate(
dol_mktime(23, 59, 59, $month, $day, $year,
'tzuserrel')).
"')";
748 $sql .=
" (a.datep < '".$db->idate(
dol_mktime(0, 0, 0, $month, $day, $year,
'tzuserrel')).
"'";
749 $sql .=
" AND a.datep2 > '".$db->idate(
dol_mktime(23, 59, 59, $month, $day, $year,
'tzuserrel')).
"')";
754 $sql .=
" (a.datep BETWEEN '".$db->idate(
dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7)).
"'";
755 $sql .=
" AND '".$db->idate(
dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10)).
"')";
757 $sql .=
" (a.datep2 BETWEEN '".$db->idate(
dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7)).
"'";
758 $sql .=
" AND '".$db->idate(
dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10)).
"')";
760 $sql .=
" (a.datep < '".$db->idate(
dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7)).
"'";
761 $sql .=
" AND a.datep2 > '".$db->idate(
dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10)).
"')";
765 $sql .=
" AND ca.id = ".((int) $type);
767 if ($status ==
'0') {
769 $sql .=
" AND a.percent = 0";
771 if ($status ==
'na') {
773 $sql .=
" AND a.percent = -1";
775 if ($status ==
'50') {
777 $sql .=
" AND (a.percent > 0 AND a.percent < 100)";
779 if ($status ==
'done' || $status ==
'100') {
780 $sql .=
" AND (a.percent = 100)";
782 if ($status ==
'todo') {
783 $sql .=
" AND (a.percent >= 0 AND a.percent < 100)";
786 if ($filtert > 0 || $usergroup > 0) {
789 $sql .=
"ar.fk_element = ".((int) $filtert);
791 if ($usergroup > 0) {
792 $sql .= ($filtert > 0 ?
" OR " :
"").
" ugu.fk_usergroup = ".((
int) $usergroup);
797 $sql .=
' ORDER BY datep';
801 dol_syslog(
"comm/action/index.php", LOG_DEBUG);
802 $resql = $db->query($sql);
804 $num = $db->num_rows(
$resql);
806 $MAXONSAMEPAGE = 10000;
808 while ($i < $num && $i < $MAXONSAMEPAGE) {
809 $obj = $db->fetch_object(
$resql);
812 if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->type_code ==
'AC_OTH_AUTO') {
820 $event->id = $obj->id;
821 $event->ref = $event->id;
823 $event->fulldayevent = $obj->fulldayevent;
826 if ($event->fulldayevent) {
828 $event->datep = $db->jdate($obj->datep, $tzforfullday ?
'tzuser' :
'tzserver');
829 $event->datef = $db->jdate($obj->datep2, $tzforfullday ?
'tzuser' :
'tzserver');
832 $event->datep = $db->jdate($obj->datep,
'tzserver');
833 $event->datef = $db->jdate($obj->datep2,
'tzserver');
839 $event->type_code = $obj->type_code;
840 $event->type_label = $obj->type_label;
841 $event->type_color = $obj->type_color;
842 $event->type = $obj->type_type;
843 $event->type_picto = $obj->type_picto;
845 $event->libelle = $obj->label;
846 $event->label = $obj->label;
847 $event->percentage = $obj->percent;
849 $event->authorid = $obj->fk_user_author;
850 $event->userownerid = $obj->fk_user_action;
851 $event->fetch_userassigned();
853 $event->priority = $obj->priority;
854 $event->location = $obj->location;
855 $event->transparency = $obj->transparency;
856 $event->fk_element = $obj->fk_element;
857 $event->elementtype = $obj->elementtype;
859 $event->fk_project = $obj->fk_project;
861 $event->socid = $obj->fk_soc;
862 $event->contact_id = $obj->fk_contact;
866 $event->date_start_in_calendar = $event->datep;
867 if ($event->datef !=
'' && $event->datef >= $event->datep) {
868 $event->date_end_in_calendar = $event->datef;
870 $event->date_end_in_calendar = $event->datep;
874 if ($event->date_end_in_calendar < $firstdaytoshow || $event->date_start_in_calendar >= $lastdaytoshow) {
877 if ($event->date_start_in_calendar < $firstdaytoshow) {
878 $event->date_start_in_calendar = $firstdaytoshow;
880 if ($event->date_end_in_calendar >= $lastdaytoshow) {
881 $event->date_end_in_calendar = ($lastdaytoshow - 1);
885 $daycursor = $event->date_start_in_calendar;
890 $daycursorend = $event->date_end_in_calendar;
900 $loop =
true; $j = 0;
901 $daykey =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
902 $daykeyend =
dol_mktime(0, 0, 0, $moisend, $jourend, $anneeend,
'gmt');
916 $eventarray[$daykey][] = $event;
919 $daykey += 60 * 60 * 24;
921 if ($daykey > $daykeyend) {
940 $sql =
'SELECT sp.rowid, sp.lastname, sp.firstname, sp.birthday';
941 $sql .=
' FROM '.MAIN_DB_PREFIX.
'socpeople as sp';
942 $sql .=
' WHERE (priv=0 OR (priv=1 AND fk_user_creat='.((int) $user->id).
'))';
943 $sql .=
" AND sp.entity IN (".getEntity(
'contact').
")";
944 if ($mode ==
'show_day') {
945 $sql .=
' AND MONTH(birthday) = '.((int) $month);
946 $sql .=
' AND DAY(birthday) = '.((int) $day);
948 $sql .=
' AND MONTH(birthday) = '.((int) $month);
950 $sql .=
' ORDER BY birthday';
952 dol_syslog(
"comm/action/index.php", LOG_DEBUG);
953 $resql = $db->query($sql);
955 $num = $db->num_rows(
$resql);
958 $obj = $db->fetch_object(
$resql);
962 $event->id = $obj->rowid;
963 $event->ref = $event->id;
968 $event->datep =
dol_mktime(0, 0, 0, $datearray[
'mon'], $datearray[
'mday'], $year,
true);
969 $event->datef = $event->datep;
971 $event->type_code =
'BIRTHDAY';
972 $event->type_label =
'';
973 $event->type_color =
'';
974 $event->type =
'birthdate';
975 $event->type_picto =
'birthdate';
977 $event->label = $langs->trans(
"Birthday").
' '.
dolGetFirstLastname($obj->firstname, $obj->lastname);
978 $event->percentage = 100;
979 $event->fulldayevent = 1;
981 $event->date_start_in_calendar = $db->jdate($event->datep);
982 $event->date_end_in_calendar = $db->jdate($event->datef);
985 $daycursor = $event->datep;
990 $daykey =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
992 $eventarray[$daykey][] = $event;
1009 if ($user->rights->holiday->read) {
1011 $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";
1012 $sql .=
" FROM ".MAIN_DB_PREFIX.
"holiday as x, ".MAIN_DB_PREFIX.
"user as u";
1013 $sql .=
" WHERE u.rowid = x.fk_user";
1014 $sql .=
" AND u.statut = '1'";
1015 $sql .=
" AND (x.statut = '2' OR x.statut = '3')";
1017 if ($mode ==
'show_day') {
1019 $sql .=
" AND '".$db->escape($year).
"-".$db->escape($month).
"-".$db->escape($day).
"' BETWEEN x.date_debut AND x.date_fin";
1020 } elseif ($mode ==
'show_week') {
1022 } elseif ($mode ==
'show_month') {
1026 $resql = $db->query($sql);
1028 $num = $db->num_rows(
$resql);
1032 $obj = $db->fetch_object(
$resql);
1037 $event->id = $obj->rowid;
1038 $event->ref = $event->id;
1040 $event->type_code =
'HOLIDAY';
1041 $event->type_label =
'';
1042 $event->type_color =
'';
1043 $event->type =
'holiday';
1044 $event->type_picto =
'holiday';
1046 $event->datep = $db->jdate($obj->date_start) + (empty($halfday) || $halfday == 1 ? 0 : 12 * 60 * 60 - 1);
1047 $event->datef = $db->jdate($obj->date_end) + (empty($halfday) || $halfday == -1 ? 24 : 12) * 60 * 60 - 1;
1048 $event->date_start_in_calendar = $event->datep;
1049 $event->date_end_in_calendar = $event->datef;
1051 if ($obj->status == 3) {
1053 $event->percentage = -1;
1054 } elseif ($obj->status == 2) {
1056 $event->percentage = 0;
1059 if ($obj->halfday == 1) {
1060 $event->label = $obj->lastname.
' ('.$langs->trans(
"Morning").
')';
1061 } elseif ($obj->halfday == -1) {
1062 $event->label = $obj->lastname.
' ('.$langs->trans(
"Afternoon").
')';
1064 $event->label = $obj->lastname;
1067 $daycursor = $event->date_start_in_calendar;
1072 $daykey =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
1074 $eventarray[$daykey][] = $event;
1076 $daykey += 60 * 60 * 24;
1077 }
while ($daykey <= $event->date_end_in_calendar);
1086 if (count($listofextcals)) {
1087 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/ical.class.php';
1088 foreach ($listofextcals as $extcal) {
1089 $url = $extcal[
'src'];
1090 $namecal = $extcal[
'name'];
1091 $offsettz = $extcal[
'offsettz'];
1092 $colorcal = $extcal[
'color'];
1093 $buggedfile = $extcal[
'buggedfile'];
1100 $icalevents = array();
1101 if (is_array($ical->get_event_list())) {
1102 $icalevents = array_merge($icalevents, $ical->get_event_list());
1104 if (is_array($ical->get_freebusy_list())) {
1105 $icalevents = array_merge($icalevents, $ical->get_freebusy_list());
1108 if (count($icalevents) > 0) {
1110 $moreicalevents = array();
1111 foreach ($icalevents as $icalevent) {
1112 if (isset($icalevent[
'RRULE']) && is_array($icalevent[
'RRULE'])) {
1115 if ($icalevent[
'DTSTART;VALUE=DATE']) {
1118 } elseif (is_array($icalevent[
'DTSTART']) && !empty($icalevent[
'DTSTART'][
'unixtime'])) {
1119 $datecurstart = $icalevent[
'DTSTART'][
'unixtime'];
1120 $datecurend = $icalevent[
'DTEND'][
'unixtime'];
1121 if (!empty($ical->cal[
'DAYLIGHT'][
'DTSTART']) && $datecurstart) {
1123 $tmpcurstart = $datecurstart;
1124 $tmpcurend = $datecurend;
1125 $tmpdaylightstart =
dol_mktime(0, 0, 0, 1, 1, 1970, 1) + (int) $ical->cal[
'DAYLIGHT'][
'DTSTART'];
1126 $tmpdaylightend =
dol_mktime(0, 0, 0, 1, 1, 1970, 1) + (int) $ical->cal[
'STANDARD'][
'DTSTART'];
1129 if ($tmpcurstart >= $tmpdaylightstart && $tmpcurstart < $tmpdaylightend) {
1130 $datecurstart -= ((int) $ical->cal[
'DAYLIGHT'][
'TZOFFSETTO']) * 36;
1132 $datecurstart -= ((int) $ical->cal[
'STANDARD'][
'TZOFFSETTO']) * 36;
1134 if ($tmpcurend >= $tmpdaylightstart && $tmpcurstart < $tmpdaylightend) {
1135 $datecurend -= ((int) $ical->cal[
'DAYLIGHT'][
'TZOFFSETTO']) * 36;
1137 $datecurend -= ((int) $ical->cal[
'STANDARD'][
'TZOFFSETTO']) * 36;
1144 dol_syslog(
"Found a not recognized repeatable record with unknown date start", LOG_ERR);
1149 $interval = (empty($icalevent[
'RRULE'][
'INTERVAL']) ? 1 : $icalevent[
'RRULE'][
'INTERVAL']);
1150 $until = empty($icalevent[
'RRULE'][
'UNTIL']) ? 0 :
dol_stringtotime($icalevent[
'RRULE'][
'UNTIL'], 1);
1151 $maxrepeat = empty($icalevent[
'RRULE'][
'COUNT']) ? 0 : $icalevent[
'RRULE'][
'COUNT'];
1152 if ($until && ($until + ($datecurend - $datecurstart)) < $firstdaytoshow) {
1155 if ($datecurstart >= $lastdaytoshow) {
1160 while (($datecurstart < $lastdaytoshow) && (empty($maxrepeat) || ($numofevent < $maxrepeat))) {
1161 if ($datecurend >= $firstdaytoshow) {
1162 $newevent = $icalevent;
1163 unset($newevent[
'RRULE']);
1164 if ($icalevent[
'DTSTART;VALUE=DATE']) {
1165 $newevent[
'DTSTART;VALUE=DATE'] =
dol_print_date($datecurstart,
'%Y%m%d');
1166 $newevent[
'DTEND;VALUE=DATE'] =
dol_print_date($datecurend + 1,
'%Y%m%d');
1168 $newevent[
'DTSTART'] = $datecurstart;
1169 $newevent[
'DTEND'] = $datecurend;
1171 $moreicalevents[] = $newevent;
1175 $savdatecurstart = $datecurstart;
1176 if ($icalevent[
'RRULE'][
'FREQ'] ==
'DAILY') {
1180 if ($icalevent[
'RRULE'][
'FREQ'] ==
'WEEKLY') {
1183 } elseif ($icalevent[
'RRULE'][
'FREQ'] ==
'MONTHLY') {
1186 } elseif ($icalevent[
'RRULE'][
'FREQ'] ==
'YEARLY') {
1191 if ($savdatecurstart >= $datecurstart) {
1192 dol_syslog(
"Found a rule freq ".$icalevent[
'RRULE'][
'FREQ'].
" not managed by dolibarr code. Assume 1 week frequency.", LOG_ERR);
1193 $datecurstart += 3600 * 24 * 7;
1194 $datecurend += 3600 * 24 * 7;
1199 $icalevents = array_merge($icalevents, $moreicalevents);
1202 foreach ($icalevents as $icalevent) {
1207 if (!empty($icalevent[
'RRULE'])) {
1214 if (isset($icalevent[
'DTSTART;VALUE=DATE'])) {
1217 if (empty($icalevent[
'DTEND;VALUE=DATE'])) {
1218 $dateend = $datestart + 86400 - 1;
1224 $event->fulldayevent = 1;
1226 } elseif (!is_array($icalevent[
'DTSTART'])) {
1227 $datestart = $icalevent[
'DTSTART'];
1228 $dateend = empty($icalevent[
'DTEND']) ? $datestart : $icalevent[
'DTEND'];
1230 $datestart += +($offsettz * 3600);
1231 $dateend += +($offsettz * 3600);
1236 } elseif (isset($icalevent[
'DTSTART'][
'unixtime'])) {
1237 $datestart = $icalevent[
'DTSTART'][
'unixtime'];
1238 $dateend = $icalevent[
'DTEND'][
'unixtime'];
1240 $datestart += +($offsettz * 3600);
1241 $dateend += +($offsettz * 3600);
1244 if ($buggedfile ===
'uselocalandtznodaylight') {
1248 if ($buggedfile ===
'uselocalandtzdaylight') {
1249 $localtzs =
new DateTimeZone(preg_replace(
'/"/',
'', $icalevent[
'DTSTART'][
'TZID']));
1250 $localtze =
new DateTimeZone(preg_replace(
'/"/',
'', $icalevent[
'DTEND'][
'TZID']));
1251 $localdts =
new DateTime(
dol_print_date($datestart,
'dayrfc',
'gmt'), $localtzs);
1252 $localdte =
new DateTime(
dol_print_date($dateend,
'dayrfc',
'gmt'), $localtze);
1253 $tmps = -1 * $localtzs->getOffset($localdts);
1254 $tmpe = -1 * $localtze->getOffset($localdte);
1255 $datestart += $tmps;
1263 $event->id = $icalevent[
'UID'];
1264 $event->ref = $event->id;
1265 $userId = $userstatic->findUserIdByEmail($namecal);
1266 if (!empty($userId) && $userId > 0) {
1267 $event->userassigned[$userId] = $userId;
1268 $event->percentage = -1;
1271 $event->type_code =
"ICALEVENT";
1272 $event->type_label = $namecal;
1273 $event->type_color = $colorcal;
1274 $event->type =
'icalevent';
1275 $event->type_picto =
'rss';
1277 $event->icalname = $namecal;
1278 $event->icalcolor = $colorcal;
1280 $event->datep = $datestart + $usertime;
1281 $event->datef = $dateend + $usertime;
1283 if ($icalevent[
'SUMMARY']) {
1285 } elseif ($icalevent[
'DESCRIPTION']) {
1288 $event->label = $langs->trans(
"ExtSiteNoLabel");
1295 if (!empty($icalevent[
'PRIORITY'])) {
1296 $event->priority = $icalevent[
'PRIORITY'];
1300 if (!empty($icalevent[
'TRANSP'])) {
1301 if ($icalevent[
'TRANSP'] ==
"TRANSPARENT") {
1302 $event->transparency = 0;
1304 if ($icalevent[
'TRANSP'] ==
"OPAQUE") {
1305 $event->transparency = 1;
1316 if (!empty($icalevent[
'LOCATION'])) {
1317 $event->location = $icalevent[
'LOCATION'];
1320 $event->date_start_in_calendar = $event->datep;
1322 if ($event->datef !=
'' && $event->datef >= $event->datep) {
1323 $event->date_end_in_calendar = $event->datef;
1325 $event->date_end_in_calendar = $event->datep;
1329 if ($event->date_end_in_calendar < $firstdaytoshow || $event->date_start_in_calendar >= $lastdaytoshow) {
1335 if ($event->date_start_in_calendar < $firstdaytoshow) {
1336 $event->date_start_in_calendar = $firstdaytoshow;
1338 if ($event->date_end_in_calendar >= $lastdaytoshow) {
1339 $event->date_end_in_calendar = ($lastdaytoshow - 1);
1343 $daycursor = $event->date_start_in_calendar;
1349 $loop =
true; $j = 0;
1351 $daykey =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
1352 $daykeygmt =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
1355 $eventarray[$daykey][] = $event;
1356 $daykey += 60 * 60 * 24; $daykeygmt += 60 * 60 * 24;
1357 if (($event->fulldayevent ? $daykeygmt : $daykey) > $event->date_end_in_calendar) {
1371 $parameters = array(); $object =
null;
1372 $reshook = $hookmanager->executeHooks(
'getCalendarEvents', $parameters, $object, $action);
1373 if (!empty($hookmanager->resArray[
'eventarray'])) {
1374 foreach ($hookmanager->resArray[
'eventarray'] as $keyDate => $events) {
1375 if (!isset($eventarray[$keyDate])) {
1376 $eventarray[$keyDate] = array();
1378 $eventarray[$keyDate] = array_merge($eventarray[$keyDate], $events);
1383 foreach ($eventarray as $keyDate => &$dateeventarray) {
1384 usort($dateeventarray,
'sort_events_by_date');
1389 $cachethirdparties = array();
1390 $cachecontacts = array();
1391 $cacheusers = array();
1394 $color_file = DOL_DOCUMENT_ROOT.
"/theme/".$conf->theme.
"/theme_vars.inc.php";
1395 if (is_readable($color_file)) {
1396 include $color_file;
1398 if (!is_array($theme_datacolor)) {
1399 $theme_datacolor = array(array(120, 130, 150), array(200, 160, 180), array(190, 190, 220));
1402 $massactionbutton =
'';
1404 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);
1410 if (empty($mode) || $mode ==
'show_month') {
1412 $newparam = preg_replace(
'/showbirthday=/i',
'showbirthday_=', $newparam);
1413 $newparam = preg_replace(
'/mode=show_month&?/i',
'', $newparam);
1414 $newparam = preg_replace(
'/mode=show_week&?/i',
'', $newparam);
1415 $newparam = preg_replace(
'/day=[0-9]+&?/i',
'', $newparam);
1416 $newparam = preg_replace(
'/month=[0-9]+&?/i',
'', $newparam);
1417 $newparam = preg_replace(
'/year=[0-9]+&?/i',
'', $newparam);
1418 $newparam = preg_replace(
'/viewcal=[0-9]+&?/i',
'', $newparam);
1419 $newparam = preg_replace(
'/showbirthday_=/i',
'showbirthday=', $newparam);
1420 $newparam .=
'&viewcal=1';
1422 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1423 print_actions_filter(
$form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup,
'', $resourceid);
1426 print
'<div class="div-table-responsive-no-min sectioncalendarbymonth maxscreenheightless300">';
1427 print
'<table class="centpercent noborder nocellnopadd cal_pannel cal_month">';
1428 print
' <tr class="liste_titre">';
1430 echo
' <td class="center">#</td>';
1433 print
' <td class="center bold uppercase tdfordaytitle'.($i == 0 ?
' borderleft' :
'').
'">';
1434 $numdayinweek = (($i + (isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1)) % 7);
1435 if (!empty($conf->dol_optimize_smallscreen)) {
1436 $labelshort = array(0=>
'SundayMin', 1=>
'MondayMin', 2=>
'TuesdayMin', 3=>
'WednesdayMin', 4=>
'ThursdayMin', 5=>
'FridayMin', 6=>
'SaturdayMin');
1437 print $langs->trans($labelshort[$numdayinweek]);
1439 print $langs->trans(
"Day".$numdayinweek);
1441 print
' </td>'.
"\n";
1447 $todaytms =
dol_mktime(0, 0, 0, $todayarray[
'mon'], $todayarray[
'mday'], $todayarray[
'year']);
1451 for ($iter_week = 0; $iter_week < 6; $iter_week++) {
1455 $currdate0 = sprintf(
"%04d", $prev_year).sprintf(
"%02d", $prev_month).sprintf(
"%02d", $max_day_in_prev_month + $tmpday);
1456 } elseif ($tmpday <= $max_day_in_month) {
1457 $currdate0 = sprintf(
"%04d", $year).sprintf(
"%02d", $month).sprintf(
"%02d", $tmpday);
1460 $currdate0 = sprintf(
"%04d", $next_year).sprintf(
"%02d", $next_month).sprintf(
"%02d", $tmpday - $max_day_in_month);
1463 $numweek0 = date(
"W", strtotime(date($currdate0)));
1465 echo
' <td class="center weeknumber opacitymedium" width="2%">'.$numweek0.
'</td>';
1467 for ($iter_day = 0; $iter_day < 7; $iter_day++) {
1470 $style =
'cal_other_month cal_past';
1471 if ($iter_day == 6) {
1472 $style .=
' cal_other_month_right';
1474 echo
' <td class="'.$style.
' nowrap tdtop" width="14%">';
1475 show_day_events($db, $max_day_in_prev_month + $tmpday, $prev_month, $prev_year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam);
1477 } elseif ($tmpday <= $max_day_in_month) {
1479 $curtime =
dol_mktime(0, 0, 0, $month, $tmpday, $year);
1480 $style =
'cal_current_month';
1481 if ($iter_day == 6) {
1482 $style .=
' cal_current_month_right';
1485 if ($todayarray[
'mday'] == $tmpday && $todayarray[
'mon'] == $month && $todayarray[
'year'] == $year) {
1489 $style =
'cal_today';
1491 if ($curtime < $todaytms) {
1492 $style .=
' cal_past';
1495 echo
' <td class="'.$style.
' nowrap tdtop" width="14%">';
1496 show_day_events($db, $tmpday, $month, $year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam);
1500 $style =
'cal_other_month';
1501 if ($iter_day == 6) {
1502 $style .=
' cal_other_month_right';
1504 echo
' <td class="'.$style.
' nowrap tdtop" width="14%">';
1505 show_day_events($db, $tmpday - $max_day_in_month, $next_month, $next_year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam);
1515 print
'<input type="hidden" name="actionmove" value="mupdate">';
1516 print
'<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($_SERVER[
'PHP_SELF']).
'?mode=show_month&'.
dol_escape_htmltag($_SERVER[
'QUERY_STRING']).
'">';
1517 print
'<input type="hidden" name="newdate" id="newdate">';
1518 } elseif ($mode ==
'show_week') {
1521 $newparam = preg_replace(
'/showbirthday=/i',
'showbirthday_=', $newparam);
1522 $newparam = preg_replace(
'/mode=show_month&?/i',
'', $newparam);
1523 $newparam = preg_replace(
'/mode=show_week&?/i',
'', $newparam);
1524 $newparam = preg_replace(
'/day=[0-9]+&?/i',
'', $newparam);
1525 $newparam = preg_replace(
'/month=[0-9]+&?/i',
'', $newparam);
1526 $newparam = preg_replace(
'/year=[0-9]+&?/i',
'', $newparam);
1527 $newparam = preg_replace(
'/viewweek=[0-9]+&?/i',
'', $newparam);
1528 $newparam = preg_replace(
'/showbirthday_=/i',
'showbirthday=', $newparam);
1529 $newparam .=
'&viewweek=1';
1531 print
'<div class="liste_titre liste_titre_bydiv centpercent"><div class="divsearchfield">';
1532 print_actions_filter(
$form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup,
'', $resourceid);
1533 print
'</div></div>';
1535 print
'<div class="div-table-responsive-no-min sectioncalendarbyweek maxscreenheightless300">';
1536 print
'<table class="centpercent noborder nocellnopadd cal_pannel cal_month">';
1537 print
' <tr class="liste_titre">';
1540 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";
1547 for ($iter_day = 0; $iter_day < 7; $iter_day++) {
1554 $style =
'cal_current_month';
1555 if ($iter_day == 6) {
1556 $style .=
' cal_other_month_right';
1561 if ($todayarray[
'mday'] == $tmpday && $todayarray[
'mon'] == $tmpmonth && $todayarray[
'year'] == $tmpyear) {
1565 $style =
'cal_today';
1568 echo
' <td class="'.$style.
'" width="14%" valign="top">';
1569 show_day_events($db, $tmpday, $tmpmonth, $tmpyear, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300);
1577 echo
'<input type="hidden" name="actionmove" value="mupdate">';
1578 echo
'<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($_SERVER[
'PHP_SELF']).
'?mode=show_week&'.
dol_escape_htmltag($_SERVER[
'QUERY_STRING']).
'">';
1579 echo
'<input type="hidden" name="newdate" id="newdate">';
1582 $newparam = preg_replace(
'/mode=show_month&?/i',
'', $newparam);
1583 $newparam = preg_replace(
'/mode=show_week&?/i',
'', $newparam);
1584 $newparam = preg_replace(
'/viewday=[0-9]+&?/i',
'', $newparam);
1585 $newparam .=
'&viewday=1';
1587 $style =
'cal_current_month cal_current_month_oneday';
1590 if ($todayarray[
'mday'] == $day && $todayarray[
'mon'] == $month && $todayarray[
'year'] == $year) {
1595 $timestamp =
dol_mktime(12, 0, 0, $month, $day, $year);
1598 print
'<div class="liste_titre liste_titre_bydiv centpercent"><div class="divsearchfield">';
1599 print_actions_filter(
$form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup,
'', $resourceid);
1600 print
'</div></div>';
1602 print
'<div class="div-table-responsive-no-min sectioncalendarbyday maxscreenheightless300">';
1603 echo
'<table class="tagtable centpercent noborder nocellnopadd cal_pannel cal_month noborderbottom" style="margin-bottom: 5px !important;">';
1605 echo
' <tr class="tagtr liste_titre">';
1606 echo
' <td class="tagtd center bold uppercase">'.$langs->trans(
"Day".$arraytimestamp[
'wday']).
"</td>\n";
1624 print
'<div class="div-table-responsive-no-min borderbottom">';
1626 $maxheightwin = (isset($_SESSION[
"dol_screenheight"]) && $_SESSION[
"dol_screenheight"] > 500) ? ($_SESSION[
"dol_screenheight"] - 200) : 660;
1628 echo
'<div style="max-height: '.$maxheightwin.
'px;">';
1629 echo
'<div class="tagtable centpercent calendarviewcontainer">';
1633 $tmp = explode(
'-', $conf->global->MAIN_DEFAULT_WORKING_HOURS);
1634 $minhour = round($tmp[0], 0);
1635 $maxhour = round($tmp[1], 0);
1636 if ($minhour > 23) {
1642 if ($maxhour <= $minhour) {
1643 $maxhour = $minhour + 1;
1649 echo
' <div class="tagtr calendarviewcontainertr">'.
"\n";
1650 echo
' <div class="tagtd width100 tdtop">'.dol_print_date($i * 3600,
'hour',
'gmt').
'</div>';
1651 echo
' <div class="tagtd '.$style.
' tdtop"></div>'.
"\n";
1652 echo
' </div>'.
"\n";
1657 echo
'</div></div>';
1659 show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 1);
1663 print
'<div class="div-table-responsive-no-min">';
1665 show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 0);
1671 print
"\n".
'</form>';
1696 function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventarray, $maxprint = 0, $maxnbofchar = 16, $newparam =
'', $showinfo = 0, $minheight = 60, $nonew = 0)
1698 global $user, $conf, $langs;
1699 global $action, $mode, $filter, $filtert, $status, $actioncode, $usergroup;
1700 global $theme_datacolor;
1701 global $cachethirdparties, $cachecontacts, $cacheusers, $colorindexused;
1703 if ($conf->use_javascript_ajax) {
1704 $conf->global->MAIN_JS_SWITCH_AGENDA = 1;
1707 $dateint = sprintf(
"%04d", $year).sprintf(
"%02d", $month).sprintf(
"%02d", $day);
1713 $curtime =
dol_mktime(0, 0, 0, $month, $day, $year);
1714 $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;
1716 if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) {
1717 $newparam .=
'&month='.str_pad($month, 2,
"0", STR_PAD_LEFT).
'&year='.$year;
1718 $hourminsec =
'100000';
1719 $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 :
''));
1723 print
'<div id="dayevent_'.$dateint.
'" class="dayevent tagtable centpercent nobordernopadding">'.
"\n";
1726 print
'<div class="tagtr cursorpointer" onclick="window.location=\''.$urltocreate.
'\';
"><div class="nowrap tagtd
"><div class="left
inline-block
">';
1727 print '<a class="dayevent-aday
" style="color: #666
" href="'.$urltoshow.'">';
1729 print dol_print_date($curtime, 'daytextshort');
1731 print dol_print_date($curtime, '%d');
1734 print '</div><div class="nowrap floatright
inline-block marginrightonly
">';
1735 if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) {
1736 print '<a class="cursoradd
" href="'.$urltocreate.'">'; // Explicit link, usefull for nojs interfaces
1737 print img_picto($langs->trans("NewAction
"), 'edit_add.png');
1740 print '</div></div></div>'."\n
";
1748 // Line with td contains all div of each events
1749 print '<div class="tagtr
">';
1750 print '<div class="tagtd centpercent agendacell sortable
">';
1752 //$curtime = dol_mktime (0, 0, 0, $month, $day, $year);
1753 $i = 0; $ireallyshown = 0; $itoshow = 0; $numother = 0; $numbirthday = 0; $numical = 0; $numicals = array();
1754 $ymd = sprintf("%04d
", $year).sprintf("%02d
", $month).sprintf("%02d
", $day);
1756 $colorindexused[$user->id] = 0; // Color index for current user (user->id) is always 0
1757 $nextindextouse = is_array($colorindexused) ?count($colorindexused) : 0; // At first run this is 0, so fist user has 0, next 1, ...
1758 //var_dump($colorindexused);
1760 include_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php';
1761 $tmpholiday = new Holiday($db);
1763 foreach ($eventarray as $daykey => $notused) { // daykey is the 'YYYYMMDD' to show according to user
1764 $annee = dol_print_date($daykey, '%Y', 'gmt'); // We use gmt because we want the value represented by string 'YYYYMMDD'
1765 $mois = dol_print_date($daykey, '%m', 'gmt'); // We use gmt because we want the value represented by string 'YYYYMMDD'
1766 $jour = dol_print_date($daykey, '%d', 'gmt'); // We use gmt because we want the value represented by string 'YYYYMMDD'
1768 //print 'event daykey='.$daykey.' dol_print_date(daykey)='.dol_print_date($daykey, 'dayhour', 'gmt').' jour='.$jour.' mois='.$mois.' annee='.$annee."<br>\n
";
1770 if ($day == $jour && $month == $mois && $year == $annee) {
1771 foreach ($eventarray[$daykey] as $index => $event) {
1772 if ($i < $maxprint || $maxprint == 0 || !empty($conf->global->MAIN_JS_SWITCH_AGENDA)) {
1773 $keysofuserassigned = array_keys($event->userassigned);
1774 $ponct = ($event->date_start_in_calendar == $event->date_end_in_calendar);
1776 // Define $color (Hex string like '0088FF') and $cssclass of event
1777 $color = -1; $cssclass = ''; $colorindex = -1;
1778 if (in_array($user->id, $keysofuserassigned)) {
1779 $cssclass = 'family_mytasks';
1781 if (empty($cacheusers[$event->userownerid])) {
1782 $newuser = new User($db);
1783 $newuser->fetch($event->userownerid);
1784 $cacheusers[$event->userownerid] = $newuser;
1786 //var_dump($cacheusers[$event->userownerid]->color);
1788 // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event)
1789 if (!empty($cacheusers[$event->userownerid]->color)) {
1790 $color = $cacheusers[$event->userownerid]->color;
1792 } elseif ($event->type_code == 'ICALEVENT') { // Event come from external ical file
1794 if (!empty($event->icalname)) {
1795 if (!isset($numicals[dol_string_nospecial($event->icalname)])) {
1796 $numicals[dol_string_nospecial($event->icalname)] = 0;
1798 $numicals[dol_string_nospecial($event->icalname)]++;
1801 $color = ($event->icalcolor ? $event->icalcolor : -1);
1802 $cssclass = (!empty($event->icalname) ? 'family_ext'.md5($event->icalname) : 'family_other');
1803 } elseif ($event->type_code == 'BIRTHDAY') {
1804 $numbirthday++; $colorindex = 2; $cssclass = 'family_birthday '; $color = sprintf("%02x%02x%02x
", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
1807 $color = ($event->icalcolor ? $event->icalcolor : -1);
1808 $cssclass = (!empty($event->icalname) ? 'family_ext'.md5($event->icalname) : 'family_other');
1810 if (empty($cacheusers[$event->userownerid])) {
1811 $newuser = new User($db);
1812 $newuser->fetch($event->userownerid);
1813 $cacheusers[$event->userownerid] = $newuser;
1815 //var_dump($cacheusers[$event->userownerid]->color);
1817 // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event)
1818 if (!empty($cacheusers[$event->userownerid]->color)) {
1819 $color = $cacheusers[$event->userownerid]->color;
1823 if ($color < 0) { // Color was not set on user card. Set color according to color index.
1824 // Define color index if not yet defined
1825 $idusertouse = ($event->userownerid ? $event->userownerid : 0);
1826 if (isset($colorindexused[$idusertouse])) {
1827 $colorindex = $colorindexused[$idusertouse]; // Color already assigned to this user
1829 $colorindex = $nextindextouse;
1830 $colorindexused[$idusertouse] = $colorindex;
1831 if (!empty($theme_datacolor[$nextindextouse + 1])) {
1832 $nextindextouse++; // Prepare to use next color
1835 //print '|'.($color).'='.($idusertouse?$idusertouse:0).'='.$colorindex.'<br>';
1837 $color = sprintf("%02x%02x%02x
", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
1839 $cssclass = $cssclass.' eventday_'.$ymd;
1841 // Defined style to disable drag and drop feature
1842 if ($event->type_code == 'AC_OTH_AUTO') {
1843 $cssclass .= " unmovable
";
1844 } elseif ($event->type_code == 'HOLIDAY') {
1845 $cssclass .= " unmovable
";
1846 } elseif ($event->type_code == 'BIRTHDAY') {
1847 $cssclass .= " unmovable
";
1848 } elseif ($event->type_code == 'ICALEVENT') {
1849 $cssclass .= " unmovable
";
1850 } 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)) {
1851 // If the event is on several days
1852 $tmpyearend = dol_print_date($event->date_start_in_calendar, '%Y', 'tzuserrel');
1853 $tmpmonthend = dol_print_date($event->date_start_in_calendar, '%m', 'tzuserrel');
1854 $tmpdayend = dol_print_date($event->date_start_in_calendar, '%d', 'tzuserrel');
1855 //var_dump($tmpyearend.' '.$tmpmonthend.' '.$tmpdayend);
1856 if ($tmpyearend != $annee || $tmpmonthend != $mois || $tmpdayend != $jour) {
1857 $cssclass .= " unmovable unmovable-mustusefirstdaytodrag
";
1859 $cssclass .= ' movable cursormove';
1862 if ($user->rights->agenda->allactions->create ||
1863 (($event->authorid == $user->id || $event->userownerid == $user->id) && $user->rights->agenda->myactions->create)) {
1864 $cssclass .= " movable cursormove
";
1866 $cssclass .= " unmovable
";
1870 $h = ''; $nowrapontd = 1;
1871 if ($mode == 'show_day') {
1872 $h = 'height: 100%; '; $nowrapontd = 0;
1874 if ($mode == 'show_week') {
1875 $h = 'height: 100%; '; $nowrapontd = 0;
1880 print '<!-- start event '.$i.' -->'."\n
";
1883 if ($maxprint && $ireallyshown >= $maxprint) {
1884 $morecss = 'showifmore';
1886 if ($event->type == 'birthdate' && !GETPOST('check_birthday')) {
1887 $morecss = 'hidden';
1889 if ($event->type == 'holiday' && !GETPOST('check_holiday')) {
1890 $morecss = 'hidden';
1892 if ($morecss != 'hidden') {
1895 if ($morecss != 'showifmore' && $morecss != 'hidden') {
1898 //var_dump($event->type.' - '.$morecss.' - '.$cssclass.' - '.$i.' - '.$ireallyshown.' - '.$itoshow);
1900 print '<div id="event_
'.$ymd.'_
'.$i.'" class="event family_
'.$event->type.' '.$cssclass.($morecss ? ' '.$morecss : '').'"';
1901 //print ' style="height: 100px;
';
1902 //print ' position: absolute; top: 40px; width: 50%;
';
1906 //var_dump($event->userassigned);
1907 //var_dump($event->transparency);
1908 print '<table class="centpercent cal_event
';
1909 print (empty($event->transparency) ? ' cal_event_notbusy
' : ' cal_event_busy
');
1910 //if (empty($event->transparency) && empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) print ' opacitymedium
'; // Not busy
1911 print '" style="'.$h;
1912 $colortouse = $color;
1913 // If colortouse is similar than background, we force to change it.
1914 if (empty($event->transparency) && empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) {
1915 print 'background: #f0f0f0;
';
1916 print 'border-left: 5px solid #
'.$colortouse.';
';
1918 print 'background: #f0f0f0;
';
1919 print 'border-left: 5px solid #
'.dol_color_minus($colortouse, -3).';
';
1920 //print 'background: -webkit-gradient(linear, left top, left bottom, from(#
'.dol_color_minus($colortouse, -3).'), to(#
'.dol_color_minus($colortouse, -1).'));
';
1922 //print 'background: #
'.$colortouse.';
';
1923 //print 'background: -webkit-gradient(linear, left top, left bottom, from(#
'.dol_color_minus($color, -3).'), to(#
'.dol_color_minus($color, -1).'));
';
1924 //if (!empty($event->transparency)) print 'background: #
'.$color.'; background: -webkit-gradient(linear, left top, left bottom, from(#
'.$color.'), to(#
'.dol_color_minus($color,1).'));
';
1925 //else print 'background-color: transparent !important; background: none; border: 1px solid #bbb;
';
1926 //print ' -moz-border-radius:4px;
"';
1927 //print 'border: 1px solid #ccc" width=
"100%"';
1930 print '<td class="tdoverflow nobottom centpercent
'.($nowrapontd ? 'nowrap
' : '').'cal_event
'.($event->type_code == 'BIRTHDAY
' ? ' cal_event_birthday
' : '').'">';
1934 if ($event->type_code == 'BIRTHDAY') { // It's birthday calendar
1935 print $event->getNomUrl(1, $maxnbofchar, 'cal_event', 'birthday', 'contact');
1936 } elseif ($event->type_code == 'HOLIDAY') { // It's holiday calendar
1937 $tmpholiday->fetch($event->id);
1939 print $tmpholiday->getNomUrl(1);
1941 $tmpid = $tmpholiday->fk_user;
1942 if (empty($cacheusers[$tmpid])) {
1943 $newuser = new User($db);
1944 $newuser->fetch($tmpid);
1945 $cacheusers[$tmpid] = $newuser;
1948 $listofusertoshow = '';
1949 $listofusertoshow .= '<br>'.$cacheusers[$tmpid]->getNomUrl(-1, '', 0, 0, 0, 0, '', 'paddingright valigntextbottom');
1950 print $listofusertoshow;
1951 } else { // Other calendar
1953 if (empty($event->fulldayevent)) {
1954 //print $event->getNomUrl(2).' ';
1958 if (empty($event->fulldayevent)) {
1959 // Show hours (start ... end)
1960 $tmpyearstart = dol_print_date($event->date_start_in_calendar, '%Y', 'tzuserrel');
1961 $tmpmonthstart = dol_print_date($event->date_start_in_calendar, '%m', 'tzuserrel');
1962 $tmpdaystart = dol_print_date($event->date_start_in_calendar, '%d', 'tzuserrel');
1963 $tmpyearend = dol_print_date($event->date_end_in_calendar, '%Y', 'tzuserrel');
1964 $tmpmonthend = dol_print_date($event->date_end_in_calendar, '%m', 'tzuserrel');
1965 $tmpdayend = dol_print_date($event->date_end_in_calendar, '%d', 'tzuserrel');
1968 if ($tmpyearstart == $annee && $tmpmonthstart == $mois && $tmpdaystart == $jour) {
1969 $daterange .= dol_print_date($event->date_start_in_calendar, 'hour', 'tzuserrel');
1970 if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) {
1971 if ($tmpyearstart == $tmpyearend && $tmpmonthstart == $tmpmonthend && $tmpdaystart == $tmpdayend) {
1978 if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) {
1979 if ($tmpyearstart != $tmpyearend || $tmpmonthstart != $tmpmonthend || $tmpdaystart != $tmpdayend) {
1980 $daterange .= '...';
1984 if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) {
1985 if ($tmpyearend == $annee && $tmpmonthend == $mois && $tmpdayend == $jour) {
1986 $daterange .= dol_print_date($event->date_end_in_calendar, 'hour', 'tzuserrel');
1991 print $langs->trans("EventOnFullDay
")."<br>\n
";
1996 $titletoshow = $daterange;
1997 $titletoshow .= ($titletoshow ? ' ' : '').dol_escape_htmltag($event->label ? $event->label : $event->libelle);
1999 if ($event->type_code != 'ICALEVENT') {
2000 $savlabel = $event->label ? $event->label : $event->libelle;
2001 $event->label = $titletoshow;
2002 $event->libelle = $titletoshow; // deprecatd
2003 // Note: List of users are inside $event->userassigned. Link may be clickable depending on permissions of user.
2004 $titletoshow = (($event->type_picto || $event->type_code) ? $event->getTypePicto() : '');
2005 $titletoshow .= $event->getNomUrl(0, $maxnbofchar, 'cal_event cal_event_title', '', 0, 0);
2006 $event->label = $savlabel;
2007 $event->libelle = $savlabel;
2010 // Loop on each assigned user
2011 $listofusertoshow = '';
2012 $posuserassigned = 0;
2013 foreach ($event->userassigned as $tmpid => $tmpdata) {
2014 if (!$posuserassigned && $titletoshow) {
2015 $listofusertoshow .= '<br>';
2018 if (empty($cacheusers[$tmpid])) {
2019 $newuser = new User($db);
2020 $newuser->fetch($tmpid);
2021 $cacheusers[$tmpid] = $newuser;
2024 $listofusertoshow .= $cacheusers[$tmpid]->getNomUrl(-3, '', 0, 0, 0, 0, '', 'paddingright valigntextbottom');
2028 print $listofusertoshow;
2030 if ($event->type_code == 'ICALEVENT') {
2031 print '<br>('.dol_trunc($event->icalname, $maxnbofchar).')';
2034 $thirdparty_id = ($event->socid > 0 ? $event->socid : ((is_object($event->societe) && $event->societe->id > 0) ? $event->societe->id : 0));
2035 $contact_id = ($event->contact_id > 0 ? $event->contact_id : ((is_object($event->contact) && $event->contact->id > 0) ? $event->contact->id : 0));
2037 // If action related to company / contact
2038 $linerelatedto = '';
2039 if ($thirdparty_id > 0) {
2040 if (!isset($cachethirdparties[$thirdparty_id]) || !is_object($cachethirdparties[$thirdparty_id])) {
2041 $thirdparty = new Societe($db);
2042 $thirdparty->fetch($thirdparty_id);
2043 $cachethirdparties[$thirdparty_id] = $thirdparty;
2045 $thirdparty = $cachethirdparties[$thirdparty_id];
2047 if (!empty($thirdparty->id)) {
2048 $linerelatedto .= $thirdparty->getNomUrl(1, '', 0);
2051 if (!empty($contact_id) && $contact_id > 0) {
2052 if (!is_object($cachecontacts[$contact_id])) {
2053 $contact = new Contact($db);
2054 $contact->fetch($contact_id);
2055 $cachecontacts[$contact_id] = $contact;
2057 $contact = $cachecontacts[$contact_id];
2059 if ($linerelatedto) {
2060 $linerelatedto .= ' ';
2062 if (!empty($contact->id)) {
2063 $linerelatedto .= $contact->getNomUrl(1, '', 0);
2066 if (!empty($event->fk_element) && $event->fk_element > 0 && !empty($event->elementtype) && !empty($conf->global->AGENDA_SHOW_LINKED_OBJECT)) {
2067 include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
2068 if ($linerelatedto) {
2069 $linerelatedto .= '<br>';
2071 $linerelatedto .= dolGetElementUrl($event->fk_element, $event->elementtype, 1);
2073 if ($linerelatedto) {
2074 print '<br>'.$linerelatedto;
2080 if ($event->location) {
2082 print $langs->trans("Location
").': '.$event->location;
2089 if ($event->type_code != 'BIRTHDAY' && $event->type_code != 'ICALEVENT') {
2091 if ($event->percentage >= 0) {
2095 print '<td class="nobottom right nowrap cal_event_right
'.($withstatus >= 2 ? ' cal_event_right_status
' : '').'">';
2097 print $event->getLibStatut(3, 1);
2101 print '</td></tr></table>';
2102 print '</div><!-- end event '.$i.' -->'."\n
";
2106 print '<a href="'.DOL_URL_ROOT.'/comm/action/index.php?mode=
'.$mode.'&maxprint=0&month=
'.((int) $monthshown).'&year=
'.((int) $year);
2107 print ($status ? '&status=
'.$status : '').($filter ? '&filter=
'.urlencode($filter) : '');
2108 print ($filtert ? '&search_filtert=
'.urlencode($filtert) : '');
2109 print ($usergroup ? '&search_usergroup=
'.urlencode($usergroup) : '');
2110 print ($actioncode != '' ? '&search_actioncode=
'.urlencode($actioncode) : '');
2111 print '">'.img_picto("all
", "1downarrow_selected.png
").' ...';
2112 print ' +'.(count($eventarray[$daykey]) - $maxprint);
2115 //$ok=false; // To avoid to show twice the link
2122 if (!$i) { // No events
2126 if (!empty($conf->global->MAIN_JS_SWITCH_AGENDA) && $itoshow > $ireallyshown && $maxprint) {
2127 print '<div class="center cursorpointer
" id="more_
'.$ymd.'">'.img_picto("All
", "angle-
double-down
", 'class="warning
"').' +'.($itoshow - $ireallyshown).'</div>';
2128 //print ' +'.(count($eventarray[$daykey])-$maxprint);
2130 print '<script type="text/javascript
">'."\n
";
2131 print 'jQuery(document).ready(function () {'."\n
";
2132 print ' var open=0;'."\n
";
2133 print ' jQuery("#more_
'.$ymd.'").click(function() { console.log("Click on showmore
for '.$ymd.'"); reinit_day_'.$ymd.'(); event.stopImmediatePropagation(); });'."\n
";
2134 print ' function reinit_day_'.$ymd.'() {'."\n
";
2135 print ' jQuery(".eventday_
'.$ymd.'.showifmore
").toggle();'."\n
";
2136 print ' open = open + 1; if (open > 1) { open = 0; }'."\n
";
2137 print ' if (open) { ';
2138 print ' jQuery("#more_
'.$ymd.'").html(\''.img_picto("All
", "angle-
double-up
", 'class="warning
"').'\');'."\n
";
2140 print ' jQuery("#more_
'.$ymd.'").html(\''.img_picto("All
", "angle-
double-down
", 'class="warning
"').' +'.($itoshow - $ireallyshown).'\');'."\n
";
2144 print '</script>'."\n
";
2147 print '</div></div>'; // td tr
2149 print '</div>'; // table
2162 function dol_color_minus($color, $minus, $minusunit = 16)
2165 if ($minusunit == 16) {
2166 $newcolor[0] = dechex(max(min(hexdec($newcolor[0]) - $minus, 15), 0));
2167 $newcolor[2] = dechex(max(min(hexdec($newcolor[2]) - $minus, 15), 0));
2168 $newcolor[4] = dechex(max(min(hexdec($newcolor[4]) - $minus, 15), 0));
2170 // Not yet implemented
2182 function sort_events_by_date($a, $b)
2184 // Sort holidays at first
2185 if ($a->type_code === 'HOLIDAY') {
2188 if ($b->type_code === 'HOLIDAY') {
2192 // datep => Event start time
2193 // datef => Event end time
2195 // Events have different start time
2196 if ($a->datep !== $b->datep) {
2197 return $a->datep - $b->datep;
2200 // Events have same start time and no end time
2201 if ((!is_numeric($b->datef)) || (!is_numeric($a->datef))) {
2202 return sort_events_by_percentage($a, $b);
2205 // Events have the same start time and same end time
2206 if ($b->datef === $a->datef) {
2207 return sort_events_by_percentage($a, $b);
2210 // Events have the same start time, but have different end time -> longest event first
2211 return $b->datef - $a->datef;
2221 function sort_events_by_percentage($a, $b)
2223 // Sort events with no percentage before each other
2224 // (usefull to sort holidays, sick days or similar on the top)
2226 if ($a->percentage < 0) {
2230 if ($b->percentage < 0) {
2234 return $b->percentage - $a->percentage;