list.php 27 KB

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