dolibarr  9.0.0
list.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2005-2010 Regis Houssin <regis.houssin@inodbox.com>
5  * Copyright (C) 2016-2018 Ferran Marcet <fmarcet@2byte.es>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
27 require '../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
29 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
32 
33 // Load translation files required by the page
34 $langs->loadLangs(array("sendings","deliveries",'companies','bills'));
35 
36 $contextpage= GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'shipmentlist'; // To manage different context of search
37 
38 $socid=GETPOST('socid','int');
39 // Security check
40 $expeditionid = GETPOST('id','int');
41 if ($user->societe_id) $socid=$user->societe_id;
42 $result = restrictedArea($user, 'expedition',$expeditionid,'');
43 
44 $diroutputmassaction=$conf->expedition->dir_output . '/temp/massgeneration/'.$user->id;
45 
46 $search_ref_exp = GETPOST("search_ref_exp", 'alpha');
47 $search_ref_liv = GETPOST('search_ref_liv', 'alpha');
48 $search_ref_customer = GETPOST('search_ref_customer', 'alpha');
49 $search_company = GETPOST("search_company", 'alpha');
50 $search_town=GETPOST('search_town','alpha');
51 $search_zip=GETPOST('search_zip','alpha');
52 $search_state=trim(GETPOST("search_state"));
53 $search_country=GETPOST("search_country",'int');
54 $search_type_thirdparty=GETPOST("search_type_thirdparty",'int');
55 $search_billed=GETPOST("search_billed",'int');
56 $sall = trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml'));
57 $optioncss = GETPOST('optioncss','alpha');
58 
59 $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
60 $sortfield = GETPOST('sortfield','alpha');
61 $sortorder = GETPOST('sortorder','alpha');
62 $page = GETPOST('page','int');
63 if (! $sortfield) $sortfield="e.ref";
64 if (! $sortorder) $sortorder="DESC";
65 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
66 $offset = $limit * $page;
67 $pageprev = $page - 1;
68 $pagenext = $page + 1;
69 
70 $viewstatut=GETPOST('viewstatut');
71 
72 $object = new Expedition($db);
73 
74 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
75 $hookmanager->initHooks(array('shipmentlist'));
76 $extrafields = new ExtraFields($db);
77 
78 // fetch optionals attributes and labels
79 $extralabels = $extrafields->fetch_name_optionals_label('expedition');
80 $search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_');
81 
82 // List of fields to search into when doing a "search in all"
83 $fieldstosearchall = array(
84  'e.ref'=>"Ref",
85  's.nom'=>"ThirdParty",
86  'e.note_public'=>'NotePublic',
87 );
88 if (empty($user->socid)) $fieldstosearchall["e.note_private"]="NotePrivate";
89 
90 $checkedtypetiers=0;
91 $arrayfields=array(
92  'e.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
93  'e.ref_customer'=>array('label'=>$langs->trans("RefCustomer"), 'checked'=>1),
94  's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1),
95  's.town'=>array('label'=>$langs->trans("Town"), 'checked'=>1),
96  's.zip'=>array('label'=>$langs->trans("Zip"), 'checked'=>1),
97  'state.nom'=>array('label'=>$langs->trans("StateShort"), 'checked'=>0),
98  'country.code_iso'=>array('label'=>$langs->trans("Country"), 'checked'=>0),
99  'typent.code'=>array('label'=>$langs->trans("ThirdPartyType"), 'checked'=>$checkedtypetiers),
100  'e.date_delivery'=>array('label'=>$langs->trans("DateDeliveryPlanned"), 'checked'=>1),
101  'e.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
102  'e.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
103  'e.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000),
104  'l.ref'=>array('label'=>$langs->trans("DeliveryRef"), 'checked'=>1, 'enabled'=>(empty($conf->livraison_bon->enabled)?0:1)),
105  'l.date_delivery'=>array('label'=>$langs->trans("DateReceived"), 'checked'=>1, 'enabled'=>(empty($conf->livraison_bon->enabled)?0:1)),
106  'e.billed'=>array('label'=>$langs->trans("Billed"), 'checked'=>1, 'position'=>1000, 'enabled'=>(!empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)))
107 );
108 
109 // Extra fields
110 if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
111 {
112  foreach($extrafields->attribute_label as $key => $val)
113  {
114  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]));
115  }
116 }
117 
118 
119 /*
120  * Actions
121  */
122 
123 if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; }
124 if (! GETPOST('confirmmassaction','alpha')) { $massaction=''; }
125 
126 $parameters=array('socid'=>$socid);
127 $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
128 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
129 
130 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
131 
132 // Purge search criteria
133 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
134 {
135  $search_ref_exp='';
136  $search_ref_liv='';
137  $search_ref_customer='';
138  $search_company='';
139  $search_town='';
140  $search_zip="";
141  $search_state="";
142  $search_type='';
143  $search_country='';
144  $search_type_thirdparty='';
145  $search_billed='';
146  $viewstatut='';
147  $search_array_options=array();
148 }
149 
150 if (empty($reshook))
151 {
152  // Mass actions. Controls on number of lines checked
153  $maxformassaction=1000;
154  $numtoselect = (is_array($toselect)?count($toselect):0);
155  if (! empty($massaction) && $numtoselect < 1)
156  {
157  $error++;
158  setEventMessages($langs->trans("NoLineChecked"), null, "warnings");
159  }
160  if (! $error && $numtoselect > $maxformassaction)
161  {
162  setEventMessages($langs->trans('TooManyRecordForMassAction',$maxformassaction), null, 'errors');
163  $error++;
164  }
165 }
166 
167 
168 
169 
170 /*
171  * View
172  */
173 
174 $form=new Form($db);
175 $companystatic=new Societe($db);
176 $shipment=new Expedition($db);
177 $formcompany=new FormCompany($db);
178 
179 $helpurl='EN:Module_Shipments|FR:Module_Exp&eacute;ditions|ES:M&oacute;dulo_Expediciones';
180 llxHeader('',$langs->trans('ListOfSendings'),$helpurl);
181 
182 $sql = "SELECT e.rowid, e.ref, e.ref_customer, e.date_expedition as date_expedition, e.date_delivery as date_livraison, l.date_delivery as date_reception, e.fk_statut, e.billed,";
183 $sql.= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client, ';
184 $sql.= " typent.code as typent_code,";
185 $sql.= " state.code_departement as state_code, state.nom as state_name,";
186 $sql.= ' e.date_creation as date_creation, e.tms as date_update';
187 // Add fields from extrafields
188 foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : '');
189 // Add fields from hooks
190 $parameters=array();
191 $reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook
192 $sql.=$hookmanager->resPrint;
193 $sql.= " FROM ".MAIN_DB_PREFIX."expedition as e";
194 if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."expedition_extrafields as ef on (e.rowid = ef.fk_object)";
195 $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc";
196 $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)";
197 $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)";
198 $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)";
199 $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as ee ON e.rowid = ee.fk_source AND ee.sourcetype = 'shipping' AND ee.targettype = 'delivery'";
200 $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."livraison as l ON l.rowid = ee.fk_target";
201 if (!$user->rights->societe->client->voir && !$socid) // Internal user with no permission to see all
202 {
203  $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
204 }
205 $sql.= " WHERE e.entity IN (".getEntity('expedition').")";
206 if (!$user->rights->societe->client->voir && !$socid) // Internal user with no permission to see all
207 {
208  $sql.= " AND e.fk_soc = sc.fk_soc";
209  $sql.= " AND sc.fk_user = " .$user->id;
210 }
211 if ($socid)
212 {
213  $sql.= " AND e.fk_soc = ".$socid;
214 }
215 if ($viewstatut <> '' && $viewstatut >= 0) {
216  $sql.= " AND e.fk_statut = ".$viewstatut;
217 }
218 if ($search_ref_customer != '') $sql.=natural_search('e.ref_customer', $search_ref_customer);
219 if ($search_billed != '' && $search_billed >= 0) $sql.=' AND e.billed = '.$search_billed;
220 if ($search_town) $sql.= natural_search('s.town', $search_town);
221 if ($search_zip) $sql.= natural_search("s.zip",$search_zip);
222 if ($search_state) $sql.= natural_search("state.nom",$search_state);
223 if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')';
224 if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')';
225 if ($search_ref_exp) $sql .= natural_search('e.ref', $search_ref_exp);
226 if ($search_ref_liv) $sql .= natural_search('l.ref', $search_ref_liv);
227 if ($search_company) $sql .= natural_search('s.nom', $search_company);
228 if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall);
229 
230 // Add where from extra fields
231 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
232 
233 // Add where from hooks
234 $parameters=array();
235 $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook
236 $sql.=$hookmanager->resPrint;
237 
238 $sql.= $db->order($sortfield,$sortorder);
239 
240 $nbtotalofrecords = '';
241 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
242 {
243  $result = $db->query($sql);
244  $nbtotalofrecords = $db->num_rows($result);
245  if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
246  {
247  $page = 0;
248  $offset = 0;
249  }
250 }
251 
252 $sql.= $db->plimit($limit + 1,$offset);
253 
254 //print $sql;
255 $resql=$db->query($sql);
256 if ($resql)
257 {
258  $num = $db->num_rows($resql);
259 
260  $expedition = new Expedition($db);
261 
262  $param='';
263  if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
264  if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
265  if ($sall) $param.= "&amp;sall=".urlencode($sall);
266  if ($search_ref_exp) $param.= "&amp;search_ref_exp=".urlencode($search_ref_exp);
267  if ($search_ref_liv) $param.= "&amp;search_ref_liv=".urlencode($search_ref_liv);
268  if ($search_ref_customer) $param.= "&amp;search_ref_customer=".urlencode($search_ref_customer);
269  if ($search_company) $param.= "&amp;search_company=".urlencode($search_company);
270  if ($search_town) $param.= '&search_town='.urlencode($search_town);
271  if ($search_zip) $param.= '&search_zip='.urlencode($search_zip);
272  if ($viewstatut != '') $param.= '&viewstatut='.urlencode($viewstatut);
273  if ($optioncss != '') $param.='&amp;optioncss='.urlencode($optioncss);
274  // Add $param from extra fields
275  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
276 
277  //$massactionbutton=$form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge")));
278 
279  $newcardbutton='';
280  if ($user->rights->expedition->creer)
281  {
282  $newcardbutton='<a class="butActionNew" href="'.DOL_URL_ROOT.'/expedition/card.php?action=create2"><span class="valignmiddle">'.$langs->trans('NewSending').'</span>';
283  $newcardbutton.= '<span class="fa fa-plus-circle valignmiddle"></span>';
284  $newcardbutton.= '</a>';
285  }
286 
287  $i = 0;
288  print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'."\n";
289  if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
290  print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
291  print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
292  print '<input type="hidden" name="action" value="list">';
293  print '<input type="hidden" name="page" value="'.$page.'">';
294  print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
295  print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
296 
297  print_barre_liste($langs->trans('ListOfSendings'), $page, $_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num, $nbtotalofrecords, '', 0, $newcardbutton, '', $limit);
298 
299  if ($sall)
300  {
301  foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
302  print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall).'</div>';
303  }
304 
305  $moreforfilter='';
306  if (! empty($moreforfilter))
307  {
308  print '<div class="liste_titre liste_titre_bydiv centpercent">';
309  print $moreforfilter;
310  $parameters=array('type'=>$type);
311  $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook
312  print $hookmanager->resPrint;
313  print '</div>';
314  }
315 
316  $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
317  $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
318 
319  print '<div class="div-table-responsive">';
320  print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
321 
322  // Lignes des champs de filtre
323  print '<tr class="liste_titre_filter">';
324  // Ref
325  if (! empty($arrayfields['e.ref']['checked']))
326  {
327  print '<td class="liste_titre">';
328  print '<input class="flat" size="6" type="text" name="search_ref_exp" value="'.$search_ref_exp.'">';
329  print '</td>';
330  }
331  // Ref customer
332  if (! empty($arrayfields['e.ref_customer']['checked']))
333  {
334  print '<td class="liste_titre">';
335  print '<input class="flat" size="6" type="text" name="search_ref_customer" value="'.$search_ref_customer.'">';
336  print '</td>';
337  }
338  // Thirdparty
339  if (! empty($arrayfields['s.nom']['checked']))
340  {
341  print '<td class="liste_titre" align="left">';
342  print '<input class="flat" type="text" size="8" name="search_company" value="'.dol_escape_htmltag($search_company).'">';
343  print '</td>';
344  }
345  // Town
346  if (! empty($arrayfields['s.town']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_town" value="'.$search_town.'"></td>';
347  // Zip
348  if (! empty($arrayfields['s.zip']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_zip" value="'.$search_zip.'"></td>';
349  // State
350  if (! empty($arrayfields['state.nom']['checked']))
351  {
352  print '<td class="liste_titre">';
353  print '<input class="flat" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
354  print '</td>';
355  }
356  // Country
357  if (! empty($arrayfields['country.code_iso']['checked']))
358  {
359  print '<td class="liste_titre" align="center">';
360  print $form->select_country($search_country,'search_country','',0,'maxwidth100');
361  print '</td>';
362  }
363  // Company type
364  if (! empty($arrayfields['typent.code']['checked']))
365  {
366  print '<td class="liste_titre maxwidthonsmartphone" align="center">';
367  print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT));
368  print '</td>';
369  }
370  // Date delivery planned
371  if (! empty($arrayfields['e.date_delivery']['checked']))
372  {
373  print '<td class="liste_titre">&nbsp;</td>';
374  }
375  if (! empty($arrayfields['l.ref']['checked']))
376  {
377  // Delivery ref
378  print '<td class="liste_titre">';
379  print '<input class="flat" size="10" type="text" name="search_ref_liv" value="'.$search_ref_liv.'"';
380  print '</td>';
381  }
382  if (! empty($arrayfields['l.date_delivery']['checked']))
383  {
384  // Date received
385  print '<td class="liste_titre">&nbsp;</td>';
386  }
387  // Extra fields
388  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
389 
390  // Fields from hook
391  $parameters=array('arrayfields'=>$arrayfields);
392  $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook
393  print $hookmanager->resPrint;
394  // Date creation
395  if (! empty($arrayfields['e.datec']['checked']))
396  {
397  print '<td class="liste_titre">';
398  print '</td>';
399  }
400  // Date modification
401  if (! empty($arrayfields['e.tms']['checked']))
402  {
403  print '<td class="liste_titre">';
404  print '</td>';
405  }
406  // Status
407  if (! empty($arrayfields['e.fk_statut']['checked']))
408  {
409  print '<td class="liste_titre maxwidthonsmartphone" align="right">';
410  print $form->selectarray('viewstatut', array('0'=>$langs->trans('StatusSendingDraftShort'),'1'=>$langs->trans('StatusSendingValidatedShort'),'2'=>$langs->trans('StatusSendingProcessedShort')),$viewstatut,1);
411  print '</td>';
412  }
413  // Status billed
414  if (! empty($arrayfields['e.billed']['checked']))
415  {
416  print '<td class="liste_titre maxwidthonsmartphone" align="center">';
417  print $form->selectyesno('search_billed', $search_billed, 1, 0, 1);
418  print '</td>';
419  }
420  // Action column
421  print '<td class="liste_titre" align="middle">';
422  $searchpicto=$form->showFilterAndCheckAddButtons(0);
423  print $searchpicto;
424  print '</td>';
425  print "</tr>\n";
426 
427  print '<tr class="liste_titre">';
428  if (! empty($arrayfields['e.ref']['checked'])) print_liste_field_titre($arrayfields['e.ref']['label'], $_SERVER["PHP_SELF"],"e.ref","",$param,'',$sortfield,$sortorder);
429  if (! empty($arrayfields['e.ref_customer']['checked'])) print_liste_field_titre($arrayfields['e.ref_customer']['label'], $_SERVER["PHP_SELF"],"e.ref_customer","",$param,'',$sortfield,$sortorder);
430  if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"],"s.nom", "", $param,'align="left"',$sortfield,$sortorder);
431  if (! empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'],$_SERVER["PHP_SELF"],'s.town','',$param,'',$sortfield,$sortorder);
432  if (! empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'],$_SERVER["PHP_SELF"],'s.zip','',$param,'',$sortfield,$sortorder);
433  if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'],$_SERVER["PHP_SELF"],"state.nom","",$param,'',$sortfield,$sortorder);
434  if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'],$_SERVER["PHP_SELF"],"country.code_iso","",$param,'align="center"',$sortfield,$sortorder);
435  if (! empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'],$_SERVER["PHP_SELF"],"typent.code","",$param,'align="center"',$sortfield,$sortorder);
436  if (! empty($arrayfields['e.date_delivery']['checked'])) print_liste_field_titre($arrayfields['e.date_delivery']['label'], $_SERVER["PHP_SELF"],"e.date_delivery","",$param, 'align="center"',$sortfield,$sortorder);
437  if (! empty($arrayfields['l.ref']['checked'])) print_liste_field_titre($arrayfields['l.ref']['label'], $_SERVER["PHP_SELF"],"l.ref","",$param, '',$sortfield,$sortorder);
438  if (! empty($arrayfields['l.date_delivery']['checked'])) print_liste_field_titre($arrayfields['l.date_delivery']['label'], $_SERVER["PHP_SELF"],"l.date_delivery","",$param, 'align="center"',$sortfield,$sortorder);
439  // Extra fields
440  if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
441  {
442  foreach($extrafields->attribute_label as $key => $val)
443  {
444  if (! empty($arrayfields["ef.".$key]['checked']))
445  {
446  $align=$extrafields->getAlignFlag($key);
447  $sortonfield = "ef.".$key;
448  if (! empty($extrafields->attribute_computed[$key])) $sortonfield='';
449  print_liste_field_titre($extralabels[$key],$_SERVER["PHP_SELF"],$sortonfield,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder);
450  }
451  }
452  }
453  // Hook fields
454  $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder);
455  $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook
456  print $hookmanager->resPrint;
457  if (! empty($arrayfields['e.datec']['checked'])) print_liste_field_titre($arrayfields['e.datec']['label'],$_SERVER["PHP_SELF"],"e.date_creation","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
458  if (! empty($arrayfields['e.tms']['checked'])) print_liste_field_titre($arrayfields['e.tms']['label'],$_SERVER["PHP_SELF"],"e.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
459  if (! empty($arrayfields['e.fk_statut']['checked'])) print_liste_field_titre($arrayfields['e.fk_statut']['label'],$_SERVER["PHP_SELF"],"e.fk_statut","",$param,'align="right"',$sortfield,$sortorder);
460  if (! empty($arrayfields['e.billed']['checked'])) print_liste_field_titre($arrayfields['e.billed']['label'],$_SERVER["PHP_SELF"],"e.billed","",$param,'align="center"',$sortfield,$sortorder);
461  print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ');
462  print "</tr>\n";
463 
464  $i=0;
465  $totalarray=array();
466  while ($i < min($num,$limit))
467  {
468  $obj = $db->fetch_object($resql);
469 
470  $shipment->id=$obj->rowid;
471  $shipment->ref=$obj->ref;
472 
473  $companystatic->id=$obj->socid;
474  $companystatic->ref=$obj->name;
475  $companystatic->name=$obj->name;
476 
477 
478  print '<tr class="oddeven">';
479 
480  // Ref
481  if (! empty($arrayfields['e.ref']['checked']))
482  {
483  print "<td>";
484  print $shipment->getNomUrl(1);
485  print "</td>\n";
486  if (! $i) $totalarray['nbfield']++;
487  }
488 
489  // Ref customer
490  if (! empty($arrayfields['e.ref_customer']['checked']))
491  {
492  print "<td>";
493  print $obj->ref_customer;
494  print "</td>\n";
495  if (! $i) $totalarray['nbfield']++;
496  }
497 
498  // Third party
499  if (! empty($arrayfields['s.nom']['checked']))
500  {
501  print '<td>';
502  print $companystatic->getNomUrl(1);
503  print '</td>';
504  if (! $i) $totalarray['nbfield']++;
505  }
506  // Town
507  if (! empty($arrayfields['s.town']['checked']))
508  {
509  print '<td class="nocellnopadd">';
510  print $obj->town;
511  print '</td>';
512  if (! $i) $totalarray['nbfield']++;
513  }
514  // Zip
515  if (! empty($arrayfields['s.zip']['checked']))
516  {
517  print '<td class="nocellnopadd">';
518  print $obj->zip;
519  print '</td>';
520  if (! $i) $totalarray['nbfield']++;
521  }
522  // State
523  if (! empty($arrayfields['state.nom']['checked']))
524  {
525  print "<td>".$obj->state_name."</td>\n";
526  if (! $i) $totalarray['nbfield']++;
527  }
528  // Country
529  if (! empty($arrayfields['country.code_iso']['checked']))
530  {
531  print '<td align="center">';
532  $tmparray=getCountry($obj->fk_pays,'all');
533  print $tmparray['label'];
534  print '</td>';
535  if (! $i) $totalarray['nbfield']++;
536  }
537  // Type ent
538  if (! empty($arrayfields['typent.code']['checked']))
539  {
540  print '<td align="center">';
541  if (count($typenArray)==0) $typenArray = $formcompany->typent_array(1);
542  print $typenArray[$obj->typent_code];
543  print '</td>';
544  if (! $i) $totalarray['nbfield']++;
545  }
546 
547  // Date delivery planed
548  if (! empty($arrayfields['e.date_delivery']['checked']))
549  {
550  print '<td align="center">';
551  print dol_print_date($db->jdate($obj->date_livraison),"day");
552  /*$now = time();
553  if ( ($now - $db->jdate($obj->date_expedition)) > $conf->warnings->lim && $obj->statutid == 1 )
554  {
555  }*/
556  print "</td>\n";
557  }
558 
559  if (! empty($arrayfields['l.ref']['checked']) || ! empty($arrayfields['l.date_delivery']['checked']))
560  {
561  $shipment->fetchObjectLinked($shipment->id,$shipment->element);
562  $receiving='';
563  if (is_array($shipment->linkedObjects['delivery']) && count($shipment->linkedObjects['delivery']) > 0) $receiving=reset($shipment->linkedObjects['delivery']);
564 
565  if (! empty($arrayfields['l.ref']['checked']))
566  {
567  // Ref
568  print '<td>';
569  print !empty($receiving) ? $receiving->getNomUrl($db) : '';
570  print '</td>';
571  }
572 
573  if (! empty($arrayfields['l.date_delivery']['checked']))
574  {
575  // Date received
576  print '<td align="center">';
577  print dol_print_date($db->jdate($obj->date_reception),"day");
578  print '</td>'."\n";
579  }
580  }
581 
582  // Extra fields
583  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
584  // Fields from hook
585  $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj);
586  $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook
587  print $hookmanager->resPrint;
588  // Date creation
589  if (! empty($arrayfields['e.datec']['checked']))
590  {
591  print '<td align="center" class="nowrap">';
592  print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
593  print '</td>';
594  if (! $i) $totalarray['nbfield']++;
595  }
596  // Date modification
597  if (! empty($arrayfields['e.tms']['checked']))
598  {
599  print '<td align="center" class="nowrap">';
600  print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
601  print '</td>';
602  if (! $i) $totalarray['nbfield']++;
603  }
604  // Status
605  if (! empty($arrayfields['e.fk_statut']['checked']))
606  {
607  print '<td align="right" class="nowrap">'.$shipment->LibStatut($obj->fk_statut,5).'</td>';
608  if (! $i) $totalarray['nbfield']++;
609  }
610  // Billed
611  if (! empty($arrayfields['e.billed']['checked']))
612  {
613  print '<td align="center">'.yn($obj->billed).'</td>';
614  if (! $i) $totalarray['nbfield']++;
615  }
616 
617  // Action column
618  print '<td></td>';
619  if (! $i) $totalarray['nbfield']++;
620 
621  print "</tr>\n";
622 
623  $i++;
624  }
625 
626  print "</table>";
627  print "</div>";
628  print '</form>';
629  $db->free($resql);
630 }
631 else
632 {
633  dol_print_error($db);
634 }
635 
636 // End of page
637 llxFooter();
638 $db->close();
llxFooter()
Empty footer.
Definition: wrapper.php:56
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.
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
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
getCountry($searchkey, $withcode='', $dbtouse=0, $outputlangs='', $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
Class to build HTML component for third parties management Only common components are here...
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...)
Class to manage shipments.
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...
dol_print_date($time, $format='', $tzoutput='tzserver', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
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.