dolibarr  7.0.0-beta
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@capnetworks.com>
6  * Copyright (C) 2017 Open-DSI <support@open-dsi.fr>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
28 require '../../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
30 require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
33 include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
34 
35 $langs->load("users");
36 $langs->load("companies");
37 $langs->load("agenda");
38 $langs->load("commercial");
39 
40 $action=GETPOST('action','alpha');
41 $resourceid=GETPOST("resourceid","int");
42 $year=GETPOST("year",'int');
43 $month=GETPOST("month",'int');
44 $day=GETPOST("day",'int');
45 $pid=GETPOST("projectid",'int',3);
46 $status=GETPOST("status",'alpha');
47 $type=GETPOST('type');
48 $optioncss = GETPOST('optioncss','alpha');
49 // Set actioncode (this code must be same for setting actioncode into peruser, listacton and index)
50 if (GETPOST('actioncode','array'))
51 {
52  $actioncode=GETPOST('actioncode','array',3);
53  if (! count($actioncode)) $actioncode='0';
54 }
55 else
56 {
57  $actioncode=GETPOST("actioncode","alpha",3)?GETPOST("actioncode","alpha",3):(GETPOST("actioncode")=='0'?'0':(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE));
58 }
59 if ($actioncode == '' && empty($actioncodearray)) $actioncode=(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE);
60 $search_title=GETPOST('search_title','alpha');
61 
62 $dateselect=dol_mktime(0, 0, 0, GETPOST('dateselectmonth','int'), GETPOST('dateselectday','int'), GETPOST('dateselectyear','int'));
63 $datestart=dol_mktime(0, 0, 0, GETPOST('datestartmonth','int'), GETPOST('datestartday','int'), GETPOST('datestartyear','int'));
64 $dateend=dol_mktime(0, 0, 0, GETPOST('dateendmonth','int'), GETPOST('dateendday','int'), GETPOST('dateendyear','int'));
65 if ($status == '' && ! isset($_GET['status']) && ! isset($_POST['status'])) $status=(empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS)?'':$conf->global->AGENDA_DEFAULT_FILTER_STATUS);
66 if (empty($action) && ! isset($_GET['action']) && ! isset($_POST['action'])) $action=(empty($conf->global->AGENDA_DEFAULT_VIEW)?'show_month':$conf->global->AGENDA_DEFAULT_VIEW);
67 
68 $filter = GETPOST("filter",'',3);
69 $filtert = GETPOST("filtert","int",3);
70 $usergroup = GETPOST("usergroup","int",3);
71 $showbirthday = empty($conf->use_javascript_ajax)?GETPOST("showbirthday","int"):1;
72 
73 $contextpage='actioncommlist';
74 
75 $extrafields = new ExtraFields($db);
76 // fetch optionals attributes and labels
77 $extralabels = $extrafields->fetch_name_optionals_label('actioncomm');
78 $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_');
79 // If not choice done on calendar owner, we filter on user.
80 if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS))
81 {
82  $filtert=$user->id;
83 }
84 
85 $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
86 $sortfield = GETPOST("sortfield",'alpha');
87 $sortorder = GETPOST("sortorder",'alpha');
88 $page = GETPOST("page",'int');
89 if ($page == -1 || $page == null) { $page = 0 ; }
90 $offset = $limit * $page ;
91 if (! $sortorder)
92 {
93  $sortorder="DESC";
94  if ($status == 'todo') $sortorder="DESC";
95  //if ($status == 'done') $sortorder="DESC";
96 }
97 if (! $sortfield)
98 {
99  $sortfield="a.datep";
100  if ($status == 'todo') $sortfield="a.datep";
101  //if ($status == 'done') $sortfield="a.datep2";
102 }
103 
104 // Security check
105 $socid = GETPOST("socid",'int');
106 if ($user->societe_id) $socid=$user->societe_id;
107 $result = restrictedArea($user, 'agenda', 0, '', 'myactions');
108 if ($socid < 0) $socid='';
109 
110 $canedit=1;
111 if (! $user->rights->agenda->myactions->read) accessforbidden();
112 if (! $user->rights->agenda->allactions->read) $canedit=0;
113 if (! $user->rights->agenda->allactions->read || $filter=='mine') // If no permission to see all, we show only affected to me
114 {
115  $filtert=$user->id;
116 }
117 
118 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
119 $hookmanager->initHooks(array('agendalist'));
120 
121 $arrayfields=array(
122  'a.id'=>array('label'=>"Ref", 'checked'=>1),
123  'owner'=>array('label'=>"Owner", 'checked'=>1),
124  'c.libelle'=>array('label'=>"Type", 'checked'=>1),
125  'a.label'=>array('label'=>"Title", 'checked'=>1),
126  'a.datep'=>array('label'=>"DateStart", 'checked'=>1),
127  'a.datep2'=>array('label'=>"DateEnd", 'checked'=>1),
128  's.nom'=>array('label'=>"ThirdParty", 'checked'=>1),
129  'a.fk_contact'=>array('label'=>"Contact", 'checked'=>1),
130  'a.fk_element'=>array('label'=>"LinkedObject", 'checked'=>0, 'enabled'=>(! empty($conf->global->AGENDA_SHOW_LINKED_OBJECT))),
131  'a.percent'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000),
132 
133 );
134 // Extra fields
135 if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
136 {
137  foreach($extrafields->attribute_label as $key => $val)
138  {
139  $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]);
140  }
141 }
142 
143 /*
144  * Actions
145  */
146 
147 if (GETPOST("viewcal") || GETPOST("viewweek") || GETPOST("viewday"))
148 {
149  $param='';
150  if (is_array($_POST))
151  {
152  foreach($_POST as $key => $val)
153  {
154  $param.='&'.$key.'='.urlencode($val);
155  }
156  }
157  //print $param;
158  header("Location: ".DOL_URL_ROOT.'/comm/action/index.php?'.$param);
159  exit;
160 }
161 
162 $parameters=array('id'=>$socid);
163 $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
164 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
165 
166 // Selection of new fields
167 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
168 // Purge search criteria
169 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
170 {
171  //$actioncode='';
172  $search_title='';
173  $datestart='';
174  $dateend='';
175  $status='';
176  $search_array_options=array();
177 }
178 
179 
180 /*
181  * View
182  */
183 
184 $form=new Form($db);
185 $userstatic=new User($db);
186 $formactions=new FormActions($db);
187 
188 $nav='';
189 $nav.=$form->select_date($dateselect, 'dateselect', 0, 0, 1, '', 1, 0, 1);
190 $nav.=' <input type="submit" name="submitdateselect" class="button" value="'.$langs->trans("Refresh").'">';
191 
192 $now=dol_now();
193 
194 $help_url='EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda';
195 llxHeader('',$langs->trans("Agenda"),$help_url);
196 
197 // Define list of all external calendars
198 $listofextcals=array();
199 
200 $param='';
201 if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
202 if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
203 if ($actioncode != '') {
204  if(is_array($actioncode)) {
205  foreach($actioncode as $str_action) $param.="&actioncode[]=".$str_action;
206  } else $param.="&actioncode=".$actioncode;
207 }
208 if ($resourceid > 0) $param.="&resourceid=".$resourceid;
209 if ($status != '' && $status > -1) $param.="&status=".$status;
210 if ($filter) $param.="&filter=".$filter;
211 if ($filtert) $param.="&filtert=".$filtert;
212 if ($socid) $param.="&socid=".$socid;
213 if ($showbirthday) $param.="&showbirthday=1";
214 if ($pid) $param.="&projectid=".$pid;
215 if ($type) $param.="&type=".$type;
216 if ($usergroup) $param.="&usergroup=".$usergroup;
217 if ($optioncss != '') $param.='&optioncss='.$optioncss;
218 if ($search_title != '') $param.='&search_title='.$search_title;
219 if (GETPOST('datestartday','int')) $param.='&datestartday='.GETPOST('datestartday','int');
220 if (GETPOST('datestartmonth','int')) $param.='&datestartmonth='.GETPOST('datestartmonth','int');
221 if (GETPOST('datestartyear','int')) $param.='&datestartyear='.GETPOST('datestartyear','int');
222 if (GETPOST('dateendday','int')) $param.='&dateendday='.GETPOST('dateendday','int');
223 if (GETPOST('dateendmonth','int')) $param.='&dateendmonth='.GETPOST('dateendmonth','int');
224 if (GETPOST('dateendyear','int')) $param.='&dateendyear='.GETPOST('dateendyear','int');
225 // Add $param from extra fields
226 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
227 
228 $sql = "SELECT";
229 if ($usergroup > 0) $sql.=" DISTINCT";
230 $sql.= " s.nom as societe, s.rowid as socid, s.client,";
231 $sql.= " a.id, a.label, a.datep as dp, a.datep2 as dp2,";
232 $sql.= ' a.fk_user_author,a.fk_user_action,';
233 $sql.= " a.fk_contact, a.note, a.percent as percent,";
234 $sql.= " a.fk_element, a.elementtype,";
235 $sql.= " c.code as type_code, c.libelle as type_label,";
236 $sql.= " sp.lastname, sp.firstname";
237 // Add fields from extrafields
238 foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : '');
239 $sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a";
240 $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."actioncomm_extrafields as ef ON (a.id = ef.fk_object) ";
241 if (! $user->rights->societe->client->voir && ! $socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
242 $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid";
243 $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid";
244 $sql.=" ,".MAIN_DB_PREFIX."c_actioncomm as c";
245 // We must filter on resource table
246 if ($resourceid > 0) $sql.=", ".MAIN_DB_PREFIX."element_resources as r";
247 // We must filter on assignement table
248 if ($filtert > 0 || $usergroup > 0) $sql.=", ".MAIN_DB_PREFIX."actioncomm_resources as ar";
249 if ($usergroup > 0) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element";
250 $sql.= " WHERE c.id = a.fk_action";
251 $sql.= ' AND a.entity IN ('.getEntity('agenda').')';
252 // Condition on actioncode
253 if (! empty($actioncode))
254 {
255  if (empty($conf->global->AGENDA_USE_EVENT_TYPE))
256  {
257  if ($actioncode == 'AC_NON_AUTO') $sql.= " AND c.type != 'systemauto'";
258  elseif ($actioncode == 'AC_ALL_AUTO') $sql.= " AND c.type = 'systemauto'";
259  else
260  {
261  if ($actioncode == 'AC_OTH') $sql.= " AND c.type != 'systemauto'";
262  if ($actioncode == 'AC_OTH_AUTO') $sql.= " AND c.type = 'systemauto'";
263  }
264  }
265  else
266  {
267  if ($actioncode == 'AC_NON_AUTO') $sql.= " AND c.type != 'systemauto'";
268  elseif ($actioncode == 'AC_ALL_AUTO') $sql.= " AND c.type = 'systemauto'";
269  else
270  {
271  if (is_array($actioncode))
272  {
273  $sql.=" AND c.code IN ('".implode("','", $actioncode)."')";
274  }
275  else
276  {
277  $sql.=" AND c.code IN ('".implode("','", explode(',', $actioncode))."')";
278  }
279  }
280  }
281 }
282 if ($resourceid > 0) $sql.=" AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid);
283 if ($pid) $sql.=" AND a.fk_project=".$db->escape($pid);
284 if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND (a.fk_soc IS NULL OR sc.fk_user = " .$user->id . ")";
285 if ($socid > 0) $sql.= " AND s.rowid = ".$socid;
286 // We must filter on assignement table
287 if ($filtert > 0 || $usergroup > 0) $sql.= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'";
288 if ($type) $sql.= " AND c.id = ".$type;
289 if ($status == '0') { $sql.= " AND a.percent = 0"; }
290 if ($status == '-1') { $sql.= " AND a.percent = -1"; } // Not applicable
291 if ($status == '50') { $sql.= " AND (a.percent > 0 AND a.percent < 100)"; } // Running already started
292 if ($status == '100') { $sql.= " AND a.percent = 100"; }
293 if ($status == 'done' || $status == '100') { $sql.= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep2 <= '".$db->idate($now)."'))"; }
294 if ($status == 'todo') { $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep2 > '".$db->idate($now)."'))"; }
295 if ($search_title) $sql.=natural_search("a.label", $search_title);
296 // We must filter on assignement table
297 if ($filtert > 0 || $usergroup > 0)
298 {
299  $sql.= " AND (";
300  if ($filtert > 0) $sql.= "(ar.fk_element = ".$filtert." OR (ar.fk_element IS NULL AND a.fk_user_action=".$filtert."))"; // The OR is for backward compatibility
301  if ($usergroup > 0) $sql.= ($filtert>0?" OR ":"")." ugu.fk_usergroup = ".$usergroup;
302  $sql.= ")";
303 }
304 
305 // The second or of next test is to take event with no end date (we suppose duration is 1 hour in such case)
306 if ($dateselect > 0) $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)."'))";
307 if ($datestart > 0) $sql.= " AND a.datep BETWEEN '".$db->idate($datestart)."' AND '".$db->idate($datestart+3600*24-1)."'";
308 if ($dateend > 0) $sql.= " AND a.datep2 BETWEEN '".$db->idate($dateend)."' AND '".$db->idate($dateend+3600*24-1)."'";
309 // Add where from extra fields
310 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
311 
312 $sql.= $db->order($sortfield,$sortorder);
313 
314 $nbtotalofrecords = '';
315 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
316 {
317  $result = $db->query($sql);
318  $nbtotalofrecords = $db->num_rows($result);
319 }
320 
321 $sql.= $db->plimit($limit + 1, $offset);
322 //print $sql;
323 
324 dol_syslog("comm/action/list.php", LOG_DEBUG);
325 $resql=$db->query($sql);
326 if ($resql)
327 {
328  $actionstatic=new ActionComm($db);
329  $societestatic=new Societe($db);
330 
331  $num = $db->num_rows($resql);
332 
333  /*$title=$langs->trans("DoneAndToDoActions");
334  if ($status == 'done') $title=$langs->trans("DoneActions");
335  if ($status == 'todo') $title=$langs->trans("ToDoActions");
336  */
337  $title=$langs->trans("ListOfEvents");
338 
339  $newtitle=$langs->trans($title);
340 
341  $tabactive='cardlist';
342 
343  $head = calendars_prepare_head($param);
344 
345  print '<form method="POST" id="searchFormList" class="listactionsfilter" action="'.$_SERVER["PHP_SELF"].'">'."\n";
346 
347  if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
348  print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
349  print '<input type="hidden" name="action" value="list">';
350  print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
351  print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
352  print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
353  print '<input type="hidden" name="page" value="'.$page.'">';
354  print '<input type="hidden" name="type" value="'.$type.'">';
355  $nav='';
356  if ($optioncss != '') $nav.= '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
357  //if ($actioncode) $nav.='<input type="hidden" name="actioncode" value="'.$actioncode.'">';
358  if ($resourceid) $nav.='<input type="hidden" name="resourceid" value="'.$resourceid.'">';
359  if ($filter) $nav.='<input type="hidden" name="filter" value="'.$filter.'">';
360  if ($filtert) $nav.='<input type="hidden" name="filtert" value="'.$filtert.'">';
361  if ($socid) $nav.='<input type="hidden" name="socid" value="'.$socid.'">';
362  if ($showbirthday) $nav.='<input type="hidden" name="showbirthday" value="1">';
363  if ($pid) $nav.='<input type="hidden" name="projectid" value="'.$pid.'">';
364  if ($usergroup) $nav.='<input type="hidden" name="usergroup" value="'.$usergroup.'">';
365  print $nav;
366 
367  dol_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action');
368  print_actions_filter($form,$canedit,$status,$year,$month,$day,$showbirthday,0,$filtert,0,$pid,$socid,$action,-1,$actioncode,$usergroup,'',$resourceid);
369  dol_fiche_end();
370 
371  // Add link to show birthdays
372  $link='';
373  /*
374  if (empty($conf->use_javascript_ajax))
375  {
376  $newparam=$param; // newparam is for birthday links
377  $newparam=preg_replace('/showbirthday=[0-1]/i','showbirthday='.(empty($showbirthday)?1:0),$newparam);
378  if (! preg_match('/showbirthday=/i',$newparam)) $newparam.='&showbirthday=1';
379  $link='<a href="'.$_SERVER['PHP_SELF'];
380  $link.='?'.$newparam;
381  $link.='">';
382  if (empty($showbirthday)) $link.=$langs->trans("AgendaShowBirthdayEvents");
383  else $link.=$langs->trans("AgendaHideBirthdayEvents");
384  $link.='</a>';
385  }
386  */
387 
388  $s=$newtitle;
389 
390  // Calendars from hooks
391  $parameters=array(); $object=null;
392  $reshook=$hookmanager->executeHooks('addCalendarChoice',$parameters,$object,$action);
393  if (empty($reshook))
394  {
395  $s.= $hookmanager->resPrint;
396  }
397  elseif ($reshook > 1)
398  {
399  $s = $hookmanager->resPrint;
400  }
401 
402  if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create)
403  {
404  $tmpforcreatebutton=dol_getdate(dol_now(), true);
405 
406  $newparam.='&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$tmpforcreatebutton['year'];
407 
408  //$param='month='.$monthshown.'&year='.$year;
409  $hourminsec='100000';
410  $link = '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.sprintf("%04d%02d%02d",$tmpforcreatebutton['year'],$tmpforcreatebutton['mon'],$tmpforcreatebutton['mday']).$hourminsec.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam?'?'.$newparam:'')).'">';
411  $link.= $langs->trans("AddAction");
412  $link.= '</a>';
413  }
414 
415  print_barre_liste($s, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, -1 * $nbtotalofrecords, '', 0, $nav.$link, '', $limit);
416 
417  $moreforfilter='';
418 
419  $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
420  $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
421  if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1);
422  $i = 0;
423  print '<div class="div-table-responsive">';
424  print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
425 
426  print '<tr class="liste_titre_filter">';
427  if (! empty($arrayfields['a.id']['checked'])) print '<td class="liste_titre"></td>';
428  if (! empty($arrayfields['owner']['checked'])) print '<td class="liste_titre"></td>';
429  if (! empty($arrayfields['c.libelle']['checked'])) print '<td class="liste_titre"></td>';
430  if (! empty($arrayfields['a.label']['checked'])) print '<td class="liste_titre"><input type="text" class="maxwidth75" name="search_title" value="'.$search_title.'"></td>';
431  if (! empty($arrayfields['a.datep']['checked'])) {
432  print '<td class="liste_titre" align="center">';
433  print $form->select_date($datestart, 'datestart', 0, 0, 1, '', 1, 0, 1);
434  print '</td>';
435  }
436  if (! empty($arrayfields['a.datep2']['checked'])) {
437  print '<td class="liste_titre" align="center">';
438  print $form->select_date($dateend, 'dateend', 0, 0, 1, '', 1, 0, 1);
439  print '</td>';
440  }
441  if (! empty($arrayfields['s.nom']['checked'])) print '<td class="liste_titre"></td>';
442  if (! empty($arrayfields['a.fk_contact']['checked'])) print '<td class="liste_titre"></td>';
443  if (! empty($arrayfields['a.fk_element']['checked'])) print '<td class="liste_titre"></td>';
444 
445  // Extra fields
446  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
447 
448  // Fields from hook
449  $parameters=array('arrayfields'=>$arrayfields);
450  $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook
451  print $hookmanager->resPrint;
452 
453 
454  if (! empty($arrayfields['a.percent']['checked'])) {
455  print '<td class="liste_titre center">';
456  print $formactions->form_select_status_action('formaction',$status,1,'status',1,2);
457  print ajax_combobox('selectstatus');
458  print '</td>';
459  }
460  // Action column
461  print '<td class="liste_titre" align="middle">';
462  $searchpicto=$form->showFilterButtons();
463  print $searchpicto;
464  print '</td>';
465  print "</tr>\n";
466 
467  print '<tr class="liste_titre">';
468  if (! empty($arrayfields['a.id']['checked'])) print_liste_field_titre($arrayfields['a.id']['label'], $_SERVER["PHP_SELF"],"a.id",$param,"","",$sortfield,$sortorder);
469  if (! empty($arrayfields['owner']['checked'])) print_liste_field_titre($arrayfields['owner']['label'], $_SERVER["PHP_SELF"],"",$param,"","",$sortfield,$sortorder);
470  if (! empty($arrayfields['c.libelle']['checked'])) print_liste_field_titre($arrayfields['c.libelle']['label'], $_SERVER["PHP_SELF"],"c.libelle",$param,"","",$sortfield,$sortorder);
471  if (! empty($arrayfields['a.label']['checked'])) print_liste_field_titre($arrayfields['a.label']['label'], $_SERVER["PHP_SELF"],"a.label",$param,"","",$sortfield,$sortorder);
472  //if (! empty($conf->global->AGENDA_USE_EVENT_TYPE))
473  if (! empty($arrayfields['a.datep']['checked'])) print_liste_field_titre($arrayfields['a.datep']['label'], $_SERVER["PHP_SELF"],"a.datep",$param,'','align="center"',$sortfield,$sortorder);
474  if (! empty($arrayfields['a.datep2']['checked'])) print_liste_field_titre($arrayfields['a.datep2']['label'], $_SERVER["PHP_SELF"],"a.datep2",$param,'','align="center"',$sortfield,$sortorder);
475  if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"],"s.nom",$param,"","",$sortfield,$sortorder);
476  if (! empty($arrayfields['a.fk_contact']['checked'])) print_liste_field_titre($arrayfields['a.fk_contact']['label'], $_SERVER["PHP_SELF"],"a.fk_contact",$param,"","",$sortfield,$sortorder);
477  if (! empty($arrayfields['a.fk_element']['checked'])) print_liste_field_titre($arrayfields['a.fk_element']['label'], $_SERVER["PHP_SELF"],"a.fk_element",$param,"","",$sortfield,$sortorder);
478 
479  // Extra fields
480  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
481 
482  // Hook fields
483  $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder);
484  $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook
485  print $hookmanager->resPrint;
486  if (! empty($arrayfields['a.percent']['checked']))print_liste_field_titre("Status",$_SERVER["PHP_SELF"],"a.percent",$param,"",'align="center"',$sortfield,$sortorder);
487  print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ');
488  print "</tr>\n";
489 
490  $contactstatic = new Contact($db);
491  $now=dol_now();
492  $delay_warning=$conf->global->MAIN_DELAY_ACTIONS_TODO*24*60*60;
493 
494  require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php';
495  $caction=new CActionComm($db);
496  $arraylist=$caction->liste_array(1, 'code', '', (empty($conf->global->AGENDA_USE_EVENT_TYPE)?1:0), '', 1);
497 
498  $var=true;
499  while ($i < min($num,$limit))
500  {
501  $obj = $db->fetch_object($resql);
502 
503  // Discard auto action if option is on
504  if (! empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->type_code == 'AC_OTH_AUTO')
505  {
506  $i++;
507  continue;
508  }
509 
510  $actionstatic->id=$obj->id;
511  $actionstatic->ref=$obj->id;
512  $actionstatic->type_code=$obj->type_code;
513  $actionstatic->type_label=$obj->type_label;
514  $actionstatic->type_picto=$obj->type_picto;
515  $actionstatic->label=$obj->label;
516 
517  print '<tr class="oddeven">';
518 
519  if (! empty($arrayfields['a.id']['checked'])) {
520  // Ref
521  print '<td>';
522  print $actionstatic->getNomUrl(1,-1);
523  print '</td>';
524  }
525 
526  // User owner
527  if (! empty($arrayfields['owner']['checked']))
528  {
529  print '<td class="'.($conf->browser->name != 'chrome'?'':'tdoverflowmax100').'">'; // With edge and chrom the td overflow is not supported correctly when content is not full text.
530  if ($obj->fk_user_action > 0)
531  {
532  $userstatic->fetch($obj->fk_user_action);
533  print $userstatic->getNomUrl(-1);
534  }
535  else print '&nbsp;';
536  print '</td>';
537  }
538 
539  // Type
540  if (! empty($arrayfields['c.libelle']['checked']))
541  {
542  print '<td>';
543  if (! empty($conf->global->AGENDA_USE_EVENT_TYPE))
544  {
545  if ($actionstatic->type_picto) print img_picto('', $actionstatic->type_picto);
546  else {
547  if ($actionstatic->type_code == 'AC_RDV') print img_picto('', 'object_group', '', false, 0, 0, '', 'paddingright').' ';
548  elseif ($actionstatic->type_code == 'AC_TEL') print img_picto('', 'object_phoning', '', false, 0, 0, '', 'paddingright').' ';
549  elseif ($actionstatic->type_code == 'AC_FAX') print img_picto('', 'object_phoning_fax', '', false, 0, 0, '', 'paddingright').' ';
550  elseif ($actionstatic->type_code == 'AC_EMAIL') print img_picto('', 'object_email', '', false, 0, 0, '', 'paddingright').' ';
551  elseif ($actionstatic->type_code == 'AC_INT') print img_picto('', 'object_intervention', '', false, 0, 0, '', 'paddingright').' ';
552  elseif (! preg_match('/_AUTO/', $actionstatic->type_code)) print img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright').' ';
553  }
554  }
555  $labeltype=$obj->type_code;
556  if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($arraylist[$labeltype])) $labeltype='AC_OTH';
557  if (! empty($arraylist[$labeltype])) $labeltype=$arraylist[$labeltype];
558  print dol_trunc($labeltype,28);
559  print '</td>';
560  }
561 
562  // Label
563  if (! empty($arrayfields['a.label']['checked'])) {
564  print '<td class="tdoverflowmax200">';
565  print $actionstatic->label;
566  print '</td>';
567  }
568 
569  // Start date
570  if (! empty($arrayfields['a.datep']['checked'])) {
571  print '<td align="center">';
572  print dol_print_date($db->jdate($obj->dp),"dayhour");
573  $late=0;
574  if ($obj->percent == 0 && $obj->dp && $db->jdate($obj->dp) < ($now - $delay_warning)) $late=1;
575  if ($obj->percent == 0 && ! $obj->dp && $obj->dp2 && $db->jdate($obj->dp) < ($now - $delay_warning)) $late=1;
576  if ($obj->percent > 0 && $obj->percent < 100 && $obj->dp2 && $db->jdate($obj->dp2) < ($now - $delay_warning)) $late=1;
577  if ($obj->percent > 0 && $obj->percent < 100 && ! $obj->dp2 && $obj->dp && $db->jdate($obj->dp) < ($now - $delay_warning)) $late=1;
578  if ($late) print img_warning($langs->trans("Late")).' ';
579  print '</td>';
580  }
581 
582  // End date
583  if (! empty($arrayfields['a.datep2']['checked'])) {
584  print '<td align="center">';
585  print dol_print_date($db->jdate($obj->dp2),"dayhour");
586  print '</td>';
587  }
588 
589  // Third party
590  if (! empty($arrayfields['s.nom']['checked'])) {
591  print '<td class="tdoverflowmax100">';
592  if ($obj->socid)
593  {
594  $societestatic->id=$obj->socid;
595  $societestatic->client=$obj->client;
596  $societestatic->name=$obj->societe;
597  print $societestatic->getNomUrl(1,'',28);
598  }
599  else print '&nbsp;';
600  print '</td>';
601  }
602 
603  // Contact
604  if (! empty($arrayfields['a.fk_contact']['checked'])) {
605  print '<td>';
606  if ($obj->fk_contact > 0)
607  {
608  $contactstatic->lastname=$obj->lastname;
609  $contactstatic->firstname=$obj->firstname;
610  $contactstatic->id=$obj->fk_contact;
611  print $contactstatic->getNomUrl(1,'',28);
612  }
613  else
614  {
615  print "&nbsp;";
616  }
617  print '</td>';
618  }
619 
620  // Linked object
621  if (! empty($arrayfields['a.fk_element']['checked'])) {
622  print '<td>';
623  if ($obj->fk_element > 0 && ! empty($obj->elementtype)) {
624  include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
625  print dolGetElementUrl($obj->fk_element,$obj->elementtype,1);
626  } else {
627  print "&nbsp;";
628  }
629  print '</td>';
630 
631  }
632 
633  // Extra fields
634  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
635  // Fields from hook
636  $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj);
637  $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook
638  print $hookmanager->resPrint;
639 
640  if (! empty($arrayfields['a.percent']['checked'])) {
641  // Status/Percent
642  $datep=$db->jdate($obj->datep);
643  print '<td align="center" class="nowrap">'.$actionstatic->LibStatut($obj->percent,3,0,$datep).'</td>';
644  }
645  print '<td></td>';
646 
647  print "</tr>\n";
648  $i++;
649  }
650  print "</table>";
651  print '</div>';
652  print '</form>';
653 
654  $db->free($resql);
655 
656 }
657 else
658 {
659  dol_print_error($db);
660 }
661 
662 
663 llxFooter();
664 
665 $db->close();
Class to manage different types of events.
llxFooter()
Empty footer.
Definition: wrapper.php:58
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve')
Convert a html select field into an ajax combobox.
Definition: ajax.lib.php:392
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='')
Show picto whatever it's its name (generic function)
setEventMessages($mesg, $mesgs, $style='mesgs')
Set event messages in dol_events session object.
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.
if(!GETPOST('transkey')&&!GETPOST('transphrase')) else
View.
Definition: notice.php:43
Class to manage building of HTML components.
Class to manage agenda events (actions)
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm=false, $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='')
Show tab header of a card.
Class to manage contact/addresses.
if(GETPOST('cancel','alpha')) if(!GETPOST('confirmmassaction','alpha')&&$massaction!= 'presend'&&$massaction!= 'confirm_presend')
Draft customers invoices.
Definition: list.php:147
calendars_prepare_head($param)
Define head array for tabs of agenda setup pages.
Definition: agenda.lib.php:510
Class to manage Dolibarr users.
Definition: user.class.php:39
print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, $filtera, $filtert, $filterd, $pid, $socid, $action, $showextcals=array(), $actioncode='', $usergroupid='', $excludetype='', $resourceid=0)
Show filter form in agenda view.
Definition: agenda.lib.php:50
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
if(empty($reshook)) $form
View.
Definition: perms.php:103
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Class to manage standard extra fields.
Class to manage generation of HTML components Only common components must be here.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='title_generic.png', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0)
Print a title with navigation controls for pagination.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='')
Write log message into outputs.
Class to manage third parties objects (customers, suppliers, prospects...)
img_warning($titlealt= 'default', $moreatt= '')
Show warning logo.
if($_POST["cancel"]==$langs->trans("Cancel")&&!$id) if($action== 'setdatev'&&$user->rights->tax->charges->creer) if($action== 'add'&&$_POST["cancel"]<> $langs->trans("Cancel")) if($action== 'delete') $title
Actions.
Definition: card.php:183
dol_fiche_end($notab=0)
Show tab footer of a card.
llxHeader()
Empty header.
Definition: wrapper.php:46
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_now($mode='gmt')
Return date for now.
dol_print_date($time, $format='', $tzoutput='tzserver', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dolGetElementUrl($objectid, $objecttype, $withpicto=0, $option='')
List urls of element.
print
Draft customers invoices.
Definition: index.php:91
if(preg_match('/set_(.*)/', $action, $reg)) if(preg_match('/del_(.*)/', $action, $reg)) if($action== 'set') else if($action== 'specimen') else if($action== 'setmodel') else if($action== 'del') else if($action== 'setdoc' $formactions)
View.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if(!empty($conf->fournisseur->enabled)&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->societe->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if(!empty($conf->fournisseur->enabled)&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1013
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="")
Show title line of an array.
dol_getdate($timestamp, $fast=false)
Return an array with locale date info.
type
Definition: viewcat.php:283
restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $objcanvas=null)
Check permissions of a user to show a page and an object.