34require
'../../main.inc.php';
35require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/lib/agenda.lib.php';
40if (isModEnabled(
'project')) {
41 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
44if (!isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) {
45 $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW = 3;
49 $conf->global->AGENDA_EXT_NB = 5;
51$MAXAGENDA = $conf->global->AGENDA_EXT_NB;
54$disabledefaultvalues =
GETPOST(
'disabledefaultvalues',
'int');
56$check_holiday =
GETPOST(
'check_holiday',
'int');
57$filter =
GETPOST(
"search_filter",
'alpha', 3) ?
GETPOST(
"search_filter",
'alpha', 3) :
GETPOST(
"filter",
'alpha', 3);
58$filtert =
GETPOST(
"search_filtert",
"int", 3) ?
GETPOST(
"search_filtert",
"int", 3) :
GETPOST(
"filtert",
"int", 3);
59$usergroup =
GETPOST(
"search_usergroup",
"int", 3) ?
GETPOST(
"search_usergroup",
"int", 3) :
GETPOST(
"usergroup",
"int", 3);
60$showbirthday = empty($conf->use_javascript_ajax) ?
GETPOST(
"showbirthday",
"int") : 1;
69$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
70$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
71$page = GETPOSTISSET(
'pageplusone') ? (
GETPOST(
'pageplusone') - 1) :
GETPOST(
"page",
'int');
72if (empty($page) || $page == -1) {
75$limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
76$offset = $limit * $page;
81 $sortfield =
"a.datec";
87 $socid = $user->socid;
94if (!$user->hasRight(
'agenda',
'myactions',
'read')) {
97if (!$user->hasRight(
'agenda',
'allactions',
'read')) {
100if (!$user->hasRight(
'agenda',
'allactions',
'read') || $filter ==
'mine') {
101 $filtert = $user->id;
104$action =
GETPOST(
'action',
'aZ09');
106$mode =
GETPOST(
'mode',
'aZ09');
107if (empty($mode) && preg_match(
'/show_/', $action)) {
110$resourceid =
GETPOST(
"search_resourceid",
"int");
111$year =
GETPOST(
"year",
"int") ?
GETPOST(
"year",
"int") : date(
"Y");
112$month =
GETPOST(
"month",
"int") ?
GETPOST(
"month",
"int") : date(
"m");
113$week =
GETPOST(
"week",
"int") ?
GETPOST(
"week",
"int") : date(
"W");
115$pid =
GETPOST(
"search_projectid",
"int", 3) ?
GETPOST(
"search_projectid",
"int", 3) :
GETPOST(
"projectid",
"int", 3);
116$status = GETPOSTISSET(
"search_status") ?
GETPOST(
"search_status",
'aZ09') :
GETPOST(
"status",
'aZ09');
117$type = GETPOSTISSET(
"search_type") ?
GETPOST(
"search_type",
'aZ09') :
GETPOST(
"type",
'aZ09');
118$maxprint = GETPOSTISSET(
"maxprint") ?
GETPOST(
"maxprint",
'int') : $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW;
119$optioncss =
GETPOST(
'optioncss',
'aZ');
122if ($dateselect > 0) {
123 $day =
GETPOST(
'dateselectday',
'int');
124 $month =
GETPOST(
'dateselectmonth',
'int');
125 $year =
GETPOST(
'dateselectyear',
'int');
129if (
GETPOST(
'search_actioncode',
'array:aZ09')) {
130 $actioncode =
GETPOST(
'search_actioncode',
'array:aZ09', 3);
131 if (!count($actioncode)) {
135 $actioncode =
GETPOST(
"search_actioncode",
"alpha", 3) ?
GETPOST(
"search_actioncode",
"alpha", 3) : (
GETPOST(
"search_actioncode") ==
'0' ?
'0' : ((!
getDolGlobalString(
'AGENDA_DEFAULT_FILTER_TYPE') || $disabledefaultvalues) ?
'' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE));
138if ($status ==
'' && !GETPOSTISSET(
'search_status')) {
139 $status = ((!
getDolGlobalString(
'AGENDA_DEFAULT_FILTER_STATUS') || $disabledefaultvalues) ?
'' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS);
142$defaultview = (!
getDolGlobalString(
'AGENDA_DEFAULT_VIEW') ?
'show_month' : $conf->global->AGENDA_DEFAULT_VIEW);
143$defaultview = (empty($user->conf->AGENDA_DEFAULT_VIEW) ? $defaultview : $user->conf->AGENDA_DEFAULT_VIEW);
144if (empty($mode) && !GETPOSTISSET(
'mode')) {
145 $mode = $defaultview;
147if ($mode ==
'default') {
148 $mode = (($defaultview !=
'show_list') ? $defaultview :
'show_month');
150if (
GETPOST(
'viewcal',
'int') &&
GETPOST(
'mode',
'alpha') !=
'show_day' &&
GETPOST(
'mode',
'alpha') !=
'show_week') {
151 $mode =
'show_month';
154if (
GETPOST(
'viewweek',
'int') ||
GETPOST(
'mode',
'alpha') ==
'show_week') {
156 $week = ($week ? $week : date(
"W"));
157 $day = ($day ? $day : date(
"d"));
159if (
GETPOST(
'viewday',
'int') ||
GETPOST(
'mode',
'alpha') ==
'show_day') {
161 $day = ($day ? $day : date(
"d"));
167$langs->loadLangs(array(
'agenda',
'other',
'commercial'));
170$hookmanager->initHooks(array(
'agenda'));
172$result =
restrictedArea($user,
'agenda', 0,
'actioncomm&societe',
'myactions|allactions',
'fk_soc',
'id');
173if ($user->socid && $socid) {
182if (
GETPOST(
"viewlist",
'alpha') || $mode ==
'show_list') {
184 if (is_array($_POST)) {
185 foreach ($_POST as $key => $val) {
186 if ($key ==
'token') {
189 $param .=
'&'.$key.
'='.urlencode($val);
192 if (!preg_match(
'/action=/', $param)) {
193 $param .= ($param ?
'&' :
'').
'mode=show_list';
196 header(
"Location: ".DOL_URL_ROOT.
'/comm/action/list.php?'.$param);
200if (
GETPOST(
"viewperuser",
'alpha') || $mode ==
'show_peruser') {
202 if (is_array($_POST)) {
203 foreach ($_POST as $key => $val) {
204 if ($key ==
'token') {
207 $param .=
'&'.$key.
'='.urlencode($val);
211 header(
"Location: ".DOL_URL_ROOT.
'/comm/action/peruser.php?'.$param);
227 'maxprint' => $maxprint,
229 'filtert' => $filtert,
230 'showbirthday' => $showbirthday,
231 'canedit' => $canedit,
232 'optioncss' => $optioncss,
233 'actioncode' => $actioncode,
235 'resourceid' => $resourceid,
236 'usergroup' => $usergroup,
238$reshook = $hookmanager->executeHooks(
'beforeAgenda', $parameters, $object, $action);
243$help_url =
'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda|DE:Modul_Terminplanung';
244llxHeader(
'', $langs->trans(
"Agenda"), $help_url);
246$form =
new Form($db);
247$companystatic =
new Societe($db);
248$contactstatic =
new Contact($db);
249$userstatic =
new User($db);
253$nowyear = $nowarray[
'year'];
254$nowmonth = $nowarray[
'mon'];
255$nowday = $nowarray[
'mday'];
257$listofextcals = array();
262 while ($i < $MAXAGENDA) {
264 $source =
'AGENDA_EXT_SRC'.$i;
265 $name =
'AGENDA_EXT_NAME'.$i;
266 $offsettz =
'AGENDA_EXT_OFFSETTZ'.$i;
267 $color =
'AGENDA_EXT_COLOR'.$i;
268 $default =
'AGENDA_EXT_ACTIVEBYDEFAULT'.$i;
269 $buggedfile =
'AGENDA_EXT_BUGGEDFILE'.$i;
272 $listofextcals[] = array(
284if (empty($user->conf->AGENDA_DISABLE_EXT)) {
286 while ($i < $MAXAGENDA) {
288 $source =
'AGENDA_EXT_SRC_'.$user->id.
'_'.$i;
289 $name =
'AGENDA_EXT_NAME_'.$user->id.
'_'.$i;
290 $offsettz =
'AGENDA_EXT_OFFSETTZ_'.$user->id.
'_'.$i;
291 $color =
'AGENDA_EXT_COLOR_'.$user->id.
'_'.$i;
292 $enabled =
'AGENDA_EXT_ENABLED_'.$user->id.
'_'.$i;
293 $default =
'AGENDA_EXT_ACTIVEBYDEFAULT_'.$user->id.
'_'.$i;
294 $buggedfile =
'AGENDA_EXT_BUGGEDFILE_'.$user->id.
'_'.$i;
298 $listofextcals[] = array(
301 'offsettz' => (
int) (empty($user->conf->$offsettz) ? 0 : $user->
conf->$offsettz),
310if (empty($mode) || $mode ==
'show_month') {
312 $prev_year = $prev[
'year'];
313 $prev_month = $prev[
'month'];
315 $next_year = $next[
'year'];
316 $next_month = $next[
'month'];
318 $max_day_in_prev_month = date(
"t",
dol_mktime(12, 0, 0, $prev_month, 1, $prev_year,
'gmt'));
319 $max_day_in_month = date(
"t",
dol_mktime(12, 0, 0, $month, 1, $year,
'gmt'));
321 $tmpday = -date(
"w",
dol_mktime(12, 0, 0, $month, 1, $year,
'gmt')) + 2;
322 $tmpday += ((isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1) - 1);
327 $firstdaytoshow =
dol_mktime(0, 0, 0, $prev_month, $max_day_in_prev_month + $tmpday, $prev_year,
'tzuserrel');
328 $next_day = 7 - ($max_day_in_month + 1 - $tmpday) % 7;
332 $lastdaytoshow =
dol_mktime(0, 0, 0, $next_month, $next_day, $next_year,
'tzuserrel');
334if ($mode ==
'show_week') {
336 $prev_year = $prev[
'prev_year'];
337 $prev_month = $prev[
'prev_month'];
338 $prev_day = $prev[
'prev_day'];
339 $first_day = $prev[
'first_day'];
340 $first_month = $prev[
'first_month'];
341 $first_year = $prev[
'first_year'];
343 $week = $prev[
'week'];
347 $next_year = $next[
'year'];
348 $next_month = $next[
'month'];
349 $next_day = $next[
'day'];
352 $firstdaytoshow =
dol_mktime(0, 0, 0, $first_month, $first_day, $first_year,
'tzuserrel');
355 $max_day_in_month = date(
"t",
dol_mktime(0, 0, 0, $month, 1, $year,
'gmt'));
357 $tmpday = $first_day;
359if ($mode ==
'show_day') {
361 $prev_year = $prev[
'year'];
362 $prev_month = $prev[
'month'];
363 $prev_day = $prev[
'day'];
365 $next_year = $next[
'year'];
366 $next_month = $next[
'month'];
367 $next_day = $next[
'day'];
369 $firstdaytoshow =
dol_mktime(0, 0, 0, $prev_month, $prev_day, $prev_year,
'tzuserrel');
370 $lastdaytoshow =
dol_mktime(0, 0, 0, $next_month, $next_day, $next_year,
'tzuserrel');
382if ($actioncode || GETPOSTISSET(
'search_actioncode')) {
383 if (is_array($actioncode)) {
384 foreach ($actioncode as $str_action) {
385 $param .=
"&search_actioncode[]=".urlencode($str_action);
388 $param .=
"&search_actioncode=".urlencode($actioncode);
391if ($resourceid > 0) {
392 $param .=
"&search_resourceid=".urlencode($resourceid);
394if ($status || GETPOSTISSET(
'status') || GETPOSTISSET(
'search_status')) {
395 $param .=
"&search_status=".urlencode($status);
398 $param .=
"&search_filter=".urlencode($filter);
401 $param .=
"&search_filtert=".urlencode($filtert);
404 $param .=
"&search_usergroup=".urlencode($usergroup);
407 $param .=
"&search_socid=".urlencode($socid);
410 $param .=
"&search_showbirthday=1";
413 $param .=
"&search_projectid=".urlencode($pid);
416 $param .=
"&search_type=".urlencode($type);
418$param .=
"&maxprint=".urlencode($maxprint);
419if ($mode ==
'show_day' || $mode ==
'show_week' || $mode ==
'show_month') {
420 $param .=
'&mode='.urlencode($mode);
425$nav .=
'<div class="navselectiondate inline-block nowraponall">';
426if (empty($mode) || $mode ==
'show_month') {
427 $nav .=
"<a href=\"?year=".$prev_year.
"&month=".$prev_month.$param.
"\"><i class=\"fa fa-chevron-left\"></i></a> \n";
428 $nav .=
" <span id=\"month_name\">".dol_print_date(
dol_mktime(0, 0, 0, $month, 1, $year),
"%b %Y");
429 $nav .=
" </span>\n";
430 $nav .=
" <a href=\"?year=".$next_year.
"&month=".$next_month.$param.
"\"><i class=\"fa fa-chevron-right\"></i></a>\n";
433if ($mode ==
'show_week') {
434 $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";
435 $nav .=
" <span id=\"month_name\">".dol_print_date(
dol_mktime(0, 0, 0, $first_month, $first_day, $first_year),
"%Y").
", ".$langs->trans(
"WeekShort").
" ".$week;
436 $nav .=
" </span>\n";
437 $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";
438 $picto =
'calendarweek';
440if ($mode ==
'show_day') {
441 $nav .=
"<a href=\"?year=".$prev_year.
"&month=".$prev_month.
"&day=".$prev_day.$param.
"\"><i class=\"fa fa-chevron-left\"></i></a> \n";
442 $nav .=
" <span id=\"month_name\">".dol_print_date(
dol_mktime(0, 0, 0, $month, $day, $year),
"daytextshort");
443 $nav .=
" </span>\n";
444 $nav .=
" <a href=\"?year=".$next_year.
"&month=".$next_month.
"&day=".$next_day.$param.
"\"><i class=\"fa fa-chevron-right\"></i></a>\n";
445 $picto =
'calendarday';
447if (empty($conf->dol_optimize_smallscreen)) {
448 $nav .=
' <a href="?year='.$nowyear.
'&month='.$nowmonth.
'&day='.$nowday.$param.
'" class="datenowlink">'.$langs->trans(
"Today").
'</a> ';
452$nav .= $form->selectDate($dateselect,
'dateselect', 0, 0, 1,
'', 1, 0);
454$nav .=
'<button type="submit" class="liste_titre button_search valignmiddle" name="button_search_x" value="x"><span class="fa fa-search"></span></button>';
457$paramnodate = $param;
458$param .=
'&year='.$year.
'&month='.$month.($day ?
'&day='.$day :
'');
473$paramnoaction = preg_replace(
'/mode=[a-z_]+/',
'', preg_replace(
'/action=[a-z_]+/',
'', $param));
474$paramnoactionodate = preg_replace(
'/mode=[a-z_]+/',
'', preg_replace(
'/action=[a-z_]+/',
'', $paramnodate));
478print
'<form method="POST" id="searchFormList" class="listactionsfilter" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
479if ($optioncss !=
'') {
480 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
482print
'<input type="hidden" name="token" value="'.newToken().
'">';
483print
'<input type="hidden" name="mode" value="'.$mode.
'">';
489$viewmode =
'<div class="navmode inline-block">';
491$viewmode .=
'<a class="btnTitle reposition" href="'.DOL_URL_ROOT.
'/comm/action/list.php?mode=show_list&restore_lastsearch_values=1'.$paramnoactionodate.
'">';
493$viewmode .=
img_picto($langs->trans(
"List"),
'object_calendarlist',
'class="imgforviewmode pictoactionview block"');
495$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans(
"ViewList").
'</span></a>';
497$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.
'">';
499$viewmode .=
img_picto($langs->trans(
"ViewCal"),
'object_calendarmonth',
'class="pictoactionview block"');
501$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans(
"ViewCal").
'</span></a>';
503$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.
'">';
505$viewmode .=
img_picto($langs->trans(
"ViewWeek"),
'object_calendarweek',
'class="pictoactionview block"');
507$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans(
"ViewWeek").
'</span></a>';
509$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.
'">';
511$viewmode .=
img_picto($langs->trans(
"ViewDay"),
'object_calendarday',
'class="pictoactionview block"');
513$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans(
"ViewDay").
'</span></a>';
515$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.
'">';
517$viewmode .=
img_picto($langs->trans(
"ViewPerUser"),
'object_calendarperuser',
'class="pictoactionview block"');
519$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans(
"ViewPerUser").
'</span></a>';
522$parameters = array(); $object =
null;
523$reshook = $hookmanager->executeHooks(
'addCalendarView', $parameters, $object, $action);
524if (empty($reshook)) {
525 $viewmode .= $hookmanager->resPrint;
526} elseif ($reshook > 1) {
527 $viewmode = $hookmanager->resPrint;
530$viewmode .=
'</div>';
532$viewmode .=
'<span class="marginrightonly"></span>';
537if ($user->hasRight(
'agenda',
'myactions',
'create') || $user->hasRight(
'agenda',
'allactions',
'create')) {
540 $newparam .=
'&month='.((int) $month).
'&year='.((int) $tmpforcreatebutton[
'year']).
'&mode='.urlencode($mode);
545 $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 :
'')));
551$showextcals = $listofextcals;
552$bookcalcalendars = array();
555if (isModEnabled(
"bookcal")) {
556 $sql =
"SELECT ba.rowid, bc.label, bc.ref, bc.rowid as id_cal";
557 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bookcal_availabilities as ba";
558 $sql .=
" JOIN ".MAIN_DB_PREFIX.
"bookcal_calendar as bc";
559 $sql .=
" ON bc.rowid = ba.fk_bookcal_calendar";
560 $sql .=
" WHERE bc.status = 1";
561 $sql .=
" AND ba.status = 1";
562 if (!empty($filtert) && $filtert != -1) {
563 $sql .=
" AND bc.visibility = ".(int) $filtert ;
565 $resql = $db->query($sql);
567 $num = $db->num_rows($resql);
570 $objp = $db->fetch_object($resql);
571 $label = !empty($objp->label) ? $objp->label : $objp->ref;
572 $bookcalcalendars[
"calendars"][] = array(
"id" => $objp->id_cal,
"label" => $label);
573 $bookcalcalendars[
"availabilitieslink"][$objp->rowid] = $objp->id_cal;
581if (!empty($conf->use_javascript_ajax)) {
582 $s .=
"\n".
'<!-- Div to calendars selectors -->'.
"\n";
583 $s .=
'<script type="text/javascript">'.
"\n";
584 $s .=
'jQuery(document).ready(function () {'.
"\n";
585 $s .=
'jQuery(".check_birthday").click(function() { console.log("Toggle birthdays"); jQuery(".family_birthday").toggle(); });'.
"\n";
586 $s .=
'jQuery(".check_holiday").click(function() { console.log("Toggle holidays"); jQuery(".family_holiday").toggle(); });'.
"\n";
587 if (isModEnabled(
"bookcal") && !empty($bookcalcalendars[
"calendars"])) {
588 foreach ($bookcalcalendars[
"calendars"] as $key => $value) {
589 $s .=
'jQuery(".check_bookcal_calendar_'.$value[
'id'].
'").click(function() { console.log("Toggle Bookcal Calendar '.$value[
'id'].
'"); jQuery(".family_bookcal_calendar_'.$value[
'id'].
'").toggle(); });'.
"\n";
592 if ($mode ==
"show_week" || $mode ==
"show_month" || empty($mode)) {
594 $s .=
'jQuery( "div.sortable" ).sortable({connectWith: ".sortable", placeholder: "ui-state-highlight", items: "div.movable", receive: function( event, ui ) {'.
"\n";
596 $s .=
'console.log("submit form to record new event");'.
"\n";
598 $s .=
'var newval = jQuery(event.target).closest("div.dayevent").attr("id");'.
"\n";
599 $s .=
'console.log("found parent div.dayevent with id = "+newval);'.
"\n";
600 $s .=
'var frm=jQuery("#searchFormList");'.
"\n";
601 $s .=
'var newurl = ui.item.find("a.cal_event").attr("href");'.
"\n";
602 $s .=
'console.log("Found url on href of a.cal_event"+newurl+", we submit form with actionmove=mupdate");'.
"\n";
603 $s .=
'frm.attr("action", newurl).children("#newdate").val(newval);frm.submit();}'.
"\n";
607 $s .=
'</script>'.
"\n";
610 $s .=
'<div class="nowrap inline-block minheight30"><input type="checkbox" id="check_mytasks" name="check_mytasks" value="1" checked disabled> '.$langs->trans(
"LocalAgenda").
' </div>';
612 if ($user->hasRight(
"holiday",
"read")) {
615 <div class="nowrap inline-block minheight30"><input type="checkbox" id="check_holiday" name="check_holiday" value="1" class="check_holiday"' . ($check_holiday
616 ?
' checked' :
'') .
'>
617 <label for="check_holiday">
618 <span class="check_holiday_text">' . $langs->trans(
"Holidays") .
'</span>
624 if (is_array($showextcals) && count($showextcals) > 0) {
625 $s .=
'<script type="text/javascript">'.
"\n";
626 $s .=
'jQuery(document).ready(function () {
627 jQuery("div input[name^=\"check_ext\"]").each(function(index, elem) {
628 var name = jQuery(elem).attr("name");
629 if (jQuery(elem).is(":checked")) {
630 jQuery(".family_ext" + name.replace("check_ext", "")).show();
632 jQuery(".family_ext" + name.replace("check_ext", "")).hide();
636 jQuery("div input[name^=\"check_ext\"]").click(function() {
637 var name = $(this).attr("name");
638 jQuery(".family_ext" + name.replace("check_ext", "")).toggle();
641 $s .=
'</script>'.
"\n";
643 foreach ($showextcals as $val) {
644 $htmlname = md5($val[
'name']);
646 if (!empty($val[
'default']) ||
GETPOST(
'check_ext'.$htmlname,
'int')) {
647 $default =
"checked";
652 $s .=
'<div class="nowrap inline-block minheight30"><input type="checkbox" id="check_ext'.$htmlname.
'" name="check_ext'.$htmlname.
'" value="1" '.$default.
'> <label for="check_ext'.$htmlname.
'" title="'.
dol_escape_htmltag($langs->trans(
"Cache").
' '.round($DELAYFORCACHE / 60).
'mn').
'">'.
dol_escape_htmltag($val[
'name']).
'</label> </div>';
657 $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>';
660 if (isModEnabled(
"bookcal")) {
661 if (!empty($bookcalcalendars[
"calendars"])) {
662 foreach ($bookcalcalendars[
"calendars"] as $key => $value) {
663 $label = $value[
'label'];
664 $s .=
'<div class="nowrap inline-block minheight30"><input '.(GETPOST(
'check_bookcal_calendar_'.$value[
'id']) ?
"checked" :
"").
' type="checkbox" id="check_bookcal_calendar_'.$value[
'id'].
'" name="check_bookcal_calendar_'.$value[
'id'].
'" class="check_bookcal_calendar_'.$value[
'id'].
'"><label for="check_bookcal_calendar_'.$value[
'id'].
'"> <span class="check_bookcal_calendar_'.$value[
'id'].
'_text">'.$langs->trans(
"AgendaShowBookcalCalendar", $label).
'</span></label> </div>';
670 $parameters = array();
671 $reshook = $hookmanager->executeHooks(
'addCalendarChoice', $parameters, $object, $action);
672 if (empty($reshook)) {
673 $s .= $hookmanager->resPrint;
674 } elseif ($reshook > 1) {
675 $s = $hookmanager->resPrint;
678 $s .=
"\n".
'<!-- End div to calendars selectors -->'.
"\n";
681 $newparam = preg_replace(
'/showbirthday=[0-1]/i',
'showbirthday='.(empty($showbirthday) ? 1 : 0), $newparam);
682 if (!preg_match(
'/showbirthday=/i', $newparam)) {
683 $newparam .=
'&showbirthday=1';
687 if (empty($showbirthday)) {
688 $link .= $langs->trans(
"AgendaShowBirthdayEvents");
690 $link .= $langs->trans(
"AgendaHideBirthdayEvents");
697$eventarray = array();
705$sql .=
' a.id, a.label,';
708$sql .=
' a.percent,';
709$sql .=
' a.fk_user_author,a.fk_user_action,';
710$sql .=
' a.transparency, a.priority, a.fulldayevent, a.location,';
711$sql .=
' a.fk_soc, a.fk_contact, a.fk_project, a.fk_bookcal_calendar,';
712$sql .=
' a.fk_element, a.elementtype,';
713$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';
714$sql .=
' FROM '.MAIN_DB_PREFIX.
'c_actioncomm as ca, '.MAIN_DB_PREFIX.
"actioncomm as a";
715if (!$user->hasRight(
'societe',
'client',
'voir') && !$socid) {
716 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
719if ($resourceid > 0) {
720 $sql .=
", ".MAIN_DB_PREFIX.
"element_resources as r";
723if ($filtert > 0 || $usergroup > 0) {
724 $sql .=
", ".MAIN_DB_PREFIX.
"actioncomm_resources as ar";
727 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"usergroup_user as ugu ON ugu.fk_user = ar.fk_element";
729$sql .=
' WHERE a.fk_action = ca.id';
730$sql .=
' AND a.entity IN ('.getEntity(
'agenda').
')';
732if (!empty($actioncode)) {
734 if ($actioncode ==
'AC_NON_AUTO') {
735 $sql .=
" AND ca.type != 'systemauto'";
736 } elseif ($actioncode ==
'AC_ALL_AUTO') {
737 $sql .=
" AND ca.type = 'systemauto'";
739 if ($actioncode ==
'AC_OTH') {
740 $sql .=
" AND ca.type != 'systemauto'";
742 if ($actioncode ==
'AC_OTH_AUTO') {
743 $sql .=
" AND ca.type = 'systemauto'";
747 if ($actioncode ==
'AC_NON_AUTO') {
748 $sql .=
" AND ca.type != 'systemauto'";
749 } elseif ($actioncode ==
'AC_ALL_AUTO') {
750 $sql .=
" AND ca.type = 'systemauto'";
752 if (is_array($actioncode)) {
753 $sql .=
" AND ca.code IN (".$db->sanitize(
"'".implode(
"','", $actioncode).
"'", 1).
")";
755 $sql .=
" AND ca.code IN (".$db->sanitize(
"'".implode(
"','", explode(
',', $actioncode)).
"'", 1).
")";
760if ($resourceid > 0) {
761 $sql .=
" AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".((int) $resourceid);
764 $sql .=
" AND a.fk_project=".((int) $pid);
766if (!$user->hasRight(
'societe',
'client',
'voir') && !$socid) {
767 $sql .=
" AND (a.fk_soc IS NULL OR sc.fk_user = ".((int) $user->id).
")";
770 $sql .=
" AND a.fk_soc = ".((int) $socid);
773if ($filtert > 0 || $usergroup > 0) {
774 $sql .=
" AND ar.fk_actioncomm = a.id AND ar.element_type='user'";
777if ($mode ==
'show_day') {
779 $sql .=
" (a.datep BETWEEN '".$db->idate(
dol_mktime(0, 0, 0, $month, $day, $year,
'tzuserrel')).
"'";
780 $sql .=
" AND '".$db->idate(
dol_mktime(23, 59, 59, $month, $day, $year,
'tzuserrel')).
"')";
782 $sql .=
" (a.datep2 BETWEEN '".$db->idate(
dol_mktime(0, 0, 0, $month, $day, $year,
'tzuserrel')).
"'";
783 $sql .=
" AND '".$db->idate(
dol_mktime(23, 59, 59, $month, $day, $year,
'tzuserrel')).
"')";
785 $sql .=
" (a.datep < '".$db->idate(
dol_mktime(0, 0, 0, $month, $day, $year,
'tzuserrel')).
"'";
786 $sql .=
" AND a.datep2 > '".$db->idate(
dol_mktime(23, 59, 59, $month, $day, $year,
'tzuserrel')).
"')";
791 $sql .=
" (a.datep BETWEEN '".$db->idate(
dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7)).
"'";
792 $sql .=
" AND '".$db->idate(
dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10)).
"')";
794 $sql .=
" (a.datep2 BETWEEN '".$db->idate(
dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7)).
"'";
795 $sql .=
" AND '".$db->idate(
dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10)).
"')";
797 $sql .=
" (a.datep < '".$db->idate(
dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7)).
"'";
798 $sql .=
" AND a.datep2 > '".$db->idate(
dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10)).
"')";
802 $sql .=
" AND ca.id = ".((int) $type);
806 $sql .=
" AND a.percent = 0";
808if ($status ==
'na') {
810 $sql .=
" AND a.percent = -1";
812if ($status ==
'50') {
814 $sql .=
" AND (a.percent > 0 AND a.percent < 100)";
816if ($status ==
'done' || $status ==
'100') {
817 $sql .=
" AND (a.percent = 100)";
819if ($status ==
'todo') {
820 $sql .=
" AND (a.percent >= 0 AND a.percent < 100)";
823if ($filtert > 0 || $usergroup > 0) {
826 $sql .=
"ar.fk_element = ".((int) $filtert);
828 if ($usergroup > 0) {
829 $sql .= ($filtert > 0 ?
" OR " :
"").
" ugu.fk_usergroup = ".((
int) $usergroup);
834$sql .=
' ORDER BY datep';
838dol_syslog(
"comm/action/index.php", LOG_DEBUG);
839$resql = $db->query($sql);
841 $num = $db->num_rows($resql);
843 $MAXONSAMEPAGE = 10000;
845 while ($i < $num && $i < $MAXONSAMEPAGE) {
846 $obj = $db->fetch_object($resql);
849 if (
getDolGlobalString(
'AGENDA_ALWAYS_HIDE_AUTO') && $obj->type_code ==
'AC_OTH_AUTO') {
857 $event->id = $obj->id;
858 $event->ref = $event->id;
860 $event->fulldayevent = $obj->fulldayevent;
863 if ($event->fulldayevent) {
865 $event->datep = $db->jdate($obj->datep, $tzforfullday ?
'tzuser' :
'tzserver');
866 $event->datef = $db->jdate($obj->datep2, $tzforfullday ?
'tzuser' :
'tzserver');
869 $event->datep = $db->jdate($obj->datep,
'tzserver');
870 $event->datef = $db->jdate($obj->datep2,
'tzserver');
876 $event->type_code = $obj->type_code;
877 $event->type_label = $obj->type_label;
878 $event->type_color = $obj->type_color;
879 $event->type = $obj->type_type;
880 $event->type_picto = $obj->type_picto;
882 $event->libelle = $obj->label;
883 $event->label = $obj->label;
884 $event->percentage = $obj->percent;
886 $event->authorid = $obj->fk_user_author;
887 $event->userownerid = $obj->fk_user_action;
888 $event->fetch_userassigned();
890 $event->priority = $obj->priority;
891 $event->location = $obj->location;
892 $event->transparency = $obj->transparency;
893 $event->fk_element = $obj->fk_element;
894 $event->elementtype = $obj->elementtype;
896 $event->fk_project = $obj->fk_project;
898 $event->socid = $obj->fk_soc;
899 $event->contact_id = $obj->fk_contact;
900 $event->fk_bookcal_calendar = $obj->fk_bookcal_calendar;
901 if (!empty($event->fk_bookcal_calendar)) {
902 $event->type =
"bookcal_calendar";
907 $event->date_start_in_calendar = $event->datep;
908 if ($event->datef !=
'' && $event->datef >= $event->datep) {
909 $event->date_end_in_calendar = $event->datef;
911 $event->date_end_in_calendar = $event->datep;
915 if ($event->date_end_in_calendar < $firstdaytoshow || $event->date_start_in_calendar >= $lastdaytoshow) {
918 if ($event->date_start_in_calendar < $firstdaytoshow) {
919 $event->date_start_in_calendar = $firstdaytoshow;
921 if ($event->date_end_in_calendar >= $lastdaytoshow) {
922 $event->date_end_in_calendar = ($lastdaytoshow - 1);
926 $daycursor = $event->date_start_in_calendar;
931 $daycursorend = $event->date_end_in_calendar;
943 $daykey =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
944 $daykeyend =
dol_mktime(0, 0, 0, $moisend, $jourend, $anneeend,
'gmt');
958 $eventarray[$daykey][] = $event;
961 $daykey += 60 * 60 * 24;
963 if ($daykey > $daykeyend) {
983 $sql =
'SELECT sp.rowid, sp.lastname, sp.firstname, sp.birthday';
984 $sql .=
' FROM '.MAIN_DB_PREFIX.
'socpeople as sp';
985 $sql .=
' WHERE (priv=0 OR (priv=1 AND fk_user_creat='.((int) $user->id).
'))';
986 $sql .=
" AND sp.entity IN (".getEntity(
'contact').
")";
987 if ($mode ==
'show_day') {
988 $sql .=
' AND MONTH(birthday) = '.((int) $month);
989 $sql .=
' AND DAY(birthday) = '.((int) $day);
991 $sql .=
' AND MONTH(birthday) = '.((int) $month);
993 $sql .=
' ORDER BY birthday';
995 dol_syslog(
"comm/action/index.php", LOG_DEBUG);
996 $resql = $db->query($sql);
998 $num = $db->num_rows($resql);
1001 $obj = $db->fetch_object($resql);
1005 $event->id = $obj->rowid;
1006 $event->ref = $event->id;
1011 $event->datep =
dol_mktime(0, 0, 0, $datearray[
'mon'], $datearray[
'mday'], $year,
true);
1012 $event->datef = $event->datep;
1014 $event->type_code =
'BIRTHDAY';
1015 $event->type_label =
'';
1016 $event->type_color =
'';
1017 $event->type =
'birthdate';
1018 $event->type_picto =
'birthdate';
1020 $event->label = $langs->trans(
"Birthday").
' '.
dolGetFirstLastname($obj->firstname, $obj->lastname);
1021 $event->percentage = 100;
1022 $event->fulldayevent = 1;
1024 $event->contact_id = $obj->rowid;
1026 $event->date_start_in_calendar = $db->jdate($event->datep);
1027 $event->date_end_in_calendar = $db->jdate($event->datef);
1030 $daycursor = $event->datep;
1035 $daykey =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
1037 $eventarray[$daykey][] = $event;
1054if ($user->hasRight(
"holiday",
"read")) {
1056 $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";
1057 $sql .=
" FROM ".MAIN_DB_PREFIX.
"holiday as x, ".MAIN_DB_PREFIX.
"user as u";
1058 $sql .=
" WHERE u.rowid = x.fk_user";
1059 $sql .=
" AND u.statut = '1'";
1060 $sql .=
" AND (x.statut = '2' OR x.statut = '3')";
1062 if ($mode ==
'show_day') {
1064 $sql .=
" AND '".$db->escape($year).
"-".$db->escape($month).
"-".$db->escape($day).
"' BETWEEN x.date_debut AND x.date_fin";
1065 } elseif ($mode ==
'show_week') {
1067 $sql .=
" AND date_debut < '".$db->idate(
dol_get_last_day($year, $month)).
"'";
1069 } elseif ($mode ==
'show_month') {
1071 $sql .=
" AND date_debut <= '".$db->idate(
dol_get_last_day($year, $month)).
"'";
1075 $resql = $db->query($sql);
1077 $num = $db->num_rows($resql);
1081 $obj = $db->fetch_object($resql);
1086 $event->id = $obj->rowid;
1087 $event->ref = $event->id;
1089 $event->type_code =
'HOLIDAY';
1090 $event->type_label =
'';
1091 $event->type_color =
'';
1092 $event->type =
'holiday';
1093 $event->type_picto =
'holiday';
1095 $event->datep = $db->jdate($obj->date_start) + (empty($halfday) || $halfday == 1 ? 0 : 12 * 60 * 60 - 1);
1096 $event->datef = $db->jdate($obj->date_end) + (empty($halfday) || $halfday == -1 ? 24 : 12) * 60 * 60 - 1;
1097 $event->date_start_in_calendar = $event->datep;
1098 $event->date_end_in_calendar = $event->datef;
1100 if ($obj->status == 3) {
1102 $event->percentage = -1;
1103 } elseif ($obj->status == 2) {
1105 $event->percentage = 0;
1108 if ($obj->halfday == 1) {
1109 $event->label = $obj->lastname.
' ('.$langs->trans(
"Morning").
')';
1110 } elseif ($obj->halfday == -1) {
1111 $event->label = $obj->lastname.
' ('.$langs->trans(
"Afternoon").
')';
1113 $event->label = $obj->lastname;
1116 $daycursor = $event->date_start_in_calendar;
1121 $daykey =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
1123 $eventarray[$daykey][] = $event;
1125 $daykey += 60 * 60 * 24;
1126 }
while ($daykey <= $event->date_end_in_calendar);
1135if (count($listofextcals)) {
1136 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/ical.class.php';
1137 foreach ($listofextcals as $extcal) {
1138 $url = $extcal[
'src'];
1139 $namecal = $extcal[
'name'];
1140 $offsettz = $extcal[
'offsettz'];
1141 $colorcal = $extcal[
'color'];
1142 $buggedfile = $extcal[
'buggedfile'];
1148 $ical->parse($url, $pathforcachefile, $DELAYFORCACHE);
1152 $icalevents = array();
1153 if (is_array($ical->get_event_list())) {
1154 $icalevents = array_merge($icalevents, $ical->get_event_list());
1156 if (is_array($ical->get_freebusy_list())) {
1157 $icalevents = array_merge($icalevents, $ical->get_freebusy_list());
1160 if (count($icalevents) > 0) {
1162 $moreicalevents = array();
1163 foreach ($icalevents as $icalevent) {
1164 if (isset($icalevent[
'RRULE']) && is_array($icalevent[
'RRULE'])) {
1167 if ($icalevent[
'DTSTART;VALUE=DATE']) {
1170 } elseif (is_array($icalevent[
'DTSTART']) && !empty($icalevent[
'DTSTART'][
'unixtime'])) {
1171 $datecurstart = $icalevent[
'DTSTART'][
'unixtime'];
1172 $datecurend = $icalevent[
'DTEND'][
'unixtime'];
1173 if (!empty($ical->cal[
'DAYLIGHT'][
'DTSTART']) && $datecurstart) {
1175 $tmpcurstart = $datecurstart;
1176 $tmpcurend = $datecurend;
1177 $tmpdaylightstart =
dol_mktime(0, 0, 0, 1, 1, 1970, 1) + (int) $ical->cal[
'DAYLIGHT'][
'DTSTART'];
1178 $tmpdaylightend =
dol_mktime(0, 0, 0, 1, 1, 1970, 1) + (int) $ical->cal[
'STANDARD'][
'DTSTART'];
1181 if ($tmpcurstart >= $tmpdaylightstart && $tmpcurstart < $tmpdaylightend) {
1182 $datecurstart -= ((int) $ical->cal[
'DAYLIGHT'][
'TZOFFSETTO']) * 36;
1184 $datecurstart -= ((int) $ical->cal[
'STANDARD'][
'TZOFFSETTO']) * 36;
1186 if ($tmpcurend >= $tmpdaylightstart && $tmpcurstart < $tmpdaylightend) {
1187 $datecurend -= ((int) $ical->cal[
'DAYLIGHT'][
'TZOFFSETTO']) * 36;
1189 $datecurend -= ((int) $ical->cal[
'STANDARD'][
'TZOFFSETTO']) * 36;
1196 dol_syslog(
"Found a not recognized repeatable record with unknown date start", LOG_ERR);
1201 $interval = (empty($icalevent[
'RRULE'][
'INTERVAL']) ? 1 : $icalevent[
'RRULE'][
'INTERVAL']);
1202 $until = empty($icalevent[
'RRULE'][
'UNTIL']) ? 0 :
dol_stringtotime($icalevent[
'RRULE'][
'UNTIL'], 1);
1203 $maxrepeat = empty($icalevent[
'RRULE'][
'COUNT']) ? 0 : $icalevent[
'RRULE'][
'COUNT'];
1204 if ($until && ($until + ($datecurend - $datecurstart)) < $firstdaytoshow) {
1207 if ($datecurstart >= $lastdaytoshow) {
1212 while (($datecurstart < $lastdaytoshow) && (empty($maxrepeat) || ($numofevent < $maxrepeat))) {
1213 if ($datecurend >= $firstdaytoshow) {
1214 $newevent = $icalevent;
1215 unset($newevent[
'RRULE']);
1216 if ($icalevent[
'DTSTART;VALUE=DATE']) {
1217 $newevent[
'DTSTART;VALUE=DATE'] =
dol_print_date($datecurstart,
'%Y%m%d');
1218 $newevent[
'DTEND;VALUE=DATE'] =
dol_print_date($datecurend + 1,
'%Y%m%d');
1220 $newevent[
'DTSTART'] = $datecurstart;
1221 $newevent[
'DTEND'] = $datecurend;
1223 $moreicalevents[] = $newevent;
1227 $savdatecurstart = $datecurstart;
1228 if ($icalevent[
'RRULE'][
'FREQ'] ==
'DAILY') {
1232 if ($icalevent[
'RRULE'][
'FREQ'] ==
'WEEKLY') {
1235 } elseif ($icalevent[
'RRULE'][
'FREQ'] ==
'MONTHLY') {
1238 } elseif ($icalevent[
'RRULE'][
'FREQ'] ==
'YEARLY') {
1243 if ($savdatecurstart >= $datecurstart) {
1244 dol_syslog(
"Found a rule freq ".$icalevent[
'RRULE'][
'FREQ'].
" not managed by dolibarr code. Assume 1 week frequency.", LOG_ERR);
1245 $datecurstart += 3600 * 24 * 7;
1246 $datecurend += 3600 * 24 * 7;
1251 $icalevents = array_merge($icalevents, $moreicalevents);
1254 foreach ($icalevents as $icalevent) {
1259 if (!empty($icalevent[
'RRULE'])) {
1266 if (isset($icalevent[
'DTSTART;VALUE=DATE'])) {
1269 if (empty($icalevent[
'DTEND;VALUE=DATE'])) {
1270 $dateend = $datestart + 86400 - 1;
1276 $event->fulldayevent = 1;
1278 } elseif (!is_array($icalevent[
'DTSTART'])) {
1279 $datestart = $icalevent[
'DTSTART'];
1280 $dateend = empty($icalevent[
'DTEND']) ? $datestart : $icalevent[
'DTEND'];
1282 $datestart += +($offsettz * 3600);
1283 $dateend += +($offsettz * 3600);
1288 } elseif (isset($icalevent[
'DTSTART'][
'unixtime'])) {
1289 $datestart = $icalevent[
'DTSTART'][
'unixtime'];
1290 $dateend = $icalevent[
'DTEND'][
'unixtime'];
1292 $datestart += +($offsettz * 3600);
1293 $dateend += +($offsettz * 3600);
1296 if ($buggedfile ===
'uselocalandtznodaylight') {
1300 if ($buggedfile ===
'uselocalandtzdaylight') {
1301 $localtzs =
new DateTimeZone(preg_replace(
'/"/',
'', $icalevent[
'DTSTART'][
'TZID']));
1302 $localtze =
new DateTimeZone(preg_replace(
'/"/',
'', $icalevent[
'DTEND'][
'TZID']));
1303 $localdts =
new DateTime(
dol_print_date($datestart,
'dayrfc',
'gmt'), $localtzs);
1304 $localdte =
new DateTime(
dol_print_date($dateend,
'dayrfc',
'gmt'), $localtze);
1305 $tmps = -1 * $localtzs->getOffset($localdts);
1306 $tmpe = -1 * $localtze->getOffset($localdte);
1307 $datestart += $tmps;
1315 $event->id = $icalevent[
'UID'];
1316 $event->ref = $event->id;
1317 $userId = $userstatic->findUserIdByEmail($namecal);
1318 if (!empty($userId) && $userId > 0) {
1319 $event->userassigned[$userId] = $userId;
1320 $event->percentage = -1;
1323 $event->type_code =
"ICALEVENT";
1324 $event->type_label = $namecal;
1325 $event->type_color = $colorcal;
1326 $event->type =
'icalevent';
1327 $event->type_picto =
'rss';
1329 $event->icalname = $namecal;
1330 $event->icalcolor = $colorcal;
1332 $event->datep = $datestart + $usertime;
1333 $event->datef = $dateend + $usertime;
1335 if ($icalevent[
'SUMMARY']) {
1337 } elseif ($icalevent[
'DESCRIPTION']) {
1340 $event->label = $langs->trans(
"ExtSiteNoLabel");
1347 if (!empty($icalevent[
'PRIORITY'])) {
1348 $event->priority = $icalevent[
'PRIORITY'];
1352 if (!empty($icalevent[
'TRANSP'])) {
1353 if ($icalevent[
'TRANSP'] ==
"TRANSPARENT") {
1354 $event->transparency = 0;
1356 if ($icalevent[
'TRANSP'] ==
"OPAQUE") {
1357 $event->transparency = 1;
1368 if (!empty($icalevent[
'LOCATION'])) {
1369 $event->location = $icalevent[
'LOCATION'];
1372 $event->date_start_in_calendar = $event->datep;
1374 if ($event->datef !=
'' && $event->datef >= $event->datep) {
1375 $event->date_end_in_calendar = $event->datef;
1377 $event->date_end_in_calendar = $event->datep;
1381 if ($event->date_end_in_calendar < $firstdaytoshow || $event->date_start_in_calendar >= $lastdaytoshow) {
1387 if ($event->date_start_in_calendar < $firstdaytoshow) {
1388 $event->date_start_in_calendar = $firstdaytoshow;
1390 if ($event->date_end_in_calendar >= $lastdaytoshow) {
1391 $event->date_end_in_calendar = ($lastdaytoshow - 1);
1395 $daycursor = $event->date_start_in_calendar;
1404 $daykey =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
1405 $daykeygmt =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
1408 $eventarray[$daykey][] = $event;
1409 $daykey += 60 * 60 * 24;
1410 $daykeygmt += 60 * 60 * 24;
1411 if (($event->fulldayevent ? $daykeygmt : $daykey) > $event->date_end_in_calendar) {
1425$parameters = array(); $object =
null;
1426$reshook = $hookmanager->executeHooks(
'getCalendarEvents', $parameters, $object, $action);
1427if (!empty($hookmanager->resArray[
'eventarray'])) {
1428 foreach ($hookmanager->resArray[
'eventarray'] as $keyDate => $events) {
1429 if (!isset($eventarray[$keyDate])) {
1430 $eventarray[$keyDate] = array();
1432 $eventarray[$keyDate] = array_merge($eventarray[$keyDate], $events);
1437foreach ($eventarray as $keyDate => &$dateeventarray) {
1438 usort($dateeventarray,
'sort_events_by_date');
1443$cachethirdparties = array();
1444$cachecontacts = array();
1445$cacheusers = array();
1448$color_file = DOL_DOCUMENT_ROOT.
"/theme/".$conf->theme.
"/theme_vars.inc.php";
1449if (is_readable($color_file)) {
1450 include $color_file;
1452if (!is_array($theme_datacolor)) {
1453 $theme_datacolor = array(array(120, 130, 150), array(200, 160, 180), array(190, 190, 220));
1456$massactionbutton =
'';
1458print_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);
1464if (empty($mode) || $mode ==
'show_month') {
1466 $newparam = preg_replace(
'/showbirthday=/i',
'showbirthday_=', $newparam);
1467 $newparam = preg_replace(
'/mode=show_month&?/i',
'', $newparam);
1468 $newparam = preg_replace(
'/mode=show_week&?/i',
'', $newparam);
1469 $newparam = preg_replace(
'/day=[0-9]+&?/i',
'', $newparam);
1470 $newparam = preg_replace(
'/month=[0-9]+&?/i',
'', $newparam);
1471 $newparam = preg_replace(
'/year=[0-9]+&?/i',
'', $newparam);
1472 $newparam = preg_replace(
'/viewcal=[0-9]+&?/i',
'', $newparam);
1473 $newparam = preg_replace(
'/showbirthday_=/i',
'showbirthday=', $newparam);
1474 $newparam .=
'&viewcal=1';
1476 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1477 print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup,
'', $resourceid);
1480 print
'<div class="div-table-responsive-no-min sectioncalendarbymonth maxscreenheightless300">';
1481 print
'<table class="centpercent noborder nocellnopadd cal_pannel cal_month">';
1482 print
' <tr class="liste_titre">';
1484 echo
' <td class="center">#</td>';
1487 print
' <td class="center bold uppercase tdfordaytitle'.($i == 0 ?
' borderleft' :
'').
'">';
1488 $numdayinweek = (($i + (isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1)) % 7);
1489 if (!empty($conf->dol_optimize_smallscreen)) {
1490 $labelshort = array(0=>
'SundayMin', 1=>
'MondayMin', 2=>
'TuesdayMin', 3=>
'WednesdayMin', 4=>
'ThursdayMin', 5=>
'FridayMin', 6=>
'SaturdayMin');
1491 print $langs->trans($labelshort[$numdayinweek]);
1493 print $langs->trans(
"Day".$numdayinweek);
1495 print
' </td>'.
"\n";
1501 $todaytms =
dol_mktime(0, 0, 0, $todayarray[
'mon'], $todayarray[
'mday'], $todayarray[
'year']);
1505 for ($iter_week = 0; $iter_week < 6; $iter_week++) {
1509 $currdate0 = sprintf(
"%04d", $prev_year).sprintf(
"%02d", $prev_month).sprintf(
"%02d", $max_day_in_prev_month + $tmpday);
1510 } elseif ($tmpday <= $max_day_in_month) {
1511 $currdate0 = sprintf(
"%04d", $year).sprintf(
"%02d", $month).sprintf(
"%02d", $tmpday);
1513 $currdate0 = sprintf(
"%04d", $next_year).sprintf(
"%02d", $next_month).sprintf(
"%02d", $tmpday - $max_day_in_month);
1516 $numweek0 = date(
"W", strtotime(date($currdate0)));
1518 echo
' <td class="center weeknumber opacitymedium" width="2%">'.$numweek0.
'</td>';
1520 for ($iter_day = 0; $iter_day < 7; $iter_day++) {
1523 $style =
'cal_other_month cal_past';
1524 if ($iter_day == 6) {
1525 $style .=
' cal_other_month_right';
1527 echo
' <td class="'.$style.
' nowrap tdtop" width="14%">';
1528 show_day_events($db, $max_day_in_prev_month + $tmpday, $prev_month, $prev_year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam);
1530 } elseif ($tmpday <= $max_day_in_month) {
1532 $curtime =
dol_mktime(0, 0, 0, $month, $tmpday, $year);
1533 $style =
'cal_current_month';
1534 if ($iter_day == 6) {
1535 $style .=
' cal_current_month_right';
1538 if ($todayarray[
'mday'] == $tmpday && $todayarray[
'mon'] == $month && $todayarray[
'year'] == $year) {
1542 $style =
'cal_today';
1544 if ($curtime < $todaytms) {
1545 $style .=
' cal_past';
1548 echo
' <td class="'.$style.
' nowrap tdtop" width="14%">';
1549 show_day_events($db, $tmpday, $month, $year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam, 0, 60, 0, $bookcalcalendars);
1553 $style =
'cal_other_month';
1554 if ($iter_day == 6) {
1555 $style .=
' cal_other_month_right';
1557 echo
' <td class="'.$style.
' nowrap tdtop" width="14%">';
1558 show_day_events($db, $tmpday - $max_day_in_month, $next_month, $next_year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam);
1568 print
'<input type="hidden" name="actionmove" value="mupdate">';
1569 print
'<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($_SERVER[
'PHP_SELF']).
'?mode=show_month&'.
dol_escape_htmltag($_SERVER[
'QUERY_STRING']).
'">';
1570 print
'<input type="hidden" name="newdate" id="newdate">';
1571} elseif ($mode ==
'show_week') {
1574 $newparam = preg_replace(
'/showbirthday=/i',
'showbirthday_=', $newparam);
1575 $newparam = preg_replace(
'/mode=show_month&?/i',
'', $newparam);
1576 $newparam = preg_replace(
'/mode=show_week&?/i',
'', $newparam);
1577 $newparam = preg_replace(
'/day=[0-9]+&?/i',
'', $newparam);
1578 $newparam = preg_replace(
'/month=[0-9]+&?/i',
'', $newparam);
1579 $newparam = preg_replace(
'/year=[0-9]+&?/i',
'', $newparam);
1580 $newparam = preg_replace(
'/viewweek=[0-9]+&?/i',
'', $newparam);
1581 $newparam = preg_replace(
'/showbirthday_=/i',
'showbirthday=', $newparam);
1582 $newparam .=
'&viewweek=1';
1584 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1585 print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup,
'', $resourceid);
1588 print
'<div class="div-table-responsive-no-min sectioncalendarbyweek maxscreenheightless300">';
1589 print
'<table class="centpercent noborder nocellnopadd cal_pannel cal_month">';
1590 print
' <tr class="liste_titre">';
1593 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";
1600 for ($iter_day = 0; $iter_day < 7; $iter_day++) {
1607 $style =
'cal_current_month';
1608 if ($iter_day == 6) {
1609 $style .=
' cal_other_month_right';
1614 if ($todayarray[
'mday'] == $tmpday && $todayarray[
'mon'] == $tmpmonth && $todayarray[
'year'] == $tmpyear) {
1618 $style =
'cal_today';
1621 echo
' <td class="'.$style.
'" width="14%" valign="top">';
1622 show_day_events($db, $tmpday, $tmpmonth, $tmpyear, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 0, $bookcalcalendars);
1630 echo
'<input type="hidden" name="actionmove" value="mupdate">';
1631 echo
'<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($_SERVER[
'PHP_SELF']).
'?mode=show_week&'.
dol_escape_htmltag($_SERVER[
'QUERY_STRING']).
'">';
1632 echo
'<input type="hidden" name="newdate" id="newdate">';
1635 $newparam = preg_replace(
'/mode=show_month&?/i',
'', $newparam);
1636 $newparam = preg_replace(
'/mode=show_week&?/i',
'', $newparam);
1637 $newparam = preg_replace(
'/viewday=[0-9]+&?/i',
'', $newparam);
1638 $newparam .=
'&viewday=1';
1640 $style =
'cal_current_month cal_current_month_oneday';
1643 if ($todayarray[
'mday'] == $day && $todayarray[
'mon'] == $month && $todayarray[
'year'] == $year) {
1648 $timestamp =
dol_mktime(12, 0, 0, $month, $day, $year);
1651 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1652 print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup,
'', $resourceid);
1655 print
'<div class="div-table-responsive-no-min sectioncalendarbyday maxscreenheightless300">';
1656 echo
'<table class="tagtable centpercent noborder nocellnopadd cal_pannel cal_month noborderbottom" style="margin-bottom: 5px !important;">';
1658 echo
' <tr class="tagtr liste_titre">';
1659 echo
' <td class="tagtd center bold uppercase">'.$langs->trans(
"Day".$arraytimestamp[
'wday']).
"</td>\n";
1677 print
'<div class="div-table-responsive-no-min borderbottom">';
1679 $maxheightwin = (isset($_SESSION[
"dol_screenheight"]) && $_SESSION[
"dol_screenheight"] > 500) ? ($_SESSION[
"dol_screenheight"] - 200) : 660;
1681 echo
'<div style="max-height: '.$maxheightwin.
'px;">';
1682 echo
'<div class="tagtable centpercent calendarviewcontainer">';
1687 $minhour = round($tmp[0], 0);
1688 $maxhour = round($tmp[1], 0);
1689 if ($minhour > 23) {
1695 if ($maxhour <= $minhour) {
1696 $maxhour = $minhour + 1;
1702 echo
' <div class="tagtr calendarviewcontainertr">'.
"\n";
1703 echo
' <div class="tagtd width100 tdtop">'.dol_print_date($i * 3600,
'hour',
'gmt').
'</div>';
1704 echo
' <div class="tagtd '.$style.
' tdtop"></div>'.
"\n";
1705 echo
' </div>'.
"\n";
1710 echo
'</div></div>';
1712 show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 1, $bookcalcalendars);
1716 print
'<div class="div-table-responsive-no-min borderbottom">';
1718 show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 0, $bookcalcalendars);
1724print
"\n".
'</form>';
1750function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventarray, $maxprint = 0, $maxnbofchar = 16, $newparam =
'', $showinfo = 0, $minheight = 60, $nonew = 0, $bookcalcalendarsarray = array())
1752 global $user, $conf, $langs;
1753 global $action, $mode, $filter, $filtert, $status, $actioncode, $usergroup;
1754 global $theme_datacolor;
1755 global $cachethirdparties, $cachecontacts, $cacheusers, $colorindexused;
1757 if ($conf->use_javascript_ajax) {
1758 $conf->global->MAIN_JS_SWITCH_AGENDA = 1;
1761 $dateint = sprintf(
"%04d", $year).sprintf(
"%02d", $month).sprintf(
"%02d", $day);
1767 $curtime =
dol_mktime(0, 0, 0, $month, $day, $year);
1768 $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;
1770 if ($user->hasRight(
'agenda',
'myactions',
'create') || $user->hasRight(
'agenda',
'allactions',
'create')) {
1771 $newparam .=
'&month='.str_pad($month, 2,
"0", STR_PAD_LEFT).
'&year='.$year;
1772 $hourminsec =
'100000';
1773 $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 :
''));
1777 print
'<div id="dayevent_'.$dateint.
'" class="dayevent tagtable centpercent nobordernopadding">'.
"\n";
1780 print
'<div class="tagtr cursorpointer" onclick="window.location=\''.$urltocreate.
'\';
"><div class="nowrap tagtd
"><div class="left
inline-block
">';
1781 print '<a class="dayevent-aday
" style="color: #666
" href="'.$urltoshow.'">';
1783 print dol_print_date($curtime, 'daytextshort');
1785 print dol_print_date($curtime, '%d');
1788 print '</div><div class="nowrap floatright
inline-block marginrightonly
">';
1789 if ($user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create')) {
1790 print '<a class="cursoradd
" href="'.$urltocreate.'">'; // Explicit link, usefull for nojs interfaces
1791 print img_picto($langs->trans("NewAction
"), 'edit_add.png');
1794 print '</div></div></div>'."\n
";
1802 // Line with td contains all div of each events
1803 print '<div class="tagtr
">';
1804 print '<div class="tagtd centpercent agendacell sortable
">';
1806 //$curtime = dol_mktime (0, 0, 0, $month, $day, $year);
1813 $numicals = array();
1814 $ymd = sprintf("%04d
", $year).sprintf("%02d
", $month).sprintf("%02d
", $day);
1816 $colorindexused[$user->id] = 0; // Color index for current user (user->id) is always 0
1817 $nextindextouse = is_array($colorindexused) ? count($colorindexused) : 0; // At first run this is 0, so fist user has 0, next 1, ...
1818 //var_dump($colorindexused);
1820 include_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php';
1821 $tmpholiday = new Holiday($db);
1823 foreach ($eventarray as $daykey => $notused) { // daykey is the 'YYYYMMDD' to show according to user
1824 $annee = dol_print_date($daykey, '%Y', 'gmt'); // We use gmt because we want the value represented by string 'YYYYMMDD'
1825 $mois = dol_print_date($daykey, '%m', 'gmt'); // We use gmt because we want the value represented by string 'YYYYMMDD'
1826 $jour = dol_print_date($daykey, '%d', 'gmt'); // We use gmt because we want the value represented by string 'YYYYMMDD'
1828 //print 'event daykey='.$daykey.' dol_print_date(daykey)='.dol_print_date($daykey, 'dayhour', 'gmt').' jour='.$jour.' mois='.$mois.' annee='.$annee."<br>\n
";
1830 if ($day == $jour && $month == $mois && $year == $annee) {
1831 foreach ($eventarray[$daykey] as $index => $event) {
1832 if ($i < $maxprint || $maxprint == 0 || getDolGlobalString('MAIN_JS_SWITCH_AGENDA')) {
1833 $keysofuserassigned = array_keys($event->userassigned);
1834 $ponct = ($event->date_start_in_calendar == $event->date_end_in_calendar);
1836 // Define $color (Hex string like '0088FF') and $cssclass of event
1840 if (in_array($user->id, $keysofuserassigned)) {
1841 $cssclass = 'family_mytasks';
1843 if (empty($cacheusers[$event->userownerid])) {
1844 $newuser = new User($db);
1845 $newuser->fetch($event->userownerid);
1846 $cacheusers[$event->userownerid] = $newuser;
1848 //var_dump($cacheusers[$event->userownerid]->color);
1850 // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event)
1851 if (!empty($cacheusers[$event->userownerid]->color)) {
1852 $color = $cacheusers[$event->userownerid]->color;
1854 } elseif ($event->type_code == 'ICALEVENT') { // Event come from external ical file
1856 if (!empty($event->icalname)) {
1857 if (!isset($numicals[dol_string_nospecial($event->icalname)])) {
1858 $numicals[dol_string_nospecial($event->icalname)] = 0;
1860 $numicals[dol_string_nospecial($event->icalname)]++;
1863 $color = ($event->icalcolor ? $event->icalcolor : -1);
1864 $cssclass = (!empty($event->icalname) ? 'family_ext'.md5($event->icalname) : 'family_other');
1865 } elseif ($event->type_code == 'BIRTHDAY') {
1868 $cssclass = 'family_birthday ';
1869 $color = sprintf("%02x%02x%02x
", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
1870 } elseif ($event->type == 'bookcal_calendar') {
1873 $cssclass = 'family_bookcal_calendar_'.(!empty($bookcalcalendarsarray["availabilitieslink
"]) ? $bookcalcalendarsarray["availabilitieslink
"][$event->fk_bookcal_calendar] : "");
1874 $color = sprintf("%02x%02x%02x
", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
1877 $color = ($event->icalcolor ? $event->icalcolor : -1);
1878 $cssclass = (!empty($event->icalname) ? 'family_ext'.md5($event->icalname) : 'family_other');
1880 if (empty($cacheusers[$event->userownerid])) {
1881 $newuser = new User($db);
1882 $newuser->fetch($event->userownerid);
1883 $cacheusers[$event->userownerid] = $newuser;
1885 //var_dump($cacheusers[$event->userownerid]->color);
1887 // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event)
1888 if (!empty($cacheusers[$event->userownerid]->color)) {
1889 $color = $cacheusers[$event->userownerid]->color;
1893 if ($color < 0) { // Color was not set on user card. Set color according to color index.
1894 // Define color index if not yet defined
1895 $idusertouse = ($event->userownerid ? $event->userownerid : 0);
1896 if (isset($colorindexused[$idusertouse])) {
1897 $colorindex = $colorindexused[$idusertouse]; // Color already assigned to this user
1899 $colorindex = $nextindextouse;
1900 $colorindexused[$idusertouse] = $colorindex;
1901 if (!empty($theme_datacolor[$nextindextouse + 1])) {
1902 $nextindextouse++; // Prepare to use next color
1905 //print '|'.($color).'='.($idusertouse?$idusertouse:0).'='.$colorindex.'<br>';
1907 $color = sprintf("%02x%02x%02x
", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
1909 $cssclass = $cssclass.' eventday_'.$ymd;
1911 // Defined style to disable drag and drop feature
1912 if ($event->type_code == 'AC_OTH_AUTO') {
1913 $cssclass .= " unmovable
";
1914 } elseif ($event->type_code == 'HOLIDAY') {
1915 $cssclass .= " unmovable
";
1916 } elseif ($event->type_code == 'BIRTHDAY') {
1917 $cssclass .= " unmovable
";
1918 } elseif ($event->type_code == 'ICALEVENT') {
1919 $cssclass .= " unmovable
";
1920 } 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)) {
1921 // If the event is on several days
1922 $tmpyearend = dol_print_date($event->date_start_in_calendar, '%Y', 'tzuserrel');
1923 $tmpmonthend = dol_print_date($event->date_start_in_calendar, '%m', 'tzuserrel');
1924 $tmpdayend = dol_print_date($event->date_start_in_calendar, '%d', 'tzuserrel');
1925 //var_dump($tmpyearend.' '.$tmpmonthend.' '.$tmpdayend);
1926 if ($tmpyearend != $annee || $tmpmonthend != $mois || $tmpdayend != $jour) {
1927 $cssclass .= " unmovable unmovable-mustusefirstdaytodrag
";
1929 $cssclass .= ' movable cursormove';
1932 if ($user->hasRight('agenda', 'allactions', 'create') ||
1933 (($event->authorid == $user->id || $event->userownerid == $user->id) && $user->hasRight('agenda', 'myactions', 'create'))) {
1934 $cssclass .= " movable cursormove
";
1936 $cssclass .= " unmovable
";
1942 if ($mode == 'show_day') {
1943 $h = 'height: 100%; ';
1946 if ($mode == 'show_week') {
1947 $h = 'height: 100%; ';
1953 print '<!-- start event '.$i.' -->'."\n
";
1956 if ($maxprint && $ireallyshown >= $maxprint) {
1957 $morecss = 'showifmore';
1959 if ($event->type == 'birthdate' && !GETPOST('check_birthday')) {
1960 $morecss = 'hidden';
1962 if ($event->type == 'holiday' && !GETPOST('check_holiday')) {
1963 $morecss = 'hidden';
1965 if ($event->type == 'bookcal_calendar' && !GETPOST('check_bookcal_calendar_'.$bookcalcalendarsarray["availabilitieslink
"][$event->fk_bookcal_calendar])) {
1966 $morecss = 'hidden';
1968 if ($morecss != 'hidden') {
1971 if ($morecss != 'showifmore' && $morecss != 'hidden') {
1974 //var_dump($event->type.' - '.$morecss.' - '.$cssclass.' - '.$i.' - '.$ireallyshown.' - '.$itoshow);
1975 if (isModEnabled("bookcal
") && $event->type == 'bookcal_calendar') {
1976 print '<div id="event_
'.$ymd.'_
'.$i.'" class="event family_
'.$event->type.'_
'.$bookcalcalendarsarray["availabilitieslink"][$event->fk_bookcal_calendar].' '.$cssclass.($morecss ? ' '.$morecss : '').'"';
1978 print '<div id="event_
'.$ymd.'_
'.$i.'" class="event family_
'.$event->type.' '.$cssclass.($morecss ? ' '.$morecss : '').'"';
1980 //print ' style="height: 100px;
';
1981 //print ' position: absolute; top: 40px; width: 50%;
';
1985 //var_dump($event->userassigned);
1986 //var_dump($event->transparency);
1987 print '<table class="centpercent cal_event
';
1988 print(empty($event->transparency) ? ' cal_event_notbusy
' : ' cal_event_busy
');
1989 //if (empty($event->transparency) && empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) print ' opacitymedium
'; // Not busy
1990 print '" style="'.$h;
1991 $colortouse = $color;
1992 // If colortouse is similar than background, we force to change it.
1993 if (empty($event->transparency) && !getDolGlobalString('AGENDA_NO_TRANSPARENT_ON_NOT_BUSY
')) {
1994 print 'background: #f0f0f0;
';
1995 print 'border-left: 5px solid #
'.$colortouse.';
';
1997 print 'background: #f0f0f0;
';
1998 print 'border-left: 5px solid #
'.dol_color_minus($colortouse, -3).';
';
1999 //print 'background: -webkit-gradient(linear, left top, left bottom, from(#
'.dol_color_minus($colortouse, -3).'), to(#
'.dol_color_minus($colortouse, -1).'));
';
2001 //print 'background: #
'.$colortouse.';
';
2002 //print 'background: -webkit-gradient(linear, left top, left bottom, from(#
'.dol_color_minus($color, -3).'), to(#
'.dol_color_minus($color, -1).'));
';
2003 //if (!empty($event->transparency)) print 'background: #
'.$color.'; background: -webkit-gradient(linear, left top, left bottom, from(#
'.$color.'), to(#
'.dol_color_minus($color,1).'));
';
2004 //else print 'background-color: transparent !important; background: none; border: 1px solid #bbb;
';
2005 //print ' -moz-border-radius:4px;
"';
2006 //print 'border: 1px solid #ccc" width=
"100%"';
2009 print '<td class="tdoverflow nobottom centpercent
'.($nowrapontd ? 'nowrap
' : '').'cal_event
'.($event->type_code == 'BIRTHDAY
' ? ' cal_event_birthday
' : '').'">';
2013 if ($event->type_code == 'BIRTHDAY') {
2014 // It's birthday calendar
2015 $picb = '<i class="fas fa-birthday-cake
inline-block
"></i>';
2016 //$pice = '<i class="fas fa-briefcase
inline-block
"></i>';
2017 //$typea = ($objp->typea == 'birth') ? $picb : $pice;
2019 print $picb.' '.$langs->trans("Birthday
").'<br>';
2020 //print img_picto($langs->trans("Birthday
"), 'birthday-cake').' ';
2022 $tmpid = $event->id;
2023 if (empty($cachecontacts[$tmpid])) {
2024 $newcontact = new Contact($db);
2025 $newcontact->fetch($tmpid);
2026 $cachecontact[$tmpid] = $newcontact;
2028 print $cachecontact[$tmpid]->getNomUrl(1);
2030 //$event->picto = 'birthday-cake';
2031 //print $event->getNomUrl(1, $maxnbofchar, 'cal_event', 'birthday', 'contact');
2032 /*$listofcontacttoshow = '';
2033 $listofcontacttoshow .= '<br>'.$cacheusers[$tmpid]->getNomUrl(-1, '', 0, 0, 0, 0, '', 'paddingright valignmiddle');
2034 print $listofcontacttoshow;
2036 } elseif ($event->type_code == 'HOLIDAY') {
2037 // It's holiday calendar
2038 $tmpholiday->fetch($event->id);
2040 print $tmpholiday->getNomUrl(1);
2042 $tmpid = $tmpholiday->fk_user;
2043 if (empty($cacheusers[$tmpid])) {
2044 $newuser = new User($db);
2045 $newuser->fetch($tmpid);
2046 $cacheusers[$tmpid] = $newuser;
2049 $listofusertoshow = '';
2050 $listofusertoshow .= '<br>'.$cacheusers[$tmpid]->getNomUrl(-1, '', 0, 0, 0, 0, '', 'paddingright valignmiddle');
2051 print $listofusertoshow;
2054 if (empty($event->fulldayevent)) {
2055 //print $event->getNomUrl(2).' ';
2059 if (empty($event->fulldayevent)) {
2060 // Show hours (start ... end)
2061 $tmpyearstart = dol_print_date($event->date_start_in_calendar, '%Y', 'tzuserrel');
2062 $tmpmonthstart = dol_print_date($event->date_start_in_calendar, '%m', 'tzuserrel');
2063 $tmpdaystart = dol_print_date($event->date_start_in_calendar, '%d', 'tzuserrel');
2064 $tmpyearend = dol_print_date($event->date_end_in_calendar, '%Y', 'tzuserrel');
2065 $tmpmonthend = dol_print_date($event->date_end_in_calendar, '%m', 'tzuserrel');
2066 $tmpdayend = dol_print_date($event->date_end_in_calendar, '%d', 'tzuserrel');
2069 if ($tmpyearstart == $annee && $tmpmonthstart == $mois && $tmpdaystart == $jour) {
2070 $daterange .= dol_print_date($event->date_start_in_calendar, 'hour', 'tzuserrel');
2071 if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) {
2072 if ($tmpyearstart == $tmpyearend && $tmpmonthstart == $tmpmonthend && $tmpdaystart == $tmpdayend) {
2079 if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) {
2080 if ($tmpyearstart != $tmpyearend || $tmpmonthstart != $tmpmonthend || $tmpdaystart != $tmpdayend) {
2081 $daterange .= '...';
2085 if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) {
2086 if ($tmpyearend == $annee && $tmpmonthend == $mois && $tmpdayend == $jour) {
2087 $daterange .= dol_print_date($event->date_end_in_calendar, 'hour', 'tzuserrel');
2092 print $langs->trans("EventOnFullDay
")."<br>\n
";
2097 $titletoshow = $daterange;
2098 $titletoshow .= ($titletoshow ? ' ' : '').dol_escape_htmltag($event->label ? $event->label : $event->libelle);
2100 if ($event->type_code != 'ICALEVENT') {
2101 $savlabel = $event->label ? $event->label : $event->libelle;
2102 $event->label = $titletoshow;
2103 $event->libelle = $titletoshow; // deprecatd
2104 // Note: List of users are inside $event->userassigned. Link may be clickable depending on permissions of user.
2105 $titletoshow = (($event->type_picto || $event->type_code) ? $event->getTypePicto() : '');
2106 $titletoshow .= $event->getNomUrl(0, $maxnbofchar, 'cal_event cal_event_title', '', 0, 0);
2107 $event->label = $savlabel;
2108 $event->libelle = $savlabel;
2111 // Loop on each assigned user
2112 $listofusertoshow = '';
2113 $posuserassigned = 0;
2114 foreach ($event->userassigned as $tmpid => $tmpdata) {
2115 if (!$posuserassigned && $titletoshow) {
2116 $listofusertoshow .= '<br>';
2119 if (empty($cacheusers[$tmpid])) {
2120 $newuser = new User($db);
2121 $newuser->fetch($tmpid);
2122 $cacheusers[$tmpid] = $newuser;
2125 $listofusertoshow .= $cacheusers[$tmpid]->getNomUrl(-3, '', 0, 0, 0, 0, '', 'valignmiddle');
2129 print $listofusertoshow;
2131 if ($event->type_code == 'ICALEVENT') {
2132 print '<br>('.dol_trunc($event->icalname, $maxnbofchar).')';
2135 $thirdparty_id = ($event->socid > 0 ? $event->socid : ((is_object($event->societe) && $event->societe->id > 0) ? $event->societe->id : 0));
2136 $contact_id = ($event->contact_id > 0 ? $event->contact_id : ((is_object($event->contact) && $event->contact->id > 0) ? $event->contact->id : 0));
2138 // If action related to company / contact
2139 $linerelatedto = '';
2140 if ($thirdparty_id > 0) {
2141 if (!isset($cachethirdparties[$thirdparty_id]) || !is_object($cachethirdparties[$thirdparty_id])) {
2142 $thirdparty = new Societe($db);
2143 $thirdparty->fetch($thirdparty_id);
2144 $cachethirdparties[$thirdparty_id] = $thirdparty;
2146 $thirdparty = $cachethirdparties[$thirdparty_id];
2148 if (!empty($thirdparty->id)) {
2149 $linerelatedto .= $thirdparty->getNomUrl(1, '', 0);
2152 if (!empty($contact_id) && $contact_id > 0) {
2153 if (empty($cachecontacts[$contact_id]) || !is_object($cachecontacts[$contact_id])) {
2154 $contact = new Contact($db);
2155 $contact->fetch($contact_id);
2156 $cachecontacts[$contact_id] = $contact;
2158 $contact = $cachecontacts[$contact_id];
2160 if ($linerelatedto) {
2161 $linerelatedto .= ' ';
2163 if (!empty($contact->id)) {
2164 $linerelatedto .= $contact->getNomUrl(1, '', 0);
2167 if (!empty($event->fk_element) && $event->fk_element > 0 && !empty($event->elementtype) && getDolGlobalString('AGENDA_SHOW_LINKED_OBJECT')) {
2168 include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
2169 if ($linerelatedto) {
2170 $linerelatedto .= '<br>';
2172 $linerelatedto .= dolGetElementUrl($event->fk_element, $event->elementtype, 1);
2174 if ($linerelatedto) {
2175 print ' '.$linerelatedto;
2181 if ($event->location) {
2183 print $langs->trans("Location
").': '.$event->location;
2190 if ($event->type_code != 'BIRTHDAY' && $event->type_code != 'ICALEVENT') {
2192 if ($event->percentage >= 0) {
2196 print '<td class="nobottom right nowrap cal_event_right
'.($withstatus >= 2 ? ' cal_event_right_status
' : '').'">';
2198 print $event->getLibStatut(3, 1);
2202 print '</td></tr></table>';
2203 print '</div><!-- end event '.$i.' -->'."\n
";
2207 print '<a href="'.DOL_URL_ROOT.'/comm/action/index.php?mode=
'.$mode.'&maxprint=0&month=
'.((int) $monthshown).'&year=
'.((int) $year);
2208 print($status ? '&
status=
'.$status : '').($filter ? '&filter=
'.urlencode($filter) : '');
2209 print($filtert ? '&search_filtert=
'.urlencode($filtert) : '');
2210 print($usergroup ? '&search_usergroup=
'.urlencode($usergroup) : '');
2211 print($actioncode != '' ? '&search_actioncode=
'.urlencode($actioncode) : '');
2212 print '">'.img_picto("all
", "1downarrow_selected.png
").' ...';
2213 print ' +'.(count($eventarray[$daykey]) - $maxprint);
2216 //$ok=false; // To avoid to show twice the link
2223 if (!$i) { // No events
2227 if (getDolGlobalString('MAIN_JS_SWITCH_AGENDA') && $itoshow > $ireallyshown && $maxprint) {
2228 print '<div class="center cursorpointer
" id="more_
'.$ymd.'">'.img_picto("All
", "angle-
double-down
", 'class="warning
"').' +'.($itoshow - $ireallyshown).'</div>';
2229 //print ' +'.(count($eventarray[$daykey])-$maxprint);
2231 print '<script type="text/javascript
">'."\n
";
2232 print 'jQuery(document).ready(function () {'."\n
";
2233 print ' var open=0;'."\n
";
2234 print ' jQuery("#more_
'.$ymd.'").click(function() { console.log("Click on showmore
for '.$ymd.'"); reinit_day_'.$ymd.'(); event.stopImmediatePropagation(); });'."\n
";
2235 print ' function reinit_day_'.$ymd.'() {'."\n
";
2236 print ' jQuery(".eventday_
'.$ymd.'.showifmore
").toggle();'."\n
";
2237 print ' open = open + 1; if (open > 1) { open = 0; }'."\n
";
2238 print ' if (open) { ';
2239 print ' jQuery("#more_
'.$ymd.'").html(\''.img_picto("All
", "angle-
double-up
", 'class="warning
"').'\');'."\n
";
2241 print ' jQuery("#more_
'.$ymd.'").html(\''.img_picto("All
", "angle-
double-down
", 'class="warning
"').' +'.($itoshow - $ireallyshown).'\');'."\n
";
2245 print '</script>'."\n
";
2248 print '</div></div>'; // td tr
2250 print '</div>'; // table
2263function dol_color_minus($color, $minus, $minusunit = 16)
2266 if ($minusunit == 16) {
2267 $newcolor[0] = dechex(max(min(hexdec($newcolor[0]) - $minus, 15), 0));
2268 $newcolor[2] = dechex(max(min(hexdec($newcolor[2]) - $minus, 15), 0));
2269 $newcolor[4] = dechex(max(min(hexdec($newcolor[4]) - $minus, 15), 0));
2271 // Not yet implemented
2283function sort_events_by_date($a, $b)
2285 // Sort holidays at first
2286 if ($a->type_code === 'HOLIDAY') {
2289 if ($b->type_code === 'HOLIDAY') {
2293 // datep => Event start time
2294 // datef => Event end time
2296 // Events have different start time
2297 if ($a->datep !== $b->datep) {
2298 return $a->datep - $b->datep;
2301 // Events have same start time and no end time
2302 if ((!is_numeric($b->datef)) || (!is_numeric($a->datef))) {
2303 return sort_events_by_percentage($a, $b);
2306 // Events have the same start time and same end time
2307 if ($b->datef === $a->datef) {
2308 return sort_events_by_percentage($a, $b);
2311 // Events have the same start time, but have different end time -> longest event first
2312 return $b->datef - $a->datef;
2322function sort_events_by_percentage($a, $b)
2324 // Sort events with no percentage before each other
2325 // (usefull to sort holidays, sick days or similar on the top)
2327 if ($a->percentage < 0) {
2331 if ($b->percentage < 0) {
2335 return $b->percentage - $a->percentage;
print $langs trans("AuditedSecurityEvents").'</strong >< span class="opacitymedium"></span >< br > status
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.
calendars_prepare_head($param)
Define head array for tabs of agenda setup pages.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage agenda events (actions)
Class to read/parse ICal calendars.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventarray, $maxprint=0, $maxnbofchar=16, $newparam='', $showinfo=0, $minheight=60, $nonew=0, $bookcalcalendarsarray=array())
Show event of a particular day.
dol_get_prev_month($month, $year)
Return previous month.
dol_get_next_day($day, $month, $year)
Return next day.
dol_get_next_week($day, $week, $month, $year)
Return next week.
dol_get_first_day_week($day, $month, $year, $gm=false)
Return first day of week for a date.
dol_get_prev_day($day, $month, $year)
Return previous day.
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
dol_get_next_month($month, $year)
Return next month.
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
dol_stringtotime($string, $gm=1)
Convert a string date into a GM Timestamps date Warning: YYYY-MM-DDTHH:MM:SS+02:00 (RFC3339) is not s...
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
getDolUserString($key, $default='', $tmpuser=null)
Return Dolibarr user constant string value.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dolGetFirstLastname($firstname, $lastname, $nameorder=-1)
Return firstname and lastname in correct order.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
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_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_sanitizePathName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a path name.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
conf($dolibarr_main_document_root)
Load conf file (file must exists)
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.