dolibarr 18.0.6
index.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2003 Eric Seigne <erics@rycks.com>
4 * Copyright (C) 2004-2018 Laurent Destailleur <eldy@users.sourceforge.net>
5 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
6 * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
7 * Copyright (C) 2014 Cedric GROSS <c.gross@kreiz-it.fr>
8 * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
9 * Copyright (C) 2017 Open-DSI <support@open-dsi.fr>
10 * Copyright (C) 2018-2021 Frédéric France <frederic.france@netlogic.fr>
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 3 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program. If not, see <https://www.gnu.org/licenses/>.
24 */
25
26
33// Load Dolibarr environment
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';
42}
43
44if (!isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) {
45 $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW = 3;
46}
47
48if (empty($conf->global->AGENDA_EXT_NB)) {
49 $conf->global->AGENDA_EXT_NB = 5;
50}
51$MAXAGENDA = $conf->global->AGENDA_EXT_NB;
52$DELAYFORCACHE = 300; // 300 seconds
53
54$disabledefaultvalues = GETPOST('disabledefaultvalues', 'int');
55
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;
61
62// If not choice done on calendar owner (like on left menu link "Agenda"), we filter on user.
63if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS)) {
64 $filtert = $user->id;
65}
66
67$newparam = '';
68
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) {
73 $page = 0;
74} // If $page is not defined, or '' or -1
75$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
76$offset = $limit * $page;
77if (!$sortorder) {
78 $sortorder = "ASC";
79}
80if (!$sortfield) {
81 $sortfield = "a.datec";
82}
83
84// Security check
85$socid = GETPOST("search_socid", "int") ?GETPOST("search_socid", "int") : GETPOST("socid", "int");
86if ($user->socid) {
87 $socid = $user->socid;
88}
89if ($socid < 0) {
90 $socid = '';
91}
92
93$canedit = 1;
94if (!$user->hasRight('agenda', 'myactions', 'read')) {
96}
97if (!$user->hasRight('agenda', 'allactions', 'read')) {
98 $canedit = 0;
99}
100if (!$user->hasRight('agenda', 'allactions', 'read') || $filter == 'mine') { // If no permission to see all, we show only affected to me
101 $filtert = $user->id;
102}
103
104$action = GETPOST('action', 'aZ09');
105
106$mode = GETPOST('mode', 'aZ09');
107if (empty($mode) && preg_match('/show_/', $action)) {
108 $mode = $action; // For backward compatibility
109}
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");
114$day = GETPOST("day", "int") ?GETPOST("day", "int") : date("d");
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'); // status may be 0, 50, 100, 'todo', 'na' or -1
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'); // Option for the css output (always '' except when 'print')
120
121$dateselect = dol_mktime(0, 0, 0, GETPOST('dateselectmonth', 'int'), GETPOST('dateselectday', 'int'), GETPOST('dateselectyear', 'int'));
122if ($dateselect > 0) {
123 $day = GETPOST('dateselectday', 'int');
124 $month = GETPOST('dateselectmonth', 'int');
125 $year = GETPOST('dateselectyear', 'int');
126}
127
128// Set actioncode (this code must be same for setting actioncode into peruser, listacton and index)
129if (GETPOST('search_actioncode', 'array:aZ09')) {
130 $actioncode = GETPOST('search_actioncode', 'array:aZ09', 3);
131 if (!count($actioncode)) {
132 $actioncode = '0';
133 }
134} else {
135 $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));
136}
137
138if ($status == '' && !GETPOSTISSET('search_status')) {
139 $status = ((empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) || $disabledefaultvalues) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS);
140}
141
142$defaultview = (empty($conf->global->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;
146}
147if ($mode == 'default') { // When action is default, we want a calendar view and not the list
148 $mode = (($defaultview != 'show_list') ? $defaultview : 'show_month');
149}
150if (GETPOST('viewcal', 'int') && GETPOST('mode', 'alpha') != 'show_day' && GETPOST('mode', 'alpha') != 'show_week') {
151 $mode = 'show_month'; $day = '';
152} // View by month
153if (GETPOST('viewweek', 'int') || GETPOST('mode', 'alpha') == 'show_week') {
154 $mode = 'show_week'; $week = ($week ? $week : date("W")); $day = ($day ? $day : date("d"));
155} // View by week
156if (GETPOST('viewday', 'int') || GETPOST('mode', 'alpha') == 'show_day') {
157 $mode = 'show_day'; $day = ($day ? $day : date("d"));
158} // View by day
159
160$object = new ActionComm($db);
161
162// Load translation files required by the page
163$langs->loadLangs(array('agenda', 'other', 'commercial'));
164
165// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
166$hookmanager->initHooks(array('agenda'));
167
168$result = restrictedArea($user, 'agenda', 0, 'actioncomm&societe', 'myactions|allactions', 'fk_soc', 'id');
169if ($user->socid && $socid) {
170 $result = restrictedArea($user, 'societe', $socid);
171}
172
173
174/*
175 * Actions
176 */
177
178if (GETPOST("viewlist", 'alpha') || $mode == 'show_list') {
179 $param = '';
180 if (is_array($_POST)) {
181 foreach ($_POST as $key => $val) {
182 if ($key == 'token') {
183 continue;
184 }
185 $param .= '&'.$key.'='.urlencode($val);
186 }
187 }
188 if (!preg_match('/action=/', $param)) {
189 $param .= ($param ? '&' : '').'mode=show_list';
190 }
191 //print $param;
192 header("Location: ".DOL_URL_ROOT.'/comm/action/list.php?'.$param);
193 exit;
194}
195
196if (GETPOST("viewperuser", 'alpha') || $mode == 'show_peruser') {
197 $param = '';
198 if (is_array($_POST)) {
199 foreach ($_POST as $key => $val) {
200 if ($key == 'token') {
201 continue;
202 }
203 $param .= '&'.$key.'='.urlencode($val);
204 }
205 }
206 //print $param;
207 header("Location: ".DOL_URL_ROOT.'/comm/action/peruser.php?'.$param);
208 exit;
209}
210
211/*
212 if ($action == 'delete_action' && $user->rights->agenda->delete) {
213 $event = new ActionComm($db);
214 $event->fetch($actionid);
215 $event->fetch_optionals();
216 $event->fetch_userassigned();
217 $event->oldcopy = dol_clone($event);
218
219 $result = $event->delete();
220 }
221 */
222
223
224/*
225 * View
226 */
227
228$parameters = array(
229 'socid' => $socid,
230 'status' => $status,
231 'year' => $year,
232 'month' => $month,
233 'day' => $day,
234 'type' => $type,
235 'maxprint' => $maxprint,
236 'filter' => $filter,
237 'filtert' => $filtert,
238 'showbirthday' => $showbirthday,
239 'canedit' => $canedit,
240 'optioncss' => $optioncss,
241 'actioncode' => $actioncode,
242 'pid' => $pid,
243 'resourceid' => $resourceid,
244 'usergroup' => $usergroup,
245);
246$reshook = $hookmanager->executeHooks('beforeAgenda', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
247if ($reshook < 0) {
248 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
249}
250
251$help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:M&oacute;dulo_Agenda|DE:Modul_Terminplanung';
252llxHeader('', $langs->trans("Agenda"), $help_url);
253
254$form = new Form($db);
255$companystatic = new Societe($db);
256$contactstatic = new Contact($db);
257$userstatic = new User($db);
258
259$now = dol_now();
260$nowarray = dol_getdate($now);
261$nowyear = $nowarray['year'];
262$nowmonth = $nowarray['mon'];
263$nowday = $nowarray['mday'];
264
265$listofextcals = array();
266
267// Define list of external calendars (global admin setup)
268if (empty($conf->global->AGENDA_DISABLE_EXT)) {
269 $i = 0;
270 while ($i < $MAXAGENDA) {
271 $i++;
272 $source = 'AGENDA_EXT_SRC'.$i;
273 $name = 'AGENDA_EXT_NAME'.$i;
274 $offsettz = 'AGENDA_EXT_OFFSETTZ'.$i;
275 $color = 'AGENDA_EXT_COLOR'.$i;
276 $default = 'AGENDA_EXT_ACTIVEBYDEFAULT'.$i;
277 $buggedfile = 'AGENDA_EXT_BUGGEDFILE'.$i;
278 if (getDolGlobalString($source) && getDolGlobalString($name)) {
279 // Note: $conf->global->buggedfile can be empty or 'uselocalandtznodaylight' or 'uselocalandtzdaylight'
280 $listofextcals[] = array(
281 'src' => getDolGlobalString($source),
283 'offsettz' => (int) getDolGlobalInt($offsettz, 0),
284 'color' => dol_string_nohtmltag(getDolGlobalString($color)),
285 'default' => dol_string_nohtmltag(getDolGlobalString($default)),
286 'buggedfile' => dol_string_nohtmltag(getDolGlobalString('buggedfile', ''))
287 );
288 }
289 }
290}
291// Define list of external calendars (user setup)
292if (empty($user->conf->AGENDA_DISABLE_EXT)) {
293 $i = 0;
294 while ($i < $MAXAGENDA) {
295 $i++;
296 $source = 'AGENDA_EXT_SRC_'.$user->id.'_'.$i;
297 $name = 'AGENDA_EXT_NAME_'.$user->id.'_'.$i;
298 $offsettz = 'AGENDA_EXT_OFFSETTZ_'.$user->id.'_'.$i;
299 $color = 'AGENDA_EXT_COLOR_'.$user->id.'_'.$i;
300 $enabled = 'AGENDA_EXT_ENABLED_'.$user->id.'_'.$i;
301 $default = 'AGENDA_EXT_ACTIVEBYDEFAULT_'.$user->id.'_'.$i;
302 $buggedfile = 'AGENDA_EXT_BUGGEDFILE_'.$user->id.'_'.$i;
303
304 if (getDolUserString($source) && getDolUserString($name)) {
305 // Note: $conf->global->buggedfile can be empty or 'uselocalandtznodaylight' or 'uselocalandtzdaylight'
306 $listofextcals[] = array(
307 'src' => getDolUserString($source),
308 'name' => dol_string_nohtmltag(getDolUserString($name)),
309 'offsettz' => (int) (empty($user->conf->$offsettz) ? 0 : $user->conf->$offsettz),
310 'color' => dol_string_nohtmltag(getDolUserString($color)),
311 'default' => dol_string_nohtmltag(getDolUserString($default)),
312 'buggedfile' => dol_string_nohtmltag(isset($user->conf->buggedfile) ? $user->conf->buggedfile : '')
313 );
314 }
315 }
316}
317
318if (empty($mode) || $mode == 'show_month') {
319 $prev = dol_get_prev_month($month, $year);
320 $prev_year = $prev['year'];
321 $prev_month = $prev['month'];
322 $next = dol_get_next_month($month, $year);
323 $next_year = $next['year'];
324 $next_month = $next['month'];
325
326 $max_day_in_prev_month = date("t", dol_mktime(0, 0, 0, $prev_month, 1, $prev_year, 'gmt')); // Nb of days in previous month
327 $max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year)); // Nb of days in next month
328 // tmpday is a negative or null cursor to know how many days before the 1st to show on month view (if tmpday=0, 1st is monday)
329 $tmpday = -date("w", dol_mktime(12, 0, 0, $month, 1, $year, 'gmt')) + 2; // date('w') is 0 fo sunday
330 $tmpday += ((isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1) - 1);
331 if ($tmpday >= 1) {
332 $tmpday -= 7; // If tmpday is 0 we start with sunday, if -6, we start with monday of previous week.
333 }
334 // Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1)
335 $firstdaytoshow = dol_mktime(0, 0, 0, $prev_month, $max_day_in_prev_month + $tmpday, $prev_year, 'tzuserrel');
336 $next_day = 7 - ($max_day_in_month + 1 - $tmpday) % 7;
337 if ($next_day < 6) {
338 $next_day += 7;
339 }
340 $lastdaytoshow = dol_mktime(0, 0, 0, $next_month, $next_day, $next_year, 'tzuserrel');
341}
342if ($mode == 'show_week') {
343 $prev = dol_get_first_day_week($day, $month, $year);
344 $prev_year = $prev['prev_year'];
345 $prev_month = $prev['prev_month'];
346 $prev_day = $prev['prev_day'];
347 $first_day = $prev['first_day'];
348 $first_month = $prev['first_month'];
349 $first_year = $prev['first_year'];
350
351 $week = $prev['week'];
352
353 $day = (int) $day;
354 $next = dol_get_next_week($first_day, $week, $first_month, $first_year);
355 $next_year = $next['year'];
356 $next_month = $next['month'];
357 $next_day = $next['day'];
358
359 // Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1)
360 $firstdaytoshow = dol_mktime(0, 0, 0, $first_month, $first_day, $first_year, 'tzuserrel');
361 $lastdaytoshow = dol_time_plus_duree($firstdaytoshow, 7, 'd');
362
363 $max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year, 'gmt'));
364
365 $tmpday = $first_day;
366}
367if ($mode == 'show_day') {
368 $prev = dol_get_prev_day($day, $month, $year);
369 $prev_year = $prev['year'];
370 $prev_month = $prev['month'];
371 $prev_day = $prev['day'];
372 $next = dol_get_next_day($day, $month, $year);
373 $next_year = $next['year'];
374 $next_month = $next['month'];
375 $next_day = $next['day'];
376 // Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1)
377 $firstdaytoshow = dol_mktime(0, 0, 0, $prev_month, $prev_day, $prev_year, 'tzuserrel');
378 $lastdaytoshow = dol_mktime(0, 0, 0, $next_month, $next_day, $next_year, 'tzuserrel');
379}
380//print 'xx'.$prev_year.'-'.$prev_month.'-'.$prev_day;
381//print 'xx'.$next_year.'-'.$next_month.'-'.$next_day;
382//print dol_print_date($firstdaytoshow,'dayhour').' '.dol_print_date($lastdaytoshow,'dayhour');
383
384/*$title = $langs->trans("DoneAndToDoActions");
385 if ($status == 'done') $title = $langs->trans("DoneActions");
386 if ($status == 'todo') $title = $langs->trans("ToDoActions");
387 */
388
389$param = '';
390if ($actioncode || GETPOSTISSET('search_actioncode')) {
391 if (is_array($actioncode)) {
392 foreach ($actioncode as $str_action) {
393 $param .= "&search_actioncode[]=".urlencode($str_action);
394 }
395 } else {
396 $param .= "&search_actioncode=".urlencode($actioncode);
397 }
398}
399if ($resourceid > 0) {
400 $param .= "&search_resourceid=".urlencode($resourceid);
401}
402if ($status || GETPOSTISSET('status') || GETPOSTISSET('search_status')) {
403 $param .= "&search_status=".urlencode($status);
404}
405if ($filter) {
406 $param .= "&search_filter=".urlencode($filter);
407}
408if ($filtert) {
409 $param .= "&search_filtert=".urlencode($filtert);
410}
411if ($usergroup > 0) {
412 $param .= "&search_usergroup=".urlencode($usergroup);
413}
414if ($socid > 0) {
415 $param .= "&search_socid=".urlencode($socid);
416}
417if ($showbirthday) {
418 $param .= "&search_showbirthday=1";
419}
420if ($pid) {
421 $param .= "&search_projectid=".urlencode($pid);
422}
423if ($type) {
424 $param .= "&search_type=".urlencode($type);
425}
426$param .= "&maxprint=".urlencode($maxprint);
427if ($mode == 'show_day' || $mode == 'show_week' || $mode == 'show_month') {
428 $param .= '&mode='.urlencode($mode);
429}
430
431// Show navigation bar
432$nav = '';
433$nav .= '<div class="navselectiondate inline-block nowraponall">';
434if (empty($mode) || $mode == 'show_month') {
435 $nav .= "<a href=\"?year=".$prev_year."&month=".$prev_month.$param."\"><i class=\"fa fa-chevron-left\"></i></a> &nbsp;\n";
436 $nav .= " <span id=\"month_name\">".dol_print_date(dol_mktime(0, 0, 0, $month, 1, $year), "%b %Y");
437 $nav .= " </span>\n";
438 $nav .= " &nbsp; <a href=\"?year=".$next_year."&month=".$next_month.$param."\"><i class=\"fa fa-chevron-right\"></i></a>\n";
439 $picto = 'calendar';
440}
441if ($mode == 'show_week') {
442 $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> &nbsp;\n";
443 $nav .= " <span id=\"month_name\">".dol_print_date(dol_mktime(0, 0, 0, $first_month, $first_day, $first_year), "%Y").", ".$langs->trans("WeekShort")." ".$week;
444 $nav .= " </span>\n";
445 $nav .= " &nbsp; <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";
446 $picto = 'calendarweek';
447}
448if ($mode == 'show_day') {
449 $nav .= "<a href=\"?year=".$prev_year."&month=".$prev_month."&day=".$prev_day.$param."\"><i class=\"fa fa-chevron-left\"></i></a> &nbsp;\n";
450 $nav .= " <span id=\"month_name\">".dol_print_date(dol_mktime(0, 0, 0, $month, $day, $year), "daytextshort");
451 $nav .= " </span>\n";
452 $nav .= " &nbsp; <a href=\"?year=".$next_year."&month=".$next_month."&day=".$next_day.$param."\"><i class=\"fa fa-chevron-right\"></i></a>\n";
453 $picto = 'calendarday';
454}
455if (empty($conf->dol_optimize_smallscreen)) {
456 $nav .= ' &nbsp; <a href="?year='.$nowyear.'&month='.$nowmonth.'&day='.$nowday.$param.'" class="datenowlink">'.$langs->trans("Today").'</a> ';
457}
458$nav .= '</div>';
459
460$nav .= $form->selectDate($dateselect, 'dateselect', 0, 0, 1, '', 1, 0);
461//$nav .= ' <input type="submit" class="button button-save" name="submitdateselect" value="'.$langs->trans("Refresh").'">';
462$nav .= '<button type="submit" class="liste_titre button_search valignmiddle" name="button_search_x" value="x"><span class="fa fa-search"></span></button>';
463
464// Must be after the nav definition
465$paramnodate = $param;
466$param .= '&year='.$year.'&month='.$month.($day ? '&day='.$day : '');
467//print 'x'.$param;
468
469
470
471
472/*$tabactive = '';
473 if ($mode == 'show_month') $tabactive = 'cardmonth';
474 if ($mode == 'show_week') $tabactive = 'cardweek';
475 if ($mode == 'show_day') $tabactive = 'cardday';
476 if ($mode == 'show_list') $tabactive = 'cardlist';
477 if ($mode == 'show_pertuser') $tabactive = 'cardperuser';
478 if ($mode == 'show_pertype') $tabactive = 'cardpertype';
479 */
480
481$paramnoaction = preg_replace('/mode=[a-z_]+/', '', preg_replace('/action=[a-z_]+/', '', $param));
482$paramnoactionodate = preg_replace('/mode=[a-z_]+/', '', preg_replace('/action=[a-z_]+/', '', $paramnodate));
483
484$head = calendars_prepare_head($paramnoaction);
485
486print '<form method="POST" id="searchFormList" class="listactionsfilter" action="'.$_SERVER["PHP_SELF"].'">'."\n";
487if ($optioncss != '') {
488 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
489}
490print '<input type="hidden" name="token" value="'.newToken().'">';
491print '<input type="hidden" name="mode" value="'.$mode.'">';
492
493//print dol_get_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action');
494//print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, $listofextcals, $actioncode, $usergroup, '', $resourceid);
495//print dol_get_fiche_end();
496
497$viewmode = '<div class="navmode inline-block">';
498
499$viewmode .= '<a class="btnTitle reposition" href="'.DOL_URL_ROOT.'/comm/action/list.php?mode=show_list&restore_lastsearch_values=1'.$paramnoactionodate.'">';
500//$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
501$viewmode .= img_picto($langs->trans("List"), 'object_calendarlist', 'class="imgforviewmode pictoactionview block"');
502//$viewmode .= '</span>';
503$viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewList").'</span></a>';
504
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.'">';
506//$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
507$viewmode .= img_picto($langs->trans("ViewCal"), 'object_calendarmonth', 'class="pictoactionview block"');
508//$viewmode .= '</span>';
509$viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewCal").'</span></a>';
510
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.'">';
512//$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
513$viewmode .= img_picto($langs->trans("ViewWeek"), 'object_calendarweek', 'class="pictoactionview block"');
514//$viewmode .= '</span>';
515$viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewWeek").'</span></a>';
516
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.'">';
518//$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
519$viewmode .= img_picto($langs->trans("ViewDay"), 'object_calendarday', 'class="pictoactionview block"');
520//$viewmode .= '</span>';
521$viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewDay").'</span></a>';
522
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.'">';
524//$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
525$viewmode .= img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser', 'class="pictoactionview block"');
526//$viewmode .= '</span>';
527$viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewPerUser").'</span></a>';
528
529// Add more views from hooks
530$parameters = array(); $object = null;
531$reshook = $hookmanager->executeHooks('addCalendarView', $parameters, $object, $action);
532if (empty($reshook)) {
533 $viewmode .= $hookmanager->resPrint;
534} elseif ($reshook > 1) {
535 $viewmode = $hookmanager->resPrint;
536}
537
538$viewmode .= '</div>';
539
540$viewmode .= '<span class="marginrightonly"></span>'; // To add a space before the navigation tools
541
542
543$newcardbutton = '';
544$newparam = '';
545if ($user->rights->agenda->myactions->create || $user->hasRight('agenda', 'allactions', 'create')) {
546 $tmpforcreatebutton = dol_getdate(dol_now(), true);
547
548 $newparam .= '&month='.((int) $month).'&year='.((int) $tmpforcreatebutton['year']).'&mode='.urlencode($mode);
549
550 //$param='month='.$monthshown.'&year='.$year;
551 $hourminsec = dol_print_date(dol_mktime(10, 0, 0, 1, 1, 1970, 'gmt'), '%H', 'gmt').'0000'; // Set $hourminsec to '100000' to auto set hour to 10:00 at creation
552
553 $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 : '')));
554}
555
556// Define the legend/list of calendard to show
557$s = ''; $link = '';
558
559$showextcals = $listofextcals;
560
561if (!empty($conf->use_javascript_ajax)) { // If javascript on
562 $s .= "\n".'<!-- Div to calendars selectors -->'."\n";
563 $s .= '<script type="text/javascript">'."\n";
564 $s .= 'jQuery(document).ready(function () {'."\n";
565 $s .= 'jQuery(".check_birthday").click(function() { console.log("Toggle birthdays"); jQuery(".family_birthday").toggle(); });'."\n";
566 $s .= 'jQuery(".check_holiday").click(function() { console.log("Toggle holidays"); jQuery(".family_holiday").toggle(); });'."\n";
567 if ($mode == "show_week" || $mode == "show_month" || empty($mode)) {
568 // Code to enable drag and drop
569 $s .= 'jQuery( "div.sortable" ).sortable({connectWith: ".sortable", placeholder: "ui-state-highlight", items: "div.movable", receive: function( event, ui ) {'."\n";
570 // Code to submit form
571 $s .= 'console.log("submit form to record new event");'."\n";
572 //$s.='console.log(event.target);';
573 $s .= 'var newval = jQuery(event.target).closest("div.dayevent").attr("id");'."\n";
574 $s .= 'console.log("found parent div.dayevent with id = "+newval);'."\n";
575 $s .= 'var frm=jQuery("#searchFormList");'."\n";
576 $s .= 'var newurl = ui.item.find("a.cal_event").attr("href");'."\n";
577 $s .= 'console.log("Found url on href of a.cal_event"+newurl+", we submit form with actionmove=mupdate");'."\n";
578 $s .= 'frm.attr("action", newurl).children("#newdate").val(newval);frm.submit();}'."\n";
579 $s .= '});'."\n";
580 }
581 $s .= '});'."\n";
582 $s .= '</script>'."\n";
583
584 // Local calendar
585 $s .= '<div class="nowrap inline-block minheight30"><input type="checkbox" id="check_mytasks" name="check_mytasks" value="1" checked disabled> '.$langs->trans("LocalAgenda").' &nbsp; </div>';
586
587 if ($user->hasRight("holiday", "read")) {
588 // Holiday calendar
589 $s .= '
590 <div class="nowrap inline-block minheight30"><input type="checkbox" id="check_holiday" name="check_holiday" value="1" class="check_holiday"' . ($check_holiday
591 ? ' checked' : '') . '>
592 <label for="check_holiday">
593 <span class="check_holiday_text">' . $langs->trans("Holidays") . '</span>
594 </label> &nbsp;
595 </div>';
596 }
597
598 // External calendars
599 if (is_array($showextcals) && count($showextcals) > 0) {
600 $s .= '<script type="text/javascript">'."\n";
601 $s .= 'jQuery(document).ready(function () {
602 jQuery("div input[name^=\"check_ext\"]").each(function(index, elem) {
603 var name = jQuery(elem).attr("name");
604 if (jQuery(elem).is(":checked")) {
605 jQuery(".family_ext" + name.replace("check_ext", "")).show();
606 } else {
607 jQuery(".family_ext" + name.replace("check_ext", "")).hide();
608 }
609 });
610
611 jQuery("div input[name^=\"check_ext\"]").click(function() {
612 var name = $(this).attr("name");
613 jQuery(".family_ext" + name.replace("check_ext", "")).toggle();
614 });
615 });' . "\n";
616 $s .= '</script>'."\n";
617
618 foreach ($showextcals as $val) {
619 $htmlname = md5($val['name']);
620
621 if (!empty($val['default']) || GETPOST('check_ext'.$htmlname, 'int')) {
622 $default = "checked";
623 } else {
624 $default = '';
625 }
626
627 $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> &nbsp; </div>';
628 }
629 }
630
631 // Birthdays
632 $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> &nbsp; </div>';
633
634 // Calendars from hooks
635 $parameters = array();
636 $reshook = $hookmanager->executeHooks('addCalendarChoice', $parameters, $object, $action);
637 if (empty($reshook)) {
638 $s .= $hookmanager->resPrint;
639 } elseif ($reshook > 1) {
640 $s = $hookmanager->resPrint;
641 }
642
643 $s .= "\n".'<!-- End div to calendars selectors -->'."\n";
644} else { // If javascript off
645 $newparam = $param; // newparam is for birthday links
646 $newparam = preg_replace('/showbirthday=[0-1]/i', 'showbirthday='.(empty($showbirthday) ? 1 : 0), $newparam);
647 if (!preg_match('/showbirthday=/i', $newparam)) {
648 $newparam .= '&showbirthday=1';
649 }
650 $link = '<a href="'.$_SERVER['PHP_SELF'].'?'.dol_escape_htmltag($newparam);
651 $link .= '">';
652 if (empty($showbirthday)) {
653 $link .= $langs->trans("AgendaShowBirthdayEvents");
654 } else {
655 $link .= $langs->trans("AgendaHideBirthdayEvents");
656 }
657 $link .= '</a>';
658}
659
660
661// Load events from database into $eventarray
662$eventarray = array();
663
664
665// DEFAULT CALENDAR + AUTOEVENT CALENDAR + CONFERENCEBOOTH CALENDAR
666$sql = 'SELECT ';
667if ($usergroup > 0) {
668 $sql .= " DISTINCT";
669}
670$sql .= ' a.id, a.label,';
671$sql .= ' a.datep,';
672$sql .= ' a.datep2,';
673$sql .= ' a.percent,';
674$sql .= ' a.fk_user_author,a.fk_user_action,';
675$sql .= ' a.transparency, a.priority, a.fulldayevent, a.location,';
676$sql .= ' a.fk_soc, a.fk_contact, a.fk_project,';
677$sql .= ' a.fk_element, a.elementtype,';
678$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';
679$sql .= ' FROM '.MAIN_DB_PREFIX.'c_actioncomm as ca, '.MAIN_DB_PREFIX."actioncomm as a";
680if (empty($user->rights->societe->client->voir) && !$socid) {
681 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
682}
683// We must filter on resource table
684if ($resourceid > 0) {
685 $sql .= ", ".MAIN_DB_PREFIX."element_resources as r";
686}
687// We must filter on assignement table
688if ($filtert > 0 || $usergroup > 0) {
689 $sql .= ", ".MAIN_DB_PREFIX."actioncomm_resources as ar";
690}
691if ($usergroup > 0) {
692 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element";
693}
694$sql .= ' WHERE a.fk_action = ca.id';
695$sql .= ' AND a.entity IN ('.getEntity('agenda').')';
696// Condition on actioncode
697if (!empty($actioncode)) {
698 if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
699 if ($actioncode == 'AC_NON_AUTO') {
700 $sql .= " AND ca.type != 'systemauto'";
701 } elseif ($actioncode == 'AC_ALL_AUTO') {
702 $sql .= " AND ca.type = 'systemauto'";
703 } else {
704 if ($actioncode == 'AC_OTH') {
705 $sql .= " AND ca.type != 'systemauto'";
706 }
707 if ($actioncode == 'AC_OTH_AUTO') {
708 $sql .= " AND ca.type = 'systemauto'";
709 }
710 }
711 } else {
712 if ($actioncode == 'AC_NON_AUTO') {
713 $sql .= " AND ca.type != 'systemauto'";
714 } elseif ($actioncode == 'AC_ALL_AUTO') {
715 $sql .= " AND ca.type = 'systemauto'";
716 } else {
717 if (is_array($actioncode)) {
718 $sql .= " AND ca.code IN (".$db->sanitize("'".implode("','", $actioncode)."'", 1).")";
719 } else {
720 $sql .= " AND ca.code IN (".$db->sanitize("'".implode("','", explode(',', $actioncode))."'", 1).")";
721 }
722 }
723 }
724}
725if ($resourceid > 0) {
726 $sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".((int) $resourceid);
727}
728if ($pid) {
729 $sql .= " AND a.fk_project=".((int) $pid);
730}
731if (empty($user->rights->societe->client->voir) && !$socid) {
732 $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = ".((int) $user->id).")";
733}
734if ($socid > 0) {
735 $sql .= " AND a.fk_soc = ".((int) $socid);
736}
737// We must filter on assignement table
738if ($filtert > 0 || $usergroup > 0) {
739 $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'";
740}
741//var_dump($day.' '.$month.' '.$year);
742if ($mode == 'show_day') {
743 $sql .= " AND (";
744 $sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year, 'tzuserrel'))."'";
745 $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year, 'tzuserrel'))."')";
746 $sql .= " OR ";
747 $sql .= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year, 'tzuserrel'))."'";
748 $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year, 'tzuserrel'))."')";
749 $sql .= " OR ";
750 $sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year, 'tzuserrel'))."'";
751 $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year, 'tzuserrel'))."')";
752 $sql .= ')';
753} else {
754 // To limit array
755 $sql .= " AND (";
756 $sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7))."'"; // Start 7 days before
757 $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10))."')"; // End 7 days after + 3 to go from 28 to 31
758 $sql .= " OR ";
759 $sql .= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7))."'";
760 $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10))."')";
761 $sql .= " OR ";
762 $sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7))."'";
763 $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10))."')";
764 $sql .= ')';
765}
766if ($type) {
767 $sql .= " AND ca.id = ".((int) $type);
768}
769if ($status == '0') {
770 // To do (not started)
771 $sql .= " AND a.percent = 0";
772}
773if ($status == 'na') {
774 // Not applicable
775 $sql .= " AND a.percent = -1";
776}
777if ($status == '50') {
778 // Running already started
779 $sql .= " AND (a.percent > 0 AND a.percent < 100)";
780}
781if ($status == 'done' || $status == '100') {
782 $sql .= " AND (a.percent = 100)";
783}
784if ($status == 'todo') {
785 $sql .= " AND (a.percent >= 0 AND a.percent < 100)";
786}
787// We must filter on assignement table
788if ($filtert > 0 || $usergroup > 0) {
789 $sql .= " AND (";
790 if ($filtert > 0) {
791 $sql .= "ar.fk_element = ".((int) $filtert);
792 }
793 if ($usergroup > 0) {
794 $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".((int) $usergroup);
795 }
796 $sql .= ")";
797}
798// Sort on date
799$sql .= ' ORDER BY datep';
800//print $sql;
801
802
803dol_syslog("comm/action/index.php", LOG_DEBUG);
804$resql = $db->query($sql);
805if ($resql) {
806 $num = $db->num_rows($resql);
807
808 $MAXONSAMEPAGE = 10000; // Useless to have more. Protection to avoid memory overload when high number of event (for example after a mass import)
809 $i = 0;
810 while ($i < $num && $i < $MAXONSAMEPAGE) {
811 $obj = $db->fetch_object($resql);
812
813 // Discard auto action if option is on
814 if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->type_code == 'AC_OTH_AUTO') {
815 $i++;
816 continue;
817 }
818
819 // Create a new object action
820 $event = new ActionComm($db);
821
822 $event->id = $obj->id;
823 $event->ref = $event->id;
824
825 $event->fulldayevent = $obj->fulldayevent;
826
827 // event->datep and event->datef must be GMT date.
828 if ($event->fulldayevent) {
829 $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT');
830 $event->datep = $db->jdate($obj->datep, $tzforfullday ? 'tzuser' : 'tzserver'); // If saved in $tzforfullday = gmt, we must invert date to be in user tz
831 $event->datef = $db->jdate($obj->datep2, $tzforfullday ? 'tzuser' : 'tzserver');
832 } else {
833 // Example: $obj->datep = '1970-01-01 01:00:00', jdate will return 0 if TZ of PHP server is Europe/Berlin (+1)
834 $event->datep = $db->jdate($obj->datep, 'tzserver');
835 $event->datef = $db->jdate($obj->datep2, 'tzserver');
836 }
837 //$event->datep_formated_gmt = dol_print_date($event->datep, 'dayhour', 'gmt');
838 //var_dump($obj->id.' '.$obj->datep.' '.dol_print_date($obj->datep, 'dayhour', 'gmt'));
839 //var_dump($obj->id.' '.$event->datep.' '.dol_print_date($event->datep, 'dayhour', 'gmt'));
840
841 $event->type_code = $obj->type_code;
842 $event->type_label = $obj->type_label;
843 $event->type_color = $obj->type_color;
844 $event->type = $obj->type_type;
845 $event->type_picto = $obj->type_picto;
846
847 $event->libelle = $obj->label; // deprecated
848 $event->label = $obj->label;
849 $event->percentage = $obj->percent;
850
851 $event->authorid = $obj->fk_user_author; // user id of creator
852 $event->userownerid = $obj->fk_user_action; // user id of owner
853 $event->fetch_userassigned(); // This load $event->userassigned
854
855 $event->priority = $obj->priority;
856 $event->location = $obj->location;
857 $event->transparency = $obj->transparency;
858 $event->fk_element = $obj->fk_element;
859 $event->elementtype = $obj->elementtype;
860
861 $event->fk_project = $obj->fk_project;
862
863 $event->socid = $obj->fk_soc;
864 $event->contact_id = $obj->fk_contact;
865
866 // Defined date_start_in_calendar and date_end_in_calendar property
867 // They are date start and end of action but modified to not be outside calendar view.
868 $event->date_start_in_calendar = $event->datep;
869 if ($event->datef != '' && $event->datef >= $event->datep) {
870 $event->date_end_in_calendar = $event->datef;
871 } else {
872 $event->date_end_in_calendar = $event->datep;
873 }
874
875 // Check values
876 if ($event->date_end_in_calendar < $firstdaytoshow || $event->date_start_in_calendar >= $lastdaytoshow) {
877 // This record is out of visible range
878 } else {
879 if ($event->date_start_in_calendar < $firstdaytoshow) {
880 $event->date_start_in_calendar = $firstdaytoshow;
881 }
882 if ($event->date_end_in_calendar >= $lastdaytoshow) {
883 $event->date_end_in_calendar = ($lastdaytoshow - 1);
884 }
885
886 // Add an entry in actionarray for each day
887 $daycursor = $event->date_start_in_calendar;
888 $annee = dol_print_date($daycursor, '%Y', 'tzuserrel');
889 $mois = dol_print_date($daycursor, '%m', 'tzuserrel');
890 $jour = dol_print_date($daycursor, '%d', 'tzuserrel');
891
892 $daycursorend = $event->date_end_in_calendar;
893 $anneeend = dol_print_date($daycursorend, '%Y', 'tzuserrel');
894 $moisend = dol_print_date($daycursorend, '%m', 'tzuserrel');
895 $jourend = dol_print_date($daycursorend, '%d', 'tzuserrel');
896
897 //var_dump(dol_print_date($event->date_start_in_calendar, 'dayhour', 'gmt')); // Hour at greenwich
898 //var_dump($annee.'-'.$mois.'-'.$jour);
899 //print 'annee='.$annee.' mois='.$mois.' jour='.$jour.'<br>';
900
901 // Loop on each day covered by action to prepare an index to show on calendar
902 $loop = true; $j = 0;
903 $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee, 'gmt'); // $mois, $jour, $annee has been set for user tz
904 $daykeyend = dol_mktime(0, 0, 0, $moisend, $jourend, $anneeend, 'gmt'); // $moisend, $jourend, $anneeend has been set for user tz
905 /*
906 print 'GMT '.$event->date_start_in_calendar.' '.dol_print_date($event->date_start_in_calendar, 'dayhour', 'gmt').'<br>';
907 print 'TZSERVER '.$event->date_start_in_calendar.' '.dol_print_date($event->date_start_in_calendar, 'dayhour', 'tzserver').'<br>';
908 print 'TZUSERREL '.$event->date_start_in_calendar.' '.dol_print_date($event->date_start_in_calendar, 'dayhour', 'tzuserrel').'<br>';
909 print 'GMT '.$event->date_end_in_calendar.' '.dol_print_date($event->date_end_in_calendar, 'dayhour', 'gmt').'<br>';
910 print 'TZSERVER '.$event->date_end_in_calendar.' '.dol_print_date($event->date_end_in_calendar, 'dayhour', 'tzserver').'<br>';
911 print 'TZUSER '.$event->date_end_in_calendar.' '.dol_print_date($event->date_end_in_calendar, 'dayhour', 'tzuserrel').'<br>';
912 */
913 do {
914 //if ($event->id==408)
915 //print 'daykey='.$daykey.' daykeyend='.$daykeyend.' '.dol_print_date($daykey, 'dayhour', 'gmt').' - '.dol_print_date($event->datep, 'dayhour', 'gmt').' '.dol_print_date($event->datef, 'dayhour', 'gmt').'<br>';
916 //print 'daykey='.$daykey.' daykeyend='.$daykeyend.' '.dol_print_date($daykey, 'dayhour', 'tzuserrel').' - '.dol_print_date($event->datep, 'dayhour', 'tzuserrel').' '.dol_print_date($event->datef, 'dayhour', 'tzuserrel').'<br>';
917
918 $eventarray[$daykey][] = $event;
919 $j++;
920
921 $daykey += 60 * 60 * 24;
922 //if ($daykey > $event->date_end_in_calendar) {
923 if ($daykey > $daykeyend) {
924 $loop = false;
925 }
926 } while ($loop);
927 //var_dump($eventarray);
928 //print 'Event '.$i.' id='.$event->id.' (start='.dol_print_date($event->datep).'-end='.dol_print_date($event->datef);
929 //print ' startincalendar='.dol_print_date($event->date_start_in_calendar).'-endincalendar='.dol_print_date($event->date_end_in_calendar).') was added in '.$j.' different index key of array<br>';
930 }
931 $i++;
932 }
933} else {
934 dol_print_error($db);
935}
936//var_dump($eventarray);
937
938
939// BIRTHDATES CALENDAR
940// Complete $eventarray with birthdates
941if ($showbirthday) {
942 // Add events in array
943 $sql = 'SELECT sp.rowid, sp.lastname, sp.firstname, sp.birthday';
944 $sql .= ' FROM '.MAIN_DB_PREFIX.'socpeople as sp';
945 $sql .= ' WHERE (priv=0 OR (priv=1 AND fk_user_creat='.((int) $user->id).'))';
946 $sql .= " AND sp.entity IN (".getEntity('contact').")";
947 if ($mode == 'show_day') {
948 $sql .= ' AND MONTH(birthday) = '.((int) $month);
949 $sql .= ' AND DAY(birthday) = '.((int) $day);
950 } else {
951 $sql .= ' AND MONTH(birthday) = '.((int) $month);
952 }
953 $sql .= ' ORDER BY birthday';
954
955 dol_syslog("comm/action/index.php", LOG_DEBUG);
956 $resql = $db->query($sql);
957 if ($resql) {
958 $num = $db->num_rows($resql);
959 $i = 0;
960 while ($i < $num) {
961 $obj = $db->fetch_object($resql);
962
963 $event = new ActionComm($db);
964
965 $event->id = $obj->rowid; // We put contact id in action id for birthdays events
966 $event->ref = $event->id;
967
968 $datebirth = dol_stringtotime($obj->birthday, 1);
969 //print 'ee'.$obj->birthday.'-'.$datebirth;
970 $datearray = dol_getdate($datebirth, true);
971 $event->datep = dol_mktime(0, 0, 0, $datearray['mon'], $datearray['mday'], $year, true); // For full day events, date are also GMT but they wont but converted during output
972 $event->datef = $event->datep;
973
974 $event->type_code = 'BIRTHDAY';
975 $event->type_label = '';
976 $event->type_color = '';
977 $event->type = 'birthdate';
978 $event->type_picto = 'birthdate';
979
980 $event->label = $langs->trans("Birthday").' '.dolGetFirstLastname($obj->firstname, $obj->lastname);
981 $event->percentage = 100;
982 $event->fulldayevent = 1;
983
984 $event->contact_id = $obj->rowid;
985
986 $event->date_start_in_calendar = $db->jdate($event->datep);
987 $event->date_end_in_calendar = $db->jdate($event->datef);
988
989 // Add an entry in eventarray for each day
990 $daycursor = $event->datep;
991 $annee = dol_print_date($daycursor, '%Y', 'tzuserrel');
992 $mois = dol_print_date($daycursor, '%m', 'tzuserrel');
993 $jour = dol_print_date($daycursor, '%d', 'tzuserrel');
994
995 $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee, 'gmt');
996
997 $eventarray[$daykey][] = $event;
998
999 /*$loop = true;
1000 $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee);
1001 do {
1002 $eventarray[$daykey][] = $event;
1003 $daykey += 60 * 60 * 24;
1004 if ($daykey > $event->date_end_in_calendar) $loop = false;
1005 } while ($loop);
1006 */
1007 $i++;
1008 }
1009 } else {
1010 dol_print_error($db);
1011 }
1012}
1013
1014if ($user->hasRight("holiday", "read")) {
1015 // LEAVE-HOLIDAY CALENDAR
1016 $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";
1017 $sql .= " FROM ".MAIN_DB_PREFIX."holiday as x, ".MAIN_DB_PREFIX."user as u";
1018 $sql .= " WHERE u.rowid = x.fk_user";
1019 $sql .= " AND u.statut = '1'"; // Show only active users (0 = inactive user, 1 = active user)
1020 $sql .= " AND (x.statut = '2' OR x.statut = '3')"; // Show only public leaves (2 = leave wait for approval, 3 = leave approved)
1021
1022 if ($mode == 'show_day') {
1023 // Request only leaves for the current selected day
1024 $sql .= " AND '".$db->escape($year)."-".$db->escape($month)."-".$db->escape($day)."' BETWEEN x.date_debut AND x.date_fin"; // date_debut and date_fin are date without time
1025 } elseif ($mode == 'show_week') {
1026 // Restrict on current month (we get more, but we will filter later)
1027 $sql .= " AND date_debut < '".$db->idate(dol_get_last_day($year, $month))."'";
1028 $sql .= " AND date_fin >= '".$db->idate(dol_get_first_day($year, $month))."'";
1029 } elseif ($mode == 'show_month') {
1030 // Restrict on current month
1031 $sql .= " AND date_debut <= '".$db->idate(dol_get_last_day($year, $month))."'";
1032 $sql .= " AND date_fin >= '".$db->idate(dol_get_first_day($year, $month))."'";
1033 }
1034
1035 $resql = $db->query($sql);
1036 if ($resql) {
1037 $num = $db->num_rows($resql);
1038 $i = 0;
1039
1040 while ($i < $num) {
1041 $obj = $db->fetch_object($resql);
1042
1043 $event = new ActionComm($db);
1044
1045 // Need the id of the leave object for link to it
1046 $event->id = $obj->rowid;
1047 $event->ref = $event->id;
1048
1049 $event->type_code = 'HOLIDAY';
1050 $event->type_label = '';
1051 $event->type_color = '';
1052 $event->type = 'holiday';
1053 $event->type_picto = 'holiday';
1054
1055 $event->datep = $db->jdate($obj->date_start) + (empty($halfday) || $halfday == 1 ? 0 : 12 * 60 * 60 - 1);
1056 $event->datef = $db->jdate($obj->date_end) + (empty($halfday) || $halfday == -1 ? 24 : 12) * 60 * 60 - 1;
1057 $event->date_start_in_calendar = $event->datep;
1058 $event->date_end_in_calendar = $event->datef;
1059
1060 if ($obj->status == 3) {
1061 // Show no symbol for leave with state "leave approved"
1062 $event->percentage = -1;
1063 } elseif ($obj->status == 2) {
1064 // Show TO-DO symbol for leave with state "leave wait for approval"
1065 $event->percentage = 0;
1066 }
1067
1068 if ($obj->halfday == 1) {
1069 $event->label = $obj->lastname.' ('.$langs->trans("Morning").')';
1070 } elseif ($obj->halfday == -1) {
1071 $event->label = $obj->lastname.' ('.$langs->trans("Afternoon").')';
1072 } else {
1073 $event->label = $obj->lastname;
1074 }
1075
1076 $daycursor = $event->date_start_in_calendar;
1077 $annee = dol_print_date($daycursor, '%Y', 'tzuserrel');
1078 $mois = dol_print_date($daycursor, '%m', 'tzuserrel');
1079 $jour = dol_print_date($daycursor, '%d', 'tzuserrel');
1080
1081 $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee, 'gmt');
1082 do {
1083 $eventarray[$daykey][] = $event;
1084
1085 $daykey += 60 * 60 * 24;
1086 } while ($daykey <= $event->date_end_in_calendar);
1087
1088 $i++;
1089 }
1090 }
1091}
1092
1093// EXTERNAL CALENDAR
1094// Complete $eventarray with external import Ical
1095if (count($listofextcals)) {
1096 require_once DOL_DOCUMENT_ROOT.'/comm/action/class/ical.class.php';
1097 foreach ($listofextcals as $extcal) {
1098 $url = $extcal['src']; // Example: https://www.google.com/calendar/ical/eldy10%40gmail.com/private-cde92aa7d7e0ef6110010a821a2aaeb/basic.ics
1099 $namecal = $extcal['name'];
1100 $offsettz = $extcal['offsettz'];
1101 $colorcal = $extcal['color'];
1102 $buggedfile = $extcal['buggedfile'];
1103
1104 $pathforcachefile = dol_sanitizePathName($conf->user->dir_temp).'/'.dol_sanitizeFileName('extcal_'.$namecal.'_user'.$user->id).'.cache';
1105 //var_dump($pathforcachefile);exit;
1106
1107 $ical = new ICal();
1108 $ical->parse($url, $pathforcachefile, $DELAYFORCACHE);
1109
1110 // After this $ical->cal['VEVENT'] contains array of events, $ical->cal['DAYLIGHT'] contains daylight info, $ical->cal['STANDARD'] contains non daylight info, ...
1111 //var_dump($ical->cal); exit;
1112 $icalevents = array();
1113 if (is_array($ical->get_event_list())) {
1114 $icalevents = array_merge($icalevents, $ical->get_event_list()); // Add $ical->cal['VEVENT']
1115 }
1116 if (is_array($ical->get_freebusy_list())) {
1117 $icalevents = array_merge($icalevents, $ical->get_freebusy_list()); // Add $ical->cal['VFREEBUSY']
1118 }
1119
1120 if (count($icalevents) > 0) {
1121 // Duplicate all repeatable events into new entries
1122 $moreicalevents = array();
1123 foreach ($icalevents as $icalevent) {
1124 if (isset($icalevent['RRULE']) && is_array($icalevent['RRULE'])) { //repeatable event
1125 //if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar=$firstdaytoshow;
1126 //if ($event->date_end_in_calendar > $lastdaytoshow) $event->date_end_in_calendar=($lastdaytoshow-1);
1127 if ($icalevent['DTSTART;VALUE=DATE']) { //fullday event
1128 $datecurstart = dol_stringtotime($icalevent['DTSTART;VALUE=DATE'], 1);
1129 $datecurend = dol_stringtotime($icalevent['DTEND;VALUE=DATE'], 1) - 1; // We remove one second to get last second of day
1130 } elseif (is_array($icalevent['DTSTART']) && !empty($icalevent['DTSTART']['unixtime'])) {
1131 $datecurstart = $icalevent['DTSTART']['unixtime'];
1132 $datecurend = $icalevent['DTEND']['unixtime'];
1133 if (!empty($ical->cal['DAYLIGHT']['DTSTART']) && $datecurstart) {
1134 //var_dump($ical->cal);
1135 $tmpcurstart = $datecurstart;
1136 $tmpcurend = $datecurend;
1137 $tmpdaylightstart = dol_mktime(0, 0, 0, 1, 1, 1970, 1) + (int) $ical->cal['DAYLIGHT']['DTSTART'];
1138 $tmpdaylightend = dol_mktime(0, 0, 0, 1, 1, 1970, 1) + (int) $ical->cal['STANDARD']['DTSTART'];
1139 //var_dump($tmpcurstart);var_dump($tmpcurend); var_dump($ical->cal['DAYLIGHT']['DTSTART']);var_dump($ical->cal['STANDARD']['DTSTART']);
1140 // Edit datecurstart and datecurend
1141 if ($tmpcurstart >= $tmpdaylightstart && $tmpcurstart < $tmpdaylightend) {
1142 $datecurstart -= ((int) $ical->cal['DAYLIGHT']['TZOFFSETTO']) * 36;
1143 } else {
1144 $datecurstart -= ((int) $ical->cal['STANDARD']['TZOFFSETTO']) * 36;
1145 }
1146 if ($tmpcurend >= $tmpdaylightstart && $tmpcurstart < $tmpdaylightend) {
1147 $datecurend -= ((int) $ical->cal['DAYLIGHT']['TZOFFSETTO']) * 36;
1148 } else {
1149 $datecurend -= ((int) $ical->cal['STANDARD']['TZOFFSETTO']) * 36;
1150 }
1151 }
1152 // datecurstart and datecurend are now GMT date
1153 //var_dump($datecurstart); var_dump($datecurend); exit;
1154 } else {
1155 // Not a recongized record
1156 dol_syslog("Found a not recognized repeatable record with unknown date start", LOG_ERR);
1157 continue;
1158 }
1159 //print 'xx'.$datecurstart;exit;
1160
1161 $interval = (empty($icalevent['RRULE']['INTERVAL']) ? 1 : $icalevent['RRULE']['INTERVAL']);
1162 $until = empty($icalevent['RRULE']['UNTIL']) ? 0 : dol_stringtotime($icalevent['RRULE']['UNTIL'], 1);
1163 $maxrepeat = empty($icalevent['RRULE']['COUNT']) ? 0 : $icalevent['RRULE']['COUNT'];
1164 if ($until && ($until + ($datecurend - $datecurstart)) < $firstdaytoshow) {
1165 continue; // We discard repeatable event that end before start date to show
1166 }
1167 if ($datecurstart >= $lastdaytoshow) {
1168 continue; // We discard repeatable event that start after end date to show
1169 }
1170
1171 $numofevent = 0;
1172 while (($datecurstart < $lastdaytoshow) && (empty($maxrepeat) || ($numofevent < $maxrepeat))) {
1173 if ($datecurend >= $firstdaytoshow) { // We add event
1174 $newevent = $icalevent;
1175 unset($newevent['RRULE']);
1176 if ($icalevent['DTSTART;VALUE=DATE']) {
1177 $newevent['DTSTART;VALUE=DATE'] = dol_print_date($datecurstart, '%Y%m%d');
1178 $newevent['DTEND;VALUE=DATE'] = dol_print_date($datecurend + 1, '%Y%m%d');
1179 } else {
1180 $newevent['DTSTART'] = $datecurstart;
1181 $newevent['DTEND'] = $datecurend;
1182 }
1183 $moreicalevents[] = $newevent;
1184 }
1185 // Jump on next occurence
1186 $numofevent++;
1187 $savdatecurstart = $datecurstart;
1188 if ($icalevent['RRULE']['FREQ'] == 'DAILY') {
1189 $datecurstart = dol_time_plus_duree($datecurstart, $interval, 'd');
1190 $datecurend = dol_time_plus_duree($datecurend, $interval, 'd');
1191 }
1192 if ($icalevent['RRULE']['FREQ'] == 'WEEKLY') {
1193 $datecurstart = dol_time_plus_duree($datecurstart, $interval, 'w');
1194 $datecurend = dol_time_plus_duree($datecurend, $interval, 'w');
1195 } elseif ($icalevent['RRULE']['FREQ'] == 'MONTHLY') {
1196 $datecurstart = dol_time_plus_duree($datecurstart, $interval, 'm');
1197 $datecurend = dol_time_plus_duree($datecurend, $interval, 'm');
1198 } elseif ($icalevent['RRULE']['FREQ'] == 'YEARLY') {
1199 $datecurstart = dol_time_plus_duree($datecurstart, $interval, 'y');
1200 $datecurend = dol_time_plus_duree($datecurend, $interval, 'y');
1201 }
1202 // Test to avoid infinite loop ($datecurstart must increase)
1203 if ($savdatecurstart >= $datecurstart) {
1204 dol_syslog("Found a rule freq ".$icalevent['RRULE']['FREQ']." not managed by dolibarr code. Assume 1 week frequency.", LOG_ERR);
1205 $datecurstart += 3600 * 24 * 7;
1206 $datecurend += 3600 * 24 * 7;
1207 }
1208 }
1209 }
1210 }
1211 $icalevents = array_merge($icalevents, $moreicalevents);
1212
1213 // Loop on each entry into cal file to know if entry is qualified and add an ActionComm into $eventarray
1214 foreach ($icalevents as $icalevent) {
1215 //var_dump($icalevent);
1216
1217 //print $icalevent['SUMMARY'].'->';
1218 //var_dump($icalevent);exit;
1219 if (!empty($icalevent['RRULE'])) {
1220 continue; // We found a repeatable event. It was already split into unitary events, so we discard general rule.
1221 }
1222
1223 // Create a new object action
1224 $event = new ActionComm($db);
1225 $addevent = false;
1226 if (isset($icalevent['DTSTART;VALUE=DATE'])) { // fullday event
1227 // For full day events, date are also GMT but they wont but converted using tz during output
1228 $datestart = dol_stringtotime($icalevent['DTSTART;VALUE=DATE'], 1);
1229 if (empty($icalevent['DTEND;VALUE=DATE'])) {
1230 $dateend = $datestart + 86400 - 1;
1231 } else {
1232 $dateend = dol_stringtotime($icalevent['DTEND;VALUE=DATE'], 1) - 1; // We remove one second to get last second of day
1233 }
1234 //print 'x'.$datestart.'-'.$dateend;exit;
1235 //print dol_print_date($dateend,'dayhour','gmt');
1236 $event->fulldayevent = 1;
1237 $addevent = true;
1238 } elseif (!is_array($icalevent['DTSTART'])) { // not fullday event (DTSTART is not array. It is a value like '19700101T000000Z' for 00:00 in greenwitch)
1239 $datestart = $icalevent['DTSTART'];
1240 $dateend = empty($icalevent['DTEND']) ? $datestart : $icalevent['DTEND'];
1241
1242 $datestart += +($offsettz * 3600);
1243 $dateend += +($offsettz * 3600);
1244
1245 $addevent = true;
1246 //var_dump($offsettz);
1247 //var_dump(dol_print_date($datestart, 'dayhour', 'gmt'));
1248 } elseif (isset($icalevent['DTSTART']['unixtime'])) { // File contains a local timezone + a TZ (for example when using bluemind)
1249 $datestart = $icalevent['DTSTART']['unixtime'];
1250 $dateend = $icalevent['DTEND']['unixtime'];
1251
1252 $datestart += +($offsettz * 3600);
1253 $dateend += +($offsettz * 3600);
1254
1255 // $buggedfile is set to uselocalandtznodaylight if conf->global->AGENDA_EXT_BUGGEDFILEx = 'uselocalandtznodaylight'
1256 if ($buggedfile === 'uselocalandtznodaylight') { // unixtime is a local date that does not take daylight into account, TZID is +1 for example for 'Europe/Paris' in summer instead of 2
1257 // TODO
1258 }
1259 // $buggedfile is set to uselocalandtzdaylight if conf->global->AGENDA_EXT_BUGGEDFILEx = 'uselocalandtzdaylight' (for example with bluemind)
1260 if ($buggedfile === 'uselocalandtzdaylight') { // unixtime is a local date that does take daylight into account, TZID is +2 for example for 'Europe/Paris' in summer
1261 $localtzs = new DateTimeZone(preg_replace('/"/', '', $icalevent['DTSTART']['TZID']));
1262 $localtze = new DateTimeZone(preg_replace('/"/', '', $icalevent['DTEND']['TZID']));
1263 $localdts = new DateTime(dol_print_date($datestart, 'dayrfc', 'gmt'), $localtzs);
1264 $localdte = new DateTime(dol_print_date($dateend, 'dayrfc', 'gmt'), $localtze);
1265 $tmps = -1 * $localtzs->getOffset($localdts);
1266 $tmpe = -1 * $localtze->getOffset($localdte);
1267 $datestart += $tmps;
1268 $dateend += $tmpe;
1269 //var_dump($datestart);
1270 }
1271 $addevent = true;
1272 }
1273
1274 if ($addevent) {
1275 $event->id = $icalevent['UID'];
1276 $event->ref = $event->id;
1277 $userId = $userstatic->findUserIdByEmail($namecal);
1278 if (!empty($userId) && $userId > 0) {
1279 $event->userassigned[$userId] = $userId;
1280 $event->percentage = -1;
1281 }
1282
1283 $event->type_code = "ICALEVENT";
1284 $event->type_label = $namecal;
1285 $event->type_color = $colorcal;
1286 $event->type = 'icalevent';
1287 $event->type_picto = 'rss';
1288
1289 $event->icalname = $namecal;
1290 $event->icalcolor = $colorcal;
1291 $usertime = 0; // We dont modify date because we want to have date into memory datep and datef stored as GMT date. Compensation will be done during output.
1292 $event->datep = $datestart + $usertime;
1293 $event->datef = $dateend + $usertime;
1294
1295 if ($icalevent['SUMMARY']) {
1296 $event->label = dol_string_nohtmltag($icalevent['SUMMARY']);
1297 } elseif ($icalevent['DESCRIPTION']) {
1298 $event->label = dol_nl2br(dol_string_nohtmltag($icalevent['DESCRIPTION']), 1);
1299 } else {
1300 $event->label = $langs->trans("ExtSiteNoLabel");
1301 }
1302
1303 // Priority (see https://www.kanzaki.com/docs/ical/priority.html)
1304 // LOW = 0 to 4
1305 // MEDIUM = 5
1306 // HIGH = 6 to 9
1307 if (!empty($icalevent['PRIORITY'])) {
1308 $event->priority = $icalevent['PRIORITY'];
1309 }
1310
1311 // Transparency (see https://www.kanzaki.com/docs/ical/transp.html)
1312 if (!empty($icalevent['TRANSP'])) {
1313 if ($icalevent['TRANSP'] == "TRANSPARENT") {
1314 $event->transparency = 0; // 0 = available / free
1315 }
1316 if ($icalevent['TRANSP'] == "OPAQUE") {
1317 $event->transparency = 1; // 1 = busy
1318 }
1319
1320 // TODO: MS outlook states
1321 // X-MICROSOFT-CDO-BUSYSTATUS:FREE + TRANSP:TRANSPARENT => Available / Free
1322 // X-MICROSOFT-CDO-BUSYSTATUS:FREE + TRANSP:OPAQUE => Work another place
1323 // X-MICROSOFT-CDO-BUSYSTATUS:TENTATIVE + TRANSP:OPAQUE => With reservations
1324 // X-MICROSOFT-CDO-BUSYSTATUS:BUSY + TRANSP:OPAQUE => Busy
1325 // X-MICROSOFT-CDO-BUSYSTATUS:OOF + TRANSP:OPAQUE => Away from the office / off-site
1326 }
1327
1328 if (!empty($icalevent['LOCATION'])) {
1329 $event->location = $icalevent['LOCATION'];
1330 }
1331
1332 $event->date_start_in_calendar = $event->datep;
1333
1334 if ($event->datef != '' && $event->datef >= $event->datep) {
1335 $event->date_end_in_calendar = $event->datef;
1336 } else {
1337 $event->date_end_in_calendar = $event->datep;
1338 }
1339
1340 // Add event into $eventarray if date range are ok.
1341 if ($event->date_end_in_calendar < $firstdaytoshow || $event->date_start_in_calendar >= $lastdaytoshow) {
1342 //print 'x'.$datestart.'-'.$dateend;exit;
1343 //print 'x'.$datestart.'-'.$dateend;exit;
1344 //print 'x'.$datestart.'-'.$dateend;exit;
1345 // This record is out of visible range
1346 } else {
1347 if ($event->date_start_in_calendar < $firstdaytoshow) {
1348 $event->date_start_in_calendar = $firstdaytoshow;
1349 }
1350 if ($event->date_end_in_calendar >= $lastdaytoshow) {
1351 $event->date_end_in_calendar = ($lastdaytoshow - 1);
1352 }
1353
1354 // Add an entry in actionarray for each day
1355 $daycursor = $event->date_start_in_calendar;
1356 $annee = dol_print_date($daycursor, '%Y', 'tzuserrel');
1357 $mois = dol_print_date($daycursor, '%m', 'tzuserrel');
1358 $jour = dol_print_date($daycursor, '%d', 'tzuserrel');
1359
1360 // Loop on each day covered by action to prepare an index to show on calendar
1361 $loop = true; $j = 0;
1362 // daykey must be date that represent day box in calendar so must be a user time
1363 $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee, 'gmt');
1364 $daykeygmt = dol_mktime(0, 0, 0, $mois, $jour, $annee, 'gmt');
1365 do {
1366 //if ($event->fulldayevent) print dol_print_date($daykeygmt,'dayhour','gmt').'-'.dol_print_date($daykey,'dayhour','gmt').'-'.dol_print_date($event->date_end_in_calendar,'dayhour','gmt').' ';
1367 $eventarray[$daykey][] = $event;
1368 $daykey += 60 * 60 * 24; $daykeygmt += 60 * 60 * 24; // Add one day
1369 if (($event->fulldayevent ? $daykeygmt : $daykey) > $event->date_end_in_calendar) {
1370 $loop = false;
1371 }
1372 } while ($loop);
1373 }
1374 }
1375 }
1376 }
1377 }
1378}
1379
1380
1381
1382// Complete $eventarray with events coming from external module
1383$parameters = array(); $object = null;
1384$reshook = $hookmanager->executeHooks('getCalendarEvents', $parameters, $object, $action);
1385if (!empty($hookmanager->resArray['eventarray'])) {
1386 foreach ($hookmanager->resArray['eventarray'] as $keyDate => $events) {
1387 if (!isset($eventarray[$keyDate])) {
1388 $eventarray[$keyDate] = array();
1389 }
1390 $eventarray[$keyDate] = array_merge($eventarray[$keyDate], $events);
1391 }
1392}
1393
1394// Sort events
1395foreach ($eventarray as $keyDate => &$dateeventarray) {
1396 usort($dateeventarray, 'sort_events_by_date');
1397}
1398
1399
1400$maxnbofchar = 0;
1401$cachethirdparties = array();
1402$cachecontacts = array();
1403$cacheusers = array();
1404
1405// Define theme_datacolor array
1406$color_file = DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/theme_vars.inc.php";
1407if (is_readable($color_file)) {
1408 include $color_file;
1409}
1410if (!is_array($theme_datacolor)) {
1411 $theme_datacolor = array(array(120, 130, 150), array(200, 160, 180), array(190, 190, 220));
1412}
1413
1414$massactionbutton ='';
1415
1416print_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);
1417
1418// Show div with list of calendars
1419print $s;
1420
1421
1422if (empty($mode) || $mode == 'show_month') { // View by month
1423 $newparam = $param; // newparam is for birthday links
1424 $newparam = preg_replace('/showbirthday=/i', 'showbirthday_=', $newparam); // To avoid replacement when replace day= is done
1425 $newparam = preg_replace('/mode=show_month&?/i', '', $newparam);
1426 $newparam = preg_replace('/mode=show_week&?/i', '', $newparam);
1427 $newparam = preg_replace('/day=[0-9]+&?/i', '', $newparam);
1428 $newparam = preg_replace('/month=[0-9]+&?/i', '', $newparam);
1429 $newparam = preg_replace('/year=[0-9]+&?/i', '', $newparam);
1430 $newparam = preg_replace('/viewcal=[0-9]+&?/i', '', $newparam);
1431 $newparam = preg_replace('/showbirthday_=/i', 'showbirthday=', $newparam); // Restore correct parameter
1432 $newparam .= '&viewcal=1';
1433
1434 print '<div class="liste_titre liste_titre_bydiv centpercent">';
1435 print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid);
1436 print '</div>';
1437
1438 print '<div class="div-table-responsive-no-min sectioncalendarbymonth maxscreenheightless300">';
1439 print '<table class="centpercent noborder nocellnopadd cal_pannel cal_month">';
1440 print ' <tr class="liste_titre">';
1441 // Column title of weeks numbers
1442 echo ' <td class="center">#</td>';
1443 $i = 0;
1444 while ($i < 7) {
1445 print ' <td class="center bold uppercase tdfordaytitle'.($i == 0 ? ' borderleft' : '').'">';
1446 $numdayinweek = (($i + (isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1)) % 7);
1447 if (!empty($conf->dol_optimize_smallscreen)) {
1448 $labelshort = array(0=>'SundayMin', 1=>'MondayMin', 2=>'TuesdayMin', 3=>'WednesdayMin', 4=>'ThursdayMin', 5=>'FridayMin', 6=>'SaturdayMin');
1449 print $langs->trans($labelshort[$numdayinweek]);
1450 } else {
1451 print $langs->trans("Day".$numdayinweek);
1452 }
1453 print ' </td>'."\n";
1454 $i++;
1455 }
1456 echo ' </tr>'."\n";
1457
1458 $todayarray = dol_getdate($now, 'fast');
1459 $todaytms = dol_mktime(0, 0, 0, $todayarray['mon'], $todayarray['mday'], $todayarray['year']);
1460
1461 // In loops, tmpday contains day nb in current month (can be zero or negative for days of previous month)
1462 //var_dump($eventarray);
1463 for ($iter_week = 0; $iter_week < 6; $iter_week++) {
1464 echo " <tr>\n";
1465 // Get date of the current day, format 'yyyy-mm-dd'
1466 if ($tmpday <= 0) { // If number of the current day is in previous month
1467 $currdate0 = sprintf("%04d", $prev_year).sprintf("%02d", $prev_month).sprintf("%02d", $max_day_in_prev_month + $tmpday);
1468 } elseif ($tmpday <= $max_day_in_month) { // If number of the current day is in current month
1469 $currdate0 = sprintf("%04d", $year).sprintf("%02d", $month).sprintf("%02d", $tmpday);
1470 } else // If number of the current day is in next month
1471 {
1472 $currdate0 = sprintf("%04d", $next_year).sprintf("%02d", $next_month).sprintf("%02d", $tmpday - $max_day_in_month);
1473 }
1474 // Get week number for the targeted date '$currdate0'
1475 $numweek0 = date("W", strtotime(date($currdate0)));
1476 // Show the week number, and define column width
1477 echo ' <td class="center weeknumber opacitymedium" width="2%">'.$numweek0.'</td>';
1478
1479 for ($iter_day = 0; $iter_day < 7; $iter_day++) {
1480 if ($tmpday <= 0) {
1481 /* Show days before the beginning of the current month (previous month) */
1482 $style = 'cal_other_month cal_past';
1483 if ($iter_day == 6) {
1484 $style .= ' cal_other_month_right';
1485 }
1486 echo ' <td class="'.$style.' nowrap tdtop" width="14%">';
1487 show_day_events($db, $max_day_in_prev_month + $tmpday, $prev_month, $prev_year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam);
1488 echo " </td>\n";
1489 } elseif ($tmpday <= $max_day_in_month) {
1490 /* Show days of the current month */
1491 $curtime = dol_mktime(0, 0, 0, $month, $tmpday, $year);
1492 $style = 'cal_current_month';
1493 if ($iter_day == 6) {
1494 $style .= ' cal_current_month_right';
1495 }
1496 $today = 0;
1497 if ($todayarray['mday'] == $tmpday && $todayarray['mon'] == $month && $todayarray['year'] == $year) {
1498 $today = 1;
1499 }
1500 if ($today) {
1501 $style = 'cal_today';
1502 }
1503 if ($curtime < $todaytms) {
1504 $style .= ' cal_past';
1505 }
1506 //var_dump($todayarray['mday']."==".$tmpday." && ".$todayarray['mon']."==".$month." && ".$todayarray['year']."==".$year.' -> '.$style);
1507 echo ' <td class="'.$style.' nowrap tdtop" width="14%">';
1508 show_day_events($db, $tmpday, $month, $year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam);
1509 echo "</td>\n";
1510 } else {
1511 /* Show days after the current month (next month) */
1512 $style = 'cal_other_month';
1513 if ($iter_day == 6) {
1514 $style .= ' cal_other_month_right';
1515 }
1516 echo ' <td class="'.$style.' nowrap tdtop" width="14%">';
1517 show_day_events($db, $tmpday - $max_day_in_month, $next_month, $next_year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam);
1518 echo "</td>\n";
1519 }
1520 $tmpday++;
1521 }
1522 echo " </tr>\n";
1523 }
1524 print "</table>\n";
1525 print '</div>';
1526
1527 print '<input type="hidden" name="actionmove" value="mupdate">';
1528 print '<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($_SERVER['PHP_SELF']).'?mode=show_month&'.dol_escape_htmltag($_SERVER['QUERY_STRING']).'">';
1529 print '<input type="hidden" name="newdate" id="newdate">';
1530} elseif ($mode == 'show_week') {
1531 // View by week
1532 $newparam = $param; // newparam is for birthday links
1533 $newparam = preg_replace('/showbirthday=/i', 'showbirthday_=', $newparam); // To avoid replacement when replace day= is done
1534 $newparam = preg_replace('/mode=show_month&?/i', '', $newparam);
1535 $newparam = preg_replace('/mode=show_week&?/i', '', $newparam);
1536 $newparam = preg_replace('/day=[0-9]+&?/i', '', $newparam);
1537 $newparam = preg_replace('/month=[0-9]+&?/i', '', $newparam);
1538 $newparam = preg_replace('/year=[0-9]+&?/i', '', $newparam);
1539 $newparam = preg_replace('/viewweek=[0-9]+&?/i', '', $newparam);
1540 $newparam = preg_replace('/showbirthday_=/i', 'showbirthday=', $newparam); // Restore correct parameter
1541 $newparam .= '&viewweek=1';
1542
1543 print '<div class="liste_titre liste_titre_bydiv centpercent">';
1544 print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid);
1545 print '</div>';
1546
1547 print '<div class="div-table-responsive-no-min sectioncalendarbyweek maxscreenheightless300">';
1548 print '<table class="centpercent noborder nocellnopadd cal_pannel cal_month">';
1549 print ' <tr class="liste_titre">';
1550 $i = 0;
1551 while ($i < 7) {
1552 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";
1553 $i++;
1554 }
1555 echo " </tr>\n";
1556
1557 echo " <tr>\n";
1558
1559 for ($iter_day = 0; $iter_day < 7; $iter_day++) {
1560 // Show days of the current week
1561 $curtime = dol_time_plus_duree($firstdaytoshow, $iter_day, 'd'); // $firstdaytoshow is in timezone of server
1562 $tmpday = dol_print_date($curtime, '%d', 'tzuserrel');
1563 $tmpmonth = dol_print_date($curtime, '%m', 'tzuserrel');
1564 $tmpyear = dol_print_date($curtime, '%Y', 'tzuserrel');
1565
1566 $style = 'cal_current_month';
1567 if ($iter_day == 6) {
1568 $style .= ' cal_other_month_right';
1569 }
1570
1571 $today = 0;
1572 $todayarray = dol_getdate($now, 'fast');
1573 if ($todayarray['mday'] == $tmpday && $todayarray['mon'] == $tmpmonth && $todayarray['year'] == $tmpyear) {
1574 $today = 1;
1575 }
1576 if ($today) {
1577 $style = 'cal_today';
1578 }
1579
1580 echo ' <td class="'.$style.'" width="14%" valign="top">';
1581 show_day_events($db, $tmpday, $tmpmonth, $tmpyear, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300);
1582 echo " </td>\n";
1583 }
1584 echo " </tr>\n";
1585
1586 print "</table>\n";
1587 print '</div>';
1588
1589 echo '<input type="hidden" name="actionmove" value="mupdate">';
1590 echo '<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($_SERVER['PHP_SELF']).'?mode=show_week&'.dol_escape_htmltag($_SERVER['QUERY_STRING']).'">';
1591 echo '<input type="hidden" name="newdate" id="newdate">';
1592} else { // View by day
1593 $newparam = $param; // newparam is for birthday links
1594 $newparam = preg_replace('/mode=show_month&?/i', '', $newparam);
1595 $newparam = preg_replace('/mode=show_week&?/i', '', $newparam);
1596 $newparam = preg_replace('/viewday=[0-9]+&?/i', '', $newparam);
1597 $newparam .= '&viewday=1';
1598 // Code to show just one day
1599 $style = 'cal_current_month cal_current_month_oneday';
1600 $today = 0;
1601 $todayarray = dol_getdate($now, 'fast');
1602 if ($todayarray['mday'] == $day && $todayarray['mon'] == $month && $todayarray['year'] == $year) {
1603 $today = 1;
1604 }
1605 //if ($today) $style='cal_today';
1606
1607 $timestamp = dol_mktime(12, 0, 0, $month, $day, $year);
1608 $arraytimestamp = dol_getdate($timestamp);
1609
1610 print '<div class="liste_titre liste_titre_bydiv centpercent">';
1611 print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid);
1612 print '</div>';
1613
1614 print '<div class="div-table-responsive-no-min sectioncalendarbyday maxscreenheightless300">';
1615 echo '<table class="tagtable centpercent noborder nocellnopadd cal_pannel cal_month noborderbottom" style="margin-bottom: 5px !important;">';
1616
1617 echo ' <tr class="tagtr liste_titre">';
1618 echo ' <td class="tagtd center bold uppercase">'.$langs->trans("Day".$arraytimestamp['wday'])."</td>\n";
1619 echo " </td>\n";
1620
1621 /*
1622 echo ' <div class="tagtr">';
1623 echo ' <div class="tagtd width100"></div>';
1624 echo ' <div class="tagtd center">';
1625 echo show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, -1);
1626 echo ' </div>'."\n";
1627 echo " </div>\n";
1628 */
1629
1630 echo '</table>';
1631 print '</div>';
1632
1633 /* WIP View per hour */
1634 $useviewhour = 0;
1635 if ($useviewhour) {
1636 print '<div class="div-table-responsive-no-min borderbottom">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
1637
1638 $maxheightwin = (isset($_SESSION["dol_screenheight"]) && $_SESSION["dol_screenheight"] > 500) ? ($_SESSION["dol_screenheight"] - 200) : 660; // Also into index.php file
1639
1640 echo '<div style="max-height: '.$maxheightwin.'px;">';
1641 echo '<div class="tagtable centpercent calendarviewcontainer">';
1642
1643 $maxnbofchar = 80;
1644
1645 $tmp = explode('-', $conf->global->MAIN_DEFAULT_WORKING_HOURS);
1646 $minhour = round($tmp[0], 0);
1647 $maxhour = round($tmp[1], 0);
1648 if ($minhour > 23) {
1649 $minhour = 23;
1650 }
1651 if ($maxhour < 1) {
1652 $maxhour = 1;
1653 }
1654 if ($maxhour <= $minhour) {
1655 $maxhour = $minhour + 1;
1656 }
1657
1658 $i = 0;
1659 $j = 0;
1660 while ($i < 24) {
1661 echo ' <div class="tagtr calendarviewcontainertr">'."\n";
1662 echo ' <div class="tagtd width100 tdtop">'.dol_print_date($i * 3600, 'hour', 'gmt').'</div>';
1663 echo ' <div class="tagtd '.$style.' tdtop"></div>'."\n";
1664 echo ' </div>'."\n";
1665 $i++;
1666 $j++;
1667 }
1668
1669 echo '</div></div>';
1670
1671 show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 1);
1672
1673 print '</div>';
1674 } else {
1675 print '<div class="div-table-responsive-no-min borderbottom">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
1676
1677 show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 0);
1678
1679 print '</div>';
1680 }
1681}
1682
1683print "\n".'</form>';
1684
1685// End of page
1686llxFooter();
1687$db->close();
1688
1689
1708function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventarray, $maxprint = 0, $maxnbofchar = 16, $newparam = '', $showinfo = 0, $minheight = 60, $nonew = 0)
1709{
1710 global $user, $conf, $langs;
1711 global $action, $mode, $filter, $filtert, $status, $actioncode, $usergroup; // Filters used into search form
1712 global $theme_datacolor;
1713 global $cachethirdparties, $cachecontacts, $cacheusers, $colorindexused;
1714
1715 if ($conf->use_javascript_ajax) { // Enable the "Show more button..."
1716 $conf->global->MAIN_JS_SWITCH_AGENDA = 1;
1717 }
1718
1719 $dateint = sprintf("%04d", $year).sprintf("%02d", $month).sprintf("%02d", $day);
1720
1721 //print 'show_day_events day='.$day.' month='.$month.' year='.$year.' dateint='.$dateint;
1722
1723 print "\n";
1724
1725 $curtime = dol_mktime(0, 0, 0, $month, $day, $year);
1726 $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;
1727 $urltocreate = '';
1728 if ($user->rights->agenda->myactions->create || $user->hasRight('agenda', 'allactions', 'create')) {
1729 $newparam .= '&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$year;
1730 $hourminsec = '100000';
1731 $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 : ''));
1732 }
1733
1734 // Line with title of day
1735 print '<div id="dayevent_'.$dateint.'" class="dayevent tagtable centpercent nobordernopadding">'."\n";
1736
1737 if ($nonew <= 0) {
1738 print '<div class="tagtr cursorpointer" onclick="window.location=\''.$urltocreate.'\';"><div class="nowrap tagtd"><div class="left inline-block">';
1739 print '<a class="dayevent-aday" style="color: #666" href="'.$urltoshow.'">';
1740 if ($showinfo) {
1741 print dol_print_date($curtime, 'daytextshort');
1742 } else {
1743 print dol_print_date($curtime, '%d');
1744 }
1745 print '</a>';
1746 print '</div><div class="nowrap floatright inline-block marginrightonly">';
1747 if ($user->rights->agenda->myactions->create || $user->hasRight('agenda', 'allactions', 'create')) {
1748 print '<a class="cursoradd" href="'.$urltocreate.'">'; // Explicit link, usefull for nojs interfaces
1749 print img_picto($langs->trans("NewAction"), 'edit_add.png');
1750 print '</a>';
1751 }
1752 print '</div></div></div>'."\n";
1753 }
1754
1755 if ($nonew < 0) {
1756 print '</div>';
1757 return;
1758 }
1759
1760 // Line with td contains all div of each events
1761 print '<div class="tagtr">';
1762 print '<div class="tagtd centpercent agendacell sortable">';
1763
1764 //$curtime = dol_mktime (0, 0, 0, $month, $day, $year);
1765 $i = 0; $ireallyshown = 0; $itoshow = 0; $numother = 0; $numbirthday = 0; $numical = 0; $numicals = array();
1766 $ymd = sprintf("%04d", $year).sprintf("%02d", $month).sprintf("%02d", $day);
1767
1768 $colorindexused[$user->id] = 0; // Color index for current user (user->id) is always 0
1769 $nextindextouse = is_array($colorindexused) ?count($colorindexused) : 0; // At first run this is 0, so fist user has 0, next 1, ...
1770 //var_dump($colorindexused);
1771
1772 include_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php';
1773 $tmpholiday = new Holiday($db);
1774
1775 foreach ($eventarray as $daykey => $notused) { // daykey is the 'YYYYMMDD' to show according to user
1776 $annee = dol_print_date($daykey, '%Y', 'gmt'); // We use gmt because we want the value represented by string 'YYYYMMDD'
1777 $mois = dol_print_date($daykey, '%m', 'gmt'); // We use gmt because we want the value represented by string 'YYYYMMDD'
1778 $jour = dol_print_date($daykey, '%d', 'gmt'); // We use gmt because we want the value represented by string 'YYYYMMDD'
1779
1780 //print 'event daykey='.$daykey.' dol_print_date(daykey)='.dol_print_date($daykey, 'dayhour', 'gmt').' jour='.$jour.' mois='.$mois.' annee='.$annee."<br>\n";
1781
1782 if ($day == $jour && $month == $mois && $year == $annee) {
1783 foreach ($eventarray[$daykey] as $index => $event) {
1784 if ($i < $maxprint || $maxprint == 0 || !empty($conf->global->MAIN_JS_SWITCH_AGENDA)) {
1785 $keysofuserassigned = array_keys($event->userassigned);
1786 $ponct = ($event->date_start_in_calendar == $event->date_end_in_calendar);
1787
1788 // Define $color (Hex string like '0088FF') and $cssclass of event
1789 $color = -1; $cssclass = ''; $colorindex = -1;
1790 if (in_array($user->id, $keysofuserassigned)) {
1791 $cssclass = 'family_mytasks';
1792
1793 if (empty($cacheusers[$event->userownerid])) {
1794 $newuser = new User($db);
1795 $newuser->fetch($event->userownerid);
1796 $cacheusers[$event->userownerid] = $newuser;
1797 }
1798 //var_dump($cacheusers[$event->userownerid]->color);
1799
1800 // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event)
1801 if (!empty($cacheusers[$event->userownerid]->color)) {
1802 $color = $cacheusers[$event->userownerid]->color;
1803 }
1804 } elseif ($event->type_code == 'ICALEVENT') { // Event come from external ical file
1805 $numical++;
1806 if (!empty($event->icalname)) {
1807 if (!isset($numicals[dol_string_nospecial($event->icalname)])) {
1808 $numicals[dol_string_nospecial($event->icalname)] = 0;
1809 }
1810 $numicals[dol_string_nospecial($event->icalname)]++;
1811 }
1812
1813 $color = ($event->icalcolor ? $event->icalcolor : -1);
1814 $cssclass = (!empty($event->icalname) ? 'family_ext'.md5($event->icalname) : 'family_other');
1815 } elseif ($event->type_code == 'BIRTHDAY') {
1816 $numbirthday++;
1817 $colorindex = 2;
1818 $cssclass = 'family_birthday ';
1819 $color = sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
1820 } else {
1821 $numother++;
1822 $color = ($event->icalcolor ? $event->icalcolor : -1);
1823 $cssclass = (!empty($event->icalname) ? 'family_ext'.md5($event->icalname) : 'family_other');
1824
1825 if (empty($cacheusers[$event->userownerid])) {
1826 $newuser = new User($db);
1827 $newuser->fetch($event->userownerid);
1828 $cacheusers[$event->userownerid] = $newuser;
1829 }
1830 //var_dump($cacheusers[$event->userownerid]->color);
1831
1832 // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event)
1833 if (!empty($cacheusers[$event->userownerid]->color)) {
1834 $color = $cacheusers[$event->userownerid]->color;
1835 }
1836 }
1837
1838 if ($color < 0) { // Color was not set on user card. Set color according to color index.
1839 // Define color index if not yet defined
1840 $idusertouse = ($event->userownerid ? $event->userownerid : 0);
1841 if (isset($colorindexused[$idusertouse])) {
1842 $colorindex = $colorindexused[$idusertouse]; // Color already assigned to this user
1843 } else {
1844 $colorindex = $nextindextouse;
1845 $colorindexused[$idusertouse] = $colorindex;
1846 if (!empty($theme_datacolor[$nextindextouse + 1])) {
1847 $nextindextouse++; // Prepare to use next color
1848 }
1849 }
1850 //print '|'.($color).'='.($idusertouse?$idusertouse:0).'='.$colorindex.'<br>';
1851 // Define color
1852 $color = sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
1853 }
1854 $cssclass = $cssclass.' eventday_'.$ymd;
1855
1856 // Defined style to disable drag and drop feature
1857 if ($event->type_code == 'AC_OTH_AUTO') {
1858 $cssclass .= " unmovable";
1859 } elseif ($event->type_code == 'HOLIDAY') {
1860 $cssclass .= " unmovable";
1861 } elseif ($event->type_code == 'BIRTHDAY') {
1862 $cssclass .= " unmovable";
1863 } elseif ($event->type_code == 'ICALEVENT') {
1864 $cssclass .= " unmovable";
1865 } 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)) {
1866 // If the event is on several days
1867 $tmpyearend = dol_print_date($event->date_start_in_calendar, '%Y', 'tzuserrel');
1868 $tmpmonthend = dol_print_date($event->date_start_in_calendar, '%m', 'tzuserrel');
1869 $tmpdayend = dol_print_date($event->date_start_in_calendar, '%d', 'tzuserrel');
1870 //var_dump($tmpyearend.' '.$tmpmonthend.' '.$tmpdayend);
1871 if ($tmpyearend != $annee || $tmpmonthend != $mois || $tmpdayend != $jour) {
1872 $cssclass .= " unmovable unmovable-mustusefirstdaytodrag";
1873 } else {
1874 $cssclass .= ' movable cursormove';
1875 }
1876 } else {
1877 if ($user->hasRight('agenda', 'allactions', 'create') ||
1878 (($event->authorid == $user->id || $event->userownerid == $user->id) && $user->hasRight('agenda', 'myactions', 'create'))) {
1879 $cssclass .= " movable cursormove";
1880 } else {
1881 $cssclass .= " unmovable";
1882 }
1883 }
1884
1885 $h = ''; $nowrapontd = 1;
1886 if ($mode == 'show_day') {
1887 $h = 'height: 100%; '; $nowrapontd = 0;
1888 }
1889 if ($mode == 'show_week') {
1890 $h = 'height: 100%; '; $nowrapontd = 0;
1891 }
1892
1893 // Show event box
1894 print "\n";
1895 print '<!-- start event '.$i.' -->'."\n";
1896
1897 $morecss = '';
1898 if ($maxprint && $ireallyshown >= $maxprint) {
1899 $morecss = 'showifmore';
1900 }
1901 if ($event->type == 'birthdate' && !GETPOST('check_birthday')) {
1902 $morecss = 'hidden';
1903 }
1904 if ($event->type == 'holiday' && !GETPOST('check_holiday')) {
1905 $morecss = 'hidden';
1906 }
1907 if ($morecss != 'hidden') {
1908 $itoshow++;
1909 }
1910 if ($morecss != 'showifmore' && $morecss != 'hidden') {
1911 $ireallyshown++;
1912 }
1913 //var_dump($event->type.' - '.$morecss.' - '.$cssclass.' - '.$i.' - '.$ireallyshown.' - '.$itoshow);
1914
1915 print '<div id="event_'.$ymd.'_'.$i.'" class="event family_'.$event->type.' '.$cssclass.($morecss ? ' '.$morecss : '').'"';
1916 //print ' style="height: 100px;';
1917 //print ' position: absolute; top: 40px; width: 50%;';
1918 //print '"';
1919 print '>';
1920
1921 //var_dump($event->userassigned);
1922 //var_dump($event->transparency);
1923 print '<table class="centpercent cal_event';
1924 print (empty($event->transparency) ? ' cal_event_notbusy' : ' cal_event_busy');
1925 //if (empty($event->transparency) && empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) print ' opacitymedium'; // Not busy
1926 print '" style="'.$h;
1927 $colortouse = $color;
1928 // If colortouse is similar than background, we force to change it.
1929 if (empty($event->transparency) && empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) {
1930 print 'background: #f0f0f0;';
1931 print 'border-left: 5px solid #'.$colortouse.';';
1932 } else {
1933 print 'background: #f0f0f0;';
1934 print 'border-left: 5px solid #'.dol_color_minus($colortouse, -3).';';
1935 //print 'background: -webkit-gradient(linear, left top, left bottom, from(#'.dol_color_minus($colortouse, -3).'), to(#'.dol_color_minus($colortouse, -1).'));';
1936 }
1937 //print 'background: #'.$colortouse.';';
1938 //print 'background: -webkit-gradient(linear, left top, left bottom, from(#'.dol_color_minus($color, -3).'), to(#'.dol_color_minus($color, -1).'));';
1939 //if (!empty($event->transparency)) print 'background: #'.$color.'; background: -webkit-gradient(linear, left top, left bottom, from(#'.$color.'), to(#'.dol_color_minus($color,1).'));';
1940 //else print 'background-color: transparent !important; background: none; border: 1px solid #bbb;';
1941 //print ' -moz-border-radius:4px;"';
1942 //print 'border: 1px solid #ccc" width="100%"';
1943 print '">';
1944 print '<tr>';
1945 print '<td class="tdoverflow nobottom centpercent '.($nowrapontd ? 'nowrap ' : '').'cal_event'.($event->type_code == 'BIRTHDAY' ? ' cal_event_birthday' : '').'">';
1946
1947 $daterange = '';
1948
1949 if ($event->type_code == 'BIRTHDAY') {
1950 // It's birthday calendar
1951 $picb = '<i class="fas fa-birthday-cake inline-block"></i>';
1952 //$pice = '<i class="fas fa-briefcase inline-block"></i>';
1953 //$typea = ($objp->typea == 'birth') ? $picb : $pice;
1954 //var_dump($event);
1955 print $picb.' '.$langs->trans("Birthday").'<br>';
1956 //print img_picto($langs->trans("Birthday"), 'birthday-cake').' ';
1957
1958 $tmpid = $event->id;
1959 if (empty($cachecontacts[$tmpid])) {
1960 $newcontact = new Contact($db);
1961 $newcontact->fetch($tmpid);
1962 $cachecontact[$tmpid] = $newcontact;
1963 }
1964 print $cachecontact[$tmpid]->getNomUrl(1);
1965
1966 //$event->picto = 'birthday-cake';
1967 //print $event->getNomUrl(1, $maxnbofchar, 'cal_event', 'birthday', 'contact');
1968 /*$listofcontacttoshow = '';
1969 $listofcontacttoshow .= '<br>'.$cacheusers[$tmpid]->getNomUrl(-1, '', 0, 0, 0, 0, '', 'paddingright valignmiddle');
1970 print $listofcontacttoshow;
1971 */
1972 } elseif ($event->type_code == 'HOLIDAY') {
1973 // It's holiday calendar
1974 $tmpholiday->fetch($event->id);
1975
1976 print $tmpholiday->getNomUrl(1);
1977
1978 $tmpid = $tmpholiday->fk_user;
1979 if (empty($cacheusers[$tmpid])) {
1980 $newuser = new User($db);
1981 $newuser->fetch($tmpid);
1982 $cacheusers[$tmpid] = $newuser;
1983 }
1984
1985 $listofusertoshow = '';
1986 $listofusertoshow .= '<br>'.$cacheusers[$tmpid]->getNomUrl(-1, '', 0, 0, 0, 0, '', 'paddingright valignmiddle');
1987 print $listofusertoshow;
1988 } else {
1989 // Other calendar
1990 if (empty($event->fulldayevent)) {
1991 //print $event->getNomUrl(2).' ';
1992 }
1993
1994 // Date
1995 if (empty($event->fulldayevent)) {
1996 // Show hours (start ... end)
1997 $tmpyearstart = dol_print_date($event->date_start_in_calendar, '%Y', 'tzuserrel');
1998 $tmpmonthstart = dol_print_date($event->date_start_in_calendar, '%m', 'tzuserrel');
1999 $tmpdaystart = dol_print_date($event->date_start_in_calendar, '%d', 'tzuserrel');
2000 $tmpyearend = dol_print_date($event->date_end_in_calendar, '%Y', 'tzuserrel');
2001 $tmpmonthend = dol_print_date($event->date_end_in_calendar, '%m', 'tzuserrel');
2002 $tmpdayend = dol_print_date($event->date_end_in_calendar, '%d', 'tzuserrel');
2003
2004 // Hour start
2005 if ($tmpyearstart == $annee && $tmpmonthstart == $mois && $tmpdaystart == $jour) {
2006 $daterange .= dol_print_date($event->date_start_in_calendar, 'hour', 'tzuserrel');
2007 if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) {
2008 if ($tmpyearstart == $tmpyearend && $tmpmonthstart == $tmpmonthend && $tmpdaystart == $tmpdayend) {
2009 $daterange .= '-';
2010 }
2011 //else
2012 //print '...';
2013 }
2014 }
2015 if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) {
2016 if ($tmpyearstart != $tmpyearend || $tmpmonthstart != $tmpmonthend || $tmpdaystart != $tmpdayend) {
2017 $daterange .= '...';
2018 }
2019 }
2020 // Hour end
2021 if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) {
2022 if ($tmpyearend == $annee && $tmpmonthend == $mois && $tmpdayend == $jour) {
2023 $daterange .= dol_print_date($event->date_end_in_calendar, 'hour', 'tzuserrel');
2024 }
2025 }
2026 } else {
2027 if ($showinfo) {
2028 print $langs->trans("EventOnFullDay")."<br>\n";
2029 }
2030 }
2031
2032 // Show title
2033 $titletoshow = $daterange;
2034 $titletoshow .= ($titletoshow ? ' ' : '').dol_escape_htmltag($event->label ? $event->label : $event->libelle);
2035
2036 if ($event->type_code != 'ICALEVENT') {
2037 $savlabel = $event->label ? $event->label : $event->libelle;
2038 $event->label = $titletoshow;
2039 $event->libelle = $titletoshow; // deprecatd
2040 // Note: List of users are inside $event->userassigned. Link may be clickable depending on permissions of user.
2041 $titletoshow = (($event->type_picto || $event->type_code) ? $event->getTypePicto() : '');
2042 $titletoshow .= $event->getNomUrl(0, $maxnbofchar, 'cal_event cal_event_title', '', 0, 0);
2043 $event->label = $savlabel;
2044 $event->libelle = $savlabel;
2045 }
2046
2047 // Loop on each assigned user
2048 $listofusertoshow = '';
2049 $posuserassigned = 0;
2050 foreach ($event->userassigned as $tmpid => $tmpdata) {
2051 if (!$posuserassigned && $titletoshow) {
2052 $listofusertoshow .= '<br>';
2053 }
2054 $posuserassigned++;
2055 if (empty($cacheusers[$tmpid])) {
2056 $newuser = new User($db);
2057 $newuser->fetch($tmpid);
2058 $cacheusers[$tmpid] = $newuser;
2059 }
2060
2061 $listofusertoshow .= $cacheusers[$tmpid]->getNomUrl(-3, '', 0, 0, 0, 0, '', 'valignmiddle');
2062 }
2063
2064 print $titletoshow;
2065 print $listofusertoshow;
2066
2067 if ($event->type_code == 'ICALEVENT') {
2068 print '<br>('.dol_trunc($event->icalname, $maxnbofchar).')';
2069 }
2070
2071 $thirdparty_id = ($event->socid > 0 ? $event->socid : ((is_object($event->societe) && $event->societe->id > 0) ? $event->societe->id : 0));
2072 $contact_id = ($event->contact_id > 0 ? $event->contact_id : ((is_object($event->contact) && $event->contact->id > 0) ? $event->contact->id : 0));
2073
2074 // If action related to company / contact
2075 $linerelatedto = '';
2076 if ($thirdparty_id > 0) {
2077 if (!isset($cachethirdparties[$thirdparty_id]) || !is_object($cachethirdparties[$thirdparty_id])) {
2078 $thirdparty = new Societe($db);
2079 $thirdparty->fetch($thirdparty_id);
2080 $cachethirdparties[$thirdparty_id] = $thirdparty;
2081 } else {
2082 $thirdparty = $cachethirdparties[$thirdparty_id];
2083 }
2084 if (!empty($thirdparty->id)) {
2085 $linerelatedto .= $thirdparty->getNomUrl(1, '', 0);
2086 }
2087 }
2088 if (!empty($contact_id) && $contact_id > 0) {
2089 if (empty($cachecontacts[$contact_id]) || !is_object($cachecontacts[$contact_id])) {
2090 $contact = new Contact($db);
2091 $contact->fetch($contact_id);
2092 $cachecontacts[$contact_id] = $contact;
2093 } else {
2094 $contact = $cachecontacts[$contact_id];
2095 }
2096 if ($linerelatedto) {
2097 $linerelatedto .= '&nbsp;';
2098 }
2099 if (!empty($contact->id)) {
2100 $linerelatedto .= $contact->getNomUrl(1, '', 0);
2101 }
2102 }
2103 if (!empty($event->fk_element) && $event->fk_element > 0 && !empty($event->elementtype) && !empty($conf->global->AGENDA_SHOW_LINKED_OBJECT)) {
2104 include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
2105 if ($linerelatedto) {
2106 $linerelatedto .= '<br>';
2107 }
2108 $linerelatedto .= dolGetElementUrl($event->fk_element, $event->elementtype, 1);
2109 }
2110 if ($linerelatedto) {
2111 print ' '.$linerelatedto;
2112 }
2113 }
2114
2115 // Show location
2116 if ($showinfo) {
2117 if ($event->location) {
2118 print '<br>';
2119 print $langs->trans("Location").': '.$event->location;
2120 }
2121 }
2122
2123 print '</td>';
2124 // Status - Percent
2125 $withstatus = 0;
2126 if ($event->type_code != 'BIRTHDAY' && $event->type_code != 'ICALEVENT') {
2127 $withstatus = 1;
2128 if ($event->percentage >= 0) {
2129 $withstatus = 2;
2130 }
2131 }
2132 print '<td class="nobottom right nowrap cal_event_right'.($withstatus >= 2 ? ' cal_event_right_status' : '').'">';
2133 if ($withstatus) {
2134 print $event->getLibStatut(3, 1);
2135 } else {
2136 print '&nbsp;';
2137 }
2138 print '</td></tr></table>';
2139 print '</div><!-- end event '.$i.' -->'."\n";
2140
2141 $i++;
2142 } else {
2143 print '<a href="'.DOL_URL_ROOT.'/comm/action/index.php?mode='.$mode.'&maxprint=0&month='.((int) $monthshown).'&year='.((int) $year);
2144 print ($status ? '&status='.$status : '').($filter ? '&filter='.urlencode($filter) : '');
2145 print ($filtert ? '&search_filtert='.urlencode($filtert) : '');
2146 print ($usergroup ? '&search_usergroup='.urlencode($usergroup) : '');
2147 print ($actioncode != '' ? '&search_actioncode='.urlencode($actioncode) : '');
2148 print '">'.img_picto("all", "1downarrow_selected.png").' ...';
2149 print ' +'.(count($eventarray[$daykey]) - $maxprint);
2150 print '</a>';
2151 break;
2152 //$ok=false; // To avoid to show twice the link
2153 }
2154 }
2155
2156 break;
2157 }
2158 }
2159 if (!$i) { // No events
2160 print '&nbsp;';
2161 }
2162
2163 if (!empty($conf->global->MAIN_JS_SWITCH_AGENDA) && $itoshow > $ireallyshown && $maxprint) {
2164 print '<div class="center cursorpointer" id="more_'.$ymd.'">'.img_picto("All", "angle-double-down", 'class="warning"').' +'.($itoshow - $ireallyshown).'</div>';
2165 //print ' +'.(count($eventarray[$daykey])-$maxprint);
2166
2167 print '<script type="text/javascript">'."\n";
2168 print 'jQuery(document).ready(function () {'."\n";
2169 print ' var open=0;'."\n";
2170 print ' jQuery("#more_'.$ymd.'").click(function() { console.log("Click on showmore for '.$ymd.'"); reinit_day_'.$ymd.'(); event.stopImmediatePropagation(); });'."\n";
2171 print ' function reinit_day_'.$ymd.'() {'."\n";
2172 print ' jQuery(".eventday_'.$ymd.'.showifmore").toggle();'."\n";
2173 print ' open = open + 1; if (open > 1) { open = 0; }'."\n";
2174 print ' if (open) { ';
2175 print ' jQuery("#more_'.$ymd.'").html(\''.img_picto("All", "angle-double-up", 'class="warning"').'\');'."\n";
2176 print ' } else { ';
2177 print ' jQuery("#more_'.$ymd.'").html(\''.img_picto("All", "angle-double-down", 'class="warning"').' +'.($itoshow - $ireallyshown).'\');'."\n";
2178 print ' }'."\n";
2179 print ' }'."\n";
2180 print '});'."\n";
2181 print '</script>'."\n";
2182 }
2183
2184 print '</div></div>'; // td tr
2185
2186 print '</div>'; // table
2187 print "\n";
2188}
2189
2190
2199function dol_color_minus($color, $minus, $minusunit = 16)
2200{
2201 $newcolor = $color;
2202 if ($minusunit == 16) {
2203 $newcolor[0] = dechex(max(min(hexdec($newcolor[0]) - $minus, 15), 0));
2204 $newcolor[2] = dechex(max(min(hexdec($newcolor[2]) - $minus, 15), 0));
2205 $newcolor[4] = dechex(max(min(hexdec($newcolor[4]) - $minus, 15), 0));
2206 } else {
2207 // Not yet implemented
2208 }
2209 return $newcolor;
2210}
2211
2219function sort_events_by_date($a, $b)
2220{
2221 // Sort holidays at first
2222 if ($a->type_code === 'HOLIDAY') {
2223 return -1;
2224 }
2225 if ($b->type_code === 'HOLIDAY') {
2226 return 1;
2227 }
2228
2229 // datep => Event start time
2230 // datef => Event end time
2231
2232 // Events have different start time
2233 if ($a->datep !== $b->datep) {
2234 return $a->datep - $b->datep;
2235 }
2236
2237 // Events have same start time and no end time
2238 if ((!is_numeric($b->datef)) || (!is_numeric($a->datef))) {
2239 return sort_events_by_percentage($a, $b);
2240 }
2241
2242 // Events have the same start time and same end time
2243 if ($b->datef === $a->datef) {
2244 return sort_events_by_percentage($a, $b);
2245 }
2246
2247 // Events have the same start time, but have different end time -> longest event first
2248 return $b->datef - $a->datef;
2249}
2250
2258function sort_events_by_percentage($a, $b)
2259{
2260 // Sort events with no percentage before each other
2261 // (usefull to sort holidays, sick days or similar on the top)
2262
2263 if ($a->percentage < 0) {
2264 return -1;
2265 }
2266
2267 if ($b->percentage < 0) {
2268 return 1;
2269 }
2270
2271 return $b->percentage - $a->percentage;
2272}
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.
Definition wrapper.php:56
llxFooter()
Empty footer.
Definition wrapper.php:70
Class to manage agenda events (actions)
Class to manage contact/addresses.
Class to manage generation of HTML components Only common components must be here.
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)
Show event of a particular day.
Definition index.php:1708
dol_get_prev_month($month, $year)
Return previous month.
Definition date.lib.php:496
dol_get_next_day($day, $month, $year)
Return next day.
Definition date.lib.php:481
dol_get_next_week($day, $week, $month, $year)
Return next week.
Definition date.lib.php:555
dol_get_first_day_week($day, $month, $year, $gm=false)
Return first day of week for a date.
Definition date.lib.php:652
dol_get_prev_day($day, $month, $year)
Return previous day.
Definition date.lib.php:465
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
Definition date.lib.php:577
dol_get_next_month($month, $year)
Return next month.
Definition date.lib.php:515
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
Definition date.lib.php:122
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...
Definition date.lib.php:409
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
Definition date.lib.php:596
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 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...
rtl background position
conf($dolibarr_main_document_root)
Load conf file (file must exists)
Definition inc.php:400
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.