invoicetemplate_list.php 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942
  1. <?php
  2. /* Copyright (C) 2002-2003 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) 2013 Florian Henry <florian.henry@open-concept.pro>
  6. * Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
  7. * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
  8. * Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
  9. * Copyright (C) 2015-2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
  10. * Copyright (C) 2016 Meziane Sof <virtualsof@yahoo.fr>
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. * the Free Software Foundation; either version 3 of the License, or
  15. * (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  24. */
  25. /**
  26. * \file htdocs/compta/facture/invoicetemplate_list.php
  27. * \ingroup facture
  28. * \brief Page to show list of template/recurring invoices
  29. */
  30. require '../../main.inc.php';
  31. require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php';
  32. require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
  33. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
  34. require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  35. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
  36. require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
  37. require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php';
  38. require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
  39. require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
  40. // Load translation files required by the page
  41. $langs->loadLangs(array('bills', 'compta', 'admin', 'other'));
  42. $action = GETPOST('action', 'alpha');
  43. $massaction = GETPOST('massaction', 'alpha');
  44. $show_files = GETPOST('show_files', 'int');
  45. $confirm = GETPOST('confirm', 'alpha');
  46. $cancel = GETPOST('cancel', 'alpha');
  47. $toselect = GETPOST('toselect', 'array');
  48. $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'invoicetemplatelist'; // To manage different context of search
  49. $optioncss = GETPOST('optioncss', 'alpha');
  50. $socid = GETPOST('socid', 'int');
  51. // Security check
  52. $id = (GETPOST('facid', 'int') ?GETPOST('facid', 'int') : GETPOST('id', 'int'));
  53. $lineid = GETPOST('lineid', 'int');
  54. $ref = GETPOST('ref', 'alpha');
  55. if ($user->socid) {
  56. $socid = $user->socid;
  57. }
  58. $objecttype = 'facture_rec';
  59. if ($action == "create" || $action == "add") {
  60. $objecttype = '';
  61. }
  62. $result = restrictedArea($user, 'facture', $id, $objecttype);
  63. $search_ref = GETPOST('search_ref');
  64. $search_societe = GETPOST('search_societe');
  65. $search_montant_ht = GETPOST('search_montant_ht');
  66. $search_montant_vat = GETPOST('search_montant_vat');
  67. $search_montant_ttc = GETPOST('search_montant_ttc');
  68. $search_payment_mode = GETPOST('search_payment_mode');
  69. $search_payment_term = GETPOST('search_payment_term');
  70. $search_date_startday = GETPOST('search_date_startday', 'int');
  71. $search_date_startmonth = GETPOST('search_date_startmonth', 'int');
  72. $search_date_startyear = GETPOST('search_date_startyear', 'int');
  73. $search_date_endday = GETPOST('search_date_endday', 'int');
  74. $search_date_endmonth = GETPOST('search_date_endmonth', 'int');
  75. $search_date_endyear = GETPOST('search_date_endyear', 'int');
  76. $search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver
  77. $search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
  78. $search_date_when_startday = GETPOST('search_date_when_startday', 'int');
  79. $search_date_when_startmonth = GETPOST('search_date_when_startmonth', 'int');
  80. $search_date_when_startyear = GETPOST('search_date_when_startyear', 'int');
  81. $search_date_when_endday = GETPOST('search_date_when_endday', 'int');
  82. $search_date_when_endmonth = GETPOST('search_date_when_endmonth', 'int');
  83. $search_date_when_endyear = GETPOST('search_date_when_endyear', 'int');
  84. $search_date_when_start = dol_mktime(0, 0, 0, $search_date_when_startmonth, $search_date_when_startday, $search_date_when_startyear); // Use tzserver
  85. $search_date_when_end = dol_mktime(23, 59, 59, $search_date_when_endmonth, $search_date_when_endday, $search_date_when_endyear);
  86. $search_recurring = GETPOST('search_recurring', 'int');
  87. $search_frequency = GETPOST('search_frequency', 'alpha');
  88. $search_unit_frequency = GETPOST('search_unit_frequency', 'alpha');
  89. $search_status = GETPOST('search_status', 'int');
  90. $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
  91. $sortfield = GETPOST('sortfield', 'aZ09comma');
  92. $sortorder = GETPOST('sortorder', 'aZ09comma');
  93. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  94. if (empty($page) || $page == -1) {
  95. $page = 0;
  96. } // If $page is not defined, or '' or -1
  97. $offset = $limit * $page;
  98. if (!$sortorder) {
  99. $sortorder = 'DESC';
  100. }
  101. if (!$sortfield) {
  102. $sortfield = 'f.titre';
  103. }
  104. $pageprev = $page - 1;
  105. $pagenext = $page + 1;
  106. $object = new FactureRec($db);
  107. if (($id > 0 || $ref) && $action != 'create' && $action != 'add') {
  108. $ret = $object->fetch($id, $ref);
  109. if (!$ret) {
  110. setEventMessages($langs->trans("ErrorRecordNotFound"), null, 'errors');
  111. }
  112. }
  113. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  114. $hookmanager->initHooks(array('invoicereclist'));
  115. $extrafields = new ExtraFields($db);
  116. // fetch optionals attributes and labels
  117. $extrafields->fetch_name_optionals_label($object->table_element);
  118. $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
  119. $permissionnote = $user->rights->facture->creer; // Used by the include of actions_setnotes.inc.php
  120. $permissiondellink = $user->rights->facture->creer; // Used by the include of actions_dellink.inc.php
  121. $permissiontoedit = $user->rights->facture->creer; // Used by the include of actions_lineupdonw.inc.php
  122. $arrayfields = array(
  123. 'f.titre'=>array('label'=>"Ref", 'checked'=>1),
  124. 's.nom'=>array('label'=>"ThirdParty", 'checked'=>1),
  125. 'f.total_ht'=>array('label'=>"AmountHT", 'checked'=>1),
  126. 'f.total_tva'=>array('label'=>"AmountVAT", 'checked'=>1),
  127. 'f.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>1),
  128. 'f.fk_mode_reglement'=>array('label'=>"PaymentMode", 'checked'=>0),
  129. 'f.fk_cond_reglement'=>array('label'=>"PaymentTerm", 'checked'=>0),
  130. 'recurring'=>array('label'=>"RecurringInvoice", 'checked'=>1),
  131. 'f.frequency'=>array('label'=>"Frequency", 'checked'=>1),
  132. 'f.unit_frequency'=>array('label'=>"FrequencyUnit", 'checked'=>1),
  133. 'f.nb_gen_done'=>array('label'=>"NbOfGenerationDoneShort", 'checked'=>1),
  134. 'f.date_last_gen'=>array('label'=>"DateLastGenerationShort", 'checked'=>1),
  135. 'f.date_when'=>array('label'=>"NextDateToExecutionShort", 'checked'=>1),
  136. 'f.fk_user_author'=>array('label'=>"UserCreation", 'checked'=>0, 'position'=>500),
  137. 'f.fk_user_modif'=>array('label'=>"UserModification", 'checked'=>0, 'position'=>505),
  138. 'f.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>520),
  139. 'f.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>525),
  140. 'status'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000),
  141. );
  142. // Extra fields
  143. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
  144. $object->fields = dol_sort_array($object->fields, 'position');
  145. $arrayfields = dol_sort_array($arrayfields, 'position');
  146. if ($socid > 0) {
  147. $tmpthirdparty = new Societe($db);
  148. $res = $tmpthirdparty->fetch($socid);
  149. if ($res > 0) {
  150. $search_societe = $tmpthirdparty->name;
  151. }
  152. }
  153. if ($socid > 0) {
  154. $tmpthirdparty = new Societe($db);
  155. $res = $tmpthirdparty->fetch($socid);
  156. if ($res > 0) {
  157. $search_societe = $tmpthirdparty->name;
  158. }
  159. }
  160. $objecttype = 'facture_rec';
  161. $result = restrictedArea($user, 'facture', $object->id, $objecttype);
  162. /*
  163. * Actions
  164. */
  165. if (GETPOST('cancel', 'alpha')) {
  166. $action = 'list';
  167. $massaction = '';
  168. }
  169. if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
  170. $massaction = '';
  171. }
  172. $parameters = array('socid' => $socid);
  173. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  174. if ($reshook < 0) {
  175. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  176. }
  177. if (empty($reshook)) {
  178. if (GETPOST('cancel', 'alpha')) {
  179. $action = '';
  180. }
  181. // Selection of new fields
  182. include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
  183. // Do we click on purge search criteria ?
  184. 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
  185. $search_ref = '';
  186. $search_societe = '';
  187. $search_montant_ht = '';
  188. $search_montant_vat = '';
  189. $search_montant_ttc = '';
  190. $search_payment_mode = '';
  191. $search_payment_term = '';
  192. $search_date_startday = '';
  193. $search_date_startmonth = '';
  194. $search_date_startyear = '';
  195. $search_date_endday = '';
  196. $search_date_endmonth = '';
  197. $search_date_endyear = '';
  198. $search_date_start = '';
  199. $search_date_end = '';
  200. $search_date_when_startday = '';
  201. $search_date_when_startmonth = '';
  202. $search_date_when_startyear = '';
  203. $search_date_when_endday = '';
  204. $search_date_when_endmonth = '';
  205. $search_date_when_endyear = '';
  206. $search_date_when_start = '';
  207. $search_date_when_end = '';
  208. $search_recurring = '';
  209. $search_frequency = '';
  210. $search_unit_frequency = '';
  211. $search_status = '';
  212. $search_array_options = array();
  213. }
  214. // Mass actions
  215. /*$objectclass='MyObject';
  216. $objectlabel='MyObject';
  217. $permissiontoread = $user->rights->mymodule->read;
  218. $permissiontodelete = $user->rights->mymodule->delete;
  219. $uploaddir = $conf->mymodule->dir_output;
  220. include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';*/
  221. }
  222. /*
  223. * View
  224. */
  225. llxHeader('', $langs->trans("RepeatableInvoices"), 'ch-facture.html#s-fac-facture-rec');
  226. $form = new Form($db);
  227. $formother = new FormOther($db);
  228. if (!empty($conf->projet->enabled)) {
  229. $formproject = new FormProjets($db);
  230. }
  231. $companystatic = new Societe($db);
  232. $invoicerectmp = new FactureRec($db);
  233. $tmpuser = new User($db);
  234. $now = dol_now();
  235. $tmparray = dol_getdate($now);
  236. $today = dol_mktime(23, 59, 59, $tmparray['mon'], $tmparray['mday'], $tmparray['year']); // Today is last second of current day
  237. /*
  238. * List mode
  239. */
  240. $sql = "SELECT s.nom as name, s.rowid as socid, f.rowid as facid, f.titre as title, f.total_ht, f.total_tva, f.total_ttc, f.frequency, f.unit_frequency,";
  241. $sql .= " f.nb_gen_done, f.nb_gen_max, f.date_last_gen, f.date_when, f.suspended,";
  242. $sql .= " f.datec, f.fk_user_author, f.tms, f.fk_user_modif,";
  243. $sql .= " f.fk_cond_reglement, f.fk_mode_reglement";
  244. // Add fields from extrafields
  245. if (!empty($extrafields->attributes[$object->table_element]['label'])) {
  246. foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
  247. $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
  248. }
  249. }
  250. // Add fields from hooks
  251. $parameters = array();
  252. $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
  253. $sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
  254. $sql = preg_replace('/,\s*$/', '', $sql);
  255. $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_rec as f";
  256. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture_rec_extrafields as ef ON ef.fk_object = f.rowid";
  257. if (empty($user->rights->societe->client->voir) && !$socid) {
  258. $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
  259. }
  260. $sql .= " WHERE f.fk_soc = s.rowid";
  261. $sql .= ' AND f.entity IN ('.getEntity('invoice').')';
  262. if (empty($user->rights->societe->client->voir) && !$socid) {
  263. $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
  264. }
  265. if ($search_ref) {
  266. $sql .= natural_search('f.titre', $search_ref);
  267. }
  268. if ($socid) {
  269. $sql .= ' AND s.rowid = '.(int) $socid;
  270. }
  271. if ($search_societe) {
  272. $sql .= natural_search('s.nom', $search_societe);
  273. }
  274. if ($search_montant_ht != '') {
  275. $sql .= natural_search('f.total_ht', $search_montant_ht, 1);
  276. }
  277. if ($search_montant_vat != '') {
  278. $sql .= natural_search('f.total_tva', $search_montant_vat, 1);
  279. }
  280. if ($search_montant_ttc != '') {
  281. $sql .= natural_search('f.total_ttc', $search_montant_ttc, 1);
  282. }
  283. if (!empty($search_payment_mode) && $search_payment_mode != '-1') {
  284. $sql .= natural_search('f.fk_mode_reglement', $search_payment_mode, 1);
  285. }
  286. if (!empty($search_payment_term) && $search_payment_term != '-1') {
  287. $sql .= natural_search('f.fk_cond_reglement', $search_payment_term, 1);
  288. }
  289. if ($search_recurring == '1') {
  290. $sql .= ' AND f.frequency > 0';
  291. }
  292. if ($search_recurring == '0') {
  293. $sql .= ' AND (f.frequency IS NULL or f.frequency = 0)';
  294. }
  295. if ($search_frequency != '') {
  296. $sql .= natural_search('f.frequency', $search_frequency, 1);
  297. }
  298. if ($search_unit_frequency != '') {
  299. $sql .= ' AND f.frequency > 0'.natural_search('f.unit_frequency', $search_unit_frequency);
  300. }
  301. if ($search_status != '' && $search_status >= -1) {
  302. if ($search_status == 0) {
  303. $sql .= ' AND frequency = 0 AND suspended = 0';
  304. }
  305. if ($search_status == 1) {
  306. $sql .= ' AND frequency != 0 AND suspended = 0';
  307. }
  308. if ($search_status == -1) {
  309. $sql .= ' AND suspended = 1';
  310. }
  311. }
  312. if ($search_date_start) {
  313. $sql .= " AND f.date_last_gen >= '".$db->idate($search_date_start)."'";
  314. }
  315. if ($search_date_end) {
  316. $sql .= " AND f.date_last_gen <= '".$db->idate($search_date_end)."'";
  317. }
  318. if ($search_date_when_start) {
  319. $sql .= " AND f.date_when >= '".$db->idate($search_date_when_start)."'";
  320. }
  321. if ($search_date_when_end) {
  322. $sql .= " AND f.date_when <= '".$db->idate($search_date_when_end)."'";
  323. }
  324. $tmpsortfield = $sortfield;
  325. if ($tmpsortfield == 'recurring') {
  326. $tmpsortfield = 'f.frequency';
  327. }
  328. $sql .= $db->order($tmpsortfield, $sortorder);
  329. $nbtotalofrecords = '';
  330. if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
  331. $result = $db->query($sql);
  332. $nbtotalofrecords = $db->num_rows($result);
  333. if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
  334. $page = 0;
  335. $offset = 0;
  336. }
  337. }
  338. $sql .= $db->plimit($limit + 1, $offset);
  339. $resql = $db->query($sql);
  340. if ($resql) {
  341. $num = $db->num_rows($resql);
  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='.urlencode($limit);
  348. }
  349. if ($socid > 0) {
  350. $param .= '&socid='.urlencode($socid);
  351. }
  352. if ($search_date_startday) {
  353. $param .= '&search_date_startday='.urlencode($search_date_startday);
  354. }
  355. if ($search_date_startmonth) {
  356. $param .= '&search_date_startmonth='.urlencode($search_date_startmonth);
  357. }
  358. if ($search_date_startyear) {
  359. $param .= '&search_date_startyear='.urlencode($search_date_startyear);
  360. }
  361. if ($search_date_endday) {
  362. $param .= '&search_date_endday='.urlencode($search_date_endday);
  363. }
  364. if ($search_date_endmonth) {
  365. $param .= '&search_date_endmonth='.urlencode($search_date_endmonth);
  366. }
  367. if ($search_date_endyear) {
  368. $param .= '&search_date_endyear='.urlencode($search_date_endyear);
  369. }
  370. if ($search_date_when_startday) {
  371. $param .= '&search_date_when_startday='.urlencode($search_date_when_startday);
  372. }
  373. if ($search_date_when_startmonth) {
  374. $param .= '&search_date_when_startmonth='.urlencode($search_date_when_startmonth);
  375. }
  376. if ($search_date_when_startyear) {
  377. $param .= '&search_date_when_startyear='.urlencode($search_date_when_startyear);
  378. }
  379. if ($search_date_when_endday) {
  380. $param .= '&search_date_when_endday='.urlencode($search_date_when_endday);
  381. }
  382. if ($search_date_when_endmonth) {
  383. $param .= '&search_date_when_endmonth='.urlencode($search_date_when_endmonth);
  384. }
  385. if ($search_date_when_endyear) {
  386. $param .= '&search_date_when_endyear='.urlencode($search_date_when_endyear);
  387. }
  388. if ($search_ref) {
  389. $param .= '&search_ref='.urlencode($search_ref);
  390. }
  391. if ($search_societe) {
  392. $param .= '&search_societe='.urlencode($search_societe);
  393. }
  394. if ($search_montant_ht != '') {
  395. $param .= '&search_montant_ht='.urlencode($search_montant_ht);
  396. }
  397. if ($search_montant_vat != '') {
  398. $param .= '&search_montant_vat='.urlencode($search_montant_vat);
  399. }
  400. if ($search_montant_ttc != '') {
  401. $param .= '&search_montant_ttc='.urlencode($search_montant_ttc);
  402. }
  403. if ($search_payment_mode != '') {
  404. $param .= '&search_payment_mode='.urlencode($search_payment_mode);
  405. }
  406. if ($search_payment_term != '') {
  407. $param .= '&search_payment_term='.urlencode($search_payment_term);
  408. }
  409. if ($search_recurring != '' && $search_recurring != '-1') {
  410. $param .= '&search_recurring='.urlencode($search_recurring);
  411. }
  412. if ($search_frequency > 0) {
  413. $param .= '&search_frequency='.urlencode($search_frequency);
  414. }
  415. if ($search_unit_frequency != '') {
  416. $param .= '&search_unit_frequency='.urlencode($search_unit_frequency);
  417. }
  418. if ($search_status != '') {
  419. $param .= '&search_status='.urlencode($search_status);
  420. }
  421. if ($optioncss != '') {
  422. $param .= '&optioncss='.urlencode($optioncss);
  423. }
  424. // Add $param from extra fields
  425. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
  426. $massactionbutton = $form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge")));
  427. $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
  428. $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
  429. //$selectedfields.=$form->showCheckAddButtons('checkforselect', 1);
  430. print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
  431. if ($optioncss != '') {
  432. print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  433. }
  434. print '<input type="hidden" name="token" value="'.newToken().'">';
  435. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  436. print '<input type="hidden" name="action" value="list">';
  437. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  438. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  439. print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
  440. print '<input type="hidden" name="search_status" value="'.$search_status.'">';
  441. $title = $langs->trans("RepeatableInvoices");
  442. print_barre_liste($title, $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'bill', 0, '', '', $limit, 0, 0, 1);
  443. print '<span class="opacitymedium">'.$langs->trans("ToCreateAPredefinedInvoice", $langs->transnoentitiesnoconv("ChangeIntoRepeatableInvoice")).'</span><br><br>';
  444. $i = 0;
  445. $moreforfilter = '';
  446. print '<div class="div-table-responsive">';
  447. print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
  448. // Filters lines
  449. print '<tr class="liste_titre_filter">';
  450. // Ref
  451. if (!empty($arrayfields['f.titre']['checked'])) {
  452. print '<td class="liste_titre left">';
  453. print '<input class="flat maxwidth100" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
  454. print '</td>';
  455. }
  456. // Thirdparty
  457. if (!empty($arrayfields['s.nom']['checked'])) {
  458. print '<td class="liste_titre left"><input class="flat" type="text" size="8" name="search_societe" value="'.dol_escape_htmltag($search_societe).'"></td>';
  459. }
  460. if (!empty($arrayfields['f.total_ht']['checked'])) {
  461. // Amount net
  462. print '<td class="liste_titre right">';
  463. print '<input class="flat" type="text" size="5" name="search_montant_ht" value="'.dol_escape_htmltag($search_montant_ht).'">';
  464. print '</td>';
  465. }
  466. if (!empty($arrayfields['f.total_tva']['checked'])) {
  467. // Amount Vat
  468. print '<td class="liste_titre right">';
  469. print '<input class="flat" type="text" size="5" name="search_montant_vat" value="'.dol_escape_htmltag($search_montant_vat).'">';
  470. print '</td>';
  471. }
  472. if (!empty($arrayfields['f.total_ttc']['checked'])) {
  473. // Amount
  474. print '<td class="liste_titre right">';
  475. print '<input class="flat" type="text" size="5" name="search_montant_ttc" value="'.dol_escape_htmltag($search_montant_ttc).'">';
  476. print '</td>';
  477. }
  478. if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) {
  479. // Payment term
  480. print '<td class="liste_titre right">';
  481. $form->select_conditions_paiements($search_payment_term, 'search_payment_term', -1, 1, 1, 'maxwidth100');
  482. print "</td>";
  483. }
  484. if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) {
  485. // Payment mode
  486. print '<td class="liste_titre right">';
  487. $form->select_types_paiements($search_payment_mode, 'search_payment_mode', '', 0, 1, 1, 0, 1, 'maxwidth100');
  488. print '</td>';
  489. }
  490. if (!empty($arrayfields['recurring']['checked'])) {
  491. // Recurring or not
  492. print '<td class="liste_titre center">';
  493. print $form->selectyesno('search_recurring', $search_recurring, 1, false, 1);
  494. print '</td>';
  495. }
  496. if (!empty($arrayfields['f.frequency']['checked'])) {
  497. // Recurring or not
  498. print '<td class="liste_titre center">';
  499. print '<input class="flat" type="text" size="1" name="search_frequency" value="'.dol_escape_htmltag($search_frequency).'">';
  500. print '</td>';
  501. }
  502. if (!empty($arrayfields['f.unit_frequency']['checked'])) {
  503. // Frequency unit
  504. print '<td class="liste_titre center">';
  505. print '<input class="flat" type="text" size="1" name="search_unit_frequency" value="'.dol_escape_htmltag($search_unit_frequency).'">';
  506. print '</td>';
  507. }
  508. if (!empty($arrayfields['f.nb_gen_done']['checked'])) {
  509. // Nb generation
  510. print '<td class="liste_titre" align="center">';
  511. print '</td>';
  512. }
  513. // Date invoice
  514. if (!empty($arrayfields['f.date_last_gen']['checked'])) {
  515. print '<td class="liste_titre center">';
  516. print '<div class="nowrap">';
  517. print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
  518. print '</div>';
  519. print '<div class="nowrap">';
  520. print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
  521. print '</div>';
  522. print '</td>';
  523. }
  524. // Date next generation
  525. if (!empty($arrayfields['f.date_when']['checked'])) {
  526. print '<td class="liste_titre center">';
  527. print '<div class="nowrap">';
  528. print $form->selectDate($search_date_when_start ? $search_date_when_start : -1, 'search_date_when_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
  529. print '</div>';
  530. print '<div class="nowrap">';
  531. print $form->selectDate($search_date_when_end ? $search_date_when_end : -1, 'search_date_when_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
  532. print '</div>';
  533. print '</td>';
  534. }
  535. // Extra fields
  536. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
  537. // Fields from hook
  538. $parameters = array('arrayfields'=>$arrayfields);
  539. $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
  540. print $hookmanager->resPrint;
  541. // User creation
  542. if (!empty($arrayfields['f.fk_user_author']['checked'])) {
  543. print '<td class="liste_titre">';
  544. print '</td>';
  545. }
  546. // User modification
  547. if (!empty($arrayfields['f.fk_user_modif']['checked'])) {
  548. print '<td class="liste_titre">';
  549. print '</td>';
  550. }
  551. // Date creation
  552. if (!empty($arrayfields['f.datec']['checked'])) {
  553. print '<td class="liste_titre">';
  554. print '</td>';
  555. }
  556. // Date modification
  557. if (!empty($arrayfields['f.tms']['checked'])) {
  558. print '<td class="liste_titre">';
  559. print '</td>';
  560. }
  561. // Status
  562. if (!empty($arrayfields['status']['checked'])) {
  563. print '<td class="liste_titre center">';
  564. $liststatus = array(
  565. 0=>$langs->trans("Draft"),
  566. 1=>$langs->trans("Active"),
  567. -1=>$langs->trans("Disabled"),
  568. );
  569. print $form->selectarray('search_status', $liststatus, $search_status, -2, 0, 0, '', 0, 0, 0, '', 'width100');
  570. print '</td>';
  571. }
  572. // Action column
  573. print '<td class="liste_titre" align="middle">';
  574. $searchpicto = $form->showFilterButtons();
  575. print $searchpicto;
  576. print '</td>';
  577. print "</tr>\n";
  578. print '<tr class="liste_titre">';
  579. if (!empty($arrayfields['f.titre']['checked'])) {
  580. print_liste_field_titre($arrayfields['f.titre']['label'], $_SERVER['PHP_SELF'], "f.titre", "", $param, "", $sortfield, $sortorder);
  581. }
  582. if (!empty($arrayfields['s.nom']['checked'])) {
  583. print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER['PHP_SELF'], "s.nom", "", $param, "", $sortfield, $sortorder);
  584. }
  585. if (!empty($arrayfields['f.total_ht']['checked'])) {
  586. print_liste_field_titre($arrayfields['f.total_ht']['label'], $_SERVER['PHP_SELF'], "f.total_ht", "", $param, 'class="right"', $sortfield, $sortorder);
  587. }
  588. if (!empty($arrayfields['f.total_tva']['checked'])) {
  589. print_liste_field_titre($arrayfields['f.total_tva']['label'], $_SERVER['PHP_SELF'], "f.total_tva", "", $param, 'class="right"', $sortfield, $sortorder);
  590. }
  591. if (!empty($arrayfields['f.total_ttc']['checked'])) {
  592. print_liste_field_titre($arrayfields['f.total_ttc']['label'], $_SERVER['PHP_SELF'], "f.total_ttc", "", $param, 'class="right"', $sortfield, $sortorder);
  593. }
  594. if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) {
  595. print_liste_field_titre($arrayfields['f.fk_cond_reglement']['label'], $_SERVER['PHP_SELF'], "f.fk_cond_reglement", "", $param, '', $sortfield, $sortorder);
  596. }
  597. if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) {
  598. print_liste_field_titre($arrayfields['f.fk_mode_reglement']['label'], $_SERVER['PHP_SELF'], "f.fk_mode_reglement", "", $param, '', $sortfield, $sortorder);
  599. }
  600. if (!empty($arrayfields['recurring']['checked'])) {
  601. print_liste_field_titre($arrayfields['recurring']['label'], $_SERVER['PHP_SELF'], "recurring", "", $param, 'class="center"', $sortfield, $sortorder);
  602. }
  603. if (!empty($arrayfields['f.frequency']['checked'])) {
  604. print_liste_field_titre($arrayfields['f.frequency']['label'], $_SERVER['PHP_SELF'], "f.frequency", "", $param, 'align="center"', $sortfield, $sortorder);
  605. }
  606. if (!empty($arrayfields['f.unit_frequency']['checked'])) {
  607. print_liste_field_titre($arrayfields['f.unit_frequency']['label'], $_SERVER['PHP_SELF'], "f.unit_frequency", "", $param, 'align="center"', $sortfield, $sortorder);
  608. }
  609. if (!empty($arrayfields['f.nb_gen_done']['checked'])) {
  610. print_liste_field_titre($arrayfields['f.nb_gen_done']['label'], $_SERVER['PHP_SELF'], "f.nb_gen_done", "", $param, 'align="center"', $sortfield, $sortorder);
  611. }
  612. if (!empty($arrayfields['f.date_last_gen']['checked'])) {
  613. print_liste_field_titre($arrayfields['f.date_last_gen']['label'], $_SERVER['PHP_SELF'], "f.date_last_gen", "", $param, 'align="center"', $sortfield, $sortorder);
  614. }
  615. if (!empty($arrayfields['f.date_when']['checked'])) {
  616. print_liste_field_titre($arrayfields['f.date_when']['label'], $_SERVER['PHP_SELF'], "f.date_when", "", $param, 'align="center"', $sortfield, $sortorder);
  617. }
  618. if (!empty($arrayfields['f.fk_user_author']['checked'])) {
  619. print_liste_field_titre($arrayfields['f.fk_user_author']['label'], $_SERVER['PHP_SELF'], "f.fk_user_author", "", $param, 'align="center"', $sortfield, $sortorder);
  620. }
  621. if (!empty($arrayfields['f.fk_user_modif']['checked'])) {
  622. print_liste_field_titre($arrayfields['f.fk_user_modif']['label'], $_SERVER['PHP_SELF'], "f.fk_user_modif", "", $param, 'align="center"', $sortfield, $sortorder);
  623. }
  624. if (!empty($arrayfields['f.datec']['checked'])) {
  625. print_liste_field_titre($arrayfields['f.datec']['label'], $_SERVER['PHP_SELF'], "f.datec", "", $param, 'align="center"', $sortfield, $sortorder);
  626. }
  627. if (!empty($arrayfields['f.tms']['checked'])) {
  628. print_liste_field_titre($arrayfields['f.tms']['label'], $_SERVER['PHP_SELF'], "f.tms", "", $param, 'align="center"', $sortfield, $sortorder);
  629. }
  630. // Extra fields
  631. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
  632. if (!empty($arrayfields['status']['checked'])) {
  633. print_liste_field_titre($arrayfields['status']['label'], $_SERVER['PHP_SELF'], "f.suspended,f.frequency", "", $param, 'align="center"', $sortfield, $sortorder);
  634. }
  635. print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'center maxwidthsearch ');
  636. print "</tr>\n";
  637. if ($num > 0) {
  638. $i = 0;
  639. $totalarray = array();
  640. $totalarray['nbfield'] = 0;
  641. $totalarray['val']['f.total_ht'] = 0;
  642. $totalarray['val']['f.total_tva'] = 0;
  643. $totalarray['val']['f.total_ttc'] = 0;
  644. while ($i < min($num, $limit)) {
  645. $objp = $db->fetch_object($resql);
  646. if (empty($objp)) {
  647. break;
  648. }
  649. $companystatic->id = $objp->socid;
  650. $companystatic->name = $objp->name;
  651. $invoicerectmp->id = !empty($objp->id) ? $objp->id : $objp->facid;
  652. $invoicerectmp->frequency = $objp->frequency;
  653. $invoicerectmp->suspended = $objp->suspended;
  654. $invoicerectmp->unit_frequency = $objp->unit_frequency;
  655. $invoicerectmp->nb_gen_max = $objp->nb_gen_max;
  656. $invoicerectmp->nb_gen_done = $objp->nb_gen_done;
  657. $invoicerectmp->ref = $objp->title;
  658. $invoicerectmp->total_ht = $objp->total_ht;
  659. $invoicerectmp->total_tva = $objp->total_tva;
  660. $invoicerectmp->total_ttc = $objp->total_ttc;
  661. print '<tr class="oddeven">';
  662. if (!empty($arrayfields['f.titre']['checked'])) {
  663. print '<td class="nowrap tdoverflowmax200">';
  664. print $invoicerectmp->getNomUrl(1);
  665. print "</a>";
  666. print "</td>\n";
  667. if (!$i) {
  668. $totalarray['nbfield']++;
  669. }
  670. }
  671. if (!empty($arrayfields['s.nom']['checked'])) {
  672. print '<td class="tdoverflowmax200">'.$companystatic->getNomUrl(1, 'customer').'</td>';
  673. if (!$i) {
  674. $totalarray['nbfield']++;
  675. }
  676. }
  677. if (!empty($arrayfields['f.total_ht']['checked'])) {
  678. print '<td class="nowrap right amount">'.price($objp->total_ht).'</td>'."\n";
  679. if (!$i) {
  680. $totalarray['nbfield']++;
  681. }
  682. if (!$i) {
  683. $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ht';
  684. }
  685. $totalarray['val']['f.total_ht'] += $objp->total_ht;
  686. }
  687. if (!empty($arrayfields['f.total_tva']['checked'])) {
  688. print '<td class="nowrap right amount">'.price($objp->total_tva).'</td>'."\n";
  689. if (!$i) {
  690. $totalarray['nbfield']++;
  691. }
  692. if (!$i) {
  693. $totalarray['pos'][$totalarray['nbfield']] = 'f.total_tva';
  694. }
  695. $totalarray['val']['f.total_tva'] += $objp->total_tva;
  696. }
  697. if (!empty($arrayfields['f.total_ttc']['checked'])) {
  698. print '<td class="nowrap right amount">'.price($objp->total_ttc).'</td>'."\n";
  699. if (!$i) {
  700. $totalarray['nbfield']++;
  701. }
  702. if (!$i) {
  703. $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ttc';
  704. }
  705. $totalarray['val']['f.total_ttc'] += $objp->total_ttc;
  706. }
  707. // Payment term
  708. if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) {
  709. print '<td class="right">';
  710. $form->form_conditions_reglement('', $objp->fk_cond_reglement, 'none');
  711. print '</td>'."\n";
  712. if (!$i) {
  713. $totalarray['nbfield']++;
  714. }
  715. }
  716. // Payment mode
  717. if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) {
  718. print '<td class="right">';
  719. $form->form_modes_reglement('', $objp->fk_mode_reglement, 'none');
  720. print '</td>'."\n";
  721. if (!$i) {
  722. $totalarray['nbfield']++;
  723. }
  724. }
  725. // Is it a recurring invoice
  726. if (!empty($arrayfields['recurring']['checked'])) {
  727. print '<td class="center">'.($objp->frequency ? img_picto($langs->trans("Frequency").': '.$objp->frequency.' '.$objp->unit_frequency, 'recurring', 'class="opacitymedium"').' ' : '').yn($objp->frequency ? 1 : 0).'</td>';
  728. if (!$i) {
  729. $totalarray['nbfield']++;
  730. }
  731. }
  732. if (!empty($arrayfields['f.frequency']['checked'])) {
  733. print '<td class="center">'.($objp->frequency > 0 ? $objp->frequency : '').'</td>';
  734. if (!$i) {
  735. $totalarray['nbfield']++;
  736. }
  737. }
  738. if (!empty($arrayfields['f.unit_frequency']['checked'])) {
  739. print '<td class="center">'.($objp->frequency > 0 ? $objp->unit_frequency : '').'</td>';
  740. if (!$i) {
  741. $totalarray['nbfield']++;
  742. }
  743. }
  744. if (!empty($arrayfields['f.nb_gen_done']['checked'])) {
  745. print '<td class="center">';
  746. print ($objp->frequency > 0 ? $objp->nb_gen_done.($objp->nb_gen_max > 0 ? ' / '.$objp->nb_gen_max : '') : '<span class="opacitymedium">'.$langs->trans('NA').'</span>');
  747. print '</td>';
  748. if (!$i) {
  749. $totalarray['nbfield']++;
  750. }
  751. }
  752. // Date last generation
  753. if (!empty($arrayfields['f.date_last_gen']['checked'])) {
  754. print '<td class="center">';
  755. print ($objp->frequency > 0 ? dol_print_date($db->jdate($objp->date_last_gen), 'day') : '<span class="opacitymedium">'.$langs->trans('NA').'</span>');
  756. print '</td>';
  757. if (!$i) {
  758. $totalarray['nbfield']++;
  759. }
  760. }
  761. // Date next generation
  762. if (!empty($arrayfields['f.date_when']['checked'])) {
  763. print '<td class="center">';
  764. print '<div class="nowraponall">';
  765. print ($objp->frequency ? ($invoicerectmp->isMaxNbGenReached() ? '<strike>' : '').dol_print_date($db->jdate($objp->date_when), 'day').($invoicerectmp->isMaxNbGenReached() ? '</strike>' : '') : '<span class="opacitymedium">'.$langs->trans('NA').'</span>');
  766. if (!$invoicerectmp->isMaxNbGenReached()) {
  767. if (!$objp->suspended && $objp->frequency > 0 && $db->jdate($objp->date_when) && $db->jdate($objp->date_when) < $now) {
  768. print img_warning($langs->trans("Late"));
  769. }
  770. } else {
  771. print img_info($langs->trans("MaxNumberOfGenerationReached"));
  772. }
  773. print '</div>';
  774. print '</td>';
  775. if (!$i) {
  776. $totalarray['nbfield']++;
  777. }
  778. }
  779. if (!empty($arrayfields['f.fk_user_author']['checked'])) {
  780. print '<td class="center tdoverflowmax150">';
  781. if ($objp->fk_user_author > 0) {
  782. $tmpuser->fetch($objp->fk_user_author);
  783. print $tmpuser->getNomUrl(1);
  784. }
  785. print '</td>';
  786. if (!$i) {
  787. $totalarray['nbfield']++;
  788. }
  789. }
  790. if (!empty($arrayfields['f.fk_user_modif']['checked'])) {
  791. print '<td class="center tdoverflowmax150">';
  792. if ($objp->fk_user_author > 0) {
  793. $tmpuser->fetch($objp->fk_user_author);
  794. print $tmpuser->getNomUrl(1);
  795. }
  796. print '</td>';
  797. if (!$i) {
  798. $totalarray['nbfield']++;
  799. }
  800. }
  801. if (!empty($arrayfields['f.datec']['checked'])) {
  802. print '<td class="center">';
  803. print dol_print_date($db->jdate($objp->datec), 'dayhour');
  804. print '</td>';
  805. if (!$i) {
  806. $totalarray['nbfield']++;
  807. }
  808. }
  809. if (!empty($arrayfields['f.tms']['checked'])) {
  810. print '<td class="center">';
  811. print dol_print_date($db->jdate($objp->tms), 'dayhour');
  812. print '</td>';
  813. if (!$i) {
  814. $totalarray['nbfield']++;
  815. }
  816. }
  817. $obj = $objp;
  818. // Extra fields
  819. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
  820. // Fields from hook
  821. $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$objp, 'i'=>$i, 'totalarray'=>&$totalarray);
  822. $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
  823. print $hookmanager->resPrint;
  824. // Status
  825. if (!empty($arrayfields['status']['checked'])) {
  826. print '<td class="center">';
  827. print $invoicerectmp->getLibStatut(3, 0);
  828. print '</td>';
  829. if (!$i) {
  830. $totalarray['nbfield']++;
  831. }
  832. }
  833. // Action column
  834. print '<td class="center tdoverflowmax125">';
  835. if ($user->rights->facture->creer && empty($invoicerectmp->suspended)) {
  836. if ($invoicerectmp->isMaxNbGenReached()) {
  837. print $langs->trans("MaxNumberOfGenerationReached");
  838. } elseif (empty($objp->frequency) || $db->jdate($objp->date_when) <= $today) {
  839. print '<a href="'.DOL_URL_ROOT.'/compta/facture/card.php?action=create&amp;socid='.$objp->socid.'&amp;fac_rec='.$objp->facid.'">';
  840. print img_picto($langs->trans("CreateBill"), 'add', 'class="paddingrightonly"');
  841. print $langs->trans("CreateBill").'</a>';
  842. } else {
  843. print $form->textwithpicto('', $langs->trans("DateIsNotEnough"));
  844. }
  845. } else {
  846. print "&nbsp;";
  847. }
  848. if (!$i) {
  849. $totalarray['nbfield']++;
  850. }
  851. print "</td>";
  852. print "</tr>\n";
  853. $i++;
  854. }
  855. } else {
  856. $colspan = 1;
  857. foreach ($arrayfields as $key => $val) {
  858. if (!empty($val['checked'])) {
  859. $colspan++;
  860. }
  861. }
  862. print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
  863. }
  864. // Show total line
  865. include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
  866. print "</table>";
  867. print "</div>";
  868. print "</form>";
  869. $db->free($resql);
  870. } else {
  871. dol_print_error($db);
  872. }
  873. // End of page
  874. llxFooter();
  875. $db->close();