dolibarr  16.0.5
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-2021 Ferran Marcet <fmarcet@2byte.es>
6  * Copyright (C) 2019 Nicolas ZABOURI <info@inovea-conseil.com>
7  * Copyright (C) 2020 Thibault FOUCART <support@ptibogxiv.net>
8  * Copyright (C) 2023 Christophe Battarel <christophe@altairis.fr>
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.'/expedition/class/expedition.class.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
33 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
34 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
35 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
36 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
37 require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
38 
39 // Load translation files required by the page
40 $langs->loadLangs(array("sendings", "deliveries", 'companies', 'bills', 'products'));
41 
42 $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'shipmentlist'; // To manage different context of search
43 
44 $socid = GETPOST('socid', 'int');
45 
46 $action = GETPOST('action', 'alpha');
47 $massaction = GETPOST('massaction', 'alpha');
48 $show_files = GETPOST('show_files', 'int');
49 $toselect = GETPOST('toselect', 'array');
50 
51 // Security check
52 $expeditionid = GETPOST('id', 'int');
53 if ($user->socid) {
54  $socid = $user->socid;
55 }
56 $result = restrictedArea($user, 'expedition', $expeditionid, '');
57 
58 $search_ref_exp = GETPOST("search_ref_exp", 'alpha');
59 $search_ref_liv = GETPOST('search_ref_liv', 'alpha');
60 $search_ref_customer = GETPOST('search_ref_customer', 'alpha');
61 $search_company = GETPOST("search_company", 'alpha');
62 $search_shipping_method_id = GETPOST('search_shipping_method_id');
63 $search_tracking = GETPOST("search_tracking", 'alpha');
64 $search_town = GETPOST('search_town', 'alpha');
65 $search_zip = GETPOST('search_zip', 'alpha');
66 $search_state = GETPOST("search_state");
67 $search_country = GETPOST("search_country", 'int');
68 $search_type_thirdparty = GETPOST("search_type_thirdparty", 'int');
69 $search_billed = GETPOST("search_billed", 'int');
70 $search_datedelivery_start = dol_mktime(0, 0, 0, GETPOST('search_datedelivery_startmonth', 'int'), GETPOST('search_datedelivery_startday', 'int'), GETPOST('search_datedelivery_startyear', 'int'));
71 $search_datedelivery_end = dol_mktime(23, 59, 59, GETPOST('search_datedelivery_endmonth', 'int'), GETPOST('search_datedelivery_endday', 'int'), GETPOST('search_datedelivery_endyear', 'int'));
72 $search_datereceipt_start = dol_mktime(0, 0, 0, GETPOST('search_datereceipt_startmonth', 'int'), GETPOST('search_datereceipt_startday', 'int'), GETPOST('search_datereceipt_startyear', 'int'));
73 $search_datereceipt_end = dol_mktime(23, 59, 59, GETPOST('search_datereceipt_endmonth', 'int'), GETPOST('search_datereceipt_endday', 'int'), GETPOST('search_datereceipt_endyear', 'int'));
74 $sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
75 $search_user = GETPOST('search_user', 'int');
76 $search_sale = GETPOST('search_sale', 'int');
77 $search_categ_cus = GETPOST("search_categ_cus", 'int');
78 $search_product_category = GETPOST('search_product_category', 'int');
79 $optioncss = GETPOST('optioncss', 'alpha');
80 
81 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
82 $sortfield = GETPOST('sortfield', 'aZ09comma');
83 $sortorder = GETPOST('sortorder', 'aZ09comma');
84 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
85 if (!$sortfield) {
86  $sortfield = "e.ref";
87 }
88 if (!$sortorder) {
89  $sortorder = "DESC";
90 }
91 if (empty($page) || $page == -1 || (empty($toselect) && $massaction === '0')) {
92  $page = 0;
93 } // If $page is not defined, or '' or -1
94 $offset = $limit * $page;
95 $pageprev = $page - 1;
96 $pagenext = $page + 1;
97 
98 $search_status = GETPOST('search_status', 'intcomma');
99 
100 $diroutputmassaction = $conf->expedition->dir_output.'/sending/temp/massgeneration/'.$user->id;
101 
102 $object = new Expedition($db);
103 $form = new Form($db);
104 
105 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
106 $hookmanager->initHooks(array('shipmentlist'));
107 $extrafields = new ExtraFields($db);
108 
109 // fetch optionals attributes and labels
110 $extrafields->fetch_name_optionals_label($object->table_element);
111 
112 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
113 
114 // List of fields to search into when doing a "search in all"
115 $fieldstosearchall = array(
116  'e.ref'=>"Ref",
117  's.nom'=>"ThirdParty",
118  'e.note_public'=>'NotePublic',
119  //'e.fk_shipping_method'=>'SendingMethod', // TODO fix this, does not work
120  'e.tracking_number'=>"TrackingNumber",
121 );
122 if (empty($user->socid)) {
123  $fieldstosearchall["e.note_private"] = "NotePrivate";
124 }
125 
126 $checkedtypetiers = 0;
127 $arrayfields = array(
128  'e.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1, 'position'=>1),
129  'e.ref_customer'=>array('label'=>$langs->trans("RefCustomer"), 'checked'=>1, 'position'=>2),
130  's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1, 'position'=>3),
131  's.town'=>array('label'=>$langs->trans("Town"), 'checked'=>1, 'position'=>4),
132  's.zip'=>array('label'=>$langs->trans("Zip"), 'checked'=>1, 'position'=>5),
133  'state.nom'=>array('label'=>$langs->trans("StateShort"), 'checked'=>0, 'position'=>6),
134  'country.code_iso'=>array('label'=>$langs->trans("Country"), 'checked'=>0, 'position'=>7),
135  'typent.code'=>array('label'=>$langs->trans("ThirdPartyType"), 'checked'=>$checkedtypetiers, 'position'=>8),
136  'e.date_delivery'=>array('label'=>$langs->trans("DateDeliveryPlanned"), 'checked'=>1, 'position'=>9),
137  'e.fk_shipping_method'=>array('label'=>$langs->trans('SendingMethod'), 'checked'=>1, 'position'=>10),
138  'e.tracking_number'=>array('label'=>$langs->trans("TrackingNumber"), 'checked'=>1, 'position'=>11),
139  'e.weight'=>array('label'=>$langs->trans("Weight"), 'checked'=>0, 'position'=>12),
140  'e.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
141  'e.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
142  'e.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000),
143  'l.ref'=>array('label'=>$langs->trans("DeliveryRef"), 'checked'=>1, 'enabled'=>(empty($conf->delivery_note->enabled) ? 0 : 1)),
144  'l.date_delivery'=>array('label'=>$langs->trans("DateReceived"), 'checked'=>1, 'enabled'=>(empty($conf->delivery_note->enabled) ? 0 : 1)),
145  'e.billed'=>array('label'=>$langs->trans("Billed"), 'checked'=>1, 'position'=>1000, 'enabled'=>(!empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)))
146 );
147 
148 // Extra fields
149 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
150 
151 $object->fields = dol_sort_array($object->fields, 'position');
152 $arrayfields = dol_sort_array($arrayfields, 'position');
153 
154 
155 /*
156  * Actions
157  */
158 $error = 0;
159 
160 if (GETPOST('cancel', 'alpha')) {
161  $action = 'list'; $massaction = '';
162 }
163 if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
164  $massaction = '';
165 }
166 
167 $parameters = array('socid'=>$socid);
168 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
169 if ($reshook < 0) {
170  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
171 }
172 
173 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
174 
175 // Purge search criteria
176 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
177  $search_categ = '';
178  $search_user = '';
179  $search_sale = '';
180  $search_product_category = '';
181  $search_ref_exp = '';
182  $search_ref_liv = '';
183  $search_ref_customer = '';
184  $search_company = '';
185  $search_town = '';
186  $search_zip = "";
187  $search_state = "";
188  $search_type = '';
189  $search_country = '';
190  $search_tracking = '';
191  $search_shipping_method_id = '';
192  $search_type_thirdparty = '';
193  $search_billed = '';
194  $search_datedelivery_start = '';
195  $search_datedelivery_end = '';
196  $search_datereceipt_start = '';
197  $search_datereceipt_end = '';
198  $search_status = '';
199  $toselect = array();
200  $search_array_options = array();
201  $search_categ_cus = 0;
202 }
203 
204 if (empty($reshook)) {
205  $objectclass = 'Expedition';
206  $objectlabel = 'Sendings';
207  $permissiontoread = $user->rights->expedition->lire;
208  $permissiontoadd = $user->rights->expedition->creer;
209  $permissiontodelete = $user->rights->expedition->supprimer;
210  $uploaddir = $conf->expedition->dir_output.'/sending';
211  include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
212 }
213 
214 // If massaction is close
215 if ($massaction == 'classifyclose') {
216  $error=0;
217  $selectids = GETPOST('toselect', 'array');
218  foreach ($selectids as $selectid) {
219  // $object->fetch($selectid);
220  $object->fetch($selectid);
221  $result = $object->setClosed();
222  }
223 
224  $massaction = $action = 'classifyclose';
225 
226  if ($result < 0) {
227  $error++;
228  }
229 
230 
231  if (!$error) {
232  $db->commit();
233 
234  setEventMessage($langs->trans("Close Done"));
235  header('Location: '.$_SERVER["PHP_SELF"]);
236  exit;
237  } else {
238  $db->rollback();
239  exit;
240  }
241 }
242 
243 /*
244  * View
245  */
246 
247 $now = dol_now();
248 
249 $form = new Form($db);
250 $formother = new FormOther($db);
251 $formfile = new FormFile($db);
252 $companystatic = new Societe($db);
253 $formcompany = new FormCompany($db);
254 $shipment = new Expedition($db);
255 
256 $helpurl = 'EN:Module_Shipments|FR:Module_Exp&eacute;ditions|ES:M&oacute;dulo_Expediciones';
257 llxHeader('', $langs->trans('ListOfSendings'), $helpurl);
258 
259 $sql = 'SELECT';
260 if ($sall || $search_product_category > 0 || $search_user > 0) {
261  $sql = 'SELECT DISTINCT';
262 }
263 $sql .= " e.rowid, e.ref, e.ref_customer, e.date_expedition as date_expedition, e.weight, e.weight_units, e.date_delivery as delivery_date, e.fk_statut, e.billed, e.tracking_number, e.fk_shipping_method,";
264 $sql .= " l.date_delivery as date_reception,";
265 $sql .= " s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client, ";
266 $sql .= " typent.code as typent_code,";
267 $sql .= " state.code_departement as state_code, state.nom as state_name,";
268 $sql .= " e.date_creation as date_creation, e.tms as date_update,";
269 $sql .= " u.login";
270 if (($search_categ_cus > 0) || ($search_categ_cus == -2)) {
271  $sql .= ", cc.fk_categorie, cc.fk_soc";
272 }
273 // Add fields from extrafields
274 if (!empty($extrafields->attributes[$object->table_element]['label'])) {
275  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
276  $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
277  }
278 }
279 // Add fields from hooks
280 $parameters = array();
281 $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
282 $sql .= $hookmanager->resPrint;
283 $sql .= " FROM ".MAIN_DB_PREFIX."expedition as e";
284 if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
285  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (e.rowid = ef.fk_object)";
286 }
287 if ($sall || $search_product_category > 0) {
288  $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'expeditiondet as ed ON e.rowid=ed.fk_expedition';
289  $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commandedet as pd ON pd.rowid=ed.fk_origin_line';
290 }
291 if ($search_product_category > 0) {
292  $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product';
293 }
294 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc";
295 if (($search_categ_cus > 0) || ($search_categ_cus == -2)) {
296  $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cc ON s.rowid = cc.fk_soc"; // We'll need this table joined to the select in order to filter by categ
297 }
298 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)";
299 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)";
300 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)";
301 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as ee ON e.rowid = ee.fk_source AND ee.sourcetype = 'shipping' AND ee.targettype = 'delivery'";
302 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."delivery as l ON l.rowid = ee.fk_target";
303 $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON e.fk_user_author = u.rowid';
304 if ($search_user > 0) { // Get link to order to get the order id in eesource.fk_source
305  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as eesource ON eesource.fk_target = e.rowid AND eesource.targettype = 'shipping' AND eesource.sourcetype = 'commande'";
306 }
307 // We'll need this table joined to the select in order to filter by sale
308 if ($search_sale > 0 || (empty($user->rights->societe->client->voir) && !$socid)) {
309  $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
310 }
311 if ($search_user > 0) {
312  $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec";
313  $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as tc";
314 }
315 
316 // Add table from hooks
317 $parameters = array();
318 $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
319 $sql .= $hookmanager->resPrint;
320 
321 $sql .= " WHERE e.entity IN (".getEntity('expedition').")";
322 if ($search_product_category > 0) {
323  $sql .= " AND cp.fk_categorie = ".((int) $search_product_category);
324 }
325 if ($socid > 0) {
326  $sql .= " AND s.rowid = ".((int) $socid);
327 }
328 if (empty($user->rights->societe->client->voir) && !$socid) { // Internal user with no permission to see all
329  $sql .= " AND e.fk_soc = sc.fk_soc";
330  $sql .= " AND sc.fk_user = ".((int) $user->id);
331 }
332 if ($socid) {
333  $sql .= " AND e.fk_soc = ".((int) $socid);
334 }
335 if ($search_status <> '' && $search_status >= 0) {
336  $sql .= " AND e.fk_statut = ".((int) $search_status);
337 }
338 if ($search_ref_customer != '') {
339  $sql .= natural_search('e.ref_customer', $search_ref_customer);
340 }
341 if ($search_billed != '' && $search_billed >= 0) {
342  $sql .= ' AND e.billed = '.((int) $search_billed);
343 }
344 if ($search_town) {
345  $sql .= natural_search('s.town', $search_town);
346 }
347 if ($search_zip) {
348  $sql .= natural_search("s.zip", $search_zip);
349 }
350 if ($search_state) {
351  $sql .= natural_search("state.nom", $search_state);
352 }
353 if ($search_country) {
354  $sql .= " AND s.fk_pays IN (".$db->sanitize($search_country).')';
355 }
356 if ($search_shipping_method_id > 0) {
357  $sql .= " AND e.fk_shipping_method = ".((int) $search_shipping_method_id);
358 }
359 if ($search_tracking) {
360  $sql .= natural_search("e.tracking_number", $search_tracking);
361 }
362 if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) {
363  $sql .= " AND s.fk_typent IN (".$db->sanitize($search_type_thirdparty).')';
364 }
365 if ($search_sale > 0) {
366  $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $search_sale);
367 }
368 if ($search_user > 0) {
369  // The contact on a shipment is also the contact of the order.
370  $sql .= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='commande' AND tc.source='internal' AND ec.element_id = eesource.fk_source AND ec.fk_socpeople = ".((int) $search_user);
371 }
372 if ($search_ref_exp) {
373  $sql .= natural_search('e.ref', $search_ref_exp);
374 }
375 if ($search_ref_liv) {
376  $sql .= natural_search('l.ref', $search_ref_liv);
377 }
378 if ($search_company) {
379  $sql .= natural_search('s.nom', $search_company);
380 }
381 if ($search_datedelivery_start) {
382  $sql .= " AND e.date_delivery >= '".$db->idate($search_datedelivery_start)."'";
383 }
384 if ($search_datedelivery_end) {
385  $sql .= " AND e.date_delivery <= '".$db->idate($search_datedelivery_end)."'";
386 }
387 if ($search_datereceipt_start) {
388  $sql .= " AND l.date_delivery >= '".$db->idate($search_datereceipt_start)."'";
389 }
390 if ($search_datereceipt_end) {
391  $sql .= " AND l.date_delivery <= '".$db->idate($search_datereceipt_end)."'";
392 }
393 if ($sall) {
394  $sql .= natural_search(array_keys($fieldstosearchall), $sall);
395 }
396 if ($search_categ_cus > 0) {
397  $sql .= " AND cc.fk_categorie = ".((int) $search_categ_cus);
398 }
399 if ($search_categ_cus == -2) {
400  $sql .= " AND cc.fk_categorie IS NULL";
401 }
402 
403 // Add where from extra fields
404 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
405 
406 // Add where from hooks
407 $parameters = array();
408 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
409 $sql .= $hookmanager->resPrint;
410 
411 // Add HAVING from hooks
412 $parameters = array();
413 $reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object); // Note that $action and $object may have been modified by hook
414 $sql .= empty($hookmanager->resPrint) ? "" : " HAVING 1=1 ".$hookmanager->resPrint;
415 
416 $sql .= $db->order($sortfield, $sortorder);
417 
418 $nbtotalofrecords = '';
419 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
420  $result = $db->query($sql);
421  $nbtotalofrecords = $db->num_rows($result);
422  if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
423  $page = 0;
424  $offset = 0;
425  }
426 }
427 
428 $sql .= $db->plimit($limit + 1, $offset);
429 
430 //print $sql;
431 $resql = $db->query($sql);
432 if (!$resql) {
433  dol_print_error($db);
434  exit;
435 }
436 
437 $num = $db->num_rows($resql);
438 
439 $arrayofselected = is_array($toselect) ? $toselect : array();
440 
441 $expedition = new Expedition($db);
442 
443 $param = '';
444 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
445  $param .= '&contextpage='.urlencode($contextpage);
446 }
447 if ($limit > 0 && $limit != $conf->liste_limit) {
448  $param .= '&limit='.urlencode($limit);
449 }
450 if ($sall) {
451  $param .= "&sall=".urlencode($sall);
452 }
453 if ($search_ref_exp) {
454  $param .= "&search_ref_exp=".urlencode($search_ref_exp);
455 }
456 if ($search_ref_liv) {
457  $param .= "&search_ref_liv=".urlencode($search_ref_liv);
458 }
459 if ($search_ref_customer) {
460  $param .= "&search_ref_customer=".urlencode($search_ref_customer);
461 }
462 if ($search_user > 0) {
463  $param .= '&search_user='.urlencode($search_user);
464 }
465 if ($search_sale > 0) {
466  $param .= '&search_sale='.urlencode($search_sale);
467 }
468 if ($search_company) {
469  $param .= "&search_company=".urlencode($search_company);
470 }
471 if ($search_shipping_method_id) {
472  $param .= "&amp;search_shipping_method_id=".urlencode($search_shipping_method_id);
473 }
474 if ($search_tracking) {
475  $param .= "&search_tracking=".urlencode($search_tracking);
476 }
477 if ($search_town) {
478  $param .= '&search_town='.urlencode($search_town);
479 }
480 if ($search_zip) {
481  $param .= '&search_zip='.urlencode($search_zip);
482 }
483 if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) {
484  $param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty);
485 }
486 if ($search_datedelivery_start) {
487  $param .= '&search_datedelivery_startday='.urlencode(dol_print_date($search_datedelivery_start, '%d')).'&search_datedelivery_startmonth='.urlencode(dol_print_date($search_datedelivery_start, '%m')).'&search_datedelivery_startyear='.urlencode(dol_print_date($search_datedelivery_start, '%Y'));
488 }
489 if ($search_datedelivery_end) {
490  $param .= '&search_datedelivery_endday='.urlencode(dol_print_date($search_datedelivery_end, '%d')).'&search_datedelivery_endmonth='.urlencode(dol_print_date($search_datedelivery_end, '%m')).'&search_datedelivery_endyear='.urlencode(dol_print_date($search_datedelivery_end, '%Y'));
491 }
492 if ($search_datereceipt_start) {
493  $param .= '&search_datereceipt_startday='.urlencode(dol_print_date($search_datereceipt_start, '%d')).'&search_datereceipt_startmonth='.urlencode(dol_print_date($search_datereceipt_start, '%m')).'&search_datereceipt_startyear='.urlencode(dol_print_date($search_datereceipt_start, '%Y'));
494 }
495 if ($search_datereceipt_end) {
496  $param .= '&search_datereceipt_endday='.urlencode(dol_print_date($search_datereceipt_end, '%d')).'&search_datereceipt_endmonth='.urlencode(dol_print_date($search_datereceipt_end, '%m')).'&search_datereceipt_endyear='.urlencode(dol_print_date($search_datereceipt_end, '%Y'));
497 }
498 if ($search_product_category != '') {
499  $param .= '&search_product_category='.urlencode($search_product_category);
500 }
501 if (($search_categ_cus > 0) || ($search_categ_cus == -2)) {
502  $param .= '&search_categ_cus='.urlencode($search_categ_cus);
503 }
504 if ($search_status != '') {
505  $param .= '&search_status='.urlencode($search_status);
506 }
507 if ($optioncss != '') {
508  $param .= '&optioncss='.urlencode($optioncss);
509 }
510 // Add $param from extra fields
511 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
512 
513 // Add $param from hooks
514 $parameters = array();
515 $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook
516 $param .= $hookmanager->resPrint;
517 
518 $arrayofmassactions = array(
519  'builddoc' => img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
520  'classifyclose'=>$langs->trans("Close"),
521  'presend' => img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
522 );
523 if (in_array($massaction, array('presend'))) {
524  $arrayofmassactions = array();
525 }
526 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
527 
528 // Currently: a sending can't create from sending list
529 // $url = DOL_URL_ROOT.'/expedition/card.php?action=create';
530 // if (!empty($socid)) $url .= '&socid='.$socid;
531 // $newcardbutton = dolGetButtonTitle($langs->trans('NewSending'), '', 'fa fa-plus-circle', $url, '', $user->rights->expedition->creer);
532 $newcardbutton = dolGetButtonTitle($langs->trans('NewSending'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/expedition/card.php?action=create2', '', $user->rights->expedition->creer);
533 
534 $i = 0;
535 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'."\n";
536 if ($optioncss != '') {
537  print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
538 }
539 print '<input type="hidden" name="token" value="'.newToken().'">';
540 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
541 print '<input type="hidden" name="action" value="list">';
542 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
543 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
544 
545 print_barre_liste($langs->trans('ListOfSendings'), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'dolly', 0, $newcardbutton, '', $limit, 0, 0, 1);
546 
547 $topicmail = "SendShippingRef";
548 $modelmail = "shipping_send";
549 $objecttmp = new Expedition($db);
550 $trackid = 'shi'.$object->id;
551 include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
552 
553 if ($sall) {
554  foreach ($fieldstosearchall as $key => $val) {
555  $fieldstosearchall[$key] = $langs->trans($val);
556  }
557  print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>';
558 }
559 
560 $moreforfilter = '';
561 
562 // If the user can view prospects other than his'
563 if ($user->rights->user->user->lire) {
564  $langs->load("commercial");
565  $moreforfilter .= '<div class="divsearchfield">';
566  $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative');
567  $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"');
568  $moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'maxwidth200');
569  $moreforfilter .= '</div>';
570 }
571 // If the user can view other users
572 if ($user->rights->user->user->lire) {
573  $moreforfilter .= '<div class="divsearchfield">';
574  $tmptitle = $langs->trans('LinkedToSpecificUsers');
575  $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"');
576  $moreforfilter .= $form->select_dolusers($search_user, 'search_user', $tmptitle, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200');
577  $moreforfilter .= '</div>';
578 }
579 // If the user can view prospects other than his'
580 if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire)) {
581  include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
582  $moreforfilter .= '<div class="divsearchfield">';
583  $tmptitle = $langs->trans('IncludingProductWithTag');
584  $moreforfilter .= img_picto($tmptitle, 'category');
585  //$cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1);
586  //$moreforfilter .= $form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1);
587  $moreforfilter .= $formother->select_categories(Categorie::TYPE_PRODUCT, $search_product_category, 'search_product_category', 1, $tmptitle);
588 
589  $moreforfilter .= '</div>';
590 }
591 if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) {
592  require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
593  $moreforfilter .= '<div class="divsearchfield">';
594  $tmptitle = $langs->trans('CustomersProspectsCategoriesShort');
595  $moreforfilter .= img_picto($tmptitle, 'category');
596  $moreforfilter .= $formother->select_categories('customer', $search_categ_cus, 'search_categ_cus', 1, $tmptitle);
597  $moreforfilter .= '</div>';
598 }
599 $parameters = array();
600 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
601 if (empty($reshook)) {
602  $moreforfilter .= $hookmanager->resPrint;
603 } else {
604  $moreforfilter = $hookmanager->resPrint;
605 }
606 
607 if (!empty($moreforfilter)) {
608  print '<div class="liste_titre liste_titre_bydiv centpercent">';
609  print $moreforfilter;
610  print '</div>';
611 }
612 
613 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
614 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage);
615 if ($massactionbutton) {
616  $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); // This also change content of $arrayfields
617 }
618 
619 print '<div class="div-table-responsive">';
620 print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
621 
622 // Fields title search
623 print '<tr class="liste_titre_filter">';
624 // Ref
625 if (!empty($arrayfields['e.ref']['checked'])) {
626  print '<td class="liste_titre">';
627  print '<input class="flat" size="6" type="text" name="search_ref_exp" value="'.$search_ref_exp.'">';
628  print '</td>';
629 }
630 // Ref customer
631 if (!empty($arrayfields['e.ref_customer']['checked'])) {
632  print '<td class="liste_titre">';
633  print '<input class="flat" size="6" type="text" name="search_ref_customer" value="'.$search_ref_customer.'">';
634  print '</td>';
635 }
636 // Thirdparty
637 if (!empty($arrayfields['s.nom']['checked'])) {
638  print '<td class="liste_titre left">';
639  print '<input class="flat" type="text" size="8" name="search_company" value="'.dol_escape_htmltag($search_company).'">';
640  print '</td>';
641 }
642 // Town
643 if (!empty($arrayfields['s.town']['checked'])) {
644  print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_town" value="'.$search_town.'"></td>';
645 }
646 // Zip
647 if (!empty($arrayfields['s.zip']['checked'])) {
648  print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_zip" value="'.$search_zip.'"></td>';
649 }
650 // State
651 if (!empty($arrayfields['state.nom']['checked'])) {
652  print '<td class="liste_titre">';
653  print '<input class="flat" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
654  print '</td>';
655 }
656 // Country
657 if (!empty($arrayfields['country.code_iso']['checked'])) {
658  print '<td class="liste_titre center">';
659  print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100');
660  print '</td>';
661 }
662 // Company type
663 if (!empty($arrayfields['typent.code']['checked'])) {
664  print '<td class="liste_titre maxwidthonsmartphone center">';
665  print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT), '', 1);
666  print '</td>';
667 }
668 // Weight
669 if (!empty($arrayfields['e.weight']['checked'])) {
670  print '<td class="liste_titre maxwidthonsmartphone center">';
671 
672  print '</td>';
673 }
674 // Date delivery planned
675 if (!empty($arrayfields['e.date_delivery']['checked'])) {
676  print '<td class="liste_titre center">';
677  print '<div class="nowrap">';
678  print $form->selectDate($search_datedelivery_start ? $search_datedelivery_start : -1, 'search_datedelivery_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
679  print '</div>';
680  print '<div class="nowrap">';
681  print $form->selectDate($search_datedelivery_end ? $search_datedelivery_end : -1, 'search_datedelivery_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
682  print '</div>';
683  print '</td>';
684 }
685 if (!empty($arrayfields['e.fk_shipping_method']['checked'])) {
686  // Delivery method
687  print '<td class="liste_titre center">';
688  $shipment->fetch_delivery_methods();
689  print $form->selectarray("search_shipping_method_id", $shipment->meths, $search_shipping_method_id, 1, 0, 0, "", 1, 0, 0, '', 'maxwidth150');
690  print "</td>\n";
691 }
692 // Tracking number
693 if (!empty($arrayfields['e.tracking_number']['checked'])) {
694  print '<td class="liste_titre center">';
695  print '<input class="flat" size="6" type="text" name="search_tracking" value="'.dol_escape_htmltag($search_tracking).'">';
696  print '</td>';
697 }
698 if (!empty($arrayfields['l.ref']['checked'])) {
699  // Delivery ref
700  print '<td class="liste_titre">';
701  print '<input class="flat" size="10" type="text" name="search_ref_liv" value="'.dol_escape_htmltag($search_ref_liv).'"';
702  print '</td>';
703 }
704 if (!empty($arrayfields['l.date_delivery']['checked'])) {
705  // Date received
706  print '<td class="liste_titre center">';
707  print '<div class="nowrap">';
708  print $form->selectDate($search_datereceipt_start ? $search_datereceipt_start : -1, 'search_datereceipt_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
709  print '</div>';
710  print '<div class="nowrap">';
711  print $form->selectDate($search_datereceipt_end ? $search_datereceipt_end : -1, 'search_datereceipt_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
712  print '</div>';
713  print '</td>';
714 }
715 // Extra fields
716 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
717 
718 // Fields from hook
719 $parameters = array('arrayfields'=>$arrayfields);
720 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
721 print $hookmanager->resPrint;
722 // Date creation
723 if (!empty($arrayfields['e.datec']['checked'])) {
724  print '<td class="liste_titre">';
725  print '</td>';
726 }
727 // Date modification
728 if (!empty($arrayfields['e.tms']['checked'])) {
729  print '<td class="liste_titre">';
730  print '</td>';
731 }
732 // Status
733 if (!empty($arrayfields['e.fk_statut']['checked'])) {
734  print '<td class="liste_titre maxwidthonsmartphone right">';
735  print $form->selectarray('search_status', array('0'=>$langs->trans('StatusSendingDraftShort'), '1'=>$langs->trans('StatusSendingValidatedShort'), '2'=>$langs->trans('StatusSendingProcessedShort')), $search_status, 1);
736  print '</td>';
737 }
738 // Status billed
739 if (!empty($arrayfields['e.billed']['checked'])) {
740  print '<td class="liste_titre maxwidthonsmartphone center">';
741  print $form->selectyesno('search_billed', $search_billed, 1, 0, 1);
742  print '</td>';
743 }
744 // Action column
745 print '<td class="liste_titre middle">';
746 $searchpicto = $form->showFilterAndCheckAddButtons(0);
747 print $searchpicto;
748 print '</td>';
749 print "</tr>\n";
750 
751 print '<tr class="liste_titre">';
752 if (!empty($arrayfields['e.ref']['checked'])) {
753  print_liste_field_titre($arrayfields['e.ref']['label'], $_SERVER["PHP_SELF"], "e.ref", "", $param, '', $sortfield, $sortorder);
754 }
755 if (!empty($arrayfields['e.ref_customer']['checked'])) {
756  print_liste_field_titre($arrayfields['e.ref_customer']['label'], $_SERVER["PHP_SELF"], "e.ref_customer", "", $param, '', $sortfield, $sortorder);
757 }
758 if (!empty($arrayfields['s.nom']['checked'])) {
759  print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder, 'left ');
760 }
761 if (!empty($arrayfields['s.town']['checked'])) {
762  print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder);
763 }
764 if (!empty($arrayfields['s.zip']['checked'])) {
765  print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder);
766 }
767 if (!empty($arrayfields['state.nom']['checked'])) {
768  print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder);
769 }
770 if (!empty($arrayfields['country.code_iso']['checked'])) {
771  print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center ');
772 }
773 if (!empty($arrayfields['typent.code']['checked'])) {
774  print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center ');
775 }
776 if (!empty($arrayfields['e.weight']['checked'])) {
777  print_liste_field_titre($arrayfields['e.weight']['label'], $_SERVER["PHP_SELF"], "e.weight", "", $param, '', $sortfield, $sortorder, 'center ');
778 }
779 if (!empty($arrayfields['e.date_delivery']['checked'])) {
780  print_liste_field_titre($arrayfields['e.date_delivery']['label'], $_SERVER["PHP_SELF"], "e.date_delivery", "", $param, '', $sortfield, $sortorder, 'center ');
781 }
782 if (!empty($arrayfields['e.fk_shipping_method']['checked'])) {
783  print_liste_field_titre($arrayfields['e.fk_shipping_method']['label'], $_SERVER["PHP_SELF"], "e.fk_shipping_method", "", $param, '', $sortfield, $sortorder, 'center ');
784 }
785 if (!empty($arrayfields['e.tracking_number']['checked'])) {
786  print_liste_field_titre($arrayfields['e.tracking_number']['label'], $_SERVER["PHP_SELF"], "e.tracking_number", "", $param, '', $sortfield, $sortorder, 'center ');
787 }
788 if (!empty($arrayfields['l.ref']['checked'])) {
789  print_liste_field_titre($arrayfields['l.ref']['label'], $_SERVER["PHP_SELF"], "l.ref", "", $param, '', $sortfield, $sortorder);
790 }
791 if (!empty($arrayfields['l.date_delivery']['checked'])) {
792  print_liste_field_titre($arrayfields['l.date_delivery']['label'], $_SERVER["PHP_SELF"], "l.date_delivery", "", $param, '', $sortfield, $sortorder, 'center ');
793 }
794 // Extra fields
795 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
796 // Hook fields
797 $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
798 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
799 print $hookmanager->resPrint;
800 if (!empty($arrayfields['e.datec']['checked'])) {
801  print_liste_field_titre($arrayfields['e.datec']['label'], $_SERVER["PHP_SELF"], "e.date_creation", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
802 }
803 if (!empty($arrayfields['e.tms']['checked'])) {
804  print_liste_field_titre($arrayfields['e.tms']['label'], $_SERVER["PHP_SELF"], "e.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
805 }
806 if (!empty($arrayfields['e.fk_statut']['checked'])) {
807  print_liste_field_titre($arrayfields['e.fk_statut']['label'], $_SERVER["PHP_SELF"], "e.fk_statut", "", $param, '', $sortfield, $sortorder, 'right ');
808 }
809 if (!empty($arrayfields['e.billed']['checked'])) {
810  print_liste_field_titre($arrayfields['e.billed']['label'], $_SERVER["PHP_SELF"], "e.billed", "", $param, '', $sortfield, $sortorder, 'center ');
811 }
812 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
813 print "</tr>\n";
814 
815 $typenArray = $formcompany->typent_array(1);
816 $i = 0;
817 $totalarray = array();
818 $totalarray['nbfield'] = 0;
819 while ($i < min($num, $limit)) {
820  $obj = $db->fetch_object($resql);
821 
822  $shipment->id = $obj->rowid;
823  $shipment->ref = $obj->ref;
824  $shipment->shipping_method_id=$obj->fk_shipping_method;
825 
826  $companystatic->id = $obj->socid;
827  $companystatic->ref = $obj->name;
828  $companystatic->name = $obj->name;
829 
830  $object = new Expedition($db);
831  $object->fetch($obj->rowid);
832 
833  print '<tr class="oddeven">';
834 
835  // Ref
836  if (!empty($arrayfields['e.ref']['checked'])) {
837  print '<td class="nowraponall">';
838  print $shipment->getNomUrl(1);
839  print "</td>\n";
840  if (!$i) {
841  $totalarray['nbfield']++;
842  }
843  }
844 
845  // Ref customer
846  if (!empty($arrayfields['e.ref_customer']['checked'])) {
847  print "<td>";
848  print $obj->ref_customer;
849  print "</td>\n";
850  if (!$i) {
851  $totalarray['nbfield']++;
852  }
853  }
854 
855  // Third party
856  if (!empty($arrayfields['s.nom']['checked'])) {
857  print '<td class="tdoverflowmax150">';
858  print $companystatic->getNomUrl(1);
859  print '</td>';
860  if (!$i) {
861  $totalarray['nbfield']++;
862  }
863  }
864  // Town
865  if (!empty($arrayfields['s.town']['checked'])) {
866  print '<td class="nocellnopadd">';
867  print $obj->town;
868  print '</td>';
869  if (!$i) {
870  $totalarray['nbfield']++;
871  }
872  }
873  // Zip
874  if (!empty($arrayfields['s.zip']['checked'])) {
875  print '<td class="nocellnopadd center">';
876  print $obj->zip;
877  print '</td>';
878  if (!$i) {
879  $totalarray['nbfield']++;
880  }
881  }
882  // State
883  if (!empty($arrayfields['state.nom']['checked'])) {
884  print '<td class="center">'.$obj->state_name."</td>\n";
885  if (!$i) {
886  $totalarray['nbfield']++;
887  }
888  }
889  // Country
890  if (!empty($arrayfields['country.code_iso']['checked'])) {
891  print '<td class="center">';
892  $tmparray = getCountry($obj->fk_pays, 'all');
893  print $tmparray['label'];
894  print '</td>';
895  if (!$i) {
896  $totalarray['nbfield']++;
897  }
898  }
899  // Type ent
900  if (!empty($arrayfields['typent.code']['checked'])) {
901  print '<td class="center">';
902  if (isset($typenArray[$obj->typent_code])) {
903  print $typenArray[$obj->typent_code];
904  }
905  print '</td>';
906  if (!$i) {
907  $totalarray['nbfield']++;
908  }
909  }
910  // Weight
911  if (!empty($arrayfields['e.weight']['checked'])) {
912  print '<td class="center">';
913  if (empty($object->trueWeight)) {
914  $tmparray = $object->getTotalWeightVolume();
915  print showDimensionInBestUnit($tmparray['weight'], 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND) ? $conf->global->MAIN_WEIGHT_DEFAULT_ROUND : -1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT) ? $conf->global->MAIN_WEIGHT_DEFAULT_UNIT : 'no');
916  print $form->textwithpicto('', $langs->trans('EstimatedWeight'), 1);
917  } else {
918  print $object->trueWeight;
919  print ($object->trueWeight && $object->weight_units != '') ? ' '.measuringUnitString(0, "weight", $object->weight_units) : '';
920  }
921  print '</td>';
922  if (!$i) {
923  $totalarray['nbfield']++;
924  }
925  }
926  // Date delivery planed
927  if (!empty($arrayfields['e.date_delivery']['checked'])) {
928  print '<td class="center">';
929  print dol_print_date($db->jdate($obj->delivery_date), "dayhour");
930  print "</td>\n";
931  }
932  if (!empty($arrayfields['e.fk_shipping_method']['checked'])) {
933  // Get code using getLabelFromKey
934  $code=$langs->getLabelFromKey($db, $shipment->shipping_method_id, 'c_shipment_mode', 'rowid', 'code');
935  print '<td class="center tdoverflowmax150" title="'.dol_escape_htmltag($langs->trans("SendingMethod".strtoupper($code))).'">';
936  if ($shipment->shipping_method_id > 0) print $langs->trans("SendingMethod".strtoupper($code));
937  print '</td>';
938  }
939  // Tracking number
940  if (!empty($arrayfields['e.tracking_number']['checked'])) {
941  $shipment->getUrlTrackingStatus($obj->tracking_number);
942  print '<td class="center">'.$shipment->tracking_url."</td>\n";
943  //print $form->editfieldval("TrackingNumber", 'tracking_number', $obj->tracking_url, $obj, $user->rights->expedition->creer, 'string', $obj->tracking_number);
944  if (!$i) {
945  $totalarray['nbfield']++;
946  }
947  }
948 
949  if (!empty($arrayfields['l.ref']['checked']) || !empty($arrayfields['l.date_delivery']['checked'])) {
950  $shipment->fetchObjectLinked($shipment->id, $shipment->element);
951  $receiving = '';
952  if (is_array($shipment->linkedObjects['delivery']) && count($shipment->linkedObjects['delivery']) > 0) {
953  $receiving = reset($shipment->linkedObjects['delivery']);
954  }
955 
956  if (!empty($arrayfields['l.ref']['checked'])) {
957  // Ref
958  print '<td>';
959  print !empty($receiving) ? $receiving->getNomUrl($db) : '';
960  print '</td>';
961  }
962 
963  if (!empty($arrayfields['l.date_delivery']['checked'])) {
964  // Date received
965  print '<td class="center">';
966  print dol_print_date($db->jdate($obj->date_reception), "day");
967  print '</td>'."\n";
968  }
969  }
970 
971  // Extra fields
972  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
973  // Fields from hook
974  $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
975  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
976  print $hookmanager->resPrint;
977  // Date creation
978  if (!empty($arrayfields['e.datec']['checked'])) {
979  print '<td class="center nowrap">';
980  print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
981  print '</td>';
982  if (!$i) {
983  $totalarray['nbfield']++;
984  }
985  }
986  // Date modification
987  if (!empty($arrayfields['e.tms']['checked'])) {
988  print '<td class="center nowrap">';
989  print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
990  print '</td>';
991  if (!$i) {
992  $totalarray['nbfield']++;
993  }
994  }
995  // Status
996  if (!empty($arrayfields['e.fk_statut']['checked'])) {
997  print '<td class="right nowrap">'.$shipment->LibStatut($obj->fk_statut, 5).'</td>';
998  if (!$i) {
999  $totalarray['nbfield']++;
1000  }
1001  }
1002  // Billed
1003  if (!empty($arrayfields['e.billed']['checked'])) {
1004  print '<td class="center">'.yn($obj->billed).'</td>';
1005  if (!$i) {
1006  $totalarray['nbfield']++;
1007  }
1008  }
1009 
1010  // Action column
1011  print '<td class="nowrap" align="center">';
1012  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1013  $selected = 0;
1014  if (in_array($obj->rowid, $arrayofselected)) {
1015  $selected = 1;
1016  }
1017  print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
1018  }
1019  print '</td>';
1020  if (!$i) {
1021  $totalarray['nbfield']++;
1022  }
1023 
1024  print "</tr>\n";
1025 
1026  $i++;
1027 }
1028 
1029 // If no record found
1030 if ($num == 0) {
1031  $colspan = 1;
1032  foreach ($arrayfields as $key => $val) {
1033  if (!empty($val['checked'])) {
1034  $colspan++;
1035  }
1036  }
1037  print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
1038 }
1039 
1040 $db->free($resql);
1041 
1042 $parameters = array('arrayfields'=>$arrayfields, 'totalarray' => $totalarray, 'sql'=>$sql);
1043 $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook
1044 print $hookmanager->resPrint;
1045 
1046 print "</table>";
1047 print "</div>";
1048 print '</form>';
1049 
1050 $hidegeneratedfilelistifempty = 1;
1051 if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
1052  $hidegeneratedfilelistifempty = 0;
1053 }
1054 
1055 // Show list of available documents
1056 $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
1057 $urlsource .= str_replace('&amp;', '&', $param);
1058 
1059 $filedir = $diroutputmassaction;
1060 $genallowed = $user->rights->expedition->lire;
1061 $delallowed = $user->rights->expedition->creer;
1062 $title = '';
1063 
1064 print $formfile->showdocuments('massfilesarea_sendings', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
1065 
1066 // End of page
1067 llxFooter();
1068 $db->close();
Societe
Class to manage third parties objects (customers, suppliers, prospects...)
Definition: societe.class.php:48
restrictedArea
restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
Definition: security.lib.php:234
Expedition
Class to manage shipments.
Definition: expedition.class.php:52
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
dol_print_error
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Definition: functions.lib.php:4844
dol_sort_array
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...
Definition: functions.lib.php:8385
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
FormOther
Classe permettant la generation de composants html autre Only common components are here.
Definition: html.formother.class.php:39
dol_print_date
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
Definition: functions.lib.php:2514
FormCompany
Class to build HTML component for third parties management Only common components are here.
Definition: html.formcompany.class.php:40
img_picto
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Definition: functions.lib.php:3880
FormFile
Class to offer components to list and upload files.
Definition: html.formfile.class.php:36
dolGetButtonTitle
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.
Definition: functions.lib.php:10605
setEventMessage
setEventMessage($mesgs, $style='mesgs')
Set event message in dol_events session object.
Definition: functions.lib.php:8108
print_barre_liste
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.
Definition: functions.lib.php:5257
GETPOSTISSET
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
Definition: functions.lib.php:386
print_liste_field_titre
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
Definition: functions.lib.php:5026
natural_search
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...
Definition: functions.lib.php:9420
ExtraFields
Class to manage standard extra fields.
Definition: extrafields.class.php:39
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
dol_now
dol_now($mode='auto')
Return date for now.
Definition: functions.lib.php:2845
$resql
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice') && $user->rights->supplier_invoice->lire)) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:742
getCountry
getCountry($searchkey, $withcode='', $dbtouse=0, $outputlangs='', $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
Definition: company.lib.php:489
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
dol_mktime
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
Definition: functions.lib.php:2757
showDimensionInBestUnit
showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round=-1, $forceunitoutput='no', $use_short_label=0)
Output a dimension with best unit.
Definition: functions.lib.php:5788
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59