dolibarr  7.0.0-beta
list.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
5  * Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es>
6  * Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
7  * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.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 require '../main.inc.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
31 require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
32 require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
33 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
34 
35 $langs->load("companies");
36 $langs->load("bills");
37 $langs->load("interventions");
38 
39 $action=GETPOST('action','alpha');
40 $massaction=GETPOST('massaction','alpha');
41 $show_files=GETPOST('show_files','int');
42 $confirm=GETPOST('confirm','alpha');
43 $toselect = GETPOST('toselect', 'array');
44 
45 $search_ref=GETPOST('search_ref')?GETPOST('search_ref','alpha'):GETPOST('search_inter','alpha');
46 $search_company=GETPOST('search_company','alpha');
47 $search_desc=GETPOST('search_desc','alpha');
48 $search_status=GETPOST('search_status');
49 $sall=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml'));
50 $optioncss = GETPOST('optioncss','alpha');
51 $socid=GETPOST('socid','int');
52 
53 // Security check
54 $id = GETPOST('id','int');
55 if ($user->societe_id) $socid=$user->societe_id;
56 $result = restrictedArea($user, 'ficheinter', $id,'fichinter');
57 
58 $diroutputmassaction=$conf->ficheinter->dir_output . '/temp/massgeneration/'.$user->id;
59 
60 $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit;
61 $sortfield = GETPOST('sortfield','alpha');
62 $sortorder = GETPOST('sortorder','alpha');
63 $page = GETPOST('page','int');
64 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
65 $offset = $limit * $page;
66 $pageprev = $page - 1;
67 $pagenext = $page + 1;
68 if (! $sortorder) $sortorder="DESC";
69 if (! $sortfield)
70 {
71  if (empty($conf->global->FICHINTER_DISABLE_DETAILS)) $sortfield="fd.date";
72  else $sortfield="f.ref";
73 }
74 
75 // Initialize technical object to manage context to save list fields
76 $contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'interventionlist';
77 
78 $sall=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml'));
79 $search_ref=GETPOST('search_ref')?GETPOST('search_ref','alpha'):GETPOST('search_inter','alpha');
80 $search_company=GETPOST('search_company','alpha');
81 $search_desc=GETPOST('search_desc','alpha');
82 $search_status=GETPOST('search_status');
83 $optioncss = GETPOST('optioncss','alpha');
84 
85 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
86 $hookmanager->initHooks(array($contextpage));
87 $extrafields = new ExtraFields($db);
88 
89 // fetch optionals attributes and labels
90 $extralabels = $extrafields->fetch_name_optionals_label('fichinter');
91 $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_');
92 
93 // List of fields to search into when doing a "search in all"
94 $fieldstosearchall = array(
95  'f.ref'=>'Ref',
96  's.nom'=>"ThirdParty",
97  'f.description'=>'Description',
98  'f.note_public'=>'NotePublic',
99 );
100 if (empty($user->socid)) $fieldstosearchall["f.note_private"]="NotePrivate";
101 if (! empty($conf->global->FICHINTER_DISABLE_DETAILS)) unset($fieldstosearchall['f.description']);
102 
103 // Definition of fields for list
104 $arrayfields=array(
105  'f.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
106  's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1),
107  'f.fk_project'=>array('label'=>$langs->trans("Project"), 'checked'=>1),
108  'f.fk_contrat'=>array('label'=>$langs->trans("Contract"), 'checked'=>1),
109  'f.description'=>array('label'=>$langs->trans("Description"), 'checked'=>1),
110  'fd.description'=>array('label'=>"xx", 'checked'=>1, 'enabled'=>empty($conf->global->FICHINTER_DISABLE_DETAILS)?1:0),
111  'fd.date'=>array('label'=>$langs->trans("Date"), 'checked'=>1, 'enabled'=>empty($conf->global->FICHINTER_DISABLE_DETAILS)?1:0),
112  'fd.duree'=>array('label'=>$langs->trans("Duration"), 'checked'=>1, 'enabled'=>empty($conf->global->FICHINTER_DISABLE_DETAILS)?1:0),
113  'f.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
114  'f.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
115  'f.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000),
116 );
117 // Extra fields
118 if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
119 {
120  foreach($extrafields->attribute_label as $key => $val)
121  {
122  if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key]));
123  }
124 }
125 
126 
127 /*
128  * Actions
129  */
130 
131 if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; }
132 if (! GETPOST('confirmmassaction','alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction=''; }
133 
134 $parameters=array('socid'=>$socid);
135 $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
136 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
137 
138 if (empty($reshook))
139 {
140  // Selection of new fields
141  include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
142 
143  // Purge search criteria
144  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
145  {
146  $search_ref="";
147  $search_company="";
148  $search_project="";
149  $search_contract="";
150  $search_desc="";
151  $search_status="";
152  $toselect='';
153  $search_array_options=array();
154  }
155 
156  // Mass actions
157  $objectclass='Fichinter';
158  $objectlabel='Interventions';
159  $permtoread = $user->rights->ficheinter->lire;
160  $permtodelete = $user->rights->ficheinter->supprimer;
161  $uploaddir = $conf->ficheinter->dir_output;
162  include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
163 }
164 
165 
166 
167 /*
168  * View
169  */
170 
171 $now=dol_now();
172 
173 $form = new Form($db);
174 $formfile = new FormFile($db);
175 $objectstatic=new Fichinter($db);
176 $companystatic=new Societe($db);
177 
178 $title=$langs->trans("ListOfInterventions");
179 llxHeader('', $title);
180 
181 
182 $sql = "SELECT";
183 $sql.= " f.ref, f.rowid, f.fk_statut, f.description, f.datec as date_creation, f.tms as date_update, f.note_private,";
184 if (empty($conf->global->FICHINTER_DISABLE_DETAILS)) $sql.= " fd.description as descriptiondetail, fd.date as dp, fd.duree,";
185 $sql.= " s.nom as name, s.rowid as socid, s.client";
186 // Add fields from extrafields
187 foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : '');
188 // Add fields from hooks
189 $parameters=array();
190 $reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook
191 $sql.=$hookmanager->resPrint;
192 $sql.= " FROM ".MAIN_DB_PREFIX."fichinter as f";
193 if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."fichinter_extrafields as ef on (f.rowid = ef.fk_object)";
194 if (empty($conf->global->FICHINTER_DISABLE_DETAILS)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."fichinterdet as fd ON fd.fk_fichinter = f.rowid";
195 if (! $user->rights->societe->client->voir && empty($socid)) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
196 $sql.= ", ".MAIN_DB_PREFIX."societe as s";
197 $sql.= " WHERE f.fk_soc = s.rowid ";
198 $sql.= " AND f.entity = ".$conf->entity;
199 if ($search_ref) {
200  $sql .= natural_search('f.ref', $search_ref);
201 }
202 if ($search_company) {
203  $sql .= natural_search('s.nom', $search_company);
204 }
205 if ($search_desc) {
206  if (empty($conf->global->FICHINTER_DISABLE_DETAILS)) $sql .= natural_search(array('f.description', 'fd.description'), $search_desc);
207  else $sql .= natural_search(array('f.description'), $search_desc);
208 }
209 if ($search_status != '' && $search_status >= 0) {
210  $sql .= ' AND f.fk_statut = '.$search_status;
211 }
212 if (! $user->rights->societe->client->voir && empty($socid))
213  $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
214 if ($socid)
215  $sql.= " AND s.rowid = " . $socid;
216 if ($sall) {
217  $sql .= natural_search(array_keys($fieldstosearchall), $sall);
218 }
219 // Add where from extra fields
220 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
221 // Add where from hooks
222 $parameters=array();
223 $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook
224 $sql.=$hookmanager->resPrint;
225 $sql.= $db->order($sortfield,$sortorder);
226 
227 // Count total nb of records
228 $nbtotalofrecords = '';
229 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
230 {
231  $result = $db->query($sql);
232  $nbtotalofrecords = $db->num_rows($result);
233 }
234 
235 $sql.= $db->plimit($limit+1, $offset);
236 //print $sql;
237 
238 $resql=$db->query($sql);
239 if ($resql)
240 {
241  $num = $db->num_rows($resql);
242 
243  $arrayofselected=is_array($toselect)?$toselect:array();
244 
245  if ($socid > 0)
246  {
247  $soc = new Societe($db);
248  $soc->fetch($socid);
249  if (empty($search_company)) $search_company = $soc->name;
250  }
251 
252  $param='';
253  if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
254  if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
255  if ($sall) $urlparam.="&sall=".$sall;
256  if ($socid) $param.="&socid=".$socid;
257  if ($search_ref) $param.="&search_ref=".urlencode($search_ref);
258  if ($search_company) $param.="&search_company=".urlencode($search_company);
259  if ($search_desc) $param.="&search_desc=".urlencode($search_desc);
260  if ($search_status != '' && $search_status > -1) $param.="&search_status=".urlencode($search_status);
261  if ($show_files) $param.='&show_files=' .$show_files;
262  if ($optioncss != '') $param.='&optioncss='.$optioncss;
263  // Add $param from extra fields
264  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
265 
266  // List of mass actions available
267  $arrayofmassactions = array(
268  //'presend'=>$langs->trans("SendByMail"),
269  'builddoc'=>$langs->trans("PDFMerge"),
270  );
271  if ($user->rights->ficheinter->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete");
272  if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
273  $massactionbutton=$form->selectMassAction('', $arrayofmassactions);
274 
275  // Lines of title fields
276  print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
277  if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
278  print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
279  print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
280  print '<input type="hidden" name="action" value="list">';
281  print '<input type="hidden" name="page" value="'.$page.'">';
282  print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
283  print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
284  print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
285 
286  print_barre_liste($title, $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_commercial.png', 0, '', '', $limit);
287 
288  $topicmail="Information";
289  $modelmail="intervention";
290  $objecttmp=new Fichinter($db);
291  $trackid='int'.$object->id;
292  include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
293 
294  if ($sall)
295  {
296  foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
297  print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall);
298  }
299 
300  $moreforfilter='';
301 
302  $parameters=array();
303  $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook
304  if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
305  else $moreforfilter = $hookmanager->resPrint;
306 
307  if (! empty($moreforfilter))
308  {
309  print '<div class="liste_titre liste_titre_bydiv centpercent">';
310  print $moreforfilter;
311  print '</div>';
312  }
313 
314  $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
315  $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
316  if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1);
317 
318  print '<div class="div-table-responsive">';
319  print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
320 
321  print '<tr class="liste_titre_filter">';
322  if (! empty($arrayfields['f.ref']['checked']))
323  {
324  print '<td class="liste_titre">';
325  print '<input type="text" class="flat" name="search_ref" value="'.$search_ref.'" size="8">';
326  print '</td>';
327  }
328  if (! empty($arrayfields['s.nom']['checked']))
329  {
330  print '<td class="liste_titre">';
331  print '<input type="text" class="flat" name="search_company" value="'.$search_company.'" size="10">';
332  print '</td>';
333  }
334  if (! empty($arrayfields['f.description']['checked']))
335  {
336  print '<td class="liste_titre">';
337  print '<input type="text" class="flat" name="search_desc" value="'.$search_desc.'" size="12">';
338  print '</td>';
339  }
340  if (! empty($arrayfields['fd.description']['checked']))
341  {
342  // Desc of line
343  print '<td class="liste_titre">&nbsp;</td>';
344  }
345  if (! empty($arrayfields['fd.date']['checked']))
346  {
347  print '<td class="liste_titre">&nbsp;</td>';
348  }
349  if (! empty($arrayfields['fd.duree']['checked']))
350  {
351  print '<td class="liste_titre">&nbsp;</td>';
352  }
353  // Extra fields
354  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
355 
356  // Fields from hook
357  $parameters=array('arrayfields'=>$arrayfields);
358  $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook
359  print $hookmanager->resPrint;
360  if (! empty($arrayfields['f.datec']['checked']))
361  {
362  // Date creation
363  print '<td class="liste_titre">';
364  print '</td>';
365  }
366  if (! empty($arrayfields['f.tms']['checked']))
367  {
368  // Date modification
369  print '<td class="liste_titre">';
370  print '</td>';
371  }
372  // Status
373  if (! empty($arrayfields['f.fk_statut']['checked']))
374  {
375  print '<td class="liste_titre" align="right">';
376  $liststatus=$objectstatic->statuts_short;
377  if (empty($conf->global->FICHINTER_CLASSIFY_BILLED)) unset($liststatus[2]); // Option deprecated. In a future, billed must be managed with a dedicated field to 0 or 1
378  print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 1);
379  print '</td>';
380  }
381  print '<td class="liste_titre" align="right">';
382  $searchpicto=$form->showFilterButtons();
383  print $searchpicto;
384  print '</td>';
385 
386  print "</tr>\n";
387 
388  print '<tr class="liste_titre">';
389  if (! empty($arrayfields['f.ref']['checked'])) print_liste_field_titre("Ref",$_SERVER["PHP_SELF"],"f.ref","",$param,'',$sortfield,$sortorder);
390  if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre("ThirdParty",$_SERVER["PHP_SELF"],"s.nom","",$param,'',$sortfield,$sortorder);
391  if (! empty($arrayfields['f.description']['checked'])) print_liste_field_titre("Description",$_SERVER["PHP_SELF"],"f.description","",$param,'',$sortfield,$sortorder);
392  if (! empty($arrayfields['fd.description']['checked'])) print_liste_field_titre('',$_SERVER["PHP_SELF"],'');
393  if (! empty($arrayfields['fd.date']['checked'])) print_liste_field_titre("Date",$_SERVER["PHP_SELF"],"fd.date","",$param,'align="center"',$sortfield,$sortorder);
394  if (! empty($arrayfields['fd.duree']['checked'])) print_liste_field_titre("Duration",$_SERVER["PHP_SELF"],"fd.duree","",$param,'align="right"',$sortfield,$sortorder);
395  // Extra fields
396  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
397  // Hook fields
398  $parameters=array('arrayfields'=>$arrayfields);
399  $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook
400  print $hookmanager->resPrint;
401  if (! empty($arrayfields['f.datec']['checked'])) print_liste_field_titre("DateCreationShort",$_SERVER["PHP_SELF"],"f.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
402  if (! empty($arrayfields['f.tms']['checked'])) print_liste_field_titre("DateModificationShort",$_SERVER["PHP_SELF"],"f.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
403  if (! empty($arrayfields['f.fk_statut']['checked'])) print_liste_field_titre("Status",$_SERVER["PHP_SELF"],"f.fk_statut","",$param,'align="right"',$sortfield,$sortorder);
404  print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ');
405  print "</tr>\n";
406 
407  $total = 0;
408  $i = 0;
409  $totalarray=array();
410  while ($i < min($num, $limit))
411  {
412  $obj = $db->fetch_object($resql);
413 
414  $objectstatic->id=$obj->rowid;
415  $objectstatic->ref=$obj->ref;
416  $objectstatic->statut=$obj->fk_statut;
417 
418  print '<tr class="oddeven">';
419 
420  if (! empty($arrayfields['f.ref']['checked']))
421  {
422  print "<td>";
423 
424  print '<table class="nobordernopadding"><tr class="nocellnopadd">';
425  // Picto + Ref
426  print '<td class="nobordernopadding nowrap">';
427  print $objectstatic->getNomUrl(1);
428  print '</td>';
429  // Warning
430  $warnornote='';
431  //if ($obj->fk_statut == 1 && $db->jdate($obj->dfv) < ($now - $conf->fichinter->warning_delay)) $warnornote.=img_warning($langs->trans("Late"));
432  if (! empty($obj->note_private))
433  {
434  $warnornote.=($warnornote?' ':'');
435  $warnornote.= '<span class="note">';
436  $warnornote.= '<a href="note.php?id='.$obj->rowid.'">'.img_picto($langs->trans("ViewPrivateNote"),'object_generic').'</a>';
437  $warnornote.= '</span>';
438  }
439  if ($warnornote)
440  {
441  print '<td style="min-width: 20px" class="nobordernopadding nowrap">';
442  print $warnornote;
443  print '</td>';
444  }
445 
446  // Other picto tool
447  print '<td width="16" align="right" class="nobordernopadding hideonsmartphone">';
448  $filename=dol_sanitizeFileName($obj->ref);
449  $filedir=$conf->ficheinter->dir_output . '/' . dol_sanitizeFileName($obj->ref);
450  $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid;
451  print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
452  print '</td></tr></table>';
453 
454  print "</td>\n";
455  if (! $i) $totalarray['nbfield']++;
456  }
457  if (! empty($arrayfields['s.nom']['checked']))
458  {
459  print '<td>';
460  $companystatic->name=$obj->name;
461  $companystatic->id=$obj->socid;
462  $companystatic->client=$obj->client;
463  print $companystatic->getNomUrl(1,'',44);
464  print '</td>';
465  if (! $i) $totalarray['nbfield']++;
466  }
467  if (! empty($arrayfields['f.description']['checked']))
468  {
469  print '<td>'.dol_trunc(dolGetFirstLineOfText($obj->description),48).'</td>';
470  if (! $i) $totalarray['nbfield']++;
471  }
472  if (! empty($arrayfields['fd.description']['checked']))
473  {
474  //print '<td>'.dol_trunc(dol_escape_htmltag(dolGetFirstLineOfText($obj->descriptiondetail)),48).'</td>';
475  print '<td>'.dolGetFirstLineOfText($obj->descriptiondetail).'</td>';
476  if (! $i) $totalarray['nbfield']++;
477  }
478  if (! empty($arrayfields['fd.date']['checked']))
479  {
480  print '<td align="center">'.dol_print_date($db->jdate($obj->dp),'dayhour')."</td>\n";
481  if (! $i) $totalarray['nbfield']++;
482  }
483  if (! empty($arrayfields['fd.duree']['checked']))
484  {
485  print '<td align="right">'.convertSecondToTime($obj->duree, 'allhourmin').'</td>';
486  if (! $i) $totalarray['nbfield']++;
487  if (! $i) $totalarray['totaldurationfield']=$totalarray['nbfield'];
488  $totalarray['totalduration']+=$obj->duree;
489  }
490 
491  // Extra fields
492  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
493  // Fields from hook
494  $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj);
495  $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook
496  print $hookmanager->resPrint;
497  // Date creation
498  if (! empty($arrayfields['f.datec']['checked']))
499  {
500  print '<td align="center">';
501  print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
502  print '</td>';
503  if (! $i) $totalarray['nbfield']++;
504  }
505  // Date modification
506  if (! empty($arrayfields['f.tms']['checked']))
507  {
508  print '<td align="center">';
509  print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
510  print '</td>';
511  if (! $i) $totalarray['nbfield']++;
512  }
513  // Status
514  if (! empty($arrayfields['f.fk_statut']['checked']))
515  {
516  print '<td align="right">'.$objectstatic->LibStatut($obj->fk_statut,5).'</td>';
517  if (! $i) $totalarray['nbfield']++;
518  }
519  // Action column
520  print '<td class="nowrap" align="center">';
521  if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
522  {
523  $selected=0;
524  if (in_array($obj->rowid, $arrayofselected)) $selected=1;
525  print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>';
526  }
527  print '</td>';
528  if (! $i) $totalarray['nbfield']++;
529 
530  print "</tr>\n";
531 
532  $total += $obj->duree;
533  $i++;
534  }
535 
536  // Show total line
537  if (isset($totalarray['totalduration']))
538  {
539  print '<tr class="liste_total">';
540  $i=0;
541  while ($i < $totalarray['nbfield'])
542  {
543  $i++;
544  if ($i == 1)
545  {
546  if ($num < $limit && empty($offset)) print '<td align="left">'.$langs->trans("Total").'</td>';
547  else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>';
548  }
549  elseif ($totalarray['totaldurationfield'] == $i) print '<td align="right">'.convertSecondToTime($totalarray['totalduration'], 'allhourmin').'</td>';
550  else print '<td></td>';
551  }
552  print '</tr>';
553  }
554 
555  $db->free($resql);
556 
557  $parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql);
558  $reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook
559  print $hookmanager->resPrint;
560 
561  print '</table>'."\n";
562  print '</div>';
563 
564  print "</form>\n";
565 
566  if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files)
567  {
568  /*
569  * Show list of available documents
570  */
571  $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
572  $urlsource.=str_replace('&amp;','&',$param);
573 
574  $filedir=$diroutputmassaction;
575  $genallowed=$user->rights->ficheinter->lire;
576  $delallowed=$user->rights->ficheinter->creer;
577 
578  print $formfile->showdocuments('massfilesarea_interventions','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'');
579  }
580  else
581  {
582  print '<br><a name="show_files"></a><a href="'.$_SERVER["PHP_SELF"].'?show_files=1'.$param.'#show_files">'.$langs->trans("ShowTempMassFilesArea").'</a>';
583  }
584 
585 }
586 else
587 {
588  dol_print_error($db);
589 }
590 
591 
592 llxFooter();
593 $db->close();
convertSecondToTime($iSecond, $format='all', $lengthOfDay=86400, $lengthOfWeek=7)
Return, in clear text, value of a number of seconds in days, hours and minutes.
Definition: date.lib.php:171
llxFooter()
Empty footer.
Definition: wrapper.php:58
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.
if(!GETPOST('transkey')&&!GETPOST('transphrase')) else
View.
Definition: notice.php:43
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
if(GETPOST('cancel','alpha')) if(!GETPOST('confirmmassaction','alpha')&&$massaction!= 'presend'&&$massaction!= 'confirm_presend')
Draft customers invoices.
Definition: list.php:147
Class to manage interventions.
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.
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.
Class to manage third parties objects (customers, suppliers, prospects...)
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
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...
dolGetFirstLineOfText($text, $nboflines=1)
Return first line of text.
dol_now($mode='gmt')
Return date for now.
Class to offer components to list and upload files.
dol_print_date($time, $format='', $tzoutput='tzserver', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
print
Draft customers invoices.
Definition: index.php:91
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.
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.