dolibarr 19.0.3
accounting-files.php
Go to the documentation of this file.
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-2024 Alexandre Spangaro <aspangaro@easya.solutions>
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
29if ((array_key_exists('action', $_GET) && $_GET['action'] == 'dl') || (array_key_exists('action', $_POST) && $_POST['action'] == 'dl')) { // To not replace token when downloading file
30 if (!defined('NOTOKENRENEWAL')) {
31 define('NOTOKENRENEWAL', '1');
32 }
33}
34
35// Load Dolibarr environment
36require '../main.inc.php';
37require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
38require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
39require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
40require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
41require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
42require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php';
43require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
44require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
45require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
46require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
47require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
48require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php';
49require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
50require_once DOL_DOCUMENT_ROOT.'/loan/class/paymentloan.class.php';
51
52if (isModEnabled('project')) {
53 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
54 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
55}
56
57// Constant to define payment sens
58const PAY_DEBIT = 0;
59const PAY_CREDIT = 1;
60
61$langs->loadLangs(array("accountancy", "bills", "companies", "salaries", "compta", "trips", "banks", "loan"));
62
63$date_start = GETPOST('date_start', 'alpha');
64$date_startDay = GETPOST('date_startday', 'int');
65$date_startMonth = GETPOST('date_startmonth', 'int');
66$date_startYear = GETPOST('date_startyear', 'int');
67$date_start = dol_mktime(0, 0, 0, $date_startMonth, $date_startDay, $date_startYear, 'tzuserrel');
68$date_stop = GETPOST('date_stop', 'alpha');
69$date_stopDay = GETPOST('date_stopday', 'int');
70$date_stopMonth = GETPOST('date_stopmonth', 'int');
71$date_stopYear = GETPOST('date_stopyear', 'int');
72$date_stop = dol_mktime(23, 59, 59, $date_stopMonth, $date_stopDay, $date_stopYear, 'tzuserrel');
73$action = GETPOST('action', 'aZ09');
74$projectid = (GETPOST('projectid', 'int') ? GETPOST('projectid', 'int') : 0);
75
76// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
77$hookmanager->initHooks(array('comptafileslist', 'globallist'));
78
79// Load variable for pagination
80$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
81$sortfield = GETPOST('sortfield', 'aZ09comma');
82$sortorder = GETPOST('sortorder', 'aZ09comma');
83$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
84if (empty($page) || $page == -1) {
85 $page = 0;
86} // If $page is not defined, or '' or -1
87$offset = $limit * $page;
88$pageprev = $page - 1;
89$pagenext = $page + 1;
90if (!$sortfield) {
91 $sortfield = "date,item"; // Set here default search field
92}
93if (!$sortorder) {
94 $sortorder = "DESC";
95}
96
97
98$arrayfields = array(
99 'type'=>array('label'=>"Type", 'checked'=>1),
100 'date'=>array('label'=>"Date", 'checked'=>1),
101 'date_due'=>array('label'=>"DateDue", 'checked'=>1),
102 'ref'=>array('label'=>"Ref", 'checked'=>1),
103 'documents'=>array('label'=>"Documents", 'checked'=>1),
104 'paid'=>array('label'=>"Paid", 'checked'=>1),
105 'total_ht'=>array('label'=>"TotalHT", 'checked'=>1),
106 'total_ttc'=>array('label'=>"TotalTTC", 'checked'=>1),
107 'total_vat'=>array('label'=>"TotalVAT", 'checked'=>1),
108 //...
109);
110
111// Security check
112if (!isModEnabled('comptabilite') && !isModEnabled('accounting')) {
114}
115if ($user->socid > 0) {
117}
118
119// Define $arrayofentities if multientity is set.
120$arrayofentities = array();
121if (isModEnabled('multicompany') && is_object($mc)) {
122 $arrayofentities = $mc->getEntitiesList();
123}
124
125$entity = (GETPOSTISSET('entity') ? GETPOST('entity', 'int') : (GETPOSTISSET('search_entity') ? GETPOST('search_entity', 'int') : $conf->entity));
126if (isModEnabled('multicompany') && is_object($mc)) {
127 if (empty($entity) && getDolGlobalString('MULTICOMPANY_ALLOW_EXPORT_ACCOUNTING_DOC_FOR_ALL_ENTITIES')) {
128 $entity = '0,'.join(',', array_keys($arrayofentities));
129 }
130}
131if (empty($entity)) {
132 $entity = $conf->entity;
133}
134
135$error = 0;
136
137$listofchoices = array(
138 'selectinvoices'=>array('label'=>'Invoices', 'picto'=>'bill', 'lang'=>'bills', 'enabled' => isModEnabled('facture'), 'perms' => $user->hasRight('facture', 'lire')),
139 'selectsupplierinvoices'=>array('label'=>'BillsSuppliers', 'picto'=>'supplier_invoice', 'lang'=>'bills', 'enabled' => isModEnabled('supplier_invoice'), 'perms' => !empty($user->rights->fournisseur->facture->lire)),
140 'selectexpensereports'=>array('label'=>'ExpenseReports', 'picto'=>'expensereport', 'lang'=>'trips', 'enabled' => isModEnabled('expensereport'), 'perms' => !empty($user->rights->expensereport->lire)),
141 'selectdonations'=>array('label'=>'Donations', 'picto'=>'donation', 'lang'=>'donation', 'enabled' => isModEnabled('don'), 'perms' => !empty($user->rights->don->lire)),
142 'selectsocialcontributions'=>array('label'=>'SocialContributions', 'picto'=>'bill', 'enabled' => isModEnabled('tax'), 'perms' => !empty($user->rights->tax->charges->lire)),
143 'selectpaymentsofsalaries'=>array('label'=>'SalariesPayments', 'picto'=>'salary', 'lang'=>'salaries', 'enabled' => isModEnabled('salaries'), 'perms' => !empty($user->rights->salaries->read)),
144 'selectvariouspayment'=>array('label'=>'VariousPayment', 'picto'=>'payment', 'enabled' => isModEnabled('banque'), 'perms' => !empty($user->rights->banque->lire)),
145 'selectloanspayment'=>array('label'=>'PaymentLoan','picto'=>'loan', 'enabled' => isModEnabled('don'), 'perms' => !empty($user->rights->loan->read)),
146);
147
148
149
150/*
151 * Actions
152 */
153
154
155//$parameters = array('socid' => $id);
156//$reshook = $hookmanager->executeHooks('doActions', $parameters, $object); // Note that $object may have been modified by some hooks
157//if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
158
159$filesarray = array();
160$result = false;
161if (($action == 'searchfiles' || $action == 'dl')) {
162 if (empty($date_start)) {
163 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DateStart")), null, 'errors');
164 $error++;
165 }
166 if (empty($date_stop)) {
167 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DateEnd")), null, 'errors');
168 $error++;
169 }
170
171 if (!$error) {
172 $sql = '';
173
174 $wheretail = " '".$db->idate($date_start)."' AND '".$db->idate($date_stop)."'";
175
176 // Customer invoices
177 if (GETPOST('selectinvoices') && !empty($listofchoices['selectinvoices']['perms'])) {
178 if (!empty($sql)) {
179 $sql .= " UNION ALL";
180 }
181 $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,";
182 $sql .= " t.localtax1, t.localtax2, t.revenuestamp,";
183 $sql .= " 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";
184 $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";
185 $sql .= " WHERE datef between ".$wheretail;
186 $sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')';
187 $sql .= " AND t.fk_statut <> ".Facture::STATUS_DRAFT;
188 if (!empty($projectid)) {
189 $sql .= " AND fk_projet = ".((int) $projectid);
190 }
191 }
192 // Vendor invoices
193 if (GETPOST('selectsupplierinvoices') && !empty($listofchoices['selectsupplierinvoices']['perms'])) {
194 if (!empty($sql)) {
195 $sql .= " UNION ALL";
196 }
197 $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,";
198 $sql .= " t.localtax1, t.localtax2, 0 as revenuestamp,";
199 $sql .= " 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";
200 $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";
201 $sql .= " WHERE datef between ".$wheretail;
202 $sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')';
203 $sql .= " AND t.fk_statut <> ".FactureFournisseur::STATUS_DRAFT;
204 if (!empty($projectid)) {
205 $sql .= " AND fk_projet = ".((int) $projectid);
206 }
207 }
208 // Expense reports
209 if (GETPOST('selectexpensereports') && !empty($listofchoices['selectexpensereports']['perms']) && empty($projectid)) {
210 if (!empty($sql)) {
211 $sql .= " UNION ALL";
212 }
213 $sql .= " SELECT t.rowid as id, t.entity, t.ref, t.paid, t.total_ht, t.total_ttc, t.total_tva as total_vat,";
214 $sql .= " 0 as localtax1, 0 as localtax2, 0 as revenuestamp,";
215 $sql .= " 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";
216 $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";
217 $sql .= " WHERE date_fin between ".$wheretail;
218 $sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')';
219 $sql .= " AND t.fk_statut <> ".ExpenseReport::STATUS_DRAFT;
220 }
221 // Donations
222 if (GETPOST('selectdonations') && !empty($listofchoices['selectdonations']['perms'])) {
223 if (!empty($sql)) {
224 $sql .= " UNION ALL";
225 }
226 $sql .= " SELECT t.rowid as id, t.entity, t.ref, paid, amount as total_ht, amount as total_ttc, 0 as total_vat,";
227 $sql .= " 0 as localtax1, 0 as localtax2, 0 as revenuestamp,";
228 $sql .= " '".$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";
229 $sql .= " FROM ".MAIN_DB_PREFIX."don as t LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = t.fk_country";
230 $sql .= " WHERE datedon between ".$wheretail;
231 $sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')';
232 $sql .= " AND t.fk_statut <> ".Don::STATUS_DRAFT;
233 if (!empty($projectid)) {
234 $sql .= " AND fk_projet = ".((int) $projectid);
235 }
236 }
237 // Payments of salaries
238 if (GETPOST('selectpaymentsofsalaries') && !empty($listofchoices['selectpaymentsofsalaries']['perms'])) {
239 if (!empty($sql)) {
240 $sql .= " UNION ALL";
241 }
242 $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,";
243 $sql .= " 0 as localtax1, 0 as localtax2, 0 as revenuestamp,";
244 $sql .= " '".$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";
245 $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";
246 $sql .= " WHERE datep between ".$wheretail;
247 $sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')';
248 //$sql.=" AND fk_statut <> ".PaymentSalary::STATUS_DRAFT;
249 if (!empty($projectid)) {
250 $sql .= " AND fk_projet = ".((int) $projectid);
251 }
252 }
253 // Social contributions
254 if (GETPOST('selectsocialcontributions') && !empty($listofchoices['selectsocialcontributions']['perms'])) {
255 if (!empty($sql)) {
256 $sql .= " UNION ALL";
257 }
258 $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,";
259 $sql .= " 0 as localtax1, 0 as localtax2, 0 as revenuestamp,";
260 $sql .= " '".$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";
261 $sql .= " FROM ".MAIN_DB_PREFIX."chargesociales as t";
262 $sql .= " WHERE t.date_ech between ".$wheretail;
263 $sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')';
264 //$sql.=" AND fk_statut <> ".ChargeSociales::STATUS_DRAFT;
265 if (!empty($projectid)) {
266 $sql .= " AND fk_projet = ".((int) $projectid);
267 }
268 }
269 // Various payments
270 if (GETPOST('selectvariouspayment') && !empty($listofchoices['selectvariouspayment']['perms'])) {
271 if (!empty($sql)) {
272 $sql .= " UNION ALL";
273 }
274 $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,";
275 $sql .= " 0 as localtax1, 0 as localtax2, 0 as revenuestamp,";
276 $sql .= " '".$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";
277 $sql .= " FROM ".MAIN_DB_PREFIX."payment_various as t";
278 $sql .= " WHERE datep between ".$wheretail;
279 $sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')';
280 if (!empty($projectid)) {
281 $sql .= " AND fk_projet = ".((int) $projectid);
282 }
283 }
284 // Loan payments
285 if (GETPOST('selectloanspayment') && !empty($listofchoices['selectloanspayment']['perms']) && empty($projectid)) {
286 if (!empty($sql)) {
287 $sql .= " UNION ALL";
288 }
289 $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,";
290 $sql .= " 0 as localtax1, 0 as localtax2, 0 as revenuestamp,";
291 $sql .= " '".$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";
292 $sql .= " FROM ".MAIN_DB_PREFIX."payment_loan as t LEFT JOIN ".MAIN_DB_PREFIX."loan as l ON l.rowid = t.fk_loan";
293 $sql .= " WHERE datep between ".$wheretail;
294 $sql .= " AND l.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')';
295 }
296
297 if ($sql) {
298 $sql .= $db->order($sortfield, $sortorder);
299 //print $sql;
300
301 $resd = $db->query($sql);
302 $files = array();
303 $link = '';
304
305 if ($resd) {
306 $numd = $db->num_rows($resd);
307
308 $tmpinvoice = new Facture($db);
309 $tmpinvoicesupplier = new FactureFournisseur($db);
310 $tmpdonation = new Don($db);
311
312 $upload_dir = '';
313 $i = 0;
314 while ($i < $numd) {
315 $objd = $db->fetch_object($resd);
316
317 switch ($objd->item) {
318 case "Invoice":
319 $subdir = '';
320 $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->ref);
321 $upload_dir = $conf->facture->dir_output.'/'.$subdir;
322 $link = "document.php?modulepart=facture&file=".str_replace('/', '%2F', $subdir).'%2F';
323 $modulepart = "facture";
324 break;
325 case "SupplierInvoice":
326 $tmpinvoicesupplier->fetch($objd->id);
327 $subdir = get_exdir($tmpinvoicesupplier->id, 2, 0, 1, $tmpinvoicesupplier, 'invoice_supplier'); // TODO Use first file
328 $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->ref);
329 $upload_dir = $conf->fournisseur->facture->dir_output.'/'.$subdir;
330 $link = "document.php?modulepart=facture_fournisseur&file=".str_replace('/', '%2F', $subdir).'%2F';
331 $modulepart = "facture_fournisseur";
332 break;
333 case "ExpenseReport":
334 $subdir = '';
335 $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->ref);
336 $upload_dir = $conf->expensereport->dir_output.'/'.$subdir;
337 $link = "document.php?modulepart=expensereport&file=".str_replace('/', '%2F', $subdir).'%2F';
338 $modulepart = "expensereport";
339 break;
340 case "SalaryPayment":
341 $subdir = '';
342 $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->id);
343 $upload_dir = $conf->salaries->dir_output.'/'.$subdir;
344 $link = "document.php?modulepart=salaries&file=".str_replace('/', '%2F', $subdir).'%2F';
345 $modulepart = "salaries";
346 break;
347 case "Donation":
348 $tmpdonation->fetch($objp->id);
349 $subdir = get_exdir(0, 0, 0, 0, $tmpdonation, 'donation');
350 $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->id);
351 $upload_dir = $conf->don->dir_output.'/'.$subdir;
352 $link = "document.php?modulepart=don&file=".str_replace('/', '%2F', $subdir).'%2F';
353 $modulepart = "don";
354 break;
355 case "SocialContributions":
356 $subdir = '';
357 $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->id);
358 $upload_dir = $conf->tax->dir_output.'/'.$subdir;
359 $link = "document.php?modulepart=tax&file=".str_replace('/', '%2F', $subdir).'%2F';
360 $modulepart = "tax";
361 break;
362 case "VariousPayment":
363 $subdir = '';
364 $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->id);
365 $upload_dir = $conf->bank->dir_output.'/'.$subdir;
366 $link = "document.php?modulepart=banque&file=".str_replace('/', '%2F', $subdir).'%2F';
367 $modulepart = "banque";
368 break;
369 case "LoanPayment":
370 // Loan payment has no linked file
371 $subdir = '';
372 $upload_dir = $conf->loan->dir_output.'/'.$subdir;
373 $link = "";
374 $modulepart = "";
375 break;
376 default:
377 $subdir = '';
378 $upload_dir = '';
379 $link = '';
380 break;
381 }
382
383 if (!empty($upload_dir)) {
384 $result = true;
385
386 $files = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', '', SORT_ASC, 1);
387 //var_dump($upload_dir);
388 //var_dump($files);
389 if (count($files) < 1) {
390 $nofile = array();
391 $nofile['id'] = $objd->id;
392 $nofile['entity'] = $objd->entity;
393 $nofile['date'] = $db->jdate($objd->date);
394 $nofile['date_due'] = $db->jdate($objd->date_due);
395 $nofile['paid'] = $objd->paid;
396 $nofile['amount_ht'] = $objd->total_ht;
397 $nofile['amount_ttc'] = $objd->total_ttc;
398 $nofile['amount_vat'] = $objd->total_vat;
399 $nofile['amount_localtax1'] = $objd->localtax1;
400 $nofile['amount_localtax2'] = $objd->localtax2;
401 $nofile['amount_revenuestamp'] = $objd->revenuestamp;
402 $nofile['ref'] = ($objd->ref ? $objd->ref : $objd->id);
403 $nofile['fk'] = $objd->fk_soc;
404 $nofile['item'] = $objd->item;
405 $nofile['thirdparty_name'] = $objd->thirdparty_name;
406 $nofile['thirdparty_code'] = $objd->thirdparty_code;
407 $nofile['country_code'] = $objd->country_code;
408 $nofile['vatnum'] = $objd->vatnum;
409 $nofile['sens'] = $objd->sens;
410 $nofile['currency'] = $objd->currency;
411 $nofile['link'] = '';
412 $nofile['name'] = '';
413
414 $filesarray[$nofile['item'].'_'.$nofile['id']] = $nofile;
415 } else {
416 foreach ($files as $key => $file) {
417 $file['id'] = $objd->id;
418 $file['entity'] = $objd->entity;
419 $file['date'] = $db->jdate($objd->date);
420 $file['date_due'] = $db->jdate($objd->date_due);
421 $file['paid'] = $objd->paid;
422 $file['amount_ht'] = $objd->total_ht;
423 $file['amount_ttc'] = $objd->total_ttc;
424 $file['amount_vat'] = $objd->total_vat;
425 $file['amount_localtax1'] = $objd->localtax1;
426 $file['amount_localtax2'] = $objd->localtax2;
427 $file['amount_revenuestamp'] = $objd->revenuestamp;
428 $file['ref'] = ($objd->ref ? $objd->ref : $objd->id);
429 $file['fk'] = $objd->fk_soc;
430 $file['item'] = $objd->item;
431 $file['thirdparty_name'] = $objd->thirdparty_name;
432 $file['thirdparty_code'] = $objd->thirdparty_code;
433 $file['country_code'] = $objd->country_code;
434 $file['vatnum'] = $objd->vatnum;
435 $file['sens'] = $objd->sens;
436 $file['currency'] = $objd->currency;
437
438 // Save record into array (only the first time it is found)
439 if (empty($filesarray[$file['item'].'_'.$file['id']])) {
440 $filesarray[$file['item'].'_'.$file['id']] = $file;
441 }
442
443 // Add or concat file
444 if (empty($filesarray[$file['item'].'_'.$file['id']]['files'])) {
445 $filesarray[$file['item'].'_'.$file['id']]['files'] = array();
446 }
447 $filesarray[$file['item'].'_'.$file['id']]['files'][] = array(
448 'link' => $link.urlencode($file['name']),
449 'name'=>$file['name'],
450 'ref'=>$file['ref'],
451 'fullname' => $file['fullname'],
452 'relpath' => '/'.$file['name'],
453 'relpathnamelang' => $langs->trans($file['item']).'/'.$file['name'],
454 'modulepart' => $modulepart,
455 'subdir' => $subdir,
456 'currency' => $file['currency']
457 );
458 //var_dump($file['item'].'_'.$file['id']);
459 //var_dump($filesarray[$file['item'].'_'.$file['id']]['files']);
460 }
461 }
462 }
463
464 $i++;
465 }
466 } else {
467 dol_print_error($db);
468 }
469
470 $db->free($resd);
471 } else {
472 setEventMessages($langs->trans("ErrorSelectAtLeastOne"), null, 'errors');
473 $error++;
474 }
475 }
476}
477
478
479/*
480 *ZIP creation
481 */
482
483$dirfortmpfile = (!empty($conf->accounting->dir_temp) ? $conf->accounting->dir_temp : $conf->comptabilite->dir_temp);
484if (empty($dirfortmpfile)) {
485 setEventMessages($langs->trans("ErrorNoAccountingModuleEnabled"), null, 'errors');
486 $error++;
487}
488
489
490if ($result && $action == "dl" && !$error) {
491 if (!extension_loaded('zip')) {
492 setEventMessages('PHPZIPExtentionNotLoaded', null, 'errors');
493 } else {
494 dol_mkdir($dirfortmpfile);
495
496 $log = $langs->transnoentitiesnoconv("Type");
497 if (isModEnabled('multicompany') && is_object($mc)) {
498 $log .= ','.$langs->transnoentitiesnoconv("Entity");
499 }
500 $log .= ','.$langs->transnoentitiesnoconv("Date");
501 $log .= ','.$langs->transnoentitiesnoconv("DateDue");
502 $log .= ','.$langs->transnoentitiesnoconv("Ref");
503 $log .= ','.$langs->transnoentitiesnoconv("TotalHT");
504 $log .= ','.$langs->transnoentitiesnoconv("TotalTTC");
505 $log .= ','.$langs->transnoentitiesnoconv("TotalVAT");
506 $log .= ','.$langs->transcountrynoentities("TotalLT1", $mysoc->country_code);
507 $log .= ','.$langs->transcountrynoentities("TotalLT2", $mysoc->country_code);
508 $log .= ','.$langs->transnoentitiesnoconv("RevenueStamp");
509 $log .= ','.$langs->transnoentitiesnoconv("Paid");
510 $log .= ','.$langs->transnoentitiesnoconv("Document");
511 $log .= ','.$langs->transnoentitiesnoconv("ItemID");
512 $log .= ','.$langs->transnoentitiesnoconv("ThirdParty");
513 $log .= ','.$langs->transnoentitiesnoconv("Code");
514 $log .= ','.$langs->transnoentitiesnoconv("Country");
515 $log .= ','.$langs->transnoentitiesnoconv("VATIntra");
516 $log .= ','.$langs->transnoentitiesnoconv("Sens")."\n";
517 $zipname = $dirfortmpfile.'/'.dol_print_date($date_start, 'dayrfc', 'tzuserrel')."-".dol_print_date($date_stop, 'dayrfc', 'tzuserrel');
518 if (!empty($projectid)) {
519 $project = new Project($db);
520 $project->fetch($projectid);
521 if ($project->ref) {
522 $zipname .= '_'.$project->ref;
523 }
524 }
525 $zipname .='_export.zip';
526
527 dol_delete_file($zipname);
528
529 $zip = new ZipArchive();
530 $res = $zip->open($zipname, ZipArchive::OVERWRITE | ZipArchive::CREATE);
531 if ($res) {
532 foreach ($filesarray as $key => $file) {
533 if (!empty($file['files'])) {
534 foreach ($file['files'] as $filecursor) {
535 if (file_exists($filecursor["fullname"])) {
536 $zip->addFile($filecursor["fullname"], $filecursor["relpathnamelang"]);
537 }
538 }
539 }
540
541 $log .= '"'.$langs->transnoentitiesnoconv($file['item']).'"';
542 if (isModEnabled('multicompany') && is_object($mc)) {
543 $log .= ',"'.(empty($arrayofentities[$file['entity']]) ? $file['entity'] : $arrayofentities[$file['entity']]).'"';
544 }
545 $log .= ','.dol_print_date($file['date'], 'dayrfc');
546 $log .= ','.dol_print_date($file['date_due'], 'dayrfc');
547 $log .= ',"'.$file['ref'].'"';
548 $log .= ','.$file['amount_ht'];
549 $log .= ','.$file['amount_ttc'];
550 $log .= ','.$file['amount_vat'];
551 $log .= ','.$file['amount_localtax1'];
552 $log .= ','.$file['amount_localtax2'];
553 $log .= ','.$file['amount_revenuestamp'];
554 $log .= ','.$file['paid'];
555 $log .= ',"'.$file["name"].'"';
556 $log .= ','.$file['fk'];
557 $log .= ',"'.$file['thirdparty_name'].'"';
558 $log .= ',"'.$file['thirdparty_code'].'"';
559 $log .= ',"'.$file['country_code'].'"';
560 $log .= ',"'.$file['vatnum'].'"';
561 $log .= ',"'.$file['sens'].'"';
562 $log .= "\n";
563 }
564 $zip->addFromString('transactions.csv', $log);
565 $zip->close();
566
567 // Then download the zipped file.
568 header('Content-Type: application/zip');
569 header('Content-disposition: attachment; filename='.basename($zipname));
570 header('Content-Length: '.filesize($zipname));
571 readfile($zipname);
572
573 dol_delete_file($zipname);
574
575 exit();
576 } else {
577 setEventMessages($langs->trans("FailedToOpenFile", $zipname), null, 'errors');
578 }
579 }
580}
581
582
583/*
584 * View
585 */
586
587$form = new Form($db);
588$formfile = new FormFile($db);
589$userstatic = new User($db);
590$invoice = new Facture($db);
591$supplier_invoice = new FactureFournisseur($db);
592$expensereport = new ExpenseReport($db);
593$don = new Don($db);
594$salary_payment = new PaymentSalary($db);
595$charge_sociales = new ChargeSociales($db);
596$various_payment = new PaymentVarious($db);
597$payment_loan = new PaymentLoan($db);
598
599$title = $langs->trans("ComptaFiles").' - '.$langs->trans("List");
600$help_url = '';
601
602llxHeader('', $title, $help_url);
603
604$h = 0;
605$head = array();
606$head[$h][0] = $_SERVER["PHP_SELF"];
607$head[$h][1] = $langs->trans("AccountantFiles");
608$head[$h][2] = 'AccountancyFiles';
609
610print dol_get_fiche_head($head, 'AccountancyFiles');
611
612
613print '<form name="searchfiles" action="?action=searchfiles" method="POST">'."\n";
614print '<input type="hidden" name="token" value="'.newToken().'">';
615
616print '<span class="opacitymedium">'.$langs->trans("ExportAccountingSourceDocHelp");
617if (isModEnabled('accounting')) {
618 print ' '.$langs->trans("ExportAccountingSourceDocHelp2", $langs->transnoentitiesnoconv("Accounting"), $langs->transnoentitiesnoconv("Journals"));
619}
620print '</span><br>';
621print '<br>';
622
623print $langs->trans("ReportPeriod").': ';
624print $form->selectDate($date_start, 'date_start', 0, 0, 0, "", 1, 1, 0, '', '', '', '', 1, '', '', 'tzuserrel');
625print ' - ';
626print $form->selectDate($date_stop, 'date_stop', 0, 0, 0, "", 1, 1, 0, '', '', '', '', 1, '', '', 'tzuserrel');
627print "\n";
628
629// Export is for current company only
630$socid = 0;
631if (isModEnabled('multicompany') && is_object($mc)) {
632 $mc->getInfo($conf->entity);
633 print ' &nbsp; <span class="marginleftonly marginrightonly'.(!getDolGlobalString('MULTICOMPANY_ALLOW_EXPORT_ACCOUNTING_DOC_FOR_ALL_ENTITIES') ? ' opacitymedium' : '').'">'.$langs->trans("Entity").' : ';
634 if (getDolGlobalString('MULTICOMPANY_ALLOW_EXPORT_ACCOUNTING_DOC_FOR_ALL_ENTITIES')) {
635 $socid = $mc->id;
636 print $mc->select_entities(GETPOSTISSET('search_entity') ? GETPOST('search_entity', 'int') : $mc->id, 'search_entity', '', false, false, false, false, true);
637 } else {
638 print $mc->label;
639 }
640 print "</span>\n";
641}
642
643print '<br>';
644
645// Project filter
646if (isModEnabled('projet')) {
647 $formproject = new FormProjets($db);
648 $langs->load('projects');
649 print '<span class="marginrightonly">'.$langs->trans('Project').":</span>";
650 print img_picto('', 'project').$formproject->select_projects(($socid > 0 ? $socid : -1), $projectid, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 1, 0, '');
651 print '<span class="classfortooltip" style="padding: 0px; padding: 0px; padding-right: 3px !important;" title="'.$langs->trans('ExportAccountingProjectHelp').'"><span class="fas fa-info-circle em088 opacityhigh" style=" vertical-align: middle; cursor: help"></span></span>';
652 print '<br>';
653}
654
655$i = 0;
656foreach ($listofchoices as $choice => $val) {
657 if (empty($val['enabled'])) {
658 continue; // list not qualified
659 }
660 $disabled = '';
661 if (empty($val['perms'])) {
662 $disabled = ' disabled';
663 }
664 $checked = (((!GETPOSTISSET('search') && $action != 'searchfiles') || GETPOST($choice)) ? ' checked="checked"' : '');
665 print '<div class="'.($i > 0 ? 'paddingleft marginleftonly' : '').' inline-block marginrightonly paddingright"><input type="checkbox" id="'.$choice.'" name="'.$choice.'" value="1"'.$checked.$disabled.'><label for="'.$choice.'"> ';
666 print img_picto($langs->trans($val['label']), $val['picto'], 'class=""').' '.$langs->trans($val['label']);
667 print '</label></div>';
668 $i++;
669}
670
671print '<input type="submit" class="button small" name="search" value="'.$langs->trans("Search").'">';
672
673print '</form>'."\n";
674
675print dol_get_fiche_end();
676
677$param = '';
678if (!empty($date_start) && !empty($date_stop)) {
679 $param .= '&date_startday='.GETPOST('date_startday', 'int');
680 $param .= '&date_startmonth='.GETPOST('date_startmonth', 'int');
681 $param .= '&date_startyear='.GETPOST('date_startyear', 'int');
682 $param .= '&date_stopday='.GETPOST('date_stopday', 'int');
683 $param .= '&date_stopmonth='.GETPOST('date_stopmonth', 'int');
684 $param .= '&date_stopyear='.GETPOST('date_stopyear', 'int');
685 foreach ($listofchoices as $choice => $val) {
686 if (GETPOST($choice, 'int')) {
687 $param .= '&'.$choice.'=1';
688 }
689 }
690
691 $TData = dol_sort_array($filesarray, $sortfield, $sortorder);
692
693
694 $filename = dol_print_date($date_start, 'dayrfc', 'tzuserrel')."-".dol_print_date($date_stop, 'dayrfc', 'tzuserrel').'_export.zip';
695
696 echo dol_print_date($date_start, 'day', 'tzuserrel')." - ".dol_print_date($date_stop, 'day', 'tzuserrel');
697
698 print '<a class="marginleftonly small'.(empty($TData) ? ' butActionRefused' : ' butAction').'" href="'.$_SERVER["PHP_SELF"].'?action=dl&token='.currentToken().'&projectid='.$projectid.'&output=file&file='.urlencode($filename).$param.'"';
699 if (empty($TData)) {
700 print " disabled";
701 }
702 print '>'."\n";
703 print $langs->trans("Download");
704 print '</a><br>';
705
706 $param .= '&action=searchfiles';
707
708 /*
709 print '<input type="hidden" name="token" value="'.currentToken().'">';
710 print '<input type="hidden" name="date_startday" value="'.GETPOST('date_startday', 'int').'" />';
711 print '<input type="hidden" name="date_startmonth" value="'.GETPOST('date_startmonth', 'int').'" />';
712 print '<input type="hidden" name="date_startyear" value="'.GETPOST('date_startyear', 'int').'" />';
713 print '<input type="hidden" name="date_stopday" value="'.GETPOST('date_stopday', 'int').'" />';
714 print '<input type="hidden" name="date_stopmonth" value="'.GETPOST('date_stopmonth', 'int').'" />';
715 print '<input type="hidden" name="date_stopyear" value="'.GETPOST('date_stopyear', 'int').'" />';
716 foreach ($listofchoices as $choice => $val) {
717 print '<input type="hidden" name="'.$choice.'" value="'.GETPOST($choice).'">';
718 }
719
720 print '<input class="butAction butDownload small marginleftonly" type="submit" value="'.$langs->trans("Download").'"';
721 if (empty($TData)) {
722 print " disabled";
723 }
724 print '/>';
725 print '</form>'."\n";
726 */
727
728 print '<br>';
729
730 print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
731 print '<table class="noborder centpercent">';
732 print '<tr class="liste_titre">';
733 print_liste_field_titre($arrayfields['type']['label'], $_SERVER["PHP_SELF"], "item", "", $param, '', $sortfield, $sortorder, 'nowrap ');
734 print_liste_field_titre($arrayfields['date']['label'], $_SERVER["PHP_SELF"], "date", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
735 print_liste_field_titre($arrayfields['date_due']['label'], $_SERVER["PHP_SELF"], "date_due", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
736 print_liste_field_titre($arrayfields['ref']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'nowraponall ');
737 print '<th>'.$langs->trans("Document").'</th>';
738 print '<th>'.$langs->trans("Paid").'</th>';
739 print '<th class="right">'.$langs->trans("TotalHT").(isModEnabled('multicurrency') ? ' ('.$langs->getCurrencySymbol($conf->currency).')' : '').'</th>';
740 print '<th class="right">'.$langs->trans("TotalTTC").(isModEnabled('multicurrency') ? ' ('.$langs->getCurrencySymbol($conf->currency).')' : '').'</th>';
741 print '<th class="right">'.$langs->trans("TotalVAT").(isModEnabled('multicurrency') ? ' ('.$langs->getCurrencySymbol($conf->currency).')' : '').'</th>';
742
743 print '<th>'.$langs->trans("ThirdParty").'</th>';
744 print '<th class="center">'.$langs->trans("Code").'</th>';
745 print '<th class="center">'.$langs->trans("Country").'</th>';
746 print '<th class="center">'.$langs->trans("VATIntra").'</th>';
747 if (isModEnabled('multicurrency')) {
748 print '<th class="center">'.$langs->trans("Currency").'</th>';
749 }
750 print '</tr>';
751
752 if (empty($TData)) {
753 print '<tr class="oddeven"><td colspan="13"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td>';
754 if (isModEnabled('multicurrency')) {
755 print '<td></td>';
756 }
757 print '</tr>';
758 } else {
759 // Sort array by date ASC to calculate balance
760
761 $totalET_debit = 0;
762 $totalIT_debit = 0;
763 $totalVAT_debit = 0;
764 $totalET_credit = 0;
765 $totalIT_credit = 0;
766 $totalVAT_credit = 0;
767
768 // Display array
769 foreach ($TData as $data) {
770 $html_class = '';
771 //if (!empty($data['fk_facture'])) $html_class = 'facid-'.$data['fk_facture'];
772 //elseif (!empty($data['fk_paiement'])) $html_class = 'payid-'.$data['fk_paiement'];
773 print '<tr class="oddeven '.$html_class.'">';
774
775 // Type
776 print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($langs->trans($data['item'])).'">'.$langs->trans($data['item']).'</td>';
777
778 // Date
779 print '<td class="center">';
780 print dol_print_date($data['date'], 'day');
781 print "</td>\n";
782
783 // Date due
784 print '<td class="center">';
785 print dol_print_date($data['date_due'], 'day');
786 print "</td>\n";
787
788 // Ref
789 print '<td class="nowraponall tdoverflowmax150">';
790
791 if ($data['item'] == 'Invoice') {
792 $invoice->id = $data['id'];
793 $invoice->ref = $data['ref'];
794 $invoice->total_ht = $data['amount_ht'];
795 $invoice->total_ttc = $data['amount_ttc'];
796 $invoice->total_tva = $data['amount_vat'];
797 $invoice->total_localtax1 = $data['amount_localtax1'];
798 $invoice->total_localtax2 = $data['amount_localtax2'];
799 $invoice->revenuestamp = $data['amount_revenuestamp'];
800 $invoice->multicurrency_code = $data['currency'];
801 print $invoice->getNomUrl(1, '', 0, 0, '', 0, 0, 0);
802 } elseif ($data['item'] == 'SupplierInvoice') {
803 $supplier_invoice->id = $data['id'];
804 $supplier_invoice->ref = $data['ref'];
805 $supplier_invoice->total_ht = $data['amount_ht'];
806 $supplier_invoice->total_ttc = $data['amount_ttc'];
807 $supplier_invoice->total_tva = $data['amount_vat'];
808 $supplier_invoice->total_localtax1 = $data['amount_localtax1'];
809 $supplier_invoice->total_localtax2 = $data['amount_localtax2'];
810 $supplier_invoice->revenuestamp = $data['amount_revenuestamp'];
811 $supplier_invoice->multicurrency_code = $data['currency'];
812 print $supplier_invoice->getNomUrl(1, '', 0, 0, '', 0, 0, 0);
813 } elseif ($data['item'] == 'ExpenseReport') {
814 $expensereport->id = $data['id'];
815 $expensereport->ref = $data['ref'];
816 print $expensereport->getNomUrl(1, 0, 0, '', 0, 0);
817 } elseif ($data['item'] == 'SalaryPayment') {
818 $salary_payment->id = $data['id'];
819 $salary_payment->ref = $data['ref'];
820 print $salary_payment->getNomUrl(1);
821 } elseif ($data['item'] == 'Donation') {
822 $don->id = $data['id'];
823 $don->ref = $data['ref'];
824 print $don->getNomUrl(1, 0, '', 0);
825 } elseif ($data['item'] == 'SocialContributions') {
826 $charge_sociales->id = $data['id'];
827 $charge_sociales->ref = $data['ref'];
828 print $charge_sociales->getNomUrl(1, 0, 0, 0, 0);
829 } elseif ($data['item'] == 'VariousPayment') {
830 $various_payment->id = $data['id'];
831 $various_payment->ref = $data['ref'];
832 print $various_payment->getNomUrl(1, '', 0, 0);
833 } elseif ($data['item'] == 'LoanPayment') {
834 $payment_loan->id = $data['id'];
835 $payment_loan->ref = $data['ref'];
836 print $payment_loan->getNomUrl(1, 0, 0, '', 0);
837 } else {
838 print $data['ref'];
839 }
840 print '</td>';
841
842 // File link
843 print '<td class="tdoverflowmax150">';
844 if (!empty($data['files'])) {
845 foreach ($data['files'] as $id => $filecursor) {
846 $tmppreview = $formfile->showPreview($filecursor, $filecursor['modulepart'], $filecursor['subdir'].'/'.$filecursor['name'], 0);
847 if ($tmppreview) {
848 print $tmppreview;
849 }
850 $filename = ($filecursor['name'] ? $filecursor['name'] : $filecursor['ref']);
851 print '<a href='.DOL_URL_ROOT.'/'.$filecursor['link'].' target="_blank" rel="noopener noreferrer" title="'.dol_escape_htmltag($filename).'">';
852 if (empty($tmppreview)) {
853 print img_picto('', 'generic', '', false, 0, 0, '', 'pictonopreview pictofixedwidth paddingright');
854 }
855 print $filename;
856 print '</a><br>';
857 }
858 }
859 print "</td>\n";
860
861 // Paid
862 print '<td class="center">'.($data['paid'] ? yn($data['paid']) : '').'</td>';
863
864 // Total WOT
865 print '<td class="right"><span class="amount">'.price(price2num($data['sens'] ? $data['amount_ht'] : -$data['amount_ht'], 'MT'))."</span></td>\n";
866 // Total INCT
867 print '<td class="right"><span class="amount">';
868 $tooltip = $langs->trans("TotalVAT").' : '.price(price2num($data['sens'] ? $data['amount_vat'] : -$data['amount_vat'], 'MT'));
869 if (!empty($data['amount_localtax1'])) {
870 $tooltip .= '<br>'.$langs->transcountrynoentities("TotalLT1", $mysoc->country_code).' : '.price(price2num($data['sens'] ? $data['amount_localtax1'] : -$data['amount_localtax1'], 'MT'));
871 }
872 if (!empty($data['amount_localtax2'])) {
873 $tooltip .= '<br>'.$langs->transcountrynoentities("TotalLT2", $mysoc->country_code).' : '.price(price2num($data['sens'] ? $data['amount_localtax2'] : -$data['amount_localtax2'], 'MT'));
874 }
875 if (!empty($data['amount_revenuestamp'])) {
876 $tooltip .= '<br>'.$langs->trans("RevenueStamp").' : '.price(price2num($data['sens'] ? $data['amount_revenuestamp'] : -$data['amount_revenuestamp'], 'MT'));
877 }
878 print '<span class="classfortooltip" title="'.dol_escape_htmltag($tooltip).'">'.price(price2num($data['sens'] ? $data['amount_ttc'] : -$data['amount_ttc'], 'MT')).'</span>';
879 print "</span></td>\n";
880 // Total VAT
881 print '<td class="right"><span class="amount">'.price(price2num($data['sens'] ? $data['amount_vat'] : -$data['amount_vat'], 'MT'))."</span></td>\n";
882
883 print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($data['thirdparty_name']).'">'.dol_escape_htmltag($data['thirdparty_name'])."</td>\n";
884
885 print '<td class="center">'.$data['thirdparty_code']."</td>\n";
886
887 print '<td class="center">'.$data['country_code']."</td>\n";
888
889 // VAT number
890 print '<td class="tdoverflowmax150 right" title="'.dol_escape_htmltag($data['vatnum']).'">'.dol_escape_htmltag($data['vatnum'])."</td>\n";
891
892 if ($data['sens']) {
893 $totalET_credit += $data['amount_ht'];
894 $totalIT_credit += $data['amount_ttc'];
895 $totalVAT_credit += $data['amount_vat'];
896 } else {
897 $totalET_debit -= $data['amount_ht'];
898 $totalIT_debit -= $data['amount_ttc'];
899 $totalVAT_debit -= $data['amount_vat'];
900 }
901
902 if (isModEnabled('multicurrency')) {
903 print '<td class="center">'.$data['currency']."</td>\n";
904 }
905
906 print "</tr>\n";
907 }
908
909 // Total credits
910 print '<tr class="liste_total">';
911 print '<td colspan="6" class="right">'.$langs->trans('Total').' '.$langs->trans('Income').'</td>';
912 print '<td class="right">'.price(price2num($totalET_credit, 'MT')).'</td>';
913 print '<td class="right">'.price(price2num($totalIT_credit, 'MT')).'</td>';
914 print '<td class="right">'.price(price2num($totalVAT_credit, 'MT')).'</td>';
915 print '<td colspan="4"></td>';
916 if (isModEnabled('multicurrency')) {
917 print '<td></td>';
918 }
919 print "</tr>\n";
920 // Total debits
921 print '<tr class="liste_total">';
922 print '<td colspan="6" class="right">'.$langs->trans('Total').' '.$langs->trans('Outcome').'</td>';
923 print '<td class="right">'.price(price2num($totalET_debit, 'MT')).'</td>';
924 print '<td class="right">'.price(price2num($totalIT_debit, 'MT')).'</td>';
925 print '<td class="right">'.price(price2num($totalVAT_debit, 'MT')).'</td>';
926 print '<td colspan="4"></td>';
927 if (isModEnabled('multicurrency')) {
928 print '<td></td>';
929 }
930 print "</tr>\n";
931 // Balance
932 print '<tr class="liste_total">';
933 print '<td colspan="6" class="right">'.$langs->trans('Total').'</td>';
934 print '<td class="right">'.price(price2num($totalET_credit + $totalET_debit, 'MT')).'</td>';
935 print '<td class="right">'.price(price2num($totalIT_credit + $totalIT_debit, 'MT')).'</td>';
936 print '<td class="right">'.price(price2num($totalVAT_credit + $totalVAT_debit, 'MT')).'</td>';
937 print '<td colspan="4"></td>';
938 if (isModEnabled('multicurrency')) {
939 print '<td></td>';
940 }
941 print "</tr>\n";
942 }
943
944 print "</table>";
945 print '</div>';
946}
947
948
949llxFooter();
950$db->close();
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:55
llxFooter()
Empty footer.
Definition wrapper.php:69
Classe permettant la gestion des paiements des charges La tva collectee n'est calculee que sur les fa...
Class to manage donations.
Definition don.class.php:40
Class to manage Trips and Expenses.
Class to manage suppliers invoices.
Class to manage invoices.
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
Class to manage building of HTML components.
Class to manage payments of loans.
Class to manage payments of salaries.
Class to manage various payments.
Class to manage projects.
Class to manage Dolibarr users.
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1, $nolog=0)
Remove a file or several files with a mask.
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
Definition files.lib.php:62
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
currentToken()
Return the value of token currently saved into session with name 'token'.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.