27 if ((array_key_exists(
'action', $_GET) && $_GET[
'action'] ==
'dl') || (array_key_exists(
'action', $_POST) && $_POST[
'action'] ==
'dl')) {
28 if (!defined(
'NOTOKENRENEWAL')) define(
'NOTOKENRENEWAL',
'1');
31 require
'../main.inc.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
34 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/salaries/class/paymentsalary.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/compta/sociales/class/chargesociales.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/don/class/don.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/expensereport.class.php';
40 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
41 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
42 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/paymentvarious.class.php';
43 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
44 require_once DOL_DOCUMENT_ROOT.
'/loan/class/paymentloan.class.php';
50 $langs->loadLangs(array(
"accountancy",
"bills",
"companies",
"salaries",
"compta",
"trips",
"banks",
"loan"));
52 $date_start =
GETPOST(
'date_start',
'alpha');
53 $date_startDay =
GETPOST(
'date_startday',
'int');
54 $date_startMonth =
GETPOST(
'date_startmonth',
'int');
55 $date_startYear =
GETPOST(
'date_startyear',
'int');
56 $date_start = ($date_startDay) ?
dol_mktime(0, 0, 0, $date_startMonth, $date_startDay, $date_startYear) : strtotime($date_start);
57 $date_stop =
GETPOST(
'date_stop',
'alpha');
58 $date_stopDay =
GETPOST(
'date_stopday',
'int');
59 $date_stopMonth =
GETPOST(
'date_stopmonth',
'int');
60 $date_stopYear =
GETPOST(
'date_stopyear',
'int');
62 $date_stop = ($date_stopDay) ?
dol_mktime(23, 59, 59, $date_stopMonth, $date_stopDay, $date_stopYear) : strtotime($date_stop);
63 $action =
GETPOST(
'action',
'aZ09');
66 $hookmanager->initHooks(array(
'comptafileslist',
'globallist'));
69 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
70 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
71 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
73 if (empty($page) || $page == -1) { $page = 0; }
74 $offset = $limit * $page;
75 $pageprev = $page - 1;
76 $pagenext = $page + 1;
77 if (!$sortfield) $sortfield =
"date,item";
78 if (!$sortorder) $sortorder =
"DESC";
82 'type'=>array(
'label'=>
"Type",
'checked'=>1),
83 'date'=>array(
'label'=>
"Date",
'checked'=>1),
84 'date_due'=>array(
'label'=>
"DateDue",
'checked'=>1),
85 'ref'=>array(
'label'=>
"Ref",
'checked'=>1),
86 'documents'=>array(
'label'=>
"Documents",
'checked'=>1),
87 'paid'=>array(
'label'=>
"Paid",
'checked'=>1),
88 'total_ht'=>array(
'label'=>
"TotalHT",
'checked'=>1),
89 'total_ttc'=>array(
'label'=>
"TotalTTC",
'checked'=>1),
90 'total_vat'=>array(
'label'=>
"TotalVAT",
'checked'=>1),
95 if (empty($conf->comptabilite->enabled) && empty($conf->accounting->enabled)) {
98 if ($user->socid > 0) {
103 $arrayofentities = array();
104 if (!empty($conf->multicompany->enabled) && is_object($mc)) {
105 $arrayofentities = $mc->getEntitiesList();
109 if (!empty($conf->multicompany->enabled) && is_object($mc)) {
110 if (empty($entity) && !empty($conf->global->MULTICOMPANY_ALLOW_EXPORT_ACCOUNTING_DOC_FOR_ALL_ENTITIES)) {
111 $entity =
'0,'.join(
',', array_keys($arrayofentities));
114 if (empty($entity)) $entity = $conf->entity;
129 $filesarray = array();
131 if (($action ==
'searchfiles' || $action ==
'dl')) {
132 if (empty($date_start))
134 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateStart")), null,
'errors');
137 if (empty($date_stop))
139 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateEnd")), null,
'errors');
147 $wheretail =
" '".$db->idate($date_start).
"' AND '".$db->idate($date_stop).
"'";
150 if (
GETPOST(
'selectinvoices')) {
151 if (!empty($sql)) $sql .=
" UNION ALL";
152 $sql .=
"SELECT t.rowid as id, t.entity, t.ref, t.paye as paid, t.total as total_ht, t.total_ttc, t.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";
153 $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";
154 $sql .=
" WHERE datef between ".$wheretail;
155 $sql .=
" AND t.entity IN (".($entity == 1 ?
'0,1' : $entity).
')';
156 $sql .=
" AND t.fk_statut <> ".Facture::STATUS_DRAFT;
159 if (
GETPOST(
'selectsupplierinvoices')) {
160 if (!empty($sql)) $sql .=
" UNION ALL";
161 $sql .=
" SELECT t.rowid as id, t.entity, t.ref, t.paye as paid, t.total_ht, t.total_ttc, t.total_tva as total_vat, t.multicurrency_code as currency, t.fk_soc, t.datef as date, t.date_lim_reglement as date_due, 'SupplierInvoice' as item, s.nom as thirdparty_name, s.code_fournisseur as thirdparty_code, c.code as country_code, s.tva_intra as vatnum, ".PAY_DEBIT.
" as sens";
162 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture_fourn as t LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid = t.fk_soc LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as c ON c.rowid = s.fk_pays";
163 $sql .=
" WHERE datef between ".$wheretail;
164 $sql .=
" AND t.entity IN (".($entity == 1 ?
'0,1' : $entity).
')';
165 $sql .=
" AND t.fk_statut <> ".FactureFournisseur::STATUS_DRAFT;
168 if (
GETPOST(
'selectexpensereports')) {
169 if (!empty($sql)) $sql .=
" UNION ALL";
170 $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";
171 $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";
172 $sql .=
" WHERE date_fin between ".$wheretail;
173 $sql .=
" AND t.entity IN (".($entity == 1 ?
'0,1' : $entity).
')';
174 $sql .=
" AND t.fk_statut <> ".ExpenseReport::STATUS_DRAFT;
177 if (
GETPOST(
'selectdonations')) {
178 if (!empty($sql)) $sql .=
" UNION ALL";
179 $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";
180 $sql .=
" FROM ".MAIN_DB_PREFIX.
"don as t LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as c ON c.rowid = t.fk_country";
181 $sql .=
" WHERE datedon between ".$wheretail;
182 $sql .=
" AND t.entity IN (".($entity == 1 ?
'0,1' : $entity).
')';
183 $sql .=
" AND t.fk_statut <> ".Don::STATUS_DRAFT;
186 if (
GETPOST(
'selectpaymentsofsalaries')) {
187 if (!empty($sql)) $sql .=
" UNION ALL";
188 $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";
189 $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";
190 $sql .=
" WHERE datep between ".$wheretail;
191 $sql .=
" AND t.entity IN (".($entity == 1 ?
'0,1' : $entity).
')';
195 if (
GETPOST(
'selectsocialcontributions')) {
196 if (!empty($sql)) $sql .=
" UNION ALL";
197 $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";
198 $sql .=
" FROM ".MAIN_DB_PREFIX.
"chargesociales as t";
199 $sql .=
" WHERE t.date_ech between ".$wheretail;
200 $sql .=
" AND t.entity IN (".($entity == 1 ?
'0,1' : $entity).
')';
204 if (
GETPOST(
'selectvariouspayment')) {
205 if (!empty($sql)) $sql .=
" UNION ALL";
206 $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";
207 $sql .=
" FROM ".MAIN_DB_PREFIX.
"payment_various as t";
208 $sql .=
" WHERE datep between ".$wheretail;
209 $sql .=
" AND t.entity IN (".($entity == 1 ?
'0,1' : $entity).
')';
212 if (
GETPOST(
'selectloanspayment')) {
213 if (!empty($sql)) $sql .=
" UNION ALL";
214 $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";
215 $sql .=
" FROM ".MAIN_DB_PREFIX.
"payment_loan as t LEFT JOIN ".MAIN_DB_PREFIX.
"loan as l ON l.rowid = t.fk_loan";
216 $sql .=
" WHERE datep between ".$wheretail;
217 $sql .=
" AND l.entity IN (".($entity == 1 ?
'0,1' : $entity).
')';
221 $sql .= $db->order($sortfield, $sortorder);
224 $resd = $db->query($sql);
230 $numd = $db->num_rows($resd);
232 $tmpinvoice =
new Facture($db);
234 $tmpdonation =
new Don($db);
240 $objd = $db->fetch_object($resd);
247 $upload_dir = $conf->facture->dir_output.
'/'.$subdir;
248 $link =
"document.php?modulepart=facture&file=".str_replace(
'/',
'%2F', $subdir).
'%2F';
249 $modulepart =
"facture";
251 case "SupplierInvoice":
252 $tmpinvoicesupplier->fetch($objd->id);
253 $subdir =
get_exdir($tmpinvoicesupplier->id, 2, 0, 1, $tmpinvoicesupplier,
'invoice_supplier');
255 $upload_dir = $conf->fournisseur->facture->dir_output.
'/'.$subdir;
256 $link =
"document.php?modulepart=facture_fournisseur&file=".str_replace(
'/',
'%2F', $subdir).
'%2F';
257 $modulepart =
"facture_fournisseur";
259 case "ExpenseReport":
262 $upload_dir = $conf->expensereport->dir_output.
'/'.$subdir;
263 $link =
"document.php?modulepart=expensereport&file=".str_replace(
'/',
'%2F', $subdir).
'%2F';
264 $modulepart =
"expensereport";
266 case "SalaryPayment":
269 $upload_dir = $conf->salaries->dir_output.
'/'.$subdir;
270 $link =
"document.php?modulepart=salaries&file=".str_replace(
'/',
'%2F', $subdir).
'%2F';
271 $modulepart =
"salaries";
274 $tmpdonation->fetch($objp->id);
275 $subdir =
get_exdir(0, 0, 0, 0, $tmpdonation,
'donation');
277 $upload_dir = $conf->don->dir_output.
'/'.$subdir;
278 $link =
"document.php?modulepart=don&file=".str_replace(
'/',
'%2F', $subdir).
'%2F';
281 case "SocialContributions":
284 $upload_dir = $conf->tax->dir_output.
'/'.$subdir;
285 $link =
"document.php?modulepart=tax&file=".str_replace(
'/',
'%2F', $subdir).
'%2F';
288 case "VariousPayment":
291 $upload_dir = $conf->bank->dir_output.
'/'.$subdir;
292 $link =
"document.php?modulepart=banque&file=".str_replace(
'/',
'%2F', $subdir).
'%2F';
293 $modulepart =
"banque";
298 $upload_dir = $conf->loan->dir_output.
'/'.$subdir;
309 if (!empty($upload_dir))
313 $files =
dol_dir_list($upload_dir,
"files", 0,
'',
'(\.meta|_preview.*\.png)$',
'', SORT_ASC, 1);
316 if (count($files) < 1)
319 $nofile[
'id'] = $objd->id;
320 $nofile[
'entity'] = $objd->entity;
321 $nofile[
'date'] = $db->idate($objd->date);
322 $nofile[
'date_due'] = $db->idate($objd->date_due);
323 $nofile[
'paid'] = $objd->paid;
324 $nofile[
'amount_ht'] = $objd->total_ht;
325 $nofile[
'amount_ttc'] = $objd->total_ttc;
326 $nofile[
'amount_vat'] = $objd->total_vat;
327 $nofile[
'ref'] = ($objd->ref ? $objd->ref : $objd->id);
328 $nofile[
'fk'] = $objd->fk_soc;
329 $nofile[
'item'] = $objd->item;
330 $nofile[
'thirdparty_name'] = $objd->thirdparty_name;
331 $nofile[
'thirdparty_code'] = $objd->thirdparty_code;
332 $nofile[
'country_code'] = $objd->country_code;
333 $nofile[
'vatnum'] = $objd->vatnum;
334 $nofile[
'sens'] = $objd->sens;
336 $filesarray[$nofile[
'item'].
'_'.$nofile[
'id']] = $nofile;
338 foreach ($files as $key => $file)
340 $file[
'id'] = $objd->id;
341 $file[
'entity'] = $objd->entity;
342 $file[
'date'] = $db->idate($objd->date);
343 $file[
'date_due'] = $db->idate($objd->date_due);
344 $file[
'paid'] = $objd->paid;
345 $file[
'amount_ht'] = $objd->total_ht;
346 $file[
'amount_ttc'] = $objd->total_ttc;
347 $file[
'amount_vat'] = $objd->total_vat;
348 $file[
'ref'] = ($objd->ref ? $objd->ref : $objd->id);
349 $file[
'fk'] = $objd->fk_soc;
350 $file[
'item'] = $objd->item;
351 $file[
'thirdparty_name'] = $objd->thirdparty_name;
352 $file[
'thirdparty_code'] = $objd->thirdparty_code;
353 $file[
'country_code'] = $objd->country_code;
354 $file[
'vatnum'] = $objd->vatnum;
355 $file[
'sens'] = $objd->sens;
358 if (empty($filesarray[$file[
'item'].
'_'.$file[
'id']])) {
359 $filesarray[$file[
'item'].
'_'.$file[
'id']] = $file;
363 if (empty($filesarray[$file[
'item'].
'_'.$file[
'id']][
'files'])) {
364 $filesarray[$file[
'item'].
'_'.$file[
'id']][
'files'] = array();
366 $filesarray[$file[
'item'].
'_'.$file[
'id']][
'files'][] = array(
367 'link' => $link.urlencode($file[
'name']),
368 'name'=>$file[
'name'],
370 'fullname' => $file[
'fullname'],
371 'relpath' =>
'/'.$file[
'name'],
372 'relpathnamelang' => $langs->trans($file[
'item']).
'/'.$file[
'name'],
373 'modulepart' => $modulepart,
401 $dirfortmpfile = ($conf->accounting->dir_temp ? $conf->accounting->dir_temp : $conf->comptabilite->dir_temp);
402 if (empty($dirfortmpfile))
404 setEventMessages($langs->trans(
"ErrorNoAccountingModuleEnabled"), null,
'errors');
409 if ($result && $action ==
"dl" && !$error)
411 if (!extension_loaded(
'zip'))
419 $log = $langs->transnoentitiesnoconv(
"Type");
420 if (!empty($conf->multicompany->enabled) && is_object($mc))
422 $log .=
','.$langs->transnoentitiesnoconv(
"Entity");
424 $log .=
','.$langs->transnoentitiesnoconv(
"Date");
425 $log .=
','.$langs->transnoentitiesnoconv(
"DateDue");
426 $log .=
','.$langs->transnoentitiesnoconv(
"Ref");
427 $log .=
','.$langs->transnoentitiesnoconv(
"TotalHT");
428 $log .=
','.$langs->transnoentitiesnoconv(
"TotalTTC");
429 $log .=
','.$langs->transnoentitiesnoconv(
"TotalVAT");
430 $log .=
','.$langs->transnoentitiesnoconv(
"Paid");
431 $log .=
','.$langs->transnoentitiesnoconv(
"Document");
432 $log .=
','.$langs->transnoentitiesnoconv(
"ItemID");
433 $log .=
','.$langs->transnoentitiesnoconv(
"ThirdParty");
434 $log .=
','.$langs->transnoentitiesnoconv(
"Code");
435 $log .=
','.$langs->transnoentitiesnoconv(
"Country");
436 $log .=
','.$langs->transnoentitiesnoconv(
"VATIntra");
437 $log .=
','.$langs->transnoentitiesnoconv(
"Sens").
"\n";
442 $zip =
new ZipArchive;
443 $res = $zip->open($zipname, ZipArchive::OVERWRITE | ZipArchive::CREATE);
446 foreach ($filesarray as $key => $file)
448 if (!empty($file[
'files'])) {
449 foreach ($file[
'files'] as $filecursor) {
450 if (file_exists($filecursor[
"fullname"])) {
451 $zip->addFile($filecursor[
"fullname"], $filecursor[
"relpathnamelang"]);
456 $log .=
'"'.$langs->trans($file[
'item']).
'"';
457 if (!empty($conf->multicompany->enabled) && is_object($mc))
459 $log .=
',"'.(empty($arrayofentities[$file[
'entity']]) ? $file[
'entity'] : $arrayofentities[$file[
'entity']]).
'"';
461 $log .=
','.dol_print_date($file[
'date'],
'dayrfc');
462 $log .=
','.dol_print_date($file[
'date_due'],
'dayrfc');
463 $log .=
',"'.$file[
'ref'].
'"';
464 $log .=
','.$file[
'amount_ht'];
465 $log .=
','.$file[
'amount_ttc'];
466 $log .=
','.$file[
'amount_vat'];
467 $log .=
','.$file[
'paid'];
468 $log .=
',"'.$file[
"name"].
'"';
469 $log .=
','.$file[
'fk'];
470 $log .=
',"'.$file[
'thirdparty_name'].
'"';
471 $log .=
',"'.$file[
'thirdparty_code'].
'"';
472 $log .=
',"'.$file[
'country_code'].
'"';
473 $log .=
',"'.$file[
'vatnum'].
'"';
474 $log .=
',"'.$file[
'sens'].
'"';
477 $zip->addFromString(
'transactions.csv', $log);
481 header(
'Content-Type: application/zip');
482 header(
'Content-disposition: attachment; filename='.basename($zipname));
483 header(
'Content-Length: '.filesize($zipname));
490 setEventMessages($langs->trans(
"FailedToOpenFile", $zipname), null,
'errors');
499 $form =
new form($db);
501 $userstatic =
new User($db);
511 $title = $langs->trans(
"ComptaFiles").
' - '.$langs->trans(
"List");
518 $head[$h][0] =
$_SERVER[
"PHP_SELF"];
519 $head[$h][1] = $langs->trans(
"AccountantFiles");
520 $head[$h][2] =
'AccountancyFiles';
525 print '<form name="searchfiles" action="?action=searchfiles" method="POST">'.
"\n";
526 print '<input type="hidden" name="token" value="'.newToken().
'">';
528 print '<span class="opacitymedium">'.$langs->trans(
"ExportAccountingSourceDocHelp", $langs->transnoentitiesnoconv(
"Accounting"), $langs->transnoentitiesnoconv(
"Journals")).
'</span><br>';
531 print $langs->trans(
"ReportPeriod").
': '.$form->selectDate($date_start,
'date_start', 0, 0, 0,
"", 1, 1, 0);
532 print ' - '.$form->selectDate($date_stop,
'date_stop', 0, 0, 0,
"", 1, 1, 0).
"\n";
535 if (!empty($conf->multicompany->enabled) && is_object($mc))
537 $mc->getInfo($conf->entity);
538 print '<span class="marginleftonly marginrightonly'.(empty($conf->global->MULTICOMPANY_ALLOW_EXPORT_ACCOUNTING_DOC_FOR_ALL_ENTITIES) ?
' opacitymedium' :
'').
'">('.$langs->trans(
"Entity").
' : ';
540 if (!empty($conf->global->MULTICOMPANY_ALLOW_EXPORT_ACCOUNTING_DOC_FOR_ALL_ENTITIES)) {
541 print $mc->select_entities(
GETPOSTISSET(
'search_entity') ?
GETPOST(
'search_entity',
'int') : $mc->id,
'search_entity',
'',
false,
false,
false,
false,
true);
551 $listofchoices = array(
552 'selectinvoices'=>array(
'label'=>
'Invoices',
'lang'=>
'bills',
'enabled' => !empty($conf->facture->enabled)),
553 'selectsupplierinvoices'=>array(
'label'=>
'BillsSuppliers',
'lang'=>
'bills',
'enabled' => !empty($conf->supplier_invoice->enabled)),
554 'selectexpensereports'=>array(
'label'=>
'ExpenseReports',
'lang'=>
'trips',
'enabled' => !empty($conf->expensereport->enabled)),
555 'selectdonations'=>array(
'label'=>
'Donations',
'lang'=>
'donation',
'enabled' => !empty($conf->don->enabled)),
556 'selectsocialcontributions'=>array(
'label'=>
'SocialContributions',
'enabled' => !empty($conf->tax->enabled)),
557 'selectpaymentsofsalaries'=>array(
'label'=>
'SalariesPayments',
'lang'=>
'salaries',
'enabled' => !empty($conf->salaries->enabled)),
558 'selectvariouspayment'=>array(
'label'=>
'VariousPayment',
'enabled' => !empty($conf->banque->enabled)),
559 'selectloanspayment'=>array(
'label'=>
'PaymentLoan',
'enabled' => !empty($conf->loan->enabled)),
561 foreach ($listofchoices as $choice => $val) {
562 if (empty($val[
'enabled']))
continue;
563 $checked = (((!
GETPOSTISSET(
'search') && $action !=
'searchfiles') ||
GETPOST($choice)) ?
' checked="checked"' :
'');
564 print '<div class="paddingleft inline-block marginrightonly"><input type="checkbox" id="'.$choice.
'" name="'.$choice.
'" value="1"'.$checked.
'> <label for="'.$choice.
'">'.$langs->trans($val[
'label']).
'</label></div>';
567 print '<input class="button" type="submit" name="search" value="'.$langs->trans(
"Search").
'">';
569 print '</form>'.
"\n";
573 if (!empty($date_start) && !empty($date_stop))
575 $param =
'action=searchfiles';
576 $param .=
'&date_startday='.GETPOST(
'date_startday',
'int');
577 $param .=
'&date_startmonth='.GETPOST(
'date_startmonth',
'int');
578 $param .=
'&date_startyear='.GETPOST(
'date_startyear',
'int');
579 $param .=
'&date_stopday='.GETPOST(
'date_stopday',
'int');
580 $param .=
'&date_stopmonth='.GETPOST(
'date_stopmonth',
'int');
581 $param .=
'&date_stopyear='.GETPOST(
'date_stopyear',
'int');
582 foreach ($listofchoices as $choice => $val) {
583 $param .=
'&'.$choice.
'='.(
GETPOST($choice,
'int') ? 1 : 0);
585 print '<form name="dl" action="'.$_SERVER[
"PHP_SELF"].
'?action=dl" method="POST">'.
"\n";
586 print '<input type="hidden" name="token" value="'.currentToken().
'">';
590 print '<input type="hidden" name="date_start" value="'.dol_print_date($date_start,
'dayxcard').
'" />';
591 print '<input type="hidden" name="date_stop" value="'.dol_print_date($date_stop,
'dayxcard').
'" />';
592 foreach ($listofchoices as $choice => $val) {
593 print '<input type="hidden" name="'.$choice.
'" value="'.
GETPOST($choice).
'">';
596 print '<input class="butAction butDownload" type="submit" value="'.$langs->trans(
"Download").
'" />';
597 print '</form>'.
"\n";
601 print '<div class="div-table-responsive">';
602 print '<table class="noborder centpercent">';
603 print '<tr class="liste_titre">';
606 print_liste_field_titre($arrayfields[
'date_due'][
'label'],
$_SERVER[
"PHP_SELF"],
"date_due",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
608 print '<td>'.$langs->trans(
"Document").
'</td>';
609 print '<td>'.$langs->trans(
"Paid").
'</td>';
610 print '<td align="right">'.$langs->trans(
"TotalHT").($conf->multicurrency->enabled ?
' ('.$conf->currency.
')' :
'').
'</td>';
611 print '<td align="right">'.$langs->trans(
"TotalTTC").($conf->multicurrency->enabled ?
' ('.$conf->currency.
')' :
'').
'</td>';
612 print '<td align="right">'.$langs->trans(
"TotalVAT").($conf->multicurrency->enabled ?
' ('.$conf->currency.
')' :
'').
'</td>';
613 print '<td>'.$langs->trans(
"ThirdParty").
'</td>';
614 print '<td class="center">'.$langs->trans(
"Code").
'</td>';
615 print '<td class="center">'.$langs->trans(
"Country").
'</td>';
616 print '<td class="center">'.$langs->trans(
"VATIntra").
'</td>';
617 if (!empty($conf->multicurrency->enabled))
print '<td class="center">'.$langs->trans(
"Currency").
'</td>';
625 print '<tr class="oddeven"><td colspan="7">'.$langs->trans(
"NoItem").
'</td>';
626 if (!empty($conf->multicurrency->enabled)) {
638 $totalVAT_credit = 0;
641 foreach ($TData as $data)
646 print '<tr class="oddeven '.$html_class.
'">';
649 print '<td>'.$langs->trans($data[
'item']).
'</td>';
652 print '<td class="center">';
657 print '<td class="center">';
662 print '<td class="nowraponall">';
664 if ($data[
'item'] ==
'Invoice') {
665 $invoice->id = $data[
'id'];
666 $invoice->ref = $data[
'ref'];
667 $invoice->total_ht = $data[
'amount_ht'];
668 $invoice->total_ttc = $data[
'amount_ttc'];
669 $invoice->total_tva = $data[
'amount_vat'];
670 $invoice->multicurrency_code = $data[
'currency'];
671 print $invoice->getNomUrl(1,
'', 0, 0,
'', 0, 0, 0);
672 } elseif ($data[
'item'] ==
'SupplierInvoice') {
673 $supplier_invoice->id = $data[
'id'];
674 $supplier_invoice->ref = $data[
'ref'];
675 $supplier_invoice->total_ht = $data[
'amount_ht'];
676 $supplier_invoice->total_ttc = $data[
'amount_ttc'];
677 $supplier_invoice->total_tva = $data[
'amount_vat'];
678 $supplier_invoice->multicurrency_code = $data[
'currency'];
679 print $supplier_invoice->getNomUrl(1,
'', 0, 0,
'', 0, 0, 0);
680 } elseif ($data[
'item'] ==
'ExpenseReport') {
681 $expensereport->id = $data[
'id'];
682 $expensereport->ref = $data[
'ref'];
683 print $expensereport->getNomUrl(1, 0, 0,
'', 0, 0);
684 } elseif ($data[
'item'] ==
'SalaryPayment') {
685 $salary_payment->id = $data[
'id'];
686 $salary_payment->ref = $data[
'ref'];
687 print $salary_payment->getNomUrl(1,
'', 0,
'', 0);
688 } elseif ($data[
'item'] ==
'Donation') {
689 $don->id = $data[
'id'];
690 $don->ref = $data[
'ref'];
691 print $don->getNomUrl(1, 0,
'', 0);
692 } elseif ($data[
'item'] ==
'SocialContributions') {
693 $charge_sociales->id = $data[
'id'];
694 $charge_sociales->ref = $data[
'ref'];
695 print $charge_sociales->getNomUrl(1, 0, 0, 0, 0);
696 } elseif ($data[
'item'] ==
'VariousPayment') {
697 $various_payment->id = $data[
'id'];
698 $various_payment->ref = $data[
'ref'];
699 print $various_payment->getNomUrl(1,
'', 0, 0);
700 } elseif ($data[
'item'] ==
'LoanPayment') {
701 $payment_loan->id = $data[
'id'];
702 $payment_loan->ref = $data[
'ref'];
703 print $payment_loan->getNomUrl(1, 0, 0,
'', 0);
711 if (!empty($data[
'files']))
713 foreach ($data[
'files'] as $id=>$filecursor) {
714 print '<a href='.DOL_URL_ROOT.
'/'.$filecursor[
'link'].
' target="_blank">'.($filecursor[
'name'] ? $filecursor[
'name'] : $filecursor[
'ref']).
'</a> '.$formfile->showPreview($filecursor, $filecursor[
'modulepart'], $filecursor[
'subdir'].
'/'.$filecursor[
'name']).
'<br>';
720 print '<td aling="left">'.$data[
'paid'].
'</td>';
723 print '<td align="right">'.price($data[
'sens'] ? $data[
'amount_ht'] : -$data[
'amount_ht']).
"</td>\n";
725 print '<td align="right">'.price($data[
'sens'] ? $data[
'amount_ttc'] : -$data[
'amount_ttc']).
"</td>\n";
727 print '<td align="right">'.price($data[
'sens'] ? $data[
'amount_vat'] : -$data[
'amount_vat']).
"</td>\n";
729 print '<td class="tdoverflowmax150" title="'.$data[
'thirdparty_name'].
'">'.$data[
'thirdparty_name'].
"</td>\n";
731 print '<td class="center">'.$data[
'thirdparty_code'].
"</td>\n";
733 print '<td class="center">'.$data[
'country_code'].
"</td>\n";
735 print '<td align="right">'.$data[
'vatnum'].
"</td>\n";
738 $totalET_credit += $data[
'amount_ht'];
739 $totalIT_credit += $data[
'amount_ttc'];
740 $totalVAT_credit += $data[
'amount_vat'];
742 $totalET_debit -= $data[
'amount_ht'];
743 $totalIT_debit -= $data[
'amount_ttc'];
744 $totalVAT_debit -= $data[
'amount_vat'];
747 if (!empty($conf->multicurrency->enabled)) {
748 print '<td class="center">'.$data[
'currency'].
"</td>\n";
755 print '<tr class="liste_total">';
756 print '<td colspan="6" class="right">'.$langs->trans(
'Total').
' '.$langs->trans(
'Income').
'</td>';
757 print '<td align="right">'.price(
price2num($totalET_credit,
'MT')).
'</td>';
758 print '<td align="right">'.price(
price2num($totalIT_credit,
'MT')).
'</td>';
759 print '<td align="right">'.price(
price2num($totalVAT_credit,
'MT')).
'</td>';
760 print '<td colspan="4"></td>';
761 if (!empty($conf->multicurrency->enabled)) {
766 print '<tr class="liste_total">';
767 print '<td colspan="6" class="right">'.$langs->trans(
'Total').
' '.$langs->trans(
'Outcome').
'</td>';
768 print '<td align="right">'.price(
price2num($totalET_debit,
'MT')).
'</td>';
769 print '<td align="right">'.price(
price2num($totalIT_debit,
'MT')).
'</td>';
770 print '<td align="right">'.price(
price2num($totalVAT_debit,
'MT')).
'</td>';
771 print '<td colspan="4"></td>';
772 if (!empty($conf->multicurrency->enabled)) {
777 print '<tr class="liste_total">';
778 print '<td colspan="6" class="right">'.$langs->trans(
'Total').
'</td>';
779 print '<td align="right">'.price(
price2num($totalET_credit + $totalET_debit,
'MT')).
'</td>';
780 print '<td align="right">'.price(
price2num($totalIT_credit + $totalIT_debit,
'MT')).
'</td>';
781 print '<td align="right">'.price(
price2num($totalVAT_credit + $totalVAT_debit,
'MT')).
'</td>';
782 print '<td colspan="4"></td>';
783 if (!empty($conf->multicurrency->enabled)) {
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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 salary payments.
Class to manage Dolibarr users.
Class to manage suppliers invoices.
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.
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.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart= '')
Return a path to have a the directory according to object where files are stored. ...
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1)
Remove a file or several files with a mask.
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.
print $_SERVER["PHP_SELF"]
Edit parameters.
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.
print
Draft customers invoices.
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.
Class to manage invoices.
Classe permettant la gestion des paiements des charges La tva collectee n'est calculee que sur les fa...
dol_mkdir($dir, $dataroot= '', $newmask=null)
Creation of a directory (this can create recursive subdir)