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