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