dolibarr  16.0.5
list.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2002-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2019 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2005-2013 Regis Houssin <regis.houssin@inodbox.com>
5  * Copyright (C) 2013-2019 Philippe Grand <philippe.grand@atoo-net.com>
6  * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
7  * Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
8  * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
9  * Copyright (C) 2015-2007 Juanjo Menent <jmenent@2byte.es>
10  * Copyright (C) 2015 Abbes Bahfir <bafbes@gmail.com>
11  * Copyright (C) 2015-2016 Ferran Marcet <fmarcet@2byte.es>
12  * Copyright (C) 2017 Josep Lluís Amador <joseplluis@lliuretic.cat>
13  * Copyright (C) 2018 Charlene Benke <charlie@patas-monkey.com>
14  * Copyright (C) 2018-2020 Frédéric France <frederic.france@netlogic.fr>
15  * Copyright (C) 2019-2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
16  *
17  * This program is free software; you can redistribute it and/or modify
18  * it under the terms of the GNU General Public License as published by
19  * the Free Software Foundation; either version 3 of the License, or
20  * (at your option) any later version.
21  *
22  * This program is distributed in the hope that it will be useful,
23  * but WITHOUT ANY WARRANTY; without even the implied warranty of
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25  * GNU General Public License for more details.
26  *
27  * You should have received a copy of the GNU General Public License
28  * along with this program. If not, see <https://www.gnu.org/licenses/>.
29  */
30 
37 require '../../main.inc.php';
38 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
39 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
40 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
41 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
42 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
43 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php';
44 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
45 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
46 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
47 
48 // Load translation files required by the page
49 $langs->loadLangs(array('products', 'bills', 'companies', 'projects'));
50 
51 $action = GETPOST('action', 'aZ09');
52 $massaction = GETPOST('massaction', 'alpha');
53 $show_files = GETPOST('show_files', 'int');
54 $confirm = GETPOST('confirm', 'alpha');
55 $toselect = GETPOST('toselect', 'array');
56 $optioncss = GETPOST('optioncss', 'alpha');
57 $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'supplierinvoicelist';
58 
59 $socid = GETPOST('socid', 'int');
60 
61 // Security check
62 if ($user->socid > 0) {
63  $action = '';
64  $_GET["action"] = '';
65  $socid = $user->socid;
66 }
67 
68 $mode = GETPOST("mode", 'aZ09');
69 
70 $search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
71 $search_label = GETPOST("search_label", "alpha");
72 $search_amount_no_tax = GETPOST("search_amount_no_tax", "alpha");
73 $search_amount_all_tax = GETPOST("search_amount_all_tax", "alpha");
74 $search_product_category = GETPOST('search_product_category', 'int');
75 $search_ref = GETPOST('sf_ref') ?GETPOST('sf_ref', 'alpha') : GETPOST('search_ref', 'alpha');
76 $search_refsupplier = GETPOST('search_refsupplier', 'alpha');
77 $search_type = GETPOST('search_type', 'int');
78 $search_project = GETPOST('search_project', 'alpha');
79 $search_company = GETPOST('search_company', 'alpha');
80 $search_montant_ht = GETPOST('search_montant_ht', 'alpha');
81 $search_montant_vat = GETPOST('search_montant_vat', 'alpha');
82 $search_montant_localtax1 = GETPOST('search_montant_localtax1', 'alpha');
83 $search_montant_localtax2 = GETPOST('search_montant_localtax2', 'alpha');
84 $search_montant_ttc = GETPOST('search_montant_ttc', 'alpha');
85 $search_login = GETPOST('search_login', 'alpha');
86 $search_multicurrency_code = GETPOST('search_multicurrency_code', 'alpha');
87 $search_multicurrency_tx = GETPOST('search_multicurrency_tx', 'alpha');
88 $search_multicurrency_montant_ht = GETPOST('search_multicurrency_montant_ht', 'alpha');
89 $search_multicurrency_montant_vat = GETPOST('search_multicurrency_montant_vat', 'alpha');
90 $search_multicurrency_montant_ttc = GETPOST('search_multicurrency_montant_ttc', 'alpha');
91 $search_status = GETPOST('search_status', 'int');
92 $search_paymentmode = GETPOST('search_paymentmode', 'int');
93 $search_paymentcond = GETPOST('search_paymentcond', 'int');
94 $search_town = GETPOST('search_town', 'alpha');
95 $search_zip = GETPOST('search_zip', 'alpha');
96 $search_state = GETPOST("search_state");
97 $search_country = GETPOST("search_country", 'int');
98 $search_type_thirdparty = GETPOST("search_type_thirdparty", 'int');
99 $search_user = GETPOST('search_user', 'int');
100 $search_sale = GETPOST('search_sale', 'int');
101 $search_date_startday = GETPOST('search_date_startday', 'int');
102 $search_date_startmonth = GETPOST('search_date_startmonth', 'int');
103 $search_date_startyear = GETPOST('search_date_startyear', 'int');
104 $search_date_endday = GETPOST('search_date_endday', 'int');
105 $search_date_endmonth = GETPOST('search_date_endmonth', 'int');
106 $search_date_endyear = GETPOST('search_date_endyear', 'int');
107 $search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver
108 $search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
109 $search_datelimit_startday = GETPOST('search_datelimit_startday', 'int');
110 $search_datelimit_startmonth = GETPOST('search_datelimit_startmonth', 'int');
111 $search_datelimit_startyear = GETPOST('search_datelimit_startyear', 'int');
112 $search_datelimit_endday = GETPOST('search_datelimit_endday', 'int');
113 $search_datelimit_endmonth = GETPOST('search_datelimit_endmonth', 'int');
114 $search_datelimit_endyear = GETPOST('search_datelimit_endyear', 'int');
115 $search_datelimit_start = dol_mktime(0, 0, 0, $search_datelimit_startmonth, $search_datelimit_startday, $search_datelimit_startyear);
116 $search_datelimit_end = dol_mktime(23, 59, 59, $search_datelimit_endmonth, $search_datelimit_endday, $search_datelimit_endyear);
117 $toselect = GETPOST('toselect', 'array');
118 $search_btn = GETPOST('button_search', 'alpha');
119 $search_remove_btn = GETPOST('button_removefilter', 'alpha');
120 $search_categ_sup = trim(GETPOST("search_categ_sup", 'int'));
121 
122 $option = GETPOST('search_option');
123 if ($option == 'late') {
124  $search_status = '1';
125 }
126 $filter = GETPOST('filtre', 'alpha');
127 
128 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
129 $sortfield = GETPOST('sortfield', 'aZ09comma');
130 $sortorder = GETPOST('sortorder', 'aZ09comma');
131 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
132 if ($page == -1 || $page == null || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction === '0')) {
133  $page = 0;
134 }
135 $offset = $limit * $page;
136 $pageprev = $page - 1;
137 $pagenext = $page + 1;
138 if (!$sortorder) {
139  $sortorder = "DESC";
140 }
141 if (!$sortfield) {
142  $sortfield = "f.datef,f.rowid";
143 }
144 
145 $diroutputmassaction = $conf->fournisseur->facture->dir_output.'/temp/massgeneration/'.$user->id;
146 
147 $now = dol_now();
148 
149 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
150 $object = new FactureFournisseur($db);
151 $hookmanager->initHooks(array('supplierinvoicelist'));
152 $extrafields = new ExtraFields($db);
153 
154 // fetch optionals attributes and labels
155 $extrafields->fetch_name_optionals_label($object->table_element);
156 
157 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
158 
159 // List of fields to search into when doing a "search in all"
160 $fieldstosearchall = array(
161  'f.ref'=>'Ref',
162  'f.ref_supplier'=>'RefSupplier',
163  'pd.description'=>'Description',
164  's.nom'=>"ThirdParty",
165  'f.note_public'=>'NotePublic',
166 );
167 if (empty($user->socid)) {
168  $fieldstosearchall["f.note_private"] = "NotePrivate";
169 }
170 
171 $checkedtypetiers = 0;
172 $arrayfields = array(
173  'f.ref'=>array('label'=>"Ref", 'checked'=>1),
174  'f.ref_supplier'=>array('label'=>"RefSupplier", 'checked'=>1),
175  'f.type'=>array('label'=>"Type", 'checked'=>0),
176  'f.label'=>array('label'=>"Label", 'checked'=>0),
177  'f.datef'=>array('label'=>"DateInvoice", 'checked'=>1),
178  'f.date_lim_reglement'=>array('label'=>"DateDue", 'checked'=>1),
179  'p.ref'=>array('label'=>"ProjectRef", 'checked'=>0),
180  's.nom'=>array('label'=>"ThirdParty", 'checked'=>1),
181  's.town'=>array('label'=>"Town", 'checked'=>-1),
182  's.zip'=>array('label'=>"Zip", 'checked'=>1),
183  'state.nom'=>array('label'=>"StateShort", 'checked'=>0),
184  'country.code_iso'=>array('label'=>"Country", 'checked'=>0),
185  'typent.code'=>array('label'=>"ThirdPartyType", 'checked'=>$checkedtypetiers),
186  'f.fk_cond_reglement'=>array('label'=>"PaymentTerm", 'checked'=>1, 'position'=>50),
187  'f.fk_mode_reglement'=>array('label'=>"PaymentMode", 'checked'=>1, 'position'=>52),
188  'f.total_ht'=>array('label'=>"AmountHT", 'checked'=>1, 'position'=>105),
189  'f.total_vat'=>array('label'=>"AmountVAT", 'checked'=>0, 'position'=>110),
190  'f.total_localtax1'=>array('label'=>$langs->transcountry("AmountLT1", $mysoc->country_code), 'checked'=>0, 'enabled'=>$mysoc->localtax1_assuj == "1", 'position'=>95),
191  'f.total_localtax2'=>array('label'=>$langs->transcountry("AmountLT2", $mysoc->country_code), 'checked'=>0, 'enabled'=>$mysoc->localtax2_assuj == "1", 'position'=>100),
192  'f.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>0, 'position'=>115),
193  'u.login'=>array('label'=>"Author", 'checked'=>1),
194  'dynamount_payed'=>array('label'=>"Paid", 'checked'=>0),
195  'rtp'=>array('label'=>"Rest", 'checked'=>0),
196  'f.multicurrency_code'=>array('label'=>'Currency', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
197  'f.multicurrency_tx'=>array('label'=>'CurrencyRate', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
198  'f.multicurrency_total_ht'=>array('label'=>'MulticurrencyAmountHT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
199  'f.multicurrency_total_vat'=>array('label'=>'MulticurrencyAmountVAT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
200  'f.multicurrency_total_ttc'=>array('label'=>'MulticurrencyAmountTTC', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
201  'multicurrency_dynamount_payed'=>array('label'=>'MulticurrencyAlreadyPaid', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
202  'multicurrency_rtp'=>array('label'=>'MulticurrencyRemainderToPay', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)), // Not enabled by default because slow
203  'f.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500),
204  'f.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500),
205  'f.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000),
206 );
207 // Extra fields
208 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
209 
210 $object->fields = dol_sort_array($object->fields, 'position');
211 $arrayfields = dol_sort_array($arrayfields, 'position');
212 
213 if ((empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD))
214  || (empty($conf->supplier_invoice->enabled) && !empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD))) {
215  accessforbidden();
216 }
217 if ((empty($user->rights->fournisseur->facture->lire) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD))
218  || (empty($user->rights->supplier_invoice->lire) && !empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD))) {
219  accessforbidden();
220 }
221 
222 
223 
224 /*
225  * Actions
226  */
227 
228 if (GETPOST('cancel', 'alpha')) {
229  $action = 'list'; $massaction = '';
230 }
231 if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
232  $massaction = '';
233 }
234 
235 $parameters = array('socid'=>$socid);
236 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
237 if ($reshook < 0) {
238  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
239 }
240 
241 if (empty($reshook)) {
242  include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
243 
244  if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha') || GETPOST('button_removefilter.x', 'alpha')) { // All tests must be present to be compatible with all browsers
245  $search_all = "";
246  $search_user = '';
247  $search_sale = '';
248  $search_product_category = '';
249  $search_ref = "";
250  $search_refsupplier = "";
251  $search_type = "";
252  $search_label = "";
253  $search_project = '';
254  $search_company = "";
255  $search_amount_no_tax = "";
256  $search_amount_all_tax = "";
257  $search_montant_ht = '';
258  $search_montant_vat = '';
259  $search_montant_localtax1 = '';
260  $search_montant_localtax2 = '';
261  $search_montant_ttc = '';
262  $search_login = '';
263  $search_multicurrency_code = '';
264  $search_multicurrency_tx = '';
265  $search_multicurrency_montant_ht = '';
266  $search_multicurrency_montant_vat = '';
267  $search_multicurrency_montant_ttc = '';
268  $search_status = '';
269  $search_paymentmode = '';
270  $search_paymentcond = '';
271  $search_town = '';
272  $search_zip = "";
273  $search_state = "";
274  $search_type = '';
275  $search_country = '';
276  $search_type_thirdparty = '';
277  $search_date_startday = '';
278  $search_date_startmonth = '';
279  $search_date_startyear = '';
280  $search_date_endday = '';
281  $search_date_endmonth = '';
282  $search_date_endyear = '';
283  $search_date_start = '';
284  $search_date_end = '';
285  $search_datelimit_startday = '';
286  $search_datelimit_startmonth = '';
287  $search_datelimit_startyear = '';
288  $search_datelimit_endday = '';
289  $search_datelimit_endmonth = '';
290  $search_datelimit_endyear = '';
291  $search_datelimit_start = '';
292  $search_datelimit_end = '';
293  $toselect = array();
294  $search_array_options = array();
295  $filter = '';
296  $option = '';
297  $socid = "";
298  $search_categ_sup = 0;
299  }
300 
301  // Mass actions
302  $objectclass = 'FactureFournisseur';
303  $objectlabel = 'SupplierInvoices';
304  $permissiontoread = ($user->rights->fournisseur->facture->lire || $user->rights->supplier_invoice->lire);
305  $permissiontoadd = ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer);
306  $permissiontodelete = ($user->rights->fournisseur->facture->supprimer || $user->rights->supplier_invoice->supprimer);
307  $uploaddir = $conf->fournisseur->facture->dir_output;
308  include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
309 
310  if ($massaction == 'banktransfertrequest') {
311  $langs->load("withdrawals");
312 
313  if (!$user->rights->paymentbybanktransfer->create) {
314  $error++;
315  setEventMessages($langs->trans("NotEnoughPermissions"), null, 'errors');
316  } else {
317  //Checking error
318  $error = 0;
319 
320  $arrayofselected = is_array($toselect) ? $toselect : array();
321  $listofbills = array();
322  foreach ($arrayofselected as $toselectid) {
323  $objecttmp = new FactureFournisseur($db);
324  $result = $objecttmp->fetch($toselectid);
325  if ($result > 0) {
326  $totalpaid = $objecttmp->getSommePaiement();
327  $totalcreditnotes = $objecttmp->getSumCreditNotesUsed();
328  $totaldeposits = $objecttmp->getSumDepositsUsed();
329  $objecttmp->resteapayer = price2num($objecttmp->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits, 'MT');
330  if ($objecttmp->statut == FactureFournisseur::STATUS_DRAFT) {
331  $error++;
332  setEventMessages($objecttmp->ref.' '.$langs->trans("Draft"), $objecttmp->errors, 'errors');
333  } elseif ($objecttmp->paye || $objecttmp->resteapayer == 0) {
334  $error++;
335  setEventMessages($objecttmp->ref.' '.$langs->trans("AlreadyPaid"), $objecttmp->errors, 'errors');
336  } elseif ($objecttmp->resteapayer < 0) {
337  $error++;
338  setEventMessages($objecttmp->ref.' '.$langs->trans("AmountMustBePositive"), $objecttmp->errors, 'errors');
339  }
340 
341  $rsql = "SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande";
342  $rsql .= " , pfd.date_traite as date_traite";
343  $rsql .= " , pfd.amount";
344  $rsql .= " , u.rowid as user_id, u.lastname, u.firstname, u.login";
345  $rsql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
346  $rsql .= " , ".MAIN_DB_PREFIX."user as u";
347  $rsql .= " WHERE fk_facture_fourn = ".((int) $objecttmp->id);
348  $rsql .= " AND pfd.fk_user_demande = u.rowid";
349  $rsql .= " AND pfd.traite = 0";
350  $rsql .= " ORDER BY pfd.date_demande DESC";
351 
352  $result_sql = $db->query($rsql);
353  if ($result_sql) {
354  $numprlv = $db->num_rows($result_sql);
355  }
356 
357  if ($numprlv > 0) {
358  $error++;
359  setEventMessages($objecttmp->ref.' '.$langs->trans("RequestAlreadyDone"), $objecttmp->errors, 'warnings');
360  } elseif (!empty($objecttmp->mode_reglement_code) && $objecttmp->mode_reglement_code != 'VIR') {
361  $error++;
362  setEventMessages($objecttmp->ref.' '.$langs->trans("BadPaymentMethod"), $objecttmp->errors, 'errors');
363  } else {
364  $listofbills[] = $objecttmp; // $listofbills will only contains invoices with good payment method and no request already done
365  }
366  }
367  }
368 
369  // Massive withdraw request for request with no errors
370  if (!empty($listofbills)) {
371  $nbwithdrawrequestok = 0;
372  foreach ($listofbills as $aBill) {
373  $db->begin();
374  $result = $aBill->demande_prelevement($user, $aBill->resteapayer, 'bank-transfer', 'supplier_invoice');
375  if ($result > 0) {
376  $db->commit();
377  $nbwithdrawrequestok++;
378  } else {
379  $db->rollback();
380  setEventMessages($aBill->error, $aBill->errors, 'errors');
381  }
382  }
383  if ($nbwithdrawrequestok > 0) {
384  setEventMessages($langs->trans("WithdrawRequestsDone", $nbwithdrawrequestok), null, 'mesgs');
385  }
386  }
387  }
388  }
389 }
390 
391 
392 /*
393  * View
394  */
395 
396 $form = new Form($db);
397 $formother = new FormOther($db);
398 $formfile = new FormFile($db);
399 $bankaccountstatic = new Account($db);
400 $facturestatic = new FactureFournisseur($db);
401 $formcompany = new FormCompany($db);
402 $thirdparty = new Societe($db);
403 
404 // llxHeader('',$langs->trans("SuppliersInvoices"),'EN:Suppliers_Invoices|FR:FactureFournisseur|ES:Facturas_de_proveedores');
405 
406 $sql = "SELECT";
407 if ($search_all || $search_product_category > 0) {
408  $sql = 'SELECT DISTINCT';
409 }
410 $sql .= " f.rowid as facid, f.ref, f.ref_supplier, f.type, f.datef, f.date_lim_reglement as datelimite, f.fk_mode_reglement, f.fk_cond_reglement,";
411 $sql .= " f.total_ht, f.total_ttc, f.total_tva as total_vat, f.paye as paye, f.fk_statut as fk_statut, f.libelle as label, f.datec as date_creation, f.tms as date_update,";
412 $sql .= " f.localtax1 as total_localtax1, f.localtax2 as total_localtax2,";
413 $sql .= ' f.fk_multicurrency, f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva as multicurrency_total_vat, f.multicurrency_total_ttc,';
414 $sql .= " f.note_public, f.note_private,";
415 $sql .= " f.fk_user_author,";
416 $sql .= " s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta as code_compta_client, s.code_compta_fournisseur,";
417 $sql .= " typent.code as typent_code,";
418 $sql .= " state.code_departement as state_code, state.nom as state_name,";
419 $sql .= " country.code as country_code,";
420 $sql .= " p.rowid as project_id, p.ref as project_ref, p.title as project_label,";
421 $sql .= ' u.login, u.lastname, u.firstname, u.email as user_email, u.statut as user_statut, u.entity, u.photo, u.office_phone, u.office_fax, u.user_mobile, u.job, u.gender';
422 if ($search_categ_sup && $search_categ_sup != '-1') {
423  $sql .= ", cs.fk_categorie, cs.fk_soc";
424 }
425 // We need dynamount_payed to be able to sort on status (value is surely wrong because we can count several lines several times due to other left join or link with contacts. But what we need is just 0 or > 0)
426 // TODO Better solution to be able to sort on already payed or remain to pay is to store amount_payed in a denormalized field.
427 if (!$search_all) {
428  $sql .= ', SUM(pf.amount) as dynamount_payed';
429 }
430 // Add fields from extrafields
431 if (!empty($extrafields->attributes[$object->table_element]['label'])) {
432  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
433  $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
434  }
435 }
436 // Add fields from hooks
437 $parameters = array();
438 $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
439 $sql .= $hookmanager->resPrint;
440 $sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s';
441 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)";
442 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)";
443 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)";
444 if (!empty($search_categ_sup) && $search_categ_supplier != '-1') {
445  $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_fournisseur as cs ON s.rowid = cs.fk_soc";
446 }
447 
448 $sql .= ', '.MAIN_DB_PREFIX.'facture_fourn as f';
449 if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
450  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (f.rowid = ef.fk_object)";
451 }
452 if (!$search_all) {
453  $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.rowid';
454 }
455 if ($search_all || $search_product_category > 0) {
456  $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn_det as pd ON f.rowid=pd.fk_facture_fourn';
457 }
458 if ($search_product_category > 0) {
459  $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product';
460 }
461 $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user AS u ON f.fk_user_author = u.rowid';
462 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = f.fk_projet";
463 // We'll need this table joined to the select in order to filter by sale
464 if ($search_sale > 0 || (empty($user->rights->societe->client->voir) && !$socid)) {
465  $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
466 }
467 if ($search_user > 0) {
468  $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec";
469  $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as tc";
470 }
471 // Add table from hooks
472 $parameters = array();
473 $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
474 $sql .= $hookmanager->resPrint;
475 $sql .= ' WHERE f.fk_soc = s.rowid';
476 $sql .= ' AND f.entity IN ('.getEntity('facture_fourn').')';
477 if (empty($user->rights->societe->client->voir) && !$socid) {
478  $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
479 }
480 if ($search_product_category > 0) {
481  $sql .= " AND cp.fk_categorie = ".((int) $search_product_category);
482 }
483 if ($socid > 0) {
484  $sql .= ' AND s.rowid = '.((int) $socid);
485 }
486 if ($search_ref) {
487  if (is_numeric($search_ref)) {
488  $sql .= natural_search(array('f.ref'), $search_ref);
489  } else {
490  $sql .= natural_search('f.ref', $search_ref);
491  }
492 }
493 if ($search_ref) {
494  $sql .= natural_search('f.ref', $search_ref);
495 }
496 if ($search_refsupplier) {
497  $sql .= natural_search('f.ref_supplier', $search_refsupplier);
498 }
499 if ($search_type != '' && $search_type >= 0) {
500  if ($search_type == '0') {
501  $sql .= " AND f.type = 0"; // standard
502  }
503  if ($search_type == '1') {
504  $sql .= " AND f.type = 1"; // replacement
505  }
506  if ($search_type == '2') {
507  $sql .= " AND f.type = 2"; // credit note
508  }
509  if ($search_type == '3') {
510  $sql .= " AND f.type = 3"; // deposit
511  }
512  //if ($search_type == '4') $sql.=" AND f.type = 4"; // proforma
513  //if ($search_type == '5') $sql.=" AND f.type = 5"; // situation
514 }
515 if ($search_project) {
516  $sql .= natural_search('p.ref', $search_project);
517 }
518 if ($search_company) {
519  $sql .= natural_search('s.nom', $search_company);
520 }
521 if ($search_town) {
522  $sql .= natural_search('s.town', $search_town);
523 }
524 if ($search_zip) {
525  $sql .= natural_search("s.zip", $search_zip);
526 }
527 if ($search_state) {
528  $sql .= natural_search("state.nom", $search_state);
529 }
530 if ($search_country) {
531  $sql .= " AND s.fk_pays IN (".$db->sanitize($search_country).')';
532 }
533 if ($search_type_thirdparty != '' && $search_type_thirdparty >= 0) {
534  $sql .= " AND s.fk_typent IN (".$db->sanitize($search_type_thirdparty).')';
535 }
536 if ($search_montant_ht != '') {
537  $sql .= natural_search('f.total_ht', $search_montant_ht, 1);
538 }
539 if ($search_montant_vat != '') {
540  $sql .= natural_search('f.total_tva', $search_montant_vat, 1);
541 }
542 if ($search_montant_localtax1 != '') {
543  $sql .= natural_search('f.localtax1', $search_montant_localtax1, 1);
544 }
545 if ($search_montant_localtax2 != '') {
546  $sql .= natural_search('f.localtax2', $search_montant_localtax2, 1);
547 }
548 if ($search_montant_ttc != '') {
549  $sql .= natural_search('f.total_ttc', $search_montant_ttc, 1);
550 }
551 if ($search_multicurrency_code != '') {
552  $sql .= " AND f.multicurrency_code = '".$db->escape($search_multicurrency_code)."'";
553 }
554 if ($search_multicurrency_tx != '') {
555  $sql .= natural_search('f.multicurrency_tx', $search_multicurrency_tx, 1);
556 }
557 if ($search_multicurrency_montant_ht != '') {
558  $sql .= natural_search('f.multicurrency_total_ht', $search_multicurrency_montant_ht, 1);
559 }
560 if ($search_multicurrency_montant_vat != '') {
561  $sql .= natural_search('f.multicurrency_total_tva', $search_multicurrency_montant_vat, 1);
562 }
563 if ($search_multicurrency_montant_ttc != '') {
564  $sql .= natural_search('f.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1);
565 }
566 if ($search_login) {
567  $sql .= natural_search(array('u.lastname', 'u.firstname', 'u.login'), $search_login);
568 }
569 if ($search_status != '' && $search_status >= 0) {
570  $sql .= " AND f.fk_statut = ".((int) $search_status);
571 }
572 if ($search_paymentmode > 0) {
573  $sql .= " AND f.fk_mode_reglement = ".((int) $search_paymentmode);
574 }
575 if ($search_paymentcond > 0) {
576  $sql .= " AND f.fk_cond_reglement = ".((int) $search_paymentcond);
577 }
578 if ($search_date_start) {
579  $sql .= " AND f.datef >= '" . $db->idate($search_date_start) . "'";
580 }
581 if ($search_date_end) {
582  $sql .= " AND f.datef <= '" . $db->idate($search_date_end) . "'";
583 }
584 if ($search_datelimit_start) {
585  $sql .= " AND f.date_lim_reglement >= '" . $db->idate($search_datelimit_start) . "'";
586 }
587 if ($search_datelimit_end) {
588  $sql .= " AND f.date_lim_reglement <= '" . $db->idate($search_datelimit_end) . "'";
589 }
590 if ($option == 'late') {
591  $sql .= " AND f.date_lim_reglement < '".$db->idate(dol_now() - $conf->facture->fournisseur->warning_delay)."'";
592 }
593 if ($search_label) {
594  $sql .= natural_search('f.libelle', $search_label);
595 }
596 if ($search_categ_sup > 0) {
597  $sql .= " AND cs.fk_categorie = ".((int) $search_categ_sup);
598 }
599 if ($search_categ_sup == -2) {
600  $sql .= " AND cs.fk_categorie IS NULL";
601 }
602 if ($search_status != '' && $search_status >= 0) {
603  $sql .= " AND f.fk_statut = ".((int) $search_status);
604 }
605 if ($filter && $filter != -1) {
606  $aFilter = explode(',', $filter);
607  foreach ($aFilter as $fil) {
608  $filt = explode(':', $fil);
609  $sql .= " AND ".$db->escape(trim($filt[0]))." = '".$db->escape(trim($filt[1]))."'";
610  }
611 }
612 if ($search_sale > 0) {
613  $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $search_sale);
614 }
615 if ($search_user > 0) {
616  $sql .= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='invoice_supplier' AND tc.source='internal' AND ec.element_id = f.rowid AND ec.fk_socpeople = ".((int) $search_user);
617 }
618 // Add where from extra fields
619 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
620 // Add where from hooks
621 $parameters = array();
622 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
623 $sql .= $hookmanager->resPrint;
624 
625 if (!$search_all) {
626  $sql .= " GROUP BY f.rowid, f.ref, f.ref_supplier, f.type, f.datef, f.date_lim_reglement, f.fk_mode_reglement, f.fk_cond_reglement,";
627  $sql .= " f.total_ht, f.total_ttc, f.total_tva, f.paye, f.fk_statut, f.libelle, f.datec, f.tms,";
628  $sql .= " f.localtax1, f.localtax2,";
629  $sql .= ' f.fk_multicurrency, f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc,';
630  $sql .= " f.note_public, f.note_private,";
631  $sql .= " f.fk_user_author,";
632  $sql .= ' s.rowid, s.nom, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,';
633  $sql .= " typent.code,";
634  $sql .= " state.code_departement, state.nom,";
635  $sql .= ' country.code,';
636  $sql .= " p.rowid, p.ref, p.title,";
637  $sql .= " u.login, u.lastname, u.firstname, u.email, u.statut, u.entity, u.photo, u.office_phone, u.office_fax, u.user_mobile, u.job, u.gender";
638  if ($search_categ_sup && $search_categ_sup != '-1') {
639  $sql .= ", cs.fk_categorie, cs.fk_soc";
640  }
641  if (!empty($extrafields->attributes[$object->table_element]['label'])) {
642  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
643  //prevent error with sql_mode=only_full_group_by
644  $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ",ef.".$key : '');
645  }
646  }
647  // Add GroupBy from hooks
648  $parameters = array('all' => $all, 'fieldstosearchall' => $fieldstosearchall);
649  $reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object); // Note that $action and $object may have been modified by hook
650  $sql .= $hookmanager->resPrint;
651 } else {
652  $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
653 }
654 
655 // Add HAVING from hooks
656 $parameters = array();
657 $reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object); // Note that $action and $object may have been modified by hook
658 $sql .= empty($hookmanager->resPrint) ? "" : " HAVING 1=1 ".$hookmanager->resPrint;
659 
660 $sql .= $db->order($sortfield, $sortorder);
661 
662 $nbtotalofrecords = '';
663 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
664  $result = $db->query($sql);
665  $nbtotalofrecords = $db->num_rows($result);
666  if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
667  $page = 0;
668  $offset = 0;
669  }
670 }
671 
672 $sql .= $db->plimit($limit + 1, $offset);
673 //print $sql;
674 
675 $resql = $db->query($sql);
676 if ($resql) {
677  $num = $db->num_rows($resql);
678 
679  $arrayofselected = is_array($toselect) ? $toselect : array();
680 
681  if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) {
682  $obj = $db->fetch_object($resql);
683  $id = $obj->facid;
684 
685  header("Location: ".DOL_URL_ROOT.'/fourn/facture/card.php?facid='.$id);
686  exit;
687  }
688 
689  llxHeader('', $langs->trans("SuppliersInvoices"), 'EN:Suppliers_Invoices|FR:FactureFournisseur|ES:Facturas_de_proveedores');
690 
691  if ($socid) {
692  $soc = new Societe($db);
693  $soc->fetch($socid);
694  if (empty($search_company)) {
695  $search_company = $soc->name;
696  }
697  }
698 
699  $param = '&socid='.$socid;
700  if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
701  $param .= '&contextpage='.urlencode($contextpage);
702  }
703  if ($limit > 0 && $limit != $conf->liste_limit) {
704  $param .= '&limit='.urlencode($limit);
705  }
706  if ($search_all) {
707  $param .= '&search_all='.urlencode($search_all);
708  }
709  if ($search_date_startday) {
710  $param .= '&search_date_startday='.urlencode($search_date_startday);
711  }
712  if ($search_date_startmonth) {
713  $param .= '&search_date_startmonth='.urlencode($search_date_startmonth);
714  }
715  if ($search_date_startyear) {
716  $param .= '&search_date_startyear='.urlencode($search_date_startyear);
717  }
718  if ($search_date_endday) {
719  $param .= '&search_date_endday='.urlencode($search_date_endday);
720  }
721  if ($search_date_endmonth) {
722  $param .= '&search_date_endmonth='.urlencode($search_date_endmonth);
723  }
724  if ($search_date_endyear) {
725  $param .= '&search_date_endyear='.urlencode($search_date_endyear);
726  }
727  if ($search_datelimit_startday) {
728  $param .= '&search_datelimit_startday='.urlencode($search_datelimit_startday);
729  }
730  if ($search_datelimit_startmonth) {
731  $param .= '&search_datelimit_startmonth='.urlencode($search_datelimit_startmonth);
732  }
733  if ($search_datelimit_startyear) {
734  $param .= '&search_datelimit_startyear='.urlencode($search_datelimit_startyear);
735  }
736  if ($search_datelimit_endday) {
737  $param .= '&search_datelimit_endday='.urlencode($search_datelimit_endday);
738  }
739  if ($search_datelimit_endmonth) {
740  $param .= '&search_datelimit_endmonth='.urlencode($search_datelimit_endmonth);
741  }
742  if ($search_datelimit_endyear) {
743  $param .= '&search_datelimit_endyear='.urlencode($search_datelimit_endyear);
744  }
745  if ($search_ref) {
746  $param .= '&search_ref='.urlencode($search_ref);
747  }
748  if ($search_refsupplier) {
749  $param .= '&search_refsupplier='.urlencode($search_refsupplier);
750  }
751  if ($search_type != '') {
752  $param .= '&search_type='.urlencode($search_type);
753  }
754  if ($search_label) {
755  $param .= '&search_label='.urlencode($search_label);
756  }
757  if ($search_company) {
758  $param .= '&search_company='.urlencode($search_company);
759  }
760  if ($search_login) {
761  $param .= '&search_login='.urlencode($search_login);
762  }
763  if ($search_montant_ht != '') {
764  $param .= '&search_montant_ht='.urlencode($search_montant_ht);
765  }
766  if ($search_montant_vat != '') {
767  $param .= '&search_montant_vat='.urlencode($search_montant_vat);
768  }
769  if ($search_montant_localtax1 != '') {
770  $param .= '&search_montant_localtax1='.urlencode($search_montant_localtax1);
771  }
772  if ($search_montant_localtax2 != '') {
773  $param .= '&search_montant_localtax2='.urlencode($search_montant_localtax2);
774  }
775  if ($search_montant_ttc != '') {
776  $param .= '&search_montant_ttc='.urlencode($search_montant_ttc);
777  }
778  if ($search_multicurrency_code != '') {
779  $param .= '&search_multicurrency_code='.urlencode($search_multicurrency_code);
780  }
781  if ($search_multicurrency_tx != '') {
782  $param .= '&search_multicurrency_tx='.urlencode($search_multicurrency_tx);
783  }
784  if ($search_multicurrency_montant_ht != '') {
785  $param .= '&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht);
786  }
787  if ($search_multicurrency_montant_vat != '') {
788  $param .= '&search_multicurrency_montant_vat='.urlencode($search_multicurrency_montant_vat);
789  }
790  if ($search_multicurrency_montant_ttc != '') {
791  $param .= '&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc);
792  }
793  if ($search_amount_no_tax) {
794  $param .= '&search_amount_no_tax='.urlencode($search_amount_no_tax);
795  }
796  if ($search_amount_all_tax) {
797  $param .= '&search_amount_all_tax='.urlencode($search_amount_all_tax);
798  }
799  if ($search_status >= 0) {
800  $param .= "&search_status=".urlencode($search_status);
801  }
802  if ($show_files) {
803  $param .= '&show_files='.urlencode($show_files);
804  }
805  if ($option) {
806  $param .= "&search_option=".urlencode($option);
807  }
808  if ($optioncss != '') {
809  $param .= '&optioncss='.urlencode($optioncss);
810  }
811  if ($search_categ_sup > 0) {
812  $param .= '&search_categ_sup='.urlencode($search_categ_sup);
813  }
814  if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) {
815  $param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty);
816  }
817 
818  // Add $param from extra fields
819  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
820  // Add $param from hooks
821  $parameters = array();
822  $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook
823  $param .= $hookmanager->resPrint;
824 
825  // List of mass actions available
826  $arrayofmassactions = array(
827  'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"),
828  'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
829  //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
830  //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
831  );
832 
833  if (!empty($conf->paymentbybanktransfer->enabled) && !empty($user->rights->paymentbybanktransfer->create)) {
834  $langs->load('withdrawals');
835  $arrayofmassactions['banktransfertrequest'] = img_picto('', 'payment', 'class="pictofixedwidth"').$langs->trans("MakeBankTransferOrder");
836  }
837  if ($user->rights->fournisseur->facture->supprimer) {
838  $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
839  }
840  if (in_array($massaction, array('presend', 'predelete'))) {
841  $arrayofmassactions = array();
842  }
843  $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
844 
845  $url = DOL_URL_ROOT.'/fourn/facture/card.php?action=create';
846  if (!empty($socid)) {
847  $url .= '&socid='.urlencode($socid);
848  }
849  $newcardbutton = dolGetButtonTitle($langs->trans('NewBill'), '', 'fa fa-plus-circle', $url, '', ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer));
850 
851  $i = 0;
852  print '<form method="POST" name="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
853  if ($optioncss != '') {
854  print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
855  }
856  print '<input type="hidden" name="token" value="'.newToken().'">';
857  print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
858  print '<input type="hidden" name="action" value="list">';
859  print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
860  print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
861  print '<input type="hidden" name="socid" value="'.$socid.'">';
862 
863  print_barre_liste($langs->trans("BillsSuppliers").($socid ? ' '.$soc->name : ''), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'supplier_invoice', 0, $newcardbutton, '', $limit, 0, 0, 1);
864 
865  $topicmail = "SendBillRef";
866  $modelmail = "invoice_supplier_send";
867  $objecttmp = new FactureFournisseur($db);
868  $trackid = 'sinv'.$object->id;
869  include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
870 
871  if ($search_all) {
872  foreach ($fieldstosearchall as $key => $val) {
873  $fieldstosearchall[$key] = $langs->trans($val);
874  }
875  print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>';
876  }
877 
878  // If the user can view prospects other than his'
879  $moreforfilter = '';
880  if ($user->rights->user->user->lire) {
881  $langs->load("commercial");
882  $moreforfilter .= '<div class="divsearchfield">';
883  $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative');
884  $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'maxwidth200');
885  $moreforfilter .= '</div>';
886  }
887  // If the user can view prospects other than his'
888  if ($user->rights->user->user->lire) {
889  $moreforfilter .= '<div class="divsearchfield">';
890  $tmptitle = $langs->trans('LinkedToSpecificUsers');
891  $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_user, 'search_user', $tmptitle, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200');
892  $moreforfilter .= '</div>';
893  }
894  // If the user can view prospects other than his'
895  if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire)) {
896  include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
897  $moreforfilter .= '<div class="divsearchfield">';
898  $tmptitle = $langs->trans('IncludingProductWithTag');
899  $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1);
900  $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$form->selectarray('search_product_category', $cate_arbo, $search_product_category, $tmptitle, 0, 0, '', 0, 0, 0, 0, 'maxwidth300 widthcentpercentminusx', 1);
901  $moreforfilter .= '</div>';
902  }
903 
904  if (!empty($conf->categorie->enabled)) {
905  require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
906  $moreforfilter .= '<div class="divsearchfield">';
907  $tmptitle = $langs->trans('SuppliersCategoriesShort');
908  $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$formother->select_categories('supplier', $search_categ_sup, 'search_categ_sup', 1, $tmptitle);
909  $moreforfilter .= '</div>';
910  }
911  $parameters = array();
912  $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
913  if (empty($reshook)) {
914  $moreforfilter .= $hookmanager->resPrint;
915  } else {
916  $moreforfilter = $hookmanager->resPrint;
917  }
918 
919  if ($moreforfilter) {
920  print '<div class="liste_titre liste_titre_bydiv centpercent">';
921  print $moreforfilter;
922  print '</div>';
923  }
924 
925  $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
926  $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
927  if ($massactionbutton) {
928  $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
929  }
930 
931  print '<div class="div-table-responsive">';
932  print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
933 
934  // Line for filters
935  print '<tr class="liste_titre_filter">';
936  // Ref
937  if (!empty($arrayfields['f.ref']['checked'])) {
938  print '<td class="liste_titre left">';
939  print '<input class="flat maxwidth50" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
940  print '</td>';
941  }
942  // Ref supplier
943  if (!empty($arrayfields['f.ref_supplier']['checked'])) {
944  print '<td class="liste_titre">';
945  print '<input class="flat maxwidth75" type="text" name="search_refsupplier" value="'.dol_escape_htmltag($search_refsupplier).'">';
946  print '</td>';
947  }
948  // Type
949  if (!empty($arrayfields['f.type']['checked'])) {
950  print '<td class="liste_titre maxwidthonsmartphone">';
951  $listtype = array(
952  FactureFournisseur::TYPE_STANDARD=>$langs->trans("InvoiceStandard"),
953  FactureFournisseur::TYPE_REPLACEMENT=>$langs->trans("InvoiceReplacement"),
954  FactureFournisseur::TYPE_CREDIT_NOTE=>$langs->trans("InvoiceAvoir"),
955  FactureFournisseur::TYPE_DEPOSIT=>$langs->trans("InvoiceDeposit"),
956  );
957  /*
958  if (! empty($conf->global->INVOICE_USE_SITUATION))
959  {
960  $listtype[Facture::TYPE_SITUATION] = $langs->trans("InvoiceSituation");
961  }
962  */
963  //$listtype[Facture::TYPE_PROFORMA]=$langs->trans("InvoiceProForma"); // A proformat invoice is not an invoice but must be an order.
964  print $form->selectarray('search_type', $listtype, $search_type, 1, 0, 0, '', 0, 0, 0, 'ASC', 'maxwidth100');
965  print '</td>';
966  }
967  // Label
968  if (!empty($arrayfields['f.label']['checked'])) {
969  print '<td class="liste_titre">';
970  print '<input class="flat maxwidth75" type="text" name="search_label" value="'.dol_escape_htmltag($search_label).'">';
971  print '</td>';
972  }
973  // Date invoice
974  if (!empty($arrayfields['f.datef']['checked'])) {
975  print '<td class="liste_titre center">';
976  print '<div class="nowrap">';
977  print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
978  print '</div>';
979  print '<div class="nowrap">';
980  print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
981  print '</div>';
982  print '</td>';
983  }
984  // Date due
985  if (!empty($arrayfields['f.date_lim_reglement']['checked'])) {
986  print '<td class="liste_titre center">';
987  print '<div class="nowrap">';
988  /*
989  print $langs->trans('From').' ';
990  print $form->selectDate($search_datelimit_start ? $search_datelimit_start : -1, 'search_datelimit_start', 0, 0, 1);
991  print '</div>';
992  print '<div class="nowrap">';
993  print $langs->trans('to').' ';*/
994  print $form->selectDate($search_datelimit_end ? $search_datelimit_end : -1, 'search_datelimit_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("Before"));
995  print '<br><input type="checkbox" name="search_option" value="late"'.($option == 'late' ? ' checked' : '').'> '.$langs->trans("Alert");
996  print '</div>';
997  print '</td>';
998  }
999  // Project
1000  if (!empty($arrayfields['p.ref']['checked'])) {
1001  print '<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_project" value="'.dol_escape_htmltag($search_project).'"></td>';
1002  }
1003  // Thirpdarty
1004  if (!empty($arrayfields['s.nom']['checked'])) {
1005  print '<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_company" value="'.dol_escape_htmltag($search_company).'"'.($socid > 0 ? " disabled" : "").'></td>';
1006  }
1007  // Town
1008  if (!empty($arrayfields['s.town']['checked'])) {
1009  print '<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_town" value="'.dol_escape_htmltag($search_town).'"></td>';
1010  }
1011  // Zip
1012  if (!empty($arrayfields['s.zip']['checked'])) {
1013  print '<td class="liste_titre center"><input class="flat maxwidth50" type="text" name="search_zip" value="'.dol_escape_htmltag($search_zip).'"></td>';
1014  }
1015  // State
1016  if (!empty($arrayfields['state.nom']['checked'])) {
1017  print '<td class="liste_titre">';
1018  print '<input class="flat" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
1019  print '</td>';
1020  }
1021  // Country
1022  if (!empty($arrayfields['country.code_iso']['checked'])) {
1023  print '<td class="liste_titre center">';
1024  print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100');
1025  print '</td>';
1026  }
1027  // Company type
1028  if (!empty($arrayfields['typent.code']['checked'])) {
1029  print '<td class="liste_titre maxwidthonsmartphone center">';
1030  print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT), '', 1);
1031  print '</td>';
1032  }
1033  // Condition of payment
1034  if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) {
1035  print '<td class="liste_titre left">';
1036  $form->select_conditions_paiements($search_paymentcond, 'search_paymentcond', -1, 1, 1, 'maxwidth100');
1037  print '</td>';
1038  }
1039  // Payment mode
1040  if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) {
1041  print '<td class="liste_titre left">';
1042  $form->select_types_paiements($search_paymentmode, 'search_paymentmode', '', 0, 1, 1, 20, 1, 'maxwidth100');
1043  print '</td>';
1044  }
1045  if (!empty($arrayfields['f.total_ht']['checked'])) {
1046  // Amount without tax
1047  print '<td class="liste_titre right">';
1048  print '<input class="flat" type="text" size="5" name="search_montant_ht" value="'.dol_escape_htmltag($search_montant_ht).'">';
1049  print '</td>';
1050  }
1051  if (!empty($arrayfields['f.total_vat']['checked'])) {
1052  // Amount vat
1053  print '<td class="liste_titre right">';
1054  print '<input class="flat" type="text" size="5" name="search_montant_vat" value="'.dol_escape_htmltag($search_montant_vat).'">';
1055  print '</td>';
1056  }
1057  if (!empty($arrayfields['f.total_localtax1']['checked'])) {
1058  // Amount tax 1
1059  print '<td class="liste_titre right">';
1060  print '<input class="flat" type="text" size="5" name="search_montant_localtax1" value="'.dol_escape_htmltag($search_montant_localtax1).'">';
1061  print '</td>';
1062  }
1063  if (!empty($arrayfields['f.total_localtax2']['checked'])) {
1064  // Amount tax 2
1065  print '<td class="liste_titre right">';
1066  print '<input class="flat" type="text" size="5" name="search_montant_localtax2" value="'.dol_escape_htmltag($search_montant_localtax2).'">';
1067  print '</td>';
1068  }
1069  if (!empty($arrayfields['f.total_ttc']['checked'])) {
1070  // Amount inc tac
1071  print '<td class="liste_titre right">';
1072  print '<input class="flat" type="text" size="5" name="search_montant_ttc" value="'.dol_escape_htmltag($search_montant_ttc).'">';
1073  print '</td>';
1074  }
1075  if (!empty($arrayfields['u.login']['checked'])) {
1076  // Author
1077  print '<td class="liste_titre" align="center">';
1078  print '<input class="flat" size="4" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).'">';
1079  print '</td>';
1080  }
1081  if (!empty($arrayfields['dynamount_payed']['checked'])) {
1082  print '<td class="liste_titre right">';
1083  print '</td>';
1084  }
1085  if (!empty($arrayfields['rtp']['checked'])) {
1086  print '<td class="liste_titre">';
1087  print '</td>';
1088  }
1089  if (!empty($arrayfields['f.multicurrency_code']['checked'])) {
1090  // Currency
1091  print '<td class="liste_titre">';
1092  print $form->selectMultiCurrency($search_multicurrency_code, 'search_multicurrency_code', 1);
1093  print '</td>';
1094  }
1095  if (!empty($arrayfields['f.multicurrency_tx']['checked'])) {
1096  // Currency rate
1097  print '<td class="liste_titre">';
1098  print '<input class="flat" type="text" size="4" name="search_multicurrency_tx" value="'.dol_escape_htmltag($search_multicurrency_tx).'">';
1099  print '</td>';
1100  }
1101  if (!empty($arrayfields['f.multicurrency_total_ht']['checked'])) {
1102  // Amount
1103  print '<td class="liste_titre right">';
1104  print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_ht" value="'.dol_escape_htmltag($search_multicurrency_montant_ht).'">';
1105  print '</td>';
1106  }
1107  if (!empty($arrayfields['f.multicurrency_total_vat']['checked'])) {
1108  // Amount
1109  print '<td class="liste_titre right">';
1110  print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_vat" value="'.dol_escape_htmltag($search_multicurrency_montant_vat).'">';
1111  print '</td>';
1112  }
1113  if (!empty($arrayfields['f.multicurrency_total_ttc']['checked'])) {
1114  // Amount
1115  print '<td class="liste_titre right">';
1116  print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_ttc" value="'.dol_escape_htmltag($search_multicurrency_montant_ttc).'">';
1117  print '</td>';
1118  }
1119  if (!empty($arrayfields['multicurrency_dynamount_payed']['checked'])) {
1120  print '<td class="liste_titre">';
1121  print '</td>';
1122  }
1123  if (!empty($arrayfields['multicurrency_rtp']['checked'])) {
1124  print '<td class="liste_titre right">';
1125  print '</td>';
1126  }
1127  // Extra fields
1128  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
1129 
1130  // Fields from hook
1131  $parameters = array('arrayfields'=>$arrayfields);
1132  $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
1133  print $hookmanager->resPrint;
1134  // Date creation
1135  if (!empty($arrayfields['f.datec']['checked'])) {
1136  print '<td class="liste_titre">';
1137  print '</td>';
1138  }
1139  // Date modification
1140  if (!empty($arrayfields['f.tms']['checked'])) {
1141  print '<td class="liste_titre">';
1142  print '</td>';
1143  }
1144  // Status
1145  if (!empty($arrayfields['f.fk_statut']['checked'])) {
1146  print '<td class="liste_titre maxwidthonsmartphone right">';
1147  $liststatus = array('0'=>$langs->trans("Draft"), '1'=>$langs->trans("Unpaid"), '2'=>$langs->trans("Paid"));
1148  print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', '', 1);
1149  print '</td>';
1150  }
1151  // Action column
1152  print '<td class="liste_titre middle">';
1153  $searchpicto = $form->showFilterButtons();
1154  print $searchpicto;
1155  print '</td>';
1156 
1157  print "</tr>\n";
1158 
1159  print '<tr class="liste_titre">';
1160  if (!empty($arrayfields['f.ref']['checked'])) {
1161  print_liste_field_titre($arrayfields['f.ref']['label'], $_SERVER['PHP_SELF'], 'f.ref,f.rowid', '', $param, '', $sortfield, $sortorder);
1162  }
1163  if (!empty($arrayfields['f.ref_supplier']['checked'])) {
1164  print_liste_field_titre($arrayfields['f.ref_supplier']['label'], $_SERVER["PHP_SELF"], 'f.ref_supplier', '', $param, '', $sortfield, $sortorder);
1165  }
1166  if (!empty($arrayfields['f.type']['checked'])) {
1167  print_liste_field_titre($arrayfields['f.type']['label'], $_SERVER["PHP_SELF"], 'f.type', '', $param, '', $sortfield, $sortorder);
1168  }
1169  if (!empty($arrayfields['f.label']['checked'])) {
1170  print_liste_field_titre($arrayfields['f.label']['label'], $_SERVER['PHP_SELF'], "f.libelle,f.rowid", '', $param, '', $sortfield, $sortorder);
1171  }
1172  if (!empty($arrayfields['f.datef']['checked'])) {
1173  print_liste_field_titre($arrayfields['f.datef']['label'], $_SERVER['PHP_SELF'], 'f.datef,f.rowid', '', $param, '', $sortfield, $sortorder, 'center ');
1174  }
1175  if (!empty($arrayfields['f.date_lim_reglement']['checked'])) {
1176  print_liste_field_titre($arrayfields['f.date_lim_reglement']['label'], $_SERVER['PHP_SELF'], "f.date_lim_reglement", '', $param, '', $sortfield, $sortorder, 'center ');
1177  }
1178  if (!empty($arrayfields['p.ref']['checked'])) {
1179  print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER['PHP_SELF'], "p.ref", '', $param, '', $sortfield, $sortorder);
1180  }
1181  if (!empty($arrayfields['s.nom']['checked'])) {
1182  print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER['PHP_SELF'], 's.nom', '', $param, '', $sortfield, $sortorder);
1183  }
1184  if (!empty($arrayfields['s.town']['checked'])) {
1185  print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder);
1186  }
1187  if (!empty($arrayfields['s.zip']['checked'])) {
1188  print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder, 'center ');
1189  }
1190  if (!empty($arrayfields['state.nom']['checked'])) {
1191  print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder);
1192  }
1193  if (!empty($arrayfields['country.code_iso']['checked'])) {
1194  print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center ');
1195  }
1196  if (!empty($arrayfields['typent.code']['checked'])) {
1197  print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center ');
1198  }
1199  if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) {
1200  print_liste_field_titre($arrayfields['f.fk_cond_reglement']['label'], $_SERVER["PHP_SELF"], "f.fk_cond_reglement", "", $param, "", $sortfield, $sortorder);
1201  }
1202  if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) {
1203  print_liste_field_titre($arrayfields['f.fk_mode_reglement']['label'], $_SERVER["PHP_SELF"], "f.fk_mode_reglement", "", $param, "", $sortfield, $sortorder);
1204  }
1205  if (!empty($arrayfields['f.total_ht']['checked'])) {
1206  print_liste_field_titre($arrayfields['f.total_ht']['label'], $_SERVER['PHP_SELF'], 'f.total_ht', '', $param, '', $sortfield, $sortorder, 'right ');
1207  }
1208  if (!empty($arrayfields['f.total_vat']['checked'])) {
1209  print_liste_field_titre($arrayfields['f.total_vat']['label'], $_SERVER['PHP_SELF'], 'f.total_tva', '', $param, '', $sortfield, $sortorder, 'right ');
1210  }
1211  if (!empty($arrayfields['f.total_localtax1']['checked'])) {
1212  print_liste_field_titre($arrayfields['f.total_localtax1']['label'], $_SERVER['PHP_SELF'], 'f.localtax1', '', $param, '', $sortfield, $sortorder, 'right ');
1213  }
1214  if (!empty($arrayfields['f.total_localtax2']['checked'])) {
1215  print_liste_field_titre($arrayfields['f.total_localtax2']['label'], $_SERVER['PHP_SELF'], 'f.localtax2', '', $param, '', $sortfield, $sortorder, 'right ');
1216  }
1217  if (!empty($arrayfields['f.total_ttc']['checked'])) {
1218  print_liste_field_titre($arrayfields['f.total_ttc']['label'], $_SERVER['PHP_SELF'], 'f.total_ttc', '', $param, '', $sortfield, $sortorder, 'right ');
1219  }
1220  if (!empty($arrayfields['u.login']['checked'])) {
1221  print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.login', '', $param, 'align="center"', $sortfield, $sortorder);
1222  }
1223  if (!empty($arrayfields['dynamount_payed']['checked'])) {
1224  print_liste_field_titre($arrayfields['dynamount_payed']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right ');
1225  }
1226  if (!empty($arrayfields['rtp']['checked'])) {
1227  print_liste_field_titre($arrayfields['rtp']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right ');
1228  }
1229  if (!empty($arrayfields['f.multicurrency_code']['checked'])) {
1230  print_liste_field_titre($arrayfields['f.multicurrency_code']['label'], $_SERVER['PHP_SELF'], 'f.multicurrency_code', '', $param, '', $sortfield, $sortorder);
1231  }
1232  if (!empty($arrayfields['f.multicurrency_tx']['checked'])) {
1233  print_liste_field_titre($arrayfields['f.multicurrency_tx']['label'], $_SERVER['PHP_SELF'], 'f.multicurrency_tx', '', $param, '', $sortfield, $sortorder);
1234  }
1235  if (!empty($arrayfields['f.multicurrency_total_ht']['checked'])) {
1236  print_liste_field_titre($arrayfields['f.multicurrency_total_ht']['label'], $_SERVER['PHP_SELF'], 'f.multicurrency_total_ht', '', $param, 'class="right"', $sortfield, $sortorder);
1237  }
1238  if (!empty($arrayfields['f.multicurrency_total_vat']['checked'])) {
1239  print_liste_field_titre($arrayfields['f.multicurrency_total_vat']['label'], $_SERVER['PHP_SELF'], 'f.multicurrency_total_tva', '', $param, 'class="right"', $sortfield, $sortorder);
1240  }
1241  if (!empty($arrayfields['f.multicurrency_total_ttc']['checked'])) {
1242  print_liste_field_titre($arrayfields['f.multicurrency_total_ttc']['label'], $_SERVER['PHP_SELF'], 'f.multicurrency_total_ttc', '', $param, 'class="right"', $sortfield, $sortorder);
1243  }
1244  if (!empty($arrayfields['multicurrency_dynamount_payed']['checked'])) {
1245  print_liste_field_titre($arrayfields['multicurrency_dynamount_payed']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder);
1246  }
1247  if (!empty($arrayfields['multicurrency_rtp']['checked'])) {
1248  print_liste_field_titre($arrayfields['multicurrency_rtp']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder);
1249  }
1250  // Extra fields
1251  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
1252  // Hook fields
1253  $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
1254  $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
1255  print $hookmanager->resPrint;
1256  if (!empty($arrayfields['f.datec']['checked'])) {
1257  print_liste_field_titre($arrayfields['f.datec']['label'], $_SERVER["PHP_SELF"], "f.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1258  }
1259  if (!empty($arrayfields['f.tms']['checked'])) {
1260  print_liste_field_titre($arrayfields['f.tms']['label'], $_SERVER["PHP_SELF"], "f.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1261  }
1262  if (!empty($arrayfields['f.fk_statut']['checked'])) {
1263  print_liste_field_titre($arrayfields['f.fk_statut']['label'], $_SERVER["PHP_SELF"], "fk_statut,paye,type", "", $param, '', $sortfield, $sortorder, 'right ');
1264  }
1265  print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
1266  print "</tr>\n";
1267 
1268  $facturestatic = new FactureFournisseur($db);
1269  $supplierstatic = new Fournisseur($db);
1270  $projectstatic = new Project($db);
1271  $userstatic = new User($db);
1272 
1273  if ($num > 0) {
1274  $i = 0;
1275  $totalarray = array();
1276  while ($i < min($num, $limit)) {
1277  $obj = $db->fetch_object($resql);
1278 
1279  $datelimit = $db->jdate($obj->datelimite);
1280  $facturestatic->id = $obj->facid;
1281  $facturestatic->ref = $obj->ref;
1282  $facturestatic->type = $obj->type;
1283  $facturestatic->ref_supplier = $obj->ref_supplier;
1284  $facturestatic->date_echeance = $db->jdate($obj->datelimite);
1285  $facturestatic->statut = $obj->fk_statut;
1286  $facturestatic->note_public = $obj->note_public;
1287  $facturestatic->note_private = $obj->note_private;
1288  $facturestatic->multicurrency_code = $obj->multicurrency_code;
1289  $facturestatic->multicurrency_tx = $obj->multicurrency_tx;
1290  $facturestatic->multicurrency_total_ht = $obj->multicurrency_total_ht;
1291  $facturestatic->multicurrency_total_tva = $obj->multicurrency_total_vat;
1292  $facturestatic->multicurrency_total_ttc = $obj->multicurrency_total_ttc;
1293 
1294  $thirdparty->id = $obj->socid;
1295  $thirdparty->name = $obj->name;
1296  $thirdparty->client = $obj->client;
1297  $thirdparty->fournisseur = $obj->fournisseur;
1298  $thirdparty->code_client = $obj->code_client;
1299  $thirdparty->code_compta_client = $obj->code_compta_client;
1300  $thirdparty->code_fournisseur = $obj->code_fournisseur;
1301  $thirdparty->code_compta_fournisseur = $obj->code_compta_fournisseur;
1302  $thirdparty->email = $obj->email;
1303  $thirdparty->country_code = $obj->country_code;
1304 
1305  $paiement = $facturestatic->getSommePaiement();
1306  $totalcreditnotes = $facturestatic->getSumCreditNotesUsed();
1307  $totaldeposits = $facturestatic->getSumDepositsUsed();
1308  $totalpay = $paiement + $totalcreditnotes + $totaldeposits;
1309  $remaintopay = $obj->total_ttc - $totalpay;
1310  $multicurrency_paiement = $facturestatic->getSommePaiement(1);
1311  $multicurrency_totalcreditnotes = $facturestatic->getSumCreditNotesUsed(1);
1312  $multicurrency_totaldeposits = $facturestatic->getSumDepositsUsed(1);
1313  $multicurrency_totalpay = $multicurrency_paiement + $multicurrency_totalcreditnotes + $multicurrency_totaldeposits;
1314  $multicurrency_remaintopay = price2num($facturestatic->multicurrency_total_ttc - $multicurrency_totalpay);
1315 
1316  $facturestatic->alreadypaid = ($paiement ? $paiement : 0);
1317  $facturestatic->paye = $obj->paye;
1318  $facturestatic->statut = $obj->fk_statut;
1319  $facturestatic->type = $obj->type;
1320 
1321 
1322  //If invoice has been converted and the conversion has been used, we dont have remain to pay on invoice
1323  if ($facturestatic->type == FactureFournisseur::TYPE_CREDIT_NOTE) {
1324  if ($facturestatic->isCreditNoteUsed()) {
1325  $remaintopay = -$facturestatic->getSumFromThisCreditNotesNotUsed();
1326  }
1327  }
1328 
1329  print '<tr class="oddeven">';
1330  if (!empty($arrayfields['f.ref']['checked'])) {
1331  print '<td class="nowraponall">';
1332 
1333  print '<table class="nobordernopadding"><tr class="nocellnopadd">';
1334  // Picto + Ref
1335  print '<td class="nobordernopadding nowraponall">';
1336  print $facturestatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1);
1337 
1338  $filename = dol_sanitizeFileName($obj->ref);
1339  $filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($obj->facid, 2, 0, 0, $facturestatic, 'invoice_supplier').dol_sanitizeFileName($obj->ref);
1340  $subdir = get_exdir($obj->facid, 2, 0, 0, $facturestatic, 'invoice_supplier').dol_sanitizeFileName($obj->ref);
1341  print $formfile->getDocumentsLink('facture_fournisseur', $subdir, $filedir);
1342  print '</td></tr></table>';
1343 
1344  print "</td>\n";
1345  if (!$i) {
1346  $totalarray['nbfield']++;
1347  }
1348  }
1349 
1350  // Supplier ref
1351  if (!empty($arrayfields['f.ref_supplier']['checked'])) {
1352  print '<td class="nowrap tdoverflowmax150" title="'.dol_escape_htmltag($obj->ref_supplier).'">';
1353  print $obj->ref_supplier;
1354  print '</td>';
1355  if (!$i) {
1356  $totalarray['nbfield']++;
1357  }
1358  }
1359 
1360  // Type
1361  if (!empty($arrayfields['f.type']['checked'])) {
1362  print '<td class="nowrap">';
1363  print $facturestatic->getLibType();
1364  print "</td>";
1365  if (!$i) {
1366  $totalarray['nbfield']++;
1367  }
1368  }
1369 
1370  // Label
1371  if (!empty($arrayfields['f.label']['checked'])) {
1372  print '<td class="nowrap">';
1373  print $obj->label;
1374  print '</td>';
1375  if (!$i) {
1376  $totalarray['nbfield']++;
1377  }
1378  }
1379 
1380  // Date
1381  if (!empty($arrayfields['f.datef']['checked'])) {
1382  print '<td class="center nowrap">';
1383  print dol_print_date($db->jdate($obj->datef), 'day');
1384  print '</td>';
1385  if (!$i) {
1386  $totalarray['nbfield']++;
1387  }
1388  }
1389 
1390  // Date limit
1391  if (!empty($arrayfields['f.date_lim_reglement']['checked'])) {
1392  print '<td class="center nowraponall">'.dol_print_date($datelimit, 'day');
1393  if ($facturestatic->hasDelay()) {
1394  print img_warning($langs->trans('Alert').' - '.$langs->trans('Late'));
1395  }
1396  print '</td>';
1397  if (!$i) {
1398  $totalarray['nbfield']++;
1399  }
1400  }
1401 
1402  // Project
1403  if (!empty($arrayfields['p.ref']['checked'])) {
1404  print '<td class="nowrap">';
1405  if ($obj->project_id > 0) {
1406  $projectstatic->id = $obj->project_id;
1407  $projectstatic->ref = $obj->project_ref;
1408  $projectstatic->title = $obj->project_label;
1409  print $projectstatic->getNomUrl(1);
1410  }
1411  print '</td>';
1412  if (!$i) {
1413  $totalarray['nbfield']++;
1414  }
1415  }
1416 
1417  // Third party
1418  if (!empty($arrayfields['s.nom']['checked'])) {
1419  print '<td class="tdoverflowmax200">';
1420  print $thirdparty->getNomUrl(1, 'supplier');
1421  print '</td>';
1422  if (!$i) {
1423  $totalarray['nbfield']++;
1424  }
1425  }
1426  // Town
1427  if (!empty($arrayfields['s.town']['checked'])) {
1428  print '<td class="nocellnopadd">';
1429  print $obj->town;
1430  print '</td>';
1431  if (!$i) {
1432  $totalarray['nbfield']++;
1433  }
1434  }
1435  // Zip
1436  if (!empty($arrayfields['s.zip']['checked'])) {
1437  print '<td class="nocellnopadd center tdoverflowmax100" title="'.dol_escape_htmltag($obj->zip).'">';
1438  print dol_escape_htmltag($obj->zip);
1439  print '</td>';
1440  if (!$i) {
1441  $totalarray['nbfield']++;
1442  }
1443  }
1444  // State
1445  if (!empty($arrayfields['state.nom']['checked'])) {
1446  print "<td>".$obj->state_name."</td>\n";
1447  if (!$i) {
1448  $totalarray['nbfield']++;
1449  }
1450  }
1451  // Country
1452  if (!empty($arrayfields['country.code_iso']['checked'])) {
1453  print '<td class="center">';
1454  $tmparray = getCountry($obj->fk_pays, 'all');
1455  print $tmparray['label'];
1456  print '</td>';
1457  if (!$i) {
1458  $totalarray['nbfield']++;
1459  }
1460  }
1461  // Type ent
1462  if (!empty($arrayfields['typent.code']['checked'])) {
1463  print '<td class="center">';
1464  if (empty($typenArray)) {
1465  $typenArray = $formcompany->typent_array(1);
1466  }
1467  print $typenArray[$obj->typent_code];
1468  print '</td>';
1469  if (!$i) {
1470  $totalarray['nbfield']++;
1471  }
1472  }
1473 
1474  // Payment condition
1475  if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) {
1476  print '<td class="tdoverflowmax125">';
1477  $form->form_conditions_reglement($_SERVER['PHP_SELF'], $obj->fk_cond_reglement, 'none', 1);
1478  print '</td>';
1479  if (!$i) {
1480  $totalarray['nbfield']++;
1481  }
1482  }
1483  // Payment mode
1484  if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) {
1485  print '<td class="tdoverflowmax125">';
1486  $form->form_modes_reglement($_SERVER['PHP_SELF'], $obj->fk_mode_reglement, 'none', '', -1);
1487  print '</td>';
1488  if (!$i) {
1489  $totalarray['nbfield']++;
1490  }
1491  }
1492 
1493  // Amount HT
1494  if (!empty($arrayfields['f.total_ht']['checked'])) {
1495  print '<td class="right nowrap"><span class="amount">'.price($obj->total_ht)."</span></td>\n";
1496  if (!$i) {
1497  $totalarray['nbfield']++;
1498  }
1499  if (!$i) {
1500  $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ht';
1501  }
1502  $totalarray['val']['f.total_ht'] += $obj->total_ht;
1503  }
1504  // Amount VAT
1505  if (!empty($arrayfields['f.total_vat']['checked'])) {
1506  print '<td class="right nowrap"><span class="amount">'.price($obj->total_vat)."</span></td>\n";
1507  if (!$i) {
1508  $totalarray['nbfield']++;
1509  }
1510  if (!$i) {
1511  $totalarray['pos'][$totalarray['nbfield']] = 'f.total_vat';
1512  }
1513  $totalarray['val']['f.total_vat'] += $obj->total_vat;
1514  }
1515  // Amount LocalTax1
1516  if (!empty($arrayfields['f.total_localtax1']['checked'])) {
1517  print '<td class="right nowrap"><span class="amount">'.price($obj->total_localtax1)."</span></td>\n";
1518  if (!$i) {
1519  $totalarray['nbfield']++;
1520  }
1521  if (!$i) {
1522  $totalarray['pos'][$totalarray['nbfield']] = 'f.total_localtax1';
1523  }
1524  $totalarray['val']['f.total_localtax1'] += $obj->total_localtax1;
1525  }
1526  // Amount LocalTax2
1527  if (!empty($arrayfields['f.total_localtax2']['checked'])) {
1528  print '<td class="right nowrap"><span class="amount">'.price($obj->total_localtax2)."</span></td>\n";
1529  if (!$i) {
1530  $totalarray['nbfield']++;
1531  }
1532  if (!$i) {
1533  $totalarray['pos'][$totalarray['nbfield']] = 'f.total_localtax2';
1534  }
1535  $totalarray['val']['f.total_localtax2'] += $obj->total_localtax2;
1536  }
1537  // Amount TTC
1538  if (!empty($arrayfields['f.total_ttc']['checked'])) {
1539  print '<td class="right nowrap"><span class="amount">'.price($obj->total_ttc)."</span></td>\n";
1540  if (!$i) {
1541  $totalarray['nbfield']++;
1542  }
1543  if (!$i) {
1544  $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ttc';
1545  }
1546  $totalarray['val']['f.total_ttc'] += $obj->total_ttc;
1547  }
1548 
1549  $userstatic->id = $obj->fk_user_author;
1550  $userstatic->login = $obj->login;
1551  $userstatic->lastname = $obj->lastname;
1552  $userstatic->firstname = $obj->firstname;
1553  $userstatic->email = $obj->user_email;
1554  $userstatic->statut = $obj->user_statut;
1555  $userstatic->entity = $obj->entity;
1556  $userstatic->photo = $obj->photo;
1557  $userstatic->office_phone = $obj->office_phone;
1558  $userstatic->office_fax = $obj->office_fax;
1559  $userstatic->user_mobile = $obj->user_mobile;
1560  $userstatic->job = $obj->job;
1561  $userstatic->gender = $obj->gender;
1562 
1563  // Author
1564  if (!empty($arrayfields['u.login']['checked'])) {
1565  print '<td class="tdoverflowmax200">';
1566  if ($userstatic->id) {
1567  print $userstatic->getLoginUrl(-1);
1568  } else {
1569  print '&nbsp;';
1570  }
1571  print "</td>\n";
1572  if (!$i) {
1573  $totalarray['nbfield']++;
1574  }
1575  }
1576 
1577  if (!empty($arrayfields['dynamount_payed']['checked'])) {
1578  print '<td class="right nowrap"><span class="amount">'.(!empty($totalpay) ?price($totalpay, 0, $langs) : '').'</span></td>'; // TODO Use a denormalized field
1579  if (!$i) {
1580  $totalarray['nbfield']++;
1581  }
1582  if (!$i) {
1583  $totalarray['pos'][$totalarray['nbfield']] = 'totalam';
1584  }
1585  $totalarray['val']['totalam'] += $totalpay;
1586  }
1587 
1588  if (!empty($arrayfields['rtp']['checked'])) {
1589  print '<td class="right nowrap">'.(!empty($remaintopay) ?price($remaintopay, 0, $langs) : '&nbsp;').'</td>'; // TODO Use a denormalized field
1590  if (!$i) {
1591  $totalarray['nbfield']++;
1592  }
1593  if (!$i) {
1594  $totalarray['pos'][$totalarray['nbfield']] = 'rtp';
1595  }
1596  $totalarray['val']['rtp'] += $remaintopay;
1597  }
1598 
1599  // Currency
1600  if (!empty($arrayfields['f.multicurrency_code']['checked'])) {
1601  print '<td class="nowrap">'.$obj->multicurrency_code.' - '.$langs->trans('Currency'.$obj->multicurrency_code)."</td>\n";
1602  if (!$i) {
1603  $totalarray['nbfield']++;
1604  }
1605  }
1606 
1607  // Currency rate
1608  if (!empty($arrayfields['f.multicurrency_tx']['checked'])) {
1609  print '<td class="nowrap">';
1610  $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code);
1611  print "</td>\n";
1612  if (!$i) {
1613  $totalarray['nbfield']++;
1614  }
1615  }
1616  // Amount HT
1617  if (!empty($arrayfields['f.multicurrency_total_ht']['checked'])) {
1618  print '<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ht)."</span></td>\n";
1619  if (!$i) {
1620  $totalarray['nbfield']++;
1621  }
1622  }
1623  // Amount VAT
1624  if (!empty($arrayfields['f.multicurrency_total_vat']['checked'])) {
1625  print '<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_vat)."</span></td>\n";
1626  if (!$i) {
1627  $totalarray['nbfield']++;
1628  }
1629  }
1630  // Amount TTC
1631  if (!empty($arrayfields['f.multicurrency_total_ttc']['checked'])) {
1632  print '<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ttc)."</span></td>\n";
1633  if (!$i) {
1634  $totalarray['nbfield']++;
1635  }
1636  }
1637  if (!empty($arrayfields['multicurrency_dynamount_payed']['checked'])) {
1638  print '<td class="right nowrap"><span class="amount">'.(!empty($multicurrency_totalpay) ?price($multicurrency_totalpay, 0, $langs) : '').'</span></td>'; // TODO Use a denormalized field
1639  if (!$i) {
1640  $totalarray['nbfield']++;
1641  }
1642  }
1643 
1644  // Pending amount
1645  if (!empty($arrayfields['multicurrency_rtp']['checked'])) {
1646  print '<td class="right nowrap"><span class="amount">';
1647  print (!empty($multicurrency_remaintopay) ? price($multicurrency_remaintopay, 0, $langs) : '');
1648  print '</span></td>'; // TODO Use a denormalized field
1649  if (!$i) {
1650  $totalarray['nbfield']++;
1651  }
1652  }
1653 
1654 
1655  // Extra fields
1656  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1657  // Fields from hook
1658  $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
1659  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
1660  print $hookmanager->resPrint;
1661 
1662  // Date creation
1663  if (!empty($arrayfields['f.datec']['checked'])) {
1664  print '<td class="center nowrap">';
1665  print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
1666  print '</td>';
1667  if (!$i) {
1668  $totalarray['nbfield']++;
1669  }
1670  }
1671  // Date modification
1672  if (!empty($arrayfields['f.tms']['checked'])) {
1673  print '<td class="center nowrap">';
1674  print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
1675  print '</td>';
1676  if (!$i) {
1677  $totalarray['nbfield']++;
1678  }
1679  }
1680  // Status
1681  if (!empty($arrayfields['f.fk_statut']['checked'])) {
1682  print '<td class="right nowrap">';
1683  print $facturestatic->LibStatut($obj->paye, $obj->fk_statut, 5, $paiement, $obj->type);
1684  print "</td>";
1685  if (!$i) {
1686  $totalarray['nbfield']++;
1687  }
1688  }
1689 
1690  // Action column
1691  print '<td class="nowrap center">';
1692  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1693  $selected = 0;
1694  if (in_array($obj->facid, $arrayofselected)) {
1695  $selected = 1;
1696  }
1697  print '<input id="cb'.$obj->facid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->facid.'"'.($selected ? ' checked="checked"' : '').'>';
1698  }
1699  print '</td>';
1700  if (!$i) {
1701  $totalarray['nbfield']++;
1702  }
1703 
1704  print "</tr>\n";
1705 
1706  $i++;
1707  }
1708 
1709  // Show total line
1710  include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
1711  }
1712 
1713  $db->free($resql);
1714 
1715  $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
1716  $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook
1717  print $hookmanager->resPrint;
1718 
1719  print "</table>\n";
1720  print '</div>';
1721 
1722  print "</form>\n";
1723 
1724  $hidegeneratedfilelistifempty = 1;
1725  if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
1726  $hidegeneratedfilelistifempty = 0;
1727  }
1728 
1729  // Show list of available documents
1730  $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
1731  $urlsource .= str_replace('&amp;', '&', $param);
1732 
1733  $filedir = $diroutputmassaction;
1734  $genallowed = $user->rights->facture->lire;
1735  $delallowed = $user->rights->facture->creer;
1736  $title = '';
1737 
1738  print $formfile->showdocuments('massfilesarea_supplier_invoice', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
1739 } else {
1740  dol_print_error($db);
1741 }
1742 
1743 // End of page
1744 llxFooter();
1745 $db->close();
Societe
Class to manage third parties objects (customers, suppliers, prospects...)
Definition: societe.class.php:48
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
Project
Class to manage projects.
Definition: project.class.php:35
FactureFournisseur\TYPE_CREDIT_NOTE
const TYPE_CREDIT_NOTE
Credit note invoice.
Definition: fournisseur.facture.class.php:338
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
img_warning
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
Definition: functions.lib.php:4521
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
FormOther
Classe permettant la generation de composants html autre Only common components are here.
Definition: html.formother.class.php:39
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
FormCompany
Class to build HTML component for third parties management Only common components are here.
Definition: html.formcompany.class.php:40
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
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
Fournisseur
Class to manage suppliers.
Definition: fournisseur.class.php:34
dolGetButtonTitle
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
Definition: functions.lib.php:10605
print_barre_liste
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
Definition: functions.lib.php:5257
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
FactureFournisseur\STATUS_DRAFT
const STATUS_DRAFT
Draft.
Definition: fournisseur.facture.class.php:348
FactureFournisseur\TYPE_DEPOSIT
const TYPE_DEPOSIT
Deposit invoice.
Definition: fournisseur.facture.class.php:343
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
natural_search
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
Definition: functions.lib.php:9420
ExtraFields
Class to manage standard extra fields.
Definition: extrafields.class.php:39
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
FactureFournisseur\TYPE_STANDARD
const TYPE_STANDARD
Standard invoice.
Definition: fournisseur.facture.class.php:328
dol_now
dol_now($mode='auto')
Return date for now.
Definition: functions.lib.php:2845
$resql
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice') && $user->rights->supplier_invoice->lire)) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:742
price
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
Definition: functions.lib.php:5541
getCountry
getCountry($searchkey, $withcode='', $dbtouse=0, $outputlangs='', $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
Definition: company.lib.php:489
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_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
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
Account
Class to manage bank accounts.
Definition: account.class.php:38
FactureFournisseur\TYPE_REPLACEMENT
const TYPE_REPLACEMENT
Replacement invoice.
Definition: fournisseur.facture.class.php:333