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