29 if ((array_key_exists(
'action', $_GET) && $_GET[
'action'] ==
'dl') || (array_key_exists(
'action', $_POST) && $_POST[
'action'] ==
'dl')) {
30 if (!defined(
'NOTOKENRENEWAL')) {
31 define(
'NOTOKENRENEWAL',
'1');
35 require
'../main.inc.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
39 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
40 require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
41 require_once DOL_DOCUMENT_ROOT.
'/salaries/class/paymentsalary.class.php';
42 require_once DOL_DOCUMENT_ROOT.
'/compta/sociales/class/chargesociales.class.php';
43 require_once DOL_DOCUMENT_ROOT.
'/don/class/don.class.php';
44 require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/expensereport.class.php';
45 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
46 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
47 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/paymentvarious.class.php';
48 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
49 require_once DOL_DOCUMENT_ROOT.
'/loan/class/paymentloan.class.php';
55 $langs->loadLangs(array(
"accountancy",
"bills",
"companies",
"salaries",
"compta",
"trips",
"banks",
"loan"));
57 $date_start =
GETPOST(
'date_start',
'alpha');
58 $date_startDay =
GETPOST(
'date_startday',
'int');
59 $date_startMonth =
GETPOST(
'date_startmonth',
'int');
60 $date_startYear =
GETPOST(
'date_startyear',
'int');
61 $date_start =
dol_mktime(0, 0, 0, $date_startMonth, $date_startDay, $date_startYear,
'tzuserrel');
62 $date_stop =
GETPOST(
'date_stop',
'alpha');
63 $date_stopDay =
GETPOST(
'date_stopday',
'int');
64 $date_stopMonth =
GETPOST(
'date_stopmonth',
'int');
65 $date_stopYear =
GETPOST(
'date_stopyear',
'int');
66 $date_stop =
dol_mktime(23, 59, 59, $date_stopMonth, $date_stopDay, $date_stopYear,
'tzuserrel');
67 $action =
GETPOST(
'action',
'aZ09');
70 $hookmanager->initHooks(array(
'comptafileslist',
'globallist'));
73 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
74 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
75 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
77 if (empty($page) || $page == -1) {
80 $offset = $limit * $page;
81 $pageprev = $page - 1;
82 $pagenext = $page + 1;
84 $sortfield =
"date,item";
92 'type'=>array(
'label'=>
"Type",
'checked'=>1),
93 'date'=>array(
'label'=>
"Date",
'checked'=>1),
94 'date_due'=>array(
'label'=>
"DateDue",
'checked'=>1),
95 'ref'=>array(
'label'=>
"Ref",
'checked'=>1),
96 'documents'=>array(
'label'=>
"Documents",
'checked'=>1),
97 'paid'=>array(
'label'=>
"Paid",
'checked'=>1),
98 'total_ht'=>array(
'label'=>
"TotalHT",
'checked'=>1),
99 'total_ttc'=>array(
'label'=>
"TotalTTC",
'checked'=>1),
100 'total_vat'=>array(
'label'=>
"TotalVAT",
'checked'=>1),
108 if ($user->socid > 0) {
113 $arrayofentities = array();
115 $arrayofentities = $mc->getEntitiesList();
120 if (empty($entity) && !empty($conf->global->MULTICOMPANY_ALLOW_EXPORT_ACCOUNTING_DOC_FOR_ALL_ENTITIES)) {
121 $entity =
'0,'.join(
',', array_keys($arrayofentities));
124 if (empty($entity)) {
125 $entity = $conf->entity;
130 $listofchoices = array(
131 'selectinvoices'=>array(
'label'=>
'Invoices',
'lang'=>
'bills',
'enabled' =>
isModEnabled(
'facture'),
'perms' => !empty($user->rights->facture->lire)),
132 'selectsupplierinvoices'=>array(
'label'=>
'BillsSuppliers',
'lang'=>
'bills',
'enabled' =>
isModEnabled(
'supplier_invoice'),
'perms' => !empty($user->rights->fournisseur->facture->lire)),
133 'selectexpensereports'=>array(
'label'=>
'ExpenseReports',
'lang'=>
'trips',
'enabled' =>
isModEnabled(
'expensereport'),
'perms' => !empty($user->rights->expensereport->lire)),
134 'selectdonations'=>array(
'label'=>
'Donations',
'lang'=>
'donation',
'enabled' =>
isModEnabled(
'don'),
'perms' => !empty($user->rights->don->lire)),
135 'selectsocialcontributions'=>array(
'label'=>
'SocialContributions',
'enabled' =>
isModEnabled(
'tax'),
'perms' => !empty($user->rights->tax->charges->lire)),
136 'selectpaymentsofsalaries'=>array(
'label'=>
'SalariesPayments',
'lang'=>
'salaries',
'enabled' =>
isModEnabled(
'salaries'),
'perms' => !empty($user->rights->salaries->read)),
137 'selectvariouspayment'=>array(
'label'=>
'VariousPayment',
'enabled' =>
isModEnabled(
'banque'),
'perms' => !empty($user->rights->banque->lire)),
138 'selectloanspayment'=>array(
'label'=>
'PaymentLoan',
'enabled' =>
isModEnabled(
'don'),
'perms' => !empty($user->rights->loan->read)),
152 $filesarray = array();
154 if (($action ==
'searchfiles' || $action ==
'dl')) {
155 if (empty($date_start)) {
156 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateStart")), null,
'errors');
159 if (empty($date_stop)) {
160 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateEnd")), null,
'errors');
167 $wheretail =
" '".$db->idate($date_start).
"' AND '".$db->idate($date_stop).
"'";
170 if (
GETPOST(
'selectinvoices') && !empty($listofchoices[
'selectinvoices'][
'perms'])) {
172 $sql .=
" UNION ALL";
174 $sql .=
"SELECT t.rowid as id, t.entity, t.ref, t.paye as paid, t.total_ht, t.total_ttc, t.total_tva as total_vat, t.multicurrency_code as currency, t.fk_soc, t.datef as date, t.date_lim_reglement as date_due, 'Invoice' as item, s.nom as thirdparty_name, s.code_client as thirdparty_code, c.code as country_code, s.tva_intra as vatnum, ".PAY_CREDIT.
" as sens";
175 $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";
176 $sql .=
" WHERE datef between ".$wheretail;
177 $sql .=
" AND t.entity IN (".$db->sanitize($entity == 1 ?
'0,1' : $entity).
')';
178 $sql .=
" AND t.fk_statut <> ".Facture::STATUS_DRAFT;
181 if (
GETPOST(
'selectsupplierinvoices') && !empty($listofchoices[
'selectsupplierinvoices'][
'perms'])) {
183 $sql .=
" UNION ALL";
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, 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";
186 $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";
187 $sql .=
" WHERE datef between ".$wheretail;
188 $sql .=
" AND t.entity IN (".$db->sanitize($entity == 1 ?
'0,1' : $entity).
')';
189 $sql .=
" AND t.fk_statut <> ".FactureFournisseur::STATUS_DRAFT;
192 if (
GETPOST(
'selectexpensereports') && !empty($listofchoices[
'selectexpensereports'][
'perms'])) {
194 $sql .=
" UNION ALL";
196 $sql .=
" SELECT t.rowid as id, t.entity, t.ref, t.paid, t.total_ht, t.total_ttc, t.total_tva as total_vat, t.multicurrency_code as currency, t.fk_user_author as fk_soc, t.date_fin as date, t.date_fin as date_due, 'ExpenseReport' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum, ".PAY_DEBIT.
" as sens";
197 $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";
198 $sql .=
" WHERE date_fin between ".$wheretail;
199 $sql .=
" AND t.entity IN (".$db->sanitize($entity == 1 ?
'0,1' : $entity).
')';
200 $sql .=
" AND t.fk_statut <> ".ExpenseReport::STATUS_DRAFT;
203 if (
GETPOST(
'selectdonations') && !empty($listofchoices[
'selectdonations'][
'perms'])) {
205 $sql .=
" UNION ALL";
207 $sql .=
" SELECT t.rowid as id, t.entity, t.ref, paid, amount as total_ht, amount as total_ttc, 0 as total_vat, '".$db->escape($conf->currency).
"' as currency, 0 as fk_soc, t.datedon as date, t.datedon as date_due, 'Donation' as item, t.societe as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum, ".PAY_CREDIT.
" as sens";
208 $sql .=
" FROM ".MAIN_DB_PREFIX.
"don as t LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as c ON c.rowid = t.fk_country";
209 $sql .=
" WHERE datedon between ".$wheretail;
210 $sql .=
" AND t.entity IN (".$db->sanitize($entity == 1 ?
'0,1' : $entity).
')';
211 $sql .=
" AND t.fk_statut <> ".Don::STATUS_DRAFT;
214 if (
GETPOST(
'selectpaymentsofsalaries') && !empty($listofchoices[
'selectpaymentsofsalaries'][
'perms'])) {
216 $sql .=
" UNION ALL";
218 $sql .=
" SELECT t.rowid as id, t.entity, t.label as ref, 1 as paid, amount as total_ht, amount as total_ttc, 0 as total_vat, '".$db->escape($conf->currency).
"' as currency, t.fk_user as fk_soc, t.datep as date, t.dateep as date_due, 'SalaryPayment' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum, ".PAY_DEBIT.
" as sens";
219 $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";
220 $sql .=
" WHERE datep between ".$wheretail;
221 $sql .=
" AND t.entity IN (".$db->sanitize($entity == 1 ?
'0,1' : $entity).
')';
225 if (
GETPOST(
'selectsocialcontributions') && !empty($listofchoices[
'selectsocialcontributions'][
'perms'])) {
227 $sql .=
" UNION ALL";
229 $sql .=
" SELECT t.rowid as id, t.entity, t.libelle as ref, t.paye as paid, t.amount as total_ht, t.amount as total_ttc, 0 as total_vat, '".$db->escape($conf->currency).
"' as currency, 0 as fk_soc, t.date_ech as date, t.periode as date_due, 'SocialContributions' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum, ".PAY_DEBIT.
" as sens";
230 $sql .=
" FROM ".MAIN_DB_PREFIX.
"chargesociales as t";
231 $sql .=
" WHERE t.date_ech between ".$wheretail;
232 $sql .=
" AND t.entity IN (".$db->sanitize($entity == 1 ?
'0,1' : $entity).
')';
236 if (
GETPOST(
'selectvariouspayment') && !empty($listofchoices[
'selectvariouspayment'][
'perms'])) {
238 $sql .=
" UNION ALL";
240 $sql .=
" SELECT t.rowid as id, t.entity, t.ref, 1 as paid, t.amount as total_ht, t.amount as total_ttc, 0 as total_vat, '".$db->escape($conf->currency).
"' as currency, 0 as fk_soc, t.datep as date, t.datep as date_due, 'VariousPayment' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum, sens";
241 $sql .=
" FROM ".MAIN_DB_PREFIX.
"payment_various as t";
242 $sql .=
" WHERE datep between ".$wheretail;
243 $sql .=
" AND t.entity IN (".$db->sanitize($entity == 1 ?
'0,1' : $entity).
')';
246 if (
GETPOST(
'selectloanspayment') && !empty($listofchoices[
'selectloanspayment'][
'perms'])) {
248 $sql .=
" UNION ALL";
250 $sql .=
" SELECT t.rowid as id, l.entity, l.label as ref, 1 as paid, (t.amount_capital+t.amount_insurance+t.amount_interest) as total_ht, (t.amount_capital+t.amount_insurance+t.amount_interest) as total_ttc, 0 as total_vat, '".$db->escape($conf->currency).
"' as currency, 0 as fk_soc, t.datep as date, t.datep as date_due, 'LoanPayment' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum, ".PAY_DEBIT.
" as sens";
251 $sql .=
" FROM ".MAIN_DB_PREFIX.
"payment_loan as t LEFT JOIN ".MAIN_DB_PREFIX.
"loan as l ON l.rowid = t.fk_loan";
252 $sql .=
" WHERE datep between ".$wheretail;
253 $sql .=
" AND l.entity IN (".$db->sanitize($entity == 1 ?
'0,1' : $entity).
')';
257 $sql .= $db->order($sortfield, $sortorder);
260 $resd = $db->query($sql);
265 $numd = $db->num_rows($resd);
267 $tmpinvoice =
new Facture($db);
269 $tmpdonation =
new Don($db);
274 $objd = $db->fetch_object($resd);
276 switch ($objd->item) {
280 $upload_dir = $conf->facture->dir_output.
'/'.$subdir;
281 $link =
"document.php?modulepart=facture&file=".str_replace(
'/',
'%2F', $subdir).
'%2F';
282 $modulepart =
"facture";
284 case "SupplierInvoice":
285 $tmpinvoicesupplier->fetch($objd->id);
286 $subdir =
get_exdir($tmpinvoicesupplier->id, 2, 0, 1, $tmpinvoicesupplier,
'invoice_supplier');
288 $upload_dir = $conf->fournisseur->facture->dir_output.
'/'.$subdir;
289 $link =
"document.php?modulepart=facture_fournisseur&file=".str_replace(
'/',
'%2F', $subdir).
'%2F';
290 $modulepart =
"facture_fournisseur";
292 case "ExpenseReport":
295 $upload_dir = $conf->expensereport->dir_output.
'/'.$subdir;
296 $link =
"document.php?modulepart=expensereport&file=".str_replace(
'/',
'%2F', $subdir).
'%2F';
297 $modulepart =
"expensereport";
299 case "SalaryPayment":
302 $upload_dir = $conf->salaries->dir_output.
'/'.$subdir;
303 $link =
"document.php?modulepart=salaries&file=".str_replace(
'/',
'%2F', $subdir).
'%2F';
304 $modulepart =
"salaries";
307 $tmpdonation->fetch($objp->id);
308 $subdir =
get_exdir(0, 0, 0, 0, $tmpdonation,
'donation');
310 $upload_dir = $conf->don->dir_output.
'/'.$subdir;
311 $link =
"document.php?modulepart=don&file=".str_replace(
'/',
'%2F', $subdir).
'%2F';
314 case "SocialContributions":
317 $upload_dir = $conf->tax->dir_output.
'/'.$subdir;
318 $link =
"document.php?modulepart=tax&file=".str_replace(
'/',
'%2F', $subdir).
'%2F';
321 case "VariousPayment":
324 $upload_dir = $conf->bank->dir_output.
'/'.$subdir;
325 $link =
"document.php?modulepart=banque&file=".str_replace(
'/',
'%2F', $subdir).
'%2F';
326 $modulepart =
"banque";
331 $upload_dir = $conf->loan->dir_output.
'/'.$subdir;
342 if (!empty($upload_dir)) {
345 $files =
dol_dir_list($upload_dir,
"files", 0,
'',
'(\.meta|_preview.*\.png)$',
'', SORT_ASC, 1);
348 if (count($files) < 1) {
350 $nofile[
'id'] = $objd->id;
351 $nofile[
'entity'] = $objd->entity;
352 $nofile[
'date'] = $db->jdate($objd->date);
353 $nofile[
'date_due'] = $db->jdate($objd->date_due);
354 $nofile[
'paid'] = $objd->paid;
355 $nofile[
'amount_ht'] = $objd->total_ht;
356 $nofile[
'amount_ttc'] = $objd->total_ttc;
357 $nofile[
'amount_vat'] = $objd->total_vat;
358 $nofile[
'ref'] = ($objd->ref ? $objd->ref : $objd->id);
359 $nofile[
'fk'] = $objd->fk_soc;
360 $nofile[
'item'] = $objd->item;
361 $nofile[
'thirdparty_name'] = $objd->thirdparty_name;
362 $nofile[
'thirdparty_code'] = $objd->thirdparty_code;
363 $nofile[
'country_code'] = $objd->country_code;
364 $nofile[
'vatnum'] = $objd->vatnum;
365 $nofile[
'sens'] = $objd->sens;
367 $filesarray[$nofile[
'item'].
'_'.$nofile[
'id']] = $nofile;
369 foreach ($files as $key => $file) {
370 $file[
'id'] = $objd->id;
371 $file[
'entity'] = $objd->entity;
372 $file[
'date'] = $db->jdate($objd->date);
373 $file[
'date_due'] = $db->jdate($objd->date_due);
374 $file[
'paid'] = $objd->paid;
375 $file[
'amount_ht'] = $objd->total_ht;
376 $file[
'amount_ttc'] = $objd->total_ttc;
377 $file[
'amount_vat'] = $objd->total_vat;
378 $file[
'ref'] = ($objd->ref ? $objd->ref : $objd->id);
379 $file[
'fk'] = $objd->fk_soc;
380 $file[
'item'] = $objd->item;
381 $file[
'thirdparty_name'] = $objd->thirdparty_name;
382 $file[
'thirdparty_code'] = $objd->thirdparty_code;
383 $file[
'country_code'] = $objd->country_code;
384 $file[
'vatnum'] = $objd->vatnum;
385 $file[
'sens'] = $objd->sens;
388 if (empty($filesarray[$file[
'item'].
'_'.$file[
'id']])) {
389 $filesarray[$file[
'item'].
'_'.$file[
'id']] = $file;
393 if (empty($filesarray[$file[
'item'].
'_'.$file[
'id']][
'files'])) {
394 $filesarray[$file[
'item'].
'_'.$file[
'id']][
'files'] = array();
396 $filesarray[$file[
'item'].
'_'.$file[
'id']][
'files'][] = array(
397 'link' => $link.urlencode($file[
'name']),
398 'name'=>$file[
'name'],
400 'fullname' => $file[
'fullname'],
401 'relpath' =>
'/'.$file[
'name'],
402 'relpathnamelang' => $langs->trans($file[
'item']).
'/'.$file[
'name'],
403 'modulepart' => $modulepart,
431 $dirfortmpfile = ($conf->accounting->dir_temp ? $conf->accounting->dir_temp : $conf->comptabilite->dir_temp);
432 if (empty($dirfortmpfile)) {
433 setEventMessages($langs->trans(
"ErrorNoAccountingModuleEnabled"), null,
'errors');
438 if ($result && $action ==
"dl" && !$error) {
439 if (!extension_loaded(
'zip')) {
446 $log = $langs->transnoentitiesnoconv(
"Type");
448 $log .=
','.$langs->transnoentitiesnoconv(
"Entity");
450 $log .=
','.$langs->transnoentitiesnoconv(
"Date");
451 $log .=
','.$langs->transnoentitiesnoconv(
"DateDue");
452 $log .=
','.$langs->transnoentitiesnoconv(
"Ref");
453 $log .=
','.$langs->transnoentitiesnoconv(
"TotalHT");
454 $log .=
','.$langs->transnoentitiesnoconv(
"TotalTTC");
455 $log .=
','.$langs->transnoentitiesnoconv(
"TotalVAT");
456 $log .=
','.$langs->transnoentitiesnoconv(
"Paid");
457 $log .=
','.$langs->transnoentitiesnoconv(
"Document");
458 $log .=
','.$langs->transnoentitiesnoconv(
"ItemID");
459 $log .=
','.$langs->transnoentitiesnoconv(
"ThirdParty");
460 $log .=
','.$langs->transnoentitiesnoconv(
"Code");
461 $log .=
','.$langs->transnoentitiesnoconv(
"Country");
462 $log .=
','.$langs->transnoentitiesnoconv(
"VATIntra");
463 $log .=
','.$langs->transnoentitiesnoconv(
"Sens").
"\n";
464 $zipname = $dirfortmpfile.
'/'.
dol_print_date($date_start,
'dayrfc',
'tzuserrel').
"-".
dol_print_date($date_stop,
'dayrfc',
'tzuserrel').
'_export.zip';
468 $zip =
new ZipArchive;
469 $res = $zip->open($zipname, ZipArchive::OVERWRITE | ZipArchive::CREATE);
471 foreach ($filesarray as $key => $file) {
472 if (!empty($file[
'files'])) {
473 foreach ($file[
'files'] as $filecursor) {
474 if (file_exists($filecursor[
"fullname"])) {
475 $zip->addFile($filecursor[
"fullname"], $filecursor[
"relpathnamelang"]);
480 $log .=
'"'.$langs->trans($file[
'item']).
'"';
482 $log .=
',"'.(empty($arrayofentities[$file[
'entity']]) ? $file[
'entity'] : $arrayofentities[$file[
'entity']]).
'"';
484 $log .=
','.dol_print_date($file[
'date'],
'dayrfc');
485 $log .=
','.dol_print_date($file[
'date_due'],
'dayrfc');
486 $log .=
',"'.$file[
'ref'].
'"';
487 $log .=
','.$file[
'amount_ht'];
488 $log .=
','.$file[
'amount_ttc'];
489 $log .=
','.$file[
'amount_vat'];
490 $log .=
','.$file[
'paid'];
491 $log .=
',"'.$file[
"name"].
'"';
492 $log .=
','.$file[
'fk'];
493 $log .=
',"'.$file[
'thirdparty_name'].
'"';
494 $log .=
',"'.$file[
'thirdparty_code'].
'"';
495 $log .=
',"'.$file[
'country_code'].
'"';
496 $log .=
',"'.$file[
'vatnum'].
'"';
497 $log .=
',"'.$file[
'sens'].
'"';
500 $zip->addFromString(
'transactions.csv', $log);
504 header(
'Content-Type: application/zip');
505 header(
'Content-disposition: attachment; filename='.basename($zipname));
506 header(
'Content-Length: '.filesize($zipname));
513 setEventMessages($langs->trans(
"FailedToOpenFile", $zipname), null,
'errors');
522 $form =
new form($db);
524 $userstatic =
new User($db);
534 $title = $langs->trans(
"ComptaFiles").
' - '.$langs->trans(
"List");
541 $head[$h][0] = $_SERVER[
"PHP_SELF"];
542 $head[$h][1] = $langs->trans(
"AccountantFiles");
543 $head[$h][2] =
'AccountancyFiles';
548 print
'<form name="searchfiles" action="?action=searchfiles" method="POST">'.
"\n";
549 print
'<input type="hidden" name="token" value="'.newToken().
'">';
551 print
'<span class="opacitymedium">'.$langs->trans(
"ExportAccountingSourceDocHelp");
553 print
' '.$langs->trans(
"ExportAccountingSourceDocHelp2", $langs->transnoentitiesnoconv(
"Accounting"), $langs->transnoentitiesnoconv(
"Journals"));
558 print $langs->trans(
"ReportPeriod").
': ';
559 print
$form->selectDate($date_start,
'date_start', 0, 0, 0,
"", 1, 1, 0,
'',
'',
'',
'', 1,
'',
'',
'tzuserrel');
561 print
$form->selectDate($date_stop,
'date_stop', 0, 0, 0,
"", 1, 1, 0,
'',
'',
'',
'', 1,
'',
'',
'tzuserrel');
566 $mc->getInfo($conf->entity);
567 print
'<span class="marginleftonly marginrightonly'.(empty($conf->global->MULTICOMPANY_ALLOW_EXPORT_ACCOUNTING_DOC_FOR_ALL_ENTITIES) ?
' opacitymedium' :
'').
'">('.$langs->trans(
"Entity").
' : ';
569 if (!empty($conf->global->MULTICOMPANY_ALLOW_EXPORT_ACCOUNTING_DOC_FOR_ALL_ENTITIES)) {
570 print $mc->select_entities(
GETPOSTISSET(
'search_entity') ?
GETPOST(
'search_entity',
'int') : $mc->id,
'search_entity',
'',
false,
false,
false,
false,
true);
580 foreach ($listofchoices as $choice => $val) {
581 if (empty($val[
'enabled'])) {
585 if (empty($val[
'perms'])) {
586 $disabled =
' disabled';
588 $checked = (((!
GETPOSTISSET(
'search') && $action !=
'searchfiles') ||
GETPOST($choice)) ?
' checked="checked"' :
'');
589 print
'<div class="paddingleft inline-block marginrightonly"><input type="checkbox" id="'.$choice.
'" name="'.$choice.
'" value="1"'.$checked.$disabled.
'> <label for="'.$choice.
'">'.$langs->trans($val[
'label']).
'</label></div>';
592 print
'<input type="submit" class="button small" name="search" value="'.$langs->trans(
"Search").
'">';
594 print
'</form>'.
"\n";
599 if (!empty($date_start) && !empty($date_stop)) {
600 $param .=
'&date_startday='.GETPOST(
'date_startday',
'int');
601 $param .=
'&date_startmonth='.GETPOST(
'date_startmonth',
'int');
602 $param .=
'&date_startyear='.GETPOST(
'date_startyear',
'int');
603 $param .=
'&date_stopday='.GETPOST(
'date_stopday',
'int');
604 $param .=
'&date_stopmonth='.GETPOST(
'date_stopmonth',
'int');
605 $param .=
'&date_stopyear='.GETPOST(
'date_stopyear',
'int');
606 foreach ($listofchoices as $choice => $val) {
608 $param .=
'&'.$choice.
'=1';
619 print
'<a class="marginleftonly small'.(empty($TData) ?
' butActionRefused' :
' butAction').
'" href="'.$_SERVER[
"PHP_SELF"].
'?action=dl&token='.
currentToken().
'&output=file&file='.urlencode($filename).$param.
'"';
624 print $langs->trans(
"Download");
627 $param .=
'&action=searchfiles';
651 print
'<div class="div-table-responsive">';
652 print
'<table class="noborder centpercent">';
653 print
'<tr class="liste_titre">';
654 print_liste_field_titre($arrayfields[
'type'][
'label'], $_SERVER[
"PHP_SELF"],
"item",
"", $param,
'', $sortfield, $sortorder,
'nowrap ');
655 print_liste_field_titre($arrayfields[
'date'][
'label'], $_SERVER[
"PHP_SELF"],
"date",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
656 print_liste_field_titre($arrayfields[
'date_due'][
'label'], $_SERVER[
"PHP_SELF"],
"date_due",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
657 print_liste_field_titre($arrayfields[
'ref'][
'label'], $_SERVER[
"PHP_SELF"],
"",
"", $param,
'', $sortfield, $sortorder,
'nowraponall ');
658 print
'<td>'.$langs->trans(
"Document").
'</td>';
659 print
'<td>'.$langs->trans(
"Paid").
'</td>';
660 print
'<td align="right">'.$langs->trans(
"TotalHT").(isModEnabled(
'multicurrency') ?
' ('.$conf->currency.
')' :
'').
'</td>';
661 print
'<td align="right">'.$langs->trans(
"TotalTTC").(isModEnabled(
'multicurrency') ?
' ('.$conf->currency.
')' :
'').
'</td>';
662 print
'<td align="right">'.$langs->trans(
"TotalVAT").(isModEnabled(
'multicurrency') ?
' ('.$conf->currency.
')' :
'').
'</td>';
663 print
'<td>'.$langs->trans(
"ThirdParty").
'</td>';
664 print
'<td class="center">'.$langs->trans(
"Code").
'</td>';
665 print
'<td class="center">'.$langs->trans(
"Country").
'</td>';
666 print
'<td class="center">'.$langs->trans(
"VATIntra").
'</td>';
668 print
'<td class="center">'.$langs->trans(
"Currency").
'</td>';
673 print
'<tr class="oddeven"><td colspan="13"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td>';
686 $totalVAT_credit = 0;
689 foreach ($TData as $data) {
693 print
'<tr class="oddeven '.$html_class.
'">';
696 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($langs->trans($data[
'item'])).
'">'.$langs->trans($data[
'item']).
'</td>';
699 print
'<td class="center">';
704 print
'<td class="center">';
709 print
'<td class="nowraponall tdoverflowmax150">';
711 if ($data[
'item'] ==
'Invoice') {
712 $invoice->id = $data[
'id'];
713 $invoice->ref = $data[
'ref'];
714 $invoice->total_ht = $data[
'amount_ht'];
715 $invoice->total_ttc = $data[
'amount_ttc'];
716 $invoice->total_tva = $data[
'amount_vat'];
717 $invoice->multicurrency_code = $data[
'currency'];
718 print $invoice->getNomUrl(1,
'', 0, 0,
'', 0, 0, 0);
719 } elseif ($data[
'item'] ==
'SupplierInvoice') {
720 $supplier_invoice->id = $data[
'id'];
721 $supplier_invoice->ref = $data[
'ref'];
722 $supplier_invoice->total_ht = $data[
'amount_ht'];
723 $supplier_invoice->total_ttc = $data[
'amount_ttc'];
724 $supplier_invoice->total_tva = $data[
'amount_vat'];
725 $supplier_invoice->multicurrency_code = $data[
'currency'];
726 print $supplier_invoice->getNomUrl(1,
'', 0, 0,
'', 0, 0, 0);
727 } elseif ($data[
'item'] ==
'ExpenseReport') {
728 $expensereport->id = $data[
'id'];
729 $expensereport->ref = $data[
'ref'];
730 print $expensereport->getNomUrl(1, 0, 0,
'', 0, 0);
731 } elseif ($data[
'item'] ==
'SalaryPayment') {
732 $salary_payment->id = $data[
'id'];
733 $salary_payment->ref = $data[
'ref'];
734 print $salary_payment->getNomUrl(1);
735 } elseif ($data[
'item'] ==
'Donation') {
736 $don->id = $data[
'id'];
737 $don->ref = $data[
'ref'];
738 print $don->getNomUrl(1, 0,
'', 0);
739 } elseif ($data[
'item'] ==
'SocialContributions') {
740 $charge_sociales->id = $data[
'id'];
741 $charge_sociales->ref = $data[
'ref'];
742 print $charge_sociales->getNomUrl(1, 0, 0, 0, 0);
743 } elseif ($data[
'item'] ==
'VariousPayment') {
744 $various_payment->id = $data[
'id'];
745 $various_payment->ref = $data[
'ref'];
746 print $various_payment->getNomUrl(1,
'', 0, 0);
747 } elseif ($data[
'item'] ==
'LoanPayment') {
748 $payment_loan->id = $data[
'id'];
749 $payment_loan->ref = $data[
'ref'];
750 print $payment_loan->getNomUrl(1, 0, 0,
'', 0);
757 print
'<td class="tdoverflowmax150">';
758 if (!empty($data[
'files'])) {
759 foreach ($data[
'files'] as $id => $filecursor) {
760 $tmppreview = $formfile->showPreview($filecursor, $filecursor[
'modulepart'], $filecursor[
'subdir'].
'/'.$filecursor[
'name'], 0);
764 $filename = ($filecursor[
'name'] ? $filecursor[
'name'] : $filecursor[
'ref']);
765 print
'<a href='.DOL_URL_ROOT.
'/'.$filecursor[
'link'].
' target="_blank" rel="noopener noreferrer" title="'.
dol_escape_htmltag($filename).
'">';
766 if (empty($tmppreview)) {
767 print
img_picto(
'',
'generic',
'',
false, 0, 0,
'',
'pictonopreview pictofixedwidth paddingright');
776 print
'<td class="center">'.($data[
'paid'] ?
yn($data[
'paid']) :
'').
'</td>';
779 print
'<td align="right"><span class="amount">'.price(
price2num($data[
'sens'] ? $data[
'amount_ht'] : -$data[
'amount_ht'],
'MT')).
"</span></td>\n";
781 print
'<td align="right"><span class="amount">'.price(
price2num($data[
'sens'] ? $data[
'amount_ttc'] : -$data[
'amount_ttc'],
'MT')).
"</span></td>\n";
783 print
'<td align="right"><span class="amount">'.price(
price2num($data[
'sens'] ? $data[
'amount_vat'] : -$data[
'amount_vat'],
'MT')).
"</span></td>\n";
785 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($data[
'thirdparty_name']).
'">'.
dol_escape_htmltag($data[
'thirdparty_name']).
"</td>\n";
787 print
'<td class="center">'.$data[
'thirdparty_code'].
"</td>\n";
789 print
'<td class="center">'.$data[
'country_code'].
"</td>\n";
792 print
'<td class="tdoverflowmax150 right" title="'.dol_escape_htmltag($data[
'vatnum']).
'">'.
dol_escape_htmltag($data[
'vatnum']).
"</td>\n";
795 $totalET_credit += $data[
'amount_ht'];
796 $totalIT_credit += $data[
'amount_ttc'];
797 $totalVAT_credit += $data[
'amount_vat'];
799 $totalET_debit -= $data[
'amount_ht'];
800 $totalIT_debit -= $data[
'amount_ttc'];
801 $totalVAT_debit -= $data[
'amount_vat'];
805 print
'<td class="center">'.$data[
'currency'].
"</td>\n";
812 print
'<tr class="liste_total">';
813 print
'<td colspan="6" class="right">'.$langs->trans(
'Total').
' '.$langs->trans(
'Income').
'</td>';
814 print
'<td align="right">'.price(
price2num($totalET_credit,
'MT')).
'</td>';
815 print
'<td align="right">'.price(
price2num($totalIT_credit,
'MT')).
'</td>';
816 print
'<td align="right">'.price(
price2num($totalVAT_credit,
'MT')).
'</td>';
817 print
'<td colspan="4"></td>';
823 print
'<tr class="liste_total">';
824 print
'<td colspan="6" class="right">'.$langs->trans(
'Total').
' '.$langs->trans(
'Outcome').
'</td>';
825 print
'<td align="right">'.price(
price2num($totalET_debit,
'MT')).
'</td>';
826 print
'<td align="right">'.price(
price2num($totalIT_debit,
'MT')).
'</td>';
827 print
'<td align="right">'.price(
price2num($totalVAT_debit,
'MT')).
'</td>';
828 print
'<td colspan="4"></td>';
834 print
'<tr class="liste_total">';
835 print
'<td colspan="6" class="right">'.$langs->trans(
'Total').
'</td>';
836 print
'<td align="right">'.price(
price2num($totalET_credit + $totalET_debit,
'MT')).
'</td>';
837 print
'<td align="right">'.price(
price2num($totalIT_credit + $totalIT_debit,
'MT')).
'</td>';
838 print
'<td align="right">'.price(
price2num($totalVAT_credit + $totalVAT_debit,
'MT')).
'</td>';
839 print
'<td colspan="4"></td>';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
if($cancel &&!$id) if($action== 'add'&&!$cancel) if($action== 'delete') if($id) $form
Actions.
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...
Class to manage various payments.
Class to manage payments of salaries.
dol_mkdir($dir, $dataroot= '', $newmask= '')
Creation of a directory (this can create recursive subdir)
Class to manage Dolibarr users.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage suppliers invoices.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save"&&empty($cancel)) $help_url
View.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form...
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
Class to manage payments of loans.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart= '')
Return a path to have a the directory according to object where files are stored. ...
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0)
Scan a directory and return a list of files/directories.
Class to manage Trips and Expenses.
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...
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
Class to manage donations.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
isModEnabled($module)
Is Dolibarr module enabled.
Class to manage invoices.
Classe permettant la gestion des paiements des charges La tva collectee n'est calculee que sur les fa...
currentToken()
Return the value of token currently saved into session with name 'token'.
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.