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