services_list.php 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924
  1. <?php
  2. /* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
  5. * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
  6. * Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es>
  7. * Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
  8. * Copyright (C) 2019 Juanjo Menent <jmenent@2byte.es>
  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. /**
  24. * \file htdocs/contrat/services_list.php
  25. * \ingroup contrat
  26. * \brief Page to list services in contracts
  27. */
  28. require "../main.inc.php";
  29. require_once DOL_DOCUMENT_ROOT."/contrat/class/contrat.class.php";
  30. require_once DOL_DOCUMENT_ROOT."/product/class/product.class.php";
  31. require_once DOL_DOCUMENT_ROOT."/societe/class/societe.class.php";
  32. // Load translation files required by the page
  33. $langs->loadLangs(array('products', 'contracts', 'companies'));
  34. $optioncss = GETPOST('optioncss', 'aZ09');
  35. $massaction = GETPOST('massaction', 'alpha');
  36. $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
  37. $sortfield = GETPOST('sortfield', 'aZ09comma');
  38. $sortorder = GETPOST('sortorder', 'aZ09comma');
  39. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  40. if (empty($page) || $page == -1) {
  41. $page = 0;
  42. } // If $page is not defined, or '' or -1
  43. $offset = $limit * $page;
  44. $pageprev = $page - 1;
  45. $pagenext = $page + 1;
  46. if (!$sortfield) {
  47. $sortfield = "c.rowid";
  48. }
  49. if (!$sortorder) {
  50. $sortorder = "ASC";
  51. }
  52. $mode = GETPOST("mode");
  53. $filter = GETPOST("filter");
  54. $search_name = GETPOST("search_name", 'alpha');
  55. $search_contract = GETPOST("search_contract", 'alpha');
  56. $search_service = GETPOST("search_service", 'alpha');
  57. $search_status = GETPOST("search_status", 'alpha');
  58. $search_product_category = GETPOST('search_product_category', 'int');
  59. $socid = GETPOST('socid', 'int');
  60. $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'contractservicelist'.$mode;
  61. $opouvertureprevuemonth = GETPOST('opouvertureprevuemonth');
  62. $opouvertureprevueday = GETPOST('opouvertureprevueday');
  63. $opouvertureprevueyear = GETPOST('opouvertureprevueyear');
  64. $filter_opouvertureprevue = GETPOST('filter_opouvertureprevue');
  65. $op1month = GETPOST('op1month', 'int');
  66. $op1day = GETPOST('op1day', 'int');
  67. $op1year = GETPOST('op1year', 'int');
  68. $filter_op1 = GETPOST('filter_op1', 'alpha');
  69. $op2month = GETPOST('op2month', 'int');
  70. $op2day = GETPOST('op2day', 'int');
  71. $op2year = GETPOST('op2year', 'int');
  72. $filter_op2 = GETPOST('filter_op2', 'alpha');
  73. $opcloturemonth = GETPOST('opcloturemonth', 'int');
  74. $opclotureday = GETPOST('opclotureday', 'int');
  75. $opclotureyear = GETPOST('opclotureyear', 'int');
  76. $filter_opcloture = GETPOST('filter_opcloture', 'alpha');
  77. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  78. $object = new ContratLigne($db);
  79. $hookmanager->initHooks(array('contractservicelist'));
  80. $extrafields = new ExtraFields($db);
  81. // fetch optionals attributes and labels
  82. $extrafields->fetch_name_optionals_label($object->table_element);
  83. $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
  84. // Security check
  85. $contratid = GETPOST('id', 'int');
  86. if (!empty($user->socid)) {
  87. $socid = $user->socid;
  88. }
  89. $result = restrictedArea($user, 'contrat', $contratid);
  90. if ($search_status != '') {
  91. $tmp = explode('&', $search_status);
  92. $mode = $tmp[0];
  93. if (empty($tmp[1])) {
  94. $filter = '';
  95. } else {
  96. if ($tmp[1] == 'filter=notexpired') {
  97. $filter = 'notexpired';
  98. }
  99. if ($tmp[1] == 'filter=expired') {
  100. $filter = 'expired';
  101. }
  102. }
  103. } else {
  104. $search_status = $mode;
  105. if ($filter == 'expired') {
  106. $search_status .= '&filter=expired';
  107. }
  108. if ($filter == 'notexpired') {
  109. $search_status .= '&filter=notexpired';
  110. }
  111. }
  112. $staticcontrat = new Contrat($db);
  113. $staticcontratligne = new ContratLigne($db);
  114. $companystatic = new Societe($db);
  115. $arrayfields = array(
  116. 'c.ref'=>array('label'=>"Contract", 'checked'=>1, 'position'=>80),
  117. 'p.description'=>array('label'=>"Service", 'checked'=>1, 'position'=>80),
  118. 's.nom'=>array('label'=>"ThirdParty", 'checked'=>1, 'position'=>90),
  119. 'cd.tva_tx'=>array('label'=>"VATRate", 'checked'=>-1, 'position'=>100),
  120. 'cd.subprice'=>array('label'=>"PriceUHT", 'checked'=>-1, 'position'=>105),
  121. 'cd.qty'=>array('label'=>"Qty", 'checked'=>-1, 'position'=>108),
  122. 'cd.total_ht'=>array('label'=>"TotalHT", 'checked'=>-1, 'position'=>109),
  123. 'cd.total_tva'=>array('label'=>"TotalVAT", 'checked'=>-1, 'position'=>110),
  124. 'cd.date_ouverture_prevue'=>array('label'=>"DateStartPlannedShort", 'checked'=>(($mode == "" || $mode == -1) || $mode == "0"), 'position'=>150),
  125. 'cd.date_ouverture'=>array('label'=>"DateStartRealShort", 'checked'=>(($mode == "" || $mode == -1) || $mode > 0), 'position'=>160),
  126. 'cd.date_fin_validite'=>array('label'=>"DateEndPlannedShort", 'checked'=>(($mode == "" || $mode == -1) || $mode < 5), 'position'=>170),
  127. 'cd.date_cloture'=>array('label'=>"DateEndRealShort", 'checked'=>(($mode == "" || $mode == -1) || $mode >= 5), 'position'=>180),
  128. //'cd.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
  129. 'cd.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500),
  130. 'status'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000)
  131. );
  132. // Extra fields
  133. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
  134. $object->fields = dol_sort_array($object->fields, 'position');
  135. $arrayfields = dol_sort_array($arrayfields, 'position');
  136. /*
  137. * Actions
  138. */
  139. if (GETPOST('cancel', 'alpha')) {
  140. $action = 'list'; $massaction = '';
  141. }
  142. if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') {
  143. $massaction = '';
  144. }
  145. $parameters = array('socid'=>$socid);
  146. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  147. if ($reshook < 0) {
  148. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  149. }
  150. if (empty($reshook)) {
  151. // Selection of new fields
  152. include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
  153. if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers
  154. $search_product_category = 0;
  155. $search_name = "";
  156. $search_contract = "";
  157. $search_service = "";
  158. $search_status = -1;
  159. $opouvertureprevuemonth = "";
  160. $opouvertureprevueday = "";
  161. $opouvertureprevueyear = "";
  162. $filter_opouvertureprevue = "";
  163. $op1month = "";
  164. $op1day = "";
  165. $op1year = "";
  166. $filter_op1 = "";
  167. $op2month = "";
  168. $op2day = "";
  169. $op2year = "";
  170. $filter_op2 = "";
  171. $opcloturemonth = "";
  172. $opclotureday = "";
  173. $opclotureyear = "";
  174. $filter_opcloture = "";
  175. $mode = '';
  176. $filter = '';
  177. $toselect = '';
  178. $search_array_options = array();
  179. }
  180. }
  181. /*
  182. * View
  183. */
  184. $now = dol_now();
  185. $form = new Form($db);
  186. $sql = "SELECT c.rowid as cid, c.ref, c.statut as cstatut, c.ref_customer, c.ref_supplier,";
  187. $sql .= " s.rowid as socid, s.nom as name, s.email, s.client, s.fournisseur,";
  188. $sql .= " cd.rowid, cd.description, cd.statut,";
  189. $sql .= " p.rowid as pid, p.ref as pref, p.label as label, p.fk_product_type as ptype, p.entity as pentity,";
  190. if (empty($user->rights->societe->client->voir) && !$socid) {
  191. $sql .= " sc.fk_soc, sc.fk_user,";
  192. }
  193. $sql .= " cd.date_ouverture_prevue,";
  194. $sql .= " cd.date_ouverture,";
  195. $sql .= " cd.date_fin_validite,";
  196. $sql .= " cd.date_cloture,";
  197. $sql .= " cd.qty,";
  198. $sql .= " cd.total_ht,";
  199. $sql .= " cd.total_tva,";
  200. $sql .= " cd.tva_tx,";
  201. $sql .= " cd.subprice,";
  202. //$sql.= " cd.date_c as date_creation,";
  203. $sql .= " cd.tms as date_update";
  204. // Add fields from extrafields
  205. if (!empty($extrafields->attributes[$object->table_element]['label'])) {
  206. foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
  207. $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
  208. }
  209. }
  210. // Add fields from hooks
  211. $parameters = array();
  212. $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
  213. $sql .= $hookmanager->resPrint;
  214. $sql .= " FROM ".MAIN_DB_PREFIX."contrat as c,";
  215. $sql .= " ".MAIN_DB_PREFIX."societe as s,";
  216. if (empty($user->rights->societe->client->voir) && !$socid) {
  217. $sql .= " ".MAIN_DB_PREFIX."societe_commerciaux as sc,";
  218. }
  219. $sql .= " ".MAIN_DB_PREFIX."contratdet as cd";
  220. if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
  221. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (cd.rowid = ef.fk_object)";
  222. }
  223. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid";
  224. if ($search_product_category > 0) {
  225. $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=cd.fk_product';
  226. }
  227. $sql .= " WHERE c.entity = ".$conf->entity;
  228. $sql .= " AND c.rowid = cd.fk_contrat";
  229. if ($search_product_category > 0) {
  230. $sql .= " AND cp.fk_categorie = ".((int) $search_product_category);
  231. }
  232. $sql .= " AND c.fk_soc = s.rowid";
  233. if (empty($user->rights->societe->client->voir) && !$socid) {
  234. $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
  235. }
  236. if ($mode == "0") {
  237. $sql .= " AND cd.statut = 0";
  238. }
  239. if ($mode == "4") {
  240. $sql .= " AND cd.statut = 4";
  241. }
  242. if ($mode == "5") {
  243. $sql .= " AND cd.statut = 5";
  244. }
  245. if ($filter == "expired") {
  246. $sql .= " AND cd.date_fin_validite < '".$db->idate($now)."'";
  247. }
  248. if ($filter == "notexpired") {
  249. $sql .= " AND cd.date_fin_validite >= '".$db->idate($now)."'";
  250. }
  251. if ($search_name) {
  252. $sql .= " AND s.nom LIKE '%".$db->escape($search_name)."%'";
  253. }
  254. if ($search_contract) {
  255. $sql .= " AND c.ref LIKE '%".$db->escape($search_contract)."%' ";
  256. }
  257. if ($search_service) {
  258. $sql .= " AND (p.ref LIKE '%".$db->escape($search_service)."%' OR p.description LIKE '%".$db->escape($search_service)."%' OR cd.description LIKE '%".$db->escape($search_service)."%')";
  259. }
  260. if ($socid > 0) {
  261. $sql .= " AND s.rowid = ".((int) $socid);
  262. }
  263. $filter_dateouvertureprevue = '';
  264. $filter_date1 = '';
  265. $filter_date2 = '';
  266. $filter_opcloture = '';
  267. $filter_dateouvertureprevue_start = dol_mktime(0, 0, 0, $opouvertureprevuemonth, $opouvertureprevueday, $opouvertureprevueyear);
  268. $filter_dateouvertureprevue_end = dol_mktime(23, 59, 59, $opouvertureprevuemonth, $opouvertureprevueday, $opouvertureprevueyear);
  269. if ($filter_dateouvertureprevue_start != '' && $filter_opouvertureprevue == -1) {
  270. $filter_opouvertureprevue = ' BETWEEN ';
  271. }
  272. $filter_date1_start = dol_mktime(0, 0, 0, $op1month, $op1day, $op1year);
  273. $filter_date1_end = dol_mktime(23, 59, 59, $op1month, $op1day, $op1year);
  274. if ($filter_date1_start != '' && $filter_op1 == -1) {
  275. $filter_op1 = ' BETWEEN ';
  276. }
  277. $filter_date2_start = dol_mktime(0, 0, 0, $op2month, $op2day, $op2year);
  278. $filter_date2_end = dol_mktime(23, 59, 59, $op2month, $op2day, $op2year);
  279. if ($filter_date2_start != '' && $filter_op2 == -1) {
  280. $filter_op2 = ' BETWEEN ';
  281. }
  282. $filter_datecloture_start = dol_mktime(0, 0, 0, $opcloturemonth, $opclotureday, $opclotureyear);
  283. $filter_datecloture_end = dol_mktime(23, 59, 59, $opcloturemonth, $opclotureday, $opclotureyear);
  284. if ($filter_datecloture_start != '' && $filter_opcloture == -1) {
  285. $filter_opcloture = ' BETWEEN ';
  286. }
  287. if (!empty($filter_opouvertureprevue) && $filter_opouvertureprevue != -1 && $filter_opouvertureprevue != ' BETWEEN ' && $filter_dateouvertureprevue_start != '') {
  288. $sql .= " AND cd.date_ouverture_prevue ".$filter_opouvertureprevue." '".$db->idate($filter_dateouvertureprevue_start)."'";
  289. }
  290. if (!empty($filter_opouvertureprevue) && $filter_opouvertureprevue == ' BETWEEN ') {
  291. $sql .= " AND '".$db->idate($filter_dateouvertureprevue_end)."'";
  292. }
  293. if (!empty($filter_op1) && $filter_op1 != -1 && $filter_op1 != ' BETWEEN ' && $filter_date1_start != '') {
  294. $sql .= " AND cd.date_ouverture ".$filter_op1." '".$db->idate($filter_date1_start)."'";
  295. }
  296. if (!empty($filter_op1) && $filter_op1 == ' BETWEEN ') {
  297. $sql .= " AND '".$db->idate($filter_date1_end)."'";
  298. }
  299. if (!empty($filter_op2) && $filter_op2 != -1 && $filter_op2 != ' BETWEEN ' && $filter_date2_start != '') {
  300. $sql .= " AND cd.date_fin_validite ".$filter_op2." '".$db->idate($filter_date2_start)."'";
  301. }
  302. if (!empty($filter_op2) && $filter_op2 == ' BETWEEN ') {
  303. $sql .= " AND '".$db->idate($filter_date2_end)."'";
  304. }
  305. if (!empty($filter_opcloture) && $filter_opcloture != ' BETWEEN ' && $filter_opcloture != -1 && $filter_datecloture_start != '') {
  306. $sql .= " AND cd.date_cloture ".$filter_opcloture." '".$db->idate($filter_datecloture_start)."'";
  307. }
  308. if (!empty($filter_opcloture) && $filter_opcloture == ' BETWEEN ') {
  309. $sql .= " AND '".$db->idate($filter_datecloture_end)."'";
  310. }
  311. // Add where from extra fields
  312. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
  313. $sql .= $db->order($sortfield, $sortorder);
  314. //print $sql;
  315. $nbtotalofrecords = '';
  316. if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
  317. $result = $db->query($sql);
  318. $nbtotalofrecords = $db->num_rows($result);
  319. if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
  320. $page = 0;
  321. $offset = 0;
  322. }
  323. }
  324. $sql .= $db->plimit($limit + 1, $offset);
  325. //print $sql;
  326. dol_syslog("contrat/services_list.php", LOG_DEBUG);
  327. $resql = $db->query($sql);
  328. if (!$resql) {
  329. dol_print_error($db);
  330. exit;
  331. }
  332. $num = $db->num_rows($resql);
  333. /*
  334. if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all)
  335. {
  336. $obj = $db->fetch_object($resql);
  337. $id = $obj->id;
  338. header("Location: ".DOL_URL_ROOT.'/projet/tasks/task.php?id='.$id.'&withprojet=1');
  339. exit;
  340. }*/
  341. llxHeader(null, $langs->trans("Services"));
  342. $param = '';
  343. if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
  344. $param .= '&contextpage='.urlencode($contextpage);
  345. }
  346. if ($limit > 0 && $limit != $conf->liste_limit) {
  347. $param .= '&limit='.$limit;
  348. }
  349. if ($search_contract) {
  350. $param .= '&amp;search_contract='.urlencode($search_contract);
  351. }
  352. if ($search_name) {
  353. $param .= '&amp;search_name='.urlencode($search_name);
  354. }
  355. if ($search_service) {
  356. $param .= '&amp;search_service='.urlencode($search_service);
  357. }
  358. if ($mode) {
  359. $param .= '&amp;mode='.urlencode($mode);
  360. }
  361. if ($filter) {
  362. $param .= '&amp;filter='.urlencode($filter);
  363. }
  364. if (!empty($filter_opouvertureprevue) && $filter_opouvertureprevue != -1) {
  365. $param .= '&amp;filter_opouvertureprevue='.urlencode($filter_opouvertureprevue);
  366. }
  367. if (!empty($filter_op1) && $filter_op1 != -1) {
  368. $param .= '&amp;filter_op1='.urlencode($filter_op1);
  369. }
  370. if (!empty($filter_op2) && $filter_op2 != -1) {
  371. $param .= '&amp;filter_op2='.urlencode($filter_op2);
  372. }
  373. if (!empty($filter_opcloture) && $filter_opcloture != -1) {
  374. $param .= '&amp;filter_opcloture='.urlencode($filter_opcloture);
  375. }
  376. if ($filter_dateouvertureprevue_start != '') {
  377. $param .= '&amp;opouvertureprevueday='.((int) $opouvertureprevueday).'&amp;opouvertureprevuemonth='.((int) $opouvertureprevuemonth).'&amp;opouvertureprevueyear='.((int) $opouvertureprevueyear);
  378. }
  379. if ($filter_date1_start != '') {
  380. $param .= '&amp;op1day='.((int) $op1day).'&amp;op1month='.((int) $op1month).'&amp;op1year='.((int) $op1year);
  381. }
  382. if ($filter_date2_start != '') {
  383. $param .= '&amp;op2day='.((int) $op2day).'&amp;op2month='.((int) $op2month).'&amp;op2year='.((int) $op2year);
  384. }
  385. if ($filter_datecloture_start != '') {
  386. $param .= '&amp;opclotureday='.((int) $op2day).'&amp;opcloturemonth='.((int) $op2month).'&amp;opclotureyear='.((int) $op2year);
  387. }
  388. if ($optioncss != '') {
  389. $param .= '&optioncss='.urlencode($optioncss);
  390. }
  391. // Add $param from extra fields
  392. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
  393. // List of mass actions available
  394. $arrayofmassactions = array(
  395. //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
  396. //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
  397. );
  398. //if ($user->rights->contrat->supprimer) $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
  399. //if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
  400. $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
  401. print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
  402. if ($optioncss != '') {
  403. print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  404. }
  405. print '<input type="hidden" name="token" value="'.newToken().'">';
  406. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  407. print '<input type="hidden" name="action" value="list">';
  408. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  409. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  410. print '<input type="hidden" name="page" value="'.$page.'">';
  411. print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
  412. $title = $langs->trans("ListOfServices");
  413. if ($mode == "0") {
  414. $title = $langs->trans("ListOfInactiveServices"); // Must use == "0"
  415. }
  416. if ($mode == "4" && $filter != "expired") {
  417. $title = $langs->trans("ListOfRunningServices");
  418. }
  419. if ($mode == "4" && $filter == "expired") {
  420. $title = $langs->trans("ListOfExpiredServices");
  421. }
  422. if ($mode == "5") {
  423. $title = $langs->trans("ListOfClosedServices");
  424. }
  425. print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'contract', 0, '', '', $limit);
  426. if (!empty($sall)) {
  427. foreach ($fieldstosearchall as $key => $val) {
  428. $fieldstosearchall[$key] = $langs->trans($val);
  429. }
  430. print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>';
  431. }
  432. $morefilter = '';
  433. $moreforfilter = '';
  434. // If the user can view categories of products
  435. if ($conf->categorie->enabled && ($user->rights->produit->lire || $user->rights->service->lire)) {
  436. include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
  437. $moreforfilter .= '<div class="divsearchfield">';
  438. $tmptitle = $langs->trans('IncludingProductWithTag');
  439. $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1);
  440. $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$form->selectarray('search_product_category', $cate_arbo, $search_product_category, $tmptitle, 0, 0, '', 0, 0, 0, 0, 'widthcentpercentminusx maxwidth300', 1);
  441. $moreforfilter .= '</div>';
  442. }
  443. $parameters = array();
  444. $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
  445. if (empty($reshook)) {
  446. $moreforfilter .= $hookmanager->resPrint;
  447. } else {
  448. $moreforfilter = $hookmanager->resPrint;
  449. }
  450. if (!empty($moreforfilter)) {
  451. print '<div class="liste_titre liste_titre_bydiv centpercent">';
  452. print $moreforfilter;
  453. print '</div>';
  454. }
  455. $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
  456. $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
  457. print '<div class="div-table-responsive">';
  458. print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
  459. print '<tr class="liste_titre">';
  460. if (!empty($arrayfields['c.ref']['checked'])) {
  461. print_liste_field_titre($arrayfields['c.ref']['label'], $_SERVER["PHP_SELF"], "c.ref", "", $param, "", $sortfield, $sortorder);
  462. }
  463. if (!empty($arrayfields['p.description']['checked'])) {
  464. print_liste_field_titre($arrayfields['p.description']['label'], $_SERVER["PHP_SELF"], "p.description", "", $param, "", $sortfield, $sortorder);
  465. }
  466. if (!empty($arrayfields['cd.tva_tx']['checked'])) {
  467. print_liste_field_titre($arrayfields['cd.tva_tx']['label'], $_SERVER["PHP_SELF"], "cd.tva_tx", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
  468. }
  469. if (!empty($arrayfields['cd.subprice']['checked'])) {
  470. print_liste_field_titre($arrayfields['cd.subprice']['label'], $_SERVER["PHP_SELF"], "cd.subprice", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
  471. }
  472. if (!empty($arrayfields['cd.qty']['checked'])) {
  473. print_liste_field_titre($arrayfields['cd.qty']['label'], $_SERVER["PHP_SELF"], "cd.qty", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
  474. }
  475. if (!empty($arrayfields['cd.total_ht']['checked'])) {
  476. print_liste_field_titre($arrayfields['cd.total_ht']['label'], $_SERVER["PHP_SELF"], "cd.total_ht", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
  477. }
  478. if (!empty($arrayfields['cd.total_tva']['checked'])) {
  479. print_liste_field_titre($arrayfields['cd.total_tva']['label'], $_SERVER["PHP_SELF"], "cd.total_tva", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
  480. }
  481. if (!empty($arrayfields['s.nom']['checked'])) {
  482. print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, "", $sortfield, $sortorder);
  483. }
  484. if (!empty($arrayfields['cd.date_ouverture_prevue']['checked'])) {
  485. print_liste_field_titre($arrayfields['cd.date_ouverture_prevue']['label'], $_SERVER["PHP_SELF"], "cd.date_ouverture_prevue", "", $param, '', $sortfield, $sortorder, 'center ');
  486. }
  487. if (!empty($arrayfields['cd.date_ouverture']['checked'])) {
  488. print_liste_field_titre($arrayfields['cd.date_ouverture']['label'], $_SERVER["PHP_SELF"], "cd.date_ouverture", "", $param, '', $sortfield, $sortorder, 'center ');
  489. }
  490. if (!empty($arrayfields['cd.date_fin_validite']['checked'])) {
  491. print_liste_field_titre($arrayfields['cd.date_fin_validite']['label'], $_SERVER["PHP_SELF"], "cd.date_fin_validite", "", $param, '', $sortfield, $sortorder, 'center ');
  492. }
  493. if (!empty($arrayfields['cd.date_cloture']['checked'])) {
  494. print_liste_field_titre($arrayfields['cd.date_cloture']['label'], $_SERVER["PHP_SELF"], "cd.date_cloture", "", $param, '', $sortfield, $sortorder, 'center ');
  495. }
  496. // Extra fields
  497. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
  498. // Hook fields
  499. $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
  500. $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
  501. print $hookmanager->resPrint;
  502. if (!empty($arrayfields['cd.datec']['checked'])) {
  503. print_liste_field_titre($arrayfields['cd.datec']['label'], $_SERVER["PHP_SELF"], "cd.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
  504. }
  505. if (!empty($arrayfields['cd.tms']['checked'])) {
  506. print_liste_field_titre($arrayfields['cd.tms']['label'], $_SERVER["PHP_SELF"], "cd.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
  507. }
  508. if (!empty($arrayfields['status']['checked'])) {
  509. print_liste_field_titre($arrayfields['status']['label'], $_SERVER["PHP_SELF"], "cd.statut,c.statut", "", $param, '', $sortfield, $sortorder, 'right ');
  510. }
  511. print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
  512. print "</tr>\n";
  513. print '<tr class="liste_titre">';
  514. if (!empty($arrayfields['c.ref']['checked'])) {
  515. print '<td class="liste_titre">';
  516. print '<input type="hidden" name="filter" value="'.$filter.'">';
  517. print '<input type="hidden" name="mode" value="'.$mode.'">';
  518. print '<input type="text" class="flat" size="3" name="search_contract" value="'.dol_escape_htmltag($search_contract).'">';
  519. print '</td>';
  520. }
  521. // Service label
  522. if (!empty($arrayfields['p.description']['checked'])) {
  523. print '<td class="liste_titre">';
  524. print '<input type="text" class="flat maxwidth100" name="search_service" value="'.dol_escape_htmltag($search_service).'">';
  525. print '</td>';
  526. }
  527. // detail lines
  528. if (!empty($arrayfields['cd.tva_tx']['checked'])) {
  529. print '<td class="liste_titre">';
  530. print '</td>';
  531. }
  532. if (!empty($arrayfields['cd.subprice']['checked'])) {
  533. print '<td class="liste_titre">';
  534. print '</td>';
  535. }
  536. if (!empty($arrayfields['cd.qty']['checked'])) {
  537. print '<td class="liste_titre">';
  538. print '</td>';
  539. }
  540. if (!empty($arrayfields['cd.total_ht']['checked'])) {
  541. print '<td class="liste_titre">';
  542. print '</td>';
  543. }
  544. if (!empty($arrayfields['cd.total_tva']['checked'])) {
  545. print '<td class="liste_titre">';
  546. print '</td>';
  547. }
  548. // Third party
  549. if (!empty($arrayfields['s.nom']['checked'])) {
  550. print '<td class="liste_titre">';
  551. print '<input type="text" class="flat maxwidth100" name="search_name" value="'.dol_escape_htmltag($search_name).'">';
  552. print '</td>';
  553. }
  554. if (!empty($arrayfields['cd.date_ouverture_prevue']['checked'])) {
  555. print '<td class="liste_titre center">';
  556. $arrayofoperators = array('<'=>'<', '>'=>'>');
  557. print $form->selectarray('filter_opouvertureprevue', $arrayofoperators, $filter_opouvertureprevue, 1, 0, 0, '', 0, 0, 0, '', 'width50');
  558. print ' ';
  559. $filter_dateouvertureprevue = dol_mktime(0, 0, 0, $opouvertureprevuemonth, $opouvertureprevueday, $opouvertureprevueyear);
  560. print $form->selectDate($filter_dateouvertureprevue, 'opouvertureprevue', 0, 0, 1, '', 1, 0);
  561. print '</td>';
  562. }
  563. if (!empty($arrayfields['cd.date_ouverture']['checked'])) {
  564. print '<td class="liste_titre center">';
  565. $arrayofoperators = array('<'=>'<', '>'=>'>');
  566. print $form->selectarray('filter_op1', $arrayofoperators, $filter_op1, 1, 0, 0, '', 0, 0, 0, '', 'width50');
  567. print ' ';
  568. $filter_date1 = dol_mktime(0, 0, 0, $op1month, $op1day, $op1year);
  569. print $form->selectDate($filter_date1, 'op1', 0, 0, 1, '', 1, 0);
  570. print '</td>';
  571. }
  572. if (!empty($arrayfields['cd.date_fin_validite']['checked'])) {
  573. print '<td class="liste_titre center">';
  574. $arrayofoperators = array('<'=>'<', '>'=>'>');
  575. print $form->selectarray('filter_op2', $arrayofoperators, $filter_op2, 1, 0, 0, '', 0, 0, 0, '', 'width50');
  576. print ' ';
  577. $filter_date2 = dol_mktime(0, 0, 0, $op2month, $op2day, $op2year);
  578. print $form->selectDate($filter_date2, 'op2', 0, 0, 1, '', 1, 0);
  579. print '</td>';
  580. }
  581. if (!empty($arrayfields['cd.date_cloture']['checked'])) {
  582. print '<td class="liste_titre center">';
  583. $arrayofoperators = array('<'=>'<', '>'=>'>');
  584. print $form->selectarray('filter_opcloture', $arrayofoperators, $filter_opcloture, 1, 0, 0, '', 0, 0, 0, '', 'width50');
  585. print ' ';
  586. $filter_date_cloture = dol_mktime(0, 0, 0, $opcloturemonth, $opclotureday, $opclotureyear);
  587. print $form->selectDate($filter_date_cloture, 'opcloture', 0, 0, 1, '', 1, 0);
  588. print '</td>';
  589. }
  590. // Extra fields
  591. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
  592. // Fields from hook
  593. $parameters = array('arrayfields'=>$arrayfields);
  594. $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
  595. print $hookmanager->resPrint;
  596. if (!empty($arrayfields['cd.datec']['checked'])) {
  597. // Date creation
  598. print '<td class="liste_titre">';
  599. print '</td>';
  600. }
  601. if (!empty($arrayfields['cd.tms']['checked'])) {
  602. // Date modification
  603. print '<td class="liste_titre">';
  604. print '</td>';
  605. }
  606. if (!empty($arrayfields['status']['checked'])) {
  607. // Status
  608. print '<td class="liste_titre right">';
  609. $arrayofstatus = array(
  610. '0'=>$langs->trans("ServiceStatusInitial"),
  611. '4'=>$langs->trans("ServiceStatusRunning"),
  612. '4&filter=notexpired'=>$langs->trans("ServiceStatusNotLate"),
  613. '4&filter=expired'=>$langs->trans("ServiceStatusLate"),
  614. '5'=>$langs->trans("ServiceStatusClosed")
  615. );
  616. print $form->selectarray('search_status', $arrayofstatus, (strstr($search_status, ',') ?-1 : $search_status), 1, 0, 0, '', 0, 0, 0, '', 'maxwidth100');
  617. print '</td>';
  618. }
  619. // Action column
  620. print '<td class="liste_titre maxwidthsearch">';
  621. $searchpicto = $form->showFilterAndCheckAddButtons(0);
  622. print $searchpicto;
  623. print '</td>';
  624. print "</tr>\n";
  625. $contractstatic = new Contrat($db);
  626. $productstatic = new Product($db);
  627. $i = 0;
  628. $totalarray = array();
  629. while ($i < min($num, $limit)) {
  630. $obj = $db->fetch_object($resql);
  631. $contractstatic->id = $obj->cid;
  632. $contractstatic->ref = $obj->ref ? $obj->ref : $obj->cid;
  633. $contractstatic->ref_customer = $obj->ref_customer;
  634. $contractstatic->ref_supplier = $obj->ref_supplier;
  635. $companystatic->id = $obj->socid;
  636. $companystatic->name = $obj->name;
  637. $companystatic->email = $obj->email;
  638. $companystatic->client = $obj->client;
  639. $companystatic->fournisseur = $obj->fournisseur;
  640. print '<tr class="oddeven">';
  641. // Ref
  642. if (!empty($arrayfields['c.ref']['checked'])) {
  643. print '<td class="nowraponall">';
  644. print $contractstatic->getNomUrl(1, 16);
  645. print '</td>';
  646. if (!$i) {
  647. $totalarray['nbfield']++;
  648. }
  649. }
  650. // Service
  651. if (!empty($arrayfields['p.description']['checked'])) {
  652. print '<td>';
  653. if ($obj->pid > 0) {
  654. $productstatic->id = $obj->pid;
  655. $productstatic->type = $obj->ptype;
  656. $productstatic->ref = $obj->pref;
  657. $productstatic->entity = $obj->pentity;
  658. print $productstatic->getNomUrl(1, '', 24);
  659. print $obj->label ? ' - '.dol_trunc($obj->label, 16) : '';
  660. if (!empty($obj->description) && !empty($conf->global->PRODUCT_DESC_IN_LIST)) {
  661. print '<br>'.dol_nl2br($obj->description);
  662. }
  663. } else {
  664. if ($obj->type == 0) {
  665. print img_object($obj->description, 'product').' '.dol_trunc($obj->description, 24);
  666. }
  667. if ($obj->type == 1) {
  668. print img_object($obj->description, 'service').' '.dol_trunc($obj->description, 24);
  669. }
  670. }
  671. print '</td>';
  672. if (!$i) {
  673. $totalarray['nbfield']++;
  674. }
  675. }
  676. if (!empty($arrayfields['cd.tva_tx']['checked'])) {
  677. print '<td class="right">';
  678. print price2num($obj->tva_tx).'%';
  679. print '</td>';
  680. if (!$i) {
  681. $totalarray['nbfield']++;
  682. }
  683. }
  684. if (!empty($arrayfields['cd.subprice']['checked'])) {
  685. print '<td class="right">';
  686. print price($obj->subprice);
  687. print '</td>';
  688. if (!$i) {
  689. $totalarray['nbfield']++;
  690. }
  691. }
  692. if (!empty($arrayfields['cd.qty']['checked'])) {
  693. print '<td class="right">';
  694. print $obj->qty;
  695. print '</td>';
  696. if (!$i) {
  697. $totalarray['nbfield']++;
  698. }
  699. }
  700. if (!empty($arrayfields['cd.total_ht']['checked'])) {
  701. print '<td class="right">';
  702. print '<span class="amount">'.price($obj->total_ht).'</span>';
  703. print '</td>';
  704. if (!$i) {
  705. $totalarray['nbfield']++;
  706. }
  707. if (!$i) {
  708. $totalarray['pos'][$totalarray['nbfield']] = 'cd.total_ht';
  709. }
  710. $totalarray['val']['cd.total_ht'] += $obj->total_ht;
  711. }
  712. if (!empty($arrayfields['cd.total_tva']['checked'])) {
  713. print '<td class="right">';
  714. print '<span class="amount">'.price($obj->total_tva).'</span>';
  715. print '</td>';
  716. if (!$i) {
  717. $totalarray['nbfield']++;
  718. }
  719. if (!$i) {
  720. $totalarray['pos'][$totalarray['nbfield']] = 'cd.total_tva';
  721. }
  722. $totalarray['val']['cd.total_tva'] += $obj->total_tva;
  723. }
  724. // Third party
  725. if (!empty($arrayfields['s.nom']['checked'])) {
  726. print '<td class="tdoverflowmax100">';
  727. print $companystatic->getNomUrl(1, 'customer', 28);
  728. print '</td>';
  729. if (!$i) {
  730. $totalarray['nbfield']++;
  731. }
  732. }
  733. // Start date
  734. if (!empty($arrayfields['cd.date_ouverture_prevue']['checked'])) {
  735. print '<td class="center">';
  736. print ($obj->date_ouverture_prevue ?dol_print_date($db->jdate($obj->date_ouverture_prevue), 'dayhour') : '&nbsp;');
  737. if ($db->jdate($obj->date_ouverture_prevue) && ($db->jdate($obj->date_ouverture_prevue) < ($now - $conf->contrat->services->inactifs->warning_delay)) && $obj->statut == 0) {
  738. print ' '.img_picto($langs->trans("Late"), "warning");
  739. } else {
  740. print '&nbsp;&nbsp;&nbsp;&nbsp;';
  741. }
  742. print '</td>';
  743. if (!$i) {
  744. $totalarray['nbfield']++;
  745. }
  746. }
  747. if (!empty($arrayfields['cd.date_ouverture']['checked'])) {
  748. print '<td class="center">'.($obj->date_ouverture ?dol_print_date($db->jdate($obj->date_ouverture), 'dayhour') : '&nbsp;').'</td>';
  749. if (!$i) {
  750. $totalarray['nbfield']++;
  751. }
  752. }
  753. // End date
  754. if (!empty($arrayfields['cd.date_fin_validite']['checked'])) {
  755. print '<td class="center">'.($obj->date_fin_validite ?dol_print_date($db->jdate($obj->date_fin_validite), 'dayhour') : '&nbsp;');
  756. if ($obj->date_fin_validite && $db->jdate($obj->date_fin_validite) < ($now - $conf->contrat->services->expires->warning_delay) && $obj->statut < 5) {
  757. $warning_delay = $conf->contrat->services->expires->warning_delay / 3600 / 24;
  758. $textlate = $langs->trans("Late").' = '.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($warning_delay) >= 0 ? '+' : '').ceil($warning_delay).' '.$langs->trans("days");
  759. print img_warning($textlate);
  760. } else {
  761. print '&nbsp;&nbsp;&nbsp;&nbsp;';
  762. }
  763. print '</td>';
  764. if (!$i) {
  765. $totalarray['nbfield']++;
  766. }
  767. }
  768. // Close date (real end date)
  769. if (!empty($arrayfields['cd.date_cloture']['checked'])) {
  770. print '<td class="center">'.dol_print_date($db->jdate($obj->date_cloture), 'dayhour').'</td>';
  771. if (!$i) {
  772. $totalarray['nbfield']++;
  773. }
  774. }
  775. // Extra fields
  776. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
  777. // Fields from hook
  778. $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
  779. $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
  780. print $hookmanager->resPrint;
  781. // Date creation
  782. if (!empty($arrayfields['cd.datec']['checked'])) {
  783. print '<td class="center">';
  784. print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
  785. print '</td>';
  786. if (!$i) {
  787. $totalarray['nbfield']++;
  788. }
  789. }
  790. // Date modification
  791. if (!empty($arrayfields['cd.tms']['checked'])) {
  792. print '<td class="center">';
  793. print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
  794. print '</td>';
  795. if (!$i) {
  796. $totalarray['nbfield']++;
  797. }
  798. }
  799. // Status
  800. if (!empty($arrayfields['status']['checked'])) {
  801. print '<td class="right">';
  802. if ($obj->cstatut == 0) {
  803. // If contract is draft, we say line is also draft
  804. print $contractstatic->LibStatut(0, 5);
  805. } else {
  806. print $staticcontratligne->LibStatut($obj->statut, 5, ($obj->date_fin_validite && $db->jdate($obj->date_fin_validite) < $now) ? 1 : 0);
  807. }
  808. print '</td>';
  809. if (!$i) {
  810. $totalarray['nbfield']++;
  811. }
  812. }
  813. // Action column
  814. print '<td class="nowrap center">';
  815. if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  816. $selected = 0;
  817. if (in_array($obj->rowid, $arrayofselected)) {
  818. $selected = 1;
  819. }
  820. print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
  821. }
  822. print '</td>';
  823. if (!$i) {
  824. $totalarray['nbfield']++;
  825. }
  826. print "</tr>\n";
  827. $i++;
  828. }
  829. // Show total line
  830. include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
  831. $db->free($resql);
  832. $parameters = array('sql' => $sql);
  833. $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook
  834. print $hookmanager->resPrint;
  835. print '</table>';
  836. print '</div>';
  837. print '</form>';
  838. llxFooter();
  839. $db->close();