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');
36 require
'../main.inc.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
39 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
40 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
41 require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
42 require_once DOL_DOCUMENT_ROOT.
'/salaries/class/paymentsalary.class.php';
43 require_once DOL_DOCUMENT_ROOT.
'/compta/sociales/class/chargesociales.class.php';
44 require_once DOL_DOCUMENT_ROOT.
'/don/class/don.class.php';
45 require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/expensereport.class.php';
46 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
47 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
48 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/paymentvarious.class.php';
49 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
50 require_once DOL_DOCUMENT_ROOT.
'/loan/class/paymentloan.class.php';
53 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
54 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
61 $langs->loadLangs(array(
"accountancy",
"bills",
"companies",
"salaries",
"compta",
"trips",
"banks",
"loan"));
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);
77 $hookmanager->initHooks(array(
'comptafileslist',
'globallist'));
80 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
81 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
82 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
84 if (empty($page) || $page == -1) {
87 $offset = $limit * $page;
88 $pageprev = $page - 1;
89 $pagenext = $page + 1;
91 $sortfield =
"date,item";
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),
115 if ($user->socid > 0) {
120 $arrayofentities = array();
122 $arrayofentities = $mc->getEntitiesList();
127 if (empty($entity) && !empty($conf->global->MULTICOMPANY_ALLOW_EXPORT_ACCOUNTING_DOC_FOR_ALL_ENTITIES)) {
128 $entity =
'0,'.join(
',', array_keys($arrayofentities));
131 if (empty($entity)) {
132 $entity = $conf->entity;
137 $listofchoices = array(
138 'selectinvoices'=>array(
'label'=>
'Invoices',
'lang'=>
'bills',
'enabled' =>
isModEnabled(
'facture'),
'perms' => !empty($user->rights->facture->lire)),
139 'selectsupplierinvoices'=>array(
'label'=>
'BillsSuppliers',
'lang'=>
'bills',
'enabled' =>
isModEnabled(
'supplier_invoice'),
'perms' => !empty($user->rights->fournisseur->facture->lire)),
140 'selectexpensereports'=>array(
'label'=>
'ExpenseReports',
'lang'=>
'trips',
'enabled' =>
isModEnabled(
'expensereport'),
'perms' => !empty($user->rights->expensereport->lire)),
141 'selectdonations'=>array(
'label'=>
'Donations',
'lang'=>
'donation',
'enabled' =>
isModEnabled(
'don'),
'perms' => !empty($user->rights->don->lire)),
142 'selectsocialcontributions'=>array(
'label'=>
'SocialContributions',
'enabled' =>
isModEnabled(
'tax'),
'perms' => !empty($user->rights->tax->charges->lire)),
143 'selectpaymentsofsalaries'=>array(
'label'=>
'SalariesPayments',
'lang'=>
'salaries',
'enabled' =>
isModEnabled(
'salaries'),
'perms' => !empty($user->rights->salaries->read)),
144 'selectvariouspayment'=>array(
'label'=>
'VariousPayment',
'enabled' =>
isModEnabled(
'banque'),
'perms' => !empty($user->rights->banque->lire)),
145 'selectloanspayment'=>array(
'label'=>
'PaymentLoan',
'enabled' =>
isModEnabled(
'don'),
'perms' => !empty($user->rights->loan->read)),
159 $filesarray = array();
161 if (($action ==
'searchfiles' || $action ==
'dl')) {
162 if (empty($date_start)) {
163 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateStart")),
null,
'errors');
166 if (empty($date_stop)) {
167 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateEnd")),
null,
'errors');
174 $wheretail =
" '".$db->idate($date_start).
"' AND '".$db->idate($date_stop).
"'";
177 if (
GETPOST(
'selectinvoices') && !empty($listofchoices[
'selectinvoices'][
'perms'])) {
179 $sql .=
" UNION ALL";
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, 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";
182 $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";
183 $sql .=
" WHERE datef between ".$wheretail;
184 $sql .=
" AND t.entity IN (".$db->sanitize($entity == 1 ?
'0,1' : $entity).
')';
185 $sql .=
" AND t.fk_statut <> ".Facture::STATUS_DRAFT;
186 if (!empty($projectid)) $sql .=
" AND fk_projet = ".((int) $projectid);
189 if (
GETPOST(
'selectsupplierinvoices') && !empty($listofchoices[
'selectsupplierinvoices'][
'perms'])) {
191 $sql .=
" UNION ALL";
193 $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";
194 $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";
195 $sql .=
" WHERE datef between ".$wheretail;
196 $sql .=
" AND t.entity IN (".$db->sanitize($entity == 1 ?
'0,1' : $entity).
')';
197 $sql .=
" AND t.fk_statut <> ".FactureFournisseur::STATUS_DRAFT;
198 if (!empty($projectid)) $sql .=
" AND fk_projet = ".((
int) $projectid);
201 if (
GETPOST(
'selectexpensereports') && !empty($listofchoices[
'selectexpensereports'][
'perms']) && empty($projectid)) {
203 $sql .=
" UNION ALL";
205 $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";
206 $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";
207 $sql .=
" WHERE date_fin between ".$wheretail;
208 $sql .=
" AND t.entity IN (".$db->sanitize($entity == 1 ?
'0,1' : $entity).
')';
209 $sql .=
" AND t.fk_statut <> ".ExpenseReport::STATUS_DRAFT;
212 if (
GETPOST(
'selectdonations') && !empty($listofchoices[
'selectdonations'][
'perms'])) {
214 $sql .=
" UNION ALL";
216 $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";
217 $sql .=
" FROM ".MAIN_DB_PREFIX.
"don as t LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as c ON c.rowid = t.fk_country";
218 $sql .=
" WHERE datedon between ".$wheretail;
219 $sql .=
" AND t.entity IN (".$db->sanitize($entity == 1 ?
'0,1' : $entity).
')';
220 $sql .=
" AND t.fk_statut <> ".Don::STATUS_DRAFT;
221 if (!empty($projectid)) $sql .=
" AND fk_projet = ".((
int) $projectid);
224 if (
GETPOST(
'selectpaymentsofsalaries') && !empty($listofchoices[
'selectpaymentsofsalaries'][
'perms'])) {
226 $sql .=
" UNION ALL";
228 $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";
229 $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";
230 $sql .=
" WHERE datep between ".$wheretail;
231 $sql .=
" AND t.entity IN (".$db->sanitize($entity == 1 ?
'0,1' : $entity).
')';
233 if (!empty($projectid)) $sql .=
" AND fk_projet = ".((
int) $projectid);
236 if (
GETPOST(
'selectsocialcontributions') && !empty($listofchoices[
'selectsocialcontributions'][
'perms'])) {
238 $sql .=
" UNION ALL";
240 $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";
241 $sql .=
" FROM ".MAIN_DB_PREFIX.
"chargesociales as t";
242 $sql .=
" WHERE t.date_ech between ".$wheretail;
243 $sql .=
" AND t.entity IN (".$db->sanitize($entity == 1 ?
'0,1' : $entity).
')';
245 if (!empty($projectid)) $sql .=
" AND fk_projet = ".((
int) $projectid);
248 if (
GETPOST(
'selectvariouspayment') && !empty($listofchoices[
'selectvariouspayment'][
'perms'])) {
250 $sql .=
" UNION ALL";
252 $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";
253 $sql .=
" FROM ".MAIN_DB_PREFIX.
"payment_various as t";
254 $sql .=
" WHERE datep between ".$wheretail;
255 $sql .=
" AND t.entity IN (".$db->sanitize($entity == 1 ?
'0,1' : $entity).
')';
256 if (!empty($projectid)) $sql .=
" AND fk_projet = ".((
int) $projectid);
259 if (
GETPOST(
'selectloanspayment') && !empty($listofchoices[
'selectloanspayment'][
'perms']) && empty($projectid)) {
261 $sql .=
" UNION ALL";
263 $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";
264 $sql .=
" FROM ".MAIN_DB_PREFIX.
"payment_loan as t LEFT JOIN ".MAIN_DB_PREFIX.
"loan as l ON l.rowid = t.fk_loan";
265 $sql .=
" WHERE datep between ".$wheretail;
266 $sql .=
" AND l.entity IN (".$db->sanitize($entity == 1 ?
'0,1' : $entity).
')';
270 $sql .= $db->order($sortfield, $sortorder);
273 $resd = $db->query($sql);
278 $numd = $db->num_rows($resd);
280 $tmpinvoice =
new Facture($db);
282 $tmpdonation =
new Don($db);
287 $objd = $db->fetch_object($resd);
289 switch ($objd->item) {
293 $upload_dir = $conf->facture->dir_output.
'/'.$subdir;
294 $link =
"document.php?modulepart=facture&file=".str_replace(
'/',
'%2F', $subdir).
'%2F';
295 $modulepart =
"facture";
297 case "SupplierInvoice":
298 $tmpinvoicesupplier->fetch($objd->id);
299 $subdir =
get_exdir($tmpinvoicesupplier->id, 2, 0, 1, $tmpinvoicesupplier,
'invoice_supplier');
301 $upload_dir = $conf->fournisseur->facture->dir_output.
'/'.$subdir;
302 $link =
"document.php?modulepart=facture_fournisseur&file=".str_replace(
'/',
'%2F', $subdir).
'%2F';
303 $modulepart =
"facture_fournisseur";
305 case "ExpenseReport":
308 $upload_dir = $conf->expensereport->dir_output.
'/'.$subdir;
309 $link =
"document.php?modulepart=expensereport&file=".str_replace(
'/',
'%2F', $subdir).
'%2F';
310 $modulepart =
"expensereport";
312 case "SalaryPayment":
315 $upload_dir = $conf->salaries->dir_output.
'/'.$subdir;
316 $link =
"document.php?modulepart=salaries&file=".str_replace(
'/',
'%2F', $subdir).
'%2F';
317 $modulepart =
"salaries";
320 $tmpdonation->fetch($objp->id);
321 $subdir =
get_exdir(0, 0, 0, 0, $tmpdonation,
'donation');
323 $upload_dir = $conf->don->dir_output.
'/'.$subdir;
324 $link =
"document.php?modulepart=don&file=".str_replace(
'/',
'%2F', $subdir).
'%2F';
327 case "SocialContributions":
330 $upload_dir = $conf->tax->dir_output.
'/'.$subdir;
331 $link =
"document.php?modulepart=tax&file=".str_replace(
'/',
'%2F', $subdir).
'%2F';
334 case "VariousPayment":
337 $upload_dir = $conf->bank->dir_output.
'/'.$subdir;
338 $link =
"document.php?modulepart=banque&file=".str_replace(
'/',
'%2F', $subdir).
'%2F';
339 $modulepart =
"banque";
344 $upload_dir = $conf->loan->dir_output.
'/'.$subdir;
355 if (!empty($upload_dir)) {
358 $files =
dol_dir_list($upload_dir,
"files", 0,
'',
'(\.meta|_preview.*\.png)$',
'', SORT_ASC, 1);
361 if (count($files) < 1) {
363 $nofile[
'id'] = $objd->id;
364 $nofile[
'entity'] = $objd->entity;
365 $nofile[
'date'] = $db->jdate($objd->date);
366 $nofile[
'date_due'] = $db->jdate($objd->date_due);
367 $nofile[
'paid'] = $objd->paid;
368 $nofile[
'amount_ht'] = $objd->total_ht;
369 $nofile[
'amount_ttc'] = $objd->total_ttc;
370 $nofile[
'amount_vat'] = $objd->total_vat;
371 $nofile[
'ref'] = ($objd->ref ? $objd->ref : $objd->id);
372 $nofile[
'fk'] = $objd->fk_soc;
373 $nofile[
'item'] = $objd->item;
374 $nofile[
'thirdparty_name'] = $objd->thirdparty_name;
375 $nofile[
'thirdparty_code'] = $objd->thirdparty_code;
376 $nofile[
'country_code'] = $objd->country_code;
377 $nofile[
'vatnum'] = $objd->vatnum;
378 $nofile[
'sens'] = $objd->sens;
379 $nofile[
'currency'] = $objd->currency;
380 $nofile[
'link'] =
'';
381 $nofile[
'name'] =
'';
383 $filesarray[$nofile[
'item'].
'_'.$nofile[
'id']] = $nofile;
385 foreach ($files as $key => $file) {
386 $file[
'id'] = $objd->id;
387 $file[
'entity'] = $objd->entity;
388 $file[
'date'] = $db->jdate($objd->date);
389 $file[
'date_due'] = $db->jdate($objd->date_due);
390 $file[
'paid'] = $objd->paid;
391 $file[
'amount_ht'] = $objd->total_ht;
392 $file[
'amount_ttc'] = $objd->total_ttc;
393 $file[
'amount_vat'] = $objd->total_vat;
394 $file[
'ref'] = ($objd->ref ? $objd->ref : $objd->id);
395 $file[
'fk'] = $objd->fk_soc;
396 $file[
'item'] = $objd->item;
397 $file[
'thirdparty_name'] = $objd->thirdparty_name;
398 $file[
'thirdparty_code'] = $objd->thirdparty_code;
399 $file[
'country_code'] = $objd->country_code;
400 $file[
'vatnum'] = $objd->vatnum;
401 $file[
'sens'] = $objd->sens;
402 $file[
'currency'] = $objd->currency;
405 if (empty($filesarray[$file[
'item'].
'_'.$file[
'id']])) {
406 $filesarray[$file[
'item'].
'_'.$file[
'id']] = $file;
410 if (empty($filesarray[$file[
'item'].
'_'.$file[
'id']][
'files'])) {
411 $filesarray[$file[
'item'].
'_'.$file[
'id']][
'files'] = array();
413 $filesarray[$file[
'item'].
'_'.$file[
'id']][
'files'][] = array(
414 'link' => $link.urlencode($file[
'name']),
415 'name'=>$file[
'name'],
417 'fullname' => $file[
'fullname'],
418 'relpath' =>
'/'.$file[
'name'],
419 'relpathnamelang' => $langs->trans($file[
'item']).
'/'.$file[
'name'],
420 'modulepart' => $modulepart,
422 'currency' => $file[
'currency']
449 $dirfortmpfile = ($conf->accounting->dir_temp ? $conf->accounting->dir_temp : $conf->comptabilite->dir_temp);
450 if (empty($dirfortmpfile)) {
451 setEventMessages($langs->trans(
"ErrorNoAccountingModuleEnabled"),
null,
'errors');
456 if ($result && $action ==
"dl" && !$error) {
457 if (!extension_loaded(
'zip')) {
462 $log = $langs->transnoentitiesnoconv(
"Type");
464 $log .=
','.$langs->transnoentitiesnoconv(
"Entity");
466 $log .=
','.$langs->transnoentitiesnoconv(
"Date");
467 $log .=
','.$langs->transnoentitiesnoconv(
"DateDue");
468 $log .=
','.$langs->transnoentitiesnoconv(
"Ref");
469 $log .=
','.$langs->transnoentitiesnoconv(
"TotalHT");
470 $log .=
','.$langs->transnoentitiesnoconv(
"TotalTTC");
471 $log .=
','.$langs->transnoentitiesnoconv(
"TotalVAT");
472 $log .=
','.$langs->transnoentitiesnoconv(
"Paid");
473 $log .=
','.$langs->transnoentitiesnoconv(
"Document");
474 $log .=
','.$langs->transnoentitiesnoconv(
"ItemID");
475 $log .=
','.$langs->transnoentitiesnoconv(
"ThirdParty");
476 $log .=
','.$langs->transnoentitiesnoconv(
"Code");
477 $log .=
','.$langs->transnoentitiesnoconv(
"Country");
478 $log .=
','.$langs->transnoentitiesnoconv(
"VATIntra");
479 $log .=
','.$langs->transnoentitiesnoconv(
"Sens").
"\n";
481 if (!empty($projectid)) {
483 $project->fetch($projectid);
485 $zipname .=
'_'.$project->ref;
488 $zipname .=
'_export.zip';
492 $zip =
new ZipArchive;
493 $res = $zip->open($zipname, ZipArchive::OVERWRITE | ZipArchive::CREATE);
495 foreach ($filesarray as $key => $file) {
496 if (!empty($file[
'files'])) {
497 foreach ($file[
'files'] as $filecursor) {
498 if (file_exists($filecursor[
"fullname"])) {
499 $zip->addFile($filecursor[
"fullname"], $filecursor[
"relpathnamelang"]);
504 $log .=
'"'.$langs->trans($file[
'item']).
'"';
506 $log .=
',"'.(empty($arrayofentities[$file[
'entity']]) ? $file[
'entity'] : $arrayofentities[$file[
'entity']]).
'"';
508 $log .=
','.dol_print_date($file[
'date'],
'dayrfc');
509 $log .=
','.dol_print_date($file[
'date_due'],
'dayrfc');
510 $log .=
',"'.$file[
'ref'].
'"';
511 $log .=
','.$file[
'amount_ht'];
512 $log .=
','.$file[
'amount_ttc'];
513 $log .=
','.$file[
'amount_vat'];
514 $log .=
','.$file[
'paid'];
515 $log .=
',"'.$file[
"name"].
'"';
516 $log .=
','.$file[
'fk'];
517 $log .=
',"'.$file[
'thirdparty_name'].
'"';
518 $log .=
',"'.$file[
'thirdparty_code'].
'"';
519 $log .=
',"'.$file[
'country_code'].
'"';
520 $log .=
',"'.$file[
'vatnum'].
'"';
521 $log .=
',"'.$file[
'sens'].
'"';
524 $zip->addFromString(
'transactions.csv', $log);
528 header(
'Content-Type: application/zip');
529 header(
'Content-disposition: attachment; filename='.basename($zipname));
530 header(
'Content-Length: '.filesize($zipname));
537 setEventMessages($langs->trans(
"FailedToOpenFile", $zipname),
null,
'errors');
547 $form =
new form($db);
549 $userstatic =
new User($db);
559 $title = $langs->trans(
"ComptaFiles").
' - '.$langs->trans(
"List");
566 $head[$h][0] = $_SERVER[
"PHP_SELF"];
567 $head[$h][1] = $langs->trans(
"AccountantFiles");
568 $head[$h][2] =
'AccountancyFiles';
573 print
'<form name="searchfiles" action="?action=searchfiles" method="POST">'.
"\n";
574 print
'<input type="hidden" name="token" value="'.newToken().
'">';
576 print
'<span class="opacitymedium">'.$langs->trans(
"ExportAccountingSourceDocHelp");
578 print
' '.$langs->trans(
"ExportAccountingSourceDocHelp2", $langs->transnoentitiesnoconv(
"Accounting"), $langs->transnoentitiesnoconv(
"Journals"));
583 print $langs->trans(
"ReportPeriod").
': ';
584 print
$form->selectDate($date_start,
'date_start', 0, 0, 0,
"", 1, 1, 0,
'',
'',
'',
'', 1,
'',
'',
'tzuserrel');
586 print
$form->selectDate($date_stop,
'date_stop', 0, 0, 0,
"", 1, 1, 0,
'',
'',
'',
'', 1,
'',
'',
'tzuserrel');
592 $mc->getInfo($conf->entity);
593 print
'<span class="marginleftonly marginrightonly'.(empty($conf->global->MULTICOMPANY_ALLOW_EXPORT_ACCOUNTING_DOC_FOR_ALL_ENTITIES) ?
' opacitymedium' :
'').
'">('.$langs->trans(
"Entity").
' : ';
595 if (!empty($conf->global->MULTICOMPANY_ALLOW_EXPORT_ACCOUNTING_DOC_FOR_ALL_ENTITIES)) {
597 print $mc->select_entities(
GETPOSTISSET(
'search_entity') ?
GETPOST(
'search_entity',
'int') : $mc->id,
'search_entity',
'', false, false, false, false, true);
610 $langs->load(
'projects');
611 print
'<span class="marginrightonly">'.$langs->trans(
'Project').
":</span>";
612 print
img_picto(
'',
'project').$formproject->select_projects(($socid > 0 ? $socid : -1), $projectid,
'projectid', 0, 0, 1, 0, 0, 0, 0,
'', 1, 0,
'');
613 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>';
617 foreach ($listofchoices as $choice => $val) {
618 if (empty($val[
'enabled'])) {
622 if (empty($val[
'perms'])) {
623 $disabled =
' disabled';
625 $checked = (((!
GETPOSTISSET(
'search') && $action !=
'searchfiles') ||
GETPOST($choice)) ?
' checked="checked"' :
'');
626 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>';
629 print
'<input type="submit" class="button small" name="search" value="'.$langs->trans(
"Search").
'">';
631 print
'</form>'.
"\n";
636 if (!empty($date_start) && !empty($date_stop)) {
637 $param .=
'&date_startday='.GETPOST(
'date_startday',
'int');
638 $param .=
'&date_startmonth='.GETPOST(
'date_startmonth',
'int');
639 $param .=
'&date_startyear='.GETPOST(
'date_startyear',
'int');
640 $param .=
'&date_stopday='.GETPOST(
'date_stopday',
'int');
641 $param .=
'&date_stopmonth='.GETPOST(
'date_stopmonth',
'int');
642 $param .=
'&date_stopyear='.GETPOST(
'date_stopyear',
'int');
643 foreach ($listofchoices as $choice => $val) {
645 $param .=
'&'.$choice.
'=1';
656 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.
'"';
661 print $langs->trans(
"Download");
664 $param .=
'&action=searchfiles';
688 print
'<div class="div-table-responsive">';
689 print
'<table class="noborder centpercent">';
690 print
'<tr class="liste_titre">';
691 print_liste_field_titre($arrayfields[
'type'][
'label'], $_SERVER[
"PHP_SELF"],
"item",
"", $param,
'', $sortfield, $sortorder,
'nowrap ');
692 print_liste_field_titre($arrayfields[
'date'][
'label'], $_SERVER[
"PHP_SELF"],
"date",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
693 print_liste_field_titre($arrayfields[
'date_due'][
'label'], $_SERVER[
"PHP_SELF"],
"date_due",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
694 print_liste_field_titre($arrayfields[
'ref'][
'label'], $_SERVER[
"PHP_SELF"],
"",
"", $param,
'', $sortfield, $sortorder,
'nowraponall ');
695 print
'<td>'.$langs->trans(
"Document").
'</td>';
696 print
'<td>'.$langs->trans(
"Paid").
'</td>';
697 print
'<td align="right">'.$langs->trans(
"TotalHT").(isModEnabled(
'multicurrency') ?
' ('.$conf->currency.
')' :
'').
'</td>';
698 print
'<td align="right">'.$langs->trans(
"TotalTTC").(isModEnabled(
'multicurrency') ?
' ('.$conf->currency.
')' :
'').
'</td>';
699 print
'<td align="right">'.$langs->trans(
"TotalVAT").(isModEnabled(
'multicurrency') ?
' ('.$conf->currency.
')' :
'').
'</td>';
700 print
'<td>'.$langs->trans(
"ThirdParty").
'</td>';
701 print
'<td class="center">'.$langs->trans(
"Code").
'</td>';
702 print
'<td class="center">'.$langs->trans(
"Country").
'</td>';
703 print
'<td class="center">'.$langs->trans(
"VATIntra").
'</td>';
705 print
'<td class="center">'.$langs->trans(
"Currency").
'</td>';
710 print
'<tr class="oddeven"><td colspan="13"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td>';
723 $totalVAT_credit = 0;
726 foreach ($TData as $data) {
730 print
'<tr class="oddeven '.$html_class.
'">';
733 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($langs->trans($data[
'item'])).
'">'.$langs->trans($data[
'item']).
'</td>';
736 print
'<td class="center">';
741 print
'<td class="center">';
746 print
'<td class="nowraponall tdoverflowmax150">';
748 if ($data[
'item'] ==
'Invoice') {
749 $invoice->id = $data[
'id'];
750 $invoice->ref = $data[
'ref'];
751 $invoice->total_ht = $data[
'amount_ht'];
752 $invoice->total_ttc = $data[
'amount_ttc'];
753 $invoice->total_tva = $data[
'amount_vat'];
754 $invoice->multicurrency_code = $data[
'currency'];
755 print $invoice->getNomUrl(1,
'', 0, 0,
'', 0, 0, 0);
756 } elseif ($data[
'item'] ==
'SupplierInvoice') {
757 $supplier_invoice->id = $data[
'id'];
758 $supplier_invoice->ref = $data[
'ref'];
759 $supplier_invoice->total_ht = $data[
'amount_ht'];
760 $supplier_invoice->total_ttc = $data[
'amount_ttc'];
761 $supplier_invoice->total_tva = $data[
'amount_vat'];
762 $supplier_invoice->multicurrency_code = $data[
'currency'];
763 print $supplier_invoice->getNomUrl(1,
'', 0, 0,
'', 0, 0, 0);
764 } elseif ($data[
'item'] ==
'ExpenseReport') {
765 $expensereport->id = $data[
'id'];
766 $expensereport->ref = $data[
'ref'];
767 print $expensereport->getNomUrl(1, 0, 0,
'', 0, 0);
768 } elseif ($data[
'item'] ==
'SalaryPayment') {
769 $salary_payment->id = $data[
'id'];
770 $salary_payment->ref = $data[
'ref'];
771 print $salary_payment->getNomUrl(1);
772 } elseif ($data[
'item'] ==
'Donation') {
773 $don->id = $data[
'id'];
774 $don->ref = $data[
'ref'];
775 print $don->getNomUrl(1, 0,
'', 0);
776 } elseif ($data[
'item'] ==
'SocialContributions') {
777 $charge_sociales->id = $data[
'id'];
778 $charge_sociales->ref = $data[
'ref'];
779 print $charge_sociales->getNomUrl(1, 0, 0, 0, 0);
780 } elseif ($data[
'item'] ==
'VariousPayment') {
781 $various_payment->id = $data[
'id'];
782 $various_payment->ref = $data[
'ref'];
783 print $various_payment->getNomUrl(1,
'', 0, 0);
784 } elseif ($data[
'item'] ==
'LoanPayment') {
785 $payment_loan->id = $data[
'id'];
786 $payment_loan->ref = $data[
'ref'];
787 print $payment_loan->getNomUrl(1, 0, 0,
'', 0);
794 print
'<td class="tdoverflowmax150">';
795 if (!empty($data[
'files'])) {
796 foreach ($data[
'files'] as $id => $filecursor) {
797 $tmppreview = $formfile->showPreview($filecursor, $filecursor[
'modulepart'], $filecursor[
'subdir'].
'/'.$filecursor[
'name'], 0);
801 $filename = ($filecursor[
'name'] ? $filecursor[
'name'] : $filecursor[
'ref']);
802 print
'<a href='.DOL_URL_ROOT.
'/'.$filecursor[
'link'].
' target="_blank" rel="noopener noreferrer" title="'.
dol_escape_htmltag($filename).
'">';
803 if (empty($tmppreview)) {
804 print
img_picto(
'',
'generic',
'',
false, 0, 0,
'',
'pictonopreview pictofixedwidth paddingright');
813 print
'<td class="center">'.($data[
'paid'] ?
yn($data[
'paid']) :
'').
'</td>';
816 print
'<td align="right"><span class="amount">'.price(
price2num($data[
'sens'] ? $data[
'amount_ht'] : -$data[
'amount_ht'],
'MT')).
"</span></td>\n";
818 print
'<td align="right"><span class="amount">'.price(
price2num($data[
'sens'] ? $data[
'amount_ttc'] : -$data[
'amount_ttc'],
'MT')).
"</span></td>\n";
820 print
'<td align="right"><span class="amount">'.price(
price2num($data[
'sens'] ? $data[
'amount_vat'] : -$data[
'amount_vat'],
'MT')).
"</span></td>\n";
822 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($data[
'thirdparty_name']).
'">'.
dol_escape_htmltag($data[
'thirdparty_name']).
"</td>\n";
824 print
'<td class="center">'.$data[
'thirdparty_code'].
"</td>\n";
826 print
'<td class="center">'.$data[
'country_code'].
"</td>\n";
829 print
'<td class="tdoverflowmax150 right" title="'.dol_escape_htmltag($data[
'vatnum']).
'">'.
dol_escape_htmltag($data[
'vatnum']).
"</td>\n";
832 $totalET_credit += $data[
'amount_ht'];
833 $totalIT_credit += $data[
'amount_ttc'];
834 $totalVAT_credit += $data[
'amount_vat'];
836 $totalET_debit -= $data[
'amount_ht'];
837 $totalIT_debit -= $data[
'amount_ttc'];
838 $totalVAT_debit -= $data[
'amount_vat'];
842 print
'<td class="center">'.$data[
'currency'].
"</td>\n";
849 print
'<tr class="liste_total">';
850 print
'<td colspan="6" class="right">'.$langs->trans(
'Total').
' '.$langs->trans(
'Income').
'</td>';
851 print
'<td align="right">'.price(
price2num($totalET_credit,
'MT')).
'</td>';
852 print
'<td align="right">'.price(
price2num($totalIT_credit,
'MT')).
'</td>';
853 print
'<td align="right">'.price(
price2num($totalVAT_credit,
'MT')).
'</td>';
854 print
'<td colspan="4"></td>';
860 print
'<tr class="liste_total">';
861 print
'<td colspan="6" class="right">'.$langs->trans(
'Total').
' '.$langs->trans(
'Outcome').
'</td>';
862 print
'<td align="right">'.price(
price2num($totalET_debit,
'MT')).
'</td>';
863 print
'<td align="right">'.price(
price2num($totalIT_debit,
'MT')).
'</td>';
864 print
'<td align="right">'.price(
price2num($totalVAT_debit,
'MT')).
'</td>';
865 print
'<td colspan="4"></td>';
871 print
'<tr class="liste_total">';
872 print
'<td colspan="6" class="right">'.$langs->trans(
'Total').
'</td>';
873 print
'<td align="right">'.price(
price2num($totalET_credit + $totalET_debit,
'MT')).
'</td>';
874 print
'<td align="right">'.price(
price2num($totalIT_credit + $totalIT_debit,
'MT')).
'</td>';
875 print
'<td align="right">'.price(
price2num($totalVAT_credit + $totalVAT_debit,
'MT')).
'</td>';
876 print
'<td colspan="4"></td>';
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.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Classe permettant la gestion des paiements des charges La tva collectee n'est calculee que sur les fa...
Class to manage donations.
Class to manage Trips and Expenses.
Class to manage suppliers invoices.
Class to manage invoices.
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.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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.
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...
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
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.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
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.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isModEnabled($module)
Is Dolibarr module enabled.
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)
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.