dolibarr  16.0.5
accounting-files.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2001-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2019 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2017 Pierre-Henry Favre <support@atm-consulting.fr>
5  * Copyright (C) 2020 Maxime DEMAREST <maxime@indelog.fr>
6  * Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
7  * Copyright (C) 2022 Alexandre Spangaro <aspangaro@open-dsi.fr>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <https://www.gnu.org/licenses/>.
21  */
22 
29 if ((array_key_exists('action', $_GET) && $_GET['action'] == 'dl') || (array_key_exists('action', $_POST) && $_POST['action'] == 'dl')) { // To not replace token when downloading file
30  if (!defined('NOTOKENRENEWAL')) {
31  define('NOTOKENRENEWAL', '1');
32  }
33 }
34 
35 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';
50 
51 // Constant to define payment sens
52 const PAY_DEBIT = 0;
53 const PAY_CREDIT = 1;
54 
55 $langs->loadLangs(array("accountancy", "bills", "companies", "salaries", "compta", "trips", "banks", "loan"));
56 
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');
68 
69 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
70 $hookmanager->initHooks(array('comptafileslist', 'globallist'));
71 
72 // Load variable for pagination
73 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
74 $sortfield = GETPOST('sortfield', 'aZ09comma');
75 $sortorder = GETPOST('sortorder', 'aZ09comma');
76 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
77 if (empty($page) || $page == -1) {
78  $page = 0;
79 } // If $page is not defined, or '' or -1
80 $offset = $limit * $page;
81 $pageprev = $page - 1;
82 $pagenext = $page + 1;
83 if (!$sortfield) {
84  $sortfield = "date,item"; // Set here default search field
85 }
86 if (!$sortorder) {
87  $sortorder = "DESC";
88 }
89 
90 
91 $arrayfields = array(
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),
101  //...
102 );
103 
104 // Security check
105 if (!isModEnabled('comptabilite') && !isModEnabled('accounting')) {
106  accessforbidden();
107 }
108 if ($user->socid > 0) {
109  accessforbidden();
110 }
111 
112 // Define $arrayofentities if multientity is set.
113 $arrayofentities = array();
114 if (isModEnabled('multicompany') && is_object($mc)) {
115  $arrayofentities = $mc->getEntitiesList();
116 }
117 
118 $entity = (GETPOSTISSET('entity') ? GETPOST('entity', 'int') : (GETPOSTISSET('search_entity') ? GETPOST('search_entity', 'int') : $conf->entity));
119 if (isModEnabled('multicompany') && is_object($mc)) {
120  if (empty($entity) && !empty($conf->global->MULTICOMPANY_ALLOW_EXPORT_ACCOUNTING_DOC_FOR_ALL_ENTITIES)) {
121  $entity = '0,'.join(',', array_keys($arrayofentities));
122  }
123 }
124 if (empty($entity)) {
125  $entity = $conf->entity;
126 }
127 
128 $error = 0;
129 
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)),
139 );
140 
141 
142 
143 /*
144  * Actions
145  */
146 
147 
148 //$parameters = array('socid' => $id);
149 //$reshook = $hookmanager->executeHooks('doActions', $parameters, $object); // Note that $object may have been modified by some hooks
150 //if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
151 
152 $filesarray = array();
153 $result = false;
154 if (($action == 'searchfiles' || $action == 'dl')) {
155  if (empty($date_start)) {
156  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DateStart")), null, 'errors');
157  $error++;
158  }
159  if (empty($date_stop)) {
160  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DateEnd")), null, 'errors');
161  $error++;
162  }
163 
164  if (!$error) {
165  $sql = '';
166 
167  $wheretail = " '".$db->idate($date_start)."' AND '".$db->idate($date_stop)."'";
168 
169  // Customer invoices
170  if (GETPOST('selectinvoices') && !empty($listofchoices['selectinvoices']['perms'])) {
171  if (!empty($sql)) {
172  $sql .= " UNION ALL";
173  }
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;
179  }
180  // Vendor invoices
181  if (GETPOST('selectsupplierinvoices') && !empty($listofchoices['selectsupplierinvoices']['perms'])) {
182  if (!empty($sql)) {
183  $sql .= " UNION ALL";
184  }
185  $sql .= " SELECT t.rowid as id, t.entity, t.ref, t.paye as paid, t.total_ht, t.total_ttc, t.total_tva as total_vat, 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;
190  }
191  // Expense reports
192  if (GETPOST('selectexpensereports') && !empty($listofchoices['selectexpensereports']['perms'])) {
193  if (!empty($sql)) {
194  $sql .= " UNION ALL";
195  }
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;
201  }
202  // Donations
203  if (GETPOST('selectdonations') && !empty($listofchoices['selectdonations']['perms'])) {
204  if (!empty($sql)) {
205  $sql .= " UNION ALL";
206  }
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;
212  }
213  // Payments of salaries
214  if (GETPOST('selectpaymentsofsalaries') && !empty($listofchoices['selectpaymentsofsalaries']['perms'])) {
215  if (!empty($sql)) {
216  $sql .= " UNION ALL";
217  }
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).')';
222  //$sql.=" AND fk_statut <> ".PaymentSalary::STATUS_DRAFT;
223  }
224  // Social contributions
225  if (GETPOST('selectsocialcontributions') && !empty($listofchoices['selectsocialcontributions']['perms'])) {
226  if (!empty($sql)) {
227  $sql .= " UNION ALL";
228  }
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).')';
233  //$sql.=" AND fk_statut <> ".ChargeSociales::STATUS_DRAFT;
234  }
235  // Various payments
236  if (GETPOST('selectvariouspayment') && !empty($listofchoices['selectvariouspayment']['perms'])) {
237  if (!empty($sql)) {
238  $sql .= " UNION ALL";
239  }
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).')';
244  }
245  // Loan payments
246  if (GETPOST('selectloanspayment') && !empty($listofchoices['selectloanspayment']['perms'])) {
247  if (!empty($sql)) {
248  $sql .= " UNION ALL";
249  }
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).')';
254  }
255 
256  if ($sql) {
257  $sql .= $db->order($sortfield, $sortorder);
258  //print $sql;
259 
260  $resd = $db->query($sql);
261  $files = array();
262  $link = '';
263 
264  if ($resd) {
265  $numd = $db->num_rows($resd);
266 
267  $tmpinvoice = new Facture($db);
268  $tmpinvoicesupplier = new FactureFournisseur($db);
269  $tmpdonation = new Don($db);
270 
271  $upload_dir = '';
272  $i = 0;
273  while ($i < $numd) {
274  $objd = $db->fetch_object($resd);
275 
276  switch ($objd->item) {
277  case "Invoice":
278  $subdir = '';
279  $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->ref);
280  $upload_dir = $conf->facture->dir_output.'/'.$subdir;
281  $link = "document.php?modulepart=facture&file=".str_replace('/', '%2F', $subdir).'%2F';
282  $modulepart = "facture";
283  break;
284  case "SupplierInvoice":
285  $tmpinvoicesupplier->fetch($objd->id);
286  $subdir = get_exdir($tmpinvoicesupplier->id, 2, 0, 1, $tmpinvoicesupplier, 'invoice_supplier'); // TODO Use first file
287  $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->ref);
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";
291  break;
292  case "ExpenseReport":
293  $subdir = '';
294  $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->ref);
295  $upload_dir = $conf->expensereport->dir_output.'/'.$subdir;
296  $link = "document.php?modulepart=expensereport&file=".str_replace('/', '%2F', $subdir).'%2F';
297  $modulepart = "expensereport";
298  break;
299  case "SalaryPayment":
300  $subdir = '';
301  $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->id);
302  $upload_dir = $conf->salaries->dir_output.'/'.$subdir;
303  $link = "document.php?modulepart=salaries&file=".str_replace('/', '%2F', $subdir).'%2F';
304  $modulepart = "salaries";
305  break;
306  case "Donation":
307  $tmpdonation->fetch($objp->id);
308  $subdir = get_exdir(0, 0, 0, 0, $tmpdonation, 'donation');
309  $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->id);
310  $upload_dir = $conf->don->dir_output.'/'.$subdir;
311  $link = "document.php?modulepart=don&file=".str_replace('/', '%2F', $subdir).'%2F';
312  $modulepart = "don";
313  break;
314  case "SocialContributions":
315  $subdir = '';
316  $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->id);
317  $upload_dir = $conf->tax->dir_output.'/'.$subdir;
318  $link = "document.php?modulepart=tax&file=".str_replace('/', '%2F', $subdir).'%2F';
319  $modulepart = "tax";
320  break;
321  case "VariousPayment":
322  $subdir = '';
323  $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->id);
324  $upload_dir = $conf->bank->dir_output.'/'.$subdir;
325  $link = "document.php?modulepart=banque&file=".str_replace('/', '%2F', $subdir).'%2F';
326  $modulepart = "banque";
327  break;
328  case "LoanPayment":
329  // Loan payment has no linked file
330  $subdir = '';
331  $upload_dir = $conf->loan->dir_output.'/'.$subdir;
332  $link = "";
333  $modulepart = "";
334  break;
335  default:
336  $subdir = '';
337  $upload_dir = '';
338  $link = '';
339  break;
340  }
341 
342  if (!empty($upload_dir)) {
343  $result = true;
344 
345  $files = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', '', SORT_ASC, 1);
346  //var_dump($upload_dir);
347  //var_dump($files);
348  if (count($files) < 1) {
349  $nofile = array();
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;
366 
367  $filesarray[$nofile['item'].'_'.$nofile['id']] = $nofile;
368  } else {
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;
386 
387  // Save record into array (only the first time it is found)
388  if (empty($filesarray[$file['item'].'_'.$file['id']])) {
389  $filesarray[$file['item'].'_'.$file['id']] = $file;
390  }
391 
392  // Add or concat file
393  if (empty($filesarray[$file['item'].'_'.$file['id']]['files'])) {
394  $filesarray[$file['item'].'_'.$file['id']]['files'] = array();
395  }
396  $filesarray[$file['item'].'_'.$file['id']]['files'][] = array(
397  'link' => $link.urlencode($file['name']),
398  'name'=>$file['name'],
399  'ref'=>$file['ref'],
400  'fullname' => $file['fullname'],
401  'relpath' => '/'.$file['name'],
402  'relpathnamelang' => $langs->trans($file['item']).'/'.$file['name'],
403  'modulepart' => $modulepart,
404  'subdir' => $subdir,
405  );
406  //var_dump($file['item'].'_'.$file['id']);
407  //var_dump($filesarray[$file['item'].'_'.$file['id']]['files']);
408  }
409  }
410  }
411 
412  $i++;
413  }
414  } else {
415  dol_print_error($db);
416  }
417 
418  $db->free($resd);
419  } else {
420  setEventMessages($langs->trans("ErrorSelectAtLeastOne"), null, 'errors');
421  $error++;
422  }
423  }
424 }
425 
426 
427 /*
428  *ZIP creation
429  */
430 
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');
434  $error++;
435 }
436 
437 
438 if ($result && $action == "dl" && !$error) {
439  if (!extension_loaded('zip')) {
440  setEventMessages('PHPZIPExtentionNotLoaded', null, 'errors');
441  exit;
442  }
443 
444  dol_mkdir($dirfortmpfile);
445 
446  $log = $langs->transnoentitiesnoconv("Type");
447  if (isModEnabled('multicompany') && is_object($mc)) {
448  $log .= ','.$langs->transnoentitiesnoconv("Entity");
449  }
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';
465 
466  dol_delete_file($zipname);
467 
468  $zip = new ZipArchive;
469  $res = $zip->open($zipname, ZipArchive::OVERWRITE | ZipArchive::CREATE);
470  if ($res) {
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"]);
476  }
477  }
478  }
479 
480  $log .= '"'.$langs->trans($file['item']).'"';
481  if (isModEnabled('multicompany') && is_object($mc)) {
482  $log .= ',"'.(empty($arrayofentities[$file['entity']]) ? $file['entity'] : $arrayofentities[$file['entity']]).'"';
483  }
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'].'"';
498  $log .= "\n";
499  }
500  $zip->addFromString('transactions.csv', $log);
501  $zip->close();
502 
503  // Then download the zipped file.
504  header('Content-Type: application/zip');
505  header('Content-disposition: attachment; filename='.basename($zipname));
506  header('Content-Length: '.filesize($zipname));
507  readfile($zipname);
508 
509  dol_delete_file($zipname);
510 
511  exit();
512  } else {
513  setEventMessages($langs->trans("FailedToOpenFile", $zipname), null, 'errors');
514  }
515 }
516 
517 
518 /*
519  * View
520  */
521 
522 $form = new form($db);
523 $formfile = new FormFile($db);
524 $userstatic = new User($db);
525 $invoice = new Facture($db);
526 $supplier_invoice = new FactureFournisseur($db);
527 $expensereport = new ExpenseReport($db);
528 $don = new Don($db);
529 $salary_payment = new PaymentSalary($db);
530 $charge_sociales = new ChargeSociales($db);
531 $various_payment = new PaymentVarious($db);
532 $payment_loan = new PaymentLoan($db);
533 
534 $title = $langs->trans("ComptaFiles").' - '.$langs->trans("List");
535 $help_url = '';
536 
537 llxHeader('', $title, $help_url);
538 
539 $h = 0;
540 $head = array();
541 $head[$h][0] = $_SERVER["PHP_SELF"];
542 $head[$h][1] = $langs->trans("AccountantFiles");
543 $head[$h][2] = 'AccountancyFiles';
544 
545 print dol_get_fiche_head($head, 'AccountancyFiles');
546 
547 
548 print '<form name="searchfiles" action="?action=searchfiles" method="POST">'."\n";
549 print '<input type="hidden" name="token" value="'.newToken().'">';
550 
551 print '<span class="opacitymedium">'.$langs->trans("ExportAccountingSourceDocHelp");
552 if (isModEnabled('accounting')) {
553  print ' '.$langs->trans("ExportAccountingSourceDocHelp2", $langs->transnoentitiesnoconv("Accounting"), $langs->transnoentitiesnoconv("Journals"));
554 }
555 print '</span><br>';
556 print '<br>';
557 
558 print $langs->trans("ReportPeriod").': ';
559 print $form->selectDate($date_start, 'date_start', 0, 0, 0, "", 1, 1, 0, '', '', '', '', 1, '', '', 'tzuserrel');
560 print ' - ';
561 print $form->selectDate($date_stop, 'date_stop', 0, 0, 0, "", 1, 1, 0, '', '', '', '', 1, '', '', 'tzuserrel');
562 print "\n";
563 
564 // Export is for current company only
565 if (isModEnabled('multicompany') && is_object($mc)) {
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").' : ';
568  print "<td>";
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);
571  } else {
572  print $mc->label;
573  }
574  print "</td>";
575  print ")</span>\n";
576 }
577 
578 print '<br>';
579 
580 foreach ($listofchoices as $choice => $val) {
581  if (empty($val['enabled'])) {
582  continue; // list not qualified
583  }
584  $disabled = '';
585  if (empty($val['perms'])) {
586  $disabled = ' disabled';
587  }
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>';
590 }
591 
592 print '<input type="submit" class="button small" name="search" value="'.$langs->trans("Search").'">';
593 
594 print '</form>'."\n";
595 
596 print dol_get_fiche_end();
597 
598 $param = '';
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) {
607  if (GETPOST($choice, 'int')) {
608  $param .= '&'.$choice.'=1';
609  }
610  }
611 
612  $TData = dol_sort_array($filesarray, $sortfield, $sortorder);
613 
614 
615  $filename = dol_print_date($date_start, 'dayrfc', 'tzuserrel')."-".dol_print_date($date_stop, 'dayrfc', 'tzuserrel').'_export.zip';
616 
617  echo dol_print_date($date_start, 'day', 'tzuserrel')." - ".dol_print_date($date_stop, 'day', 'tzuserrel');
618 
619  print '<a class="marginleftonly small'.(empty($TData) ? ' butActionRefused' : ' butAction').'" href="'.$_SERVER["PHP_SELF"].'?action=dl&token='.currentToken().'&output=file&file='.urlencode($filename).$param.'"';
620  if (empty($TData)) {
621  print " disabled";
622  }
623  print '>'."\n";
624  print $langs->trans("Download");
625  print '</a><br>';
626 
627  $param .= '&action=searchfiles';
628 
629  /*
630  print '<input type="hidden" name="token" value="'.currentToken().'">';
631  print '<input type="hidden" name="date_startday" value="'.GETPOST('date_startday', 'int').'" />';
632  print '<input type="hidden" name="date_startmonth" value="'.GETPOST('date_startmonth', 'int').'" />';
633  print '<input type="hidden" name="date_startyear" value="'.GETPOST('date_startyear', 'int').'" />';
634  print '<input type="hidden" name="date_stopday" value="'.GETPOST('date_stopday', 'int').'" />';
635  print '<input type="hidden" name="date_stopmonth" value="'.GETPOST('date_stopmonth', 'int').'" />';
636  print '<input type="hidden" name="date_stopyear" value="'.GETPOST('date_stopyear', 'int').'" />';
637  foreach ($listofchoices as $choice => $val) {
638  print '<input type="hidden" name="'.$choice.'" value="'.GETPOST($choice).'">';
639  }
640 
641  print '<input class="butAction butDownload small marginleftonly" type="submit" value="'.$langs->trans("Download").'"';
642  if (empty($TData)) {
643  print " disabled";
644  }
645  print '/>';
646  print '</form>'."\n";
647  */
648 
649  print '<br>';
650 
651  print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
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>';
667  if (isModEnabled('multicurrency')) {
668  print '<td class="center">'.$langs->trans("Currency").'</td>';
669  }
670  print '</tr>';
671 
672  if (empty($TData)) {
673  print '<tr class="oddeven"><td colspan="13"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td>';
674  if (isModEnabled('multicurrency')) {
675  print '<td></td>';
676  }
677  print '</tr>';
678  } else {
679  // Sort array by date ASC to calculate balance
680 
681  $totalET_debit = 0;
682  $totalIT_debit = 0;
683  $totalVAT_debit = 0;
684  $totalET_credit = 0;
685  $totalIT_credit = 0;
686  $totalVAT_credit = 0;
687 
688  // Display array
689  foreach ($TData as $data) {
690  $html_class = '';
691  //if (!empty($data['fk_facture'])) $html_class = 'facid-'.$data['fk_facture'];
692  //elseif (!empty($data['fk_paiement'])) $html_class = 'payid-'.$data['fk_paiement'];
693  print '<tr class="oddeven '.$html_class.'">';
694 
695  // Type
696  print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($langs->trans($data['item'])).'">'.$langs->trans($data['item']).'</td>';
697 
698  // Date
699  print '<td class="center">';
700  print dol_print_date($data['date'], 'day');
701  print "</td>\n";
702 
703  // Date due
704  print '<td class="center">';
705  print dol_print_date($data['date_due'], 'day');
706  print "</td>\n";
707 
708  // Ref
709  print '<td class="nowraponall tdoverflowmax150">';
710 
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);
751  } else {
752  print $data['ref'];
753  }
754  print '</td>';
755 
756  // File link
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);
761  if ($tmppreview) {
762  print $tmppreview;
763  }
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');
768  }
769  print $filename;
770  print '</a><br>';
771  }
772  }
773  print "</td>\n";
774 
775  // Paid
776  print '<td class="center">'.($data['paid'] ? yn($data['paid']) : '').'</td>';
777 
778  // Total ET
779  print '<td align="right"><span class="amount">'.price(price2num($data['sens'] ? $data['amount_ht'] : -$data['amount_ht'], 'MT'))."</span></td>\n";
780  // Total IT
781  print '<td align="right"><span class="amount">'.price(price2num($data['sens'] ? $data['amount_ttc'] : -$data['amount_ttc'], 'MT'))."</span></td>\n";
782  // Total VAT
783  print '<td align="right"><span class="amount">'.price(price2num($data['sens'] ? $data['amount_vat'] : -$data['amount_vat'], 'MT'))."</span></td>\n";
784 
785  print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($data['thirdparty_name']).'">'.dol_escape_htmltag($data['thirdparty_name'])."</td>\n";
786 
787  print '<td class="center">'.$data['thirdparty_code']."</td>\n";
788 
789  print '<td class="center">'.$data['country_code']."</td>\n";
790 
791  // VAT number
792  print '<td class="tdoverflowmax150 right" title="'.dol_escape_htmltag($data['vatnum']).'">'.dol_escape_htmltag($data['vatnum'])."</td>\n";
793 
794  if ($data['sens']) {
795  $totalET_credit += $data['amount_ht'];
796  $totalIT_credit += $data['amount_ttc'];
797  $totalVAT_credit += $data['amount_vat'];
798  } else {
799  $totalET_debit -= $data['amount_ht'];
800  $totalIT_debit -= $data['amount_ttc'];
801  $totalVAT_debit -= $data['amount_vat'];
802  }
803 
804  if (isModEnabled('multicurrency')) {
805  print '<td class="center">'.$data['currency']."</td>\n";
806  }
807 
808  print "</tr>\n";
809  }
810 
811  // Total credits
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>';
818  if (isModEnabled('multicurrency')) {
819  print '<td></td>';
820  }
821  print "</tr>\n";
822  // Total debits
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>';
829  if (isModEnabled('multicurrency')) {
830  print '<td></td>';
831  }
832  print "</tr>\n";
833  // Balance
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>';
840  if (isModEnabled('multicurrency')) {
841  print '<td></td>';
842  }
843  print "</tr>\n";
844  }
845 
846  print "</table>";
847  print '</div>';
848 }
849 
850 
851 llxFooter();
852 $db->close();
yn
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
Definition: functions.lib.php:6491
dol_escape_htmltag
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.
Definition: functions.lib.php:1468
dol_sanitizeFileName
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
Definition: functions.lib.php:1226
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
ChargeSociales
Classe permettant la gestion des paiements des charges La tva collectee n'est calculee que sur les fa...
Definition: chargesociales.class.php:34
PaymentSalary
Class to manage payments of salaries.
Definition: paymentsalary.class.php:34
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
FactureFournisseur
Class to manage suppliers invoices.
Definition: fournisseur.facture.class.php:53
dol_print_error
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Definition: functions.lib.php:4844
dol_sort_array
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...
Definition: functions.lib.php:8385
PaymentLoan
Class to manage payments of loans.
Definition: paymentloan.class.php:32
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
Don
Class to manage donations.
Definition: don.class.php:38
dol_dir_list
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.
Definition: files.lib.php:60
Facture
Class to manage invoices.
Definition: facture.class.php:60
$help_url
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.
Definition: agenda.php:116
price2num
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
Definition: functions.lib.php:5661
dol_print_date
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
Definition: functions.lib.php:2514
img_picto
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Definition: functions.lib.php:3880
PaymentVarious
Class to manage various payments.
Definition: paymentvarious.class.php:32
dol_delete_file
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.
Definition: files.lib.php:1231
get_exdir
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
Definition: functions.lib.php:6549
FormFile
Class to offer components to list and upload files.
Definition: html.formfile.class.php:36
dol_get_fiche_head
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
Definition: functions.lib.php:1822
dol_get_fiche_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2018
isModEnabled
isModEnabled($module)
Is Dolibarr module enabled.
Definition: functions.lib.php:105
User
Class to manage Dolibarr users.
Definition: user.class.php:44
GETPOSTISSET
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
Definition: functions.lib.php:386
print_liste_field_titre
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
Definition: functions.lib.php:5026
ExpenseReport
Class to manage Trips and Expenses.
Definition: expensereport.class.php:36
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
accessforbidden
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 ...
Definition: security.lib.php:933
dol_mkdir
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
Definition: functions.lib.php:6603
dol_mktime
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...
Definition: functions.lib.php:2757
currentToken
currentToken()
Return the value of token currently saved into session with name 'token'.
Definition: functions.lib.php:10889
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59