dolibarr  13.0.2
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@inodbox.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  * Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program. If not, see <https://www.gnu.org/licenses/>.
22  */
23 
30 require '../main.inc.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
32 require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
33 require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
34 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
35 if (!empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
36 if (!empty($conf->contrat->enabled)) require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
37 
38 // Load translation files required by the page
39 $langs->loadLangs(array('companies', 'bills', 'interventions'));
40 if (!empty($conf->projet->enabled)) $langs->load("projects");
41 if (!empty($conf->contrat->enabled)) $langs->load("contracts");
42 
43 $action = GETPOST('action', 'aZ09');
44 $massaction = GETPOST('massaction', 'alpha');
45 $show_files = GETPOST('show_files', 'int');
46 $confirm = GETPOST('confirm', 'alpha');
47 $toselect = GETPOST('toselect', 'array');
48 $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'interventionlist';
49 
50 $search_ref = GETPOST('search_ref') ?GETPOST('search_ref', 'alpha') : GETPOST('search_inter', 'alpha');
51 $search_company = GETPOST('search_company', 'alpha');
52 $search_desc = GETPOST('search_desc', 'alpha');
53 $search_projet_ref = GETPOST('search_projet_ref', 'alpha');
54 $search_contrat_ref = GETPOST('search_contrat_ref', 'alpha');
55 $search_status = GETPOST('search_status', 'alpha');
56 $sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
57 $optioncss = GETPOST('optioncss', 'alpha');
58 $socid = GETPOST('socid', 'int');
59 
60 // Security check
61 $id = GETPOST('id', 'int');
62 if ($user->socid) $socid = $user->socid;
63 $result = restrictedArea($user, 'ficheinter', $id, 'fichinter');
64 
65 $diroutputmassaction = $conf->ficheinter->dir_output.'/temp/massgeneration/'.$user->id;
66 
67 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
68 $sortfield = GETPOST('sortfield', 'aZ09comma');
69 $sortorder = GETPOST('sortorder', 'aZ09comma');
70 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
71 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
72 $offset = $limit * $page;
73 $pageprev = $page - 1;
74 $pagenext = $page + 1;
75 if (!$sortorder) $sortorder = "DESC";
76 if (!$sortfield)
77 {
78  $sortfield = "f.ref";
79 }
80 
81 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
82 $object = new Fichinter($db);
83 $hookmanager->initHooks(array('interventionlist'));
84 
85 $extrafields = new ExtraFields($db);
86 
87 // fetch optionals attributes and labels
88 $extrafields->fetch_name_optionals_label($object->table_element);
89 
90 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
91 
92 // List of fields to search into when doing a "search in all"
93 $fieldstosearchall = array(
94  'f.ref'=>'Ref',
95  's.nom'=>"ThirdParty",
96  'f.description'=>'Description',
97  'f.note_public'=>'NotePublic',
98  'fd.description'=>'DescriptionOfLine',
99 );
100 if (empty($user->socid)) $fieldstosearchall["f.note_private"] = "NotePrivate";
101 if (!empty($conf->global->FICHINTER_DISABLE_DETAILS)) unset($fieldstosearchall['fd.description']);
102 
103 // Definition of fields for list
104 $arrayfields = array(
105  'f.ref'=>array('label'=>'Ref', 'checked'=>1),
106  's.nom'=>array('label'=>'ThirdParty', 'checked'=>1),
107  'pr.ref'=>array('label'=>'Project', 'checked'=>1, 'enabled'=>(empty($conf->projet->enabled) ? 0 : 1)),
108  'c.ref'=>array('label'=>'Contract', 'checked'=>1, 'enabled'=>(empty($conf->contrat->enabled) ? 0 : 1)),
109  'f.description'=>array('label'=>'Description', 'checked'=>1),
110  'f.datec'=>array('label'=>'DateCreation', 'checked'=>0, 'position'=>500),
111  'f.tms'=>array('label'=>'DateModificationShort', 'checked'=>0, 'position'=>500),
112  'f.note_public'=>array('label'=>'NotePublic', 'checked'=>0, 'position'=>510, 'enabled'=>(empty($conf->global->MAIN_LIST_ALLOW_PUBLIC_NOTES))),
113  'f.note_private'=>array('label'=>'NotePrivate', 'checked'=>0, 'position'=>511, 'enabled'=>(empty($conf->global->MAIN_LIST_ALLOW_PRIVATE_NOTES))),
114  'f.fk_statut'=>array('label'=>'Status', 'checked'=>1, 'position'=>1000),
115  'fd.description'=>array('label'=>"DescriptionOfLine", 'checked'=>1, 'enabled'=>empty($conf->global->FICHINTER_DISABLE_DETAILS) ? 1 : 0),
116  'fd.date'=>array('label'=>'DateOfLine', 'checked'=>1, 'enabled'=>empty($conf->global->FICHINTER_DISABLE_DETAILS) ? 1 : 0),
117  'fd.duree'=>array('label'=>'DurationOfLine', 'checked'=>1, 'enabled'=>empty($conf->global->FICHINTER_DISABLE_DETAILS) ? 1 : 0),
118 );
119 // Extra fields
120 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
121 
122 $object->fields = dol_sort_array($object->fields, 'position');
123 $arrayfields = dol_sort_array($arrayfields, 'position');
124 
125 
126 /*
127  * Actions
128  */
129 
130 if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
131 if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction = ''; }
132 
133 $parameters = array('socid'=>$socid);
134 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
135 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
136 
137 if (empty($reshook))
138 {
139  // Selection of new fields
140  include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
141 
142  // Purge search criteria
143  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
144  {
145  $search_ref = "";
146  $search_company = "";
147  $search_projet_ref = "";
148  $search_contrat_ref = "";
149  $search_desc = "";
150  $search_status = "";
151  $toselect = '';
152  $search_array_options = array();
153  }
154 
155  // Mass actions
156  $objectclass = 'Fichinter';
157  $objectlabel = 'Interventions';
158  $permissiontoread = $user->rights->ficheinter->lire;
159  $permissiontodelete = $user->rights->ficheinter->supprimer;
160  $uploaddir = $conf->ficheinter->dir_output;
161  include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
162 }
163 
164 
165 
166 /*
167  * View
168  */
169 
170 $now = dol_now();
171 
172 $form = new Form($db);
173 $formfile = new FormFile($db);
174 $objectstatic = new Fichinter($db);
175 $companystatic = new Societe($db);
176 if (!empty($conf->projet->enabled)) {
177  $projetstatic = new Project($db);
178 }
179 if (!empty($conf->contrat->enabled)) {
180  $contratstatic = new Contrat($db);
181 }
182 
183 $title = $langs->trans("ListOfInterventions");
184 llxHeader('', $title);
185 
186 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
187 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
188 
189 $atleastonefieldinlines = 0;
190 foreach ($arrayfields as $tmpkey => $tmpval)
191 {
192  if (preg_match('/^fd\./', $tmpkey) && !empty($arrayfields[$tmpkey]['checked']))
193  {
194  $atleastonefieldinlines++;
195  break;
196  }
197 }
198 
199 $sql = "SELECT";
200 $sql .= " f.ref, f.rowid, f.fk_statut as status, f.description, f.datec as date_creation, f.tms as date_update, f.note_public, f.note_private,";
201 if (empty($conf->global->FICHINTER_DISABLE_DETAILS) && $atleastonefieldinlines) $sql .= " fd.rowid as lineid, fd.description as descriptiondetail, fd.date as dp, fd.duree,";
202 $sql .= " s.nom as name, s.rowid as socid, s.client, s.fournisseur, s.email, s.status as thirdpartystatus";
203 if (!empty($conf->projet->enabled)) {
204  $sql .= ", pr.rowid as projet_id, pr.ref as projet_ref, pr.title as projet_title";
205 }
206 if (!empty($conf->contrat->enabled)) {
207  $sql .= ", c.rowid as contrat_id, c.ref as contrat_ref, c.ref_customer as contrat_ref_supplier, c.ref_supplier as contrat_ref_supplier";
208 }
209 // Add fields from extrafields
210 if (!empty($extrafields->attributes[$object->table_element]['label'])) {
211  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : '');
212 }
213 // Add fields from hooks
214 $parameters = array();
215 $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
216 $sql .= $hookmanager->resPrint;
217 $sql .= " FROM ".MAIN_DB_PREFIX."fichinter as f";
218 if (!empty($conf->projet->enabled)) {
219  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as pr on f.fk_projet = pr.rowid";
220 }
221 if (!empty($conf->contrat->enabled)) {
222  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."contrat as c on f.fk_contrat = c.rowid";
223 }
224 if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (f.rowid = ef.fk_object)";
225 if (empty($conf->global->FICHINTER_DISABLE_DETAILS) && $atleastonefieldinlines) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."fichinterdet as fd ON fd.fk_fichinter = f.rowid";
226 if (!$user->rights->societe->client->voir && empty($socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
227 $sql .= ", ".MAIN_DB_PREFIX."societe as s";
228 $sql .= " WHERE f.entity IN (".getEntity('intervention').")";
229 $sql .= " AND f.fk_soc = s.rowid";
230 if ($search_ref) {
231  $sql .= natural_search('f.ref', $search_ref);
232 }
233 if ($search_company) {
234  $sql .= natural_search('s.nom', $search_company);
235 }
236 if ($search_projet_ref) {
237  $sql .= natural_search('pr.ref', $search_projet_ref);
238 }
239 if ($search_contrat_ref) {
240  $sql .= natural_search('c.ref', $search_contrat_ref);
241 }
242 if ($search_desc) {
243  if (empty($conf->global->FICHINTER_DISABLE_DETAILS) && $atleastonefieldinlines) $sql .= natural_search(array('f.description', 'fd.description'), $search_desc);
244  else $sql .= natural_search(array('f.description'), $search_desc);
245 }
246 if ($search_status != '' && $search_status >= 0) {
247  $sql .= ' AND f.fk_statut = '.urlencode($search_status);
248 }
249 if (!$user->rights->societe->client->voir && empty($socid))
250  $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
251 if ($socid)
252  $sql .= " AND s.rowid = ".$socid;
253 if ($sall) {
254  $sql .= natural_search(array_keys($fieldstosearchall), $sall);
255 }
256 // Add where from extra fields
257 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
258 // Add where from hooks
259 $parameters = array();
260 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
261 $sql .= $hookmanager->resPrint;
262 $sql .= $db->order($sortfield, $sortorder);
263 
264 // Count total nb of records
265 $nbtotalofrecords = '';
266 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
267 {
268  $result = $db->query($sql);
269  $nbtotalofrecords = $db->num_rows($result);
270  if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
271  {
272  $page = 0;
273  $offset = 0;
274  }
275 }
276 
277 $sql .= $db->plimit($limit + 1, $offset);
278 //print $sql;
279 
280 $resql = $db->query($sql);
281 if ($resql)
282 {
283  $num = $db->num_rows($resql);
284 
285  $arrayofselected = is_array($toselect) ? $toselect : array();
286 
287  if ($socid > 0)
288  {
289  $soc = new Societe($db);
290  $soc->fetch($socid);
291  if (empty($search_company)) $search_company = $soc->name;
292  }
293 
294  $param = '';
295  if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
296  if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
297  if ($sall) $param .= "&sall=".urlencode($sall);
298  if ($socid) $param .= "&socid=".urlencode($socid);
299  if ($search_ref) $param .= "&search_ref=".urlencode($search_ref);
300  if ($search_company) $param .= "&search_company=".urlencode($search_company);
301  if ($search_desc) $param .= "&search_desc=".urlencode($search_desc);
302  if ($search_status != '' && $search_status > -1) $param .= "&search_status=".urlencode($search_status);
303  if ($show_files) $param .= '&show_files='.urlencode($show_files);
304  if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
305  // Add $param from extra fields
306  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
307 
308  // List of mass actions available
309  $arrayofmassactions = array(
310  'generate_doc'=>$langs->trans("ReGeneratePDF"),
311  'builddoc'=>$langs->trans("PDFMerge"),
312  //'presend'=>$langs->trans("SendByMail"),
313  );
314  if ($user->rights->ficheinter->supprimer) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
315  if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array();
316  $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
317 
318  $newcardbutton = '';
319 
320  $url = DOL_URL_ROOT.'/fichinter/card.php?action=create';
321  if (!empty($socid)) $url .= '&socid='.$socid;
322  $newcardbutton = dolGetButtonTitle($langs->trans('NewIntervention'), '', 'fa fa-plus-circle', $url, '', $user->rights->ficheinter->creer);
323 
324  // Lines of title fields
325  print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
326  if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
327  print '<input type="hidden" name="token" value="'.newToken().'">';
328  print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
329  print '<input type="hidden" name="action" value="list">';
330  print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
331  print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
332  print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
333 
334  print_barre_liste($title, $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'commercial', 0, $newcardbutton, '', $limit, 0, 0, 1);
335 
336  $topicmail = "Information";
337  $modelmail = "intervention";
338  $objecttmp = new Fichinter($db);
339  $trackid = 'int'.$object->id;
340  include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
341 
342  if ($sall)
343  {
344  foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val);
345  print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>';
346  }
347 
348  $moreforfilter = '';
349 
350  $parameters = array();
351  $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
352  if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
353  else $moreforfilter = $hookmanager->resPrint;
354 
355  if (!empty($moreforfilter))
356  {
357  print '<div class="liste_titre liste_titre_bydiv centpercent">';
358  print $moreforfilter;
359  print '</div>';
360  }
361 
362  if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
363 
364  print '<div class="div-table-responsive">';
365  print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
366 
367  print '<tr class="liste_titre_filter">';
368  if (!empty($arrayfields['f.ref']['checked']))
369  {
370  print '<td class="liste_titre">';
371  print '<input type="text" class="flat" name="search_ref" value="'.$search_ref.'" size="8">';
372  print '</td>';
373  }
374  if (!empty($arrayfields['s.nom']['checked']))
375  {
376  print '<td class="liste_titre">';
377  print '<input type="text" class="flat" name="search_company" value="'.$search_company.'" size="10">';
378  print '</td>';
379  }
380  if (!empty($arrayfields['pr.ref']['checked']))
381  {
382  print '<td class="liste_titre">';
383  print '<input type="text" class="flat" name="search_projet_ref" value="'.$search_projet_ref.'" size="8">';
384  print '</td>';
385  }
386  if (!empty($arrayfields['c.ref']['checked']))
387  {
388  print '<td class="liste_titre">';
389  print '<input type="text" class="flat" name="search_contrat_ref" value="'.$search_contrat_ref.'" size="8">';
390  print '</td>';
391  }
392  if (!empty($arrayfields['f.description']['checked']))
393  {
394  print '<td class="liste_titre">';
395  print '<input type="text" class="flat" name="search_desc" value="'.$search_desc.'" size="12">';
396  print '</td>';
397  }
398  // Extra fields
399  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
400 
401  // Fields from hook
402  $parameters = array('arrayfields'=>$arrayfields);
403  $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
404  print $hookmanager->resPrint;
405  if (!empty($arrayfields['f.datec']['checked']))
406  {
407  // Date creation
408  print '<td class="liste_titre">';
409  print '</td>';
410  }
411  if (!empty($arrayfields['f.tms']['checked']))
412  {
413  // Date modification
414  print '<td class="liste_titre">';
415  print '</td>';
416  }
417  if (!empty($arrayfields['f.note_public']['checked']))
418  {
419  // Note public
420  print '<td class="liste_titre">';
421  print '</td>';
422  }
423  if (!empty($arrayfields['f.note_private']['checked']))
424  {
425  // Note private
426  print '<td class="liste_titre">';
427  print '</td>';
428  }
429  // Status
430  if (!empty($arrayfields['f.fk_statut']['checked']))
431  {
432  print '<td class="liste_titre right">';
433  $tmp = $objectstatic->LibStatut(0); // To load $this->statuts_short
434  $liststatus = $objectstatic->statuts_short;
435  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
436  print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 1);
437  print '</td>';
438  }
439  // Fields of detail line
440  if (!empty($arrayfields['fd.description']['checked']))
441  {
442  print '<td class="liste_titre">&nbsp;</td>';
443  }
444  if (!empty($arrayfields['fd.date']['checked']))
445  {
446  print '<td class="liste_titre">&nbsp;</td>';
447  }
448  if (!empty($arrayfields['fd.duree']['checked']))
449  {
450  print '<td class="liste_titre">&nbsp;</td>';
451  }
452  print '<td class="liste_titre maxwidthsearch">';
453  $searchpicto = $form->showFilterButtons();
454  print $searchpicto;
455  print '</td>';
456 
457  print "</tr>\n";
458 
459  print '<tr class="liste_titre">';
460  if (!empty($arrayfields['f.ref']['checked'])) print_liste_field_titre($arrayfields['f.ref']['label'], $_SERVER["PHP_SELF"], "f.ref", "", $param, '', $sortfield, $sortorder);
461  if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder);
462  if (!empty($arrayfields['pr.ref']['checked'])) print_liste_field_titre($arrayfields['pr.ref']['label'], $_SERVER["PHP_SELF"], "pr.ref", "", $param, '', $sortfield, $sortorder);
463  if (!empty($arrayfields['c.ref']['checked'])) print_liste_field_titre($arrayfields['c.ref']['label'], $_SERVER["PHP_SELF"], "c.ref", "", $param, '', $sortfield, $sortorder);
464  if (!empty($arrayfields['f.description']['checked'])) print_liste_field_titre($arrayfields['f.description']['label'], $_SERVER["PHP_SELF"], "f.description", "", $param, '', $sortfield, $sortorder);
465  // Extra fields
466  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
467  // Hook fields
468  $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
469  $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
470  print $hookmanager->resPrint;
471  if (!empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($arrayfields['f.datec']['label'], $_SERVER["PHP_SELF"], "f.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
472  if (!empty($arrayfields['f.tms']['checked'])) print_liste_field_titre($arrayfields['f.tms']['label'], $_SERVER["PHP_SELF"], "f.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
473  if (!empty($arrayfields['f.note_public']['checked'])) print_liste_field_titre($arrayfields['f.note_public']['label'], $_SERVER["PHP_SELF"], "f.note_public", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
474  if (!empty($arrayfields['f.note_private']['checked'])) print_liste_field_titre($arrayfields['f.note_private']['label'], $_SERVER["PHP_SELF"], "f.note_private", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
475  if (!empty($arrayfields['f.fk_statut']['checked'])) print_liste_field_titre($arrayfields['f.fk_statut']['label'], $_SERVER["PHP_SELF"], "f.fk_statut", "", $param, '', $sortfield, $sortorder, 'right ');
476  if (!empty($arrayfields['fd.description']['checked'])) print_liste_field_titre($arrayfields['fd.description']['label'], $_SERVER["PHP_SELF"], '');
477  if (!empty($arrayfields['fd.date']['checked'])) print_liste_field_titre($arrayfields['fd.date']['label'], $_SERVER["PHP_SELF"], "fd.date", "", $param, '', $sortfield, $sortorder, 'center ');
478  if (!empty($arrayfields['fd.duree']['checked'])) print_liste_field_titre($arrayfields['fd.duree']['label'], $_SERVER["PHP_SELF"], "fd.duree", "", $param, '', $sortfield, $sortorder, 'right ');
479  print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
480  print "</tr>\n";
481 
482  $total = 0;
483  $i = 0;
484  $totalarray = array();
485  while ($i < min($num, $limit))
486  {
487  $obj = $db->fetch_object($resql);
488 
489  $objectstatic->id = $obj->rowid;
490  $objectstatic->ref = $obj->ref;
491  $objectstatic->statut = $obj->status;
492  $objectstatic->status = $obj->status;
493 
494  $companystatic->name = $obj->name;
495  $companystatic->id = $obj->socid;
496  $companystatic->client = $obj->client;
497  $companystatic->fournisseur = $obj->fournisseur;
498  $companystatic->email = $obj->email;
499  $companystatic->status = $obj->thirdpartystatus;
500 
501  print '<tr class="oddeven">';
502 
503  if (!empty($arrayfields['f.ref']['checked']))
504  {
505  print "<td>";
506 
507  print '<table class="nobordernopadding"><tr class="nocellnopadd">';
508  // Picto + Ref
509  print '<td class="nobordernopadding nowrap">';
510  print $objectstatic->getNomUrl(1);
511  print '</td>';
512  // Warning
513  $warnornote = '';
514  //if ($obj->fk_statut == 1 && $db->jdate($obj->dfv) < ($now - $conf->fichinter->warning_delay)) $warnornote.=img_warning($langs->trans("Late"));
515  if (!empty($obj->note_private))
516  {
517  $warnornote .= ($warnornote ? ' ' : '');
518  $warnornote .= '<span class="note">';
519  $warnornote .= '<a href="note.php?id='.$obj->rowid.'">'.img_picto($langs->trans("ViewPrivateNote"), 'object_generic').'</a>';
520  $warnornote .= '</span>';
521  }
522  if ($warnornote)
523  {
524  print '<td style="min-width: 20px" class="nobordernopadding nowrap">';
525  print $warnornote;
526  print '</td>';
527  }
528 
529  // Other picto tool
530  print '<td width="16" class="right nobordernopadding hideonsmartphone">';
531  $filename = dol_sanitizeFileName($obj->ref);
532  $filedir = $conf->ficheinter->dir_output.'/'.dol_sanitizeFileName($obj->ref);
533  $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid;
534  print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
535  print '</td></tr></table>';
536 
537  print "</td>\n";
538  if (!$i) $totalarray['nbfield']++;
539  }
540  if (!empty($arrayfields['s.nom']['checked']))
541  {
542  print '<td>';
543  print $companystatic->getNomUrl(1, '', 44);
544  print '</td>';
545  if (!$i) $totalarray['nbfield']++;
546  }
547  if (!empty($arrayfields['pr.ref']['checked']))
548  {
549  print '<td>';
550  $projetstatic->id = $obj->projet_id;
551  $projetstatic->ref = $obj->projet_ref;
552  $projetstatic->title = $obj->projet_title;
553  if ($projetstatic->id > 0) {
554  print $projetstatic->getNomUrl(1, '');
555  }
556  print '</td>';
557  if (!$i) $totalarray['nbfield']++;
558  }
559  if (!empty($arrayfields['c.ref']['checked']))
560  {
561  print '<td>';
562  $contratstatic->id = $obj->contrat_id;
563  $contratstatic->ref = $obj->contrat_ref;
564  $contratstatic->ref_customer = $obj->contrat_ref_customer;
565  $contratstatic->ref_supplier = $obj->contrat_ref_supplier;
566  if ($contratstatic->id > 0) {
567  print $contratstatic->getNomUrl(1, '');
568  print '</td>';
569  }
570  if (!$i) $totalarray['nbfield']++;
571  }
572  if (!empty($arrayfields['f.description']['checked']))
573  {
574  print '<td>'.dol_trunc(dolGetFirstLineOfText($obj->description), 48).'</td>';
575  if (!$i) $totalarray['nbfield']++;
576  }
577 
578  // Extra fields
579  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
580  // Fields from hook
581  $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
582  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
583  print $hookmanager->resPrint;
584  // Date creation
585  if (!empty($arrayfields['f.datec']['checked']))
586  {
587  print '<td class="center">';
588  print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
589  print '</td>';
590  if (!$i) $totalarray['nbfield']++;
591  }
592  // Date modification
593  if (!empty($arrayfields['f.tms']['checked']))
594  {
595  print '<td class="center">';
596  print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
597  print '</td>';
598  if (!$i) $totalarray['nbfield']++;
599  }
600  // Note public
601  if (!empty($arrayfields['f.note_public']['checked']))
602  {
603  print '<td class="center">';
604  print dol_escape_htmltag($obj->note_public);
605  print '</td>';
606  if (!$i) $totalarray['nbfield']++;
607  }
608  // Note private
609  if (!empty($arrayfields['f.note_private']['checked']))
610  {
611  print '<td class="center">';
612  print dol_escape_htmltag($obj->note_private);
613  print '</td>';
614  if (!$i) $totalarray['nbfield']++;
615  }
616  // Status
617  if (!empty($arrayfields['f.fk_statut']['checked']))
618  {
619  print '<td class="right">'.$objectstatic->getLibStatut(5).'</td>';
620  if (!$i) $totalarray['nbfield']++;
621  }
622  // Fields of detail of line
623  if (!empty($arrayfields['fd.description']['checked']))
624  {
625  print '<td>'.dolGetFirstLineOfText($obj->descriptiondetail).'</td>';
626  if (!$i) $totalarray['nbfield']++;
627  }
628  if (!empty($arrayfields['fd.date']['checked']))
629  {
630  print '<td class="center">'.dol_print_date($db->jdate($obj->dp), 'dayhour')."</td>\n";
631  if (!$i) $totalarray['nbfield']++;
632  }
633  if (!empty($arrayfields['fd.duree']['checked']))
634  {
635  print '<td class="right">'.convertSecondToTime($obj->duree, 'allhourmin').'</td>';
636  if (!$i) $totalarray['nbfield']++;
637  if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'fd.duree';
638  $totalarray['val']['fd.duree'] += $obj->duree;
639  }
640  // Action column
641  print '<td class="nowrap center">';
642  if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
643  {
644  $selected = 0;
645  if (in_array($obj->rowid, $arrayofselected)) $selected = 1;
646  print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
647  }
648  print '</td>';
649  if (!$i) $totalarray['nbfield']++;
650 
651  print "</tr>\n";
652 
653  $total += $obj->duree;
654  $i++;
655  }
656 
657  // Show total line
658  include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
659 
660  $db->free($resql);
661 
662  $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
663  $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook
664  print $hookmanager->resPrint;
665 
666  print '</table>'."\n";
667  print '</div>';
668 
669  print "</form>\n";
670 
671  $hidegeneratedfilelistifempty = 1;
672  if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0;
673 
674  // Show list of available documents
675  $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
676  $urlsource .= str_replace('&amp;', '&', $param);
677 
678  $filedir = $diroutputmassaction;
679  $genallowed = $user->rights->ficheinter->lire;
680  $delallowed = $user->rights->ficheinter->creer;
681 
682  print $formfile->showdocuments('massfilesarea_interventions', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
683 } else {
684  dol_print_error($db);
685 }
686 
687 
688 llxFooter();
689 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dolGetButtonTitle($label, $helpText= '', $iconClass= 'fa fa-file', $url= '', $id= '', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
Class to manage interventions.
dol_now($mode= 'auto')
Return date for now.
Class to manage contracts.
llxHeader()
Empty header.
Definition: wrapper.php:45
Class to manage standard extra fields.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
print_barre_liste($titre, $page, $file, $options= '', $sortfield= '', $sortorder= '', $morehtmlcenter= '', $num=-1, $totalnboflines= '', $picto= 'generic', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow= '')
Print a title with navigation controls for pagination.
Class to manage generation of HTML components Only common components must be here.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
Class to manage third parties objects (customers, suppliers, prospects...)
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
Class to manage projects.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it&#39;s its name (generic function)
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.
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_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
Class to offer components to list and upload files.
print $_SERVER["PHP_SELF"]
Edit parameters.
dolGetFirstLineOfText($text, $nboflines=1, $charset= 'UTF-8')
Return first line of text.
dol_sort_array(&$array, $index, $order= 'asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
print
Draft customers invoices.
Definition: index.php:89
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->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)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1232
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
llxFooter()
Empty footer.
Definition: wrapper.php:59
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...