dolibarr  x.y.z
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 (empty($user->rights->agenda->myactions->read)) {
90 }
91 if (empty($user->rights->agenda->allactions->read)) {
92  $canedit = 0;
93 }
94 if (empty($user->rights->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';
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 = dol_mktime(0, 0, 0, $first_month, $first_day, $first_year, 'gmt');
354 
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');
359 //print dol_print_date($lastdaytoshow,'dayhour');
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 $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";
367 $nav .= " <span id=\"month_name\">".dol_print_date(dol_mktime(0, 0, 0, $first_month, $first_day, $first_year), "%Y").", ".$langs->trans("Week")." ".$week;
368 $nav .= " </span>\n";
369 $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";
370 if (empty($conf->dol_optimize_smallscreen)) {
371  $nav .= " &nbsp; <a href=\"?year=".$nowyear."&amp;month=".$nowmonth."&amp;day=".$nowday.$param."\">".$langs->trans("Today")."</a> ";
372 }
373 $nav .= $form->selectDate($dateselect, 'dateselect', 0, 0, 1, '', 1, 0);
374 $nav .= ' <button type="submit" class="liste_titre button_search" name="button_search_x" value="x"><span class="fa fa-search"></span></button>';
375 
376 // Must be after the nav definition
377 $param .= '&year='.urlencode($year).'&month='.urlencode($month).($day ? '&day='.urlencode($day) : '');
378 //print 'x'.$param;
379 
380 
381 $paramnoaction = preg_replace('/action=[a-z_]+/', '', $param);
382 
383 $head = calendars_prepare_head($paramnoaction);
384 
385 print '<form method="POST" id="searchFormList" class="listactionsfilter" action="'.$_SERVER["PHP_SELF"].'">'."\n";
386 
387 $showextcals = $listofextcals;
388 // Legend
389 if ($conf->use_javascript_ajax) {
390  $s = '';
391  $s .= '<script type="text/javascript">'."\n";
392  $s .= 'jQuery(document).ready(function () {'."\n";
393  $s .= 'jQuery("#check_mytasks").click(function() { jQuery(".family_mytasks").toggle(); jQuery(".family_other").toggle(); });'."\n";
394  $s .= 'jQuery("#check_birthday").click(function() { jQuery(".family_birthday").toggle(); });'."\n";
395  $s .= 'jQuery(".family_birthday").toggle();'."\n";
396  if ($mode == "show_week" || $mode == "show_month" || empty($mode)) {
397  $s .= 'jQuery( "td.sortable" ).sortable({connectWith: ".sortable",placeholder: "ui-state-highlight",items: "div:not(.unsortable)", receive: function( event, ui ) {';
398  }
399  $s .= '});'."\n";
400  $s .= '</script>'."\n";
401  if (!empty($conf->use_javascript_ajax)) {
402  $s .= '<div class="nowrap clear float"><input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> '.$langs->trans("LocalAgenda").' &nbsp; </div>';
403  if (is_array($showextcals) && count($showextcals) > 0) {
404  foreach ($showextcals as $val) {
405  $htmlname = md5($val['name']);
406  $s .= '<script type="text/javascript">'."\n";
407  $s .= 'jQuery(document).ready(function () {'."\n";
408  $s .= ' jQuery("#check_ext'.$htmlname.'").click(function() {';
409  $s .= ' /* alert("'.$htmlname.'"); */';
410  $s .= ' jQuery(".family_ext'.$htmlname.'").toggle();';
411  $s .= ' });'."\n";
412  $s .= '});'."\n";
413  $s .= '</script>'."\n";
414  $s .= '<div class="nowrap float"><input type="checkbox" id="check_ext'.$htmlname.'" name="check_ext'.$htmlname.'" checked> '.$val ['name'].' &nbsp; </div>';
415  }
416  }
417 
418  //$s.='<div class="nowrap float"><input type="checkbox" id="check_birthday" name="check_birthday"> '.$langs->trans("AgendaShowBirthdayEvents").' &nbsp; </div>';
419 
420  // Calendars from hooks
421  $parameters = array();
422  $reshook = $hookmanager->executeHooks('addCalendarChoice', $parameters, $object, $action);
423  if (empty($reshook)) {
424  $s .= $hookmanager->resPrint;
425  } elseif ($reshook > 1) {
426  $s = $hookmanager->resPrint;
427  }
428  }
429 }
430 
431 $massactionbutton = '';
432 
433 $viewmode = '';
434 $viewmode .= '<a class="btnTitle reposition" href="'.DOL_URL_ROOT.'/comm/action/list.php?mode=show_list&restore_lastsearch_values=1'.$paramnoactionodate.'">';
435 //$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
436 $viewmode .= img_picto($langs->trans("List"), 'object_calendarlist', 'class="imgforviewmode pictoactionview block"');
437 //$viewmode .= '</span>';
438 $viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewList").'</span></a>';
439 
440 $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.'">';
441 //$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
442 $viewmode .= img_picto($langs->trans("ViewCal"), 'object_calendarmonth', 'class="pictoactionview block"');
443 //$viewmode .= '</span>';
444 $viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewCal").'</span></a>';
445 
446 $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.'">';
447 //$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
448 $viewmode .= img_picto($langs->trans("ViewWeek"), 'object_calendarweek', 'class="pictoactionview block"');
449 //$viewmode .= '</span>';
450 $viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewWeek").'</span></a>';
451 
452 $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.'">';
453 //$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
454 $viewmode .= img_picto($langs->trans("ViewDay"), 'object_calendarday', 'class="pictoactionview block"');
455 //$viewmode .= '</span>';
456 $viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewDay").'</span></a>';
457 
458 $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.'">';
459 //$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
460 $viewmode .= img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser', 'class="pictoactionview block"');
461 //$viewmode .= '</span>';
462 $viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewPerUser").'</span></a>';
463 
464 $viewmode .= '<span class="marginrightonly"></span>';
465 
466 // Add more views from hooks
467 $parameters = array(); $object = null;
468 $reshook = $hookmanager->executeHooks('addCalendarView', $parameters, $object, $action);
469 if (empty($reshook)) {
470  $viewmode .= $hookmanager->resPrint;
471 } elseif ($reshook > 1) {
472  $viewmode = $hookmanager->resPrint;
473 }
474 
475 
476 $newparam = '';
477 $newcardbutton = '';
478 if ($user->rights->agenda->myactions->create || $user->hasRight('agenda', 'allactions', 'create')) {
479  $tmpforcreatebutton = dol_getdate(dol_now(), true);
480 
481  $newparam .= '&month='.urlencode(str_pad($month, 2, "0", STR_PAD_LEFT)).'&year='.urlencode($tmpforcreatebutton['year']);
482  if ($begin_h !== '') {
483  $newparam .= '&begin_h='.urlencode($begin_h);
484  }
485  if ($end_h !== '') {
486  $newparam .= '&end_h='.urlencode($end_h);
487  }
488  if ($begin_d !== '') {
489  $newparam .= '&begin_d='.urlencode($begin_d);
490  }
491  if ($end_d !== '') {
492  $newparam .= '&end_d='.urlencode($end_d);
493  }
494 
495  //$param='month='.$monthshown.'&year='.$year;
496  $hourminsec = '100000';
497  $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 : '')));
498 }
499 
500 $num = '';
501 
502 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);
503 
504 $link = '';
505 //print load_fiche_titre('', $link.' &nbsp; &nbsp; '.$nav.' '.$newcardbutton, '');
506 
507 // Local calendar
508 $newtitle = '<div class="nowrap clear inline-block minheight30">';
509 $newtitle .= '<input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> '.$langs->trans("LocalAgenda").' &nbsp; ';
510 $newtitle .= '</div>';
511 //$newtitle=$langs->trans($title);
512 
513 $s = $newtitle;
514 
515 print $s;
516 
517 print '<div class="liste_titre liste_titre_bydiv centpercent">';
518 print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid);
519 print '</div>';
520 
521 
522 // Get event in an array
523 $eventarray = array();
524 
525 
526 // DEFAULT CALENDAR + AUTOEVENT CALENDAR + CONFERENCEBOOTH CALENDAR
527 $sql = 'SELECT';
528 if ($usergroup > 0) {
529  $sql .= " DISTINCT";
530 }
531 $sql .= ' a.id, a.label,';
532 $sql .= ' a.datep,';
533 $sql .= ' a.datep2,';
534 $sql .= ' a.percent,';
535 $sql .= ' a.fk_user_author,a.fk_user_action,';
536 $sql .= ' a.transparency, a.priority, a.fulldayevent, a.location,';
537 $sql .= ' a.fk_soc, a.fk_contact, a.fk_element, a.elementtype, a.fk_project,';
538 $sql .= ' ca.code, ca.libelle as type_label, ca.color, ca.type as type_type, ca.picto as type_picto';
539 $sql .= ' FROM '.MAIN_DB_PREFIX.'c_actioncomm as ca, '.MAIN_DB_PREFIX."actioncomm as a";
540 if (empty($user->rights->societe->client->voir) && !$socid) {
541  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
542 }
543 // We must filter on resource table
544 if ($resourceid > 0) {
545  $sql .= ", ".MAIN_DB_PREFIX."element_resources as r";
546 }
547 // We must filter on assignement table
548 if ($filtert > 0 || $usergroup > 0) {
549  $sql .= ", ".MAIN_DB_PREFIX."actioncomm_resources as ar";
550 }
551 if ($usergroup > 0) {
552  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element";
553 }
554 $sql .= ' WHERE a.fk_action = ca.id';
555 $sql .= ' AND a.entity IN ('.getEntity('agenda').')';
556 // Condition on actioncode
557 if (!empty($actioncode)) {
558  if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
559  if ($actioncode == 'AC_NON_AUTO') {
560  $sql .= " AND ca.type != 'systemauto'";
561  } elseif ($actioncode == 'AC_ALL_AUTO') {
562  $sql .= " AND ca.type = 'systemauto'";
563  } else {
564  if ($actioncode == 'AC_OTH') {
565  $sql .= " AND ca.type != 'systemauto'";
566  }
567  if ($actioncode == 'AC_OTH_AUTO') {
568  $sql .= " AND ca.type = 'systemauto'";
569  }
570  }
571  } else {
572  if ($actioncode == 'AC_NON_AUTO') {
573  $sql .= " AND ca.type != 'systemauto'";
574  } elseif ($actioncode == 'AC_ALL_AUTO') {
575  $sql .= " AND ca.type = 'systemauto'";
576  } else {
577  if (is_array($actioncode)) {
578  $sql .= " AND ca.code IN (".$db->sanitize("'".implode("','", $actioncode)."'", 1).")";
579  } else {
580  $sql .= " AND ca.code IN (".$db->sanitize("'".implode("','", explode(',', $actioncode))."'", 1).")";
581  }
582  }
583  }
584 }
585 if ($resourceid > 0) {
586  $sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".((int) $resourceid);
587 }
588 if ($pid) {
589  $sql .= " AND a.fk_project = ".((int) $pid);
590 }
591 if (empty($user->rights->societe->client->voir) && !$socid) {
592  $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = ".((int) $user->id).")";
593 }
594 if ($socid > 0) {
595  $sql .= ' AND a.fk_soc = '.((int) $socid);
596 }
597 // We must filter on assignement table
598 if ($filtert > 0 || $usergroup > 0) {
599  $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'";
600 }
601 if ($mode == 'show_day') {
602  $sql .= " AND (";
603  $sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year, 'tzuserrel'))."'";
604  $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year, 'tzuserrel'))."')";
605  $sql .= " OR ";
606  $sql .= " (a.datep2 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.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year, 'tzuserrel'))."'";
610  $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year, 'tzuserrel'))."')";
611  $sql .= ')';
612 } else {
613  // To limit array
614  $sql .= " AND (";
615  $sql .= " (a.datep BETWEEN '".$db->idate($firstdaytoshow - (60 * 60 * 24 * 2))."'"; // Start 2 day before $firstdaytoshow
616  $sql .= " AND '".$db->idate($lastdaytoshow + (60 * 60 * 24 * 2))."')"; // End 2 day after $lastdaytoshow
617  $sql .= " OR ";
618  $sql .= " (a.datep2 BETWEEN '".$db->idate($firstdaytoshow - (60 * 60 * 24 * 2))."'";
619  $sql .= " AND '".$db->idate($lastdaytoshow + (60 * 60 * 24 * 2))."')";
620  $sql .= " OR ";
621  $sql .= " (a.datep < '".$db->idate($firstdaytoshow - (60 * 60 * 24 * 2))."'";
622  $sql .= " AND a.datep2 > '".$db->idate($lastdaytoshow + (60 * 60 * 24 * 2))."')";
623  $sql .= ')';
624 }
625 if ($type) {
626  $sql .= " AND ca.id = ".((int) $type);
627 }
628 if ($status == '0') {
629  $sql .= " AND a.percent = 0";
630 }
631 if ($status == '-1' || $status == 'na') {
632  // Not applicable
633  $sql .= " AND a.percent = -1";
634 }
635 if ($status == '50') {
636  // Running already started
637  $sql .= " AND (a.percent > 0 AND a.percent < 100)";
638 }
639 if ($status == 'done' || $status == '100') {
640  $sql .= " AND (a.percent = 100)";
641 }
642 if ($status == 'todo') {
643  $sql .= " AND (a.percent >= 0 AND a.percent < 100)";
644 }
645 // We must filter on assignement table
646 if ($filtert > 0 || $usergroup > 0) {
647  $sql .= " AND (";
648  if ($filtert > 0) {
649  $sql .= "ar.fk_element = ".$filtert;
650  }
651  if ($usergroup > 0) {
652  $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".((int) $usergroup);
653  }
654  $sql .= ")";
655 }
656 // Sort on date
657 $sql .= ' ORDER BY fk_user_action, datep'; //fk_user_action
658 
659 
660 dol_syslog("comm/action/peruser.php", LOG_DEBUG);
661 $resql = $db->query($sql);
662 if ($resql) {
663  $num = $db->num_rows($resql);
664 
665  $i = 0;
666  while ($i < $num) {
667  $obj = $db->fetch_object($resql);
668 
669  // Discard auto action if option is on
670  if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->code == 'AC_OTH_AUTO') {
671  $i++;
672  continue;
673  }
674 
675  $datep = $db->jdate($obj->datep);
676  $datep2 = $db->jdate($obj->datep2);
677 
678  // Create a new object action
679  $event = new ActionComm($db);
680  $event->id = $obj->id;
681  $event->datep = $datep; // datep and datef are GMT date
682  $event->datef = $datep2;
683  $event->type_code = $obj->code;
684  $event->type_color = $obj->color;
685  $event->label = $obj->label;
686  $event->percentage = $obj->percent;
687  $event->authorid = $obj->fk_user_author; // user id of creator
688  $event->userownerid = $obj->fk_user_action; // user id of owner
689  $event->priority = $obj->priority;
690  $event->fulldayevent = $obj->fulldayevent;
691  $event->location = $obj->location;
692  $event->transparency = $obj->transparency;
693 
694  $event->fk_project = $obj->fk_project;
695 
696  $event->socid = $obj->fk_soc;
697  $event->contact_id = $obj->fk_contact;
698 
699  $event->fk_element = $obj->fk_element;
700  $event->elementtype = $obj->elementtype;
701 
702  // Defined date_start_in_calendar and date_end_in_calendar property
703  // They are date start and end of action but modified to not be outside calendar view.
704  if ($event->percentage <= 0) {
705  $event->date_start_in_calendar = $datep;
706  if ($datep2 != '' && $datep2 >= $datep) {
707  $event->date_end_in_calendar = $datep2;
708  } else {
709  $event->date_end_in_calendar = $datep;
710  }
711  } else {
712  $event->date_start_in_calendar = $datep;
713  if ($datep2 != '' && $datep2 >= $datep) {
714  $event->date_end_in_calendar = $datep2;
715  } else {
716  $event->date_end_in_calendar = $datep;
717  }
718  }
719 
720  // Check values
721  if ($event->date_end_in_calendar < $firstdaytoshow ||
722  $event->date_start_in_calendar >= $lastdaytoshow) {
723  // This record is out of visible range
724  unset($event);
725  } else {
726  //print $i.' - '.dol_print_date($this->date_start_in_calendar, 'dayhour').' - '.dol_print_date($this->date_end_in_calendar, 'dayhour').'<br>'."\n";
727  $event->fetch_userassigned(); // This load $event->userassigned
728 
729  if ($event->date_start_in_calendar < $firstdaytoshow) {
730  $event->date_start_in_calendar = $firstdaytoshow;
731  }
732  if ($event->date_end_in_calendar >= $lastdaytoshow) {
733  $event->date_end_in_calendar = ($lastdaytoshow - 1);
734  }
735 
736  // Add an entry in actionarray for each day
737  $daycursor = $event->date_start_in_calendar;
738  $annee = dol_print_date($daycursor, '%Y', 'tzuserrel');
739  $mois = dol_print_date($daycursor, '%m', 'tzuserrel');
740  $jour = dol_print_date($daycursor, '%d', 'tzuserrel');
741  //print $daycursor.' '.dol_print_date($daycursor, 'dayhour', 'gmt').' '.$event->id.' -> '.$annee.'-'.$mois.'-'.$jour.'<br>';
742 
743  // Loop on each day covered by action to prepare an index to show on calendar
744  $loop = true; $j = 0;
745  $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee, 'gmt');
746  do {
747  //if ($event->id==408) print 'daykey='.$daykey.' '.$event->datep.' '.$event->datef.'<br>';
748 
749  $eventarray[$daykey][] = $event;
750  $j++;
751 
752  $daykey += 60 * 60 * 24;
753  if ($daykey > $event->date_end_in_calendar) {
754  $loop = false;
755  }
756  } while ($loop);
757 
758  //print 'Event '.$i.' id='.$event->id.' (start='.dol_print_date($event->datep).'-end='.dol_print_date($event->datef);
759  //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>';
760  }
761  $i++;
762  }
763  $db->free($resql);
764 } else {
765  dol_print_error($db);
766 }
767 
768 $maxnbofchar = 18;
769 $cachethirdparties = array();
770 $cachecontacts = array();
771 $cacheusers = array();
772 
773 // Define theme_datacolor array
774 $color_file = DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/theme_vars.inc.php";
775 if (is_readable($color_file)) {
776  include $color_file;
777 }
778 if (!is_array($theme_datacolor)) {
779  $theme_datacolor = array(array(120, 130, 150), array(200, 160, 180), array(190, 190, 220));
780 }
781 
782 
783 $newparam = $param; // newparam is for birthday links
784 $newparam = preg_replace('/showbirthday=/i', 'showbirthday_=', $newparam); // To avoid replacement when replace day= is done
785 $newparam = preg_replace('/mode=show_month&?/i', '', $newparam);
786 $newparam = preg_replace('/mode=show_week&?/i', '', $newparam);
787 $newparam = preg_replace('/day=[0-9]+&?/i', '', $newparam);
788 $newparam = preg_replace('/month=[0-9]+&?/i', '', $newparam);
789 $newparam = preg_replace('/year=[0-9]+&?/i', '', $newparam);
790 $newparam = preg_replace('/viewweek=[0-9]+&?/i', '', $newparam);
791 $newparam = preg_replace('/showbirthday_=/i', 'showbirthday=', $newparam); // Restore correct parameter
792 $newparam .= '&viewweek=1';
793 
794 echo '<input type="hidden" name="actionmove" value="mupdate">';
795 echo '<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($_SERVER['PHP_SELF']).'?'.dol_escape_htmltag($_SERVER['QUERY_STRING']).'">';
796 echo '<input type="hidden" name="newdate" id="newdate">';
797 
798 
799 // Line header with list of days
800 
801 //print "begin_d=".$begin_d." end_d=".$end_d;
802 
803 $currentdaytoshow = $firstdaytoshow;
804 echo '<div class="div-table-responsive">';
805 
806 while ($currentdaytoshow < $lastdaytoshow) {
807  echo '<table class="centpercent noborder nocellnopadd cal_month">';
808 
809  echo '<tr class="liste_titre">';
810  echo '<td class="nopaddingtopimp nopaddingbottomimp nowraponsmartphone">';
811 
812  if ($canedit && $mode == 'show_peruser') {
813  // Filter on hours
814  print img_picto('', 'clock', 'class="fawidth30 inline-block paddingleft"');
815  print '<span class="hideonsmartphone" title="'.$langs->trans("VisibleTimeRange").'">'.$langs->trans("Hours").'</span>';
816  print "\n".'<div class="ui-grid-a inline-block"><div class="ui-block-a nowraponall">';
817  print '<input type="number" class="short" name="begin_h" value="'.$begin_h.'" min="0" max="23">';
818  if (empty($conf->dol_use_jmobile)) {
819  print ' - ';
820  } else {
821  print '</div><div class="ui-block-b">';
822  }
823  print '<input type="number" class="short" name="end_h" value="'.$end_h.'" min="1" max="24">';
824  if (empty($conf->dol_use_jmobile)) {
825  print ' '.$langs->trans("H");
826  }
827  print '</div></div>';
828 
829  print '<br>';
830 
831  // Filter on days
832  print img_picto('', 'clock', 'class="fawidth30 inline-block paddingleft"');
833  print '<span class="hideonsmartphone" title="'.$langs->trans("VisibleDaysRange").'">'.$langs->trans("DaysOfWeek").'</span>';
834  print "\n".'<div class="ui-grid-a inline-block"><div class="ui-block-a nowraponall">';
835  print '<input type="number" class="short" name="begin_d" value="'.$begin_d.'" min="1" max="7">';
836  if (empty($conf->dol_use_jmobile)) {
837  print ' - ';
838  } else {
839  print '</div><div class="ui-block-b">';
840  }
841  print '<input type="number" class="short" name="end_d" value="'.$end_d.'" min="1" max="7">';
842  print '</div></div>';
843  }
844 
845  print '</td>';
846  $i = 0; // 0 = sunday,
847  while ($i < 7) {
848  if (($i + 1) < $begin_d || ($i + 1) > $end_d) {
849  $i++;
850  continue;
851  }
852  echo '<td align="center" colspan="'.($end_h - $begin_h).'">';
853  echo '<span class="bold spandayofweek">'.$langs->trans("Day".(($i + (isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1)) % 7)).'</span>';
854  print "<br>";
855  if ($i) {
856  print dol_print_date(dol_time_plus_duree($currentdaytoshow, $i, 'd'), 'day');
857  } else {
858  print dol_print_date($currentdaytoshow, 'day');
859  }
860  echo "</td>\n";
861  $i++;
862  }
863  echo "</tr>\n";
864 
865  echo '<tr class="liste_titre">';
866  echo '<td></td>';
867  $i = 0;
868  while ($i < 7) {
869  if (($i + 1) < $begin_d || ($i + 1) > $end_d) {
870  $i++;
871  continue;
872  }
873  for ($h = $begin_h; $h < $end_h; $h++) {
874  echo '<td class="center">';
875  print '<small style="font-family: courier">'.sprintf("%02d", $h).'</small>';
876  print "</td>";
877  }
878  echo "</td>\n";
879  $i++;
880  }
881  echo "</tr>\n";
882 
883 
884  // Define $usernames
885  $usernames = array(); //init
886  $usernamesid = array();
887  /* Use this to have list of users only if users have events */
888  if (!empty($conf->global->AGENDA_SHOWOWNERONLY_ONPERUSERVIEW)) {
889  foreach ($eventarray as $daykey => $notused) {
890  // Get all assigned users for each event
891  foreach ($eventarray[$daykey] as $index => $event) {
892  $event->fetch_userassigned();
893  $listofuserid = $event->userassigned;
894  foreach ($listofuserid as $userid => $tmp) {
895  if (!in_array($userid, $usernamesid)) {
896  $usernamesid[$userid] = $userid;
897  }
898  }
899  }
900  }
901  } else {
902  /* Use this list to have for all users */
903  $sql = "SELECT DISTINCT u.rowid, u.lastname as lastname, u.firstname, u.statut, u.login, u.admin, u.entity";
904  $sql .= " FROM ".MAIN_DB_PREFIX."user as u";
905  if (isModEnabled('multicompany') && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
906  $sql .= ", ".MAIN_DB_PREFIX."usergroup_user as ug";
907  $sql .= " WHERE ug.entity IN (".getEntity('usergroup').")";
908  $sql .= " AND ug.fk_user = u.rowid ";
909  } else {
910  if ($usergroup > 0) {
911  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ug ON u.rowid = ug.fk_user";
912  }
913  $sql .= " WHERE u.entity IN (".getEntity('user').")";
914  }
915  $sql .= " AND u.statut = 1";
916  if ($usergroup > 0) {
917  $sql .= " AND ug.fk_usergroup = ".((int) $usergroup);
918  }
919 
920  //print $sql;
921  $resql = $db->query($sql);
922  if ($resql) {
923  $num = $db->num_rows($resql);
924  $i = 0;
925  if ($num) {
926  while ($i < $num) {
927  $obj = $db->fetch_object($resql);
928  $usernamesid[$obj->rowid] = $obj->rowid;
929  $i++;
930  }
931  }
932  } else {
933  dol_print_error($db);
934  }
935  }
936  //var_dump($usernamesid);
937  foreach ($usernamesid as $id) {
938  $tmpuser = new User($db);
939  $result = $tmpuser->fetch($id);
940  $usernames[] = $tmpuser;
941  }
942 
943  /*
944  if ($filtert > 0)
945  {
946  $tmpuser = new User($db);
947  $tmpuser->fetch($filtert);
948  $usernames[] = $tmpuser;
949  }
950  else if ($usergroup)
951  {
952  $tmpgroup = new UserGroup($db);
953  $tmpgroup->fetch($usergroup);
954  $usernames = $tmpgroup->listUsersForGroup();
955  }
956  else
957  {
958  $tmpgroup = new UserGroup($db);
959  //$tmpgroup->fetch($usergroup); No fetch, we want all users for all groups
960  $usernames = $tmpgroup->listUsersForGroup();
961  }*/
962 
963  // Load array of colors by type
964  $colorsbytype = array();
965  $labelbytype = array();
966  $sql = "SELECT code, color, libelle as label FROM ".MAIN_DB_PREFIX."c_actioncomm ORDER BY position";
967  $resql = $db->query($sql);
968  while ($obj = $db->fetch_object($resql)) {
969  $colorsbytype[$obj->code] = $obj->color;
970  $labelbytype[$obj->code] = $obj->label;
971  }
972 
973  // Loop on each user to show calendar
974  $todayarray = dol_getdate($now, 'fast');
975  $sav = $tmpday;
976  $showheader = true;
977  $var = false;
978  foreach ($usernames as $username) {
979  $var = !$var;
980  echo "<tr>";
981  echo '<td class="tdoverflowmax100 cal_current_month cal_peruserviewname'.($var ? ' cal_impair' : '').'">';
982  print $username->getNomUrl(-1, '', 0, 0, 20, 1, '');
983  print '</td>';
984  $tmpday = $sav;
985 
986  // Lopp on each day of week
987  $i = 0;
988  for ($iter_day = 0; $iter_day < 8; $iter_day++) {
989  if (($i + 1) < $begin_d || ($i + 1) > $end_d) {
990  $i++;
991  continue;
992  }
993 
994  // Show days of the current week
995  $curtime = dol_time_plus_duree($currentdaytoshow, $iter_day, 'd');
996  $tmparray = dol_getdate($curtime, 'fast');
997  $tmpday = $tmparray['mday'];
998  $tmpmonth = $tmparray['mon'];
999  $tmpyear = $tmparray['year'];
1000  //var_dump($curtime.' '.$tmpday.' '.$tmpmonth.' '.$tmpyear);
1001 
1002  $style = 'cal_current_month';
1003  if ($iter_day == 6) {
1004  $style .= ' cal_other_month';
1005  }
1006  $today = 0;
1007  if ($todayarray['mday'] == $tmpday && $todayarray['mon'] == $tmpmonth && $todayarray['year'] == $tmpyear) {
1008  $today = 1;
1009  }
1010  if ($today) {
1011  $style = 'cal_today_peruser';
1012  }
1013 
1014  show_day_events2($username, $tmpday, $tmpmonth, $tmpyear, 0, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, $showheader, $colorsbytype, $var);
1015 
1016  $i++;
1017  }
1018  echo "</tr>\n";
1019  $showheader = false;
1020  }
1021 
1022  echo "</table>\n";
1023  echo "<br>";
1024 
1025  $currentdaytoshow = dol_time_plus_duree($currentdaytoshow, 7, 'd');
1026 }
1027 
1028 echo '</div>';
1029 
1030 if (!empty($conf->global->AGENDA_USE_EVENT_TYPE) && !empty($conf->global->AGENDA_USE_COLOR_PER_EVENT_TYPE)) {
1031  $langs->load("commercial");
1032  print '<br>'.$langs->trans("Legend").': <br>';
1033  foreach ($colorsbytype as $code => $color) {
1034  if ($color) {
1035  print '<div style="float: left; padding: 2px; margin-right: 6px;"><div style="'.($color ? 'background: #'.$color.';' : '').'width:16px; float: left; margin-right: 4px;">&nbsp;</div>';
1036  print $langs->trans("Action".$code) != "Action".$code ? $langs->trans("Action".$code) : $labelbytype[$code];
1037  //print $code;
1038  print '</div>';
1039  }
1040  }
1041  //$color=sprintf("%02x%02x%02x",$theme_datacolor[0][0],$theme_datacolor[0][1],$theme_datacolor[0][2]);
1042  print '<div style="float: left; padding: 2px; margin-right: 6px;"><div class="peruser_busy" style="width:16px; float: left; margin-right: 4px;">&nbsp;</div>';
1043  print $langs->trans("Other");
1044  print '</div>';
1045  /* TODO Show this if at least one cumulated event
1046  print '<div style="float: left; padding: 2px; margin-right: 6px;"><div style="background: #222222; width:16px; float: left; margin-right: 4px;">&nbsp;</div>';
1047  print $langs->trans("SeveralEvents");
1048  print '</div>';
1049  */
1050 }
1051 
1052 print "\n".'</form>';
1053 print "\n";
1054 
1055 // Add js code to manage click on a box
1056 print '<script type="text/javascript">
1057 jQuery(document).ready(function() {
1058  jQuery(".onclickopenref").click(function() {
1059  var ref=$(this).attr(\'ref\');
1060  var res = ref.split("_");
1061  var userid = res[1];
1062  var year = res[2];
1063  var month = res[3];
1064  var day = res[4];
1065  var hour = res[5];
1066  var min = res[6];
1067  var ids = res[7];
1068  if (ids == \'none\') /* No event */
1069  {
1070  /* alert(\'no event\'); */
1071  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 : '')).'"
1072  window.location.href = url;
1073  }
1074  else if (ids.indexOf(",") > -1) /* There is several events */
1075  {
1076  /* alert(\'several events\'); */
1077  url = "'.DOL_URL_ROOT.'/comm/action/list.php?mode=show_list&filtert="+userid+"&dateselectyear="+year+"&dateselectmonth="+month+"&dateselectday="+day;
1078  window.location.href = url;
1079  }
1080  else /* One event */
1081  {
1082  /* alert(\'one event\'); */
1083  url = "'.DOL_URL_ROOT.'/comm/action/card.php?action=view&id="+ids
1084  window.location.href = url;
1085  }
1086  });
1087 });
1088 </script>';
1089 
1090 // End of page
1091 llxFooter();
1092 $db->close();
1093 
1094 
1095 
1096 
1117 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)
1118 {
1119  global $db;
1120  global $user, $conf, $langs, $hookmanager, $action;
1121  global $filter, $filtert, $status, $actioncode; // Filters used into search form
1122  global $theme_datacolor; // Array with a list of different we can use (come from theme)
1123  global $cachethirdparties, $cachecontacts, $cacheusers, $cacheprojects, $colorindexused;
1124  global $begin_h, $end_h;
1125 
1126  $cases1 = array(); // Color first half hour
1127  $cases2 = array(); // Color second half hour
1128 
1129  $i = 0; $numother = 0; $numbirthday = 0; $numical = 0; $numicals = array();
1130  //$ymd = sprintf("%04d", $year).sprintf("%02d", $month).sprintf("%02d", $day);
1131 
1132  $colorindexused[$user->id] = 0; // Color index for current user (user->id) is always 0
1133  $nextindextouse = count($colorindexused); // At first run this is 0, so first user has 0, next 1, ...
1134  //if ($username->id && $day==1) {
1135  //var_dump($eventarray);
1136  //}
1137 
1138  // We are in a particular day for $username, now we scan all events
1139  foreach ($eventarray as $daykey => $notused) {
1140  $annee = dol_print_date($daykey, '%Y');
1141  $mois = dol_print_date($daykey, '%m');
1142  $jour = dol_print_date($daykey, '%d');
1143 
1144  if ($day == $jour && $month == $mois && $year == $annee) { // Is it the day we are looking for when calling function ?
1145  // Scan all event for this date
1146  foreach ($eventarray[$daykey] as $index => $event) {
1147  //print $daykey.' '.dol_print_date($daykey, 'dayhour', 'gmt').' '.$year.'-'.$month.'-'.$day.' -> '.$event->id.' '.$index.' '.$annee.'-'.$mois.'-'.$jour."<br>\n";
1148  //var_dump($event);
1149 
1150  $keysofuserassigned = array_keys($event->userassigned);
1151  $ponct = ($event->date_start_in_calendar == $event->date_end_in_calendar);
1152 
1153  if (!in_array($username->id, $keysofuserassigned)) {
1154  continue; // We discard record if event is from another user than user we want to show
1155  }
1156  //if ($username->id != $event->userownerid) continue; // We discard record if event is from another user than user we want to show
1157 
1158  $parameters = array();
1159  $reshook = $hookmanager->executeHooks('formatEvent', $parameters, $event, $action); // Note that $action and $object may have been modified by some hooks
1160  if ($reshook < 0) {
1161  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1162  }
1163 
1164  // Define $color (Hex string like '0088FF') and $cssclass of event
1165  $color = -1; $cssclass = ''; $colorindex = -1;
1166  if (in_array($user->id, $keysofuserassigned)) {
1167  $cssclass = 'family_mytasks';
1168 
1169  if (empty($cacheusers[$event->userownerid])) {
1170  $newuser = new User($db);
1171  $newuser->fetch($event->userownerid);
1172  $cacheusers[$event->userownerid] = $newuser;
1173  }
1174  //var_dump($cacheusers[$event->userownerid]->color);
1175 
1176  // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event)
1177  if (!empty($cacheusers[$event->userownerid]->color)) {
1178  $color = $cacheusers[$event->userownerid]->color;
1179  }
1180 
1181  if (!empty($conf->global->AGENDA_USE_COLOR_PER_EVENT_TYPE)) {
1182  $color = $event->type_color;
1183  }
1184  } elseif ($event->type_code == 'ICALEVENT') {
1185  $numical++;
1186  if (!empty($event->icalname)) {
1187  if (!isset($numicals[dol_string_nospecial($event->icalname)])) {
1188  $numicals[dol_string_nospecial($event->icalname)] = 0;
1189  }
1190  $numicals[dol_string_nospecial($event->icalname)]++;
1191  }
1192 
1193  $color = $event->icalcolor;
1194  $cssclass = (!empty($event->icalname) ? 'family_ext'.md5($event->icalname) : 'family_other unsortable');
1195  } elseif ($event->type_code == 'BIRTHDAY') {
1196  $numbirthday++; $colorindex = 2; $cssclass = 'family_birthday unsortable'; $color = sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
1197  } else {
1198  $numother++;
1199  $color = ($event->icalcolor ? $event->icalcolor : -1);
1200  $cssclass = (!empty($event->icalname) ? 'family_ext'.md5($event->icalname) : 'family_other');
1201 
1202  if (empty($cacheusers[$event->userownerid])) {
1203  $newuser = new User($db);
1204  $newuser->fetch($event->userownerid);
1205  $cacheusers[$event->userownerid] = $newuser;
1206  }
1207  //var_dump($cacheusers[$event->userownerid]->color);
1208 
1209  // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event)
1210  if (!empty($cacheusers[$event->userownerid]->color)) {
1211  $color = $cacheusers[$event->userownerid]->color;
1212  }
1213 
1214  if (!empty($conf->global->AGENDA_USE_COLOR_PER_EVENT_TYPE)) {
1215  $color = $event->type_color;
1216  }
1217  }
1218 
1219  if ($color < 0) { // Color was not set on user card. Set color according to color index.
1220  // Define color index if not yet defined
1221  $idusertouse = ($event->userownerid ? $event->userownerid : 0);
1222  if (isset($colorindexused[$idusertouse])) {
1223  $colorindex = $colorindexused[$idusertouse]; // Color already assigned to this user
1224  } else {
1225  $colorindex = $nextindextouse;
1226  $colorindexused[$idusertouse] = $colorindex;
1227  if (!empty($theme_datacolor[$nextindextouse + 1])) {
1228  $nextindextouse++; // Prepare to use next color
1229  }
1230  }
1231  // Define color
1232  $color = sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
1233  }
1234 
1235  // Define all rects with event (cases1 is first half hour, cases2 is second half hour)
1236  for ($h = $begin_h; $h < $end_h; $h++) {
1237  //if ($username->id == 1 && $day==1) print 'h='.$h;
1238  $newcolor = ''; //init
1239  if (empty($event->fulldayevent)) {
1240  $a = dol_mktime((int) $h, 0, 0, $month, $day, $year, 'tzuserrel', 0);
1241  $b = dol_mktime((int) $h, 30, 0, $month, $day, $year, 'tzuserrel', 0);
1242  $c = dol_mktime((int) $h + 1, 0, 0, $month, $day, $year, 'tzuserrel', 0);
1243 
1244  $dateendtouse = $event->date_end_in_calendar;
1245  if ($dateendtouse == $event->date_start_in_calendar) {
1246  $dateendtouse++;
1247  }
1248 
1249  //print dol_print_date($event->date_start_in_calendar,'dayhour').'-'.dol_print_date($a,'dayhour').'-'.dol_print_date($b,'dayhour').'<br>';
1250 
1251  if ($event->date_start_in_calendar < $b && $dateendtouse > $a) {
1252  $busy = $event->transparency;
1253  $cases1[$h][$event->id]['busy'] = $busy;
1254  $cases1[$h][$event->id]['string'] = dol_print_date($event->date_start_in_calendar, 'dayhour', 'tzuserrel');
1255  if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) {
1256  $tmpa = dol_getdate($event->date_start_in_calendar, true);
1257  $tmpb = dol_getdate($event->date_end_in_calendar, true);
1258  if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) {
1259  $cases1[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'hour', 'tzuserrel');
1260  } else {
1261  $cases1[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'dayhour', 'tzuserrel');
1262  }
1263  }
1264  if ($event->label) {
1265  $cases1[$h][$event->id]['string'] .= ' - '.$event->label;
1266  }
1267  $cases1[$h][$event->id]['typecode'] = $event->type_code;
1268  $cases1[$h][$event->id]['color'] = $color;
1269  if ($event->fk_project > 0) {
1270  if (empty($cacheprojects[$event->fk_project])) {
1271  $tmpproj = new Project($db);
1272  $tmpproj->fetch($event->fk_project);
1273  $cacheprojects[$event->fk_project] = $tmpproj;
1274  }
1275  $cases1[$h][$event->id]['string'] .= ', '.$langs->trans("Project").': '.$cacheprojects[$event->fk_project]->ref.' - '.$cacheprojects[$event->fk_project]->title;
1276  }
1277  if ($event->socid > 0) {
1278  if (empty($cachethirdparties[$event->socid])) {
1279  $tmpthirdparty = new Societe($db);
1280  $tmpthirdparty->fetch($event->socid);
1281  $cachethirdparties[$event->socid] = $tmpthirdparty;
1282  }
1283  $cases1[$h][$event->id]['string'] .= ', '.$cachethirdparties[$event->socid]->name;
1284  }
1285  if ($event->contact_id > 0) {
1286  if (empty($cachecontacts[$event->contact_id])) {
1287  $tmpcontact = new Contact($db);
1288  $tmpcontact->fetch($event->contact_id);
1289  $cachecontacts[$event->contact_id] = $tmpcontact;
1290  }
1291  $cases1[$h][$event->id]['string'] .= ', '.$cachecontacts[$event->contact_id]->getFullName($langs);
1292  }
1293  }
1294  if ($event->date_start_in_calendar < $c && $dateendtouse > $b) {
1295  $busy = $event->transparency;
1296  $cases2[$h][$event->id]['busy'] = $busy;
1297  $cases2[$h][$event->id]['string'] = dol_print_date($event->date_start_in_calendar, 'dayhour', 'tzuserrel');
1298  if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) {
1299  $tmpa = dol_getdate($event->date_start_in_calendar, true);
1300  $tmpb = dol_getdate($event->date_end_in_calendar, true);
1301  if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) {
1302  $cases2[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'hour', 'tzuserrel');
1303  } else {
1304  $cases2[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'dayhour', 'tzuserrel');
1305  }
1306  }
1307  if ($event->label) {
1308  $cases2[$h][$event->id]['string'] .= ' - '.$event->label;
1309  }
1310  $cases2[$h][$event->id]['typecode'] = $event->type_code;
1311  $cases2[$h][$event->id]['color'] = $color;
1312  if ($event->fk_project > 0) {
1313  if (empty($cacheprojects[$event->fk_project])) {
1314  $tmpproj = new Project($db);
1315  $tmpproj->fetch($event->fk_project);
1316  $cacheprojects[$event->fk_project] = $tmpproj;
1317  }
1318  $cases2[$h][$event->id]['string'] .= ', '.$langs->trans("Project").': '.$cacheprojects[$event->fk_project]->ref.' - '.$cacheprojects[$event->fk_project]->title;
1319  }
1320  if ($event->socid > 0) {
1321  if (empty($cachethirdparties[$event->socid])) {
1322  $tmpthirdparty = new Societe($db);
1323  $tmpthirdparty->fetch($event->socid);
1324  $cachethirdparties[$event->socid] = $tmpthirdparty;
1325  }
1326  $cases2[$h][$event->id]['string'] .= ', '.$cachethirdparties[$event->socid]->name;
1327  }
1328  if ($event->contact_id > 0) {
1329  if (empty($cachecontacts[$event->contact_id])) {
1330  $tmpcontact = new Contact($db);
1331  $tmpcontact->fetch($event->contact_id);
1332  $cachecontacts[$event->contact_id] = $tmpcontact;
1333  }
1334  $cases2[$h][$event->id]['string'] .= ', '.$cachecontacts[$event->contact_id]->getFullName($langs);
1335  }
1336  }
1337  } else {
1338  $busy = $event->transparency;
1339  $cases1[$h][$event->id]['busy'] = $busy;
1340  $cases2[$h][$event->id]['busy'] = $busy;
1341  $cases1[$h][$event->id]['string'] = $event->label;
1342  $cases2[$h][$event->id]['string'] = $event->label;
1343  $cases1[$h][$event->id]['typecode'] = $event->type_code;
1344  $cases2[$h][$event->id]['typecode'] = $event->type_code;
1345  $cases1[$h][$event->id]['color'] = $color;
1346  $cases2[$h][$event->id]['color'] = $color;
1347  }
1348  }
1349  $i++;
1350  }
1351 
1352  break; // We found the date we were looking for. No need to search anymore.
1353  }
1354  }
1355 
1356  // Now output $casesX
1357  for ($h = $begin_h; $h < $end_h; $h++) {
1358  $color1 = ''; $color2 = '';
1359  $style1 = ''; $style2 = '';
1360  $string1 = '&nbsp;'; $string2 = '&nbsp;';
1361  $title1 = ''; $title2 = '';
1362  if (isset($cases1[$h]) && $cases1[$h] != '') {
1363  //$title1.=count($cases1[$h]).' '.(count($cases1[$h])==1?$langs->trans("Event"):$langs->trans("Events"));
1364  if (count($cases1[$h]) > 1) {
1365  $title1 .= count($cases1[$h]).' '.(count($cases1[$h]) == 1 ? $langs->trans("Event") : $langs->trans("Events"));
1366  }
1367  $string1 = '&nbsp;';
1368  if (empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) {
1369  $style1 = 'peruser_notbusy';
1370  } else {
1371  $style1 = 'peruser_busy';
1372  }
1373  foreach ($cases1[$h] as $id => $ev) {
1374  if ($ev['busy']) {
1375  $style1 = 'peruser_busy';
1376  }
1377  }
1378  }
1379  if (isset($cases2[$h]) && $cases2[$h] != '') {
1380  //$title2.=count($cases2[$h]).' '.(count($cases2[$h])==1?$langs->trans("Event"):$langs->trans("Events"));
1381  if (count($cases2[$h]) > 1) {
1382  $title2 .= count($cases2[$h]).' '.(count($cases2[$h]) == 1 ? $langs->trans("Event") : $langs->trans("Events"));
1383  }
1384  $string2 = '&nbsp;';
1385  if (empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) {
1386  $style2 = 'peruser_notbusy';
1387  } else {
1388  $style2 = 'peruser_busy';
1389  }
1390  foreach ($cases2[$h] as $id => $ev) {
1391  if ($ev['busy']) {
1392  $style2 = 'peruser_busy';
1393  }
1394  }
1395  }
1396 
1397  $ids1 = '';
1398  $ids2 = '';
1399  if (!empty($cases1[$h]) && is_array($cases1[$h]) && count($cases1[$h]) && array_keys($cases1[$h])) {
1400  $ids1 = join(',', array_keys($cases1[$h]));
1401  }
1402  if (!empty($cases2[$h]) && is_array($cases2[$h]) && count($cases2[$h]) && array_keys($cases2[$h])) {
1403  $ids2 = join(',', array_keys($cases2[$h]));
1404  }
1405 
1406  if ($h == $begin_h) {
1407  echo '<td class="'.$style.'_peruserleft cal_peruser'.($var ? ' cal_impair '.$style.'_impair' : '').'">';
1408  } else {
1409  echo '<td class="'.$style.' cal_peruser'.($var ? ' cal_impair '.$style.'_impair' : '').'">';
1410  }
1411  if (!empty($cases1[$h]) && is_array($cases1[$h]) && count($cases1[$h]) == 1) { // only 1 event
1412  $output = array_slice($cases1[$h], 0, 1);
1413  $title1 = $langs->trans("Ref").' '.$ids1.($title1 ? ' - '.$title1 : '');
1414  if ($output[0]['string']) {
1415  $title1 .= ($title1 ? ' - ' : '').$output[0]['string'];
1416  }
1417  if ($output[0]['color']) {
1418  $color1 = $output[0]['color'];
1419  }
1420  } elseif (!empty($cases1[$h]) && is_array($cases1[$h]) && count($cases1[$h]) > 1) {
1421  $title1 = $langs->trans("Ref").' '.$ids1.($title1 ? ' - '.$title1 : '');
1422  $color1 = '222222';
1423  }
1424 
1425  if (!empty($cases2[$h]) && is_array($cases2[$h]) && count($cases2[$h]) == 1) { // only 1 event
1426  $output = array_slice($cases2[$h], 0, 1);
1427  $title2 = $langs->trans("Ref").' '.$ids2.($title2 ? ' - '.$title2 : '');
1428  if ($output[0]['string']) {
1429  $title2 .= ($title2 ? ' - ' : '').$output[0]['string'];
1430  }
1431  if ($output[0]['color']) {
1432  $color2 = $output[0]['color'];
1433  }
1434  } elseif (!empty($cases2[$h]) && is_array($cases2[$h]) && count($cases2[$h]) > 1) {
1435  $title2 = $langs->trans("Ref").' '.$ids2.($title2 ? ' - '.$title2 : '');
1436  $color2 = '222222';
1437  }
1438  print '<table class="nobordernopadding" width="100%">';
1439  print '<tr><td ';
1440  if ($style1 == 'peruser_notbusy') {
1441  print 'style="border: 1px solid #'.($color1 ? $color1 : "888").' !important" ';
1442  } elseif ($color1) {
1443  print ($color1 ? 'style="background: #'.$color1.';"' : '');
1444  }
1445  print 'class="';
1446  print ($style1 ? $style1.' ' : '');
1447  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.'"' : '').'>';
1448  print $string1;
1449  print '</td><td ';
1450  if ($style2 == 'peruser_notbusy') {
1451  print 'style="border: 1px solid #'.($color2 ? $color2 : "888").' !important" ';
1452  } elseif ($color2) {
1453  print ($color2 ? 'style="background: #'.$color2.';"' : '');
1454  }
1455  print 'class="';
1456  print ($style2 ? $style2.' ' : '');
1457  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.'"' : '').'>';
1458  print $string2;
1459  print '</td></tr>';
1460  print '</table>';
1461  print '</td>';
1462  }
1463 }
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:45
if(isModEnabled('facture') &&!empty($user->rights->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') &&!empty($user->rights->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)) $resql
Social contributions to pay.
Definition: index.php:745
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:553
dol_get_first_day_week($day, $month, $year, $gm=false)
Return first day of week for a date.
Definition: date.lib.php:650
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
Definition: date.lib.php:121
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_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
dol_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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
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)
dol_string_nospecial($str, $newstr='_', $badcharstoreplace='', $badcharstoremove='')
Clean a string from all punctuation characters to use it as a ref or login.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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.
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.