accounting-files.php 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852
  1. <?php
  2. /* Copyright (C) 2001-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2019 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2017 Pierre-Henry Favre <support@atm-consulting.fr>
  5. * Copyright (C) 2020 Maxime DEMAREST <maxime@indelog.fr>
  6. * Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
  7. * Copyright (C) 2022 Alexandre Spangaro <aspangaro@open-dsi.fr>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 3 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  21. */
  22. /**
  23. * \file htdocs/compta/accounting-files.php
  24. * \ingroup compta
  25. * \brief Page to show portoflio and files of a thirdparty and download it
  26. */
  27. if ((array_key_exists('action', $_GET) && $_GET['action'] == 'dl') || (array_key_exists('action', $_POST) && $_POST['action'] == 'dl')) { // To not replace token when downloading file
  28. if (!defined('NOTOKENRENEWAL')) {
  29. define('NOTOKENRENEWAL', '1');
  30. }
  31. }
  32. require '../main.inc.php';
  33. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  34. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  35. require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
  36. require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
  37. require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
  38. require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php';
  39. require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
  40. require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
  41. require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
  42. require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
  43. require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
  44. require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php';
  45. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
  46. require_once DOL_DOCUMENT_ROOT.'/loan/class/paymentloan.class.php';
  47. // Constant to define payment sens
  48. const PAY_DEBIT = 0;
  49. const PAY_CREDIT = 1;
  50. $langs->loadLangs(array("accountancy", "bills", "companies", "salaries", "compta", "trips", "banks", "loan"));
  51. $date_start = GETPOST('date_start', 'alpha');
  52. $date_startDay = GETPOST('date_startday', 'int');
  53. $date_startMonth = GETPOST('date_startmonth', 'int');
  54. $date_startYear = GETPOST('date_startyear', 'int');
  55. $date_start = dol_mktime(0, 0, 0, $date_startMonth, $date_startDay, $date_startYear, 'tzuserrel');
  56. $date_stop = GETPOST('date_stop', 'alpha');
  57. $date_stopDay = GETPOST('date_stopday', 'int');
  58. $date_stopMonth = GETPOST('date_stopmonth', 'int');
  59. $date_stopYear = GETPOST('date_stopyear', 'int');
  60. $date_stop = dol_mktime(23, 59, 59, $date_stopMonth, $date_stopDay, $date_stopYear, 'tzuserrel');
  61. $action = GETPOST('action', 'aZ09');
  62. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  63. $hookmanager->initHooks(array('comptafileslist', 'globallist'));
  64. // Load variable for pagination
  65. $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
  66. $sortfield = GETPOST('sortfield', 'aZ09comma');
  67. $sortorder = GETPOST('sortorder', 'aZ09comma');
  68. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  69. if (empty($page) || $page == -1) {
  70. $page = 0;
  71. } // If $page is not defined, or '' or -1
  72. $offset = $limit * $page;
  73. $pageprev = $page - 1;
  74. $pagenext = $page + 1;
  75. if (!$sortfield) {
  76. $sortfield = "date,item"; // Set here default search field
  77. }
  78. if (!$sortorder) {
  79. $sortorder = "DESC";
  80. }
  81. $arrayfields = array(
  82. 'type'=>array('label'=>"Type", 'checked'=>1),
  83. 'date'=>array('label'=>"Date", 'checked'=>1),
  84. 'date_due'=>array('label'=>"DateDue", 'checked'=>1),
  85. 'ref'=>array('label'=>"Ref", 'checked'=>1),
  86. 'documents'=>array('label'=>"Documents", 'checked'=>1),
  87. 'paid'=>array('label'=>"Paid", 'checked'=>1),
  88. 'total_ht'=>array('label'=>"TotalHT", 'checked'=>1),
  89. 'total_ttc'=>array('label'=>"TotalTTC", 'checked'=>1),
  90. 'total_vat'=>array('label'=>"TotalVAT", 'checked'=>1),
  91. //...
  92. );
  93. // Security check
  94. if (!isModEnabled('comptabilite') && !isModEnabled('accounting')) {
  95. accessforbidden();
  96. }
  97. if ($user->socid > 0) {
  98. accessforbidden();
  99. }
  100. // Define $arrayofentities if multientity is set.
  101. $arrayofentities = array();
  102. if (isModEnabled('multicompany') && is_object($mc)) {
  103. $arrayofentities = $mc->getEntitiesList();
  104. }
  105. $entity = (GETPOSTISSET('entity') ? GETPOST('entity', 'int') : (GETPOSTISSET('search_entity') ? GETPOST('search_entity', 'int') : $conf->entity));
  106. if (isModEnabled('multicompany') && is_object($mc)) {
  107. if (empty($entity) && !empty($conf->global->MULTICOMPANY_ALLOW_EXPORT_ACCOUNTING_DOC_FOR_ALL_ENTITIES)) {
  108. $entity = '0,'.join(',', array_keys($arrayofentities));
  109. }
  110. }
  111. if (empty($entity)) {
  112. $entity = $conf->entity;
  113. }
  114. $error = 0;
  115. $listofchoices = array(
  116. 'selectinvoices'=>array('label'=>'Invoices', 'lang'=>'bills', 'enabled' => isModEnabled('facture'), 'perms' => !empty($user->rights->facture->lire)),
  117. 'selectsupplierinvoices'=>array('label'=>'BillsSuppliers', 'lang'=>'bills', 'enabled' => isModEnabled('supplier_invoice'), 'perms' => !empty($user->rights->fournisseur->facture->lire)),
  118. 'selectexpensereports'=>array('label'=>'ExpenseReports', 'lang'=>'trips', 'enabled' => isModEnabled('expensereport'), 'perms' => !empty($user->rights->expensereport->lire)),
  119. 'selectdonations'=>array('label'=>'Donations', 'lang'=>'donation', 'enabled' => isModEnabled('don'), 'perms' => !empty($user->rights->don->lire)),
  120. 'selectsocialcontributions'=>array('label'=>'SocialContributions', 'enabled' => isModEnabled('tax'), 'perms' => !empty($user->rights->tax->charges->lire)),
  121. 'selectpaymentsofsalaries'=>array('label'=>'SalariesPayments', 'lang'=>'salaries', 'enabled' => isModEnabled('salaries'), 'perms' => !empty($user->rights->salaries->read)),
  122. 'selectvariouspayment'=>array('label'=>'VariousPayment', 'enabled' => isModEnabled('banque'), 'perms' => !empty($user->rights->banque->lire)),
  123. 'selectloanspayment'=>array('label'=>'PaymentLoan', 'enabled' => isModEnabled('don'), 'perms' => !empty($user->rights->loan->read)),
  124. );
  125. /*
  126. * Actions
  127. */
  128. //$parameters = array('socid' => $id);
  129. //$reshook = $hookmanager->executeHooks('doActions', $parameters, $object); // Note that $object may have been modified by some hooks
  130. //if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  131. $filesarray = array();
  132. $result = false;
  133. if (($action == 'searchfiles' || $action == 'dl')) {
  134. if (empty($date_start)) {
  135. setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DateStart")), null, 'errors');
  136. $error++;
  137. }
  138. if (empty($date_stop)) {
  139. setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DateEnd")), null, 'errors');
  140. $error++;
  141. }
  142. if (!$error) {
  143. $sql = '';
  144. $wheretail = " '".$db->idate($date_start)."' AND '".$db->idate($date_stop)."'";
  145. // Customer invoices
  146. if (GETPOST('selectinvoices') && !empty($listofchoices['selectinvoices']['perms'])) {
  147. if (!empty($sql)) {
  148. $sql .= " UNION ALL";
  149. }
  150. $sql .= "SELECT t.rowid as id, t.entity, t.ref, t.paye as paid, t.total_ht, t.total_ttc, t.total_tva as total_vat, t.multicurrency_code as currency, t.fk_soc, t.datef as date, t.date_lim_reglement as date_due, 'Invoice' as item, s.nom as thirdparty_name, s.code_client as thirdparty_code, c.code as country_code, s.tva_intra as vatnum, ".PAY_CREDIT." as sens";
  151. $sql .= " FROM ".MAIN_DB_PREFIX."facture as t LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = t.fk_soc LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = s.fk_pays";
  152. $sql .= " WHERE datef between ".$wheretail;
  153. $sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')';
  154. $sql .= " AND t.fk_statut <> ".Facture::STATUS_DRAFT;
  155. }
  156. // Vendor invoices
  157. if (GETPOST('selectsupplierinvoices') && !empty($listofchoices['selectsupplierinvoices']['perms'])) {
  158. if (!empty($sql)) {
  159. $sql .= " UNION ALL";
  160. }
  161. $sql .= " SELECT t.rowid as id, t.entity, t.ref, t.paye as paid, t.total_ht, t.total_ttc, t.total_tva as total_vat, t.multicurrency_code as currency, t.fk_soc, t.datef as date, t.date_lim_reglement as date_due, 'SupplierInvoice' as item, s.nom as thirdparty_name, s.code_fournisseur as thirdparty_code, c.code as country_code, s.tva_intra as vatnum, ".PAY_DEBIT." as sens";
  162. $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as t LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = t.fk_soc LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = s.fk_pays";
  163. $sql .= " WHERE datef between ".$wheretail;
  164. $sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')';
  165. $sql .= " AND t.fk_statut <> ".FactureFournisseur::STATUS_DRAFT;
  166. }
  167. // Expense reports
  168. if (GETPOST('selectexpensereports') && !empty($listofchoices['selectexpensereports']['perms'])) {
  169. if (!empty($sql)) {
  170. $sql .= " UNION ALL";
  171. }
  172. $sql .= " SELECT t.rowid as id, t.entity, t.ref, t.paid, t.total_ht, t.total_ttc, t.total_tva as total_vat, t.multicurrency_code as currency, t.fk_user_author as fk_soc, t.date_fin as date, t.date_fin as date_due, 'ExpenseReport' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum, ".PAY_DEBIT." as sens";
  173. $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as t LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = t.fk_user_author LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = u.fk_country";
  174. $sql .= " WHERE date_fin between ".$wheretail;
  175. $sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')';
  176. $sql .= " AND t.fk_statut <> ".ExpenseReport::STATUS_DRAFT;
  177. }
  178. // Donations
  179. if (GETPOST('selectdonations') && !empty($listofchoices['selectdonations']['perms'])) {
  180. if (!empty($sql)) {
  181. $sql .= " UNION ALL";
  182. }
  183. $sql .= " SELECT t.rowid as id, t.entity, t.ref, paid, amount as total_ht, amount as total_ttc, 0 as total_vat, '".$db->escape($conf->currency)."' as currency, 0 as fk_soc, t.datedon as date, t.datedon as date_due, 'Donation' as item, t.societe as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum, ".PAY_CREDIT." as sens";
  184. $sql .= " FROM ".MAIN_DB_PREFIX."don as t LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = t.fk_country";
  185. $sql .= " WHERE datedon between ".$wheretail;
  186. $sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')';
  187. $sql .= " AND t.fk_statut <> ".Don::STATUS_DRAFT;
  188. }
  189. // Payments of salaries
  190. if (GETPOST('selectpaymentsofsalaries') && !empty($listofchoices['selectpaymentsofsalaries']['perms'])) {
  191. if (!empty($sql)) {
  192. $sql .= " UNION ALL";
  193. }
  194. $sql .= " SELECT t.rowid as id, t.entity, t.label as ref, 1 as paid, amount as total_ht, amount as total_ttc, 0 as total_vat, '".$db->escape($conf->currency)."' as currency, t.fk_user as fk_soc, t.datep as date, t.dateep as date_due, 'SalaryPayment' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum, ".PAY_DEBIT." as sens";
  195. $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as t LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = t.fk_user LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = u.fk_country";
  196. $sql .= " WHERE datep between ".$wheretail;
  197. $sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')';
  198. //$sql.=" AND fk_statut <> ".PaymentSalary::STATUS_DRAFT;
  199. }
  200. // Social contributions
  201. if (GETPOST('selectsocialcontributions') && !empty($listofchoices['selectsocialcontributions']['perms'])) {
  202. if (!empty($sql)) {
  203. $sql .= " UNION ALL";
  204. }
  205. $sql .= " SELECT t.rowid as id, t.entity, t.libelle as ref, t.paye as paid, t.amount as total_ht, t.amount as total_ttc, 0 as total_vat, '".$db->escape($conf->currency)."' as currency, 0 as fk_soc, t.date_ech as date, t.periode as date_due, 'SocialContributions' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum, ".PAY_DEBIT." as sens";
  206. $sql .= " FROM ".MAIN_DB_PREFIX."chargesociales as t";
  207. $sql .= " WHERE t.date_ech between ".$wheretail;
  208. $sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')';
  209. //$sql.=" AND fk_statut <> ".ChargeSociales::STATUS_DRAFT;
  210. }
  211. // Various payments
  212. if (GETPOST('selectvariouspayment') && !empty($listofchoices['selectvariouspayment']['perms'])) {
  213. if (!empty($sql)) {
  214. $sql .= " UNION ALL";
  215. }
  216. $sql .= " SELECT t.rowid as id, t.entity, t.ref, 1 as paid, t.amount as total_ht, t.amount as total_ttc, 0 as total_vat, '".$db->escape($conf->currency)."' as currency, 0 as fk_soc, t.datep as date, t.datep as date_due, 'VariousPayment' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum, sens";
  217. $sql .= " FROM ".MAIN_DB_PREFIX."payment_various as t";
  218. $sql .= " WHERE datep between ".$wheretail;
  219. $sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')';
  220. }
  221. // Loan payments
  222. if (GETPOST('selectloanspayment') && !empty($listofchoices['selectloanspayment']['perms'])) {
  223. if (!empty($sql)) {
  224. $sql .= " UNION ALL";
  225. }
  226. $sql .= " SELECT t.rowid as id, l.entity, l.label as ref, 1 as paid, (t.amount_capital+t.amount_insurance+t.amount_interest) as total_ht, (t.amount_capital+t.amount_insurance+t.amount_interest) as total_ttc, 0 as total_vat, '".$db->escape($conf->currency)."' as currency, 0 as fk_soc, t.datep as date, t.datep as date_due, 'LoanPayment' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum, ".PAY_DEBIT." as sens";
  227. $sql .= " FROM ".MAIN_DB_PREFIX."payment_loan as t LEFT JOIN ".MAIN_DB_PREFIX."loan as l ON l.rowid = t.fk_loan";
  228. $sql .= " WHERE datep between ".$wheretail;
  229. $sql .= " AND l.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')';
  230. }
  231. if ($sql) {
  232. $sql .= $db->order($sortfield, $sortorder);
  233. //print $sql;
  234. $resd = $db->query($sql);
  235. $files = array();
  236. $link = '';
  237. if ($resd) {
  238. $numd = $db->num_rows($resd);
  239. $tmpinvoice = new Facture($db);
  240. $tmpinvoicesupplier = new FactureFournisseur($db);
  241. $tmpdonation = new Don($db);
  242. $upload_dir = '';
  243. $i = 0;
  244. while ($i < $numd) {
  245. $objd = $db->fetch_object($resd);
  246. switch ($objd->item) {
  247. case "Invoice":
  248. $subdir = '';
  249. $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->ref);
  250. $upload_dir = $conf->facture->dir_output.'/'.$subdir;
  251. $link = "document.php?modulepart=facture&file=".str_replace('/', '%2F', $subdir).'%2F';
  252. $modulepart = "facture";
  253. break;
  254. case "SupplierInvoice":
  255. $tmpinvoicesupplier->fetch($objd->id);
  256. $subdir = get_exdir($tmpinvoicesupplier->id, 2, 0, 1, $tmpinvoicesupplier, 'invoice_supplier'); // TODO Use first file
  257. $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->ref);
  258. $upload_dir = $conf->fournisseur->facture->dir_output.'/'.$subdir;
  259. $link = "document.php?modulepart=facture_fournisseur&file=".str_replace('/', '%2F', $subdir).'%2F';
  260. $modulepart = "facture_fournisseur";
  261. break;
  262. case "ExpenseReport":
  263. $subdir = '';
  264. $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->ref);
  265. $upload_dir = $conf->expensereport->dir_output.'/'.$subdir;
  266. $link = "document.php?modulepart=expensereport&file=".str_replace('/', '%2F', $subdir).'%2F';
  267. $modulepart = "expensereport";
  268. break;
  269. case "SalaryPayment":
  270. $subdir = '';
  271. $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->id);
  272. $upload_dir = $conf->salaries->dir_output.'/'.$subdir;
  273. $link = "document.php?modulepart=salaries&file=".str_replace('/', '%2F', $subdir).'%2F';
  274. $modulepart = "salaries";
  275. break;
  276. case "Donation":
  277. $tmpdonation->fetch($objp->id);
  278. $subdir = get_exdir(0, 0, 0, 0, $tmpdonation, 'donation');
  279. $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->id);
  280. $upload_dir = $conf->don->dir_output.'/'.$subdir;
  281. $link = "document.php?modulepart=don&file=".str_replace('/', '%2F', $subdir).'%2F';
  282. $modulepart = "don";
  283. break;
  284. case "SocialContributions":
  285. $subdir = '';
  286. $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->id);
  287. $upload_dir = $conf->tax->dir_output.'/'.$subdir;
  288. $link = "document.php?modulepart=tax&file=".str_replace('/', '%2F', $subdir).'%2F';
  289. $modulepart = "tax";
  290. break;
  291. case "VariousPayment":
  292. $subdir = '';
  293. $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->id);
  294. $upload_dir = $conf->bank->dir_output.'/'.$subdir;
  295. $link = "document.php?modulepart=banque&file=".str_replace('/', '%2F', $subdir).'%2F';
  296. $modulepart = "banque";
  297. break;
  298. case "LoanPayment":
  299. // Loan payment has no linked file
  300. $subdir = '';
  301. $upload_dir = $conf->loan->dir_output.'/'.$subdir;
  302. $link = "";
  303. $modulepart = "";
  304. break;
  305. default:
  306. $subdir = '';
  307. $upload_dir = '';
  308. $link = '';
  309. break;
  310. }
  311. if (!empty($upload_dir)) {
  312. $result = true;
  313. $files = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', '', SORT_ASC, 1);
  314. //var_dump($upload_dir);
  315. //var_dump($files);
  316. if (count($files) < 1) {
  317. $nofile = array();
  318. $nofile['id'] = $objd->id;
  319. $nofile['entity'] = $objd->entity;
  320. $nofile['date'] = $db->jdate($objd->date);
  321. $nofile['date_due'] = $db->jdate($objd->date_due);
  322. $nofile['paid'] = $objd->paid;
  323. $nofile['amount_ht'] = $objd->total_ht;
  324. $nofile['amount_ttc'] = $objd->total_ttc;
  325. $nofile['amount_vat'] = $objd->total_vat;
  326. $nofile['ref'] = ($objd->ref ? $objd->ref : $objd->id);
  327. $nofile['fk'] = $objd->fk_soc;
  328. $nofile['item'] = $objd->item;
  329. $nofile['thirdparty_name'] = $objd->thirdparty_name;
  330. $nofile['thirdparty_code'] = $objd->thirdparty_code;
  331. $nofile['country_code'] = $objd->country_code;
  332. $nofile['vatnum'] = $objd->vatnum;
  333. $nofile['sens'] = $objd->sens;
  334. $filesarray[$nofile['item'].'_'.$nofile['id']] = $nofile;
  335. } else {
  336. foreach ($files as $key => $file) {
  337. $file['id'] = $objd->id;
  338. $file['entity'] = $objd->entity;
  339. $file['date'] = $db->jdate($objd->date);
  340. $file['date_due'] = $db->jdate($objd->date_due);
  341. $file['paid'] = $objd->paid;
  342. $file['amount_ht'] = $objd->total_ht;
  343. $file['amount_ttc'] = $objd->total_ttc;
  344. $file['amount_vat'] = $objd->total_vat;
  345. $file['ref'] = ($objd->ref ? $objd->ref : $objd->id);
  346. $file['fk'] = $objd->fk_soc;
  347. $file['item'] = $objd->item;
  348. $file['thirdparty_name'] = $objd->thirdparty_name;
  349. $file['thirdparty_code'] = $objd->thirdparty_code;
  350. $file['country_code'] = $objd->country_code;
  351. $file['vatnum'] = $objd->vatnum;
  352. $file['sens'] = $objd->sens;
  353. // Save record into array (only the first time it is found)
  354. if (empty($filesarray[$file['item'].'_'.$file['id']])) {
  355. $filesarray[$file['item'].'_'.$file['id']] = $file;
  356. }
  357. // Add or concat file
  358. if (empty($filesarray[$file['item'].'_'.$file['id']]['files'])) {
  359. $filesarray[$file['item'].'_'.$file['id']]['files'] = array();
  360. }
  361. $filesarray[$file['item'].'_'.$file['id']]['files'][] = array(
  362. 'link' => $link.urlencode($file['name']),
  363. 'name'=>$file['name'],
  364. 'ref'=>$file['ref'],
  365. 'fullname' => $file['fullname'],
  366. 'relpath' => '/'.$file['name'],
  367. 'relpathnamelang' => $langs->trans($file['item']).'/'.$file['name'],
  368. 'modulepart' => $modulepart,
  369. 'subdir' => $subdir,
  370. );
  371. //var_dump($file['item'].'_'.$file['id']);
  372. //var_dump($filesarray[$file['item'].'_'.$file['id']]['files']);
  373. }
  374. }
  375. }
  376. $i++;
  377. }
  378. } else {
  379. dol_print_error($db);
  380. }
  381. $db->free($resd);
  382. } else {
  383. setEventMessages($langs->trans("ErrorSelectAtLeastOne"), null, 'errors');
  384. $error++;
  385. }
  386. }
  387. }
  388. /*
  389. *ZIP creation
  390. */
  391. $dirfortmpfile = ($conf->accounting->dir_temp ? $conf->accounting->dir_temp : $conf->comptabilite->dir_temp);
  392. if (empty($dirfortmpfile)) {
  393. setEventMessages($langs->trans("ErrorNoAccountingModuleEnabled"), null, 'errors');
  394. $error++;
  395. }
  396. if ($result && $action == "dl" && !$error) {
  397. if (!extension_loaded('zip')) {
  398. setEventMessages('PHPZIPExtentionNotLoaded', null, 'errors');
  399. exit;
  400. }
  401. dol_mkdir($dirfortmpfile);
  402. $log = $langs->transnoentitiesnoconv("Type");
  403. if (isModEnabled('multicompany') && is_object($mc)) {
  404. $log .= ','.$langs->transnoentitiesnoconv("Entity");
  405. }
  406. $log .= ','.$langs->transnoentitiesnoconv("Date");
  407. $log .= ','.$langs->transnoentitiesnoconv("DateDue");
  408. $log .= ','.$langs->transnoentitiesnoconv("Ref");
  409. $log .= ','.$langs->transnoentitiesnoconv("TotalHT");
  410. $log .= ','.$langs->transnoentitiesnoconv("TotalTTC");
  411. $log .= ','.$langs->transnoentitiesnoconv("TotalVAT");
  412. $log .= ','.$langs->transnoentitiesnoconv("Paid");
  413. $log .= ','.$langs->transnoentitiesnoconv("Document");
  414. $log .= ','.$langs->transnoentitiesnoconv("ItemID");
  415. $log .= ','.$langs->transnoentitiesnoconv("ThirdParty");
  416. $log .= ','.$langs->transnoentitiesnoconv("Code");
  417. $log .= ','.$langs->transnoentitiesnoconv("Country");
  418. $log .= ','.$langs->transnoentitiesnoconv("VATIntra");
  419. $log .= ','.$langs->transnoentitiesnoconv("Sens")."\n";
  420. $zipname = $dirfortmpfile.'/'.dol_print_date($date_start, 'dayrfc', 'tzuserrel')."-".dol_print_date($date_stop, 'dayrfc', 'tzuserrel').'_export.zip';
  421. dol_delete_file($zipname);
  422. $zip = new ZipArchive;
  423. $res = $zip->open($zipname, ZipArchive::OVERWRITE | ZipArchive::CREATE);
  424. if ($res) {
  425. foreach ($filesarray as $key => $file) {
  426. if (!empty($file['files'])) {
  427. foreach ($file['files'] as $filecursor) {
  428. if (file_exists($filecursor["fullname"])) {
  429. $zip->addFile($filecursor["fullname"], $filecursor["relpathnamelang"]);
  430. }
  431. }
  432. }
  433. $log .= '"'.$langs->trans($file['item']).'"';
  434. if (isModEnabled('multicompany') && is_object($mc)) {
  435. $log .= ',"'.(empty($arrayofentities[$file['entity']]) ? $file['entity'] : $arrayofentities[$file['entity']]).'"';
  436. }
  437. $log .= ','.dol_print_date($file['date'], 'dayrfc');
  438. $log .= ','.dol_print_date($file['date_due'], 'dayrfc');
  439. $log .= ',"'.$file['ref'].'"';
  440. $log .= ','.$file['amount_ht'];
  441. $log .= ','.$file['amount_ttc'];
  442. $log .= ','.$file['amount_vat'];
  443. $log .= ','.$file['paid'];
  444. $log .= ',"'.$file["name"].'"';
  445. $log .= ','.$file['fk'];
  446. $log .= ',"'.$file['thirdparty_name'].'"';
  447. $log .= ',"'.$file['thirdparty_code'].'"';
  448. $log .= ',"'.$file['country_code'].'"';
  449. $log .= ',"'.$file['vatnum'].'"';
  450. $log .= ',"'.$file['sens'].'"';
  451. $log .= "\n";
  452. }
  453. $zip->addFromString('transactions.csv', $log);
  454. $zip->close();
  455. // Then download the zipped file.
  456. header('Content-Type: application/zip');
  457. header('Content-disposition: attachment; filename='.basename($zipname));
  458. header('Content-Length: '.filesize($zipname));
  459. readfile($zipname);
  460. dol_delete_file($zipname);
  461. exit();
  462. } else {
  463. setEventMessages($langs->trans("FailedToOpenFile", $zipname), null, 'errors');
  464. }
  465. }
  466. /*
  467. * View
  468. */
  469. $form = new form($db);
  470. $formfile = new FormFile($db);
  471. $userstatic = new User($db);
  472. $invoice = new Facture($db);
  473. $supplier_invoice = new FactureFournisseur($db);
  474. $expensereport = new ExpenseReport($db);
  475. $don = new Don($db);
  476. $salary_payment = new PaymentSalary($db);
  477. $charge_sociales = new ChargeSociales($db);
  478. $various_payment = new PaymentVarious($db);
  479. $payment_loan = new PaymentLoan($db);
  480. $title = $langs->trans("ComptaFiles").' - '.$langs->trans("List");
  481. $help_url = '';
  482. llxHeader('', $title, $help_url);
  483. $h = 0;
  484. $head = array();
  485. $head[$h][0] = $_SERVER["PHP_SELF"];
  486. $head[$h][1] = $langs->trans("AccountantFiles");
  487. $head[$h][2] = 'AccountancyFiles';
  488. print dol_get_fiche_head($head, 'AccountancyFiles');
  489. print '<form name="searchfiles" action="?action=searchfiles" method="POST">'."\n";
  490. print '<input type="hidden" name="token" value="'.newToken().'">';
  491. print '<span class="opacitymedium">'.$langs->trans("ExportAccountingSourceDocHelp");
  492. if (isModEnabled('accounting')) {
  493. print ' '.$langs->trans("ExportAccountingSourceDocHelp2", $langs->transnoentitiesnoconv("Accounting"), $langs->transnoentitiesnoconv("Journals"));
  494. }
  495. print '</span><br>';
  496. print '<br>';
  497. print $langs->trans("ReportPeriod").': ';
  498. print $form->selectDate($date_start, 'date_start', 0, 0, 0, "", 1, 1, 0, '', '', '', '', 1, '', '', 'tzuserrel');
  499. print ' - ';
  500. print $form->selectDate($date_stop, 'date_stop', 0, 0, 0, "", 1, 1, 0, '', '', '', '', 1, '', '', 'tzuserrel');
  501. print "\n";
  502. // Export is for current company only
  503. if (isModEnabled('multicompany') && is_object($mc)) {
  504. $mc->getInfo($conf->entity);
  505. print '<span class="marginleftonly marginrightonly'.(empty($conf->global->MULTICOMPANY_ALLOW_EXPORT_ACCOUNTING_DOC_FOR_ALL_ENTITIES) ? ' opacitymedium' : '').'">('.$langs->trans("Entity").' : ';
  506. print "<td>";
  507. if (!empty($conf->global->MULTICOMPANY_ALLOW_EXPORT_ACCOUNTING_DOC_FOR_ALL_ENTITIES)) {
  508. print $mc->select_entities(GETPOSTISSET('search_entity') ? GETPOST('search_entity', 'int') : $mc->id, 'search_entity', '', false, false, false, false, true);
  509. } else {
  510. print $mc->label;
  511. }
  512. print "</td>";
  513. print ")</span>\n";
  514. }
  515. print '<br>';
  516. foreach ($listofchoices as $choice => $val) {
  517. if (empty($val['enabled'])) {
  518. continue; // list not qualified
  519. }
  520. $disabled = '';
  521. if (empty($val['perms'])) {
  522. $disabled = ' disabled';
  523. }
  524. $checked = (((!GETPOSTISSET('search') && $action != 'searchfiles') || GETPOST($choice)) ? ' checked="checked"' : '');
  525. print '<div class="paddingleft inline-block marginrightonly"><input type="checkbox" id="'.$choice.'" name="'.$choice.'" value="1"'.$checked.$disabled.'> <label for="'.$choice.'">'.$langs->trans($val['label']).'</label></div>';
  526. }
  527. print '<input type="submit" class="button small" name="search" value="'.$langs->trans("Search").'">';
  528. print '</form>'."\n";
  529. print dol_get_fiche_end();
  530. $param = '';
  531. if (!empty($date_start) && !empty($date_stop)) {
  532. $param .= '&date_startday='.GETPOST('date_startday', 'int');
  533. $param .= '&date_startmonth='.GETPOST('date_startmonth', 'int');
  534. $param .= '&date_startyear='.GETPOST('date_startyear', 'int');
  535. $param .= '&date_stopday='.GETPOST('date_stopday', 'int');
  536. $param .= '&date_stopmonth='.GETPOST('date_stopmonth', 'int');
  537. $param .= '&date_stopyear='.GETPOST('date_stopyear', 'int');
  538. foreach ($listofchoices as $choice => $val) {
  539. if (GETPOST($choice, 'int')) {
  540. $param .= '&'.$choice.'=1';
  541. }
  542. }
  543. $TData = dol_sort_array($filesarray, $sortfield, $sortorder);
  544. $filename = dol_print_date($date_start, 'dayrfc', 'tzuserrel')."-".dol_print_date($date_stop, 'dayrfc', 'tzuserrel').'_export.zip';
  545. echo dol_print_date($date_start, 'day', 'tzuserrel')." - ".dol_print_date($date_stop, 'day', 'tzuserrel');
  546. print '<a class="marginleftonly small'.(empty($TData) ? ' butActionRefused' : ' butAction').'" href="'.$_SERVER["PHP_SELF"].'?action=dl&token='.currentToken().'&output=file&file='.urlencode($filename).$param.'"';
  547. if (empty($TData)) {
  548. print " disabled";
  549. }
  550. print '>'."\n";
  551. print $langs->trans("Download");
  552. print '</a><br>';
  553. $param .= '&action=searchfiles';
  554. /*
  555. print '<input type="hidden" name="token" value="'.currentToken().'">';
  556. print '<input type="hidden" name="date_startday" value="'.GETPOST('date_startday', 'int').'" />';
  557. print '<input type="hidden" name="date_startmonth" value="'.GETPOST('date_startmonth', 'int').'" />';
  558. print '<input type="hidden" name="date_startyear" value="'.GETPOST('date_startyear', 'int').'" />';
  559. print '<input type="hidden" name="date_stopday" value="'.GETPOST('date_stopday', 'int').'" />';
  560. print '<input type="hidden" name="date_stopmonth" value="'.GETPOST('date_stopmonth', 'int').'" />';
  561. print '<input type="hidden" name="date_stopyear" value="'.GETPOST('date_stopyear', 'int').'" />';
  562. foreach ($listofchoices as $choice => $val) {
  563. print '<input type="hidden" name="'.$choice.'" value="'.GETPOST($choice).'">';
  564. }
  565. print '<input class="butAction butDownload small marginleftonly" type="submit" value="'.$langs->trans("Download").'"';
  566. if (empty($TData)) {
  567. print " disabled";
  568. }
  569. print '/>';
  570. print '</form>'."\n";
  571. */
  572. print '<br>';
  573. print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
  574. print '<table class="noborder centpercent">';
  575. print '<tr class="liste_titre">';
  576. print_liste_field_titre($arrayfields['type']['label'], $_SERVER["PHP_SELF"], "item", "", $param, '', $sortfield, $sortorder, 'nowrap ');
  577. print_liste_field_titre($arrayfields['date']['label'], $_SERVER["PHP_SELF"], "date", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
  578. print_liste_field_titre($arrayfields['date_due']['label'], $_SERVER["PHP_SELF"], "date_due", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
  579. print_liste_field_titre($arrayfields['ref']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'nowraponall ');
  580. print '<td>'.$langs->trans("Document").'</td>';
  581. print '<td>'.$langs->trans("Paid").'</td>';
  582. print '<td align="right">'.$langs->trans("TotalHT").(isModEnabled('multicurrency') ? ' ('.$conf->currency.')' : '').'</td>';
  583. print '<td align="right">'.$langs->trans("TotalTTC").(isModEnabled('multicurrency') ? ' ('.$conf->currency.')' : '').'</td>';
  584. print '<td align="right">'.$langs->trans("TotalVAT").(isModEnabled('multicurrency') ? ' ('.$conf->currency.')' : '').'</td>';
  585. print '<td>'.$langs->trans("ThirdParty").'</td>';
  586. print '<td class="center">'.$langs->trans("Code").'</td>';
  587. print '<td class="center">'.$langs->trans("Country").'</td>';
  588. print '<td class="center">'.$langs->trans("VATIntra").'</td>';
  589. if (isModEnabled('multicurrency')) {
  590. print '<td class="center">'.$langs->trans("Currency").'</td>';
  591. }
  592. print '</tr>';
  593. if (empty($TData)) {
  594. print '<tr class="oddeven"><td colspan="13"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td>';
  595. if (isModEnabled('multicurrency')) {
  596. print '<td></td>';
  597. }
  598. print '</tr>';
  599. } else {
  600. // Sort array by date ASC to calculate balance
  601. $totalET_debit = 0;
  602. $totalIT_debit = 0;
  603. $totalVAT_debit = 0;
  604. $totalET_credit = 0;
  605. $totalIT_credit = 0;
  606. $totalVAT_credit = 0;
  607. // Display array
  608. foreach ($TData as $data) {
  609. $html_class = '';
  610. //if (!empty($data['fk_facture'])) $html_class = 'facid-'.$data['fk_facture'];
  611. //elseif (!empty($data['fk_paiement'])) $html_class = 'payid-'.$data['fk_paiement'];
  612. print '<tr class="oddeven '.$html_class.'">';
  613. // Type
  614. print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($langs->trans($data['item'])).'">'.$langs->trans($data['item']).'</td>';
  615. // Date
  616. print '<td class="center">';
  617. print dol_print_date($data['date'], 'day');
  618. print "</td>\n";
  619. // Date due
  620. print '<td class="center">';
  621. print dol_print_date($data['date_due'], 'day');
  622. print "</td>\n";
  623. // Ref
  624. print '<td class="nowraponall tdoverflowmax150">';
  625. if ($data['item'] == 'Invoice') {
  626. $invoice->id = $data['id'];
  627. $invoice->ref = $data['ref'];
  628. $invoice->total_ht = $data['amount_ht'];
  629. $invoice->total_ttc = $data['amount_ttc'];
  630. $invoice->total_tva = $data['amount_vat'];
  631. $invoice->multicurrency_code = $data['currency'];
  632. print $invoice->getNomUrl(1, '', 0, 0, '', 0, 0, 0);
  633. } elseif ($data['item'] == 'SupplierInvoice') {
  634. $supplier_invoice->id = $data['id'];
  635. $supplier_invoice->ref = $data['ref'];
  636. $supplier_invoice->total_ht = $data['amount_ht'];
  637. $supplier_invoice->total_ttc = $data['amount_ttc'];
  638. $supplier_invoice->total_tva = $data['amount_vat'];
  639. $supplier_invoice->multicurrency_code = $data['currency'];
  640. print $supplier_invoice->getNomUrl(1, '', 0, 0, '', 0, 0, 0);
  641. } elseif ($data['item'] == 'ExpenseReport') {
  642. $expensereport->id = $data['id'];
  643. $expensereport->ref = $data['ref'];
  644. print $expensereport->getNomUrl(1, 0, 0, '', 0, 0);
  645. } elseif ($data['item'] == 'SalaryPayment') {
  646. $salary_payment->id = $data['id'];
  647. $salary_payment->ref = $data['ref'];
  648. print $salary_payment->getNomUrl(1);
  649. } elseif ($data['item'] == 'Donation') {
  650. $don->id = $data['id'];
  651. $don->ref = $data['ref'];
  652. print $don->getNomUrl(1, 0, '', 0);
  653. } elseif ($data['item'] == 'SocialContributions') {
  654. $charge_sociales->id = $data['id'];
  655. $charge_sociales->ref = $data['ref'];
  656. print $charge_sociales->getNomUrl(1, 0, 0, 0, 0);
  657. } elseif ($data['item'] == 'VariousPayment') {
  658. $various_payment->id = $data['id'];
  659. $various_payment->ref = $data['ref'];
  660. print $various_payment->getNomUrl(1, '', 0, 0);
  661. } elseif ($data['item'] == 'LoanPayment') {
  662. $payment_loan->id = $data['id'];
  663. $payment_loan->ref = $data['ref'];
  664. print $payment_loan->getNomUrl(1, 0, 0, '', 0);
  665. } else {
  666. print $data['ref'];
  667. }
  668. print '</td>';
  669. // File link
  670. print '<td class="tdoverflowmax150">';
  671. if (!empty($data['files'])) {
  672. foreach ($data['files'] as $id => $filecursor) {
  673. $tmppreview = $formfile->showPreview($filecursor, $filecursor['modulepart'], $filecursor['subdir'].'/'.$filecursor['name'], 0);
  674. if ($tmppreview) {
  675. print $tmppreview;
  676. }
  677. $filename = ($filecursor['name'] ? $filecursor['name'] : $filecursor['ref']);
  678. print '<a href='.DOL_URL_ROOT.'/'.$filecursor['link'].' target="_blank" rel="noopener noreferrer" title="'.dol_escape_htmltag($filename).'">';
  679. if (empty($tmppreview)) {
  680. print img_picto('', 'generic', '', false, 0, 0, '', 'pictonopreview pictofixedwidth paddingright');
  681. }
  682. print $filename;
  683. print '</a><br>';
  684. }
  685. }
  686. print "</td>\n";
  687. // Paid
  688. print '<td class="center">'.($data['paid'] ? yn($data['paid']) : '').'</td>';
  689. // Total ET
  690. print '<td align="right"><span class="amount">'.price(price2num($data['sens'] ? $data['amount_ht'] : -$data['amount_ht'], 'MT'))."</span></td>\n";
  691. // Total IT
  692. print '<td align="right"><span class="amount">'.price(price2num($data['sens'] ? $data['amount_ttc'] : -$data['amount_ttc'], 'MT'))."</span></td>\n";
  693. // Total VAT
  694. print '<td align="right"><span class="amount">'.price(price2num($data['sens'] ? $data['amount_vat'] : -$data['amount_vat'], 'MT'))."</span></td>\n";
  695. print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($data['thirdparty_name']).'">'.dol_escape_htmltag($data['thirdparty_name'])."</td>\n";
  696. print '<td class="center">'.$data['thirdparty_code']."</td>\n";
  697. print '<td class="center">'.$data['country_code']."</td>\n";
  698. // VAT number
  699. print '<td class="tdoverflowmax150 right" title="'.dol_escape_htmltag($data['vatnum']).'">'.dol_escape_htmltag($data['vatnum'])."</td>\n";
  700. if ($data['sens']) {
  701. $totalET_credit += $data['amount_ht'];
  702. $totalIT_credit += $data['amount_ttc'];
  703. $totalVAT_credit += $data['amount_vat'];
  704. } else {
  705. $totalET_debit -= $data['amount_ht'];
  706. $totalIT_debit -= $data['amount_ttc'];
  707. $totalVAT_debit -= $data['amount_vat'];
  708. }
  709. if (isModEnabled('multicurrency')) {
  710. print '<td class="center">'.$data['currency']."</td>\n";
  711. }
  712. print "</tr>\n";
  713. }
  714. // Total credits
  715. print '<tr class="liste_total">';
  716. print '<td colspan="6" class="right">'.$langs->trans('Total').' '.$langs->trans('Income').'</td>';
  717. print '<td align="right">'.price(price2num($totalET_credit, 'MT')).'</td>';
  718. print '<td align="right">'.price(price2num($totalIT_credit, 'MT')).'</td>';
  719. print '<td align="right">'.price(price2num($totalVAT_credit, 'MT')).'</td>';
  720. print '<td colspan="4"></td>';
  721. if (isModEnabled('multicurrency')) {
  722. print '<td></td>';
  723. }
  724. print "</tr>\n";
  725. // Total debits
  726. print '<tr class="liste_total">';
  727. print '<td colspan="6" class="right">'.$langs->trans('Total').' '.$langs->trans('Outcome').'</td>';
  728. print '<td align="right">'.price(price2num($totalET_debit, 'MT')).'</td>';
  729. print '<td align="right">'.price(price2num($totalIT_debit, 'MT')).'</td>';
  730. print '<td align="right">'.price(price2num($totalVAT_debit, 'MT')).'</td>';
  731. print '<td colspan="4"></td>';
  732. if (isModEnabled('multicurrency')) {
  733. print '<td></td>';
  734. }
  735. print "</tr>\n";
  736. // Balance
  737. print '<tr class="liste_total">';
  738. print '<td colspan="6" class="right">'.$langs->trans('Total').'</td>';
  739. print '<td align="right">'.price(price2num($totalET_credit + $totalET_debit, 'MT')).'</td>';
  740. print '<td align="right">'.price(price2num($totalIT_credit + $totalIT_debit, 'MT')).'</td>';
  741. print '<td align="right">'.price(price2num($totalVAT_credit + $totalVAT_debit, 'MT')).'</td>';
  742. print '<td colspan="4"></td>';
  743. if (isModEnabled('multicurrency')) {
  744. print '<td></td>';
  745. }
  746. print "</tr>\n";
  747. }
  748. print "</table>";
  749. print '</div>';
  750. }
  751. llxFooter();
  752. $db->close();