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