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('datestartday_dtstart', 'int')) {
349  $param .= '&datestartday_dtstart='.GETPOST('datestartday_dtstart', 'int');
350 }
351 if (GETPOST('datestartmonth_dtstart', 'int')) {
352  $param .= '&datestartmonth_dtstart='.GETPOST('datestartmonth_dtstart', 'int');
353 }
354 if (GETPOST('datestartyear_dtstart', 'int')) {
355  $param .= '&datestartyear_dtstart='.GETPOST('datestartyear_dtstart', 'int');
356 }
357 if (GETPOST('datestartday_dtend', 'int')) {
358  $param .= '&datestartday_dtend='.GETPOST('datestartday_dtend', 'int');
359 }
360 if (GETPOST('datestartmonth_dtend', 'int')) {
361  $param .= '&datestartmonth_dtend='.GETPOST('datestartmonth_dtend', 'int');
362 }
363 if (GETPOST('datestartyear_dtend', 'int')) {
364  $param .= '&datestartyear_dtend='.GETPOST('datestartyear_dtend', 'int');
365 }
366 if (GETPOST('dateendday_dtstart', 'int')) {
367  $param .= '&dateendday_dtstart='.GETPOST('dateendday_dtstart', 'int');
368 }
369 if (GETPOST('dateendmonth_dtstart', 'int')) {
370  $param .= '&dateendmonth_dtstart='.GETPOST('dateendmonth_dtstart', 'int');
371 }
372 if (GETPOST('dateendyear_dtstart', 'int')) {
373  $param .= '&dateendyear_dtstart='.GETPOST('dateendyear_dtstart', 'int');
374 }
375 if (GETPOST('dateendday_dtend', 'int')) {
376  $param .= '&dateendday_dtend='.GETPOST('dateendday_dtend', 'int');
377 }
378 if (GETPOST('dateendmonth_dtend', 'int')) {
379  $param .= '&dateendmonth_dtend='.GETPOST('dateendmonth_dtend', 'int');
380 }
381 if (GETPOST('dateendyear_dtend', 'int')) {
382  $param .= '&dateendyear_dtend='.GETPOST('dateendyear_dtend', '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 $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a";
434 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."actioncomm_extrafields as ef ON (a.id = ef.fk_object)";
435 if (empty($user->rights->societe->client->voir) && !$socid) {
436  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
437 }
438 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid";
439 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid";
440 $sql .= " ,".MAIN_DB_PREFIX."c_actioncomm as c";
441 // We must filter on resource table
442 if ($resourceid > 0) {
443  $sql .= ", ".MAIN_DB_PREFIX."element_resources as r";
444 }
445 // We must filter on assignement table
446 if ($filtert > 0 || $usergroup > 0) {
447  $sql .= ", ".MAIN_DB_PREFIX."actioncomm_resources as ar";
448 }
449 if ($usergroup > 0) {
450  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element";
451 }
452 $sql .= " WHERE c.id = a.fk_action";
453 $sql .= ' AND a.entity IN ('.getEntity('agenda').')';
454 // Condition on actioncode
455 if (!empty($actioncode)) {
456  if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
457  if ($actioncode == 'AC_NON_AUTO') {
458  $sql .= " AND c.type != 'systemauto'";
459  } elseif ($actioncode == 'AC_ALL_AUTO') {
460  $sql .= " AND c.type = 'systemauto'";
461  } else {
462  if ($actioncode == 'AC_OTH') {
463  $sql .= " AND c.type != 'systemauto'";
464  }
465  if ($actioncode == 'AC_OTH_AUTO') {
466  $sql .= " AND c.type = 'systemauto'";
467  }
468  }
469  } else {
470  if ($actioncode == 'AC_NON_AUTO') {
471  $sql .= " AND c.type != 'systemauto'";
472  } elseif ($actioncode == 'AC_ALL_AUTO') {
473  $sql .= " AND c.type = 'systemauto'";
474  } else {
475  if (is_array($actioncode)) {
476  $sql .= " AND c.code IN (".$db->sanitize("'".implode("','", $actioncode)."'", 1).")";
477  } else {
478  $sql .= " AND c.code IN (".$db->sanitize("'".implode("','", explode(',', $actioncode))."'", 1).")";
479  }
480  }
481  }
482 }
483 if ($resourceid > 0) {
484  $sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".((int) $resourceid);
485 }
486 if ($pid) {
487  $sql .= " AND a.fk_project=".((int) $pid);
488 }
489 if (empty($user->rights->societe->client->voir) && !$socid) {
490  $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = ".((int) $user->id).")";
491 }
492 if ($socid > 0) {
493  $sql .= " AND s.rowid = ".((int) $socid);
494 }
495 // We must filter on assignement table
496 if ($filtert > 0 || $usergroup > 0) {
497  $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'";
498 }
499 if ($type) {
500  $sql .= " AND c.id = ".((int) $type);
501 }
502 if ($search_status == '0') {
503  $sql .= " AND a.percent = 0";
504 }
505 if ($search_status == 'na') {
506  $sql .= " AND a.percent = -1";
507 } // Not applicable
508 if ($search_status == '50') {
509  $sql .= " AND (a.percent > 0 AND a.percent < 100)";
510 } // Running already started
511 if ($search_status == '100') {
512  $sql .= " AND a.percent = 100";
513 }
514 if ($search_status == 'done') {
515  $sql .= " AND (a.percent = 100)";
516 }
517 if ($search_status == 'todo') {
518  $sql .= " AND (a.percent >= 0 AND a.percent < 100)";
519 }
520 if ($search_id) {
521  $sql .= natural_search("a.id", $search_id, 1);
522 }
523 if ($search_title) {
524  $sql .= natural_search("a.label", $search_title);
525 }
526 if ($search_note) {
527  $sql .= natural_search('a.note', $search_note);
528 }
529 // We must filter on assignement table
530 if ($filtert > 0 || $usergroup > 0) {
531  $sql .= " AND (";
532  if ($filtert > 0) {
533  $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
534  }
535  if ($usergroup > 0) {
536  $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".((int) $usergroup);
537  }
538  $sql .= ")";
539 }
540 
541 // The second or of next test is to take event with no end date (we suppose duration is 1 hour in such case)
542 if ($dateselect > 0) {
543  $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)."'))";
544 }
545 if ($datestart_dtstart > 0) {
546  $sql .= " AND a.datep >= '".$db->idate($datestart_dtstart)."'";
547 }
548 if ($datestart_dtend > 0) {
549  $sql .= " AND a.datep <= '".$db->idate($datestart_dtend)."'";
550 }
551 if ($dateend_dtstart > 0) {
552  $sql .= " AND a.datep2 >= '".$db->idate($dateend_dtstart)."'";
553 }
554 if ($dateend_dtend > 0) {
555  $sql .= " AND a.datep2 <= '".$db->idate($dateend_dtend)."'";
556 }
557 
558 // Add where from extra fields
559 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
560 
561 // Add where from hooks
562 $parameters = array();
563 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
564 $sql .= $hookmanager->resPrint;
565 
566 // Count total nb of records
567 $nbtotalofrecords = '';
568 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
569  /* This old and fast method to get and count full list returns all record so use a high amount of memory.
570  $resql = $db->query($sql);
571  $nbtotalofrecords = $db->num_rows($resql);
572  */
573  /* The slow method does not consume memory on mysql (not tested on pgsql) */
574  /*$resql = $db->query($sql, 0, 'auto', 1);
575  while ($db->fetch_object($resql)) {
576  $nbtotalofrecords++;
577  }*/
578  /* The fast and low memory method to get and count full list converts the sql into a sql count */
579  $sqlforcount = preg_replace('/^SELECT[a-zA-Z0-9\._\s\(\),]+FROM/i', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql);
580  $resql = $db->query($sqlforcount);
581  $objforcount = $db->fetch_object($resql);
582  $nbtotalofrecords = $objforcount->nbtotalofrecords;
583  if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0
584  $page = 0;
585  $offset = 0;
586  }
587  $db->free($resql);
588 }
589 
590 // Complete request and execute it with limit
591 $sql .= $db->order($sortfield, $sortorder);
592 if ($limit) {
593  $sql .= $db->plimit($limit + 1, $offset);
594 }
595 
596 $resql = $db->query($sql);
597 if (!$resql) {
598  dol_print_error($db);
599  exit;
600 }
601 
602 $num = $db->num_rows($resql);
603 
604 $arrayofselected = is_array($toselect) ? $toselect : array();
605 
606 // Local calendar
607 $newtitle = '<div class="nowrap clear inline-block minheight30 margintoponly">';
608 $newtitle .= '<input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> '.$langs->trans("LocalAgenda").' &nbsp; ';
609 $newtitle .= '</div>';
610 //$newtitle=$langs->trans($title);
611 
612 $tabactive = 'cardlist';
613 
614 $head = calendars_prepare_head($param);
615 
616 print '<form method="POST" id="searchFormList" class="listactionsfilter" action="'.$_SERVER["PHP_SELF"].'">'."\n";
617 
618 if ($optioncss != '') {
619  print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
620 }
621 print '<input type="hidden" name="token" value="'.newToken().'">';
622 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
623 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
624 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
625 print '<input type="hidden" name="type" value="'.$type.'">';
626 $nav = '';
627 
628 if ($filter) {
629  $nav .= '<input type="hidden" name="search_filter" value="'.$filter.'">';
630 }
631 if ($showbirthday) {
632  $nav .= '<input type="hidden" name="search_showbirthday" value="1">';
633 }
634 print $nav;
635 
636 //print dol_get_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action');
637 //print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid);
638 //print dol_get_fiche_end();
639 
640 
641 $s = $newtitle;
642 
643 // Calendars from hooks
644 $parameters = array();
645 $reshook = $hookmanager->executeHooks('addCalendarChoice', $parameters, $object, $action);
646 if (empty($reshook)) {
647  $s .= $hookmanager->resPrint;
648 } elseif ($reshook > 1) {
649  $s = $hookmanager->resPrint;
650 }
651 $viewyear = is_object($object) ? dol_print_date($object->datep, '%Y') : '';
652 $viewmonth = is_object($object) ? dol_print_date($object->datep, '%m') : '';
653 $viewday = is_object($object) ? dol_print_date($object->datep, '%d') : '';
654 $viewmode = '';
655 $viewmode .= '<a class="btnTitle btnTitleSelected reposition" href="'.DOL_URL_ROOT.'/comm/action/list.php?mode=show_list&restore_lastsearch_values=1'.$paramnoactionodate.'">';
656 //$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
657 $viewmode .= img_picto($langs->trans("List"), 'object_calendarlist', 'class="imgforviewmode pictoactionview block"');
658 //$viewmode .= '</span>';
659 $viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewList").'</span></a>';
660 
661 $viewmode .= '<a class="btnTitle reposition" href="'.DOL_URL_ROOT.'/comm/action/index.php?mode=show_month&year='.$viewyear.'&month='.$viewmonth.'&day='.$viewday.$paramnoactionodate.'">';
662 //$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
663 $viewmode .= img_picto($langs->trans("ViewCal"), 'object_calendarmonth', 'class="pictoactionview block"');
664 //$viewmode .= '</span>';
665 $viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewCal").'</span></a>';
666 
667 $viewmode .= '<a class="btnTitle reposition" href="'.DOL_URL_ROOT.'/comm/action/index.php?mode=show_week&year='.$viewyear.'&month='.$viewmonth.'&day='.$viewday.$paramnoactionodate.'">';
668 //$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
669 $viewmode .= img_picto($langs->trans("ViewWeek"), 'object_calendarweek', 'class="pictoactionview block"');
670 //$viewmode .= '</span>';
671 $viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewWeek").'</span></a>';
672 
673 $viewmode .= '<a class="btnTitle reposition" href="'.DOL_URL_ROOT.'/comm/action/index.php?mode=show_day&year='.$viewyear.'&month='.$viewmonth.'&day='.$viewday.$paramnoactionodate.'">';
674 //$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
675 $viewmode .= img_picto($langs->trans("ViewDay"), 'object_calendarday', 'class="pictoactionview block"');
676 //$viewmode .= '</span>';
677 $viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewDay").'</span></a>';
678 
679 $viewmode .= '<a class="btnTitle reposition marginrightonly" href="'.DOL_URL_ROOT.'/comm/action/peruser.php?mode=show_peruser&year='.$viewyear.'&month='.$viewmonth.'&day='.$viewday.$paramnoactionodate.'">';
680 //$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
681 $viewmode .= img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser', 'class="pictoactionview block"');
682 //$viewmode .= '</span>';
683 $viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewPerUser").'</span></a>';
684 
685 $viewmode .= '<span class="marginrightonly"></span>';
686 
687 // Add more views from hooks
688 $parameters = array();
689 $reshook = $hookmanager->executeHooks('addCalendarView', $parameters, $object, $action);
690 if (empty($reshook)) {
691  $viewmode .= $hookmanager->resPrint;
692 } elseif ($reshook > 1) {
693  $viewmode = $hookmanager->resPrint;
694 }
695 
696 $tmpforcreatebutton = dol_getdate(dol_now(), true);
697 
698 $newparam = '&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$tmpforcreatebutton['year'];
699 
700 //$param='month='.$monthshown.'&year='.$year;
701 $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
702 
703 $url = DOL_URL_ROOT.'/comm/action/card.php?action=create';
704 $url .= '&datep='.sprintf("%04d%02d%02d", $tmpforcreatebutton['year'], $tmpforcreatebutton['mon'], $tmpforcreatebutton['mday']).$hourminsec;
705 $url .= '&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam ? '?'.$newparam : ''));
706 
707 $newcardbutton = dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', $url, '', $user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create);
708 
709 $param .= '&mode='.$mode;
710 
711 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);
712 
713 print $s;
714 
715 $objecttmp = new ActionComm($db);
716 include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
717 
718 $moreforfilter = '';
719 
720 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
721 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
722 if ($massactionbutton) {
723  $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
724 }
725 $i = 0;
726 
727 print '<div class="liste_titre liste_titre_bydiv centpercent">';
728 print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid);
729 print '</div>';
730 
731 print '<div class="div-table-responsive">';
732 print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
733 
734 print '<tr class="liste_titre_filter">';
735 if (!empty($arrayfields['a.id']['checked'])) {
736  print '<td class="liste_titre"><input type="text" class="maxwidth50" name="search_id" value="'.$search_id.'"></td>';
737 }
738 if (!empty($arrayfields['owner']['checked'])) {
739  print '<td class="liste_titre"></td>';
740 }
741 if (!empty($arrayfields['c.libelle']['checked'])) {
742  print '<td class="liste_titre"></td>';
743 }
744 if (!empty($arrayfields['a.label']['checked'])) {
745  print '<td class="liste_titre"><input type="text" class="maxwidth75" name="search_title" value="'.$search_title.'"></td>';
746 }
747 if (!empty($arrayfields['a.note']['checked'])) {
748  print '<td class="liste_titre"><input type="text" class="maxwidth75" name="search_note" value="'.$search_note.'"></td>';
749 }
750 if (!empty($arrayfields['a.datep']['checked'])) {
751  print '<td class="liste_titre nowraponall" align="center">';
752  print '<div class="nowrap">';
753  print $form->selectDate($datestart_dtstart, 'datestart_dtstart', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'), 'tzuserrel');
754  print '</div>';
755  print '<div class="nowrap">';
756  print $form->selectDate($datestart_dtend, 'datestart_dtend', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('To'), 'tzuserrel');
757  print '</div>';
758  print '</td>';
759 }
760 if (!empty($arrayfields['a.datep2']['checked'])) {
761  print '<td class="liste_titre nowraponall" align="center">';
762  print '<div class="nowrap">';
763  print $form->selectDate($dateend_dtstart, 'dateend_dtstart', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'), 'tzuserrel');
764  print '</div>';
765  print '<div class="nowrap">';
766  print $form->selectDate($dateend_dtend, 'dateend_dtend', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('To'), 'tzuserrel');
767  print '</div>';
768  print '</td>';
769 }
770 if (!empty($arrayfields['s.nom']['checked'])) {
771  print '<td class="liste_titre"></td>';
772 }
773 if (!empty($arrayfields['a.fk_contact']['checked'])) {
774  print '<td class="liste_titre"></td>';
775 }
776 if (!empty($arrayfields['a.fk_element']['checked'])) {
777  print '<td class="liste_titre"></td>';
778 }
779 
780 // Extra fields
781 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
782 
783 // Fields from hook
784 $parameters = array('arrayfields'=>$arrayfields);
785 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
786 print $hookmanager->resPrint;
787 
788 if (!empty($arrayfields['a.datec']['checked'])) {
789  print '<td class="liste_titre"></td>';
790 }
791 if (!empty($arrayfields['a.tms']['checked'])) {
792  print '<td class="liste_titre"></td>';
793 }
794 if (!empty($arrayfields['a.percent']['checked'])) {
795  print '<td class="liste_titre center">';
796  $formactions->form_select_status_action('formaction', $search_status, 1, 'search_status', 1, 2, 'minwidth100imp maxwidth125');
797  print ajax_combobox('selectsearch_status');
798  print '</td>';
799 }
800 // Action column
801 print '<td class="liste_titre" align="middle">';
802 $searchpicto = $form->showFilterButtons();
803 print $searchpicto;
804 print '</td>';
805 print '</tr>'."\n";
806 
807 $totalarray = array();
808 $totalarray['nbfield'] = 0;
809 
810 // Fields title label
811 // --------------------------------------------------------------------
812 print '<tr class="liste_titre">';
813 if (!empty($arrayfields['a.id']['checked'])) {
814  print_liste_field_titre($arrayfields['a.id']['label'], $_SERVER["PHP_SELF"], "a.id", $param, "", "", $sortfield, $sortorder);
815  $totalarray['nbfield']++;
816 }
817 if (!empty($arrayfields['owner']['checked'])) {
818  print_liste_field_titre($arrayfields['owner']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder);
819  $totalarray['nbfield']++;
820 }
821 if (!empty($arrayfields['c.libelle']['checked'])) {
822  print_liste_field_titre($arrayfields['c.libelle']['label'], $_SERVER["PHP_SELF"], "c.libelle", $param, "", "", $sortfield, $sortorder);
823  $totalarray['nbfield']++;
824 }
825 if (!empty($arrayfields['a.label']['checked'])) {
826  print_liste_field_titre($arrayfields['a.label']['label'], $_SERVER["PHP_SELF"], "a.label", $param, "", "", $sortfield, $sortorder);
827  $totalarray['nbfield']++;
828 }
829 if (!empty($arrayfields['a.note']['checked'])) {
830  print_liste_field_titre($arrayfields['a.note']['label'], $_SERVER["PHP_SELF"], "a.note", $param, "", "", $sortfield, $sortorder);
831  $totalarray['nbfield']++;
832 }
833 //if (! empty($conf->global->AGENDA_USE_EVENT_TYPE))
834 if (!empty($arrayfields['a.datep']['checked'])) {
835  print_liste_field_titre($arrayfields['a.datep']['label'], $_SERVER["PHP_SELF"], "a.datep,a.id", $param, '', 'align="center"', $sortfield, $sortorder);
836  $totalarray['nbfield']++;
837 }
838 if (!empty($arrayfields['a.datep2']['checked'])) {
839  print_liste_field_titre($arrayfields['a.datep2']['label'], $_SERVER["PHP_SELF"], "a.datep2", $param, '', 'align="center"', $sortfield, $sortorder);
840  $totalarray['nbfield']++;
841 }
842 if (!empty($arrayfields['s.nom']['checked'])) {
843  print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", $param, "", "", $sortfield, $sortorder);
844  $totalarray['nbfield']++;
845 }
846 if (!empty($arrayfields['a.fk_contact']['checked'])) {
847  print_liste_field_titre($arrayfields['a.fk_contact']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder);
848  $totalarray['nbfield']++;
849 }
850 if (!empty($arrayfields['a.fk_element']['checked'])) {
851  print_liste_field_titre($arrayfields['a.fk_element']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder);
852  $totalarray['nbfield']++;
853 }
854 // Extra fields
855 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
856 // Hook fields
857 $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
858 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
859 print $hookmanager->resPrint;
860 
861 if (!empty($arrayfields['a.datec']['checked'])) {
862  print_liste_field_titre($arrayfields['a.datec']['label'], $_SERVER["PHP_SELF"], "a.datec,a.id", $param, "", 'align="center"', $sortfield, $sortorder);
863  $totalarray['nbfield']++;
864 }
865 if (!empty($arrayfields['a.tms']['checked'])) {
866  print_liste_field_titre($arrayfields['a.tms']['label'], $_SERVER["PHP_SELF"], "a.tms,a.id", $param, "", 'align="center"', $sortfield, $sortorder);
867  $totalarray['nbfield']++;
868 }
869 
870 if (!empty($arrayfields['a.percent']['checked'])) {
871  print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "a.percent", $param, "", 'align="center"', $sortfield, $sortorder);
872  $totalarray['nbfield']++;
873 }
874 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
875 $totalarray['nbfield']++;
876 print "</tr>\n";
877 
878 $now = dol_now();
879 $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60;
880 
881 require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php';
882 $caction = new CActionComm($db);
883 $arraylist = $caction->liste_array(1, 'code', '', (empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : 0), '', 1);
884 $contactListCache = array();
885 
886 // Loop on record
887 // --------------------------------------------------------------------
888 $i = 0;
889 //$savnbfield = $totalarray['nbfield'];
890 //$totalarray['nbfield'] = 0;
891 $imaxinloop = ($limit ? min($num, $limit) : $num);
892 while ($i < $imaxinloop) {
893  $obj = $db->fetch_object($resql);
894  if (empty($obj)) {
895  break; // Should not happen
896  }
897 
898  // Store properties in $object
899  $object->setVarsFromFetchObj($obj);
900 
901  // Discard auto action if option is on
902  if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->type_code == 'AC_OTH_AUTO') {
903  $i++;
904  continue;
905  }
906 
907  $actionstatic->id = $obj->id;
908  $actionstatic->ref = $obj->id;
909  $actionstatic->code = $obj->code;
910  $actionstatic->type_code = $obj->type_code;
911  $actionstatic->type_label = $obj->type_label;
912  $actionstatic->type_picto = $obj->type_picto;
913  $actionstatic->type_color = $obj->type_color;
914  $actionstatic->label = $obj->label;
915  $actionstatic->location = $obj->location;
916  $actionstatic->note_private = dol_htmlentitiesbr($obj->note);
917  $actionstatic->datep = $db->jdate($obj->dp);
918  $actionstatic->percentage = $obj->percent;
919  $actionstatic->authorid = $obj->fk_user_author;
920  $actionstatic->userownerid = $obj->fk_user_action;
921 
922  // Initialize $this->userassigned && this->socpeopleassigned array && this->userownerid
923  // but only if we need it
924  if (!empty($arrayfields['a.fk_contact']['checked'])) {
925  $actionstatic->fetchResources();
926  }
927 
928  print '<tr class="oddeven">';
929 
930  // Ref
931  if (!empty($arrayfields['a.id']['checked'])) {
932  print '<td class="nowraponall">';
933  print $actionstatic->getNomUrl(1, -1);
934  print '</td>';
935  }
936 
937  // User owner
938  if (!empty($arrayfields['owner']['checked'])) {
939  print '<td class="tdoverflowmax150">'; // With edge and chrome the td overflow is not supported correctly when content is not full text.
940  if ($obj->fk_user_action > 0) {
941  $userstatic->fetch($obj->fk_user_action);
942  print $userstatic->getNomUrl(-1);
943  } else {
944  print '&nbsp;';
945  }
946  print '</td>';
947  }
948 
949  // Type
950  if (!empty($arrayfields['c.libelle']['checked'])) {
951  print '<td class="nowraponall">';
952  print $actionstatic->getTypePicto();
953  $labeltype = $obj->type_code;
954  if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($arraylist[$labeltype])) {
955  $labeltype = 'AC_OTH';
956  }
957  if ($actionstatic->type_code == 'AC_OTH' && $actionstatic->code == 'TICKET_MSG') {
958  $labeltype = $langs->trans("Message");
959  } else {
960  if (!empty($arraylist[$labeltype])) {
961  $labeltype = $arraylist[$labeltype];
962  }
963  if ($obj->type_code == 'AC_OTH_AUTO' && ($obj->type_code != $obj->code) && $labeltype && !empty($arraylist[$obj->code])) {
964  $labeltype .= ' - '.$arraylist[$obj->code]; // Use code in priority on type_code
965  }
966  }
967  print dol_trunc($labeltype, 28);
968  print '</td>';
969  }
970 
971  // Label
972  if (!empty($arrayfields['a.label']['checked'])) {
973  print '<td class="tdoverflowmax200" title="'.dol_escape_htmltag($actionstatic->label).'">';
974  print $actionstatic->label;
975  print '</td>';
976  }
977 
978  // Description
979  if (!empty($arrayfields['a.note']['checked'])) {
980  print '<td class="tdoverflowonsmartphone">';
981  $text = dolGetFirstLineOfText(dol_string_nohtmltag($actionstatic->note_private, 1));
982  print $form->textwithtooltip(dol_trunc($text, 48), $actionstatic->note_private);
983  print '</td>';
984  }
985 
986  $formatToUse = $obj->fulldayevent ? 'day' : 'dayhour';
987 
988  // Start date
989  if (!empty($arrayfields['a.datep']['checked'])) {
990  print '<td class="center nowraponall">';
991  if (empty($obj->fulldayevent)) {
992  print dol_print_date($db->jdate($obj->dp), $formatToUse, 'tzuserrel');
993  } else {
994  $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT');
995  print dol_print_date($db->jdate($obj->dp), $formatToUse, ($tzforfullday ? $tzforfullday : 'tzuserrel'));
996  }
997  $late = 0;
998  if ($actionstatic->hasDelay() && $actionstatic->percentage >= 0 && $actionstatic->percentage < 100 ) {
999  $late = 1;
1000  }
1001  if ($late) {
1002  print img_warning($langs->trans("Late")).' ';
1003  }
1004  print '</td>';
1005  }
1006 
1007  // End date
1008  if (!empty($arrayfields['a.datep2']['checked'])) {
1009  print '<td class="center nowraponall">';
1010  if (empty($obj->fulldayevent)) {
1011  print dol_print_date($db->jdate($obj->dp2), $formatToUse, 'tzuserrel');
1012  } else {
1013  $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT');
1014  print dol_print_date($db->jdate($obj->dp2), $formatToUse, ($tzforfullday ? $tzforfullday : 'tzuserrel'));
1015  }
1016  print '</td>';
1017  }
1018 
1019  // Third party
1020  if (!empty($arrayfields['s.nom']['checked'])) {
1021  print '<td class="tdoverflowmax150">';
1022  if ($obj->socid > 0) {
1023  $societestatic->id = $obj->socid;
1024  $societestatic->client = $obj->client;
1025  $societestatic->name = $obj->societe;
1026  $societestatic->email = $obj->socemail;
1027 
1028  print $societestatic->getNomUrl(1, '', 28);
1029  } else {
1030  print '&nbsp;';
1031  }
1032  print '</td>';
1033  }
1034 
1035  // Contact
1036  if (!empty($arrayfields['a.fk_contact']['checked'])) {
1037  print '<td class="tdoverflowmax100">';
1038 
1039  if (!empty($actionstatic->socpeopleassigned)) {
1040  $contactList = array();
1041  foreach ($actionstatic->socpeopleassigned as $socpeopleassigned) {
1042  if (!isset($contactListCache[$socpeopleassigned['id']])) {
1043  // if no cache found we fetch it
1044  $contact = new Contact($db);
1045  if ($contact->fetch($socpeopleassigned['id']) > 0) {
1046  $contactListCache[$socpeopleassigned['id']] = $contact->getNomUrl(1, '', 0);
1047  $contactList[] = $contact->getNomUrl(1, '', 0);
1048  }
1049  } else {
1050  // use cache
1051  $contactList[] = $contactListCache[$socpeopleassigned['id']];
1052  }
1053  }
1054  if (!empty($contactList)) {
1055  print implode(', ', $contactList);
1056  }
1057  } elseif ($obj->fk_contact > 0) { //keep for retrocompatibility with faraway event
1058  $contactstatic->id = $obj->fk_contact;
1059  $contactstatic->email = $obj->email;
1060  $contactstatic->lastname = $obj->lastname;
1061  $contactstatic->firstname = $obj->firstname;
1062  $contactstatic->phone_pro = $obj->phone_pro;
1063  $contactstatic->phone_mobile = $obj->phone_mobile;
1064  $contactstatic->phone_perso = $obj->phone_perso;
1065  $contactstatic->country_id = $obj->country_id;
1066  print $contactstatic->getNomUrl(1, '', 0);
1067  } else {
1068  print "&nbsp;";
1069  }
1070  print '</td>';
1071  }
1072 
1073  // Linked object
1074  if (!empty($arrayfields['a.fk_element']['checked'])) {
1075  print '<td class="tdoverflowmax150">';
1076  //var_dump($obj->fkelement.' '.$obj->elementtype);
1077  if ($obj->fk_element > 0 && !empty($obj->elementtype)) {
1078  include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
1079  print dolGetElementUrl($obj->fk_element, $obj->elementtype, 1);
1080  } else {
1081  print "&nbsp;";
1082  }
1083  print '</td>';
1084  }
1085 
1086  // Extra fields
1087  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1088  // Fields from hook
1089  $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
1090  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
1091  print $hookmanager->resPrint;
1092 
1093  // Date creation
1094  if (!empty($arrayfields['a.datec']['checked'])) {
1095  // Status/Percent
1096  print '<td align="center" class="nowrap">'.dol_print_date($db->jdate($obj->datec), 'dayhour', 'tzuserrel').'</td>';
1097  }
1098  // Date update
1099  if (!empty($arrayfields['a.tms']['checked'])) {
1100  print '<td align="center" class="nowrap">'.dol_print_date($db->jdate($obj->datem), 'dayhour', 'tzuserrel').'</td>';
1101  }
1102  if (!empty($arrayfields['a.percent']['checked'])) {
1103  // Status/Percent
1104  $datep = $db->jdate($obj->dp);
1105  print '<td align="center" class="nowrap">'.$actionstatic->LibStatut($obj->percent, 5, 0, $datep).'</td>';
1106  }
1107  // Action column
1108  print '<td class="nowrap center">';
1109  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1110  $selected = 0;
1111  if (in_array($obj->id, $arrayofselected)) {
1112  $selected = 1;
1113  }
1114  print '<input id="cb'.$obj->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->id.'"'.($selected ? ' checked="checked"' : '').'>';
1115  }
1116  print '</td>';
1117 
1118  print '</tr>'."\n";
1119 
1120  $i++;
1121 }
1122 // If no record found
1123 if ($num == 0) {
1124  print '<tr><td colspan="'.$totalarray['nbfield'].'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
1125 }
1126 
1127 
1128 print '</table>'."\n";
1129 print '</div>'."\n";
1130 
1131 print '</form>'."\n";
1132 
1133 $db->free($resql);
1134 
1135 // End of page
1136 llxFooter();
1137 $db->close();
dol_getdate
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
Definition: functions.lib.php:2699
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:3791
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:4830
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:8371
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:4507
$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:2500
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:3866
$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:10591
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:6680
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:5243
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:5012
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:9406
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:6977
dol_now
dol_now($mode='auto')
Return date for now.
Definition: functions.lib.php:2831
$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:8123
dolGetFirstLineOfText
dolGetFirstLineOfText($text, $nboflines=1, $charset='UTF-8')
Return first line of text.
Definition: functions.lib.php:6893
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:2743
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