dolibarr  17.0.4
list.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-2016 Laurent Destailleur <eldy@users.sourceforge.net>
5  * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
6  * Copyright (C) 2017 Open-DSI <support@open-dsi.fr>
7  * Copyright (C) 2018-2021 Frédéric France <frederic.france@netlogic.fr>
8  * Copyright (C) 2020 Tobias Sekan <tobias.sekan@startmail.com>
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 
30 // Load Dolibarr environment
31 require '../../main.inc.php';
32 require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
33 require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
34 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
35 require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
36 include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
37 require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
38 
39 // Load translation files required by the page
40 $langs->loadLangs(array("users", "companies", "agenda", "commercial", "other", "orders", "bills"));
41 
42 $action = GETPOST('action', 'aZ09');
43 $massaction = GETPOST('massaction', 'alpha');
44 $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'actioncommlist'; // To manage different context of search
45 $optioncss = GETPOST('optioncss', 'alpha');
46 $toselect = GETPOST('toselect', 'array');
47 $confirm = GETPOST('confirm', 'alpha');
48 
49 $disabledefaultvalues = GETPOST('disabledefaultvalues', 'int');
50 
51 $mode = GETPOST('mode', 'aZ09');
52 if (empty($mode) && preg_match('/show_/', $action)) {
53  $mode = $action; // For backward compatibility
54 }
55 $resourceid = GETPOST("search_resourceid", "int") ?GETPOST("search_resourceid", "int") : GETPOST("resourceid", "int");
56 $pid = GETPOST("search_projectid", 'int', 3) ?GETPOST("search_projectid", 'int', 3) : GETPOST("projectid", 'int', 3);
57 $search_status = (GETPOST("search_status", 'aZ09') != '') ? GETPOST("search_status", 'aZ09') : GETPOST("status", 'aZ09');
58 $type = GETPOST('search_type', 'alphanohtml') ?GETPOST('search_type', 'alphanohtml') : GETPOST('type', 'alphanohtml');
59 $year = GETPOST("year", 'int');
60 $month = GETPOST("month", 'int');
61 $day = GETPOST("day", 'int');
62 
63 // Set actioncode (this code must be same for setting actioncode into peruser, listacton and index)
64 if (GETPOST('search_actioncode', 'array')) {
65  $actioncode = GETPOST('search_actioncode', 'array', 3);
66  if (!count($actioncode)) {
67  $actioncode = '0';
68  }
69 } else {
70  $actioncode = GETPOST("search_actioncode", "alpha", 3) ?GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode") == '0' ? '0' : ((empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) || $disabledefaultvalues) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE));
71 }
72 
73 $search_id = GETPOST('search_id', 'alpha');
74 $search_title = GETPOST('search_title', 'alpha');
75 $search_note = GETPOST('search_note', 'alpha');
76 
77 $dateselect = dol_mktime(0, 0, 0, GETPOST('dateselectmonth', 'int'), GETPOST('dateselectday', 'int'), GETPOST('dateselectyear', 'int'), 'tzuserrel');
78 $datestart_dtstart = dol_mktime(0, 0, 0, GETPOST('datestart_dtstartmonth', 'int'), GETPOST('datestart_dtstartday', 'int'), GETPOST('datestart_dtstartyear', 'int'), 'tzuserrel');
79 $datestart_dtend = dol_mktime(23, 59, 59, GETPOST('datestart_dtendmonth', 'int'), GETPOST('datestart_dtendday', 'int'), GETPOST('datestart_dtendyear', 'int'), 'tzuserrel');
80 $dateend_dtstart = dol_mktime(0, 0, 0, GETPOST('dateend_dtstartmonth', 'int'), GETPOST('dateend_dtstartday', 'int'), GETPOST('dateend_dtstartyear', 'int'), 'tzuserrel');
81 $dateend_dtend = dol_mktime(23, 59, 59, GETPOST('dateend_dtendmonth', 'int'), GETPOST('dateend_dtendday', 'int'), GETPOST('dateend_dtendyear', 'int'), 'tzuserrel');
82 if ($search_status == '' && !GETPOSTISSET('search_status')) {
83  $search_status = ((empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) || $disabledefaultvalues) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS);
84 }
85 if (empty($mode) && !GETPOSTISSET('mode')) {
86  $mode = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW);
87 }
88 
89 $filter = GETPOST("search_filter", 'alpha', 3) ?GETPOST("search_filter", 'alpha', 3) : GETPOST("filter", 'alpha', 3);
90 $filtert = GETPOST("search_filtert", "int", 3) ?GETPOST("search_filtert", "int", 3) : GETPOST("filtert", "int", 3);
91 $usergroup = GETPOST("search_usergroup", "int", 3) ?GETPOST("search_usergroup", "int", 3) : GETPOST("usergroup", "int", 3);
92 $showbirthday = empty($conf->use_javascript_ajax) ? (GETPOST("search_showbirthday", "int") ?GETPOST("search_showbirthday", "int") : GETPOST("showbirthday", "int")) : 1;
93 
94 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
95 $object = new ActionComm($db);
96 $hookmanager->initHooks(array('agendalist'));
97 
98 $extrafields = new ExtraFields($db);
99 
100 // fetch optionals attributes and labels
101 $extrafields->fetch_name_optionals_label($object->table_element);
102 
103 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
104 // If not choice done on calendar owner, we filter on user.
105 if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS)) {
106  $filtert = $user->id;
107 }
108 
109 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
110 $sortfield = GETPOST('sortfield', 'aZ09comma');
111 $sortorder = GETPOST('sortorder', 'aZ09comma');
112 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
113 if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
114  // If $page is not defined, or '' or -1 or if we click on clear filters
115  $page = 0;
116 }
117 $offset = $limit * $page;
118 if (!$sortorder) {
119  $sortorder = "DESC,DESC";
120  if ($search_status == 'todo') {
121  $sortorder = "DESC,DESC";
122  }
123 }
124 if (!$sortfield) {
125  $sortfield = "a.datep,a.id";
126  if ($search_status == 'todo') {
127  $sortfield = "a.datep,a.id";
128  }
129 }
130 
131 // Security check
132 $socid = GETPOST("search_socid", 'int') ?GETPOST("search_socid", 'int') : GETPOST("socid", 'int');
133 if ($user->socid) {
134  $socid = $user->socid;
135 }
136 if ($socid < 0) {
137  $socid = '';
138 }
139 
140 $canedit = 1;
141 if (empty($user->rights->agenda->myactions->read)) {
142  accessforbidden();
143 }
144 if (empty($user->rights->agenda->allactions->read)) {
145  $canedit = 0;
146 }
147 if (empty($user->rights->agenda->allactions->read) || $filter == 'mine') { // If no permission to see all, we show only affected to me
148  $filtert = $user->id;
149 }
150 
151 $arrayfields = array(
152  'a.id'=>array('label'=>"Ref", 'checked'=>1),
153  'owner'=>array('label'=>"Owner", 'checked'=>1),
154  'c.libelle'=>array('label'=>"Type", 'checked'=>1),
155  'a.label'=>array('label'=>"Title", 'checked'=>1),
156  'a.note'=>array('label'=>'Description', 'checked'=>0),
157  'a.datep'=>array('label'=>"DateStart", 'checked'=>1),
158  'a.datep2'=>array('label'=>"DateEnd", 'checked'=>1),
159  's.nom'=>array('label'=>"ThirdParty", 'checked'=>1),
160  'a.fk_contact'=>array('label'=>"Contact", 'checked'=>0),
161  'a.fk_element'=>array('label'=>"LinkedObject", 'checked'=>1, 'enabled'=>(!empty($conf->global->AGENDA_SHOW_LINKED_OBJECT))),
162  'a.datec'=>array('label'=>'DateCreation', 'checked'=>0, 'position'=>510),
163  'a.tms'=>array('label'=>'DateModification', 'checked'=>0, 'position'=>520),
164  'a.percent'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000)
165 );
166 // Extra fields
167 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
168 
169 $object->fields = dol_sort_array($object->fields, 'position');
170 $arrayfields = dol_sort_array($arrayfields, 'position');
171 
172 $result = restrictedArea($user, 'agenda', 0, '', 'myactions');
173 if ($user->socid && $socid) {
174  $result = restrictedArea($user, 'societe', $socid);
175 }
176 
177 
178 /*
179  * Actions
180  */
181 
182 if (GETPOST('cancel', 'alpha')) {
183  $mode = 'list';
184  $massaction = '';
185 }
186 
187 if (GETPOST("viewcal") || GETPOST("viewweek") || GETPOST("viewday")) {
188  $param = '';
189  if (is_array($_POST)) {
190  foreach ($_POST as $key => $val) {
191  $param .= '&'.$key.'='.urlencode($val);
192  }
193  }
194  //print $param;
195  header("Location: ".DOL_URL_ROOT.'/comm/action/index.php?'.$param);
196  exit;
197 }
198 
199 $parameters = array('id'=>$socid);
200 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
201 if ($reshook < 0) {
202  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
203 }
204 
205 // Selection of new fields
206 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
207 // Purge search criteria
208 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
209  //$actioncode='';
210  $search_id = '';
211  $search_title = '';
212  $search_note = '';
213  $datestart_dtstart = '';
214  $datestart_dtend = '';
215  $dateend_dtstart = '';
216  $dateend_dtend = '';
217  $actioncode = '';
218  $search_status = '';
219  $pid = '';
220  $socid = '';
221  $resourceid = '';
222  $filter = '';
223  $filtert = '';
224  $usergroup = '';
225  $toselect = array();
226  $search_array_options = array();
227 }
228 
229 if (empty($reshook) && !empty($massaction)) {
230  unset($percent);
231 
232  switch ($massaction) {
233  case 'set_all_events_to_todo':
234  $percent = ActionComm::EVENT_TODO;
235  break;
236 
237  case 'set_all_events_to_in_progress':
239  break;
240 
241  case 'set_all_events_to_finished':
242  $percent = ActionComm::EVENT_FINISHED;
243  break;
244  }
245 
246  if (isset($percent)) {
247  foreach ($toselect as $toselectid) {
248  $result = $object->updatePercent($toselectid, $percent);
249  if ($result < 0) {
250  dol_print_error($db);
251  break;
252  }
253  }
254  }
255 }
256 
257 // As mass deletion happens with a confirm step, $massaction is not use for the final step (deletion).
258 if (empty($reshook)) {
259  $objectclass = 'ActionComm';
260  $objectlabel = 'Events';
261  $uploaddir = true;
262  // Only users that can delete any event can remove records.
263  $permissiontodelete = $user->rights->agenda->allactions->delete;
264  $permissiontoadd = $user->rights->agenda->myactions->create;
265  include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
266 }
267 
268 /*
269  * View
270  */
271 
272 $form = new Form($db);
273 $userstatic = new User($db);
274 $formactions = new FormActions($db);
275 
276 $actionstatic = new ActionComm($db);
277 $societestatic = new Societe($db);
278 $contactstatic = new Contact($db);
279 
280 $nav = '';
281 $nav .= $form->selectDate($dateselect, 'dateselect', 0, 0, 1, '', 1, 0);
282 $nav .= ' <input type="submit" name="submitdateselect" class="button" value="'.$langs->trans("Refresh").'">';
283 
284 $now = dol_now();
285 
286 $help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda';
287 $title = $langs->trans("Agenda");
288 llxHeader('', $title, $help_url);
289 
290 // Define list of all external calendars
291 $listofextcals = array();
292 
293 $param = '';
294 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
295  $param .= '&contextpage='.urlencode($contextpage);
296 }
297 if ($limit > 0 && $limit != $conf->liste_limit) {
298  $param .= '&limit='.urlencode($limit);
299 }
300 if ($actioncode != '') {
301  if (is_array($actioncode)) {
302  foreach ($actioncode as $str_action) {
303  $param .= "&search_actioncode[]=".urlencode($str_action);
304  }
305  } else {
306  $param .= "&search_actioncode=".urlencode($actioncode);
307  }
308 }
309 if ($resourceid > 0) {
310  $param .= "&search_resourceid=".urlencode($resourceid);
311 }
312 if ($search_status != '') {
313  $param .= "&search_status=".urlencode($search_status);
314 }
315 if ($filter) {
316  $param .= "&search_filter=".urlencode($filter);
317 }
318 if ($filtert) {
319  $param .= "&search_filtert=".urlencode($filtert);
320 }
321 if ($usergroup > 0) {
322  $param .= "&search_usergroup=".urlencode($usergroup);
323 }
324 if ($socid > 0) {
325  $param .= "&search_socid=".urlencode($socid);
326 }
327 if ($showbirthday) {
328  $param .= "&search_showbirthday=1";
329 }
330 if ($pid) {
331  $param .= "&search_projectid=".urlencode($pid);
332 }
333 if ($type) {
334  $param .= "&search_type=".urlencode($type);
335 }
336 if ($search_id != '') {
337  $param .= '&search_title='.urlencode($search_id);
338 }
339 if ($search_title != '') {
340  $param .= '&search_title='.urlencode($search_title);
341 }
342 if ($search_note != '') {
343  $param .= '&search_note='.urlencode($search_note);
344 }
345 if (GETPOST('datestart_dtstartday', 'int')) {
346  $param .= '&datestart_dtstartday='.GETPOST('datestart_dtstartday', 'int');
347 }
348 if (GETPOST('datestart_dtstartmonth', 'int')) {
349  $param .= '&datestart_dtstartmonth='.GETPOST('datestart_dtstartmonth', 'int');
350 }
351 if (GETPOST('datestart_dtstartyear', 'int')) {
352  $param .= '&datestart_dtstartyear='.GETPOST('datestart_dtstartyear', 'int');
353 }
354 if (GETPOST('datestart_dtendday', 'int')) {
355  $param .= '&datestart_dtendday='.GETPOST('datestart_dtendday', 'int');
356 }
357 if (GETPOST('datestart_dtendmonth', 'int')) {
358  $param .= '&datestart_dtendmonth='.GETPOST('datestart_dtendmonth', 'int');
359 }
360 if (GETPOST('datestart_dtendyear', 'int')) {
361  $param .= '&datestart_dtendyear='.GETPOST('datestart_dtendyear', 'int');
362 }
363 if (GETPOST('dateend_dtstartday', 'int')) {
364  $param .= '&dateend_dtstartday='.GETPOST('dateend_dtstartday', 'int');
365 }
366 if (GETPOST('dateend_dtstartmonth', 'int')) {
367  $param .= '&dateend_dtstartmonth='.GETPOST('dateend_dtstartmonth', 'int');
368 }
369 if (GETPOST('dateend_dtstartyear', 'int')) {
370  $param .= '&dateend_dtstartyear='.GETPOST('dateend_dtstartyear', 'int');
371 }
372 if (GETPOST('dateend_dtendday', 'int')) {
373  $param .= '&dateend_dtendday='.GETPOST('dateend_dtendday', 'int');
374 }
375 if (GETPOST('dateend_dtendmonth', 'int')) {
376  $param .= '&dateend_dtendmonth='.GETPOST('dateend_dtendmonth', 'int');
377 }
378 if (GETPOST('dateend_dtendyear', 'int')) {
379  $param .= '&dateend_dtendyear='.GETPOST('dateend_dtendyear', 'int');
380 }
381 if ($optioncss != '') {
382  $param .= '&optioncss='.urlencode($optioncss);
383 }
384 // Add $param from extra fields
385 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
386 
387 $paramnoactionodate = $param;
388 
389 // List of mass actions available
390 $arrayofmassactions = array(
391  'set_all_events_to_todo' => $langs->trans("SetAllEventsToTodo"),
392  'set_all_events_to_in_progress' => $langs->trans("SetAllEventsToInProgress"),
393  'set_all_events_to_finished' => $langs->trans("SetAllEventsToFinished"),
394 );
395 if ($user->rights->agenda->allactions->delete) {
396  $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
397 }
398 if (isModEnabled('category') && $user->rights->agenda->myactions->create) {
399  $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag");
400 }
401 if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete','preaffecttag'))) {
402  $arrayofmassactions = array();
403 }
404 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
405 
406 $sql = "SELECT";
407 if ($usergroup > 0) {
408  $sql .= " DISTINCT";
409 }
410 $sql .= " s.nom as societe, s.rowid as socid, s.client, s.email as socemail,";
411 $sql .= " a.id, a.code, a.label, a.note, a.datep as dp, a.datep2 as dp2, a.fulldayevent, a.location,";
412 $sql .= " a.fk_user_author, a.fk_user_action,";
413 $sql .= " a.fk_contact, a.note, a.percent as percent,";
414 $sql .= " a.fk_element, a.elementtype, a.datec, a.tms as datem,";
415 $sql .= " c.code as type_code, c.libelle as type_label, c.color as type_color, c.type as type_type, c.picto as type_picto,";
416 $sql .= " sp.lastname, sp.firstname, sp.email, sp.phone, sp.address, sp.phone as phone_pro, sp.phone_mobile, sp.phone_perso, sp.fk_pays as country_id";
417 
418 // Add fields from extrafields
419 if (!empty($extrafields->attributes[$object->table_element]['label'])) {
420  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
421  $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
422  }
423 }
424 
425 // Add fields from hooks
426 $parameters = array();
427 $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
428 $sql .= $hookmanager->resPrint;
429 
430 $sqlfields = $sql; // $sql fields to remove for count total
431 
432 $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a";
433 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."actioncomm_extrafields as ef ON (a.id = ef.fk_object)";
434 if (empty($user->rights->societe->client->voir) && !$socid) {
435  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
436 }
437 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid";
438 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid";
439 $sql .= " ,".MAIN_DB_PREFIX."c_actioncomm as c";
440 // We must filter on resource table
441 if ($resourceid > 0) {
442  $sql .= ", ".MAIN_DB_PREFIX."element_resources as r";
443 }
444 // We must filter on assignement table
445 if ($filtert > 0 || $usergroup > 0) {
446  $sql .= ", ".MAIN_DB_PREFIX."actioncomm_resources as ar";
447 }
448 if ($usergroup > 0) {
449  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element";
450 }
451 $sql .= " WHERE c.id = a.fk_action";
452 $sql .= ' AND a.entity IN ('.getEntity('agenda').')';
453 // Condition on actioncode
454 if (!empty($actioncode)) {
455  if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
456  if ($actioncode == 'AC_NON_AUTO') {
457  $sql .= " AND c.type != 'systemauto'";
458  } elseif ($actioncode == 'AC_ALL_AUTO') {
459  $sql .= " AND c.type = 'systemauto'";
460  } else {
461  if ($actioncode == 'AC_OTH') {
462  $sql .= " AND c.type != 'systemauto'";
463  }
464  if ($actioncode == 'AC_OTH_AUTO') {
465  $sql .= " AND c.type = 'systemauto'";
466  }
467  }
468  } else {
469  if ($actioncode == 'AC_NON_AUTO') {
470  $sql .= " AND c.type != 'systemauto'";
471  } elseif ($actioncode == 'AC_ALL_AUTO') {
472  $sql .= " AND c.type = 'systemauto'";
473  } else {
474  if (is_array($actioncode)) {
475  $sql .= " AND c.code IN (".$db->sanitize("'".implode("','", $actioncode)."'", 1).")";
476  } else {
477  $sql .= " AND c.code IN (".$db->sanitize("'".implode("','", explode(',', $actioncode))."'", 1).")";
478  }
479  }
480  }
481 }
482 if ($resourceid > 0) {
483  $sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".((int) $resourceid);
484 }
485 if ($pid) {
486  $sql .= " AND a.fk_project=".((int) $pid);
487 }
488 if (empty($user->rights->societe->client->voir) && !$socid) {
489  $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = ".((int) $user->id).")";
490 }
491 if ($socid > 0) {
492  $sql .= " AND s.rowid = ".((int) $socid);
493 }
494 // We must filter on assignement table
495 if ($filtert > 0 || $usergroup > 0) {
496  $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'";
497 }
498 if ($type) {
499  $sql .= " AND c.id = ".((int) $type);
500 }
501 if ($search_status == '0') {
502  $sql .= " AND a.percent = 0";
503 }
504 if ($search_status == 'na') {
505  $sql .= " AND a.percent = -1";
506 } // Not applicable
507 if ($search_status == '50') {
508  $sql .= " AND (a.percent > 0 AND a.percent < 100)";
509 } // Running already started
510 if ($search_status == '100') {
511  $sql .= " AND a.percent = 100";
512 }
513 if ($search_status == 'done') {
514  $sql .= " AND (a.percent = 100)";
515 }
516 if ($search_status == 'todo') {
517  $sql .= " AND (a.percent >= 0 AND a.percent < 100)";
518 }
519 if ($search_id) {
520  $sql .= natural_search("a.id", $search_id, 1);
521 }
522 if ($search_title) {
523  $sql .= natural_search("a.label", $search_title);
524 }
525 if ($search_note) {
526  $sql .= natural_search('a.note', $search_note);
527 }
528 // We must filter on assignement table
529 if ($filtert > 0 || $usergroup > 0) {
530  $sql .= " AND (";
531  if ($filtert > 0) {
532  $sql .= "(ar.fk_element = ".((int) $filtert)." OR (ar.fk_element IS NULL AND a.fk_user_action = ".((int) $filtert)."))"; // The OR is for backward compatibility
533  }
534  if ($usergroup > 0) {
535  $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".((int) $usergroup);
536  }
537  $sql .= ")";
538 }
539 
540 // The second or of next test is to take event with no end date (we suppose duration is 1 hour in such case)
541 if ($dateselect > 0) {
542  $sql .= " AND ((a.datep2 >= '".$db->idate($dateselect)."' AND a.datep <= '".$db->idate($dateselect + 3600 * 24 - 1)."') OR (a.datep2 IS NULL AND a.datep > '".$db->idate($dateselect - 3600)."' AND a.datep <= '".$db->idate($dateselect + 3600 * 24 - 1)."'))";
543 }
544 if ($datestart_dtstart > 0) {
545  $sql .= " AND a.datep >= '".$db->idate($datestart_dtstart)."'";
546 }
547 if ($datestart_dtend > 0) {
548  $sql .= " AND a.datep <= '".$db->idate($datestart_dtend)."'";
549 }
550 if ($dateend_dtstart > 0) {
551  $sql .= " AND a.datep2 >= '".$db->idate($dateend_dtstart)."'";
552 }
553 if ($dateend_dtend > 0) {
554  $sql .= " AND a.datep2 <= '".$db->idate($dateend_dtend)."'";
555 }
556 
557 // Add where from extra fields
558 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
559 
560 // Add where from hooks
561 $parameters = array();
562 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
563 $sql .= $hookmanager->resPrint;
564 
565 // Count total nb of records
566 $nbtotalofrecords = '';
567 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
568  /* The fast and low memory method to get and count full list converts the sql into a sql count */
569  $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
570  $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
571 
572  $resql = $db->query($sqlforcount);
573  if ($resql) {
574  $objforcount = $db->fetch_object($resql);
575  $nbtotalofrecords = $objforcount->nbtotalofrecords;
576  } else {
577  dol_print_error($db);
578  }
579 
580  if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
581  $page = 0;
582  $offset = 0;
583  }
584  $db->free($resql);
585 }
586 
587 // Complete request and execute it with limit
588 $sql .= $db->order($sortfield, $sortorder);
589 if ($limit) {
590  $sql .= $db->plimit($limit + 1, $offset);
591 }
592 
593 $resql = $db->query($sql);
594 if (!$resql) {
595  dol_print_error($db);
596  exit;
597 }
598 
599 $num = $db->num_rows($resql);
600 
601 $arrayofselected = is_array($toselect) ? $toselect : array();
602 
603 // Local calendar
604 $newtitle = '<div class="nowrap clear inline-block minheight30 margintoponly">';
605 $newtitle .= '<input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> '.$langs->trans("LocalAgenda").' &nbsp; ';
606 $newtitle .= '</div>';
607 //$newtitle=$langs->trans($title);
608 
609 $tabactive = 'cardlist';
610 
611 $head = calendars_prepare_head($param);
612 
613 print '<form method="POST" id="searchFormList" class="listactionsfilter" action="'.$_SERVER["PHP_SELF"].'">'."\n";
614 
615 if ($optioncss != '') {
616  print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
617 }
618 print '<input type="hidden" name="token" value="'.newToken().'">';
619 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
620 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
621 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
622 print '<input type="hidden" name="type" value="'.$type.'">';
623 $nav = '';
624 
625 if ($filter) {
626  $nav .= '<input type="hidden" name="search_filter" value="'.$filter.'">';
627 }
628 if ($showbirthday) {
629  $nav .= '<input type="hidden" name="search_showbirthday" value="1">';
630 }
631 print $nav;
632 
633 //print dol_get_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action');
634 //print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid);
635 //print dol_get_fiche_end();
636 
637 
638 $s = $newtitle;
639 
640 // Calendars from hooks
641 $parameters = array();
642 $reshook = $hookmanager->executeHooks('addCalendarChoice', $parameters, $object, $action);
643 if (empty($reshook)) {
644  $s .= $hookmanager->resPrint;
645 } elseif ($reshook > 1) {
646  $s = $hookmanager->resPrint;
647 }
648 $viewyear = is_object($object) ? dol_print_date($object->datep, '%Y') : '';
649 $viewmonth = is_object($object) ? dol_print_date($object->datep, '%m') : '';
650 $viewday = is_object($object) ? dol_print_date($object->datep, '%d') : '';
651 $viewmode = '';
652 $viewmode .= '<a class="btnTitle btnTitleSelected reposition" href="'.DOL_URL_ROOT.'/comm/action/list.php?mode=show_list&restore_lastsearch_values=1'.$paramnoactionodate.'">';
653 //$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
654 $viewmode .= img_picto($langs->trans("List"), 'object_calendarlist', 'class="imgforviewmode pictoactionview block"');
655 //$viewmode .= '</span>';
656 $viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewList").'</span></a>';
657 
658 $viewmode .= '<a class="btnTitle reposition" href="'.DOL_URL_ROOT.'/comm/action/index.php?mode=show_month&year='.$viewyear.'&month='.$viewmonth.'&day='.$viewday.$paramnoactionodate.'">';
659 //$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
660 $viewmode .= img_picto($langs->trans("ViewCal"), 'object_calendarmonth', 'class="pictoactionview block"');
661 //$viewmode .= '</span>';
662 $viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewCal").'</span></a>';
663 
664 $viewmode .= '<a class="btnTitle reposition" href="'.DOL_URL_ROOT.'/comm/action/index.php?mode=show_week&year='.$viewyear.'&month='.$viewmonth.'&day='.$viewday.$paramnoactionodate.'">';
665 //$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
666 $viewmode .= img_picto($langs->trans("ViewWeek"), 'object_calendarweek', 'class="pictoactionview block"');
667 //$viewmode .= '</span>';
668 $viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewWeek").'</span></a>';
669 
670 $viewmode .= '<a class="btnTitle reposition" href="'.DOL_URL_ROOT.'/comm/action/index.php?mode=show_day&year='.$viewyear.'&month='.$viewmonth.'&day='.$viewday.$paramnoactionodate.'">';
671 //$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
672 $viewmode .= img_picto($langs->trans("ViewDay"), 'object_calendarday', 'class="pictoactionview block"');
673 //$viewmode .= '</span>';
674 $viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewDay").'</span></a>';
675 
676 $viewmode .= '<a class="btnTitle reposition marginrightonly" href="'.DOL_URL_ROOT.'/comm/action/peruser.php?mode=show_peruser&year='.$viewyear.'&month='.$viewmonth.'&day='.$viewday.$paramnoactionodate.'">';
677 //$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
678 $viewmode .= img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser', 'class="pictoactionview block"');
679 //$viewmode .= '</span>';
680 $viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewPerUser").'</span></a>';
681 
682 $viewmode .= '<span class="marginrightonly"></span>';
683 
684 // Add more views from hooks
685 $parameters = array();
686 $reshook = $hookmanager->executeHooks('addCalendarView', $parameters, $object, $action);
687 if (empty($reshook)) {
688  $viewmode .= $hookmanager->resPrint;
689 } elseif ($reshook > 1) {
690  $viewmode = $hookmanager->resPrint;
691 }
692 
693 $tmpforcreatebutton = dol_getdate(dol_now(), true);
694 
695 $newparam = '&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$tmpforcreatebutton['year'];
696 
697 //$param='month='.$monthshown.'&year='.$year;
698 $hourminsec = dol_print_date(dol_mktime(10, 0, 0, 1, 1, 1970, 'gmt'), '%H', 'gmt').'0000'; // Set $hourminsec to '100000' to auto set hour to 10:00 at creation
699 
700 $url = DOL_URL_ROOT.'/comm/action/card.php?action=create';
701 $url .= '&datep='.sprintf("%04d%02d%02d", $tmpforcreatebutton['year'], $tmpforcreatebutton['mon'], $tmpforcreatebutton['mday']).$hourminsec;
702 $url .= '&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam ? '?'.$newparam : ''));
703 
704 $newcardbutton = dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', $url, '', $user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create);
705 
706 $param .= '&mode='.$mode;
707 
708 print_barre_liste($langs->trans("Agenda"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, -1 * $nbtotalofrecords, 'object_action', 0, $nav.$newcardbutton, '', $limit, 0, 0, 1, $viewmode);
709 
710 print $s;
711 
712 $objecttmp = new ActionComm($db);
713 include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
714 
715 $moreforfilter = '';
716 
717 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
718 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields
719 if ($massactionbutton) {
720  $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
721 }
722 $i = 0;
723 
724 print '<div class="liste_titre liste_titre_bydiv centpercent">';
725 print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid);
726 print '</div>';
727 
728 print '<div class="div-table-responsive">';
729 print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
730 
731 print '<tr class="liste_titre_filter">';
732 // Action column
733 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
734  print '<td class="liste_titre" align="middle">';
735  $searchpicto = $form->showFilterButtons('left');
736  print $searchpicto;
737  print '</td>';
738 }
739 if (!empty($arrayfields['a.id']['checked'])) {
740  print '<td class="liste_titre"><input type="text" class="maxwidth50" name="search_id" value="'.$search_id.'"></td>';
741 }
742 if (!empty($arrayfields['owner']['checked'])) {
743  print '<td class="liste_titre"></td>';
744 }
745 if (!empty($arrayfields['c.libelle']['checked'])) {
746  print '<td class="liste_titre"></td>';
747 }
748 if (!empty($arrayfields['a.label']['checked'])) {
749  print '<td class="liste_titre"><input type="text" class="maxwidth75" name="search_title" value="'.$search_title.'"></td>';
750 }
751 if (!empty($arrayfields['a.note']['checked'])) {
752  print '<td class="liste_titre"><input type="text" class="maxwidth75" name="search_note" value="'.$search_note.'"></td>';
753 }
754 if (!empty($arrayfields['a.datep']['checked'])) {
755  print '<td class="liste_titre nowraponall" align="center">';
756  print '<div class="nowrap">';
757  print $form->selectDate($datestart_dtstart, 'datestart_dtstart', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'), 'tzuserrel');
758  print '</div>';
759  print '<div class="nowrap">';
760  print $form->selectDate($datestart_dtend, 'datestart_dtend', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('To'), 'tzuserrel');
761  print '</div>';
762  print '</td>';
763 }
764 if (!empty($arrayfields['a.datep2']['checked'])) {
765  print '<td class="liste_titre nowraponall" align="center">';
766  print '<div class="nowrap">';
767  print $form->selectDate($dateend_dtstart, 'dateend_dtstart', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'), 'tzuserrel');
768  print '</div>';
769  print '<div class="nowrap">';
770  print $form->selectDate($dateend_dtend, 'dateend_dtend', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('To'), 'tzuserrel');
771  print '</div>';
772  print '</td>';
773 }
774 if (!empty($arrayfields['s.nom']['checked'])) {
775  print '<td class="liste_titre"></td>';
776 }
777 if (!empty($arrayfields['a.fk_contact']['checked'])) {
778  print '<td class="liste_titre"></td>';
779 }
780 if (!empty($arrayfields['a.fk_element']['checked'])) {
781  print '<td class="liste_titre"></td>';
782 }
783 
784 // Extra fields
785 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
786 
787 // Fields from hook
788 $parameters = array('arrayfields'=>$arrayfields);
789 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
790 print $hookmanager->resPrint;
791 
792 if (!empty($arrayfields['a.datec']['checked'])) {
793  print '<td class="liste_titre"></td>';
794 }
795 if (!empty($arrayfields['a.tms']['checked'])) {
796  print '<td class="liste_titre"></td>';
797 }
798 if (!empty($arrayfields['a.percent']['checked'])) {
799  print '<td class="liste_titre right parentonrightofpage">';
800  $formactions->form_select_status_action('formaction', $search_status, 1, 'search_status', 1, 2, 'search_status width100 onrightofpage');
801  print '</td>';
802 }
803 // Action column
804 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
805  print '<td class="liste_titre" align="middle">';
806  $searchpicto = $form->showFilterButtons();
807  print $searchpicto;
808  print '</td>';
809 }
810 print '</tr>'."\n";
811 
812 $totalarray = array();
813 $totalarray['nbfield'] = 0;
814 
815 // Fields title label
816 // --------------------------------------------------------------------
817 print '<tr class="liste_titre">';
818 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
819  print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
820 }
821 if (!empty($arrayfields['a.id']['checked'])) {
822  print_liste_field_titre($arrayfields['a.id']['label'], $_SERVER["PHP_SELF"], "a.id", $param, "", "", $sortfield, $sortorder);
823  $totalarray['nbfield']++;
824 }
825 if (!empty($arrayfields['owner']['checked'])) {
826  print_liste_field_titre($arrayfields['owner']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder);
827  $totalarray['nbfield']++;
828 }
829 if (!empty($arrayfields['c.libelle']['checked'])) {
830  print_liste_field_titre($arrayfields['c.libelle']['label'], $_SERVER["PHP_SELF"], "c.libelle", $param, "", "", $sortfield, $sortorder);
831  $totalarray['nbfield']++;
832 }
833 if (!empty($arrayfields['a.label']['checked'])) {
834  print_liste_field_titre($arrayfields['a.label']['label'], $_SERVER["PHP_SELF"], "a.label", $param, "", "", $sortfield, $sortorder);
835  $totalarray['nbfield']++;
836 }
837 if (!empty($arrayfields['a.note']['checked'])) {
838  print_liste_field_titre($arrayfields['a.note']['label'], $_SERVER["PHP_SELF"], "a.note", $param, "", "", $sortfield, $sortorder);
839  $totalarray['nbfield']++;
840 }
841 //if (!empty($conf->global->AGENDA_USE_EVENT_TYPE))
842 if (!empty($arrayfields['a.datep']['checked'])) {
843  print_liste_field_titre($arrayfields['a.datep']['label'], $_SERVER["PHP_SELF"], "a.datep,a.id", $param, '', 'align="center"', $sortfield, $sortorder);
844  $totalarray['nbfield']++;
845 }
846 if (!empty($arrayfields['a.datep2']['checked'])) {
847  print_liste_field_titre($arrayfields['a.datep2']['label'], $_SERVER["PHP_SELF"], "a.datep2", $param, '', 'align="center"', $sortfield, $sortorder);
848  $totalarray['nbfield']++;
849 }
850 if (!empty($arrayfields['s.nom']['checked'])) {
851  print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", $param, "", "", $sortfield, $sortorder);
852  $totalarray['nbfield']++;
853 }
854 if (!empty($arrayfields['a.fk_contact']['checked'])) {
855  print_liste_field_titre($arrayfields['a.fk_contact']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder);
856  $totalarray['nbfield']++;
857 }
858 if (!empty($arrayfields['a.fk_element']['checked'])) {
859  print_liste_field_titre($arrayfields['a.fk_element']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder);
860  $totalarray['nbfield']++;
861 }
862 // Extra fields
863 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
864 // Hook fields
865 $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
866 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
867 print $hookmanager->resPrint;
868 
869 if (!empty($arrayfields['a.datec']['checked'])) {
870  print_liste_field_titre($arrayfields['a.datec']['label'], $_SERVER["PHP_SELF"], "a.datec,a.id", $param, "", 'align="center"', $sortfield, $sortorder);
871  $totalarray['nbfield']++;
872 }
873 if (!empty($arrayfields['a.tms']['checked'])) {
874  print_liste_field_titre($arrayfields['a.tms']['label'], $_SERVER["PHP_SELF"], "a.tms,a.id", $param, "", 'align="center"', $sortfield, $sortorder);
875  $totalarray['nbfield']++;
876 }
877 
878 if (!empty($arrayfields['a.percent']['checked'])) {
879  print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "a.percent", $param, "", 'align="center"', $sortfield, $sortorder);
880  $totalarray['nbfield']++;
881 }
882 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
883  print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
884 }
885 $totalarray['nbfield']++;
886 print "</tr>\n";
887 
888 $now = dol_now();
889 $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60;
890 
891 require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php';
892 $caction = new CActionComm($db);
893 $arraylist = $caction->liste_array(1, 'code', '', (empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : 0), '', 1);
894 $contactListCache = array();
895 
896 // Loop on record
897 // --------------------------------------------------------------------
898 $i = 0;
899 //$savnbfield = $totalarray['nbfield'];
900 //$totalarray['nbfield'] = 0;
901 $imaxinloop = ($limit ? min($num, $limit) : $num);
902 while ($i < $imaxinloop) {
903  $obj = $db->fetch_object($resql);
904  if (empty($obj)) {
905  break; // Should not happen
906  }
907 
908  // Store properties in $object
909  $object->setVarsFromFetchObj($obj);
910 
911  // Discard auto action if option is on
912  if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->type_code == 'AC_OTH_AUTO') {
913  $i++;
914  continue;
915  }
916 
917  $actionstatic->id = $obj->id;
918  $actionstatic->ref = $obj->id;
919  $actionstatic->code = $obj->code;
920  $actionstatic->type_code = $obj->type_code;
921  $actionstatic->type_label = $obj->type_label;
922  $actionstatic->type_picto = $obj->type_picto;
923  $actionstatic->type_color = $obj->type_color;
924  $actionstatic->label = $obj->label;
925  $actionstatic->location = $obj->location;
926  $actionstatic->note_private = dol_htmlentitiesbr($obj->note);
927  $actionstatic->datep = $db->jdate($obj->dp);
928  $actionstatic->percentage = $obj->percent;
929  $actionstatic->authorid = $obj->fk_user_author;
930  $actionstatic->userownerid = $obj->fk_user_action;
931 
932  // Initialize $this->userassigned && this->socpeopleassigned array && this->userownerid
933  // but only if we need it
934  if (!empty($arrayfields['a.fk_contact']['checked'])) {
935  $actionstatic->fetchResources();
936  }
937 
938  print '<tr class="oddeven">';
939  // Action column
940  if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
941  print '<td class="nowrap center">';
942  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
943  $selected = 0;
944  if (in_array($obj->id, $arrayofselected)) {
945  $selected = 1;
946  }
947  print '<input id="cb'.$obj->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->id.'"'.($selected ? ' checked="checked"' : '').'>';
948  }
949  print '</td>';
950  }
951  // Ref
952  if (!empty($arrayfields['a.id']['checked'])) {
953  print '<td class="nowraponall">';
954  print $actionstatic->getNomUrl(1, -1);
955  print '</td>';
956  }
957 
958  // User owner
959  if (!empty($arrayfields['owner']['checked'])) {
960  print '<td class="tdoverflowmax150">'; // With edge and chrome the td overflow is not supported correctly when content is not full text.
961  if ($obj->fk_user_action > 0) {
962  $userstatic->fetch($obj->fk_user_action);
963  print $userstatic->getNomUrl(-1);
964  } else {
965  print '&nbsp;';
966  }
967  print '</td>';
968  }
969 
970  // Type
971  if (!empty($arrayfields['c.libelle']['checked'])) {
972  print '<td class="nowraponall">';
973  print $actionstatic->getTypePicto();
974  $labeltype = $obj->type_code;
975  if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($arraylist[$labeltype])) {
976  $labeltype = 'AC_OTH';
977  }
978  if (preg_match('/^TICKET_MSG/', $actionstatic->code)) {
979  $labeltype = $langs->trans("Message");
980  } else {
981  if (!empty($arraylist[$labeltype])) {
982  $labeltype = $arraylist[$labeltype];
983  }
984  if ($obj->type_code == 'AC_OTH_AUTO' && ($obj->type_code != $obj->code) && $labeltype && !empty($arraylist[$obj->code])) {
985  $labeltype .= ' - '.$arraylist[$obj->code]; // Use code in priority on type_code
986  }
987  }
988  print dol_trunc($labeltype, 28);
989  print '</td>';
990  }
991 
992  // Label
993  if (!empty($arrayfields['a.label']['checked'])) {
994  print '<td class="tdoverflowmax200" title="'.dol_escape_htmltag($actionstatic->label).'">';
995  print $actionstatic->label;
996  print '</td>';
997  }
998 
999  // Description
1000  if (!empty($arrayfields['a.note']['checked'])) {
1001  print '<td class="tdoverflowonsmartphone">';
1002  $text = dolGetFirstLineOfText(dol_string_nohtmltag($actionstatic->note_private, 1));
1003  print $form->textwithtooltip(dol_trunc($text, 48), $actionstatic->note_private);
1004  print '</td>';
1005  }
1006 
1007  $formatToUse = $obj->fulldayevent ? 'day' : 'dayhour';
1008 
1009  // Start date
1010  if (!empty($arrayfields['a.datep']['checked'])) {
1011  print '<td class="center nowraponall">';
1012  if (empty($obj->fulldayevent)) {
1013  print dol_print_date($db->jdate($obj->dp), $formatToUse, 'tzuserrel');
1014  } else {
1015  $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT');
1016  print dol_print_date($db->jdate($obj->dp), $formatToUse, ($tzforfullday ? $tzforfullday : 'tzuserrel'));
1017  }
1018  $late = 0;
1019  if ($actionstatic->hasDelay() && $actionstatic->percentage >= 0 && $actionstatic->percentage < 100 ) {
1020  $late = 1;
1021  }
1022  if ($late) {
1023  print img_warning($langs->trans("Late")).' ';
1024  }
1025  print '</td>';
1026  }
1027 
1028  // End date
1029  if (!empty($arrayfields['a.datep2']['checked'])) {
1030  print '<td class="center nowraponall">';
1031  if (empty($obj->fulldayevent)) {
1032  print dol_print_date($db->jdate($obj->dp2), $formatToUse, 'tzuserrel');
1033  } else {
1034  $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT');
1035  print dol_print_date($db->jdate($obj->dp2), $formatToUse, ($tzforfullday ? $tzforfullday : 'tzuserrel'));
1036  }
1037  print '</td>';
1038  }
1039 
1040  // Third party
1041  if (!empty($arrayfields['s.nom']['checked'])) {
1042  print '<td class="tdoverflowmax150">';
1043  if ($obj->socid > 0) {
1044  $societestatic->id = $obj->socid;
1045  $societestatic->client = $obj->client;
1046  $societestatic->name = $obj->societe;
1047  $societestatic->email = $obj->socemail;
1048 
1049  print $societestatic->getNomUrl(1, '', 28);
1050  } else {
1051  print '&nbsp;';
1052  }
1053  print '</td>';
1054  }
1055 
1056  // Contact
1057  if (!empty($arrayfields['a.fk_contact']['checked'])) {
1058  print '<td class="tdoverflowmax100">';
1059 
1060  if (!empty($actionstatic->socpeopleassigned)) {
1061  $contactList = array();
1062  foreach ($actionstatic->socpeopleassigned as $socpeopleassigned) {
1063  if (!isset($contactListCache[$socpeopleassigned['id']])) {
1064  // if no cache found we fetch it
1065  $contact = new Contact($db);
1066  if ($contact->fetch($socpeopleassigned['id']) > 0) {
1067  $contactListCache[$socpeopleassigned['id']] = $contact->getNomUrl(1, '', 0);
1068  $contactList[] = $contact->getNomUrl(1, '', 0);
1069  }
1070  } else {
1071  // use cache
1072  $contactList[] = $contactListCache[$socpeopleassigned['id']];
1073  }
1074  }
1075  if (!empty($contactList)) {
1076  print implode(', ', $contactList);
1077  }
1078  } elseif ($obj->fk_contact > 0) { //keep for retrocompatibility with faraway event
1079  $contactstatic->id = $obj->fk_contact;
1080  $contactstatic->email = $obj->email;
1081  $contactstatic->lastname = $obj->lastname;
1082  $contactstatic->firstname = $obj->firstname;
1083  $contactstatic->phone_pro = $obj->phone_pro;
1084  $contactstatic->phone_mobile = $obj->phone_mobile;
1085  $contactstatic->phone_perso = $obj->phone_perso;
1086  $contactstatic->country_id = $obj->country_id;
1087  print $contactstatic->getNomUrl(1, '', 0);
1088  } else {
1089  print "&nbsp;";
1090  }
1091  print '</td>';
1092  }
1093 
1094  // Linked object
1095  if (!empty($arrayfields['a.fk_element']['checked'])) {
1096  print '<td class="tdoverflowmax150">';
1097  //var_dump($obj->fkelement.' '.$obj->elementtype);
1098  if ($obj->fk_element > 0 && !empty($obj->elementtype)) {
1099  include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
1100  print dolGetElementUrl($obj->fk_element, $obj->elementtype, 1);
1101  } else {
1102  print "&nbsp;";
1103  }
1104  print '</td>';
1105  }
1106 
1107  // Extra fields
1108  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1109  // Fields from hook
1110  $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
1111  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
1112  print $hookmanager->resPrint;
1113 
1114  // Date creation
1115  if (!empty($arrayfields['a.datec']['checked'])) {
1116  // Status/Percent
1117  print '<td align="center" class="nowrap">'.dol_print_date($db->jdate($obj->datec), 'dayhour', 'tzuserrel').'</td>';
1118  }
1119  // Date update
1120  if (!empty($arrayfields['a.tms']['checked'])) {
1121  print '<td align="center" class="nowrap">'.dol_print_date($db->jdate($obj->datem), 'dayhour', 'tzuserrel').'</td>';
1122  }
1123  if (!empty($arrayfields['a.percent']['checked'])) {
1124  // Status/Percent
1125  $datep = $db->jdate($obj->dp);
1126  print '<td align="center" class="nowrap">'.$actionstatic->LibStatut($obj->percent, 5, 0, $datep).'</td>';
1127  }
1128  // Action column
1129  if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1130  print '<td class="nowrap center">';
1131  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1132  $selected = 0;
1133  if (in_array($obj->id, $arrayofselected)) {
1134  $selected = 1;
1135  }
1136  print '<input id="cb'.$obj->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->id.'"'.($selected ? ' checked="checked"' : '').'>';
1137  }
1138  print '</td>';
1139  }
1140 
1141  print '</tr>'."\n";
1142 
1143  $i++;
1144 }
1145 // If no record found
1146 if ($num == 0) {
1147  print '<tr><td colspan="'.$totalarray['nbfield'].'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
1148 }
1149 
1150 
1151 print '</table>'."\n";
1152 print '</div>'."\n";
1153 
1154 print '</form>'."\n";
1155 
1156 $db->free($resql);
1157 
1158 // End of page
1159 llxFooter();
1160 $db->close();
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
Definition: agenda.php:118
print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, $filtera, $filtert, $filterd, $pid, $socid, $action, $showextcals=array(), $actioncode='', $usergroupid='', $excludetype='', $resourceid=0)
Show filter form in agenda view.
Definition: agenda.lib.php:51
calendars_prepare_head($param)
Define head array for tabs of agenda setup pages.
Definition: agenda.lib.php:483
if(preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if(preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if($action=='set') elseif($action=='specimen') elseif($action=='setmodel') elseif($action=='del') elseif($action=='setdoc') $formactions
View.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:56
llxFooter()
Empty footer.
Definition: wrapper.php:70
Class to manage agenda events (actions)
const EVENT_FINISHED
Typical value for a event that is in a finished state.
const EVENT_IN_PROGRESS
Typical value for a event that is in a progress state.
const EVENT_TODO
Typical value for a event that is in a todo state.
Class to manage different types of events.
Class to manage contact/addresses.
Class to manage standard extra fields.
Class to manage building of HTML components.
Class to manage generation of HTML components Only common components must be here.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
Definition: user.class.php:47
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:745
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
dolGetElementUrl($objectid, $objecttype, $withpicto=0, $option='')
Return link url to an object.
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...
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
dolGetFirstLineOfText($text, $nboflines=1, $charset='UTF-8')
Return first line of text.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
isModEnabled($module)
Is Dolibarr module enabled.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
$nbtotalofrecords
Count total nb of records.
Definition: list.php:329
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.