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