dolibarr  x.y.z
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->hasRight('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 center">';
799  $formactions->form_select_status_action('formaction', $search_status, 1, 'search_status', 1, 2, 'minwidth100imp maxwidth125');
800  print ajax_combobox('selectsearch_status');
801  print '</td>';
802 }
803 // Action column
804 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
805  print '<td class="liste_titre" align="middle">';
806  $searchpicto = $form->showFilterButtons();
807  print $searchpicto;
808  print '</td>';
809 }
810 print '</tr>'."\n";
811 
812 $totalarray = array();
813 $totalarray['nbfield'] = 0;
814 
815 // Fields title label
816 // --------------------------------------------------------------------
817 print '<tr class="liste_titre">';
818 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
819  print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
820 }
821 if (!empty($arrayfields['a.id']['checked'])) {
822  print_liste_field_titre($arrayfields['a.id']['label'], $_SERVER["PHP_SELF"], "a.id", $param, "", "", $sortfield, $sortorder);
823  $totalarray['nbfield']++;
824 }
825 if (!empty($arrayfields['owner']['checked'])) {
826  print_liste_field_titre($arrayfields['owner']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder);
827  $totalarray['nbfield']++;
828 }
829 if (!empty($arrayfields['c.libelle']['checked'])) {
830  print_liste_field_titre($arrayfields['c.libelle']['label'], $_SERVER["PHP_SELF"], "c.libelle", $param, "", "", $sortfield, $sortorder);
831  $totalarray['nbfield']++;
832 }
833 if (!empty($arrayfields['a.label']['checked'])) {
834  print_liste_field_titre($arrayfields['a.label']['label'], $_SERVER["PHP_SELF"], "a.label", $param, "", "", $sortfield, $sortorder);
835  $totalarray['nbfield']++;
836 }
837 if (!empty($arrayfields['a.note']['checked'])) {
838  print_liste_field_titre($arrayfields['a.note']['label'], $_SERVER["PHP_SELF"], "a.note", $param, "", "", $sortfield, $sortorder);
839  $totalarray['nbfield']++;
840 }
841 //if (!empty($conf->global->AGENDA_USE_EVENT_TYPE))
842 if (!empty($arrayfields['a.datep']['checked'])) {
843  print_liste_field_titre($arrayfields['a.datep']['label'], $_SERVER["PHP_SELF"], "a.datep,a.id", $param, '', 'align="center"', $sortfield, $sortorder);
844  $totalarray['nbfield']++;
845 }
846 if (!empty($arrayfields['a.datep2']['checked'])) {
847  print_liste_field_titre($arrayfields['a.datep2']['label'], $_SERVER["PHP_SELF"], "a.datep2", $param, '', 'align="center"', $sortfield, $sortorder);
848  $totalarray['nbfield']++;
849 }
850 if (!empty($arrayfields['s.nom']['checked'])) {
851  print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", $param, "", "", $sortfield, $sortorder);
852  $totalarray['nbfield']++;
853 }
854 if (!empty($arrayfields['a.fk_contact']['checked'])) {
855  print_liste_field_titre($arrayfields['a.fk_contact']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder);
856  $totalarray['nbfield']++;
857 }
858 if (!empty($arrayfields['a.fk_element']['checked'])) {
859  print_liste_field_titre($arrayfields['a.fk_element']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder);
860  $totalarray['nbfield']++;
861 }
862 // Extra fields
863 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
864 // Hook fields
865 $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
866 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
867 print $hookmanager->resPrint;
868 
869 if (!empty($arrayfields['a.datec']['checked'])) {
870  print_liste_field_titre($arrayfields['a.datec']['label'], $_SERVER["PHP_SELF"], "a.datec,a.id", $param, "", 'align="center"', $sortfield, $sortorder);
871  $totalarray['nbfield']++;
872 }
873 if (!empty($arrayfields['a.tms']['checked'])) {
874  print_liste_field_titre($arrayfields['a.tms']['label'], $_SERVER["PHP_SELF"], "a.tms,a.id", $param, "", 'align="center"', $sortfield, $sortorder);
875  $totalarray['nbfield']++;
876 }
877 
878 if (!empty($arrayfields['a.percent']['checked'])) {
879  print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "a.percent", $param, "", 'align="center"', $sortfield, $sortorder);
880  $totalarray['nbfield']++;
881 }
882 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
883  print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
884 }
885 $totalarray['nbfield']++;
886 print "</tr>\n";
887 
888 $now = dol_now();
889 $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60;
890 
891 require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php';
892 $caction = new CActionComm($db);
893 $arraylist = $caction->liste_array(1, 'code', '', (empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : 0), '', 1);
894 $contactListCache = array();
895 
896 // Loop on record
897 // --------------------------------------------------------------------
898 $i = 0;
899 //$savnbfield = $totalarray['nbfield'];
900 //$totalarray['nbfield'] = 0;
901 $imaxinloop = ($limit ? min($num, $limit) : $num);
902 while ($i < $imaxinloop) {
903  $obj = $db->fetch_object($resql);
904  if (empty($obj)) {
905  break; // Should not happen
906  }
907 
908  // Store properties in $object
909  $object->setVarsFromFetchObj($obj);
910 
911  // Discard auto action if option is on
912  if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->type_code == 'AC_OTH_AUTO') {
913  $i++;
914  continue;
915  }
916 
917  $actionstatic->id = $obj->id;
918  $actionstatic->ref = $obj->id;
919  $actionstatic->code = $obj->code;
920  $actionstatic->type_code = $obj->type_code;
921  $actionstatic->type_label = $obj->type_label;
922  $actionstatic->type_picto = $obj->type_picto;
923  $actionstatic->type_color = $obj->type_color;
924  $actionstatic->label = $obj->label;
925  $actionstatic->location = $obj->location;
926  $actionstatic->note_private = dol_htmlentitiesbr($obj->note);
927  $actionstatic->datep = $db->jdate($obj->dp);
928  $actionstatic->percentage = $obj->percent;
929 
930  // Initialize $this->userassigned && this->socpeopleassigned array && this->userownerid
931  // but only if we need it
932  if (!empty($arrayfields['a.fk_contact']['checked'])) {
933  $actionstatic->fetchResources();
934  }
935 
936  print '<tr class="oddeven">';
937  // Action column
938  if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
939  print '<td class="nowrap center">';
940  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
941  $selected = 0;
942  if (in_array($obj->id, $arrayofselected)) {
943  $selected = 1;
944  }
945  print '<input id="cb'.$obj->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->id.'"'.($selected ? ' checked="checked"' : '').'>';
946  }
947  print '</td>';
948  }
949  // Ref
950  if (!empty($arrayfields['a.id']['checked'])) {
951  print '<td class="nowraponall">';
952  print $actionstatic->getNomUrl(1, -1);
953  print '</td>';
954  }
955 
956  // User owner
957  if (!empty($arrayfields['owner']['checked'])) {
958  print '<td class="tdoverflowmax150">'; // With edge and chrome the td overflow is not supported correctly when content is not full text.
959  if ($obj->fk_user_action > 0) {
960  $userstatic->fetch($obj->fk_user_action);
961  print $userstatic->getNomUrl(-1);
962  } else {
963  print '&nbsp;';
964  }
965  print '</td>';
966  }
967 
968  // Type
969  if (!empty($arrayfields['c.libelle']['checked'])) {
970  print '<td class="nowraponall">';
971  print $actionstatic->getTypePicto();
972  $labeltype = $obj->type_code;
973  if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($arraylist[$labeltype])) {
974  $labeltype = 'AC_OTH';
975  }
976  if (preg_match('/^TICKET_MSG/', $actionstatic->code)) {
977  $labeltype = $langs->trans("Message");
978  } else {
979  if (!empty($arraylist[$labeltype])) {
980  $labeltype = $arraylist[$labeltype];
981  }
982  if ($obj->type_code == 'AC_OTH_AUTO' && ($obj->type_code != $obj->code) && $labeltype && !empty($arraylist[$obj->code])) {
983  $labeltype .= ' - '.$arraylist[$obj->code]; // Use code in priority on type_code
984  }
985  }
986  print dol_trunc($labeltype, 28);
987  print '</td>';
988  }
989 
990  // Label
991  if (!empty($arrayfields['a.label']['checked'])) {
992  print '<td class="tdoverflowmax200" title="'.dol_escape_htmltag($actionstatic->label).'">';
993  print $actionstatic->label;
994  print '</td>';
995  }
996 
997  // Description
998  if (!empty($arrayfields['a.note']['checked'])) {
999  print '<td class="tdoverflowonsmartphone">';
1000  $text = dolGetFirstLineOfText(dol_string_nohtmltag($actionstatic->note_private, 1));
1001  print $form->textwithtooltip(dol_trunc($text, 48), $actionstatic->note_private);
1002  print '</td>';
1003  }
1004 
1005  $formatToUse = $obj->fulldayevent ? 'day' : 'dayhour';
1006 
1007  // Start date
1008  if (!empty($arrayfields['a.datep']['checked'])) {
1009  print '<td class="center nowraponall">';
1010  if (empty($obj->fulldayevent)) {
1011  print dol_print_date($db->jdate($obj->dp), $formatToUse, 'tzuserrel');
1012  } else {
1013  $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT');
1014  print dol_print_date($db->jdate($obj->dp), $formatToUse, ($tzforfullday ? $tzforfullday : 'tzuserrel'));
1015  }
1016  $late = 0;
1017  if ($actionstatic->hasDelay() && $actionstatic->percentage >= 0 && $actionstatic->percentage < 100 ) {
1018  $late = 1;
1019  }
1020  if ($late) {
1021  print img_warning($langs->trans("Late")).' ';
1022  }
1023  print '</td>';
1024  }
1025 
1026  // End date
1027  if (!empty($arrayfields['a.datep2']['checked'])) {
1028  print '<td class="center nowraponall">';
1029  if (empty($obj->fulldayevent)) {
1030  print dol_print_date($db->jdate($obj->dp2), $formatToUse, 'tzuserrel');
1031  } else {
1032  $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT');
1033  print dol_print_date($db->jdate($obj->dp2), $formatToUse, ($tzforfullday ? $tzforfullday : 'tzuserrel'));
1034  }
1035  print '</td>';
1036  }
1037 
1038  // Third party
1039  if (!empty($arrayfields['s.nom']['checked'])) {
1040  print '<td class="tdoverflowmax150">';
1041  if ($obj->socid > 0) {
1042  $societestatic->id = $obj->socid;
1043  $societestatic->client = $obj->client;
1044  $societestatic->name = $obj->societe;
1045  $societestatic->email = $obj->socemail;
1046 
1047  print $societestatic->getNomUrl(1, '', 28);
1048  } else {
1049  print '&nbsp;';
1050  }
1051  print '</td>';
1052  }
1053 
1054  // Contact
1055  if (!empty($arrayfields['a.fk_contact']['checked'])) {
1056  print '<td class="tdoverflowmax100">';
1057 
1058  if (!empty($actionstatic->socpeopleassigned)) {
1059  $contactList = array();
1060  foreach ($actionstatic->socpeopleassigned as $socpeopleassigned) {
1061  if (!isset($contactListCache[$socpeopleassigned['id']])) {
1062  // if no cache found we fetch it
1063  $contact = new Contact($db);
1064  if ($contact->fetch($socpeopleassigned['id']) > 0) {
1065  $contactListCache[$socpeopleassigned['id']] = $contact->getNomUrl(1, '', 0);
1066  $contactList[] = $contact->getNomUrl(1, '', 0);
1067  }
1068  } else {
1069  // use cache
1070  $contactList[] = $contactListCache[$socpeopleassigned['id']];
1071  }
1072  }
1073  if (!empty($contactList)) {
1074  print implode(', ', $contactList);
1075  }
1076  } elseif ($obj->fk_contact > 0) { //keep for retrocompatibility with faraway event
1077  $contactstatic->id = $obj->fk_contact;
1078  $contactstatic->email = $obj->email;
1079  $contactstatic->lastname = $obj->lastname;
1080  $contactstatic->firstname = $obj->firstname;
1081  $contactstatic->phone_pro = $obj->phone_pro;
1082  $contactstatic->phone_mobile = $obj->phone_mobile;
1083  $contactstatic->phone_perso = $obj->phone_perso;
1084  $contactstatic->country_id = $obj->country_id;
1085  print $contactstatic->getNomUrl(1, '', 0);
1086  } else {
1087  print "&nbsp;";
1088  }
1089  print '</td>';
1090  }
1091 
1092  // Linked object
1093  if (!empty($arrayfields['a.fk_element']['checked'])) {
1094  print '<td class="tdoverflowmax150">';
1095  //var_dump($obj->fkelement.' '.$obj->elementtype);
1096  if ($obj->fk_element > 0 && !empty($obj->elementtype)) {
1097  include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
1098  print dolGetElementUrl($obj->fk_element, $obj->elementtype, 1);
1099  } else {
1100  print "&nbsp;";
1101  }
1102  print '</td>';
1103  }
1104 
1105  // Extra fields
1106  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1107  // Fields from hook
1108  $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
1109  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
1110  print $hookmanager->resPrint;
1111 
1112  // Date creation
1113  if (!empty($arrayfields['a.datec']['checked'])) {
1114  // Status/Percent
1115  print '<td align="center" class="nowrap">'.dol_print_date($db->jdate($obj->datec), 'dayhour', 'tzuserrel').'</td>';
1116  }
1117  // Date update
1118  if (!empty($arrayfields['a.tms']['checked'])) {
1119  print '<td align="center" class="nowrap">'.dol_print_date($db->jdate($obj->datem), 'dayhour', 'tzuserrel').'</td>';
1120  }
1121  if (!empty($arrayfields['a.percent']['checked'])) {
1122  // Status/Percent
1123  $datep = $db->jdate($obj->dp);
1124  print '<td align="center" class="nowrap">'.$actionstatic->LibStatut($obj->percent, 5, 0, $datep).'</td>';
1125  }
1126  // Action column
1127  if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1128  print '<td class="nowrap center">';
1129  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1130  $selected = 0;
1131  if (in_array($obj->id, $arrayofselected)) {
1132  $selected = 1;
1133  }
1134  print '<input id="cb'.$obj->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->id.'"'.($selected ? ' checked="checked"' : '').'>';
1135  }
1136  print '</td>';
1137  }
1138 
1139  print '</tr>'."\n";
1140 
1141  $i++;
1142 }
1143 // If no record found
1144 if ($num == 0) {
1145  print '<tr><td colspan="'.$totalarray['nbfield'].'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
1146 }
1147 
1148 
1149 print '</table>'."\n";
1150 print '</div>'."\n";
1151 
1152 print '</form>'."\n";
1153 
1154 $db->free($resql);
1155 
1156 // End of page
1157 llxFooter();
1158 $db->close();
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
Definition: agenda.php:118
print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, $filtera, $filtert, $filterd, $pid, $socid, $action, $showextcals=array(), $actioncode='', $usergroupid='', $excludetype='', $resourceid=0)
Show filter form in agenda view.
Definition: agenda.lib.php:51
calendars_prepare_head($param)
Define head array for tabs of agenda setup pages.
Definition: agenda.lib.php:483
if(preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if(preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if($action=='set') elseif($action=='specimen') elseif($action=='setmodel') elseif($action=='del') elseif($action=='setdoc') $formactions
View.
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='')
Convert a html select field into an ajax combobox.
Definition: ajax.lib.php:449
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:56
llxFooter()
Empty footer.
Definition: wrapper.php:70
Class to manage agenda events (actions)
const EVENT_FINISHED
Typical value for a event that is in a finished state.
const EVENT_IN_PROGRESS
Typical value for a event that is in a progress state.
const EVENT_TODO
Typical value for a event that is in a todo state.
Class to manage different types of events.
Class to manage contact/addresses.
Class to manage standard extra fields.
Class to manage building of HTML components.
Class to manage generation of HTML components Only common components must be here.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
Definition: user.class.php:45
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:745
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
dolGetElementUrl($objectid, $objecttype, $withpicto=0, $option='')
Return link url to an object.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
dolGetFirstLineOfText($text, $nboflines=1, $charset='UTF-8')
Return first line of text.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
isModEnabled($module)
Is Dolibarr module enabled.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
$nbtotalofrecords
Count total nb of records.
Definition: list.php:329
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.