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. // Load Dolibarr environment
  31. require '../../main.inc.php';
  32. require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php';
  33. require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
  34. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
  35. require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  36. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
  37. require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
  38. require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php';
  39. require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
  40. require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
  41. // Load translation files required by the page
  42. $langs->loadLangs(array('bills', 'compta', 'admin', 'other'));
  43. $action = GETPOST('action', 'alpha');
  44. $massaction = GETPOST('massaction', 'alpha');
  45. $show_files = GETPOST('show_files', 'int');
  46. $confirm = GETPOST('confirm', 'alpha');
  47. $cancel = GETPOST('cancel', 'alpha');
  48. $toselect = GETPOST('toselect', 'array');
  49. $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'invoicetemplatelist'; // To manage different context of search
  50. $optioncss = GETPOST('optioncss', 'alpha');
  51. $socid = GETPOST('socid', 'int');
  52. // Security check
  53. $id = (GETPOST('facid', 'int') ?GETPOST('facid', 'int') : GETPOST('id', 'int'));
  54. $lineid = GETPOST('lineid', 'int');
  55. $ref = GETPOST('ref', 'alpha');
  56. if ($user->socid) {
  57. $socid = $user->socid;
  58. }
  59. $objecttype = 'facture_rec';
  60. if ($action == "create" || $action == "add") {
  61. $objecttype = '';
  62. }
  63. $result = restrictedArea($user, 'facture', $id, $objecttype);
  64. $search_ref = GETPOST('search_ref');
  65. $search_societe = GETPOST('search_societe');
  66. $search_montant_ht = GETPOST('search_montant_ht');
  67. $search_montant_vat = GETPOST('search_montant_vat');
  68. $search_montant_ttc = GETPOST('search_montant_ttc');
  69. $search_payment_mode = GETPOST('search_payment_mode');
  70. $search_payment_term = GETPOST('search_payment_term');
  71. $search_date_startday = GETPOST('search_date_startday', 'int');
  72. $search_date_startmonth = GETPOST('search_date_startmonth', 'int');
  73. $search_date_startyear = GETPOST('search_date_startyear', 'int');
  74. $search_date_endday = GETPOST('search_date_endday', 'int');
  75. $search_date_endmonth = GETPOST('search_date_endmonth', 'int');
  76. $search_date_endyear = GETPOST('search_date_endyear', 'int');
  77. $search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver
  78. $search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
  79. $search_date_when_startday = GETPOST('search_date_when_startday', 'int');
  80. $search_date_when_startmonth = GETPOST('search_date_when_startmonth', 'int');
  81. $search_date_when_startyear = GETPOST('search_date_when_startyear', 'int');
  82. $search_date_when_endday = GETPOST('search_date_when_endday', 'int');
  83. $search_date_when_endmonth = GETPOST('search_date_when_endmonth', 'int');
  84. $search_date_when_endyear = GETPOST('search_date_when_endyear', 'int');
  85. $search_date_when_start = dol_mktime(0, 0, 0, $search_date_when_startmonth, $search_date_when_startday, $search_date_when_startyear); // Use tzserver
  86. $search_date_when_end = dol_mktime(23, 59, 59, $search_date_when_endmonth, $search_date_when_endday, $search_date_when_endyear);
  87. $search_recurring = GETPOST('search_recurring', 'int');
  88. $search_frequency = GETPOST('search_frequency', 'alpha');
  89. $search_unit_frequency = GETPOST('search_unit_frequency', 'alpha');
  90. $search_status = GETPOST('search_status', 'int');
  91. $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
  92. $sortfield = GETPOST('sortfield', 'aZ09comma');
  93. $sortorder = GETPOST('sortorder', 'aZ09comma');
  94. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  95. if (empty($page) || $page == -1) {
  96. $page = 0;
  97. } // If $page is not defined, or '' or -1
  98. $offset = $limit * $page;
  99. if (!$sortorder) {
  100. $sortorder = 'DESC';
  101. }
  102. if (!$sortfield) {
  103. $sortfield = 'f.titre';
  104. }
  105. $pageprev = $page - 1;
  106. $pagenext = $page + 1;
  107. $object = new FactureRec($db);
  108. if (($id > 0 || $ref) && $action != 'create' && $action != 'add') {
  109. $ret = $object->fetch($id, $ref);
  110. if (!$ret) {
  111. setEventMessages($langs->trans("ErrorRecordNotFound"), null, 'errors');
  112. }
  113. }
  114. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  115. $hookmanager->initHooks(array('invoicereclist'));
  116. $extrafields = new ExtraFields($db);
  117. // fetch optionals attributes and labels
  118. $extrafields->fetch_name_optionals_label($object->table_element);
  119. $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
  120. $permissionnote = $user->rights->facture->creer; // Used by the include of actions_setnotes.inc.php
  121. $permissiondellink = $user->rights->facture->creer; // Used by the include of actions_dellink.inc.php
  122. $permissiontoedit = $user->rights->facture->creer; // Used by the include of actions_lineupdonw.inc.php
  123. $arrayfields = array(
  124. 'f.titre'=>array('label'=>"Ref", 'checked'=>1),
  125. 's.nom'=>array('label'=>"ThirdParty", 'checked'=>1),
  126. 'f.total_ht'=>array('label'=>"AmountHT", 'checked'=>1),
  127. 'f.total_tva'=>array('label'=>"AmountVAT", 'checked'=>1),
  128. 'f.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>1),
  129. 'f.fk_mode_reglement'=>array('label'=>"PaymentMode", 'checked'=>0),
  130. 'f.fk_cond_reglement'=>array('label'=>"PaymentTerm", 'checked'=>0),
  131. 'recurring'=>array('label'=>"RecurringInvoice", 'checked'=>1),
  132. 'f.frequency'=>array('label'=>"Frequency", 'checked'=>1),
  133. 'f.unit_frequency'=>array('label'=>"FrequencyUnit", 'checked'=>1),
  134. 'f.nb_gen_done'=>array('label'=>"NbOfGenerationDoneShort", 'checked'=>1),
  135. 'f.date_last_gen'=>array('label'=>"DateLastGenerationShort", 'checked'=>1),
  136. 'f.date_when'=>array('label'=>"NextDateToExecutionShort", 'checked'=>1),
  137. 'f.fk_user_author'=>array('label'=>"UserCreation", 'checked'=>0, 'position'=>500),
  138. 'f.fk_user_modif'=>array('label'=>"UserModification", 'checked'=>0, 'position'=>505),
  139. 'f.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>520),
  140. 'f.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>525),
  141. 'status'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000),
  142. );
  143. // Extra fields
  144. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
  145. $object->fields = dol_sort_array($object->fields, 'position');
  146. $arrayfields = dol_sort_array($arrayfields, 'position');
  147. if ($socid > 0) {
  148. $tmpthirdparty = new Societe($db);
  149. $res = $tmpthirdparty->fetch($socid);
  150. if ($res > 0) {
  151. $search_societe = $tmpthirdparty->name;
  152. }
  153. }
  154. if ($socid > 0) {
  155. $tmpthirdparty = new Societe($db);
  156. $res = $tmpthirdparty->fetch($socid);
  157. if ($res > 0) {
  158. $search_societe = $tmpthirdparty->name;
  159. }
  160. }
  161. $objecttype = 'facture_rec';
  162. $result = restrictedArea($user, 'facture', $object->id, $objecttype);
  163. /*
  164. * Actions
  165. */
  166. if (GETPOST('cancel', 'alpha')) {
  167. $action = 'list';
  168. $massaction = '';
  169. }
  170. if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
  171. $massaction = '';
  172. }
  173. $parameters = array('socid' => $socid);
  174. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  175. if ($reshook < 0) {
  176. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  177. }
  178. if (empty($reshook)) {
  179. if (GETPOST('cancel', 'alpha')) {
  180. $action = '';
  181. }
  182. // Selection of new fields
  183. include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
  184. // Do we click on purge search criteria ?
  185. 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
  186. $search_ref = '';
  187. $search_societe = '';
  188. $search_montant_ht = '';
  189. $search_montant_vat = '';
  190. $search_montant_ttc = '';
  191. $search_payment_mode = '';
  192. $search_payment_term = '';
  193. $search_date_startday = '';
  194. $search_date_startmonth = '';
  195. $search_date_startyear = '';
  196. $search_date_endday = '';
  197. $search_date_endmonth = '';
  198. $search_date_endyear = '';
  199. $search_date_start = '';
  200. $search_date_end = '';
  201. $search_date_when_startday = '';
  202. $search_date_when_startmonth = '';
  203. $search_date_when_startyear = '';
  204. $search_date_when_endday = '';
  205. $search_date_when_endmonth = '';
  206. $search_date_when_endyear = '';
  207. $search_date_when_start = '';
  208. $search_date_when_end = '';
  209. $search_recurring = '';
  210. $search_frequency = '';
  211. $search_unit_frequency = '';
  212. $search_status = '';
  213. $search_array_options = array();
  214. }
  215. // Mass actions
  216. /*$objectclass='MyObject';
  217. $objectlabel='MyObject';
  218. $permissiontoread = $user->rights->mymodule->read;
  219. $permissiontodelete = $user->rights->mymodule->delete;
  220. $uploaddir = $conf->mymodule->dir_output;
  221. include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';*/
  222. }
  223. /*
  224. * View
  225. */
  226. llxHeader('', $langs->trans("RepeatableInvoices"), 'ch-facture.html#s-fac-facture-rec');
  227. $form = new Form($db);
  228. $formother = new FormOther($db);
  229. if (isModEnabled('project')) {
  230. $formproject = new FormProjets($db);
  231. }
  232. $companystatic = new Societe($db);
  233. $invoicerectmp = new FactureRec($db);
  234. $tmpuser = new User($db);
  235. $now = dol_now();
  236. $tmparray = dol_getdate($now);
  237. $today = dol_mktime(23, 59, 59, $tmparray['mon'], $tmparray['mday'], $tmparray['year']); // Today is last second of current day
  238. /*
  239. * List mode
  240. */
  241. $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,";
  242. $sql .= " f.nb_gen_done, f.nb_gen_max, f.date_last_gen, f.date_when, f.suspended,";
  243. $sql .= " f.datec, f.fk_user_author, f.tms, f.fk_user_modif,";
  244. $sql .= " f.fk_cond_reglement, f.fk_mode_reglement";
  245. // Add fields from extrafields
  246. if (!empty($extrafields->attributes[$object->table_element]['label'])) {
  247. foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
  248. $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
  249. }
  250. }
  251. // Add fields from hooks
  252. $parameters = array();
  253. $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
  254. $sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
  255. $sql = preg_replace('/,\s*$/', '', $sql);
  256. $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_rec as f";
  257. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture_rec_extrafields as ef ON ef.fk_object = f.rowid";
  258. if (empty($user->rights->societe->client->voir) && !$socid) {
  259. $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
  260. }
  261. $sql .= " WHERE f.fk_soc = s.rowid";
  262. $sql .= ' AND f.entity IN ('.getEntity('invoice').')';
  263. if (empty($user->rights->societe->client->voir) && !$socid) {
  264. $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
  265. }
  266. if ($search_ref) {
  267. $sql .= natural_search('f.titre', $search_ref);
  268. }
  269. if ($socid) {
  270. $sql .= ' AND s.rowid = '.(int) $socid;
  271. }
  272. if ($search_societe) {
  273. $sql .= natural_search('s.nom', $search_societe);
  274. }
  275. if ($search_montant_ht != '') {
  276. $sql .= natural_search('f.total_ht', $search_montant_ht, 1);
  277. }
  278. if ($search_montant_vat != '') {
  279. $sql .= natural_search('f.total_tva', $search_montant_vat, 1);
  280. }
  281. if ($search_montant_ttc != '') {
  282. $sql .= natural_search('f.total_ttc', $search_montant_ttc, 1);
  283. }
  284. if (!empty($search_payment_mode) && $search_payment_mode != '-1') {
  285. $sql .= natural_search('f.fk_mode_reglement', $search_payment_mode, 1);
  286. }
  287. if (!empty($search_payment_term) && $search_payment_term != '-1') {
  288. $sql .= natural_search('f.fk_cond_reglement', $search_payment_term, 1);
  289. }
  290. if ($search_recurring == '1') {
  291. $sql .= ' AND f.frequency > 0';
  292. }
  293. if ($search_recurring == '0') {
  294. $sql .= ' AND (f.frequency IS NULL or f.frequency = 0)';
  295. }
  296. if ($search_frequency != '') {
  297. $sql .= natural_search('f.frequency', $search_frequency, 1);
  298. }
  299. if ($search_unit_frequency != '') {
  300. $sql .= ' AND f.frequency > 0'.natural_search('f.unit_frequency', $search_unit_frequency);
  301. }
  302. if ($search_status != '' && $search_status >= -1) {
  303. if ($search_status == 0) {
  304. $sql .= ' AND frequency = 0 AND suspended = 0';
  305. }
  306. if ($search_status == 1) {
  307. $sql .= ' AND frequency != 0 AND suspended = 0';
  308. }
  309. if ($search_status == -1) {
  310. $sql .= ' AND suspended = 1';
  311. }
  312. }
  313. if ($search_date_start) {
  314. $sql .= " AND f.date_last_gen >= '".$db->idate($search_date_start)."'";
  315. }
  316. if ($search_date_end) {
  317. $sql .= " AND f.date_last_gen <= '".$db->idate($search_date_end)."'";
  318. }
  319. if ($search_date_when_start) {
  320. $sql .= " AND f.date_when >= '".$db->idate($search_date_when_start)."'";
  321. }
  322. if ($search_date_when_end) {
  323. $sql .= " AND f.date_when <= '".$db->idate($search_date_when_end)."'";
  324. }
  325. $tmpsortfield = $sortfield;
  326. if ($tmpsortfield == 'recurring') {
  327. $tmpsortfield = 'f.frequency';
  328. }
  329. $sql .= $db->order($tmpsortfield, $sortorder);
  330. $nbtotalofrecords = '';
  331. if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
  332. $result = $db->query($sql);
  333. $nbtotalofrecords = $db->num_rows($result);
  334. if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
  335. $page = 0;
  336. $offset = 0;
  337. }
  338. }
  339. $sql .= $db->plimit($limit + 1, $offset);
  340. $resql = $db->query($sql);
  341. if ($resql) {
  342. $num = $db->num_rows($resql);
  343. $param = '';
  344. if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
  345. $param .= '&contextpage='.urlencode($contextpage);
  346. }
  347. if ($limit > 0 && $limit != $conf->liste_limit) {
  348. $param .= '&limit='.urlencode($limit);
  349. }
  350. if ($socid > 0) {
  351. $param .= '&socid='.urlencode($socid);
  352. }
  353. if ($search_date_startday) {
  354. $param .= '&search_date_startday='.urlencode($search_date_startday);
  355. }
  356. if ($search_date_startmonth) {
  357. $param .= '&search_date_startmonth='.urlencode($search_date_startmonth);
  358. }
  359. if ($search_date_startyear) {
  360. $param .= '&search_date_startyear='.urlencode($search_date_startyear);
  361. }
  362. if ($search_date_endday) {
  363. $param .= '&search_date_endday='.urlencode($search_date_endday);
  364. }
  365. if ($search_date_endmonth) {
  366. $param .= '&search_date_endmonth='.urlencode($search_date_endmonth);
  367. }
  368. if ($search_date_endyear) {
  369. $param .= '&search_date_endyear='.urlencode($search_date_endyear);
  370. }
  371. if ($search_date_when_startday) {
  372. $param .= '&search_date_when_startday='.urlencode($search_date_when_startday);
  373. }
  374. if ($search_date_when_startmonth) {
  375. $param .= '&search_date_when_startmonth='.urlencode($search_date_when_startmonth);
  376. }
  377. if ($search_date_when_startyear) {
  378. $param .= '&search_date_when_startyear='.urlencode($search_date_when_startyear);
  379. }
  380. if ($search_date_when_endday) {
  381. $param .= '&search_date_when_endday='.urlencode($search_date_when_endday);
  382. }
  383. if ($search_date_when_endmonth) {
  384. $param .= '&search_date_when_endmonth='.urlencode($search_date_when_endmonth);
  385. }
  386. if ($search_date_when_endyear) {
  387. $param .= '&search_date_when_endyear='.urlencode($search_date_when_endyear);
  388. }
  389. if ($search_ref) {
  390. $param .= '&search_ref='.urlencode($search_ref);
  391. }
  392. if ($search_societe) {
  393. $param .= '&search_societe='.urlencode($search_societe);
  394. }
  395. if ($search_montant_ht != '') {
  396. $param .= '&search_montant_ht='.urlencode($search_montant_ht);
  397. }
  398. if ($search_montant_vat != '') {
  399. $param .= '&search_montant_vat='.urlencode($search_montant_vat);
  400. }
  401. if ($search_montant_ttc != '') {
  402. $param .= '&search_montant_ttc='.urlencode($search_montant_ttc);
  403. }
  404. if ($search_payment_mode != '') {
  405. $param .= '&search_payment_mode='.urlencode($search_payment_mode);
  406. }
  407. if ($search_payment_term != '') {
  408. $param .= '&search_payment_term='.urlencode($search_payment_term);
  409. }
  410. if ($search_recurring != '' && $search_recurring != '-1') {
  411. $param .= '&search_recurring='.urlencode($search_recurring);
  412. }
  413. if ($search_frequency > 0) {
  414. $param .= '&search_frequency='.urlencode($search_frequency);
  415. }
  416. if ($search_unit_frequency != '') {
  417. $param .= '&search_unit_frequency='.urlencode($search_unit_frequency);
  418. }
  419. if ($search_status != '') {
  420. $param .= '&search_status='.urlencode($search_status);
  421. }
  422. if ($optioncss != '') {
  423. $param .= '&optioncss='.urlencode($optioncss);
  424. }
  425. // Add $param from extra fields
  426. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
  427. $massactionbutton = $form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge")));
  428. $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
  429. $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
  430. //$selectedfields.=$form->showCheckAddButtons('checkforselect', 1);
  431. print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
  432. if ($optioncss != '') {
  433. print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  434. }
  435. print '<input type="hidden" name="token" value="'.newToken().'">';
  436. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  437. print '<input type="hidden" name="action" value="list">';
  438. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  439. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  440. print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
  441. print '<input type="hidden" name="search_status" value="'.$search_status.'">';
  442. $title = $langs->trans("RepeatableInvoices");
  443. print_barre_liste($title, $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'bill', 0, '', '', $limit, 0, 0, 1);
  444. print '<span class="opacitymedium">'.$langs->trans("ToCreateAPredefinedInvoice", $langs->transnoentitiesnoconv("ChangeIntoRepeatableInvoice")).'</span><br><br>';
  445. $i = 0;
  446. $moreforfilter = '';
  447. print '<div class="div-table-responsive">';
  448. print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
  449. // Filters lines
  450. print '<tr class="liste_titre_filter">';
  451. // Ref
  452. if (!empty($arrayfields['f.titre']['checked'])) {
  453. print '<td class="liste_titre left">';
  454. print '<input class="flat maxwidth100" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
  455. print '</td>';
  456. }
  457. // Thirdparty
  458. if (!empty($arrayfields['s.nom']['checked'])) {
  459. print '<td class="liste_titre left"><input class="flat" type="text" size="8" name="search_societe" value="'.dol_escape_htmltag($search_societe).'"></td>';
  460. }
  461. if (!empty($arrayfields['f.total_ht']['checked'])) {
  462. // Amount net
  463. print '<td class="liste_titre right">';
  464. print '<input class="flat" type="text" size="5" name="search_montant_ht" value="'.dol_escape_htmltag($search_montant_ht).'">';
  465. print '</td>';
  466. }
  467. if (!empty($arrayfields['f.total_tva']['checked'])) {
  468. // Amount Vat
  469. print '<td class="liste_titre right">';
  470. print '<input class="flat" type="text" size="5" name="search_montant_vat" value="'.dol_escape_htmltag($search_montant_vat).'">';
  471. print '</td>';
  472. }
  473. if (!empty($arrayfields['f.total_ttc']['checked'])) {
  474. // Amount
  475. print '<td class="liste_titre right">';
  476. print '<input class="flat" type="text" size="5" name="search_montant_ttc" value="'.dol_escape_htmltag($search_montant_ttc).'">';
  477. print '</td>';
  478. }
  479. if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) {
  480. // Payment term
  481. print '<td class="liste_titre right">';
  482. print $form->getSelectConditionsPaiements($search_payment_term, 'search_payment_term', -1, 1, 1, 'maxwidth100');
  483. print "</td>";
  484. }
  485. if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) {
  486. // Payment mode
  487. print '<td class="liste_titre right">';
  488. print $form->select_types_paiements($search_payment_mode, 'search_payment_mode', '', 0, 1, 1, 0, 1, 'maxwidth100', 1);
  489. print '</td>';
  490. }
  491. if (!empty($arrayfields['recurring']['checked'])) {
  492. // Recurring or not
  493. print '<td class="liste_titre center">';
  494. print $form->selectyesno('search_recurring', $search_recurring, 1, false, 1);
  495. print '</td>';
  496. }
  497. if (!empty($arrayfields['f.frequency']['checked'])) {
  498. // Recurring or not
  499. print '<td class="liste_titre center">';
  500. print '<input class="flat" type="text" size="1" name="search_frequency" value="'.dol_escape_htmltag($search_frequency).'">';
  501. print '</td>';
  502. }
  503. if (!empty($arrayfields['f.unit_frequency']['checked'])) {
  504. // Frequency unit
  505. print '<td class="liste_titre center">';
  506. print '<input class="flat" type="text" size="1" name="search_unit_frequency" value="'.dol_escape_htmltag($search_unit_frequency).'">';
  507. print '</td>';
  508. }
  509. if (!empty($arrayfields['f.nb_gen_done']['checked'])) {
  510. // Nb generation
  511. print '<td class="liste_titre" align="center">';
  512. print '</td>';
  513. }
  514. // Date invoice
  515. if (!empty($arrayfields['f.date_last_gen']['checked'])) {
  516. print '<td class="liste_titre center">';
  517. print '<div class="nowrap">';
  518. print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
  519. print '</div>';
  520. print '<div class="nowrap">';
  521. print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
  522. print '</div>';
  523. print '</td>';
  524. }
  525. // Date next generation
  526. if (!empty($arrayfields['f.date_when']['checked'])) {
  527. print '<td class="liste_titre center">';
  528. print '<div class="nowrap">';
  529. 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'));
  530. print '</div>';
  531. print '<div class="nowrap">';
  532. 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'));
  533. print '</div>';
  534. print '</td>';
  535. }
  536. // Extra fields
  537. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
  538. // Fields from hook
  539. $parameters = array('arrayfields'=>$arrayfields);
  540. $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
  541. print $hookmanager->resPrint;
  542. // User creation
  543. if (!empty($arrayfields['f.fk_user_author']['checked'])) {
  544. print '<td class="liste_titre">';
  545. print '</td>';
  546. }
  547. // User modification
  548. if (!empty($arrayfields['f.fk_user_modif']['checked'])) {
  549. print '<td class="liste_titre">';
  550. print '</td>';
  551. }
  552. // Date creation
  553. if (!empty($arrayfields['f.datec']['checked'])) {
  554. print '<td class="liste_titre">';
  555. print '</td>';
  556. }
  557. // Date modification
  558. if (!empty($arrayfields['f.tms']['checked'])) {
  559. print '<td class="liste_titre">';
  560. print '</td>';
  561. }
  562. // Status
  563. if (!empty($arrayfields['status']['checked'])) {
  564. print '<td class="liste_titre center">';
  565. $liststatus = array(
  566. 0=>$langs->trans("Draft"),
  567. 1=>$langs->trans("Active"),
  568. -1=>$langs->trans("Disabled"),
  569. );
  570. print $form->selectarray('search_status', $liststatus, $search_status, -2, 0, 0, '', 0, 0, 0, '', 'width100 onrightofpage');
  571. print '</td>';
  572. }
  573. // Action column
  574. print '<td class="liste_titre" align="middle">';
  575. $searchpicto = $form->showFilterButtons();
  576. print $searchpicto;
  577. print '</td>';
  578. print "</tr>\n";
  579. print '<tr class="liste_titre">';
  580. if (!empty($arrayfields['f.titre']['checked'])) {
  581. print_liste_field_titre($arrayfields['f.titre']['label'], $_SERVER['PHP_SELF'], "f.titre", "", $param, "", $sortfield, $sortorder);
  582. }
  583. if (!empty($arrayfields['s.nom']['checked'])) {
  584. print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER['PHP_SELF'], "s.nom", "", $param, "", $sortfield, $sortorder);
  585. }
  586. if (!empty($arrayfields['f.total_ht']['checked'])) {
  587. print_liste_field_titre($arrayfields['f.total_ht']['label'], $_SERVER['PHP_SELF'], "f.total_ht", "", $param, 'class="right"', $sortfield, $sortorder);
  588. }
  589. if (!empty($arrayfields['f.total_tva']['checked'])) {
  590. print_liste_field_titre($arrayfields['f.total_tva']['label'], $_SERVER['PHP_SELF'], "f.total_tva", "", $param, 'class="right"', $sortfield, $sortorder);
  591. }
  592. if (!empty($arrayfields['f.total_ttc']['checked'])) {
  593. print_liste_field_titre($arrayfields['f.total_ttc']['label'], $_SERVER['PHP_SELF'], "f.total_ttc", "", $param, 'class="right"', $sortfield, $sortorder);
  594. }
  595. if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) {
  596. print_liste_field_titre($arrayfields['f.fk_cond_reglement']['label'], $_SERVER['PHP_SELF'], "f.fk_cond_reglement", "", $param, '', $sortfield, $sortorder);
  597. }
  598. if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) {
  599. print_liste_field_titre($arrayfields['f.fk_mode_reglement']['label'], $_SERVER['PHP_SELF'], "f.fk_mode_reglement", "", $param, '', $sortfield, $sortorder);
  600. }
  601. if (!empty($arrayfields['recurring']['checked'])) {
  602. print_liste_field_titre($arrayfields['recurring']['label'], $_SERVER['PHP_SELF'], "recurring", "", $param, 'class="center"', $sortfield, $sortorder);
  603. }
  604. if (!empty($arrayfields['f.frequency']['checked'])) {
  605. print_liste_field_titre($arrayfields['f.frequency']['label'], $_SERVER['PHP_SELF'], "f.frequency", "", $param, 'align="center"', $sortfield, $sortorder);
  606. }
  607. if (!empty($arrayfields['f.unit_frequency']['checked'])) {
  608. print_liste_field_titre($arrayfields['f.unit_frequency']['label'], $_SERVER['PHP_SELF'], "f.unit_frequency", "", $param, 'align="center"', $sortfield, $sortorder);
  609. }
  610. if (!empty($arrayfields['f.nb_gen_done']['checked'])) {
  611. print_liste_field_titre($arrayfields['f.nb_gen_done']['label'], $_SERVER['PHP_SELF'], "f.nb_gen_done", "", $param, 'align="center"', $sortfield, $sortorder);
  612. }
  613. if (!empty($arrayfields['f.date_last_gen']['checked'])) {
  614. print_liste_field_titre($arrayfields['f.date_last_gen']['label'], $_SERVER['PHP_SELF'], "f.date_last_gen", "", $param, 'align="center"', $sortfield, $sortorder);
  615. }
  616. if (!empty($arrayfields['f.date_when']['checked'])) {
  617. print_liste_field_titre($arrayfields['f.date_when']['label'], $_SERVER['PHP_SELF'], "f.date_when", "", $param, 'align="center"', $sortfield, $sortorder);
  618. }
  619. if (!empty($arrayfields['f.fk_user_author']['checked'])) {
  620. print_liste_field_titre($arrayfields['f.fk_user_author']['label'], $_SERVER['PHP_SELF'], "f.fk_user_author", "", $param, 'align="center"', $sortfield, $sortorder);
  621. }
  622. if (!empty($arrayfields['f.fk_user_modif']['checked'])) {
  623. print_liste_field_titre($arrayfields['f.fk_user_modif']['label'], $_SERVER['PHP_SELF'], "f.fk_user_modif", "", $param, 'align="center"', $sortfield, $sortorder);
  624. }
  625. if (!empty($arrayfields['f.datec']['checked'])) {
  626. print_liste_field_titre($arrayfields['f.datec']['label'], $_SERVER['PHP_SELF'], "f.datec", "", $param, 'align="center"', $sortfield, $sortorder);
  627. }
  628. if (!empty($arrayfields['f.tms']['checked'])) {
  629. print_liste_field_titre($arrayfields['f.tms']['label'], $_SERVER['PHP_SELF'], "f.tms", "", $param, 'align="center"', $sortfield, $sortorder);
  630. }
  631. // Extra fields
  632. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
  633. if (!empty($arrayfields['status']['checked'])) {
  634. print_liste_field_titre($arrayfields['status']['label'], $_SERVER['PHP_SELF'], "f.suspended,f.frequency", "", $param, 'align="center"', $sortfield, $sortorder);
  635. }
  636. print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'center maxwidthsearch ');
  637. print "</tr>\n";
  638. if ($num > 0) {
  639. $i = 0;
  640. $totalarray = array();
  641. $totalarray['nbfield'] = 0;
  642. $totalarray['val']['f.total_ht'] = 0;
  643. $totalarray['val']['f.total_tva'] = 0;
  644. $totalarray['val']['f.total_ttc'] = 0;
  645. while ($i < min($num, $limit)) {
  646. $objp = $db->fetch_object($resql);
  647. if (empty($objp)) {
  648. break;
  649. }
  650. $companystatic->id = $objp->socid;
  651. $companystatic->name = $objp->name;
  652. $invoicerectmp->id = !empty($objp->id) ? $objp->id : $objp->facid;
  653. $invoicerectmp->frequency = $objp->frequency;
  654. $invoicerectmp->suspended = $objp->suspended;
  655. $invoicerectmp->unit_frequency = $objp->unit_frequency;
  656. $invoicerectmp->nb_gen_max = $objp->nb_gen_max;
  657. $invoicerectmp->nb_gen_done = $objp->nb_gen_done;
  658. $invoicerectmp->ref = $objp->title;
  659. $invoicerectmp->total_ht = $objp->total_ht;
  660. $invoicerectmp->total_tva = $objp->total_tva;
  661. $invoicerectmp->total_ttc = $objp->total_ttc;
  662. print '<tr class="oddeven">';
  663. if (!empty($arrayfields['f.titre']['checked'])) {
  664. print '<td class="nowrap tdoverflowmax200">';
  665. print $invoicerectmp->getNomUrl(1);
  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="tdoverflowmax150">';
  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="tdoverflowmax150">';
  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 nowraponall">';
  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 nowraponall">';
  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();