list.php 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830
  1. <?php
  2. /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005-2010 Regis Houssin <regis.houssin@inodbox.com>
  5. * Copyright (C) 2016-2018 Ferran Marcet <fmarcet@2byte.es>
  6. * Copyright (C) 2019 Nicolas ZABOURI <info@inovea-conseil.com>
  7. * Copyright (C) 2020 Thibault FOUCART <support@ptibogxiv.net>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 3 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  21. */
  22. /**
  23. * \file htdocs/expedition/list.php
  24. * \ingroup expedition
  25. * \brief Page to list all shipments
  26. */
  27. require '../main.inc.php';
  28. require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
  29. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
  30. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
  31. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
  32. require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
  33. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  34. require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
  35. // Load translation files required by the page
  36. $langs->loadLangs(array("sendings", "deliveries", 'companies', 'bills'));
  37. $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'shipmentlist'; // To manage different context of search
  38. $socid = GETPOST('socid', 'int');
  39. $action = GETPOST('action', 'alpha');
  40. $massaction = GETPOST('massaction', 'alpha');
  41. $show_files = GETPOST('show_files', 'int');
  42. $toselect = GETPOST('toselect', 'array');
  43. // Security check
  44. $expeditionid = GETPOST('id', 'int');
  45. if ($user->socid) $socid = $user->socid;
  46. $result = restrictedArea($user, 'expedition', $expeditionid, '');
  47. $search_ref_exp = GETPOST("search_ref_exp", 'alpha');
  48. $search_ref_liv = GETPOST('search_ref_liv', 'alpha');
  49. $search_ref_customer = GETPOST('search_ref_customer', 'alpha');
  50. $search_company = GETPOST("search_company", 'alpha');
  51. $search_tracking = GETPOST("search_tracking", 'alpha');
  52. $search_town = GETPOST('search_town', 'alpha');
  53. $search_zip = GETPOST('search_zip', 'alpha');
  54. $search_state = GETPOST("search_state");
  55. $search_country = GETPOST("search_country", 'int');
  56. $search_type_thirdparty = GETPOST("search_type_thirdparty", 'int');
  57. $search_billed = GETPOST("search_billed", 'int');
  58. $search_datedelivery_start = dol_mktime(0, 0, 0, GETPOST('search_datedelivery_startmonth', 'int'), GETPOST('search_datedelivery_startday', 'int'), GETPOST('search_datedelivery_startyear', 'int'));
  59. $search_datedelivery_end = dol_mktime(23, 59, 59, GETPOST('search_datedelivery_endmonth', 'int'), GETPOST('search_datedelivery_endday', 'int'), GETPOST('search_datedelivery_endyear', 'int'));
  60. $search_datereceipt_start = dol_mktime(0, 0, 0, GETPOST('search_datereceipt_startmonth', 'int'), GETPOST('search_datereceipt_startday', 'int'), GETPOST('search_datereceipt_startyear', 'int'));
  61. $search_datereceipt_end = dol_mktime(23, 59, 59, GETPOST('search_datereceipt_endmonth', 'int'), GETPOST('search_datereceipt_endday', 'int'), GETPOST('search_datereceipt_endyear', 'int'));
  62. $sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
  63. $socid = GETPOST('socid', 'int');
  64. $search_user = GETPOST('search_user', 'int');
  65. $search_sale = GETPOST('search_sale', 'int');
  66. $search_categ_cus = GETPOST("search_categ_cus", 'int');
  67. $search_product_category = GETPOST('search_product_category', 'int');
  68. $optioncss = GETPOST('optioncss', 'alpha');
  69. $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
  70. $sortfield = GETPOST('sortfield', 'aZ09comma');
  71. $sortorder = GETPOST('sortorder', 'aZ09comma');
  72. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  73. if (!$sortfield) $sortfield = "e.ref";
  74. if (!$sortorder) $sortorder = "DESC";
  75. if (empty($page) || $page == -1 || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1
  76. $offset = $limit * $page;
  77. $pageprev = $page - 1;
  78. $pagenext = $page + 1;
  79. $search_status = GETPOST('search_status');
  80. $diroutputmassaction = $conf->expedition->dir_output.'/sending/temp/massgeneration/'.$user->id;
  81. $object = new Expedition($db);
  82. $form = new Form($db);
  83. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  84. $hookmanager->initHooks(array('shipmentlist'));
  85. $extrafields = new ExtraFields($db);
  86. // fetch optionals attributes and labels
  87. $extrafields->fetch_name_optionals_label($object->table_element);
  88. $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
  89. // List of fields to search into when doing a "search in all"
  90. $fieldstosearchall = array(
  91. 'e.ref'=>"Ref",
  92. 's.nom'=>"ThirdParty",
  93. 'e.note_public'=>'NotePublic',
  94. 'e.tracking_number'=>"TrackingNumber",
  95. );
  96. if (empty($user->socid)) $fieldstosearchall["e.note_private"] = "NotePrivate";
  97. $checkedtypetiers = 0;
  98. $arrayfields = array(
  99. 'e.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
  100. 'e.ref_customer'=>array('label'=>$langs->trans("RefCustomer"), 'checked'=>1),
  101. 's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1),
  102. 's.town'=>array('label'=>$langs->trans("Town"), 'checked'=>1),
  103. 's.zip'=>array('label'=>$langs->trans("Zip"), 'checked'=>1),
  104. 'state.nom'=>array('label'=>$langs->trans("StateShort"), 'checked'=>0),
  105. 'country.code_iso'=>array('label'=>$langs->trans("Country"), 'checked'=>0),
  106. 'typent.code'=>array('label'=>$langs->trans("ThirdPartyType"), 'checked'=>$checkedtypetiers),
  107. 'e.date_delivery'=>array('label'=>$langs->trans("DateDeliveryPlanned"), 'checked'=>1),
  108. 'e.tracking_number'=>array('label'=>$langs->trans("TrackingNumber"), 'checked'=>1),
  109. 'e.weight'=>array('label'=>$langs->trans("Weight"), 'checked'=>0),
  110. 'e.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
  111. 'e.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
  112. 'e.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000),
  113. 'l.ref'=>array('label'=>$langs->trans("DeliveryRef"), 'checked'=>1, 'enabled'=>(empty($conf->delivery_note->enabled) ? 0 : 1)),
  114. 'l.date_delivery'=>array('label'=>$langs->trans("DateReceived"), 'checked'=>1, 'enabled'=>(empty($conf->delivery_note->enabled) ? 0 : 1)),
  115. 'e.billed'=>array('label'=>$langs->trans("Billed"), 'checked'=>1, 'position'=>1000, 'enabled'=>(!empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)))
  116. );
  117. // Extra fields
  118. if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0)
  119. {
  120. foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val)
  121. {
  122. if (!empty($extrafields->attributes[$object->table_element]['list'][$key]))
  123. $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key]));
  124. }
  125. }
  126. $object->fields = dol_sort_array($object->fields, 'position');
  127. $arrayfields = dol_sort_array($arrayfields, 'position');
  128. /*
  129. * Actions
  130. */
  131. $error = 0;
  132. if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
  133. if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
  134. $parameters = array('socid'=>$socid);
  135. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  136. if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  137. include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
  138. // Purge search criteria
  139. 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
  140. {
  141. $search_categ = '';
  142. $search_user = '';
  143. $search_sale = '';
  144. $search_product_category = '';
  145. $search_ref_exp = '';
  146. $search_ref_liv = '';
  147. $search_ref_customer = '';
  148. $search_company = '';
  149. $search_town = '';
  150. $search_zip = "";
  151. $search_state = "";
  152. $search_type = '';
  153. $search_country = '';
  154. $search_tracking='';
  155. $search_type_thirdparty = '';
  156. $search_billed = '';
  157. $search_datedelivery_start = '';
  158. $search_datedelivery_end = '';
  159. $search_datereceipt_start = '';
  160. $search_datereceipt_end = '';
  161. $search_status = '';
  162. $toselect = '';
  163. $search_array_options = array();
  164. $search_categ_cus = 0;
  165. }
  166. if (empty($reshook))
  167. {
  168. $objectclass = 'Expedition';
  169. $objectlabel = 'Sendings';
  170. $permissiontoread = $user->rights->expedition->lire;
  171. $permissiontoadd = $user->rights->expedition->creer;
  172. $permissiontodelete = $user->rights->expedition->supprimer;
  173. $uploaddir = $conf->expedition->dir_output.'/sending';
  174. include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
  175. }
  176. /*
  177. * View
  178. */
  179. $now = dol_now();
  180. $form = new Form($db);
  181. $formother = new FormOther($db);
  182. $formfile = new FormFile($db);
  183. $companystatic = new Societe($db);
  184. $formcompany = new FormCompany($db);
  185. $shipment = new Expedition($db);
  186. $helpurl = 'EN:Module_Shipments|FR:Module_Exp&eacute;ditions|ES:M&oacute;dulo_Expediciones';
  187. llxHeader('', $langs->trans('ListOfSendings'), $helpurl);
  188. $sql = 'SELECT';
  189. if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT';
  190. $sql .= " e.rowid, e.ref, e.ref_customer, e.date_expedition as date_expedition, e.weight, e.weight_units, e.date_delivery as date_livraison, l.date_delivery as date_reception, e.fk_statut, e.billed, e.tracking_number,";
  191. $sql .= " s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client, ";
  192. $sql .= " typent.code as typent_code,";
  193. $sql .= " state.code_departement as state_code, state.nom as state_name,";
  194. $sql .= " e.date_creation as date_creation, e.tms as date_update,";
  195. $sql .= " u.login";
  196. if ($search_categ_cus) $sql .= ", cc.fk_categorie, cc.fk_soc";
  197. // Add fields from extrafields
  198. if (!empty($extrafields->attributes[$object->table_element]['label'])) {
  199. foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : '');
  200. }
  201. // Add fields from hooks
  202. $parameters = array();
  203. $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
  204. $sql .= $hookmanager->resPrint;
  205. $sql .= " FROM ".MAIN_DB_PREFIX."expedition as e";
  206. if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (e.rowid = ef.fk_object)";
  207. if ($sall || $search_product_category > 0) {
  208. $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'expeditiondet as ed ON e.rowid=ed.fk_expedition';
  209. $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commandedet as pd ON pd.rowid=ed.fk_origin_line';
  210. }
  211. if ($search_product_category > 0) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product';
  212. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc";
  213. if (!empty($search_categ_cus)) $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
  214. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)";
  215. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)";
  216. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)";
  217. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as ee ON e.rowid = ee.fk_source AND ee.sourcetype = 'shipping' AND ee.targettype = 'delivery'";
  218. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."delivery as l ON l.rowid = ee.fk_target";
  219. $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON e.fk_user_author = u.rowid';
  220. // We'll need this table joined to the select in order to filter by sale
  221. if ($search_sale > 0 || (!$user->rights->societe->client->voir && !$socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
  222. if ($search_user > 0)
  223. {
  224. $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec";
  225. $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as tc";
  226. }
  227. $sql .= " WHERE e.entity IN (".getEntity('expedition').")";
  228. if ($search_product_category > 0) $sql .= " AND cp.fk_categorie = ".$search_product_category;
  229. if ($socid > 0) $sql .= ' AND s.rowid = '.$socid;
  230. if (!$user->rights->societe->client->voir && !$socid) // Internal user with no permission to see all
  231. {
  232. $sql .= " AND e.fk_soc = sc.fk_soc";
  233. $sql .= " AND sc.fk_user = ".$user->id;
  234. }
  235. if ($socid)
  236. {
  237. $sql .= " AND e.fk_soc = ".$socid;
  238. }
  239. if ($search_status <> '' && $search_status >= 0) {
  240. $sql .= " AND e.fk_statut = ".$search_status;
  241. }
  242. if ($search_ref_customer != '') $sql .= natural_search('e.ref_customer', $search_ref_customer);
  243. if ($search_billed != '' && $search_billed >= 0) $sql .= ' AND e.billed = '.$search_billed;
  244. if ($search_town) $sql .= natural_search('s.town', $search_town);
  245. if ($search_zip) $sql .= natural_search("s.zip", $search_zip);
  246. if ($search_state) $sql .= natural_search("state.nom", $search_state);
  247. if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')';
  248. if ($search_tracking) $sql.= natural_search("e.tracking_number", $search_tracking);
  249. if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')';
  250. if ($search_sale > 0) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$search_sale;
  251. if ($search_ref_exp) $sql .= natural_search('e.ref', $search_ref_exp);
  252. if ($search_ref_liv) $sql .= natural_search('l.ref', $search_ref_liv);
  253. if ($search_company) $sql .= natural_search('s.nom', $search_company);
  254. if ($search_datedelivery_start) $sql .= " AND e.date_delivery >= '".$db->idate($search_datedelivery_start)."'";
  255. if ($search_datedelivery_end) $sql .= " AND e.date_delivery <= '".$db->idate($search_datedelivery_end)."'";
  256. if ($search_datereceipt_start) $sql .= " AND l.date_delivery >= '".$db->idate($search_datereceipt_start)."'";
  257. if ($search_datereceipt_end) $sql .= " AND l.date_delivery <= '".$db->idate($search_datereceipt_end)."'";
  258. if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall);
  259. if ($search_categ_cus > 0) $sql .= " AND cc.fk_categorie = ".$db->escape($search_categ_cus);
  260. if ($search_categ_cus == -2) $sql .= " AND cc.fk_categorie IS NULL";
  261. // Add where from extra fields
  262. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
  263. // Add where from hooks
  264. $parameters = array();
  265. $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
  266. $sql .= $hookmanager->resPrint;
  267. $sql .= $db->order($sortfield, $sortorder);
  268. $nbtotalofrecords = '';
  269. if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
  270. {
  271. $result = $db->query($sql);
  272. $nbtotalofrecords = $db->num_rows($result);
  273. if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
  274. {
  275. $page = 0;
  276. $offset = 0;
  277. }
  278. }
  279. $sql .= $db->plimit($limit + 1, $offset);
  280. //print $sql;
  281. $resql = $db->query($sql);
  282. if ($resql)
  283. {
  284. $num = $db->num_rows($resql);
  285. $arrayofselected = is_array($toselect) ? $toselect : array();
  286. $expedition = new Expedition($db);
  287. $param = '';
  288. if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
  289. if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
  290. if ($sall) $param .= "&amp;sall=".urlencode($sall);
  291. if ($search_ref_exp) $param .= "&amp;search_ref_exp=".urlencode($search_ref_exp);
  292. if ($search_ref_liv) $param .= "&amp;search_ref_liv=".urlencode($search_ref_liv);
  293. if ($search_ref_customer) $param .= "&amp;search_ref_customer=".urlencode($search_ref_customer);
  294. if ($search_user > 0) $param .= '&search_user='.urlencode($search_user);
  295. if ($search_sale > 0) $param .= '&search_sale='.urlencode($search_sale);
  296. if ($search_company) $param .= "&amp;search_company=".urlencode($search_company);
  297. if ($search_tracking) $param.= "&amp;search_tracking=".urlencode($search_tracking);
  298. if ($search_town) $param .= '&search_town='.urlencode($search_town);
  299. if ($search_zip) $param .= '&search_zip='.urlencode($search_zip);
  300. if ($search_datedelivery_start) $param .= '&search_datedelivery_start='.urlencode($search_datedelivery_start);
  301. if ($search_datedelivery_end) $param .= '&search_datedelivery_end='.urlencode($search_datedelivery_end);
  302. if ($search_datereceipt_start) $param .= '&search_datereceipt_start='.urlencode($search_datereceipt_start);
  303. if ($search_datereceipt_end) $param .= '&search_datereceipt_end='.urlencode($search_datereceipt_end);
  304. if ($search_product_category != '') $param .= '&search_product_category='.urlencode($search_product_category);
  305. if ($search_categ_cus > 0) $param .= '&search_categ_cus='.urlencode($search_categ_cus);
  306. if ($search_status != '') $param .= '&viewstatut='.urlencode($search_status);
  307. if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
  308. // Add $param from extra fields
  309. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
  310. $arrayofmassactions = array(
  311. 'builddoc' => $langs->trans("PDFMerge"),
  312. //'classifyclose'=>$langs->trans("Close"), TODO massive close shipment ie: when truck is charged
  313. 'presend' => $langs->trans("SendByMail"),
  314. );
  315. if (in_array($massaction, array('presend'))) $arrayofmassactions = array();
  316. $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
  317. // Currently: a sending can't create from sending list
  318. // $url = DOL_URL_ROOT.'/expedition/card.php?action=create';
  319. // if (!empty($socid)) $url .= '&socid='.$socid;
  320. // $newcardbutton = dolGetButtonTitle($langs->trans('NewSending'), '', 'fa fa-plus-circle', $url, '', $user->rights->expedition->creer);
  321. $newcardbutton = dolGetButtonTitle($langs->trans('NewSending'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/expedition/card.php?action=create2', '', $user->rights->expedition->creer);
  322. $i = 0;
  323. print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'."\n";
  324. if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  325. print '<input type="hidden" name="token" value="'.newToken().'">';
  326. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  327. print '<input type="hidden" name="action" value="list">';
  328. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  329. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  330. print_barre_liste($langs->trans('ListOfSendings'), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'dolly', 0, $newcardbutton, '', $limit, 0, 0, 1);
  331. $topicmail = "SendShippingRef";
  332. $modelmail = "shipping_send";
  333. $objecttmp = new Expedition($db);
  334. $trackid = 'shi'.$object->id;
  335. include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
  336. if ($sall)
  337. {
  338. foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val);
  339. print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>';
  340. }
  341. $moreforfilter = '';
  342. // If the user can view prospects other than his'
  343. if ($user->rights->societe->client->voir || $socid)
  344. {
  345. $langs->load("commercial");
  346. $moreforfilter .= '<div class="divsearchfield">';
  347. $moreforfilter .= $langs->trans('ThirdPartiesOfSaleRepresentative').': ';
  348. $moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200');
  349. $moreforfilter .= '</div>';
  350. }
  351. // If the user can view other users
  352. if ($user->rights->user->user->lire)
  353. {
  354. $moreforfilter .= '<div class="divsearchfield">';
  355. $moreforfilter .= $langs->trans('LinkedToSpecificUsers').': ';
  356. $moreforfilter .= $form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200');
  357. $moreforfilter .= '</div>';
  358. }
  359. // If the user can view prospects other than his'
  360. if ($conf->categorie->enabled && ($user->rights->produit->lire || $user->rights->service->lire))
  361. {
  362. include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
  363. $moreforfilter .= '<div class="divsearchfield">';
  364. $moreforfilter .= $langs->trans('IncludingProductWithTag').': ';
  365. $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1);
  366. $moreforfilter .= $form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1);
  367. $moreforfilter .= '</div>';
  368. }
  369. if (!empty($conf->categorie->enabled))
  370. {
  371. require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
  372. $moreforfilter .= '<div class="divsearchfield">';
  373. $moreforfilter .= $langs->trans('CustomersProspectsCategoriesShort').': ';
  374. $moreforfilter .= $formother->select_categories('customer', $search_categ_cus, 'search_categ_cus', 1);
  375. $moreforfilter .= '</div>';
  376. }
  377. $parameters = array();
  378. $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
  379. if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
  380. else $moreforfilter = $hookmanager->resPrint;
  381. if (!empty($moreforfilter))
  382. {
  383. print '<div class="liste_titre liste_titre_bydiv centpercent">';
  384. print $moreforfilter;
  385. print '</div>';
  386. }
  387. $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
  388. $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage);
  389. if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); // This also change content of $arrayfields
  390. print '<div class="div-table-responsive">';
  391. print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
  392. // Fields title search
  393. print '<tr class="liste_titre_filter">';
  394. // Ref
  395. if (!empty($arrayfields['e.ref']['checked']))
  396. {
  397. print '<td class="liste_titre">';
  398. print '<input class="flat" size="6" type="text" name="search_ref_exp" value="'.$search_ref_exp.'">';
  399. print '</td>';
  400. }
  401. // Ref customer
  402. if (!empty($arrayfields['e.ref_customer']['checked']))
  403. {
  404. print '<td class="liste_titre">';
  405. print '<input class="flat" size="6" type="text" name="search_ref_customer" value="'.$search_ref_customer.'">';
  406. print '</td>';
  407. }
  408. // Thirdparty
  409. if (!empty($arrayfields['s.nom']['checked']))
  410. {
  411. print '<td class="liste_titre left">';
  412. print '<input class="flat" type="text" size="8" name="search_company" value="'.dol_escape_htmltag($search_company).'">';
  413. print '</td>';
  414. }
  415. // Town
  416. if (!empty($arrayfields['s.town']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_town" value="'.$search_town.'"></td>';
  417. // Zip
  418. if (!empty($arrayfields['s.zip']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_zip" value="'.$search_zip.'"></td>';
  419. // State
  420. if (!empty($arrayfields['state.nom']['checked']))
  421. {
  422. print '<td class="liste_titre">';
  423. print '<input class="flat" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
  424. print '</td>';
  425. }
  426. // Country
  427. if (!empty($arrayfields['country.code_iso']['checked']))
  428. {
  429. print '<td class="liste_titre center">';
  430. print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100');
  431. print '</td>';
  432. }
  433. // Company type
  434. if (!empty($arrayfields['typent.code']['checked']))
  435. {
  436. print '<td class="liste_titre maxwidthonsmartphone center">';
  437. print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT));
  438. print '</td>';
  439. }
  440. // Weight
  441. if (!empty($arrayfields['e.weight']['checked']))
  442. {
  443. print '<td class="liste_titre maxwidthonsmartphone center">';
  444. print '</td>';
  445. }
  446. // Date delivery planned
  447. if (!empty($arrayfields['e.date_delivery']['checked']))
  448. {
  449. print '<td class="liste_titre center">';
  450. print '<div class="nowrap">';
  451. print $langs->trans('From').' ';
  452. print $form->selectDate($search_delivery_start ? $search_delivery_start : -1, 'search_delivery_start', 0, 0, 1);
  453. print '</div>';
  454. print '<div class="nowrap">';
  455. print $langs->trans('to').' ';
  456. print $form->selectDate($search_delivery_end ? $search_delivery_end : -1, 'search_delivery_end', 0, 0, 1);
  457. print '</div>';
  458. print '</td>';
  459. }
  460. // Tracking number
  461. if (! empty($arrayfields['e.tracking_number']['checked']))
  462. {
  463. print '<td class="liste_titre center">';
  464. print '<input class="flat" size="6" type="text" name="search_tracking" value="'.dol_escape_htmltag($search_tracking).'">';
  465. print '</td>';
  466. }
  467. if (!empty($arrayfields['l.ref']['checked']))
  468. {
  469. // Delivery ref
  470. print '<td class="liste_titre">';
  471. print '<input class="flat" size="10" type="text" name="search_ref_liv" value="'.$search_ref_liv.'"';
  472. print '</td>';
  473. }
  474. if (!empty($arrayfields['l.date_delivery']['checked']))
  475. {
  476. // Date received
  477. print '<td class="liste_titre center">';
  478. print '<div class="nowrap">';
  479. print $langs->trans('From').' ';
  480. print $form->selectDate($search_receipt_start ? $search_receipt_start : -1, 'search_receipt_start', 0, 0, 1);
  481. print '</div>';
  482. print '<div class="nowrap">';
  483. print $langs->trans('to').' ';
  484. print $form->selectDate($search_receipt_end ? $search_receipt_end : -1, 'search_receipt_end', 0, 0, 1);
  485. print '</div>';
  486. print '</td>';
  487. }
  488. // Extra fields
  489. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
  490. // Fields from hook
  491. $parameters = array('arrayfields'=>$arrayfields);
  492. $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
  493. print $hookmanager->resPrint;
  494. // Date creation
  495. if (!empty($arrayfields['e.datec']['checked']))
  496. {
  497. print '<td class="liste_titre">';
  498. print '</td>';
  499. }
  500. // Date modification
  501. if (!empty($arrayfields['e.tms']['checked']))
  502. {
  503. print '<td class="liste_titre">';
  504. print '</td>';
  505. }
  506. // Status
  507. if (!empty($arrayfields['e.fk_statut']['checked']))
  508. {
  509. print '<td class="liste_titre maxwidthonsmartphone right">';
  510. print $form->selectarray('search_status', array('0'=>$langs->trans('StatusSendingDraftShort'), '1'=>$langs->trans('StatusSendingValidatedShort'), '2'=>$langs->trans('StatusSendingProcessedShort')), $search_status, 1);
  511. print '</td>';
  512. }
  513. // Status billed
  514. if (!empty($arrayfields['e.billed']['checked']))
  515. {
  516. print '<td class="liste_titre maxwidthonsmartphone center">';
  517. print $form->selectyesno('search_billed', $search_billed, 1, 0, 1);
  518. print '</td>';
  519. }
  520. // Action column
  521. print '<td class="liste_titre middle">';
  522. $searchpicto = $form->showFilterAndCheckAddButtons(0);
  523. print $searchpicto;
  524. print '</td>';
  525. print "</tr>\n";
  526. print '<tr class="liste_titre">';
  527. if (!empty($arrayfields['e.ref']['checked'])) print_liste_field_titre($arrayfields['e.ref']['label'], $_SERVER["PHP_SELF"], "e.ref", "", $param, '', $sortfield, $sortorder);
  528. if (!empty($arrayfields['e.ref_customer']['checked'])) print_liste_field_titre($arrayfields['e.ref_customer']['label'], $_SERVER["PHP_SELF"], "e.ref_customer", "", $param, '', $sortfield, $sortorder);
  529. if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder, 'left ');
  530. if (!empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder);
  531. if (!empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder);
  532. if (!empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder);
  533. if (!empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center ');
  534. if (!empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center ');
  535. if (!empty($arrayfields['e.weight']['checked'])) print_liste_field_titre($arrayfields['e.weight']['label'], $_SERVER["PHP_SELF"], "e.weight", "", $param, '', $sortfield, $sortorder, 'center ');
  536. if (!empty($arrayfields['e.date_delivery']['checked'])) print_liste_field_titre($arrayfields['e.date_delivery']['label'], $_SERVER["PHP_SELF"], "e.date_delivery", "", $param, '', $sortfield, $sortorder, 'center ');
  537. if (! empty($arrayfields['e.tracking_number']['checked'])) print_liste_field_titre($arrayfields['e.tracking_number']['label'], $_SERVER["PHP_SELF"], "e.tracking_number", "", $param, '', $sortfield, $sortorder, 'center ');
  538. if (!empty($arrayfields['l.ref']['checked'])) print_liste_field_titre($arrayfields['l.ref']['label'], $_SERVER["PHP_SELF"], "l.ref", "", $param, '', $sortfield, $sortorder);
  539. if (!empty($arrayfields['l.date_delivery']['checked'])) print_liste_field_titre($arrayfields['l.date_delivery']['label'], $_SERVER["PHP_SELF"], "l.date_delivery", "", $param, '', $sortfield, $sortorder, 'center ');
  540. // Extra fields
  541. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
  542. // Hook fields
  543. $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
  544. $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
  545. print $hookmanager->resPrint;
  546. if (!empty($arrayfields['e.datec']['checked'])) print_liste_field_titre($arrayfields['e.datec']['label'], $_SERVER["PHP_SELF"], "e.date_creation", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
  547. if (!empty($arrayfields['e.tms']['checked'])) print_liste_field_titre($arrayfields['e.tms']['label'], $_SERVER["PHP_SELF"], "e.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
  548. if (!empty($arrayfields['e.fk_statut']['checked'])) print_liste_field_titre($arrayfields['e.fk_statut']['label'], $_SERVER["PHP_SELF"], "e.fk_statut", "", $param, '', $sortfield, $sortorder, 'right ');
  549. if (!empty($arrayfields['e.billed']['checked'])) print_liste_field_titre($arrayfields['e.billed']['label'], $_SERVER["PHP_SELF"], "e.billed", "", $param, '', $sortfield, $sortorder, 'center ');
  550. print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
  551. print "</tr>\n";
  552. $typenArray = $formcompany->typent_array(1);
  553. $i = 0;
  554. $totalarray = array();
  555. while ($i < min($num, $limit))
  556. {
  557. $obj = $db->fetch_object($resql);
  558. $shipment->id = $obj->rowid;
  559. $shipment->ref = $obj->ref;
  560. $companystatic->id = $obj->socid;
  561. $companystatic->ref = $obj->name;
  562. $companystatic->name = $obj->name;
  563. $object = new Expedition($db);
  564. $object->fetch($obj->rowid);
  565. print '<tr class="oddeven">';
  566. // Ref
  567. if (!empty($arrayfields['e.ref']['checked']))
  568. {
  569. print "<td>";
  570. print $shipment->getNomUrl(1);
  571. print "</td>\n";
  572. if (!$i) $totalarray['nbfield']++;
  573. }
  574. // Ref customer
  575. if (!empty($arrayfields['e.ref_customer']['checked']))
  576. {
  577. print "<td>";
  578. print $obj->ref_customer;
  579. print "</td>\n";
  580. if (!$i) $totalarray['nbfield']++;
  581. }
  582. // Third party
  583. if (!empty($arrayfields['s.nom']['checked']))
  584. {
  585. print '<td>';
  586. print $companystatic->getNomUrl(1);
  587. print '</td>';
  588. if (!$i) $totalarray['nbfield']++;
  589. }
  590. // Town
  591. if (!empty($arrayfields['s.town']['checked']))
  592. {
  593. print '<td class="nocellnopadd">';
  594. print $obj->town;
  595. print '</td>';
  596. if (!$i) $totalarray['nbfield']++;
  597. }
  598. // Zip
  599. if (!empty($arrayfields['s.zip']['checked']))
  600. {
  601. print '<td class="nocellnopadd">';
  602. print $obj->zip;
  603. print '</td>';
  604. if (!$i) $totalarray['nbfield']++;
  605. }
  606. // State
  607. if (!empty($arrayfields['state.nom']['checked']))
  608. {
  609. print "<td>".$obj->state_name."</td>\n";
  610. if (!$i) $totalarray['nbfield']++;
  611. }
  612. // Country
  613. if (!empty($arrayfields['country.code_iso']['checked']))
  614. {
  615. print '<td class="center">';
  616. $tmparray = getCountry($obj->fk_pays, 'all');
  617. print $tmparray['label'];
  618. print '</td>';
  619. if (!$i) $totalarray['nbfield']++;
  620. }
  621. // Type ent
  622. if (!empty($arrayfields['typent.code']['checked']))
  623. {
  624. print '<td class="center">';
  625. if (isset($typenArray[$obj->typent_code])) print $typenArray[$obj->typent_code];
  626. print '</td>';
  627. if (!$i) $totalarray['nbfield']++;
  628. }
  629. // Weight
  630. if (!empty($arrayfields['e.weight']['checked']))
  631. {
  632. print '<td class="center">';
  633. if (empty($object->trueWeight))
  634. {
  635. $tmparray = $object->getTotalWeightVolume();
  636. 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');
  637. print $form->textwithpicto('', $langs->trans('EstimatedWeight'), 1);
  638. } else {
  639. print $object->trueWeight;
  640. print ($object->trueWeight && $object->weight_units != '') ? ' '.measuringUnitString(0, "weight", $object->weight_units) : '';
  641. }
  642. print '</td>';
  643. if (!$i) $totalarray['nbfield']++;
  644. }
  645. // Date delivery planed
  646. if (!empty($arrayfields['e.date_delivery']['checked']))
  647. {
  648. print '<td class="center">';
  649. print dol_print_date($db->jdate($obj->date_livraison), "dayhour");
  650. /*$now = time();
  651. if ( ($now - $db->jdate($obj->date_expedition)) > $conf->warnings->lim && $obj->statutid == 1 )
  652. {
  653. }*/
  654. print "</td>\n";
  655. }
  656. // Tracking number
  657. if (! empty($arrayfields['e.tracking_number']['checked']))
  658. {
  659. print '<td class="center">'.$obj->tracking_number."</td>\n";
  660. if (! $i) $totalarray['nbfield']++;
  661. }
  662. if (!empty($arrayfields['l.ref']['checked']) || !empty($arrayfields['l.date_delivery']['checked']))
  663. {
  664. $shipment->fetchObjectLinked($shipment->id, $shipment->element);
  665. $receiving = '';
  666. if (is_array($shipment->linkedObjects['delivery']) && count($shipment->linkedObjects['delivery']) > 0) $receiving = reset($shipment->linkedObjects['delivery']);
  667. if (!empty($arrayfields['l.ref']['checked']))
  668. {
  669. // Ref
  670. print '<td>';
  671. print !empty($receiving) ? $receiving->getNomUrl($db) : '';
  672. print '</td>';
  673. }
  674. if (!empty($arrayfields['l.date_delivery']['checked']))
  675. {
  676. // Date received
  677. print '<td class="center">';
  678. print dol_print_date($db->jdate($obj->date_reception), "day");
  679. print '</td>'."\n";
  680. }
  681. }
  682. // Extra fields
  683. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
  684. // Fields from hook
  685. $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
  686. $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
  687. print $hookmanager->resPrint;
  688. // Date creation
  689. if (!empty($arrayfields['e.datec']['checked']))
  690. {
  691. print '<td class="center nowrap">';
  692. print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
  693. print '</td>';
  694. if (!$i) $totalarray['nbfield']++;
  695. }
  696. // Date modification
  697. if (!empty($arrayfields['e.tms']['checked']))
  698. {
  699. print '<td class="center nowrap">';
  700. print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
  701. print '</td>';
  702. if (!$i) $totalarray['nbfield']++;
  703. }
  704. // Status
  705. if (!empty($arrayfields['e.fk_statut']['checked']))
  706. {
  707. print '<td class="right nowrap">'.$shipment->LibStatut($obj->fk_statut, 5).'</td>';
  708. if (!$i) $totalarray['nbfield']++;
  709. }
  710. // Billed
  711. if (!empty($arrayfields['e.billed']['checked']))
  712. {
  713. print '<td class="center">'.yn($obj->billed).'</td>';
  714. if (!$i) $totalarray['nbfield']++;
  715. }
  716. // Action column
  717. print '<td class="nowrap" align="center">';
  718. if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  719. {
  720. $selected = 0;
  721. if (in_array($obj->rowid, $arrayofselected)) $selected = 1;
  722. print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
  723. }
  724. print '</td>';
  725. if (!$i) $totalarray['nbfield']++;
  726. print "</tr>\n";
  727. $i++;
  728. }
  729. $db->free($resql);
  730. $parameters = array('arrayfields'=>$arrayfields, 'totalarray' => $totalarray, 'sql'=>$sql);
  731. $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook
  732. print $hookmanager->resPrint;
  733. print "</table>";
  734. print "</div>";
  735. print '</form>';
  736. $hidegeneratedfilelistifempty = 1;
  737. if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0;
  738. // Show list of available documents
  739. $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
  740. $urlsource .= str_replace('&amp;', '&', $param);
  741. $filedir = $diroutputmassaction;
  742. $genallowed = $user->rights->expedition->lire;
  743. $delallowed = $user->rights->expedition->creer;
  744. $title = '';
  745. print $formfile->showdocuments('massfilesarea_sendings', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
  746. } else {
  747. dol_print_error($db);
  748. }
  749. // End of page
  750. llxFooter();
  751. $db->close();