list-rec.php 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923
  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.'/fourn/class/fournisseur.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', 'suppliers'));
  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_fourn_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', 'alpha');
  93. $sortorder = GETPOST('sortorder', 'alpha');
  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 FactureFournisseurRec($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('supplierinvoicereclist'));
  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. 'suspended '=>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. $objecttype = 'facture_fourn_rec';
  155. $result = restrictedArea($user, 'facture', $object->id, $objecttype);
  156. /*
  157. * Actions
  158. */
  159. if (GETPOST('cancel', 'alpha')) {
  160. $action = 'list';
  161. $massaction = '';
  162. }
  163. if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
  164. $massaction = '';
  165. }
  166. $parameters = array('socid' => $socid);
  167. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  168. if ($reshook < 0) {
  169. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  170. }
  171. if (empty($reshook)) {
  172. if (GETPOST('cancel', 'alpha')) {
  173. $action = '';
  174. }
  175. // Selection of new fields
  176. include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
  177. // Do we click on purge search criteria ?
  178. 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
  179. $search_ref = '';
  180. $search_societe = '';
  181. $search_montant_ht = '';
  182. $search_montant_vat = '';
  183. $search_montant_ttc = '';
  184. $search_payment_mode = '';
  185. $search_payment_term = '';
  186. $search_date_startday = '';
  187. $search_date_startmonth = '';
  188. $search_date_startyear = '';
  189. $search_date_endday = '';
  190. $search_date_endmonth = '';
  191. $search_date_endyear = '';
  192. $search_date_start = '';
  193. $search_date_end = '';
  194. $search_date_when_startday = '';
  195. $search_date_when_startmonth = '';
  196. $search_date_when_startyear = '';
  197. $search_date_when_endday = '';
  198. $search_date_when_endmonth = '';
  199. $search_date_when_endyear = '';
  200. $search_date_when_start = '';
  201. $search_date_when_end = '';
  202. $search_recurring = '';
  203. $search_frequency = '';
  204. $search_unit_frequency = '';
  205. $search_status = '';
  206. $search_array_options = array();
  207. }
  208. // Mass actions
  209. /*$objectclass='MyObject';
  210. $objectlabel='MyObject';
  211. $permissiontoread = $user->rights->mymodule->read;
  212. $permissiontodelete = $user->rights->mymodule->delete;
  213. $uploaddir = $conf->mymodule->dir_output;
  214. include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';*/
  215. }
  216. /*
  217. * View
  218. */
  219. $help_url = '';
  220. llxHeader('', $langs->trans("RepeatableSupplierInvoices"), $help_url);
  221. $form = new Form($db);
  222. $formother = new FormOther($db);
  223. if (isModEnabled('project')) {
  224. $formproject = new FormProjets($db);
  225. }
  226. $companystatic = new Societe($db);
  227. $supplierinvoicerectmp = new FactureFournisseurRec($db);
  228. $tmpuser = new User($db);
  229. $now = dol_now();
  230. $tmparray = dol_getdate($now);
  231. $today = dol_mktime(23, 59, 59, $tmparray['mon'], $tmparray['mday'], $tmparray['year']); // Today is last second of current day
  232. /*
  233. * List mode
  234. */
  235. $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,";
  236. $sql .= " f.nb_gen_done, f.nb_gen_max, f.date_last_gen, f.date_when, f.suspended,";
  237. $sql .= " f.datec, f.fk_user_author, f.tms, f.fk_user_modif,";
  238. $sql .= " f.fk_cond_reglement, f.fk_mode_reglement";
  239. // Add fields from extrafields
  240. if (!empty($extrafields->attributes[$object->table_element]['label'])) {
  241. foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
  242. $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
  243. }
  244. }
  245. // Add fields from hooks
  246. $parameters = array();
  247. $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
  248. $sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
  249. $sql = preg_replace('/,\s*$/', '', $sql);
  250. $sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'facture_fourn_rec as f';
  251. $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn_rec_extrafields as ef ON ef.fk_object = f.rowid';
  252. if (empty($user->rights->societe->client->voir) && !$socid) {
  253. $sql .= ', '.MAIN_DB_PREFIX.'societe_commerciaux as sc';
  254. }
  255. $sql .= ' WHERE f.fk_soc = s.rowid';
  256. $sql .= ' AND f.entity IN ('.getEntity('invoice').')';
  257. if (empty($user->rights->societe->client->voir) && !$socid) {
  258. $sql .= ' AND s.rowid = sc.fk_soc AND sc.fk_user = '. (int) $user->id;
  259. }
  260. if ($search_ref) {
  261. $sql .= natural_search('f.titre', $search_ref);
  262. }
  263. if ($socid) {
  264. $sql .= ' AND s.rowid = '.(int) $socid;
  265. }
  266. if ($search_societe) {
  267. $sql .= natural_search('s.nom', $search_societe);
  268. }
  269. if ($search_montant_ht != '') {
  270. $sql .= natural_search('f.total_ht', $search_montant_ht, 1);
  271. }
  272. if ($search_montant_vat != '') {
  273. $sql .= natural_search('f.total_tva', $search_montant_vat, 1);
  274. }
  275. if ($search_montant_ttc != '') {
  276. $sql .= natural_search('f.total_ttc', $search_montant_ttc, 1);
  277. }
  278. if (!empty($search_payment_mode) && $search_payment_mode != '-1') {
  279. $sql .= natural_search('f.fk_mode_reglement', $search_payment_mode, 1);
  280. }
  281. if (!empty($search_payment_term) && $search_payment_term != '-1') {
  282. $sql .= natural_search('f.fk_cond_reglement', $search_payment_term, 1);
  283. }
  284. if ($search_recurring == '1') {
  285. $sql .= ' AND f.frequency > 0';
  286. }
  287. if ($search_recurring == '0') {
  288. $sql .= ' AND (f.frequency IS NULL or f.frequency = 0)';
  289. }
  290. if ($search_frequency != '') {
  291. $sql .= natural_search('f.frequency', $search_frequency, 1);
  292. }
  293. if ($search_unit_frequency != '') {
  294. $sql .= ' AND f.frequency > 0'.natural_search('f.unit_frequency', $search_unit_frequency);
  295. }
  296. if ($search_status != '' && $search_status >= -1) {
  297. if ($search_status == 0) {
  298. $sql .= ' AND frequency = 0 AND suspended = 0';
  299. }
  300. if ($search_status == 1) {
  301. $sql .= ' AND frequency != 0 AND suspended = 0';
  302. }
  303. if ($search_status == -1) {
  304. $sql .= ' AND suspended = 1';
  305. }
  306. }
  307. if ($search_date_start) {
  308. $sql .= " AND f.date_last_gen >= '".$db->idate($search_date_start)."'";
  309. }
  310. if ($search_date_end) {
  311. $sql .= " AND f.date_last_gen <= '".$db->idate($search_date_end)."'";
  312. }
  313. if ($search_date_when_start) {
  314. $sql .= " AND f.date_when >= '".$db->idate($search_date_when_start)."'";
  315. }
  316. if ($search_date_when_end) {
  317. $sql .= " AND f.date_when <= '".$db->idate($search_date_when_end)."'";
  318. }
  319. $tmpsortfield = $sortfield;
  320. if ($tmpsortfield == 'recurring') {
  321. $tmpsortfield = 'f.frequency';
  322. }
  323. $sql .= $db->order($tmpsortfield, $sortorder);
  324. $nbtotalofrecords = '';
  325. if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
  326. $result = $db->query($sql);
  327. $nbtotalofrecords = $db->num_rows($result);
  328. if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
  329. $page = 0;
  330. $offset = 0;
  331. }
  332. }
  333. $sql .= $db->plimit($limit + 1, $offset);
  334. $resql = $db->query($sql);
  335. if ($resql) {
  336. $num = $db->num_rows($resql);
  337. $param = '';
  338. if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
  339. $param .= '&contextpage='.urlencode($contextpage);
  340. }
  341. if ($limit > 0 && $limit != $conf->liste_limit) {
  342. $param .= '&limit='.urlencode($limit);
  343. }
  344. if ($socid > 0) {
  345. $param .= '&socid='.urlencode($socid);
  346. }
  347. if ($search_date_startday) {
  348. $param .= '&search_date_startday='.urlencode($search_date_startday);
  349. }
  350. if ($search_date_startmonth) {
  351. $param .= '&search_date_startmonth='.urlencode($search_date_startmonth);
  352. }
  353. if ($search_date_startyear) {
  354. $param .= '&search_date_startyear='.urlencode($search_date_startyear);
  355. }
  356. if ($search_date_endday) {
  357. $param .= '&search_date_endday='.urlencode($search_date_endday);
  358. }
  359. if ($search_date_endmonth) {
  360. $param .= '&search_date_endmonth='.urlencode($search_date_endmonth);
  361. }
  362. if ($search_date_endyear) {
  363. $param .= '&search_date_endyear='.urlencode($search_date_endyear);
  364. }
  365. if ($search_date_when_startday) {
  366. $param .= '&search_date_when_startday='.urlencode($search_date_when_startday);
  367. }
  368. if ($search_date_when_startmonth) {
  369. $param .= '&search_date_when_startmonth='.urlencode($search_date_when_startmonth);
  370. }
  371. if ($search_date_when_startyear) {
  372. $param .= '&search_date_when_startyear='.urlencode($search_date_when_startyear);
  373. }
  374. if ($search_date_when_endday) {
  375. $param .= '&search_date_when_endday='.urlencode($search_date_when_endday);
  376. }
  377. if ($search_date_when_endmonth) {
  378. $param .= '&search_date_when_endmonth='.urlencode($search_date_when_endmonth);
  379. }
  380. if ($search_date_when_endyear) {
  381. $param .= '&search_date_when_endyear='.urlencode($search_date_when_endyear);
  382. }
  383. if ($search_ref) {
  384. $param .= '&search_ref='.urlencode($search_ref);
  385. }
  386. if ($search_societe) {
  387. $param .= '&search_societe='.urlencode($search_societe);
  388. }
  389. if ($search_montant_ht != '') {
  390. $param .= '&search_montant_ht='.urlencode($search_montant_ht);
  391. }
  392. if ($search_montant_vat != '') {
  393. $param .= '&search_montant_vat='.urlencode($search_montant_vat);
  394. }
  395. if ($search_montant_ttc != '') {
  396. $param .= '&search_montant_ttc='.urlencode($search_montant_ttc);
  397. }
  398. if ($search_payment_mode != '') {
  399. $param .= '&search_payment_mode='.urlencode($search_payment_mode);
  400. }
  401. if ($search_payment_term != '') {
  402. $param .= '&search_payment_term='.urlencode($search_payment_term);
  403. }
  404. if ($search_recurring != '' && $search_recurring != '-1') {
  405. $param .= '&search_recurring='.urlencode($search_recurring);
  406. }
  407. if ($search_frequency > 0) {
  408. $param .= '&search_frequency='.urlencode($search_frequency);
  409. }
  410. if ($search_unit_frequency != '') {
  411. $param .= '&search_unit_frequency='.urlencode($search_unit_frequency);
  412. }
  413. if ($search_status != '') {
  414. $param .= '&search_status='.urlencode($search_status);
  415. }
  416. if ($optioncss != '') {
  417. $param .= '&optioncss='.urlencode($optioncss);
  418. }
  419. // Add $param from extra fields
  420. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
  421. $massactionbutton = $form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge")));
  422. $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
  423. $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
  424. //$selectedfields.=$form->showCheckAddButtons('checkforselect', 1);
  425. print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
  426. if ($optioncss != '') {
  427. print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  428. }
  429. print '<input type="hidden" name="token" value="'.newToken().'">';
  430. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  431. print '<input type="hidden" name="action" value="list">';
  432. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  433. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  434. print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
  435. print '<input type="hidden" name="search_status" value="'.$search_status.'">';
  436. $title = $langs->trans("RepeatableSupplierInvoices");
  437. print_barre_liste($title, $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'bill', 0, '', '', $limit, 0, 0, 1);
  438. print '<span class="opacitymedium">'.$langs->trans("ToCreateAPredefinedSupplierInvoice", $langs->transnoentitiesnoconv("ChangeIntoRepeatableInvoice")).'</span><br><br>';
  439. $i = 0;
  440. $moreforfilter = '';
  441. print '<div class="div-table-responsive">';
  442. print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
  443. // Filters lines
  444. print '<tr class="liste_titre_filter">';
  445. // Ref
  446. if (!empty($arrayfields['f.titre']['checked'])) {
  447. print '<td class="liste_titre left">';
  448. print '<input class="flat maxwidth100" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
  449. print '</td>';
  450. }
  451. // Thirdparty
  452. if (!empty($arrayfields['s.nom']['checked'])) {
  453. print '<td class="liste_titre left"><input class="flat" type="text" size="8" name="search_societe" value="'.dol_escape_htmltag($search_societe).'"></td>';
  454. }
  455. if (!empty($arrayfields['f.total_ht']['checked'])) {
  456. // Amount net
  457. print '<td class="liste_titre right">';
  458. print '<input class="flat" type="text" size="5" name="search_montant_ht" value="'.dol_escape_htmltag($search_montant_ht).'">';
  459. print '</td>';
  460. }
  461. if (!empty($arrayfields['f.total_tva']['checked'])) {
  462. // Amount Vat
  463. print '<td class="liste_titre right">';
  464. print '<input class="flat" type="text" size="5" name="search_montant_vat" value="'.dol_escape_htmltag($search_montant_vat).'">';
  465. print '</td>';
  466. }
  467. if (!empty($arrayfields['f.total_ttc']['checked'])) {
  468. // Amount
  469. print '<td class="liste_titre right">';
  470. print '<input class="flat" type="text" size="5" name="search_montant_ttc" value="'.dol_escape_htmltag($search_montant_ttc).'">';
  471. print '</td>';
  472. }
  473. if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) {
  474. // Payment term
  475. print '<td class="liste_titre right">';
  476. print $form->getSelectConditionsPaiements($search_payment_term, 'search_payment_term', -1, 1, 1, 'maxwidth100');
  477. print "</td>";
  478. }
  479. if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) {
  480. // Payment mode
  481. print '<td class="liste_titre right">';
  482. print $form->select_types_paiements($search_payment_mode, 'search_payment_mode', '', 0, 1, 1, 0, 1, 'maxwidth100', 1);
  483. print '</td>';
  484. }
  485. if (!empty($arrayfields['recurring']['checked'])) {
  486. // Recurring or not
  487. print '<td class="liste_titre center">';
  488. print $form->selectyesno('search_recurring', $search_recurring, 1, false, 1);
  489. print '</td>';
  490. }
  491. if (!empty($arrayfields['f.frequency']['checked'])) {
  492. // Recurring or not
  493. print '<td class="liste_titre center">';
  494. print '<input class="flat" type="text" size="1" name="search_frequency" value="'.dol_escape_htmltag($search_frequency).'">';
  495. print '</td>';
  496. }
  497. if (!empty($arrayfields['f.unit_frequency']['checked'])) {
  498. // Frequency unit
  499. print '<td class="liste_titre center">';
  500. print '<input class="flat" type="text" size="1" name="search_unit_frequency" value="'.dol_escape_htmltag($search_unit_frequency).'">';
  501. print '</td>';
  502. }
  503. if (!empty($arrayfields['f.nb_gen_done']['checked'])) {
  504. // Nb generation
  505. print '<td class="liste_titre" align="center">';
  506. print '</td>';
  507. }
  508. // Date invoice
  509. if (!empty($arrayfields['f.date_last_gen']['checked'])) {
  510. print '<td class="liste_titre center">';
  511. print '<div class="nowrap">';
  512. print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
  513. print '</div>';
  514. print '<div class="nowrap">';
  515. print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
  516. print '</div>';
  517. print '</td>';
  518. }
  519. // Date next generation
  520. if (!empty($arrayfields['f.date_when']['checked'])) {
  521. print '<td class="liste_titre center">';
  522. print '<div class="nowrap">';
  523. 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'));
  524. print '</div>';
  525. print '<div class="nowrap">';
  526. 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'));
  527. print '</div>';
  528. print '</td>';
  529. }
  530. // Extra fields
  531. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
  532. // Fields from hook
  533. $parameters = array('arrayfields'=>$arrayfields);
  534. $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
  535. print $hookmanager->resPrint;
  536. // User creation
  537. if (!empty($arrayfields['f.fk_user_author']['checked'])) {
  538. print '<td class="liste_titre">';
  539. print '</td>';
  540. }
  541. // User modification
  542. if (!empty($arrayfields['f.fk_user_modif']['checked'])) {
  543. print '<td class="liste_titre">';
  544. print '</td>';
  545. }
  546. // Date creation
  547. if (!empty($arrayfields['f.datec']['checked'])) {
  548. print '<td class="liste_titre">';
  549. print '</td>';
  550. }
  551. // Date modification
  552. if (!empty($arrayfields['f.tms']['checked'])) {
  553. print '<td class="liste_titre">';
  554. print '</td>';
  555. }
  556. // Action column
  557. print '<td class="liste_titre" align="middle">';
  558. $searchpicto = $form->showFilterButtons();
  559. print $searchpicto;
  560. print '</td>';
  561. print "</tr>\n";
  562. print '<tr class="liste_titre">';
  563. if (!empty($arrayfields['f.titre']['checked'])) {
  564. print_liste_field_titre($arrayfields['f.titre']['label'], $_SERVER['PHP_SELF'], "f.titre", "", $param, "", $sortfield, $sortorder);
  565. }
  566. if (!empty($arrayfields['s.nom']['checked'])) {
  567. print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER['PHP_SELF'], "s.nom", "", $param, "", $sortfield, $sortorder);
  568. }
  569. if (!empty($arrayfields['f.total_ht']['checked'])) {
  570. print_liste_field_titre($arrayfields['f.total_ht']['label'], $_SERVER['PHP_SELF'], "f.total_ht", "", $param, 'class="right"', $sortfield, $sortorder);
  571. }
  572. if (!empty($arrayfields['f.total_tva']['checked'])) {
  573. print_liste_field_titre($arrayfields['f.total_tva']['label'], $_SERVER['PHP_SELF'], "f.total_tva", "", $param, 'class="right"', $sortfield, $sortorder);
  574. }
  575. if (!empty($arrayfields['f.total_ttc']['checked'])) {
  576. print_liste_field_titre($arrayfields['f.total_ttc']['label'], $_SERVER['PHP_SELF'], "f.total_ttc", "", $param, 'class="right"', $sortfield, $sortorder);
  577. }
  578. if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) {
  579. print_liste_field_titre($arrayfields['f.fk_cond_reglement']['label'], $_SERVER['PHP_SELF'], "f.fk_cond_reglement", "", $param, '', $sortfield, $sortorder);
  580. }
  581. if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) {
  582. print_liste_field_titre($arrayfields['f.fk_mode_reglement']['label'], $_SERVER['PHP_SELF'], "f.fk_mode_reglement", "", $param, '', $sortfield, $sortorder);
  583. }
  584. if (!empty($arrayfields['recurring']['checked'])) {
  585. print_liste_field_titre($arrayfields['recurring']['label'], $_SERVER['PHP_SELF'], "recurring", "", $param, 'class="center"', $sortfield, $sortorder);
  586. }
  587. if (!empty($arrayfields['f.frequency']['checked'])) {
  588. print_liste_field_titre($arrayfields['f.frequency']['label'], $_SERVER['PHP_SELF'], "f.frequency", "", $param, 'align="center"', $sortfield, $sortorder);
  589. }
  590. if (!empty($arrayfields['f.unit_frequency']['checked'])) {
  591. print_liste_field_titre($arrayfields['f.unit_frequency']['label'], $_SERVER['PHP_SELF'], "f.unit_frequency", "", $param, 'align="center"', $sortfield, $sortorder);
  592. }
  593. if (!empty($arrayfields['f.nb_gen_done']['checked'])) {
  594. print_liste_field_titre($arrayfields['f.nb_gen_done']['label'], $_SERVER['PHP_SELF'], "f.nb_gen_done", "", $param, 'align="center"', $sortfield, $sortorder);
  595. }
  596. if (!empty($arrayfields['f.date_last_gen']['checked'])) {
  597. print_liste_field_titre($arrayfields['f.date_last_gen']['label'], $_SERVER['PHP_SELF'], "f.date_last_gen", "", $param, 'align="center"', $sortfield, $sortorder);
  598. }
  599. if (!empty($arrayfields['f.date_when']['checked'])) {
  600. print_liste_field_titre($arrayfields['f.date_when']['label'], $_SERVER['PHP_SELF'], "f.date_when", "", $param, 'align="center"', $sortfield, $sortorder);
  601. }
  602. if (!empty($arrayfields['f.fk_user_author']['checked'])) {
  603. print_liste_field_titre($arrayfields['f.fk_user_author']['label'], $_SERVER['PHP_SELF'], "f.fk_user_author", "", $param, 'align="center"', $sortfield, $sortorder);
  604. }
  605. if (!empty($arrayfields['f.fk_user_modif']['checked'])) {
  606. print_liste_field_titre($arrayfields['f.fk_user_modif']['label'], $_SERVER['PHP_SELF'], "f.fk_user_modif", "", $param, 'align="center"', $sortfield, $sortorder);
  607. }
  608. if (!empty($arrayfields['f.datec']['checked'])) {
  609. print_liste_field_titre($arrayfields['f.datec']['label'], $_SERVER['PHP_SELF'], "f.datec", "", $param, 'align="center"', $sortfield, $sortorder);
  610. }
  611. if (!empty($arrayfields['f.tms']['checked'])) {
  612. print_liste_field_titre($arrayfields['f.tms']['label'], $_SERVER['PHP_SELF'], "f.tms", "", $param, 'align="center"', $sortfield, $sortorder);
  613. }
  614. // Extra fields
  615. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
  616. if (!empty($arrayfields['status']['checked'])) {
  617. print_liste_field_titre($arrayfields['status']['label'], $_SERVER['PHP_SELF'], "f.suspended,f.frequency", "", $param, 'align="center"', $sortfield, $sortorder);
  618. }
  619. print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'center maxwidthsearch ');
  620. print "</tr>\n";
  621. if ($num > 0) {
  622. $i = 0;
  623. $totalarray = array();
  624. $totalarray['nbfield'] = 0;
  625. $totalarray['val']['f.total_ht'] = 0;
  626. $totalarray['val']['f.total_tva'] = 0;
  627. $totalarray['val']['f.total_ttc'] = 0;
  628. while ($i < min($num, $limit)) {
  629. $objp = $db->fetch_object($resql);
  630. if (empty($objp)) {
  631. break;
  632. }
  633. $companystatic->id = $objp->socid;
  634. $companystatic->name = $objp->name;
  635. $supplierinvoicerectmp->id = !empty($objp->id) ? $objp->id : $objp->facid;
  636. $supplierinvoicerectmp->frequency = $objp->frequency;
  637. $supplierinvoicerectmp->suspended = $objp->suspended;
  638. $supplierinvoicerectmp->unit_frequency = $objp->unit_frequency;
  639. $supplierinvoicerectmp->nb_gen_max = $objp->nb_gen_max;
  640. $supplierinvoicerectmp->nb_gen_done = $objp->nb_gen_done;
  641. $supplierinvoicerectmp->ref = $objp->title;
  642. $supplierinvoicerectmp->total_ht = $objp->total_ht;
  643. $supplierinvoicerectmp->total_tva = $objp->total_tva;
  644. $supplierinvoicerectmp->total_ttc = $objp->total_ttc;
  645. print '<tr class="oddeven">';
  646. if (!empty($arrayfields['f.titre']['checked'])) {
  647. print '<td class="nowrap tdoverflowmax200">';
  648. print $supplierinvoicerectmp->getNomUrl(1);
  649. print "</a>";
  650. print "</td>\n";
  651. if (!$i) {
  652. $totalarray['nbfield']++;
  653. }
  654. }
  655. if (!empty($arrayfields['s.nom']['checked'])) {
  656. print '<td class="tdoverflowmax200">'.$companystatic->getNomUrl(1, 'customer').'</td>';
  657. if (!$i) {
  658. $totalarray['nbfield']++;
  659. }
  660. }
  661. if (!empty($arrayfields['f.total_ht']['checked'])) {
  662. print '<td class="nowrap right amount">'.price($objp->total_ht).'</td>'."\n";
  663. if (!$i) {
  664. $totalarray['nbfield']++;
  665. }
  666. if (!$i) {
  667. $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ht';
  668. }
  669. $totalarray['val']['f.total_ht'] += $objp->total_ht;
  670. }
  671. if (!empty($arrayfields['f.total_tva']['checked'])) {
  672. print '<td class="nowrap right amount">'.price($objp->total_tva).'</td>'."\n";
  673. if (!$i) {
  674. $totalarray['nbfield']++;
  675. }
  676. if (!$i) {
  677. $totalarray['pos'][$totalarray['nbfield']] = 'f.total_tva';
  678. }
  679. $totalarray['val']['f.total_tva'] += $objp->total_tva;
  680. }
  681. if (!empty($arrayfields['f.total_ttc']['checked'])) {
  682. print '<td class="nowrap right amount">'.price($objp->total_ttc).'</td>'."\n";
  683. if (!$i) {
  684. $totalarray['nbfield']++;
  685. }
  686. if (!$i) {
  687. $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ttc';
  688. }
  689. $totalarray['val']['f.total_ttc'] += $objp->total_ttc;
  690. }
  691. // Payment term
  692. if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) {
  693. print '<td class="right">';
  694. $form->form_conditions_reglement('', $objp->fk_cond_reglement, 'none');
  695. print '</td>'."\n";
  696. if (!$i) {
  697. $totalarray['nbfield']++;
  698. }
  699. }
  700. // Payment mode
  701. if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) {
  702. print '<td class="right">';
  703. $form->form_modes_reglement('', $objp->fk_mode_reglement, 'none');
  704. print '</td>'."\n";
  705. if (!$i) {
  706. $totalarray['nbfield']++;
  707. }
  708. }
  709. // Is it a recurring invoice
  710. if (!empty($arrayfields['recurring']['checked'])) {
  711. 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>';
  712. if (!$i) {
  713. $totalarray['nbfield']++;
  714. }
  715. }
  716. if (!empty($arrayfields['f.frequency']['checked'])) {
  717. print '<td class="center">'.($objp->frequency > 0 ? $objp->frequency : '').'</td>';
  718. if (!$i) {
  719. $totalarray['nbfield']++;
  720. }
  721. }
  722. if (!empty($arrayfields['f.unit_frequency']['checked'])) {
  723. print '<td class="center">'.($objp->frequency > 0 ? $objp->unit_frequency : '').'</td>';
  724. if (!$i) {
  725. $totalarray['nbfield']++;
  726. }
  727. }
  728. if (!empty($arrayfields['f.nb_gen_done']['checked'])) {
  729. print '<td class="center">';
  730. print ($objp->frequency > 0 ? $objp->nb_gen_done.($objp->nb_gen_max > 0 ? ' / '.$objp->nb_gen_max : '') : '<span class="opacitymedium">'.$langs->trans('NA').'</span>');
  731. print '</td>';
  732. if (!$i) {
  733. $totalarray['nbfield']++;
  734. }
  735. }
  736. // Date last generation
  737. if (!empty($arrayfields['f.date_last_gen']['checked'])) {
  738. print '<td class="center">';
  739. print ($objp->frequency > 0 ? dol_print_date($db->jdate($objp->date_last_gen), 'day') : '<span class="opacitymedium">'.$langs->trans('NA').'</span>');
  740. print '</td>';
  741. if (!$i) {
  742. $totalarray['nbfield']++;
  743. }
  744. }
  745. // Date next generation
  746. if (!empty($arrayfields['f.date_when']['checked'])) {
  747. print '<td class="center">';
  748. print '<div class="nowraponall">';
  749. print ($objp->frequency ? ($supplierinvoicerectmp->isMaxNbGenReached() ? '<strike>' : '').dol_print_date($db->jdate($objp->date_when), 'day').($supplierinvoicerectmp->isMaxNbGenReached() ? '</strike>' : '') : '<span class="opacitymedium">'.$langs->trans('NA').'</span>');
  750. if (!$supplierinvoicerectmp->isMaxNbGenReached()) {
  751. if (!$objp->suspended && $objp->frequency > 0 && $db->jdate($objp->date_when) && $db->jdate($objp->date_when) < $now) {
  752. print img_warning($langs->trans("Late"));
  753. }
  754. } else {
  755. print img_info($langs->trans("MaxNumberOfGenerationReached"));
  756. }
  757. print '</div>';
  758. print '</td>';
  759. if (!$i) {
  760. $totalarray['nbfield']++;
  761. }
  762. }
  763. if (!empty($arrayfields['f.fk_user_author']['checked'])) {
  764. print '<td class="center tdoverflowmax150">';
  765. if ($objp->fk_user_author > 0) {
  766. $tmpuser->fetch($objp->fk_user_author);
  767. print $tmpuser->getNomUrl(1);
  768. }
  769. print '</td>';
  770. if (!$i) {
  771. $totalarray['nbfield']++;
  772. }
  773. }
  774. if (!empty($arrayfields['f.fk_user_modif']['checked'])) {
  775. print '<td class="center tdoverflowmax150">';
  776. if ($objp->fk_user_author > 0) {
  777. $tmpuser->fetch($objp->fk_user_author);
  778. print $tmpuser->getNomUrl(1);
  779. }
  780. print '</td>';
  781. if (!$i) {
  782. $totalarray['nbfield']++;
  783. }
  784. }
  785. if (!empty($arrayfields['f.datec']['checked'])) {
  786. print '<td class="center">';
  787. print dol_print_date($db->jdate($objp->datec), 'dayhour');
  788. print '</td>';
  789. if (!$i) {
  790. $totalarray['nbfield']++;
  791. }
  792. }
  793. if (!empty($arrayfields['f.tms']['checked'])) {
  794. print '<td class="center">';
  795. print dol_print_date($db->jdate($objp->tms), 'dayhour');
  796. print '</td>';
  797. if (!$i) {
  798. $totalarray['nbfield']++;
  799. }
  800. }
  801. $obj = $objp;
  802. // Extra fields
  803. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
  804. // Fields from hook
  805. $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$objp, 'i'=>$i, 'totalarray'=>&$totalarray);
  806. $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
  807. print $hookmanager->resPrint;
  808. // Status
  809. if (!empty($arrayfields['status']['checked'])) {
  810. print '<td class="center">';
  811. print $supplierinvoicerectmp->getLibStatut(3, 0);
  812. print '</td>';
  813. if (!$i) {
  814. $totalarray['nbfield']++;
  815. }
  816. }
  817. // Action column
  818. print '<td class="center tdoverflowmax125">';
  819. if ($user->rights->facture->creer && empty($supplierinvoicerectmp->suspended)) {
  820. if ($supplierinvoicerectmp->isMaxNbGenReached()) {
  821. print $langs->trans("MaxNumberOfGenerationReached");
  822. } elseif (empty($objp->frequency) || $db->jdate($objp->date_when) <= $today) {
  823. print '<a href="'.DOL_URL_ROOT.'/fourn/facture/card.php?action=create&amp;socid='.$objp->socid.'&amp;fac_rec='.$objp->facid.'">';
  824. print img_picto($langs->trans("CreateBill"), 'add', 'class="paddingrightonly"');
  825. print $langs->trans("CreateBill").'</a>';
  826. } else {
  827. print $form->textwithpicto('', $langs->trans("DateIsNotEnough"));
  828. }
  829. } else {
  830. print "&nbsp;";
  831. }
  832. if (!$i) {
  833. $totalarray['nbfield']++;
  834. }
  835. print "</td>";
  836. print "</tr>\n";
  837. $i++;
  838. }
  839. } else {
  840. $colspan = 1;
  841. foreach ($arrayfields as $key => $val) {
  842. if (!empty($val['checked'])) {
  843. $colspan++;
  844. }
  845. }
  846. print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
  847. }
  848. // Show total line
  849. include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
  850. print "</table>";
  851. print "</div>";
  852. print "</form>";
  853. $db->free($resql);
  854. } else {
  855. dol_print_error($db);
  856. }
  857. // End of page
  858. llxFooter();
  859. $db->close();