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