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