dolibarr  19.0.0-dev
peruser.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-2014 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) 2018-2019 Frédéric France <frederic.france@netlogic.fr>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program. If not, see <https://www.gnu.org/licenses/>.
22  */
23 
24 
31 // Load Dolibarr environment
32 require '../../main.inc.php';
33 require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
34 require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
35 require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
36 require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php';
37 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
38 require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
39 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
40 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
41 
42 
43 if (!isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) {
44  $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW = 3;
45 }
46 
47 $action = GETPOST('action', 'aZ09');
48 
49 $disabledefaultvalues = GETPOST('disabledefaultvalues', 'int');
50 
51 $filter = GETPOST("search_filter", 'alpha', 3) ? GETPOST("search_filter", 'alpha', 3) : GETPOST("filter", 'alpha', 3);
52 $filtert = GETPOST("search_filtert", "int", 3) ? GETPOST("search_filtert", "int", 3) : GETPOST("filtert", "int", 3);
53 $usergroup = GETPOST("search_usergroup", "int", 3) ? GETPOST("search_usergroup", "int", 3) : GETPOST("usergroup", "int", 3);
54 //if (! ($usergroup > 0) && ! ($filtert > 0)) $filtert = $user->id;
55 //$showbirthday = empty($conf->use_javascript_ajax)?GETPOST("showbirthday","int"):1;
56 $showbirthday = 0;
57 
58 // If not choice done on calendar owner, we filter on user.
59 /*if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS))
60 {
61  $filtert = $user->id;
62 }*/
63 
64 $sortfield = GETPOST('sortfield', 'aZ09comma');
65 $sortorder = GETPOST('sortorder', 'aZ09comma');
66 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
67 if (empty($page) || $page == -1) {
68  $page = 0;
69 } // If $page is not defined, or '' or -1
70 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
71 $offset = $limit * $page;
72 if (!$sortorder) {
73  $sortorder = "ASC";
74 }
75 if (!$sortfield) {
76  $sortfield = "a.datec";
77 }
78 
79 $socid = GETPOST("search_socid", "int") ?GETPOST("search_socid", "int") : GETPOST("socid", "int");
80 if ($user->socid) {
81  $socid = $user->socid;
82 }
83 if ($socid < 0) {
84  $socid = '';
85 }
86 
87 $canedit = 1;
88 if (!$user->hasRight('agenda', 'myactions', 'read')) {
90 }
91 if (!$user->hasRight('agenda', 'allactions', 'read')) {
92  $canedit = 0;
93 }
94 if (!$user->hasRight('agenda', 'allactions', 'read') || $filter == 'mine') { // If no permission to see all, we show only affected to me
95  $filtert = $user->id;
96 }
97 
98 $mode = 'show_peruser';
99 $resourceid = GETPOST("search_resourceid", "int") ?GETPOST("search_resourceid", "int") : GETPOST("resourceid", "int");
100 $year = GETPOST("year", "int") ?GETPOST("year", "int") : date("Y");
101 $month = GETPOST("month", "int") ?GETPOST("month", "int") : date("m");
102 $week = GETPOST("week", "int") ?GETPOST("week", "int") : date("W");
103 $day = GETPOST("day", "int") ?GETPOST("day", "int") : date("d");
104 $pid = GETPOSTISSET("search_projectid") ? GETPOST("search_projectid", "int", 3) : GETPOST("projectid", "int", 3);
105 $status = GETPOSTISSET("search_status") ? GETPOST("search_status", 'aZ09') : GETPOST("status", 'aZ09'); // status may be 0, 50, 100, 'todo', 'na' or -1
106 $type = GETPOSTISSET("search_type") ? GETPOST("search_type", 'alpha') : GETPOST("type", 'alpha');
107 $maxprint = ((GETPOST("maxprint", 'int') != '') ?GETPOST("maxprint", 'int') : $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW);
108 $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
109 // Set actioncode (this code must be same for setting actioncode into peruser, listacton and index)
110 if (GETPOST('search_actioncode', 'array:aZ09')) {
111  $actioncode = GETPOST('search_actioncode', 'array:aZ09', 3);
112  if (!count($actioncode)) {
113  $actioncode = '0';
114  }
115 } else {
116  $actioncode = GETPOST("search_actioncode", "alpha", 3) ?GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode", "alpha") == '0' ? '0' : ((empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) || $disabledefaultvalues) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE));
117 }
118 
119 $dateselect = dol_mktime(0, 0, 0, GETPOST('dateselectmonth', 'int'), GETPOST('dateselectday', 'int'), GETPOST('dateselectyear', 'int'));
120 if ($dateselect > 0) {
121  $day = GETPOST('dateselectday', 'int');
122  $month = GETPOST('dateselectmonth', 'int');
123  $year = GETPOST('dateselectyear', 'int');
124 }
125 
126 $tmp = empty($conf->global->MAIN_DEFAULT_WORKING_HOURS) ? '9-18' : $conf->global->MAIN_DEFAULT_WORKING_HOURS;
127 $tmp = str_replace(' ', '', $tmp); // FIX 7533
128 $tmparray = explode('-', $tmp);
129 $begin_h = GETPOST('begin_h', 'int') != '' ? GETPOST('begin_h', 'int') : ($tmparray[0] != '' ? $tmparray[0] : 9);
130 $end_h = GETPOST('end_h', 'int') ? GETPOST('end_h', 'int') : ($tmparray[1] != '' ? $tmparray[1] : 18);
131 if ($begin_h < 0 || $begin_h > 23) {
132  $begin_h = 9;
133 }
134 if ($end_h < 1 || $end_h > 24) {
135  $end_h = 18;
136 }
137 if ($end_h <= $begin_h) {
138  $end_h = $begin_h + 1;
139 }
140 
141 $tmp = empty($conf->global->MAIN_DEFAULT_WORKING_DAYS) ? '1-5' : $conf->global->MAIN_DEFAULT_WORKING_DAYS;
142 $tmp = str_replace(' ', '', $tmp); // FIX 7533
143 $tmparray = explode('-', $tmp);
144 $begin_d = GETPOST('begin_d', 'int') ?GETPOST('begin_d', 'int') : ($tmparray[0] != '' ? $tmparray[0] : 1);
145 $end_d = GETPOST('end_d', 'int') ?GETPOST('end_d', 'int') : ($tmparray[1] != '' ? $tmparray[1] : 5);
146 if ($begin_d < 1 || $begin_d > 7) {
147  $begin_d = 1;
148 }
149 if ($end_d < 1 || $end_d > 7) {
150  $end_d = 7;
151 }
152 if ($end_d < $begin_d) {
153  $end_d = $begin_d + 1;
154 }
155 
156 if ($status == '' && !GETPOSTISSET('search_status')) {
157  $status = ((empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) || $disabledefaultvalues) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS);
158 }
159 
160 if (empty($mode) && !GETPOSTISSET('mode')) {
161  $mode = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW);
162 }
163 
164 if (GETPOST('viewcal', 'alpha') && $mode != 'show_day' && $mode != 'show_week' && $mode != 'show_peruser') {
165  $mode = 'show_month'; $day = '';
166 } // View by month
167 if (GETPOST('viewweek', 'alpha') || $mode == 'show_week') {
168  $mode = 'show_week'; $week = ($week ? $week : date("W")); $day = ($day ? $day : date("d"));
169 } // View by week
170 if (GETPOST('viewday', 'alpha') || $mode == 'show_day') {
171  $mode = 'show_day'; $day = ($day ? $day : date("d"));
172 } // View by day
173 
174 $object = new ActionComm($db);
175 
176 // Load translation files required by the page
177 $langs->loadLangs(array('users', 'agenda', 'other', 'commercial'));
178 
179 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
180 $hookmanager->initHooks(array('agenda'));
181 
182 $result = restrictedArea($user, 'agenda', 0, '', 'myactions');
183 if ($user->socid && $socid) {
184  $result = restrictedArea($user, 'societe', $socid);
185 }
186 
187 $search_status = $status;
188 
189 
190 /*
191  * Actions
192  */
193 
194 /*
195 if ($action == 'delete_action' && $user->rights->agenda->delete) {
196  $event = new ActionComm($db);
197  $event->fetch($actionid);
198  $event->fetch_optionals();
199  $event->fetch_userassigned();
200  $event->oldcopy = dol_clone($event);
201 
202  $result = $event->delete();
203 }
204 */
205 
206 
207 /*
208  * View
209  */
210 
211 $parameters = array(
212  'socid' => $socid,
213  'status' => $status,
214  'year' => $year,
215  'month' => $month,
216  'day' => $day,
217  'type' => $type,
218  'maxprint' => $maxprint,
219  'filter' => $filter,
220  'filtert' => $filtert,
221  'showbirthday' => $showbirthday,
222  'canedit' => $canedit,
223  'optioncss' => $optioncss,
224  'actioncode' => $actioncode,
225  'pid' => $pid,
226  'resourceid' => $resourceid,
227  'usergroup' => $usergroup,
228 );
229 $reshook = $hookmanager->executeHooks('beforeAgendaPerUser', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
230 if ($reshook < 0) {
231  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
232 }
233 
234 $form = new Form($db);
235 $companystatic = new Societe($db);
236 
237 $help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:M&oacute;dulo_Agenda|DE:Modul_Terminplanung';
238 llxHeader('', $langs->trans("Agenda"), $help_url);
239 
240 $now = dol_now();
241 $nowarray = dol_getdate($now);
242 $nowyear = $nowarray['year'];
243 $nowmonth = $nowarray['mon'];
244 $nowday = $nowarray['mday'];
245 
246 
247 // Define list of all external calendars (global setup)
248 $listofextcals = array();
249 
250 $prev = dol_get_first_day_week($day, $month, $year);
251 $first_day = $prev['first_day'];
252 $first_month = $prev['first_month'];
253 $first_year = $prev['first_year'];
254 
255 $week = $prev['week'];
256 
257 $day = (int) $day;
258 $next = dol_get_next_week($day, $week, $month, $year);
259 $next_year = $next['year'];
260 $next_month = $next['month'];
261 $next_day = $next['day'];
262 
263 $max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year));
264 
265 $tmpday = $first_day;
266 //print 'xx'.$prev_year.'-'.$prev_month.'-'.$prev_day;
267 //print 'xx'.$next_year.'-'.$next_month.'-'.$next_day;
268 
269 $title = $langs->trans("DoneAndToDoActions");
270 if ($status == 'done') {
271  $title = $langs->trans("DoneActions");
272 }
273 if ($status == 'todo') {
274  $title = $langs->trans("ToDoActions");
275 }
276 
277 $param = '';
278 if ($actioncode || GETPOSTISSET('search_actioncode')) {
279  if (is_array($actioncode)) {
280  foreach ($actioncode as $str_action) {
281  $param .= "&search_actioncode[]=".urlencode($str_action);
282  }
283  } else {
284  $param .= "&search_actioncode=".urlencode($actioncode);
285  }
286 }
287 if ($resourceid > 0) {
288  $param .= "&search_resourceid=".urlencode($resourceid);
289 }
290 
291 if ($status || GETPOSTISSET('status') || GETPOSTISSET('search_status')) {
292  $param .= "&search_status=".urlencode($status);
293 }
294 if ($filter) {
295  $param .= "&search_filter=".urlencode($filter);
296 }
297 if ($filtert) {
298  $param .= "&search_filtert=".urlencode($filtert);
299 }
300 if ($usergroup > 0) {
301  $param .= "&search_usergroup=".urlencode($usergroup);
302 }
303 if ($socid > 0) {
304  $param .= "&search_socid=".urlencode($socid);
305 }
306 if ($showbirthday) {
307  $param .= "&search_showbirthday=1";
308 }
309 if ($pid) {
310  $param .= "&search_projectid=".urlencode($pid);
311 }
312 if ($type) {
313  $param .= "&search_type=".urlencode($type);
314 }
315 if ($mode != 'show_peruser') {
316  $param .= '&mode='.urlencode($mode);
317 }
318 if ($begin_h != '') {
319  $param .= '&begin_h='.urlencode($begin_h);
320 }
321 if ($end_h != '') {
322  $param .= '&end_h='.urlencode($end_h);
323 }
324 if ($begin_d != '') {
325  $param .= '&begin_d='.urlencode($begin_d);
326 }
327 if ($end_d != '') {
328  $param .= '&end_d='.urlencode($end_d);
329 }
330 $param .= "&maxprint=".urlencode($maxprint);
331 
332 $paramnoactionodate = $param;
333 
334 $prev = dol_get_first_day_week($day, $month, $year);
335 //print "day=".$day." month=".$month." year=".$year;
336 //var_dump($prev); exit;
337 $prev_year = $prev['prev_year'];
338 $prev_month = $prev['prev_month'];
339 $prev_day = $prev['prev_day'];
340 $first_day = $prev['first_day'];
341 $first_month = $prev['first_month'];
342 $first_year = $prev['first_year'];
343 
344 $week = $prev['week'];
345 
346 $day = (int) $day;
347 $next = dol_get_next_week($first_day, $week, $first_month, $first_year);
348 $next_year = $next['year'];
349 $next_month = $next['month'];
350 $next_day = $next['day'];
351 
352 // Define firstdaytoshow and lastdaytoshow. Warning: lastdaytoshow is last second to show + 1
353 // $firstdaytoshow and lastdaytoshow become a gmt dates to use to search/compare because first_xxx are in tz idea and we used tzuserrel
354 $firstdaytoshow = dol_mktime(0, 0, 0, $first_month, $first_day, $first_year, 'tzuserrel');
355 $nb_weeks_to_show = (!empty($conf->global->AGENDA_NB_WEEKS_IN_VIEW_PER_USER)) ? ((int) $conf->global->AGENDA_NB_WEEKS_IN_VIEW_PER_USER * 7) : 7;
356 $lastdaytoshow = dol_time_plus_duree($firstdaytoshow, $nb_weeks_to_show, 'd');
357 //print $firstday.'-'.$first_month.'-'.$first_year;
358 //print dol_print_date($firstdaytoshow, 'dayhour', 'gmt');
359 //print dol_print_date($lastdaytoshow,'dayhour', 'gmt');
360 
361 $max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year, 'gmt'));
362 
363 $tmpday = $first_day;
364 $picto = 'calendarweek';
365 
366 // Show navigation bar
367 $nav = '<div class="navselectiondate inline-block nowraponall">';
368 $nav .= "<a href=\"?year=".$prev_year."&amp;month=".$prev_month."&amp;day=".$prev_day.$param."\"><i class=\"fa fa-chevron-left\" title=\"".dol_escape_htmltag($langs->trans("Previous"))."\"></i></a> &nbsp; \n";
369 $nav .= " <span id=\"month_name\">".dol_print_date(dol_mktime(0, 0, 0, $first_month, $first_day, $first_year), "%Y").", ".$langs->trans("Week")." ".$week;
370 $nav .= " </span>\n";
371 $nav .= " &nbsp; <a href=\"?year=".$next_year."&amp;month=".$next_month."&amp;day=".$next_day.$param."\"><i class=\"fa fa-chevron-right\" title=\"".dol_escape_htmltag($langs->trans("Next"))."\"></i></a>\n";
372 if (empty($conf->dol_optimize_smallscreen)) {
373  $nav .= " &nbsp; <a href=\"?year=".$nowyear."&amp;month=".$nowmonth."&amp;day=".$nowday.$param.'" class="datenowlink">'.$langs->trans("Today").'</a> ';
374 }
375 $nav .= '</div>';
376 $nav .= $form->selectDate($dateselect, 'dateselect', 0, 0, 1, '', 1, 0);
377 $nav .= ' <button type="submit" class="liste_titre button_search" name="button_search_x" value="x"><span class="fa fa-search"></span></button>';
378 
379 // Must be after the nav definition
380 $param .= '&year='.urlencode($year).'&month='.urlencode($month).($day ? '&day='.urlencode($day) : '');
381 //print 'x'.$param;
382 
383 
384 $paramnoaction = preg_replace('/action=[a-z_]+/', '', $param);
385 
386 $head = calendars_prepare_head($paramnoaction);
387 
388 print '<form method="POST" id="searchFormList" class="listactionsfilter" action="'.$_SERVER["PHP_SELF"].'">'."\n";
389 
390 $showextcals = $listofextcals;
391 // Legend
392 if ($conf->use_javascript_ajax) {
393  $s = '';
394  $s .= '<script type="text/javascript">'."\n";
395  $s .= 'jQuery(document).ready(function () {'."\n";
396  $s .= 'jQuery("#check_mytasks").click(function() { jQuery(".family_mytasks").toggle(); jQuery(".family_other").toggle(); });'."\n";
397  $s .= 'jQuery("#check_birthday").click(function() { jQuery(".family_birthday").toggle(); });'."\n";
398  $s .= 'jQuery(".family_birthday").toggle();'."\n";
399  if ($mode == "show_week" || $mode == "show_month" || empty($mode)) {
400  $s .= 'jQuery( "td.sortable" ).sortable({connectWith: ".sortable",placeholder: "ui-state-highlight",items: "div:not(.unsortable)", receive: function( event, ui ) {';
401  }
402  $s .= '});'."\n";
403  $s .= '</script>'."\n";
404  if (!empty($conf->use_javascript_ajax)) {
405  $s .= '<div class="nowrap clear float"><input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> '.$langs->trans("LocalAgenda").' &nbsp; </div>';
406  if (is_array($showextcals) && count($showextcals) > 0) {
407  foreach ($showextcals as $val) {
408  $htmlname = md5($val['name']);
409  $s .= '<script type="text/javascript">'."\n";
410  $s .= 'jQuery(document).ready(function () {'."\n";
411  $s .= ' jQuery("#check_ext'.$htmlname.'").click(function() {';
412  $s .= ' /* alert("'.$htmlname.'"); */';
413  $s .= ' jQuery(".family_ext'.$htmlname.'").toggle();';
414  $s .= ' });'."\n";
415  $s .= '});'."\n";
416  $s .= '</script>'."\n";
417  $s .= '<div class="nowrap float"><input type="checkbox" id="check_ext'.$htmlname.'" name="check_ext'.$htmlname.'" checked> '.$val ['name'].' &nbsp; </div>';
418  }
419  }
420 
421  //$s.='<div class="nowrap float"><input type="checkbox" id="check_birthday" name="check_birthday"> '.$langs->trans("AgendaShowBirthdayEvents").' &nbsp; </div>';
422 
423  // Calendars from hooks
424  $parameters = array();
425  $reshook = $hookmanager->executeHooks('addCalendarChoice', $parameters, $object, $action);
426  if (empty($reshook)) {
427  $s .= $hookmanager->resPrint;
428  } elseif ($reshook > 1) {
429  $s = $hookmanager->resPrint;
430  }
431  }
432 }
433 
434 $massactionbutton = '';
435 
436 $viewmode = '';
437 $viewmode .= '<a class="btnTitle reposition" href="'.DOL_URL_ROOT.'/comm/action/list.php?mode=show_list&restore_lastsearch_values=1'.$paramnoactionodate.'">';
438 //$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
439 $viewmode .= img_picto($langs->trans("List"), 'object_calendarlist', 'class="imgforviewmode pictoactionview block"');
440 //$viewmode .= '</span>';
441 $viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewList").'</span></a>';
442 
443 $viewmode .= '<a class="btnTitle reposition" href="'.DOL_URL_ROOT.'/comm/action/index.php?mode=show_month&year='.dol_print_date($object->datep, '%Y').'&month='.dol_print_date($object->datep, '%m').'&day='.dol_print_date($object->datep, '%d').$paramnoactionodate.'">';
444 //$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
445 $viewmode .= img_picto($langs->trans("ViewCal"), 'object_calendarmonth', 'class="pictoactionview block"');
446 //$viewmode .= '</span>';
447 $viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewCal").'</span></a>';
448 
449 $viewmode .= '<a class="btnTitle reposition" href="'.DOL_URL_ROOT.'/comm/action/index.php?mode=show_week&year='.dol_print_date($object->datep, '%Y').'&month='.dol_print_date($object->datep, '%m').'&day='.dol_print_date($object->datep, '%d').$paramnoactionodate.'">';
450 //$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
451 $viewmode .= img_picto($langs->trans("ViewWeek"), 'object_calendarweek', 'class="pictoactionview block"');
452 //$viewmode .= '</span>';
453 $viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewWeek").'</span></a>';
454 
455 $viewmode .= '<a class="btnTitle reposition" href="'.DOL_URL_ROOT.'/comm/action/index.php?mode=show_day&year='.dol_print_date($object->datep, '%Y').'&month='.dol_print_date($object->datep, '%m').'&day='.dol_print_date($object->datep, '%d').$paramnoactionodate.'">';
456 //$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
457 $viewmode .= img_picto($langs->trans("ViewDay"), 'object_calendarday', 'class="pictoactionview block"');
458 //$viewmode .= '</span>';
459 $viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewDay").'</span></a>';
460 
461 $viewmode .= '<a class="btnTitle btnTitleSelected reposition marginrightonly" href="'.DOL_URL_ROOT.'/comm/action/peruser.php?mode=show_peruser&year='.dol_print_date($object->datep, '%Y').'&month='.dol_print_date($object->datep, '%m').'&day='.dol_print_date($object->datep, '%d').$paramnoactionodate.'">';
462 //$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
463 $viewmode .= img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser', 'class="pictoactionview block"');
464 //$viewmode .= '</span>';
465 $viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewPerUser").'</span></a>';
466 
467 $viewmode .= '<span class="marginrightonly"></span>';
468 
469 // Add more views from hooks
470 $parameters = array(); $object = null;
471 $reshook = $hookmanager->executeHooks('addCalendarView', $parameters, $object, $action);
472 if (empty($reshook)) {
473  $viewmode .= $hookmanager->resPrint;
474 } elseif ($reshook > 1) {
475  $viewmode = $hookmanager->resPrint;
476 }
477 
478 
479 $newparam = '';
480 $newcardbutton = '';
481 if ($user->rights->agenda->myactions->create || $user->hasRight('agenda', 'allactions', 'create')) {
482  $tmpforcreatebutton = dol_getdate(dol_now(), true);
483 
484  $newparam .= '&month='.urlencode(str_pad($month, 2, "0", STR_PAD_LEFT)).'&year='.urlencode($tmpforcreatebutton['year']);
485  if ($begin_h !== '') {
486  $newparam .= '&begin_h='.urlencode($begin_h);
487  }
488  if ($end_h !== '') {
489  $newparam .= '&end_h='.urlencode($end_h);
490  }
491  if ($begin_d !== '') {
492  $newparam .= '&begin_d='.urlencode($begin_d);
493  }
494  if ($end_d !== '') {
495  $newparam .= '&end_d='.urlencode($end_d);
496  }
497 
498  //$param='month='.$monthshown.'&year='.$year;
499  $hourminsec = '100000';
500  $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 : '')));
501 }
502 
503 $num = '';
504 
505 print_barre_liste($langs->trans("Agenda"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, -1, 'object_action', 0, $nav.'<span class="marginleftonly"></span>'.$newcardbutton, '', $limit, 1, 0, 1, $viewmode);
506 
507 $link = '';
508 //print load_fiche_titre('', $link.' &nbsp; &nbsp; '.$nav.' '.$newcardbutton, '');
509 
510 // Local calendar
511 $newtitle = '<div class="nowrap clear inline-block minheight30">';
512 $newtitle .= '<input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> '.$langs->trans("LocalAgenda").' &nbsp; ';
513 $newtitle .= '</div>';
514 //$newtitle=$langs->trans($title);
515 
516 $s = $newtitle;
517 
518 print $s;
519 
520 print '<div class="liste_titre liste_titre_bydiv centpercent">';
521 print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid);
522 print '</div>';
523 
524 
525 // Get event in an array
526 $eventarray = array();
527 
528 
529 // DEFAULT CALENDAR + AUTOEVENT CALENDAR + CONFERENCEBOOTH CALENDAR
530 $sql = 'SELECT';
531 if ($usergroup > 0) {
532  $sql .= " DISTINCT";
533 }
534 $sql .= ' a.id, a.label,';
535 $sql .= ' a.datep,';
536 $sql .= ' a.datep2,';
537 $sql .= ' a.percent,';
538 $sql .= ' a.fk_user_author,a.fk_user_action,';
539 $sql .= ' a.transparency, a.priority, a.fulldayevent, a.location,';
540 $sql .= ' a.fk_soc, a.fk_contact, a.fk_element, a.elementtype, a.fk_project,';
541 $sql .= ' ca.code, ca.libelle as type_label, ca.color, ca.type as type_type, ca.picto as type_picto';
542 $sql .= ' FROM '.MAIN_DB_PREFIX.'c_actioncomm as ca, '.MAIN_DB_PREFIX."actioncomm as a";
543 if (empty($user->rights->societe->client->voir) && !$socid) {
544  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
545 }
546 // We must filter on resource table
547 if ($resourceid > 0) {
548  $sql .= ", ".MAIN_DB_PREFIX."element_resources as r";
549 }
550 // We must filter on assignement table
551 if ($filtert > 0 || $usergroup > 0) {
552  $sql .= ", ".MAIN_DB_PREFIX."actioncomm_resources as ar";
553 }
554 if ($usergroup > 0) {
555  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element";
556 }
557 $sql .= ' WHERE a.fk_action = ca.id';
558 $sql .= ' AND a.entity IN ('.getEntity('agenda').')';
559 // Condition on actioncode
560 if (!empty($actioncode)) {
561  if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
562  if ($actioncode == 'AC_NON_AUTO') {
563  $sql .= " AND ca.type != 'systemauto'";
564  } elseif ($actioncode == 'AC_ALL_AUTO') {
565  $sql .= " AND ca.type = 'systemauto'";
566  } else {
567  if ($actioncode == 'AC_OTH') {
568  $sql .= " AND ca.type != 'systemauto'";
569  }
570  if ($actioncode == 'AC_OTH_AUTO') {
571  $sql .= " AND ca.type = 'systemauto'";
572  }
573  }
574  } else {
575  if ($actioncode == 'AC_NON_AUTO') {
576  $sql .= " AND ca.type != 'systemauto'";
577  } elseif ($actioncode == 'AC_ALL_AUTO') {
578  $sql .= " AND ca.type = 'systemauto'";
579  } else {
580  if (is_array($actioncode)) {
581  $sql .= " AND ca.code IN (".$db->sanitize("'".implode("','", $actioncode)."'", 1).")";
582  } else {
583  $sql .= " AND ca.code IN (".$db->sanitize("'".implode("','", explode(',', $actioncode))."'", 1).")";
584  }
585  }
586  }
587 }
588 if ($resourceid > 0) {
589  $sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".((int) $resourceid);
590 }
591 if ($pid) {
592  $sql .= " AND a.fk_project = ".((int) $pid);
593 }
594 if (empty($user->rights->societe->client->voir) && !$socid) {
595  $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = ".((int) $user->id).")";
596 }
597 if ($socid > 0) {
598  $sql .= ' AND a.fk_soc = '.((int) $socid);
599 }
600 // We must filter on assignement table
601 if ($filtert > 0 || $usergroup > 0) {
602  $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'";
603 }
604 if ($mode == 'show_day') {
605  $sql .= " AND (";
606  $sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year, 'tzuserrel'))."'";
607  $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year, 'tzuserrel'))."')";
608  $sql .= " OR ";
609  $sql .= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year, 'tzuserrel'))."'";
610  $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year, 'tzuserrel'))."')";
611  $sql .= " OR ";
612  $sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year, 'tzuserrel'))."'";
613  $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year, 'tzuserrel'))."')";
614  $sql .= ')';
615 } else {
616  // To limit array
617  $sql .= " AND (";
618  $sql .= " (a.datep BETWEEN '".$db->idate($firstdaytoshow - (60 * 60 * 24 * 2))."'"; // Start 2 day before $firstdaytoshow
619  $sql .= " AND '".$db->idate($lastdaytoshow + (60 * 60 * 24 * 2))."')"; // End 2 day after $lastdaytoshow
620  $sql .= " OR ";
621  $sql .= " (a.datep2 BETWEEN '".$db->idate($firstdaytoshow - (60 * 60 * 24 * 2))."'";
622  $sql .= " AND '".$db->idate($lastdaytoshow + (60 * 60 * 24 * 2))."')";
623  $sql .= " OR ";
624  $sql .= " (a.datep < '".$db->idate($firstdaytoshow - (60 * 60 * 24 * 2))."'";
625  $sql .= " AND a.datep2 > '".$db->idate($lastdaytoshow + (60 * 60 * 24 * 2))."')";
626  $sql .= ')';
627 }
628 if ($type) {
629  $sql .= " AND ca.id = ".((int) $type);
630 }
631 if ($status == '0') {
632  $sql .= " AND a.percent = 0";
633 }
634 if ($status === 'na') {
635  // Not applicable
636  $sql .= " AND a.percent = -1";
637 }
638 if ($status == '50') {
639  // Running already started
640  $sql .= " AND (a.percent > 0 AND a.percent < 100)";
641 }
642 if ($status == 'done' || $status == '100') {
643  $sql .= " AND (a.percent = 100)";
644 }
645 if ($status == 'todo') {
646  $sql .= " AND (a.percent >= 0 AND a.percent < 100)";
647 }
648 // We must filter on assignement table
649 if ($filtert > 0 || $usergroup > 0) {
650  $sql .= " AND (";
651  if ($filtert > 0) {
652  $sql .= "ar.fk_element = ".$filtert;
653  }
654  if ($usergroup > 0) {
655  $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".((int) $usergroup);
656  }
657  $sql .= ")";
658 }
659 // Sort on date
660 $sql .= ' ORDER BY fk_user_action, datep'; //fk_user_action
661 //print $sql;
662 
663 dol_syslog("comm/action/peruser.php", LOG_DEBUG);
664 $resql = $db->query($sql);
665 if ($resql) {
666  $num = $db->num_rows($resql);
667 
668  $i = 0;
669  while ($i < $num) {
670  $obj = $db->fetch_object($resql);
671  //print $obj->fk_user_action.' '.$obj->id."<br>";
672 
673  // Discard auto action if option is on
674  if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->code == 'AC_OTH_AUTO') {
675  $i++;
676  continue;
677  }
678 
679  $datep = $db->jdate($obj->datep);
680  $datep2 = $db->jdate($obj->datep2);
681 
682 
683  // Create a new object action
684  $event = new ActionComm($db);
685  $event->id = $obj->id;
686  $event->datep = $datep; // datep and datef are GMT date
687  $event->datef = $datep2;
688  $event->type_code = $obj->code;
689  $event->type_color = $obj->color;
690  $event->label = $obj->label;
691  $event->percentage = $obj->percent;
692  $event->authorid = $obj->fk_user_author; // user id of creator
693  $event->userownerid = $obj->fk_user_action; // user id of owner
694  $event->priority = $obj->priority;
695  $event->fulldayevent = $obj->fulldayevent;
696  $event->location = $obj->location;
697  $event->transparency = $obj->transparency;
698 
699  $event->fk_project = $obj->fk_project;
700 
701  $event->socid = $obj->fk_soc;
702  $event->contact_id = $obj->fk_contact;
703 
704  $event->fk_element = $obj->fk_element;
705  $event->elementtype = $obj->elementtype;
706 
707  // Defined date_start_in_calendar and date_end_in_calendar property
708  // They are date start and end of action but modified to not be outside calendar view.
709  if ($event->percentage <= 0) {
710  $event->date_start_in_calendar = $datep;
711  if ($datep2 != '' && $datep2 >= $datep) {
712  $event->date_end_in_calendar = $datep2;
713  } else {
714  $event->date_end_in_calendar = $datep;
715  }
716  } else {
717  $event->date_start_in_calendar = $datep;
718  if ($datep2 != '' && $datep2 >= $datep) {
719  $event->date_end_in_calendar = $datep2;
720  } else {
721  $event->date_end_in_calendar = $datep;
722  }
723  }
724 
725  //print '<br>'.$i.' - eventid='.$event->id.' '.dol_print_date($event->date_start_in_calendar, 'dayhour').' '.dol_print_date($firstdaytoshow, 'dayhour').' - '.dol_print_date($event->date_end_in_calendar, 'dayhour').' '.dol_print_date($lastdaytoshow, 'dayhour').'<br>'."\n";
726 
727  // Check values
728  if ($event->date_end_in_calendar < $firstdaytoshow ||
729  $event->date_start_in_calendar >= $lastdaytoshow) {
730  // This record is out of visible range
731  unset($event);
732  } else {
733  //print $i.' - eventid='.$event->id.' '.dol_print_date($event->date_start_in_calendar, 'dayhour').' - '.dol_print_date($event->date_end_in_calendar, 'dayhour').'<br>'."\n";
734  $event->fetch_userassigned(); // This load $event->userassigned
735 
736  if ($event->date_start_in_calendar < $firstdaytoshow) {
737  $event->date_start_in_calendar = $firstdaytoshow;
738  }
739  if ($event->date_end_in_calendar >= $lastdaytoshow) {
740  $event->date_end_in_calendar = ($lastdaytoshow - 1);
741  }
742 
743  // Add an entry in actionarray for each day
744  $daycursor = $event->date_start_in_calendar;
745  $annee = dol_print_date($daycursor, '%Y', 'tzuserrel');
746  $mois = dol_print_date($daycursor, '%m', 'tzuserrel');
747  $jour = dol_print_date($daycursor, '%d', 'tzuserrel');
748  //print $daycursor.' '.dol_print_date($daycursor, 'dayhour', 'gmt').' '.$event->id.' -> '.$annee.'-'.$mois.'-'.$jour.'<br>';
749 
750  // Loop on each day covered by action to prepare an index to show on calendar
751  $loop = true; $j = 0;
752  $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee, 'gmt');
753  do {
754  //print 'Add event into eventarray for daykey='.$daykey.'='.dol_print_date($daykey, 'dayhour', 'gmt').' '.$event->id.' '.$event->datep.' '.$event->datef.'<br>';
755 
756  $eventarray[$daykey][] = $event;
757  $j++;
758 
759  $daykey += 60 * 60 * 24;
760  if ($daykey > $event->date_end_in_calendar) {
761  $loop = false;
762  }
763  } while ($loop);
764 
765  //print 'Event '.$i.' id='.$event->id.' (start='.dol_print_date($event->datep).'-end='.dol_print_date($event->datef);
766  //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>';
767  }
768  $i++;
769  }
770  $db->free($resql);
771 } else {
772  dol_print_error($db);
773 }
774 
775 $maxnbofchar = 18;
776 $cachethirdparties = array();
777 $cachecontacts = array();
778 $cacheusers = array();
779 
780 // Define theme_datacolor array
781 $color_file = DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/theme_vars.inc.php";
782 if (is_readable($color_file)) {
783  include $color_file;
784 }
785 if (!is_array($theme_datacolor)) {
786  $theme_datacolor = array(array(120, 130, 150), array(200, 160, 180), array(190, 190, 220));
787 }
788 
789 
790 $newparam = $param; // newparam is for birthday links
791 $newparam = preg_replace('/showbirthday=/i', 'showbirthday_=', $newparam); // To avoid replacement when replace day= is done
792 $newparam = preg_replace('/mode=show_month&?/i', '', $newparam);
793 $newparam = preg_replace('/mode=show_week&?/i', '', $newparam);
794 $newparam = preg_replace('/day=[0-9]+&?/i', '', $newparam);
795 $newparam = preg_replace('/month=[0-9]+&?/i', '', $newparam);
796 $newparam = preg_replace('/year=[0-9]+&?/i', '', $newparam);
797 $newparam = preg_replace('/viewweek=[0-9]+&?/i', '', $newparam);
798 $newparam = preg_replace('/showbirthday_=/i', 'showbirthday=', $newparam); // Restore correct parameter
799 $newparam .= '&viewweek=1';
800 
801 echo '<input type="hidden" name="actionmove" value="mupdate">';
802 echo '<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($_SERVER['PHP_SELF']).'?'.dol_escape_htmltag($_SERVER['QUERY_STRING']).'">';
803 echo '<input type="hidden" name="newdate" id="newdate">';
804 
805 
806 // Line header with list of days
807 
808 //print "begin_d=".$begin_d." end_d=".$end_d;
809 
810 $currentdaytoshow = $firstdaytoshow;
811 echo '<div class="div-table-responsive">';
812 //print dol_print_date($currentdaytoshow, 'dayhour', 'gmt');
813 
814 while ($currentdaytoshow < $lastdaytoshow) {
815  echo '<table class="centpercent noborder nocellnopadd cal_month">';
816 
817  echo '<tr class="liste_titre">';
818  echo '<td class="nopaddingtopimp nopaddingbottomimp nowraponsmartphone">';
819 
820  if ($canedit && $mode == 'show_peruser') {
821  // Filter on hours
822  print img_picto('', 'clock', 'class="fawidth30 inline-block paddingleft"');
823  print '<span class="hideonsmartphone" title="'.$langs->trans("VisibleTimeRange").'">'.$langs->trans("Hours").'</span>';
824  print "\n".'<div class="ui-grid-a inline-block"><div class="ui-block-a nowraponall">';
825  print '<input type="number" class="short" name="begin_h" value="'.$begin_h.'" min="0" max="23">';
826  if (empty($conf->dol_use_jmobile)) {
827  print ' - ';
828  } else {
829  print '</div><div class="ui-block-b">';
830  }
831  print '<input type="number" class="short" name="end_h" value="'.$end_h.'" min="1" max="24">';
832  if (empty($conf->dol_use_jmobile)) {
833  print ' '.$langs->trans("H");
834  }
835  print '</div></div>';
836 
837  print '<br>';
838 
839  // Filter on days
840  print img_picto('', 'clock', 'class="fawidth30 inline-block paddingleft"');
841  print '<span class="hideonsmartphone" title="'.$langs->trans("VisibleDaysRange").'">'.$langs->trans("DaysOfWeek").'</span>';
842  print "\n".'<div class="ui-grid-a inline-block"><div class="ui-block-a nowraponall">';
843  print '<input type="number" class="short" name="begin_d" value="'.$begin_d.'" min="1" max="7">';
844  if (empty($conf->dol_use_jmobile)) {
845  print ' - ';
846  } else {
847  print '</div><div class="ui-block-b">';
848  }
849  print '<input type="number" class="short" name="end_d" value="'.$end_d.'" min="1" max="7">';
850  print '</div></div>';
851  }
852 
853  print '</td>';
854  $i = 0; // 0 = sunday,
855  while ($i < 7) {
856  if (($i + 1) < $begin_d || ($i + 1) > $end_d) {
857  $i++;
858  continue;
859  }
860  echo '<td align="center" colspan="'.($end_h - $begin_h).'">';
861  echo '<span class="bold spandayofweek">'.$langs->trans("Day".(($i + (isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1)) % 7)).'</span>';
862  print "<br>";
863  if ($i) {
864  print dol_print_date(dol_time_plus_duree($currentdaytoshow, $i, 'd'), 'day', 'tzuserrel');
865  } else {
866  print dol_print_date($currentdaytoshow, 'day', 'tzuserrel');
867  }
868  echo "</td>\n";
869  $i++;
870  }
871  echo "</tr>\n";
872 
873  echo '<tr class="liste_titre">';
874  echo '<td></td>';
875  $i = 0;
876  while ($i < 7) {
877  if (($i + 1) < $begin_d || ($i + 1) > $end_d) {
878  $i++;
879  continue;
880  }
881  for ($h = $begin_h; $h < $end_h; $h++) {
882  echo '<td class="center">';
883  print '<small style="font-family: courier">'.sprintf("%02d", $h).'</small>';
884  print "</td>";
885  }
886  echo "</td>\n";
887  $i++;
888  }
889  echo "</tr>\n";
890 
891 
892  // Define $usernames
893  $usernames = array(); //init
894  $usernamesid = array();
895  /* Use this to have list of users only if users have events */
896  if (!empty($conf->global->AGENDA_SHOWOWNERONLY_ONPERUSERVIEW)) {
897  foreach ($eventarray as $daykey => $notused) {
898  // Get all assigned users for each event
899  foreach ($eventarray[$daykey] as $index => $event) {
900  $event->fetch_userassigned();
901  $listofuserid = $event->userassigned;
902  foreach ($listofuserid as $userid => $tmp) {
903  if (!in_array($userid, $usernamesid)) {
904  $usernamesid[$userid] = $userid;
905  }
906  }
907  }
908  }
909  } else {
910  /* Use this list to have for all users */
911  $sql = "SELECT DISTINCT u.rowid, u.lastname as lastname, u.firstname, u.statut, u.login, u.admin, u.entity";
912  $sql .= " FROM ".MAIN_DB_PREFIX."user as u";
913  if (isModEnabled('multicompany') && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
914  $sql .= ", ".MAIN_DB_PREFIX."usergroup_user as ug";
915  $sql .= " WHERE ug.entity IN (".getEntity('usergroup').")";
916  $sql .= " AND ug.fk_user = u.rowid ";
917  } else {
918  if ($usergroup > 0) {
919  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ug ON u.rowid = ug.fk_user";
920  }
921  $sql .= " WHERE u.entity IN (".getEntity('user').")";
922  }
923  $sql .= " AND u.statut = 1";
924  if ($usergroup > 0) {
925  $sql .= " AND ug.fk_usergroup = ".((int) $usergroup);
926  }
927  if ($user->socid > 0) {
928  // External users should see only contacts of their company
929  $sql .= " AND u.fk_soc = ".((int) $user->socid);
930  }
931 
932  //print $sql;
933  $resql = $db->query($sql);
934  if ($resql) {
935  $num = $db->num_rows($resql);
936  $i = 0;
937  if ($num) {
938  while ($i < $num) {
939  $obj = $db->fetch_object($resql);
940  $usernamesid[$obj->rowid] = $obj->rowid;
941  $i++;
942  }
943  }
944  } else {
945  dol_print_error($db);
946  }
947  }
948  //var_dump($usernamesid);
949  foreach ($usernamesid as $id) {
950  $tmpuser = new User($db);
951  $result = $tmpuser->fetch($id);
952  $usernames[] = $tmpuser;
953  }
954 
955  // Load array of colors by type
956  $colorsbytype = array();
957  $labelbytype = array();
958  $sql = "SELECT code, color, libelle as label FROM ".MAIN_DB_PREFIX."c_actioncomm ORDER BY position";
959  $resql = $db->query($sql);
960  while ($obj = $db->fetch_object($resql)) {
961  $colorsbytype[$obj->code] = $obj->color;
962  $labelbytype[$obj->code] = $obj->label;
963  }
964 
965  // Loop on each user to show calendar
966  $todayarray = dol_getdate($now, 'fast');
967  $sav = $tmpday;
968  $showheader = true;
969  $var = false;
970  foreach ($usernames as $username) {
971  //if ($username->login != 'admin') continue;
972 
973  $var = !$var;
974  echo "<tr>";
975  echo '<td class="tdoverflowmax100 cal_current_month cal_peruserviewname'.($var ? ' cal_impair' : '').'">';
976  print $username->getNomUrl(-1, '', 0, 0, 20, 1, '');
977  print '</td>';
978  $tmpday = $sav;
979 
980  // Lopp on each day of week
981  $i = 0;
982  for ($iter_day = 0; $iter_day < 8; $iter_day++) {
983  if (($i + 1) < $begin_d || ($i + 1) > $end_d) {
984  $i++;
985  continue;
986  }
987 
988  // Show days of the current week
989  $curtime = dol_time_plus_duree($currentdaytoshow, $iter_day, 'd');
990  // $curtime is a gmt time, but we want the day, month, year in user TZ
991  $tmpday = dol_print_date($curtime, "%d", "tzuserrel");
992  $tmpmonth = dol_print_date($curtime, "%m", "tzuserrel");
993  $tmpyear = dol_print_date($curtime, "%Y", "tzuserrel");
994  //var_dump($curtime.' '.$tmpday.' '.$tmpmonth.' '.$tmpyear);
995 
996  $style = 'cal_current_month';
997  if ($iter_day == 6) {
998  $style .= ' cal_other_month';
999  }
1000  $today = 0;
1001  if ($todayarray['mday'] == $tmpday && $todayarray['mon'] == $tmpmonth && $todayarray['year'] == $tmpyear) {
1002  $today = 1;
1003  }
1004  if ($today) {
1005  $style = 'cal_today_peruser';
1006  }
1007 
1008  show_day_events2($username, $tmpday, $tmpmonth, $tmpyear, 0, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, $showheader, $colorsbytype, $var);
1009 
1010  $i++;
1011  }
1012  echo "</tr>\n";
1013  $showheader = false;
1014  }
1015 
1016  echo "</table>\n";
1017  echo "<br>";
1018 
1019  $currentdaytoshow = dol_time_plus_duree($currentdaytoshow, 7, 'd');
1020 }
1021 
1022 echo '</div>';
1023 
1024 if (!empty($conf->global->AGENDA_USE_EVENT_TYPE) && !empty($conf->global->AGENDA_USE_COLOR_PER_EVENT_TYPE)) {
1025  $langs->load("commercial");
1026  print '<br>'.$langs->trans("Legend").': <br>';
1027  foreach ($colorsbytype as $code => $color) {
1028  if ($color) {
1029  print '<div style="float: left; padding: 2px; margin-right: 6px;"><div style="'.($color ? 'background: #'.$color.';' : '').'width:16px; float: left; margin-right: 4px;">&nbsp;</div>';
1030  print $langs->trans("Action".$code) != "Action".$code ? $langs->trans("Action".$code) : $labelbytype[$code];
1031  //print $code;
1032  print '</div>';
1033  }
1034  }
1035  //$color=sprintf("%02x%02x%02x",$theme_datacolor[0][0],$theme_datacolor[0][1],$theme_datacolor[0][2]);
1036  print '<div style="float: left; padding: 2px; margin-right: 6px;"><div class="peruser_busy" style="width:16px; float: left; margin-right: 4px;">&nbsp;</div>';
1037  print $langs->trans("Other");
1038  print '</div>';
1039  /* TODO Show this if at least one cumulated event
1040  print '<div style="float: left; padding: 2px; margin-right: 6px;"><div style="background: #222222; width:16px; float: left; margin-right: 4px;">&nbsp;</div>';
1041  print $langs->trans("SeveralEvents");
1042  print '</div>';
1043  */
1044 }
1045 
1046 print "\n".'</form>';
1047 print "\n";
1048 
1049 // Add js code to manage click on a box
1050 print '<script type="text/javascript">
1051 jQuery(document).ready(function() {
1052  jQuery(".onclickopenref").click(function() {
1053  var ref=$(this).attr(\'ref\');
1054  var res = ref.split("_");
1055  var userid = res[1];
1056  var year = res[2];
1057  var month = res[3];
1058  var day = res[4];
1059  var hour = res[5];
1060  var min = res[6];
1061  var ids = res[7];
1062  if (ids == \'none\') /* No event */
1063  {
1064  /* alert(\'no event\'); */
1065  url = "'.DOL_URL_ROOT.'/comm/action/card.php?action=create&assignedtouser="+userid+"&datep="+year+month+day+hour+min+"00&backtopage='.urlencode($_SERVER["PHP_SELF"].'?year='.$year.'&month='.$month.'&day='.$day.($begin_h !== '' ? '&begin_h='.$begin_h : '').($end_h !== '' ? '&end_h='.$end_h : '').($begin_d !== '' ? '&begin_d='.$begin_d : '').($end_d !== '' ? '&end_d='.$end_d : '')).'"
1066  window.location.href = url;
1067  }
1068  else if (ids.indexOf(",") > -1) /* There is several events */
1069  {
1070  /* alert(\'several events\'); */
1071  url = "'.DOL_URL_ROOT.'/comm/action/list.php?mode=show_list&filtert="+userid+"&dateselectyear="+year+"&dateselectmonth="+month+"&dateselectday="+day;
1072  window.location.href = url;
1073  }
1074  else /* One event */
1075  {
1076  /* alert(\'one event\'); */
1077  url = "'.DOL_URL_ROOT.'/comm/action/card.php?action=view&id="+ids
1078  window.location.href = url;
1079  }
1080  });
1081 });
1082 </script>';
1083 
1084 // End of page
1085 llxFooter();
1086 $db->close();
1087 
1088 
1089 
1090 
1111 function show_day_events2($username, $day, $month, $year, $monthshown, $style, &$eventarray, $maxprint = 0, $maxnbofchar = 16, $newparam = '', $showinfo = 0, $minheight = 60, $showheader = false, $colorsbytype = array(), $var = false)
1112 {
1113  global $db;
1114  global $user, $conf, $langs, $hookmanager, $action;
1115  global $filter, $filtert, $status, $actioncode; // Filters used into search form
1116  global $theme_datacolor; // Array with a list of different we can use (come from theme)
1117  global $cachethirdparties, $cachecontacts, $cacheusers, $cacheprojects, $colorindexused;
1118  global $begin_h, $end_h;
1119 
1120  $cases1 = array(); // Color first half hour
1121  $cases2 = array(); // Color second half hour
1122 
1123  $i = 0; $numother = 0; $numbirthday = 0; $numical = 0; $numicals = array();
1124  //$ymd = sprintf("%04d", $year).sprintf("%02d", $month).sprintf("%02d", $day);
1125 
1126  $colorindexused[$user->id] = 0; // Color index for current user (user->id) is always 0
1127  $nextindextouse = count($colorindexused); // At first run this is 0, so first user has 0, next 1, ...
1128  //if ($username->id && $day==1) {
1129  //var_dump($eventarray);
1130  //}
1131  //var_dump("------ username=".$username->login." for day=".$day);
1132 
1133  // We are in a particular day for $username, now we scan all events
1134  foreach ($eventarray as $daykey => $notused) {
1135  $annee = dol_print_date($daykey, '%Y', 'tzuserrel');
1136  $mois = dol_print_date($daykey, '%m', 'tzuserrel');
1137  $jour = dol_print_date($daykey, '%d', 'tzuserrel');
1138  //var_dump("daykey=$daykey day=$day jour=$jour, month=$month mois=$mois, year=$year annee=$annee");
1139 
1140 
1141  if ($day == $jour && (int) $month == (int) $mois && $year == $annee) { // Is it the day we are looking for when calling function ?
1142  //var_dump("day=$day jour=$jour month=$month mois=$mois year=$year annee=$annee");
1143 
1144  // Scan all event for this date
1145  foreach ($eventarray[$daykey] as $index => $event) {
1146  //print 'daykey='.$daykey.'='.dol_print_date($daykey, 'dayhour', 'gmt').' '.$year.'-'.$month.'-'.$day.' -> This event: '.$event->id.' '.$index.' is open for this daykey '.$annee.'-'.$mois.'-'.$jour."<br>\n";
1147  //var_dump($event);
1148 
1149  $keysofuserassigned = array_keys($event->userassigned);
1150  $ponct = ($event->date_start_in_calendar == $event->date_end_in_calendar);
1151 
1152  if (!in_array($username->id, $keysofuserassigned)) {
1153  continue; // We discard record if event is from another user than user we want to show
1154  }
1155  //if ($username->id != $event->userownerid) continue; // We discard record if event is from another user than user we want to show
1156 
1157  $parameters = array();
1158  $reshook = $hookmanager->executeHooks('formatEvent', $parameters, $event, $action); // Note that $action and $object may have been modified by some hooks
1159  if ($reshook < 0) {
1160  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1161  }
1162 
1163  // Define $color (Hex string like '0088FF') and $cssclass of event
1164  $color = -1; $cssclass = ''; $colorindex = -1;
1165  if (in_array($user->id, $keysofuserassigned)) {
1166  $cssclass = 'family_mytasks';
1167 
1168  if (empty($cacheusers[$event->userownerid])) {
1169  $newuser = new User($db);
1170  $newuser->fetch($event->userownerid);
1171  $cacheusers[$event->userownerid] = $newuser;
1172  }
1173  //var_dump($cacheusers[$event->userownerid]->color);
1174 
1175  // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event)
1176  if (!empty($cacheusers[$event->userownerid]->color)) {
1177  $color = $cacheusers[$event->userownerid]->color;
1178  }
1179 
1180  if (!empty($conf->global->AGENDA_USE_COLOR_PER_EVENT_TYPE)) {
1181  $color = $event->type_color;
1182  }
1183  } elseif ($event->type_code == 'ICALEVENT') {
1184  $numical++;
1185  if (!empty($event->icalname)) {
1186  if (!isset($numicals[dol_string_nospecial($event->icalname)])) {
1187  $numicals[dol_string_nospecial($event->icalname)] = 0;
1188  }
1189  $numicals[dol_string_nospecial($event->icalname)]++;
1190  }
1191 
1192  $color = $event->icalcolor;
1193  $cssclass = (!empty($event->icalname) ? 'family_ext'.md5($event->icalname) : 'family_other unsortable');
1194  } elseif ($event->type_code == 'BIRTHDAY') {
1195  $numbirthday++; $colorindex = 2; $cssclass = 'family_birthday unsortable'; $color = sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
1196  } else {
1197  $numother++;
1198  $color = ($event->icalcolor ? $event->icalcolor : -1);
1199  $cssclass = (!empty($event->icalname) ? 'family_ext'.md5($event->icalname) : 'family_other');
1200 
1201  if (empty($cacheusers[$event->userownerid])) {
1202  $newuser = new User($db);
1203  $newuser->fetch($event->userownerid);
1204  $cacheusers[$event->userownerid] = $newuser;
1205  }
1206  //var_dump($cacheusers[$event->userownerid]->color);
1207 
1208  // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event)
1209  if (!empty($cacheusers[$event->userownerid]->color)) {
1210  $color = $cacheusers[$event->userownerid]->color;
1211  }
1212 
1213  if (!empty($conf->global->AGENDA_USE_COLOR_PER_EVENT_TYPE)) {
1214  $color = $event->type_color;
1215  }
1216  }
1217 
1218  if ($color < 0) { // Color was not set on user card. Set color according to color index.
1219  // Define color index if not yet defined
1220  $idusertouse = ($event->userownerid ? $event->userownerid : 0);
1221  if (isset($colorindexused[$idusertouse])) {
1222  $colorindex = $colorindexused[$idusertouse]; // Color already assigned to this user
1223  } else {
1224  $colorindex = $nextindextouse;
1225  $colorindexused[$idusertouse] = $colorindex;
1226  if (!empty($theme_datacolor[$nextindextouse + 1])) {
1227  $nextindextouse++; // Prepare to use next color
1228  }
1229  }
1230  // Define color
1231  $color = sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
1232  }
1233 
1234  // Define all rects with event (cases1 is first half hour, cases2 is second half hour)
1235  for ($h = $begin_h; $h < $end_h; $h++) {
1236  //if ($username->id == 1 && $day==1) print 'h='.$h;
1237  $newcolor = ''; //init
1238  if (empty($event->fulldayevent)) {
1239  $a = dol_mktime((int) $h, 0, 0, $month, $day, $year, 'tzuserrel', 0);
1240  $b = dol_mktime((int) $h, 30, 0, $month, $day, $year, 'tzuserrel', 0);
1241  $c = dol_mktime((int) $h + 1, 0, 0, $month, $day, $year, 'tzuserrel', 0);
1242 
1243  $dateendtouse = $event->date_end_in_calendar;
1244  if ($dateendtouse == $event->date_start_in_calendar) {
1245  $dateendtouse++;
1246  }
1247 
1248  //print dol_print_date($event->date_start_in_calendar,'dayhour').'-'.dol_print_date($a,'dayhour').'-'.dol_print_date($b,'dayhour').'<br>';
1249 
1250  if ($event->date_start_in_calendar < $b && $dateendtouse > $a) {
1251  $busy = $event->transparency;
1252  $cases1[$h][$event->id]['busy'] = $busy;
1253  $cases1[$h][$event->id]['string'] = dol_print_date($event->date_start_in_calendar, 'dayhour', 'tzuserrel');
1254  if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) {
1255  $tmpa = dol_getdate($event->date_start_in_calendar, true);
1256  $tmpb = dol_getdate($event->date_end_in_calendar, true);
1257  if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) {
1258  $cases1[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'hour', 'tzuserrel');
1259  } else {
1260  $cases1[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'dayhour', 'tzuserrel');
1261  }
1262  }
1263  if ($event->label) {
1264  $cases1[$h][$event->id]['string'] .= ' - '.$event->label;
1265  }
1266  $cases1[$h][$event->id]['typecode'] = $event->type_code;
1267  $cases1[$h][$event->id]['color'] = $color;
1268  if ($event->fk_project > 0) {
1269  if (empty($cacheprojects[$event->fk_project])) {
1270  $tmpproj = new Project($db);
1271  $tmpproj->fetch($event->fk_project);
1272  $cacheprojects[$event->fk_project] = $tmpproj;
1273  }
1274  $cases1[$h][$event->id]['string'] .= ', '.$langs->trans("Project").': '.$cacheprojects[$event->fk_project]->ref.' - '.$cacheprojects[$event->fk_project]->title;
1275  }
1276  if ($event->socid > 0) {
1277  if (empty($cachethirdparties[$event->socid])) {
1278  $tmpthirdparty = new Societe($db);
1279  $tmpthirdparty->fetch($event->socid);
1280  $cachethirdparties[$event->socid] = $tmpthirdparty;
1281  }
1282  $cases1[$h][$event->id]['string'] .= ', '.$cachethirdparties[$event->socid]->name;
1283  }
1284  if ($event->contact_id > 0) {
1285  if (empty($cachecontacts[$event->contact_id])) {
1286  $tmpcontact = new Contact($db);
1287  $tmpcontact->fetch($event->contact_id);
1288  $cachecontacts[$event->contact_id] = $tmpcontact;
1289  }
1290  $cases1[$h][$event->id]['string'] .= ', '.$cachecontacts[$event->contact_id]->getFullName($langs);
1291  }
1292  }
1293  if ($event->date_start_in_calendar < $c && $dateendtouse > $b) {
1294  $busy = $event->transparency;
1295  $cases2[$h][$event->id]['busy'] = $busy;
1296  $cases2[$h][$event->id]['string'] = dol_print_date($event->date_start_in_calendar, 'dayhour', 'tzuserrel');
1297  if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) {
1298  $tmpa = dol_getdate($event->date_start_in_calendar, true);
1299  $tmpb = dol_getdate($event->date_end_in_calendar, true);
1300  if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) {
1301  $cases2[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'hour', 'tzuserrel');
1302  } else {
1303  $cases2[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'dayhour', 'tzuserrel');
1304  }
1305  }
1306  if ($event->label) {
1307  $cases2[$h][$event->id]['string'] .= ' - '.$event->label;
1308  }
1309  $cases2[$h][$event->id]['typecode'] = $event->type_code;
1310  $cases2[$h][$event->id]['color'] = $color;
1311  if ($event->fk_project > 0) {
1312  if (empty($cacheprojects[$event->fk_project])) {
1313  $tmpproj = new Project($db);
1314  $tmpproj->fetch($event->fk_project);
1315  $cacheprojects[$event->fk_project] = $tmpproj;
1316  }
1317  $cases2[$h][$event->id]['string'] .= ', '.$langs->trans("Project").': '.$cacheprojects[$event->fk_project]->ref.' - '.$cacheprojects[$event->fk_project]->title;
1318  }
1319  if ($event->socid > 0) {
1320  if (empty($cachethirdparties[$event->socid])) {
1321  $tmpthirdparty = new Societe($db);
1322  $tmpthirdparty->fetch($event->socid);
1323  $cachethirdparties[$event->socid] = $tmpthirdparty;
1324  }
1325  $cases2[$h][$event->id]['string'] .= ', '.$cachethirdparties[$event->socid]->name;
1326  }
1327  if ($event->contact_id > 0) {
1328  if (empty($cachecontacts[$event->contact_id])) {
1329  $tmpcontact = new Contact($db);
1330  $tmpcontact->fetch($event->contact_id);
1331  $cachecontacts[$event->contact_id] = $tmpcontact;
1332  }
1333  $cases2[$h][$event->id]['string'] .= ', '.$cachecontacts[$event->contact_id]->getFullName($langs);
1334  }
1335  }
1336  } else {
1337  $busy = $event->transparency;
1338  $cases1[$h][$event->id]['busy'] = $busy;
1339  $cases2[$h][$event->id]['busy'] = $busy;
1340  $cases1[$h][$event->id]['string'] = $event->label;
1341  $cases2[$h][$event->id]['string'] = $event->label;
1342  $cases1[$h][$event->id]['typecode'] = $event->type_code;
1343  $cases2[$h][$event->id]['typecode'] = $event->type_code;
1344  $cases1[$h][$event->id]['color'] = $color;
1345  $cases2[$h][$event->id]['color'] = $color;
1346  }
1347  }
1348  $i++;
1349  }
1350 
1351  break; // We found the date we were looking for. No need to search anymore.
1352  }
1353  }
1354 
1355  // Now output $casesX from start hour to end hour
1356  for ($h = $begin_h; $h < $end_h; $h++) {
1357  $color1 = ''; $color2 = '';
1358  $style1 = ''; $style2 = '';
1359  $string1 = '&nbsp;'; $string2 = '&nbsp;';
1360  $title1 = ''; $title2 = '';
1361  if (isset($cases1[$h]) && $cases1[$h] != '') {
1362  //$title1.=count($cases1[$h]).' '.(count($cases1[$h])==1?$langs->trans("Event"):$langs->trans("Events"));
1363  if (count($cases1[$h]) > 1) {
1364  $title1 .= count($cases1[$h]).' '.(count($cases1[$h]) == 1 ? $langs->trans("Event") : $langs->trans("Events"));
1365  }
1366  $string1 = '&nbsp;';
1367  if (empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) {
1368  $style1 = 'peruser_notbusy';
1369  } else {
1370  $style1 = 'peruser_busy';
1371  }
1372  foreach ($cases1[$h] as $id => $ev) {
1373  if ($ev['busy']) {
1374  $style1 = 'peruser_busy';
1375  }
1376  }
1377  }
1378  if (isset($cases2[$h]) && $cases2[$h] != '') {
1379  //$title2.=count($cases2[$h]).' '.(count($cases2[$h])==1?$langs->trans("Event"):$langs->trans("Events"));
1380  if (count($cases2[$h]) > 1) {
1381  $title2 .= count($cases2[$h]).' '.(count($cases2[$h]) == 1 ? $langs->trans("Event") : $langs->trans("Events"));
1382  }
1383  $string2 = '&nbsp;';
1384  if (empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) {
1385  $style2 = 'peruser_notbusy';
1386  } else {
1387  $style2 = 'peruser_busy';
1388  }
1389  foreach ($cases2[$h] as $id => $ev) {
1390  if ($ev['busy']) {
1391  $style2 = 'peruser_busy';
1392  }
1393  }
1394  }
1395 
1396  $ids1 = '';
1397  $ids2 = '';
1398  if (!empty($cases1[$h]) && is_array($cases1[$h]) && count($cases1[$h]) && array_keys($cases1[$h])) {
1399  $ids1 = join(', ', array_keys($cases1[$h]));
1400  }
1401  if (!empty($cases2[$h]) && is_array($cases2[$h]) && count($cases2[$h]) && array_keys($cases2[$h])) {
1402  $ids2 = join(', ', array_keys($cases2[$h]));
1403  }
1404 
1405  if ($h == $begin_h) {
1406  echo '<td class="'.$style.'_peruserleft cal_peruser'.($var ? ' cal_impair '.$style.'_impair' : '').'">';
1407  } else {
1408  echo '<td class="'.$style.' cal_peruser'.($var ? ' cal_impair '.$style.'_impair' : '').'">';
1409  }
1410  if (!empty($cases1[$h]) && is_array($cases1[$h]) && count($cases1[$h]) == 1) { // only 1 event
1411  $output = array_slice($cases1[$h], 0, 1);
1412  $title1 = $langs->trans("Ref").' '.$ids1.($title1 ? ' - '.$title1 : '');
1413  if ($output[0]['string']) {
1414  $title1 .= ($title1 ? ' - ' : '').$output[0]['string'];
1415  }
1416  if ($output[0]['color']) {
1417  $color1 = $output[0]['color'];
1418  }
1419  } elseif (!empty($cases1[$h]) && is_array($cases1[$h]) && count($cases1[$h]) > 1) {
1420  $title1 = $langs->trans("Ref").' '.$ids1.($title1 ? ' - '.$title1 : '');
1421  $color1 = '222222';
1422  }
1423 
1424  if (!empty($cases2[$h]) && is_array($cases2[$h]) && count($cases2[$h]) == 1) { // only 1 event
1425  $output = array_slice($cases2[$h], 0, 1);
1426  $title2 = $langs->trans("Ref").' '.$ids2.($title2 ? ' - '.$title2 : '');
1427  if ($output[0]['string']) {
1428  $title2 .= ($title2 ? ' - ' : '').$output[0]['string'];
1429  }
1430  if ($output[0]['color']) {
1431  $color2 = $output[0]['color'];
1432  }
1433  } elseif (!empty($cases2[$h]) && is_array($cases2[$h]) && count($cases2[$h]) > 1) {
1434  $title2 = $langs->trans("Ref").' '.$ids2.($title2 ? ' - '.$title2 : '');
1435  $color2 = '222222';
1436  }
1437  print '<table class="nobordernopadding case centpercent">';
1438  print '<tr><td ';
1439  if ($style1 == 'peruser_notbusy') {
1440  print 'style="border: 1px solid #'.($color1 ? $color1 : "888").' !important" ';
1441  } elseif ($color1) {
1442  print ($color1 ? 'style="background: #'.$color1.';"' : '');
1443  }
1444  print 'class="';
1445  print ($style1 ? $style1.' ' : '');
1446  print 'onclickopenref center'.($title2 ? ' classfortooltip' : '').($title1 ? ' cursorpointer' : '').'" ref="ref_'.$username->id.'_'.sprintf("%04d", $year).'_'.sprintf("%02d", $month).'_'.sprintf("%02d", $day).'_'.sprintf("%02d", $h).'_00_'.($ids1 ? $ids1 : 'none').'"'.($title1 ? ' title="'.$title1.'"' : '').'>';
1447  print $string1;
1448  print '</td><td ';
1449  if ($style2 == 'peruser_notbusy') {
1450  print 'style="border: 1px solid #'.($color2 ? $color2 : "888").' !important" ';
1451  } elseif ($color2) {
1452  print ($color2 ? 'style="background: #'.$color2.';"' : '');
1453  }
1454  print 'class="';
1455  print ($style2 ? $style2.' ' : '');
1456  print 'onclickopenref center'.($title2 ? ' classfortooltip' : '').($title1 ? ' cursorpointer' : '').'" ref="ref_'.$username->id.'_'.sprintf("%04d", $year).'_'.sprintf("%02d", $month).'_'.sprintf("%02d", $day).'_'.sprintf("%02d", $h).'_30_'.($ids2 ? $ids2 : 'none').'"'.($title2 ? ' title="'.$title2.'"' : '').'>';
1457  print $string2;
1458  print '</td></tr>';
1459  print '</table>';
1460  print '</td>';
1461  }
1462 }
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
Definition: agenda.php:118
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.
Definition: agenda.lib.php:51
calendars_prepare_head($param)
Define head array for tabs of agenda setup pages.
Definition: agenda.lib.php:483
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 manage projects.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
Definition: user.class.php:48
if(isModEnabled('facture') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $sql
Social contributions to pay.
Definition: index.php:746
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
dol_get_next_week($day, $week, $month, $year)
Return next week.
Definition: date.lib.php:554
dol_get_first_day_week($day, $month, $year, $gm=false)
Return first day of week for a date.
Definition: date.lib.php:651
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
Definition: date.lib.php:122
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_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_string_nospecial($str, $newstr='_', $badcharstoreplace='', $badcharstoremove='', $keepspaces=0)
Clean a string from all punctuation characters to use it as a ref or login.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
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...
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.