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