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