dolibarr  x.y.z
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 // Load Dolibarr environment
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';
51 
52 if (isModEnabled('project')) {
53  require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
54  require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
55 }
56 
57 // Constant to define payment sens
58 const PAY_DEBIT = 0;
59 const PAY_CREDIT = 1;
60 
61 $langs->loadLangs(array("accountancy", "bills", "companies", "salaries", "compta", "trips", "banks", "loan"));
62 
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);
75 
76 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
77 $hookmanager->initHooks(array('comptafileslist', 'globallist'));
78 
79 // Load variable for pagination
80 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
81 $sortfield = GETPOST('sortfield', 'aZ09comma');
82 $sortorder = GETPOST('sortorder', 'aZ09comma');
83 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
84 if (empty($page) || $page == -1) {
85  $page = 0;
86 } // If $page is not defined, or '' or -1
87 $offset = $limit * $page;
88 $pageprev = $page - 1;
89 $pagenext = $page + 1;
90 if (!$sortfield) {
91  $sortfield = "date,item"; // Set here default search field
92 }
93 if (!$sortorder) {
94  $sortorder = "DESC";
95 }
96 
97 
98 $arrayfields = array(
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),
108  //...
109 );
110 
111 // Security check
112 if (!isModEnabled('comptabilite') && !isModEnabled('accounting')) {
113  accessforbidden();
114 }
115 if ($user->socid > 0) {
116  accessforbidden();
117 }
118 
119 // Define $arrayofentities if multientity is set.
120 $arrayofentities = array();
121 if (isModEnabled('multicompany') && is_object($mc)) {
122  $arrayofentities = $mc->getEntitiesList();
123 }
124 
125 $entity = (GETPOSTISSET('entity') ? GETPOST('entity', 'int') : (GETPOSTISSET('search_entity') ? GETPOST('search_entity', 'int') : $conf->entity));
126 if (isModEnabled('multicompany') && is_object($mc)) {
127  if (empty($entity) && !empty($conf->global->MULTICOMPANY_ALLOW_EXPORT_ACCOUNTING_DOC_FOR_ALL_ENTITIES)) {
128  $entity = '0,'.join(',', array_keys($arrayofentities));
129  }
130 }
131 if (empty($entity)) {
132  $entity = $conf->entity;
133 }
134 
135 $error = 0;
136 
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)),
146 );
147 
148 
149 
150 /*
151  * Actions
152  */
153 
154 
155 //$parameters = array('socid' => $id);
156 //$reshook = $hookmanager->executeHooks('doActions', $parameters, $object); // Note that $object may have been modified by some hooks
157 //if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
158 
159 $filesarray = array();
160 $result = false;
161 if (($action == 'searchfiles' || $action == 'dl')) {
162  if (empty($date_start)) {
163  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DateStart")), null, 'errors');
164  $error++;
165  }
166  if (empty($date_stop)) {
167  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DateEnd")), null, 'errors');
168  $error++;
169  }
170 
171  if (!$error) {
172  $sql = '';
173 
174  $wheretail = " '".$db->idate($date_start)."' AND '".$db->idate($date_stop)."'";
175 
176  // Customer invoices
177  if (GETPOST('selectinvoices') && !empty($listofchoices['selectinvoices']['perms'])) {
178  if (!empty($sql)) {
179  $sql .= " UNION ALL";
180  }
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);
187  }
188  // Vendor invoices
189  if (GETPOST('selectsupplierinvoices') && !empty($listofchoices['selectsupplierinvoices']['perms'])) {
190  if (!empty($sql)) {
191  $sql .= " UNION ALL";
192  }
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);
199  }
200  // Expense reports
201  if (GETPOST('selectexpensereports') && !empty($listofchoices['selectexpensereports']['perms']) && empty($projectid)) {
202  if (!empty($sql)) {
203  $sql .= " UNION ALL";
204  }
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;
210  }
211  // Donations
212  if (GETPOST('selectdonations') && !empty($listofchoices['selectdonations']['perms'])) {
213  if (!empty($sql)) {
214  $sql .= " UNION ALL";
215  }
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);
222  }
223  // Payments of salaries
224  if (GETPOST('selectpaymentsofsalaries') && !empty($listofchoices['selectpaymentsofsalaries']['perms'])) {
225  if (!empty($sql)) {
226  $sql .= " UNION ALL";
227  }
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).')';
232  //$sql.=" AND fk_statut <> ".PaymentSalary::STATUS_DRAFT;
233  if (!empty($projectid)) $sql .= " AND fk_projet = ".((int) $projectid);
234  }
235  // Social contributions
236  if (GETPOST('selectsocialcontributions') && !empty($listofchoices['selectsocialcontributions']['perms'])) {
237  if (!empty($sql)) {
238  $sql .= " UNION ALL";
239  }
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).')';
244  //$sql.=" AND fk_statut <> ".ChargeSociales::STATUS_DRAFT;
245  if (!empty($projectid)) $sql .= " AND fk_projet = ".((int) $projectid);
246  }
247  // Various payments
248  if (GETPOST('selectvariouspayment') && !empty($listofchoices['selectvariouspayment']['perms'])) {
249  if (!empty($sql)) {
250  $sql .= " UNION ALL";
251  }
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);
257  }
258  // Loan payments
259  if (GETPOST('selectloanspayment') && !empty($listofchoices['selectloanspayment']['perms']) && empty($projectid)) {
260  if (!empty($sql)) {
261  $sql .= " UNION ALL";
262  }
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).')';
267  }
268 
269  if ($sql) {
270  $sql .= $db->order($sortfield, $sortorder);
271  //print $sql;
272 
273  $resd = $db->query($sql);
274  $files = array();
275  $link = '';
276 
277  if ($resd) {
278  $numd = $db->num_rows($resd);
279 
280  $tmpinvoice = new Facture($db);
281  $tmpinvoicesupplier = new FactureFournisseur($db);
282  $tmpdonation = new Don($db);
283 
284  $upload_dir = '';
285  $i = 0;
286  while ($i < $numd) {
287  $objd = $db->fetch_object($resd);
288 
289  switch ($objd->item) {
290  case "Invoice":
291  $subdir = '';
292  $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->ref);
293  $upload_dir = $conf->facture->dir_output.'/'.$subdir;
294  $link = "document.php?modulepart=facture&file=".str_replace('/', '%2F', $subdir).'%2F';
295  $modulepart = "facture";
296  break;
297  case "SupplierInvoice":
298  $tmpinvoicesupplier->fetch($objd->id);
299  $subdir = get_exdir($tmpinvoicesupplier->id, 2, 0, 1, $tmpinvoicesupplier, 'invoice_supplier'); // TODO Use first file
300  $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->ref);
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";
304  break;
305  case "ExpenseReport":
306  $subdir = '';
307  $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->ref);
308  $upload_dir = $conf->expensereport->dir_output.'/'.$subdir;
309  $link = "document.php?modulepart=expensereport&file=".str_replace('/', '%2F', $subdir).'%2F';
310  $modulepart = "expensereport";
311  break;
312  case "SalaryPayment":
313  $subdir = '';
314  $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->id);
315  $upload_dir = $conf->salaries->dir_output.'/'.$subdir;
316  $link = "document.php?modulepart=salaries&file=".str_replace('/', '%2F', $subdir).'%2F';
317  $modulepart = "salaries";
318  break;
319  case "Donation":
320  $tmpdonation->fetch($objp->id);
321  $subdir = get_exdir(0, 0, 0, 0, $tmpdonation, 'donation');
322  $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->id);
323  $upload_dir = $conf->don->dir_output.'/'.$subdir;
324  $link = "document.php?modulepart=don&file=".str_replace('/', '%2F', $subdir).'%2F';
325  $modulepart = "don";
326  break;
327  case "SocialContributions":
328  $subdir = '';
329  $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->id);
330  $upload_dir = $conf->tax->dir_output.'/'.$subdir;
331  $link = "document.php?modulepart=tax&file=".str_replace('/', '%2F', $subdir).'%2F';
332  $modulepart = "tax";
333  break;
334  case "VariousPayment":
335  $subdir = '';
336  $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->id);
337  $upload_dir = $conf->bank->dir_output.'/'.$subdir;
338  $link = "document.php?modulepart=banque&file=".str_replace('/', '%2F', $subdir).'%2F';
339  $modulepart = "banque";
340  break;
341  case "LoanPayment":
342  // Loan payment has no linked file
343  $subdir = '';
344  $upload_dir = $conf->loan->dir_output.'/'.$subdir;
345  $link = "";
346  $modulepart = "";
347  break;
348  default:
349  $subdir = '';
350  $upload_dir = '';
351  $link = '';
352  break;
353  }
354 
355  if (!empty($upload_dir)) {
356  $result = true;
357 
358  $files = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', '', SORT_ASC, 1);
359  //var_dump($upload_dir);
360  //var_dump($files);
361  if (count($files) < 1) {
362  $nofile = array();
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 
380  $filesarray[$nofile['item'].'_'.$nofile['id']] = $nofile;
381  } else {
382  foreach ($files as $key => $file) {
383  $file['id'] = $objd->id;
384  $file['entity'] = $objd->entity;
385  $file['date'] = $db->jdate($objd->date);
386  $file['date_due'] = $db->jdate($objd->date_due);
387  $file['paid'] = $objd->paid;
388  $file['amount_ht'] = $objd->total_ht;
389  $file['amount_ttc'] = $objd->total_ttc;
390  $file['amount_vat'] = $objd->total_vat;
391  $file['ref'] = ($objd->ref ? $objd->ref : $objd->id);
392  $file['fk'] = $objd->fk_soc;
393  $file['item'] = $objd->item;
394  $file['thirdparty_name'] = $objd->thirdparty_name;
395  $file['thirdparty_code'] = $objd->thirdparty_code;
396  $file['country_code'] = $objd->country_code;
397  $file['vatnum'] = $objd->vatnum;
398  $file['sens'] = $objd->sens;
399 
400  // Save record into array (only the first time it is found)
401  if (empty($filesarray[$file['item'].'_'.$file['id']])) {
402  $filesarray[$file['item'].'_'.$file['id']] = $file;
403  }
404 
405  // Add or concat file
406  if (empty($filesarray[$file['item'].'_'.$file['id']]['files'])) {
407  $filesarray[$file['item'].'_'.$file['id']]['files'] = array();
408  }
409  $filesarray[$file['item'].'_'.$file['id']]['files'][] = array(
410  'link' => $link.urlencode($file['name']),
411  'name'=>$file['name'],
412  'ref'=>$file['ref'],
413  'fullname' => $file['fullname'],
414  'relpath' => '/'.$file['name'],
415  'relpathnamelang' => $langs->trans($file['item']).'/'.$file['name'],
416  'modulepart' => $modulepart,
417  'subdir' => $subdir,
418  );
419  //var_dump($file['item'].'_'.$file['id']);
420  //var_dump($filesarray[$file['item'].'_'.$file['id']]['files']);
421  }
422  }
423  }
424 
425  $i++;
426  }
427  } else {
428  dol_print_error($db);
429  }
430 
431  $db->free($resd);
432  } else {
433  setEventMessages($langs->trans("ErrorSelectAtLeastOne"), null, 'errors');
434  $error++;
435  }
436  }
437 }
438 
439 
440 /*
441  *ZIP creation
442  */
443 
444 $dirfortmpfile = ($conf->accounting->dir_temp ? $conf->accounting->dir_temp : $conf->comptabilite->dir_temp);
445 if (empty($dirfortmpfile)) {
446  setEventMessages($langs->trans("ErrorNoAccountingModuleEnabled"), null, 'errors');
447  $error++;
448 }
449 
450 
451 if ($result && $action == "dl" && !$error) {
452  if (!extension_loaded('zip')) {
453  setEventMessages('PHPZIPExtentionNotLoaded', null, 'errors');
454  } else {
455  dol_mkdir($dirfortmpfile);
456 
457  $log = $langs->transnoentitiesnoconv("Type");
458  if (isModEnabled('multicompany') && is_object($mc)) {
459  $log .= ','.$langs->transnoentitiesnoconv("Entity");
460  }
461  $log .= ','.$langs->transnoentitiesnoconv("Date");
462  $log .= ','.$langs->transnoentitiesnoconv("DateDue");
463  $log .= ','.$langs->transnoentitiesnoconv("Ref");
464  $log .= ','.$langs->transnoentitiesnoconv("TotalHT");
465  $log .= ','.$langs->transnoentitiesnoconv("TotalTTC");
466  $log .= ','.$langs->transnoentitiesnoconv("TotalVAT");
467  $log .= ','.$langs->transnoentitiesnoconv("Paid");
468  $log .= ','.$langs->transnoentitiesnoconv("Document");
469  $log .= ','.$langs->transnoentitiesnoconv("ItemID");
470  $log .= ','.$langs->transnoentitiesnoconv("ThirdParty");
471  $log .= ','.$langs->transnoentitiesnoconv("Code");
472  $log .= ','.$langs->transnoentitiesnoconv("Country");
473  $log .= ','.$langs->transnoentitiesnoconv("VATIntra");
474  $log .= ','.$langs->transnoentitiesnoconv("Sens")."\n";
475  $zipname = $dirfortmpfile.'/'.dol_print_date($date_start, 'dayrfc', 'tzuserrel')."-".dol_print_date($date_stop, 'dayrfc', 'tzuserrel');
476  if (!empty($projectid)) {
477  $project = new Project($db);
478  $project->fetch($projectid);
479  if ($project->ref) {
480  $zipname .= '_'.$project->ref;
481  }
482  }
483  $zipname .='_export.zip';
484 
485  dol_delete_file($zipname);
486 
487  $zip = new ZipArchive;
488  $res = $zip->open($zipname, ZipArchive::OVERWRITE | ZipArchive::CREATE);
489  if ($res) {
490  foreach ($filesarray as $key => $file) {
491  if (!empty($file['files'])) {
492  foreach ($file['files'] as $filecursor) {
493  if (file_exists($filecursor["fullname"])) {
494  $zip->addFile($filecursor["fullname"], $filecursor["relpathnamelang"]);
495  }
496  }
497  }
498 
499  $log .= '"'.$langs->trans($file['item']).'"';
500  if (isModEnabled('multicompany') && is_object($mc)) {
501  $log .= ',"'.(empty($arrayofentities[$file['entity']]) ? $file['entity'] : $arrayofentities[$file['entity']]).'"';
502  }
503  $log .= ','.dol_print_date($file['date'], 'dayrfc');
504  $log .= ','.dol_print_date($file['date_due'], 'dayrfc');
505  $log .= ',"'.$file['ref'].'"';
506  $log .= ','.$file['amount_ht'];
507  $log .= ','.$file['amount_ttc'];
508  $log .= ','.$file['amount_vat'];
509  $log .= ','.$file['paid'];
510  $log .= ',"'.$file["name"].'"';
511  $log .= ','.$file['fk'];
512  $log .= ',"'.$file['thirdparty_name'].'"';
513  $log .= ',"'.$file['thirdparty_code'].'"';
514  $log .= ',"'.$file['country_code'].'"';
515  $log .= ',"'.$file['vatnum'].'"';
516  $log .= ',"'.$file['sens'].'"';
517  $log .= "\n";
518  }
519  $zip->addFromString('transactions.csv', $log);
520  $zip->close();
521 
522  // Then download the zipped file.
523  header('Content-Type: application/zip');
524  header('Content-disposition: attachment; filename='.basename($zipname));
525  header('Content-Length: '.filesize($zipname));
526  readfile($zipname);
527 
528  dol_delete_file($zipname);
529 
530  exit();
531  } else {
532  setEventMessages($langs->trans("FailedToOpenFile", $zipname), null, 'errors');
533  }
534  }
535 }
536 
537 
538 /*
539  * View
540  */
541 
542 $form = new form($db);
543 $formfile = new FormFile($db);
544 $userstatic = new User($db);
545 $invoice = new Facture($db);
546 $supplier_invoice = new FactureFournisseur($db);
547 $expensereport = new ExpenseReport($db);
548 $don = new Don($db);
549 $salary_payment = new PaymentSalary($db);
550 $charge_sociales = new ChargeSociales($db);
551 $various_payment = new PaymentVarious($db);
552 $payment_loan = new PaymentLoan($db);
553 
554 $title = $langs->trans("ComptaFiles").' - '.$langs->trans("List");
555 $help_url = '';
556 
557 llxHeader('', $title, $help_url);
558 
559 $h = 0;
560 $head = array();
561 $head[$h][0] = $_SERVER["PHP_SELF"];
562 $head[$h][1] = $langs->trans("AccountantFiles");
563 $head[$h][2] = 'AccountancyFiles';
564 
565 print dol_get_fiche_head($head, 'AccountancyFiles');
566 
567 
568 print '<form name="searchfiles" action="?action=searchfiles" method="POST">'."\n";
569 print '<input type="hidden" name="token" value="'.newToken().'">';
570 
571 print '<span class="opacitymedium">'.$langs->trans("ExportAccountingSourceDocHelp");
572 if (isModEnabled('accounting')) {
573  print ' '.$langs->trans("ExportAccountingSourceDocHelp2", $langs->transnoentitiesnoconv("Accounting"), $langs->transnoentitiesnoconv("Journals"));
574 }
575 print '</span><br>';
576 print '<br>';
577 
578 print $langs->trans("ReportPeriod").': ';
579 print $form->selectDate($date_start, 'date_start', 0, 0, 0, "", 1, 1, 0, '', '', '', '', 1, '', '', 'tzuserrel');
580 print ' - ';
581 print $form->selectDate($date_stop, 'date_stop', 0, 0, 0, "", 1, 1, 0, '', '', '', '', 1, '', '', 'tzuserrel');
582 print "\n";
583 
584 // Export is for current company only
585 $socid = 0;
586 if (isModEnabled('multicompany') && is_object($mc)) {
587  $mc->getInfo($conf->entity);
588  print '<span class="marginleftonly marginrightonly'.(empty($conf->global->MULTICOMPANY_ALLOW_EXPORT_ACCOUNTING_DOC_FOR_ALL_ENTITIES) ? ' opacitymedium' : '').'">('.$langs->trans("Entity").' : ';
589  print "<td>";
590  if (!empty($conf->global->MULTICOMPANY_ALLOW_EXPORT_ACCOUNTING_DOC_FOR_ALL_ENTITIES)) {
591  $socid = $mc->id;
592  print $mc->select_entities(GETPOSTISSET('search_entity') ? GETPOST('search_entity', 'int') : $mc->id, 'search_entity', '', false, false, false, false, true);
593  } else {
594  print $mc->label;
595  }
596  print "</td>";
597  print ")</span>\n";
598 }
599 
600 print '<br>';
601 
602 // Project filter
603 if (isModEnabled('projet')) {
604  $formproject = new FormProjets($db);
605  $langs->load('projects');
606  print '<span class="marginrightonly">'.$langs->trans('Project').":</span>";
607  print img_picto('', 'project').$formproject->select_projects(($socid > 0 ? $socid : -1), $projectid, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 1, 0, '');
608  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>';
609  print '<br>';
610 }
611 
612 foreach ($listofchoices as $choice => $val) {
613  if (empty($val['enabled'])) {
614  continue; // list not qualified
615  }
616  $disabled = '';
617  if (empty($val['perms'])) {
618  $disabled = ' disabled';
619  }
620  $checked = (((!GETPOSTISSET('search') && $action != 'searchfiles') || GETPOST($choice)) ? ' checked="checked"' : '');
621  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>';
622 }
623 
624 print '<input type="submit" class="button small" name="search" value="'.$langs->trans("Search").'">';
625 
626 print '</form>'."\n";
627 
628 print dol_get_fiche_end();
629 
630 $param = '';
631 if (!empty($date_start) && !empty($date_stop)) {
632  $param .= '&date_startday='.GETPOST('date_startday', 'int');
633  $param .= '&date_startmonth='.GETPOST('date_startmonth', 'int');
634  $param .= '&date_startyear='.GETPOST('date_startyear', 'int');
635  $param .= '&date_stopday='.GETPOST('date_stopday', 'int');
636  $param .= '&date_stopmonth='.GETPOST('date_stopmonth', 'int');
637  $param .= '&date_stopyear='.GETPOST('date_stopyear', 'int');
638  foreach ($listofchoices as $choice => $val) {
639  if (GETPOST($choice, 'int')) {
640  $param .= '&'.$choice.'=1';
641  }
642  }
643 
644  $TData = dol_sort_array($filesarray, $sortfield, $sortorder);
645 
646 
647  $filename = dol_print_date($date_start, 'dayrfc', 'tzuserrel')."-".dol_print_date($date_stop, 'dayrfc', 'tzuserrel').'_export.zip';
648 
649  echo dol_print_date($date_start, 'day', 'tzuserrel')." - ".dol_print_date($date_stop, 'day', 'tzuserrel');
650 
651  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.'"';
652  if (empty($TData)) {
653  print " disabled";
654  }
655  print '>'."\n";
656  print $langs->trans("Download");
657  print '</a><br>';
658 
659  $param .= '&action=searchfiles';
660 
661  /*
662  print '<input type="hidden" name="token" value="'.currentToken().'">';
663  print '<input type="hidden" name="date_startday" value="'.GETPOST('date_startday', 'int').'" />';
664  print '<input type="hidden" name="date_startmonth" value="'.GETPOST('date_startmonth', 'int').'" />';
665  print '<input type="hidden" name="date_startyear" value="'.GETPOST('date_startyear', 'int').'" />';
666  print '<input type="hidden" name="date_stopday" value="'.GETPOST('date_stopday', 'int').'" />';
667  print '<input type="hidden" name="date_stopmonth" value="'.GETPOST('date_stopmonth', 'int').'" />';
668  print '<input type="hidden" name="date_stopyear" value="'.GETPOST('date_stopyear', 'int').'" />';
669  foreach ($listofchoices as $choice => $val) {
670  print '<input type="hidden" name="'.$choice.'" value="'.GETPOST($choice).'">';
671  }
672 
673  print '<input class="butAction butDownload small marginleftonly" type="submit" value="'.$langs->trans("Download").'"';
674  if (empty($TData)) {
675  print " disabled";
676  }
677  print '/>';
678  print '</form>'."\n";
679  */
680 
681  print '<br>';
682 
683  print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
684  print '<table class="noborder centpercent">';
685  print '<tr class="liste_titre">';
686  print_liste_field_titre($arrayfields['type']['label'], $_SERVER["PHP_SELF"], "item", "", $param, '', $sortfield, $sortorder, 'nowrap ');
687  print_liste_field_titre($arrayfields['date']['label'], $_SERVER["PHP_SELF"], "date", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
688  print_liste_field_titre($arrayfields['date_due']['label'], $_SERVER["PHP_SELF"], "date_due", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
689  print_liste_field_titre($arrayfields['ref']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'nowraponall ');
690  print '<td>'.$langs->trans("Document").'</td>';
691  print '<td>'.$langs->trans("Paid").'</td>';
692  print '<td align="right">'.$langs->trans("TotalHT").(isModEnabled('multicurrency') ? ' ('.$conf->currency.')' : '').'</td>';
693  print '<td align="right">'.$langs->trans("TotalTTC").(isModEnabled('multicurrency') ? ' ('.$conf->currency.')' : '').'</td>';
694  print '<td align="right">'.$langs->trans("TotalVAT").(isModEnabled('multicurrency') ? ' ('.$conf->currency.')' : '').'</td>';
695  print '<td>'.$langs->trans("ThirdParty").'</td>';
696  print '<td class="center">'.$langs->trans("Code").'</td>';
697  print '<td class="center">'.$langs->trans("Country").'</td>';
698  print '<td class="center">'.$langs->trans("VATIntra").'</td>';
699  if (isModEnabled('multicurrency')) {
700  print '<td class="center">'.$langs->trans("Currency").'</td>';
701  }
702  print '</tr>';
703 
704  if (empty($TData)) {
705  print '<tr class="oddeven"><td colspan="13"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td>';
706  if (isModEnabled('multicurrency')) {
707  print '<td></td>';
708  }
709  print '</tr>';
710  } else {
711  // Sort array by date ASC to calculate balance
712 
713  $totalET_debit = 0;
714  $totalIT_debit = 0;
715  $totalVAT_debit = 0;
716  $totalET_credit = 0;
717  $totalIT_credit = 0;
718  $totalVAT_credit = 0;
719 
720  // Display array
721  foreach ($TData as $data) {
722  $html_class = '';
723  //if (!empty($data['fk_facture'])) $html_class = 'facid-'.$data['fk_facture'];
724  //elseif (!empty($data['fk_paiement'])) $html_class = 'payid-'.$data['fk_paiement'];
725  print '<tr class="oddeven '.$html_class.'">';
726 
727  // Type
728  print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($langs->trans($data['item'])).'">'.$langs->trans($data['item']).'</td>';
729 
730  // Date
731  print '<td class="center">';
732  print dol_print_date($data['date'], 'day');
733  print "</td>\n";
734 
735  // Date due
736  print '<td class="center">';
737  print dol_print_date($data['date_due'], 'day');
738  print "</td>\n";
739 
740  // Ref
741  print '<td class="nowraponall tdoverflowmax150">';
742 
743  if ($data['item'] == 'Invoice') {
744  $invoice->id = $data['id'];
745  $invoice->ref = $data['ref'];
746  $invoice->total_ht = $data['amount_ht'];
747  $invoice->total_ttc = $data['amount_ttc'];
748  $invoice->total_tva = $data['amount_vat'];
749  $invoice->multicurrency_code = $data['currency'];
750  print $invoice->getNomUrl(1, '', 0, 0, '', 0, 0, 0);
751  } elseif ($data['item'] == 'SupplierInvoice') {
752  $supplier_invoice->id = $data['id'];
753  $supplier_invoice->ref = $data['ref'];
754  $supplier_invoice->total_ht = $data['amount_ht'];
755  $supplier_invoice->total_ttc = $data['amount_ttc'];
756  $supplier_invoice->total_tva = $data['amount_vat'];
757  $supplier_invoice->multicurrency_code = $data['currency'];
758  print $supplier_invoice->getNomUrl(1, '', 0, 0, '', 0, 0, 0);
759  } elseif ($data['item'] == 'ExpenseReport') {
760  $expensereport->id = $data['id'];
761  $expensereport->ref = $data['ref'];
762  print $expensereport->getNomUrl(1, 0, 0, '', 0, 0);
763  } elseif ($data['item'] == 'SalaryPayment') {
764  $salary_payment->id = $data['id'];
765  $salary_payment->ref = $data['ref'];
766  print $salary_payment->getNomUrl(1);
767  } elseif ($data['item'] == 'Donation') {
768  $don->id = $data['id'];
769  $don->ref = $data['ref'];
770  print $don->getNomUrl(1, 0, '', 0);
771  } elseif ($data['item'] == 'SocialContributions') {
772  $charge_sociales->id = $data['id'];
773  $charge_sociales->ref = $data['ref'];
774  print $charge_sociales->getNomUrl(1, 0, 0, 0, 0);
775  } elseif ($data['item'] == 'VariousPayment') {
776  $various_payment->id = $data['id'];
777  $various_payment->ref = $data['ref'];
778  print $various_payment->getNomUrl(1, '', 0, 0);
779  } elseif ($data['item'] == 'LoanPayment') {
780  $payment_loan->id = $data['id'];
781  $payment_loan->ref = $data['ref'];
782  print $payment_loan->getNomUrl(1, 0, 0, '', 0);
783  } else {
784  print $data['ref'];
785  }
786  print '</td>';
787 
788  // File link
789  print '<td class="tdoverflowmax150">';
790  if (!empty($data['files'])) {
791  foreach ($data['files'] as $id => $filecursor) {
792  $tmppreview = $formfile->showPreview($filecursor, $filecursor['modulepart'], $filecursor['subdir'].'/'.$filecursor['name'], 0);
793  if ($tmppreview) {
794  print $tmppreview;
795  }
796  $filename = ($filecursor['name'] ? $filecursor['name'] : $filecursor['ref']);
797  print '<a href='.DOL_URL_ROOT.'/'.$filecursor['link'].' target="_blank" rel="noopener noreferrer" title="'.dol_escape_htmltag($filename).'">';
798  if (empty($tmppreview)) {
799  print img_picto('', 'generic', '', false, 0, 0, '', 'pictonopreview pictofixedwidth paddingright');
800  }
801  print $filename;
802  print '</a><br>';
803  }
804  }
805  print "</td>\n";
806 
807  // Paid
808  print '<td class="center">'.($data['paid'] ? yn($data['paid']) : '').'</td>';
809 
810  // Total ET
811  print '<td align="right"><span class="amount">'.price(price2num($data['sens'] ? $data['amount_ht'] : -$data['amount_ht'], 'MT'))."</span></td>\n";
812  // Total IT
813  print '<td align="right"><span class="amount">'.price(price2num($data['sens'] ? $data['amount_ttc'] : -$data['amount_ttc'], 'MT'))."</span></td>\n";
814  // Total VAT
815  print '<td align="right"><span class="amount">'.price(price2num($data['sens'] ? $data['amount_vat'] : -$data['amount_vat'], 'MT'))."</span></td>\n";
816 
817  print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($data['thirdparty_name']).'">'.dol_escape_htmltag($data['thirdparty_name'])."</td>\n";
818 
819  print '<td class="center">'.$data['thirdparty_code']."</td>\n";
820 
821  print '<td class="center">'.$data['country_code']."</td>\n";
822 
823  // VAT number
824  print '<td class="tdoverflowmax150 right" title="'.dol_escape_htmltag($data['vatnum']).'">'.dol_escape_htmltag($data['vatnum'])."</td>\n";
825 
826  if ($data['sens']) {
827  $totalET_credit += $data['amount_ht'];
828  $totalIT_credit += $data['amount_ttc'];
829  $totalVAT_credit += $data['amount_vat'];
830  } else {
831  $totalET_debit -= $data['amount_ht'];
832  $totalIT_debit -= $data['amount_ttc'];
833  $totalVAT_debit -= $data['amount_vat'];
834  }
835 
836  if (isModEnabled('multicurrency')) {
837  print '<td class="center">'.$data['currency']."</td>\n";
838  }
839 
840  print "</tr>\n";
841  }
842 
843  // Total credits
844  print '<tr class="liste_total">';
845  print '<td colspan="6" class="right">'.$langs->trans('Total').' '.$langs->trans('Income').'</td>';
846  print '<td align="right">'.price(price2num($totalET_credit, 'MT')).'</td>';
847  print '<td align="right">'.price(price2num($totalIT_credit, 'MT')).'</td>';
848  print '<td align="right">'.price(price2num($totalVAT_credit, 'MT')).'</td>';
849  print '<td colspan="4"></td>';
850  if (isModEnabled('multicurrency')) {
851  print '<td></td>';
852  }
853  print "</tr>\n";
854  // Total debits
855  print '<tr class="liste_total">';
856  print '<td colspan="6" class="right">'.$langs->trans('Total').' '.$langs->trans('Outcome').'</td>';
857  print '<td align="right">'.price(price2num($totalET_debit, 'MT')).'</td>';
858  print '<td align="right">'.price(price2num($totalIT_debit, 'MT')).'</td>';
859  print '<td align="right">'.price(price2num($totalVAT_debit, 'MT')).'</td>';
860  print '<td colspan="4"></td>';
861  if (isModEnabled('multicurrency')) {
862  print '<td></td>';
863  }
864  print "</tr>\n";
865  // Balance
866  print '<tr class="liste_total">';
867  print '<td colspan="6" class="right">'.$langs->trans('Total').'</td>';
868  print '<td align="right">'.price(price2num($totalET_credit + $totalET_debit, 'MT')).'</td>';
869  print '<td align="right">'.price(price2num($totalIT_credit + $totalIT_debit, 'MT')).'</td>';
870  print '<td align="right">'.price(price2num($totalVAT_credit + $totalVAT_debit, 'MT')).'</td>';
871  print '<td colspan="4"></td>';
872  if (isModEnabled('multicurrency')) {
873  print '<td></td>';
874  }
875  print "</tr>\n";
876  }
877 
878  print "</table>";
879  print '</div>';
880 }
881 
882 
883 llxFooter();
884 $db->close();
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:118
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:56
llxFooter()
Empty footer.
Definition: wrapper.php:70
Classe permettant la gestion des paiements des charges La tva collectee n'est calculee que sur les fa...
Class to manage donations.
Definition: don.class.php:39
Class to manage Trips and Expenses.
Class to manage suppliers invoices.
Class to manage invoices.
Class to offer components to list and upload files.
Class to manage building of HTML components.
Class to manage payments of loans.
Class to manage payments of salaries.
Class to manage various payments.
Class to manage projects.
Class to manage Dolibarr users.
Definition: user.class.php:45
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
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:1250
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.
Definition: files.lib.php:61
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.