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