list.php 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909
  1. <?php
  2. /* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
  3. * Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
  4. * Copyright (C) 2013-2019 Alexandre Spangaro <aspangaro@open-dsi.fr>
  5. * Copyright (C) 2016-2017 Laurent Destailleur <eldy@users.sourceforge.net>
  6. * Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. */
  21. /**
  22. * \file htdocs/accountancy/bookkeeping/list.php
  23. * \ingroup Accountancy (Double entries)
  24. * \brief List operation of book keeping
  25. */
  26. require '../../main.inc.php';
  27. require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountancyexport.class.php';
  28. require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
  29. require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
  30. require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php';
  31. require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
  32. require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
  33. require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
  34. require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
  35. // Load translation files required by the page
  36. $langs->loadLangs(array("accountancy"));
  37. $socid = GETPOST('socid', 'int');
  38. $action = GETPOST('action', 'aZ09');
  39. $search_mvt_num = GETPOST('search_mvt_num', 'int');
  40. $search_doc_type = GETPOST("search_doc_type", 'alpha');
  41. $search_doc_ref = GETPOST("search_doc_ref", 'alpha');
  42. $search_date_start = dol_mktime(0, 0, 0, GETPOST('search_date_startmonth', 'int'), GETPOST('search_date_startday', 'int'), GETPOST('search_date_startyear', 'int'));
  43. $search_date_end = dol_mktime(0, 0, 0, GETPOST('search_date_endmonth', 'int'), GETPOST('search_date_endday', 'int'), GETPOST('search_date_endyear', 'int'));
  44. $search_doc_date = dol_mktime(0, 0, 0, GETPOST('doc_datemonth', 'int'), GETPOST('doc_dateday', 'int'), GETPOST('doc_dateyear', 'int'));
  45. $search_date_creation_start = dol_mktime(0, 0, 0, GETPOST('date_creation_startmonth', 'int'), GETPOST('date_creation_startday', 'int'), GETPOST('date_creation_startyear', 'int'));
  46. $search_date_creation_end = dol_mktime(0, 0, 0, GETPOST('date_creation_endmonth', 'int'), GETPOST('date_creation_endday', 'int'), GETPOST('date_creation_endyear', 'int'));
  47. $search_date_modification_start = dol_mktime(0, 0, 0, GETPOST('date_modification_startmonth', 'int'), GETPOST('date_modification_startday', 'int'), GETPOST('date_modification_startyear', 'int'));
  48. $search_date_modification_end = dol_mktime(0, 0, 0, GETPOST('date_modification_endmonth', 'int'), GETPOST('date_modification_endday', 'int'), GETPOST('date_modification_endyear', 'int'));
  49. $search_date_export_start = dol_mktime(0, 0, 0, GETPOST('date_export_startmonth', 'int'), GETPOST('date_export_startday', 'int'), GETPOST('date_export_startyear', 'int'));
  50. $search_date_export_end = dol_mktime(0, 0, 0, GETPOST('date_export_endmonth', 'int'), GETPOST('date_export_endday', 'int'), GETPOST('date_export_endyear', 'int'));
  51. //var_dump($search_date_start);exit;
  52. if (GETPOST("button_delmvt_x") || GETPOST("button_delmvt.x") || GETPOST("button_delmvt")) {
  53. $action = 'delbookkeepingyear';
  54. }
  55. if (GETPOST("button_export_file_x") || GETPOST("button_export_file.x") || GETPOST("button_export_file")) {
  56. $action = 'export_file';
  57. }
  58. $search_accountancy_code = GETPOST("search_accountancy_code");
  59. $search_accountancy_code_start = GETPOST('search_accountancy_code_start', 'alpha');
  60. if ($search_accountancy_code_start == - 1) {
  61. $search_accountancy_code_start = '';
  62. }
  63. $search_accountancy_code_end = GETPOST('search_accountancy_code_end', 'alpha');
  64. if ($search_accountancy_code_end == - 1) {
  65. $search_accountancy_code_end = '';
  66. }
  67. $search_accountancy_aux_code = GETPOST("search_accountancy_aux_code");
  68. $search_accountancy_aux_code_start = GETPOST('search_accountancy_aux_code_start', 'alpha');
  69. if ($search_accountancy_aux_code_start == - 1) {
  70. $search_accountancy_aux_code_start = '';
  71. }
  72. $search_accountancy_aux_code_end = GETPOST('search_accountancy_aux_code_end', 'alpha');
  73. if ($search_accountancy_aux_code_end == - 1) {
  74. $search_accountancy_aux_code_end = '';
  75. }
  76. $search_mvt_label = GETPOST('search_mvt_label', 'alpha');
  77. $search_direction = GETPOST('search_direction', 'alpha');
  78. $search_debit = GETPOST('search_debit', 'alpha');
  79. $search_credit = GETPOST('search_credit', 'alpha');
  80. $search_ledger_code = GETPOST('search_ledger_code', 'alpha');
  81. $search_lettering_code = GETPOST('search_lettering_code', 'alpha');
  82. // Load variable for pagination
  83. $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
  84. $sortfield = GETPOST('sortfield', 'alpha');
  85. $sortorder = GETPOST('sortorder', 'alpha');
  86. $page = GETPOST('page', 'int');
  87. if (empty($page) || $page < 0) { $page = 0; }
  88. $offset = $limit * $page;
  89. $pageprev = $page - 1;
  90. $pagenext = $page + 1;
  91. if ($sortorder == "") $sortorder = "ASC";
  92. if ($sortfield == "") $sortfield = "t.piece_num,t.rowid";
  93. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  94. $object = new BookKeeping($db);
  95. $hookmanager->initHooks(array('bookkeepinglist'));
  96. $formaccounting = new FormAccounting($db);
  97. $formother = new FormOther($db);
  98. $form = new Form($db);
  99. if (! in_array($action, array('export_file', 'delmouv', 'delmouvconfirm')) && ! isset($_POST['begin']) && ! isset($_GET['begin']) && ! isset($_POST['formfilteraction']) && GETPOST('page', 'int') == '' && ! GETPOST('noreset', 'int') && $user->rights->accounting->mouvements->export)
  100. {
  101. if (empty($search_date_start) && empty($search_date_end) && ! GETPOSTISSET('restore_lastsearch_values'))
  102. {
  103. $query = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear ";
  104. $query.= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."' limit 1";
  105. $res = $db->query($query);
  106. if ($res->num_rows > 0) {
  107. $fiscalYear = $db->fetch_object($res);
  108. $search_date_start = strtotime($fiscalYear->date_start);
  109. $search_date_end = strtotime($fiscalYear->date_end);
  110. } else {
  111. $month_start= ($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1);
  112. $year_start = dol_print_date(dol_now(), '%Y');
  113. if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year
  114. $year_end = $year_start + 1;
  115. $month_end = $month_start - 1;
  116. if ($month_end < 1)
  117. {
  118. $month_end = 12;
  119. $year_end--;
  120. }
  121. $search_date_start = dol_mktime(0, 0, 0, $month_start, 1, $year_start);
  122. $search_date_end = dol_get_last_day($year_end, $month_end);
  123. }
  124. }
  125. }
  126. $arrayfields=array(
  127. 't.piece_num'=>array('label'=>$langs->trans("TransactionNumShort"), 'checked'=>1),
  128. 't.doc_date'=>array('label'=>$langs->trans("Docdate"), 'checked'=>1),
  129. 't.doc_ref'=>array('label'=>$langs->trans("Piece"), 'checked'=>1),
  130. 't.numero_compte'=>array('label'=>$langs->trans("AccountAccountingShort"), 'checked'=>1),
  131. 't.subledger_account'=>array('label'=>$langs->trans("SubledgerAccount"), 'checked'=>1),
  132. 't.label_operation'=>array('label'=>$langs->trans("Label"), 'checked'=>1),
  133. 't.debit'=>array('label'=>$langs->trans("Debit"), 'checked'=>1),
  134. 't.credit'=>array('label'=>$langs->trans("Credit"), 'checked'=>1),
  135. 't.lettering_code'=>array('label'=>$langs->trans("LetteringCode"), 'checked'=>1),
  136. 't.code_journal'=>array('label'=>$langs->trans("Codejournal"), 'checked'=>1),
  137. 't.date_creation'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0),
  138. 't.tms'=>array('label'=>$langs->trans("DateModification"), 'checked'=>0),
  139. 't.date_export'=>array('label'=>$langs->trans("DateExport"), 'checked'=>1),
  140. );
  141. if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) unset($arrayfields['t.lettering_code']);
  142. /*
  143. * Actions
  144. */
  145. if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; }
  146. if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; }
  147. $parameters=array('socid'=>$socid);
  148. $reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  149. if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  150. if (empty($reshook))
  151. {
  152. include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
  153. if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
  154. {
  155. $search_mvt_num = '';
  156. $search_doc_type = '';
  157. $search_doc_ref = '';
  158. $search_doc_date = '';
  159. $search_accountancy_code = '';
  160. $search_accountancy_code_start = '';
  161. $search_accountancy_code_end = '';
  162. $search_accountancy_aux_code = '';
  163. $search_accountancy_aux_code_start = '';
  164. $search_accountancy_aux_code_end = '';
  165. $search_mvt_label = '';
  166. $search_direction = '';
  167. $search_ledger_code = '';
  168. $search_date_start = '';
  169. $search_date_end = '';
  170. $search_date_creation_start = '';
  171. $search_date_creation_end = '';
  172. $search_date_modification_start = '';
  173. $search_date_modification_end = '';
  174. $search_date_export_start = '';
  175. $search_date_export_end = '';
  176. $search_debit = '';
  177. $search_credit = '';
  178. $search_lettering_code = '';
  179. }
  180. // Must be after the remove filter action, before the export.
  181. $param = '';
  182. $filter = array ();
  183. if (! empty($search_date_start)) {
  184. $filter['t.doc_date>='] = $search_date_start;
  185. $tmp=dol_getdate($search_date_start);
  186. $param .= '&search_date_startmonth=' . $tmp['mon'] . '&search_date_startday=' . $tmp['mday'] . '&search_date_startyear=' . $tmp['year'];
  187. }
  188. if (! empty($search_date_end)) {
  189. $filter['t.doc_date<='] = $search_date_end;
  190. $tmp=dol_getdate($search_date_end);
  191. $param .= '&search_date_endmonth=' . $tmp['mon'] . '&search_date_endday=' . $tmp['mday'] . '&search_date_endyear=' . $tmp['year'];
  192. }
  193. if (! empty($search_doc_date)) {
  194. $filter['t.doc_date'] = $search_doc_date;
  195. $tmp=dol_getdate($search_doc_date);
  196. $param .= '&doc_datemonth=' . $tmp['mon'] . '&doc_dateday=' . $tmp['mday'] . '&doc_dateyear=' . $tmp['year'];
  197. }
  198. if (! empty($search_doc_type)) {
  199. $filter['t.doc_type'] = $search_doc_type;
  200. $param .= '&search_doc_type=' . urlencode($search_doc_type);
  201. }
  202. if (! empty($search_doc_ref)) {
  203. $filter['t.doc_ref'] = $search_doc_ref;
  204. $param .= '&search_doc_ref=' . urlencode($search_doc_ref);
  205. }
  206. if (! empty($search_accountancy_code)) {
  207. $filter['t.numero_compte'] = $search_accountancy_code;
  208. $param .= '&search_accountancy_code=' . urlencode($search_accountancy_code);
  209. }
  210. if (! empty($search_accountancy_code_start)) {
  211. $filter['t.numero_compte>='] = $search_accountancy_code_start;
  212. $param .= '&search_accountancy_code_start=' . urlencode($search_accountancy_code_start);
  213. }
  214. if (! empty($search_accountancy_code_end)) {
  215. $filter['t.numero_compte<='] = $search_accountancy_code_end;
  216. $param .= '&search_accountancy_code_end=' . urlencode($search_accountancy_code_end);
  217. }
  218. if (! empty($search_accountancy_aux_code)) {
  219. $filter['t.subledger_account'] = $search_accountancy_aux_code;
  220. $param .= '&search_accountancy_aux_code=' . urlencode($search_accountancy_aux_code);
  221. }
  222. if (! empty($search_accountancy_aux_code_start)) {
  223. $filter['t.subledger_account>='] = $search_accountancy_aux_code_start;
  224. $param .= '&search_accountancy_aux_code_start=' . urlencode($search_accountancy_aux_code_start);
  225. }
  226. if (! empty($search_accountancy_aux_code_end)) {
  227. $filter['t.subledger_account<='] = $search_accountancy_aux_code_end;
  228. $param .= '&search_accountancy_aux_code_end=' . urlencode($search_accountancy_aux_code_end);
  229. }
  230. if (! empty($search_mvt_label)) {
  231. $filter['t.label_operation'] = $search_mvt_label;
  232. $param .= '&search_mvt_label=' . urlencode($search_mvt_label);
  233. }
  234. if (! empty($search_direction)) {
  235. $filter['t.sens'] = $search_direction;
  236. $param .= '&search_direction=' . urlencode($search_direction);
  237. }
  238. if (! empty($search_ledger_code)) {
  239. $filter['t.code_journal'] = $search_ledger_code;
  240. $param .= '&search_ledger_code=' . urlencode($search_ledger_code);
  241. }
  242. if (! empty($search_mvt_num)) {
  243. $filter['t.piece_num'] = $search_mvt_num;
  244. $param .= '&search_mvt_num=' . urlencode($search_mvt_num);
  245. }
  246. if (! empty($search_date_creation_start)) {
  247. $filter['t.date_creation>='] = $search_date_creation_start;
  248. $tmp=dol_getdate($search_date_creation_start);
  249. $param .= '&date_creation_startmonth=' . $tmp['mon'] . '&date_creation_startday=' . $tmp['mday'] . '&date_creation_startyear=' . $tmp['year'];
  250. }
  251. if (! empty($search_date_creation_end)) {
  252. $filter['t.date_creation<='] = $search_date_creation_end;
  253. $tmp=dol_getdate($search_date_creation_end);
  254. $param .= '&date_creation_endmonth=' . $tmp['mon'] . '&date_creation_endday=' . $tmp['mday'] . '&date_creation_endyear=' . $tmp['year'];
  255. }
  256. if (! empty($search_date_modification_start)) {
  257. $filter['t.tms>='] = $search_date_modification_start;
  258. $tmp=dol_getdate($search_date_modification_start);
  259. $param .= '&date_modification_startmonth=' . $tmp['mon'] . '&date_modification_startday=' . $tmp['mday'] . '&date_modification_startyear=' . $tmp['year'];
  260. }
  261. if (! empty($search_date_modification_end)) {
  262. $filter['t.tms<='] = $search_date_modification_end;
  263. $tmp=dol_getdate($search_date_modification_end);
  264. $param .= '&date_modification_endmonth=' . $tmp['mon'] . '&date_modification_endday=' . $tmp['mday'] . '&date_modification_endyear=' . $tmp['year'];
  265. }
  266. if (! empty($search_date_export_start)) {
  267. $filter['t.date_export>='] = $search_date_export_start;
  268. $tmp=dol_getdate($search_date_export_start);
  269. $param .= '&date_export_startmonth=' . $tmp['mon'] . '&date_export_startday=' . $tmp['mday'] . '&date_export_startyear=' . $tmp['year'];
  270. }
  271. if (! empty($search_date_export_end)) {
  272. $filter['t.date_export<='] = $search_date_export_end;
  273. $tmp=dol_getdate($search_date_export_end);
  274. $param .= '&date_export_endmonth=' . $tmp['mon'] . '&date_export_endday=' . $tmp['mday'] . '&date_export_endyear=' . $tmp['year'];
  275. }
  276. if (! empty($search_debit)) {
  277. $filter['t.debit'] = $search_debit;
  278. $param .= '&search_debit=' . urlencode($search_debit);
  279. }
  280. if (! empty($search_credit)) {
  281. $filter['t.credit'] = $search_credit;
  282. $param .= '&search_credit=' . urlencode($search_credit);
  283. }
  284. if (! empty($search_lettering_code)) {
  285. $filter['t.lettering_code'] = $search_lettering_code;
  286. $param .= '&search_lettering_code=' . urlencode($search_lettering_code);
  287. }
  288. }
  289. if ($action == 'delbookkeeping' && $user->rights->accounting->mouvements->supprimer) {
  290. $import_key = GETPOST('importkey', 'alpha');
  291. if (! empty($import_key)) {
  292. $result = $object->deleteByImportkey($import_key);
  293. if ($result < 0) {
  294. setEventMessages($object->error, $object->errors, 'errors');
  295. }
  296. // Make a redirect to avoid to launch the delete later after a back button
  297. header("Location: list.php".($param?'?'.$param:''));
  298. exit;
  299. }
  300. }
  301. if ($action == 'delbookkeepingyearconfirm' && $user->rights->accounting->mouvements->supprimer_tous) {
  302. $delyear = GETPOST('delyear', 'int');
  303. if ($delyear==-1) {
  304. $delyear=0;
  305. }
  306. $deljournal = GETPOST('deljournal', 'alpha');
  307. if ($deljournal==-1) {
  308. $deljournal=0;
  309. }
  310. if (! empty($delyear) || ! empty($deljournal))
  311. {
  312. $result = $object->deleteByYearAndJournal($delyear, $deljournal);
  313. if ($result < 0) {
  314. setEventMessages($object->error, $object->errors, 'errors');
  315. }
  316. else
  317. {
  318. setEventMessages("RecordDeleted", null, 'mesgs');
  319. }
  320. // Make a redirect to avoid to launch the delete later after a back button
  321. header("Location: list.php".($param?'?'.$param:''));
  322. exit;
  323. }
  324. else
  325. {
  326. setEventMessages("NoRecordDeleted", null, 'warnings');
  327. }
  328. }
  329. if ($action == 'delmouvconfirm' && $user->rights->accounting->mouvements->supprimer) {
  330. $mvt_num = GETPOST('mvt_num', 'int');
  331. if (! empty($mvt_num)) {
  332. $result = $object->deleteMvtNum($mvt_num);
  333. if ($result < 0) {
  334. setEventMessages($object->error, $object->errors, 'errors');
  335. }
  336. else
  337. {
  338. setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
  339. }
  340. header("Location: list.php?noreset=1".($param?'&'.$param:''));
  341. exit;
  342. }
  343. }
  344. // Export into a file with format defined into setup (FEC, CSV, ...)
  345. if ($action == 'export_file' && $user->rights->accounting->mouvements->export) {
  346. $result = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter, 'AND', $conf->global->ACCOUNTING_REEXPORT);
  347. if ($result < 0)
  348. {
  349. setEventMessages($object->error, $object->errors, 'errors');
  350. }
  351. else
  352. {
  353. // Export files
  354. $accountancyexport = new AccountancyExport($db);
  355. $accountancyexport->export($object->lines);
  356. if (! empty($accountancyexport->errors))
  357. {
  358. setEventMessages('', $accountancyexport->errors, 'errors');
  359. } else {
  360. // Specify as export : update field date_export
  361. // TODO Move in class bookKeeping
  362. $error=0;
  363. $db->begin();
  364. if (is_array($object->lines)) {
  365. foreach ($object->lines as $movement) {
  366. $now = dol_now();
  367. $sql = " UPDATE " . MAIN_DB_PREFIX . "accounting_bookkeeping";
  368. $sql .= " SET date_export = '" . $db->idate($now) . "'";
  369. $sql .= " WHERE rowid = " . $movement->id;
  370. dol_syslog("/accountancy/bookeeping/list.php Function export_file Specify movements as exported sql=" . $sql, LOG_DEBUG);
  371. $result = $db->query($sql);
  372. if ($result) {
  373. $db->commit();
  374. // setEventMessages($langs->trans("AllExportedMovementsWereRecordedAsExported"), null, 'mesgs');
  375. } else {
  376. $db->rollback();
  377. // setEventMessages($langs->trans("NotAllExportedMovementsCouldBeRecordedAsExported"), null, 'errors');
  378. }
  379. }
  380. }
  381. }
  382. exit;
  383. }
  384. }
  385. if ($action == 'setreexport') {
  386. $export = 0;
  387. $setreexport = GETPOST('value', 'int');
  388. if (! dolibarr_set_const($db, "ACCOUNTING_REEXPORT", $setreexport, 'yesno', 0, '', $conf->entity)) $error++;
  389. if (! $error) {
  390. if ($conf->global->ACCOUNTING_REEXPORT == 1) {
  391. setEventMessages($langs->trans("ExportOfPiecesAlreadyExportedIsEnable"), null, 'mesgs');
  392. } else {
  393. setEventMessages($langs->trans("ExportOfPiecesAlreadyExportedIsDisable"), null, 'mesgs');
  394. }
  395. } else {
  396. setEventMessages($langs->trans("Error"), null, 'errors');
  397. }
  398. }
  399. /*
  400. * View
  401. */
  402. $title_page = $langs->trans("Bookkeeping");
  403. llxHeader('', $title_page);
  404. // List
  405. $nbtotalofrecords = '';
  406. if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
  407. $nbtotalofrecords = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter, 'AND', $conf->global->ACCOUNTING_REEXPORT);
  408. if ($nbtotalofrecords < 0) {
  409. setEventMessages($object->error, $object->errors, 'errors');
  410. }
  411. }
  412. // TODO Do not use this
  413. $result = $object->fetchAll($sortorder, $sortfield, $limit, $offset, $filter, 'AND', $conf->global->ACCOUNTING_REEXPORT);
  414. if ($result < 0) {
  415. setEventMessages($object->error, $object->errors, 'errors');
  416. }
  417. $num=count($object->lines);
  418. if ($action == 'delmouv') {
  419. $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?mvt_num='.GETPOST('mvt_num').$param, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvtPartial'), 'delmouvconfirm', '', 0, 1);
  420. print $formconfirm;
  421. }
  422. if ($action == 'delbookkeepingyear') {
  423. $form_question = array ();
  424. $delyear = GETPOST('delyear');
  425. $deljournal = GETPOST('deljournal');
  426. if (empty($delyear)) {
  427. $delyear = dol_print_date(dol_now(), '%Y');
  428. }
  429. $year_array = $formaccounting->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array');
  430. $journal_array = $formaccounting->select_journal($deljournal, 'deljournal', '', 1, 1, 1, '', 0, 1);
  431. $form_question['delyear'] = array (
  432. 'name' => 'delyear',
  433. 'type' => 'select',
  434. 'label' => $langs->trans('DelYear'),
  435. 'values' => $year_array,
  436. 'default' => $delyear
  437. );
  438. $form_question['deljournal'] = array (
  439. 'name' => 'deljournal',
  440. 'type' => 'other', // We don't use select here, the journal_array is already a select html component
  441. 'label' => $langs->trans('DelJournal'),
  442. 'value' => $journal_array,
  443. 'default' => $deljournal
  444. );
  445. $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?'.$param, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'delbookkeepingyearconfirm', $form_question, 0, 1, 250);
  446. print $formconfirm;
  447. }
  448. //$param=''; param started before
  449. if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
  450. if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
  451. print '<form method="POST" id="searchFormList" action="' . $_SERVER["PHP_SELF"] . '">';
  452. print '<input type="hidden" name="action" value="list">';
  453. if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  454. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  455. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  456. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  457. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  458. print '<input type="hidden" name="page" value="'.$page.'">';
  459. $button .= '<a class="butAction" title="" name="button_export_file" href="'.$_SERVER["PHP_SELF"].'?action=export_file'.($param?'&'.$param:'').'">';
  460. $listofformat=AccountancyExport::getType();
  461. if (count($filter)) $buttonLabel = $langs->trans("ExportFilteredList");
  462. else $buttonLabel = $langs->trans("ExportList");
  463. // Button re-export
  464. if (! empty($conf->global->ACCOUNTING_REEXPORT)) {
  465. $newcardbutton ='<a href="'.$_SERVER['PHP_SELF'].'?action=setreexport&value=0'.($param?'&'.$param:'').'">'.img_picto($langs->trans("Activated"), 'switch_on').'</a> ';
  466. } else {
  467. $newcardbutton ='<a href="'.$_SERVER['PHP_SELF'].'?action=setreexport&value=1'.($param?'&'.$param:'').'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a> ';
  468. }
  469. $newcardbutton.= '<span class="valignmiddle marginrightonly">'.$langs->trans("IncludeDocsAlreadyExported").'</span>';
  470. $newcardbutton.= dolGetButtonTitle($buttonLabel, $langs->trans("ExportFilteredList").' ('.$listofformat[$conf->global->ACCOUNTING_EXPORT_MODELCSV].')', 'fa fa-file-export paddingleft', $_SERVER["PHP_SELF"].'?action=export_file'.($param?'&'.$param:''), $user->rights->accounting->mouvements->export);
  471. $newcardbutton.= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param);
  472. $newcardbutton.= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', './card.php?action=create', '', $user->rights->accounting->mouvements->creer);
  473. print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $result, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit);
  474. $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
  475. $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
  476. if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1);
  477. $parameters=array();
  478. $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
  479. if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
  480. else $moreforfilter = $hookmanager->resPrint;
  481. print '<div class="div-table-responsive">';
  482. print '<table class="tagtable liste" width="100%">';
  483. // Filters lines
  484. print '<tr class="liste_titre_filter">';
  485. // Movement number
  486. if (! empty($arrayfields['t.piece_num']['checked']))
  487. {
  488. print '<td class="liste_titre"><input type="text" name="search_mvt_num" size="6" value="' . dol_escape_htmltag($search_mvt_num) . '"></td>';
  489. }
  490. // Date document
  491. if (! empty($arrayfields['t.doc_date']['checked']))
  492. {
  493. print '<td class="liste_titre center">';
  494. print '<div class="nowrap">';
  495. print $langs->trans('From') . ' ';
  496. print $form->selectDate($search_date_start?$search_date_start:-1, 'search_date_start', 0, 0, 1);
  497. print '</div>';
  498. print '<div class="nowrap">';
  499. print $langs->trans('to') . ' ';
  500. print $form->selectDate($search_date_end?$search_date_end:-1, 'search_date_end', 0, 0, 1);
  501. print '</div>';
  502. print '</td>';
  503. }
  504. // Ref document
  505. if (! empty($arrayfields['t.doc_ref']['checked']))
  506. {
  507. print '<td class="liste_titre"><input type="text" name="search_doc_ref" size="8" value="' . dol_escape_htmltag($search_doc_ref) . '"></td>';
  508. }
  509. // Accountancy account
  510. if (! empty($arrayfields['t.numero_compte']['checked']))
  511. {
  512. print '<td class="liste_titre">';
  513. print '<div class="nowrap">';
  514. print $langs->trans('From').' ';
  515. print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, 'maxwidth200');
  516. print '</div>';
  517. print '<div class="nowrap">';
  518. print $langs->trans('to').' ';
  519. print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array (), 1, 1, 'maxwidth200');
  520. print '</div>';
  521. print '</td>';
  522. }
  523. // Subledger account
  524. if (! empty($arrayfields['t.subledger_account']['checked']))
  525. {
  526. print '<td class="liste_titre">';
  527. print '<div class="nowrap">';
  528. print $langs->trans('From').' ';
  529. // TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because it does not
  530. // use setup of keypress to select thirdparty and this hang browser on large database.
  531. if (! empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX))
  532. {
  533. print $formaccounting->select_auxaccount($search_accountancy_aux_code_start, 'search_accountancy_aux_code_start', 1);
  534. }
  535. else
  536. {
  537. print '<input type="text" class="maxwidth100" name="search_accountancy_aux_code_start" value="'.$search_accountancy_aux_code_start.'">';
  538. }
  539. print '</div>';
  540. print '<div class="nowrap">';
  541. print $langs->trans('to').' ';
  542. // TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because it does not
  543. // use setup of keypress to select thirdparty and this hang browser on large database.
  544. if (! empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX))
  545. {
  546. print $formaccounting->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', 1);
  547. }
  548. else
  549. {
  550. print '<input type="text" class="maxwidth100" name="search_accountancy_aux_code_end" value="'.$search_accountancy_aux_code_end.'">';
  551. }
  552. print '</div>';
  553. print '</td>';
  554. }
  555. // Label operation
  556. if (! empty($arrayfields['t.label_operation']['checked']))
  557. {
  558. print '<td class="liste_titre">';
  559. print '<input type="text" size="7" class="flat" name="search_mvt_label" value="' . $search_mvt_label . '"/>';
  560. print '</td>';
  561. }
  562. // Debit
  563. if (! empty($arrayfields['t.debit']['checked']))
  564. {
  565. print '<td class="liste_titre right">';
  566. print '<input type="text" class="flat" name="search_debit" size="4" value="'.dol_escape_htmltag($search_debit).'">';
  567. print '</td>';
  568. }
  569. // Credit
  570. if (! empty($arrayfields['t.credit']['checked']))
  571. {
  572. print '<td class="liste_titre right">';
  573. print '<input type="text" class="flat" name="search_credit" size="4" value="'.dol_escape_htmltag($search_credit).'">';
  574. print '</td>';
  575. }
  576. // Lettering code
  577. if (! empty($arrayfields['t.lettering_code']['checked']))
  578. {
  579. print '<td class="liste_titre center">';
  580. print '<input type="text" size="3" class="flat" name="search_lettering_code" value="' . $search_lettering_code . '"/>';
  581. print '</td>';
  582. }
  583. // Code journal
  584. if (! empty($arrayfields['t.code_journal']['checked']))
  585. {
  586. print '<td class="liste_titre center"><input type="text" name="search_ledger_code" size="3" value="' . $search_ledger_code . '"></td>';
  587. }
  588. // Fields from hook
  589. $parameters=array('arrayfields'=>$arrayfields);
  590. $reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
  591. print $hookmanager->resPrint;
  592. // Date creation
  593. if (! empty($arrayfields['t.date_creation']['checked']))
  594. {
  595. print '<td class="liste_titre center">';
  596. print '<div class="nowrap">';
  597. print $langs->trans('From') . ' ';
  598. print $form->selectDate($search_date_creation_start, 'date_creation_start', 0, 0, 1);
  599. print '</div>';
  600. print '<div class="nowrap">';
  601. print $langs->trans('to') . ' ';
  602. print $form->selectDate($search_date_creation_end, 'date_creation_end', 0, 0, 1);
  603. print '</div>';
  604. print '</td>';
  605. }
  606. // Date modification
  607. if (! empty($arrayfields['t.tms']['checked']))
  608. {
  609. print '<td class="liste_titre center">';
  610. print '<div class="nowrap">';
  611. print $langs->trans('From') . ' ';
  612. print $form->selectDate($search_date_modification_start, 'date_modification_start', 0, 0, 1);
  613. print '</div>';
  614. print '<div class="nowrap">';
  615. print $langs->trans('to') . ' ';
  616. print $form->selectDate($search_date_modification_end, 'date_modification_end', 0, 0, 1);
  617. print '</div>';
  618. print '</td>';
  619. }
  620. // Date export
  621. if (! empty($arrayfields['t.date_export']['checked']))
  622. {
  623. print '<td class="liste_titre center">';
  624. print '<div class="nowrap">';
  625. print $langs->trans('From') . ' ';
  626. print $form->selectDate($search_date_export_start, 'date_export_start', 0, 0, 1);
  627. print '</div>';
  628. print '<div class="nowrap">';
  629. print $langs->trans('to') . ' ';
  630. print $form->selectDate($search_date_export_end, 'date_export_end', 0, 0, 1);
  631. print '</div>';
  632. print '</td>';
  633. }
  634. // Action column
  635. print '<td class="liste_titre center">';
  636. $searchpicto=$form->showFilterButtons();
  637. print $searchpicto;
  638. print '</td>';
  639. print "</tr>\n";
  640. print '<tr class="liste_titre">';
  641. if (! empty($arrayfields['t.piece_num']['checked'])) print_liste_field_titre($arrayfields['t.piece_num']['label'], $_SERVER['PHP_SELF'], "t.piece_num", "", $param, "", $sortfield, $sortorder);
  642. if (! empty($arrayfields['t.doc_date']['checked'])) print_liste_field_titre($arrayfields['t.doc_date']['label'], $_SERVER['PHP_SELF'], "t.doc_date", "", $param, '', $sortfield, $sortorder, 'center ');
  643. if (! empty($arrayfields['t.doc_ref']['checked'])) print_liste_field_titre($arrayfields['t.doc_ref']['label'], $_SERVER['PHP_SELF'], "t.doc_ref", "", $param, "", $sortfield, $sortorder);
  644. if (! empty($arrayfields['t.numero_compte']['checked'])) print_liste_field_titre($arrayfields['t.numero_compte']['label'], $_SERVER['PHP_SELF'], "t.numero_compte", "", $param, "", $sortfield, $sortorder);
  645. if (! empty($arrayfields['t.subledger_account']['checked'])) print_liste_field_titre($arrayfields['t.subledger_account']['label'], $_SERVER['PHP_SELF'], "t.subledger_account", "", $param, "", $sortfield, $sortorder);
  646. if (! empty($arrayfields['t.label_operation']['checked'])) print_liste_field_titre($arrayfields['t.label_operation']['label'], $_SERVER['PHP_SELF'], "t.label_operation", "", $param, "", $sortfield, $sortorder);
  647. if (! empty($arrayfields['t.debit']['checked'])) print_liste_field_titre($arrayfields['t.debit']['label'], $_SERVER['PHP_SELF'], "t.debit", "", $param, '', $sortfield, $sortorder, 'right ');
  648. if (! empty($arrayfields['t.credit']['checked'])) print_liste_field_titre($arrayfields['t.credit']['label'], $_SERVER['PHP_SELF'], "t.credit", "", $param, '', $sortfield, $sortorder, 'right ');
  649. if (! empty($arrayfields['t.lettering_code']['checked'])) print_liste_field_titre($arrayfields['t.lettering_code']['label'], $_SERVER['PHP_SELF'], "t.lettering_code", "", $param, '', $sortfield, $sortorder, 'center ');
  650. if (! empty($arrayfields['t.code_journal']['checked'])) print_liste_field_titre($arrayfields['t.code_journal']['label'], $_SERVER['PHP_SELF'], "t.code_journal", "", $param, '', $sortfield, $sortorder, 'center ');
  651. // Hook fields
  652. $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder);
  653. $reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
  654. print $hookmanager->resPrint;
  655. if (! empty($arrayfields['t.date_creation']['checked'])) print_liste_field_titre($arrayfields['t.date_creation']['label'], $_SERVER['PHP_SELF'], "t.date_creation", "", $param, '', $sortfield, $sortorder, 'center ');
  656. if (! empty($arrayfields['t.tms']['checked'])) print_liste_field_titre($arrayfields['t.tms']['label'], $_SERVER['PHP_SELF'], "t.tms", "", $param, '', $sortfield, $sortorder, 'center ');
  657. if (! empty($arrayfields['t.date_export']['checked'])) print_liste_field_titre($arrayfields['t.date_export']['label'], $_SERVER['PHP_SELF'], "t.date_export", "", $param, '', $sortfield, $sortorder, 'center ');
  658. print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
  659. print "</tr>\n";
  660. if ($num > 0)
  661. {
  662. $i=0;
  663. $totalarray=array();
  664. while ($i < min($num, $limit))
  665. {
  666. $line = $object->lines[$i];
  667. $total_debit += $line->debit;
  668. $total_credit += $line->credit;
  669. print '<tr class="oddeven">';
  670. // Piece number
  671. if (! empty($arrayfields['t.piece_num']['checked']))
  672. {
  673. print '<td>';
  674. $object->id = $line->id;
  675. $object->piece_num = $line->piece_num;
  676. print $object->getNomUrl(1, '', 0, '', 1);
  677. print '</td>';
  678. if (! $i) $totalarray['nbfield']++;
  679. }
  680. // Document date
  681. if (! empty($arrayfields['t.doc_date']['checked']))
  682. {
  683. print '<td class="center">' . dol_print_date($line->doc_date, 'day') . '</td>';
  684. if (! $i) $totalarray['nbfield']++;
  685. }
  686. // Document ref
  687. if (! empty($arrayfields['t.doc_ref']['checked']))
  688. {
  689. print '<td class="nowrap">' . $line->doc_ref . '</td>';
  690. if (! $i) $totalarray['nbfield']++;
  691. }
  692. // Account number
  693. if (! empty($arrayfields['t.numero_compte']['checked']))
  694. {
  695. print '<td>' . length_accountg($line->numero_compte) . '</td>';
  696. if (! $i) $totalarray['nbfield']++;
  697. }
  698. // Subledger account
  699. if (! empty($arrayfields['t.subledger_account']['checked']))
  700. {
  701. print '<td>' . length_accounta($line->subledger_account) . '</td>';
  702. if (! $i) $totalarray['nbfield']++;
  703. }
  704. // Label operation
  705. if (! empty($arrayfields['t.label_operation']['checked']))
  706. {
  707. print '<td>' . $line->label_operation . '</td>';
  708. if (! $i) $totalarray['nbfield']++;
  709. }
  710. // Amount debit
  711. if (! empty($arrayfields['t.debit']['checked']))
  712. {
  713. print '<td class="nowrap right">' . ($line->debit ? price($line->debit) : ''). '</td>';
  714. if (! $i) $totalarray['nbfield']++;
  715. if (! $i) $totalarray['totaldebitfield']=$totalarray['nbfield'];
  716. $totalarray['totaldebit'] += $line->debit;
  717. }
  718. // Amount credit
  719. if (! empty($arrayfields['t.credit']['checked']))
  720. {
  721. print '<td class="nowrap right">' . ($line->credit ? price($line->credit) : '') . '</td>';
  722. if (! $i) $totalarray['nbfield']++;
  723. if (! $i) $totalarray['totalcreditfield']=$totalarray['nbfield'];
  724. $totalarray['totalcredit'] += $line->credit;
  725. }
  726. // Lettering code
  727. if (! empty($arrayfields['t.lettering_code']['checked']))
  728. {
  729. print '<td class="center">' . $line->lettering_code . '</td>';
  730. if (! $i) $totalarray['nbfield']++;
  731. }
  732. // Journal code
  733. if (! empty($arrayfields['t.code_journal']['checked']))
  734. {
  735. $accountingjournal = new AccountingJournal($db);
  736. $result = $accountingjournal->fetch('', $line->code_journal);
  737. $journaltoshow = (($result > 0)?$accountingjournal->getNomUrl(0, 0, 0, '', 0) : $line->code_journal);
  738. print '<td class="center">' . $journaltoshow . '</td>';
  739. if (! $i) $totalarray['nbfield']++;
  740. }
  741. // Fields from hook
  742. $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj);
  743. $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
  744. print $hookmanager->resPrint;
  745. // Creation operation date
  746. if (! empty($arrayfields['t.date_creation']['checked']))
  747. {
  748. print '<td class="center">' . dol_print_date($line->date_creation, 'dayhour') . '</td>';
  749. if (! $i) $totalarray['nbfield']++;
  750. }
  751. // Modification operation date
  752. if (! empty($arrayfields['t.tms']['checked']))
  753. {
  754. print '<td class="center">' . dol_print_date($line->date_modification, 'dayhour') . '</td>';
  755. if (! $i) $totalarray['nbfield']++;
  756. }
  757. // Exported operation date
  758. if (! empty($arrayfields['t.date_export']['checked']))
  759. {
  760. print '<td align="center">' . dol_print_date($line->date_export, 'dayhour') . '</td>';
  761. if (! $i) $totalarray['nbfield']++;
  762. }
  763. // Action column
  764. print '<td class="nowraponall center">';
  765. if (empty($line->date_export)) {
  766. if ($user->rights->accounting->mouvements->creer) {
  767. print '<a href="' . DOL_URL_ROOT . '/accountancy/bookkeeping/card.php?piece_num=' . $line->piece_num . $param . '&page=' . $page . ($sortfield ? '&sortfield=' . $sortfield : '') . ($sortorder ? '&sortorder=' . $sortorder : '') . '">' . img_edit() . '</a>';
  768. }
  769. if ($user->rights->accounting->mouvements->supprimer) {
  770. print '&nbsp;<a href="' . $_SERVER['PHP_SELF'] . '?action=delmouv&mvt_num=' . $line->piece_num . $param . '&page=' . $page . ($sortfield ? '&sortfield=' . $sortfield : '') . ($sortorder ? '&sortorder=' . $sortorder : '') . '">' . img_delete() . '</a>';
  771. }
  772. }
  773. print '</td>';
  774. if (! $i) $totalarray['nbfield']++;
  775. print "</tr>\n";
  776. $i++;
  777. }
  778. // Show total line
  779. if (isset($totalarray['totaldebitfield']) || isset($totalarray['totalcreditfield']))
  780. {
  781. $i=0;
  782. print '<tr class="liste_total">';
  783. while ($i < $totalarray['nbfield'])
  784. {
  785. $i++;
  786. if ($i == 1)
  787. {
  788. if ($num < $limit && empty($offset)) print '<td class="left">'.$langs->trans("Total").'</td>';
  789. else print '<td class="left">'.$langs->trans("Totalforthispage").'</td>';
  790. }
  791. elseif ($totalarray['totaldebitfield'] == $i) print '<td class="nowrap right">'.price($totalarray['totaldebit']).'</td>';
  792. elseif ($totalarray['totalcreditfield'] == $i) print '<td class="nowrap right">'.price($totalarray['totalcredit']).'</td>';
  793. else print '<td></td>';
  794. }
  795. $parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql);
  796. $reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook
  797. print $hookmanager->resPrint;
  798. print '</tr>';
  799. }
  800. }
  801. print "</table>";
  802. print '</div>';
  803. // TODO Replace this with mass delete action
  804. if ($user->rights->accounting->mouvements->supprimer_tous) {
  805. print '<div class="tabsAction tabsActionNoBottom">' . "\n";
  806. print '<a class="butActionDelete" name="button_delmvt" href="' . $_SERVER["PHP_SELF"] . '?action=delbookkeepingyear' . ($param ? '&' . $param : '') . '">' . $langs->trans("DeleteMvt") . '</a>';
  807. print '</div>';
  808. }
  809. print '</form>';
  810. // End of page
  811. llxFooter();
  812. $db->close();