dolibarr  17.0.4
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 ($search_paymentmode) {
875  $param .= '&search_paymentmode='.urlencode($search_paymentmode);
876 }
877 if ($search_paymentcond) {
878  $param .= '&search_paymentcond='.urlencode($search_paymentcond);
879 }
880 if ($show_files) {
881  $param .= '&show_files='.urlencode($show_files);
882 }
883 if ($option) {
884  $param .= "&search_option=".urlencode($option);
885 }
886 if ($optioncss != '') {
887  $param .= '&optioncss='.urlencode($optioncss);
888 }
889 if ($search_categ_sup > 0) {
890  $param .= '&search_categ_sup='.urlencode($search_categ_sup);
891 }
892 if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) {
893  $param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty);
894 }
895 
896 // Add $param from extra fields
897 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
898 // Add $param from hooks
899 $parameters = array();
900 $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
901 $param .= $hookmanager->resPrint;
902 
903 // List of mass actions available
904 $arrayofmassactions = array(
905  'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"),
906  'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
907  //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
908  //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
909 );
910 
911 if (isModEnabled('paymentbybanktransfer') && !empty($user->rights->paymentbybanktransfer->create)) {
912  $langs->load('withdrawals');
913  $arrayofmassactions['banktransfertrequest'] = img_picto('', 'payment', 'class="pictofixedwidth"').$langs->trans("MakeBankTransferOrder");
914 }
915 if ($user->rights->fournisseur->facture->supprimer) {
916  $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
917 }
918 if (in_array($massaction, array('presend', 'predelete'))) {
919  $arrayofmassactions = array();
920 }
921 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
922 
923 $url = DOL_URL_ROOT.'/fourn/facture/card.php?action=create';
924 if (!empty($socid)) {
925  $url .= '&socid='.urlencode($socid);
926 }
927 $newcardbutton = dolGetButtonTitle($langs->trans('NewBill'), '', 'fa fa-plus-circle', $url, '', ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer));
928 
929 $i = 0;
930 print '<form method="POST" name="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
931 if ($optioncss != '') {
932  print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
933 }
934 print '<input type="hidden" name="token" value="'.newToken().'">';
935 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
936 print '<input type="hidden" name="action" value="list">';
937 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
938 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
939 print '<input type="hidden" name="socid" value="'.$socid.'">';
940 
941 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);
942 
943 $topicmail = "SendBillRef";
944 $modelmail = "invoice_supplier_send";
945 $objecttmp = new FactureFournisseur($db);
946 $trackid = 'sinv'.$object->id;
947 include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
948 
949 if ($search_all) {
950  foreach ($fieldstosearchall as $key => $val) {
951  $fieldstosearchall[$key] = $langs->trans($val);
952  }
953  print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>';
954 }
955 
956 // If the user can view prospects other than his'
957 $moreforfilter = '';
958 if ($user->rights->user->user->lire) {
959  $langs->load("commercial");
960  $moreforfilter .= '<div class="divsearchfield">';
961  $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative');
962  $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'maxwidth200');
963  $moreforfilter .= '</div>';
964 }
965 // If the user can view prospects other than his'
966 if ($user->rights->user->user->lire) {
967  $moreforfilter .= '<div class="divsearchfield">';
968  $tmptitle = $langs->trans('LinkedToSpecificUsers');
969  $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_user, 'search_user', $tmptitle, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200');
970  $moreforfilter .= '</div>';
971 }
972 // If the user can view prospects other than his'
973 if (isModEnabled('categorie') && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire)) {
974  include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
975  $moreforfilter .= '<div class="divsearchfield">';
976  $tmptitle = $langs->trans('IncludingProductWithTag');
977  $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1);
978  $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);
979  $moreforfilter .= '</div>';
980 }
981 
982 if (isModEnabled('categorie')) {
983  require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
984  $moreforfilter .= '<div class="divsearchfield">';
985  $tmptitle = $langs->trans('SuppliersCategoriesShort');
986  $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$formother->select_categories('supplier', $search_categ_sup, 'search_categ_sup', 1, $tmptitle);
987  $moreforfilter .= '</div>';
988 }
989 $parameters = array();
990 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
991 if (empty($reshook)) {
992  $moreforfilter .= $hookmanager->resPrint;
993 } else {
994  $moreforfilter = $hookmanager->resPrint;
995 }
996 
997 if ($moreforfilter) {
998  print '<div class="liste_titre liste_titre_bydiv centpercent">';
999  print $moreforfilter;
1000  print '</div>';
1001 }
1002 
1003 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
1004 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields
1005 if ($massactionbutton) {
1006  $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
1007 }
1008 
1009 print '<div class="div-table-responsive">';
1010 print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
1011 
1012 // Line for filters
1013 print '<tr class="liste_titre_filter">';
1014 // Action column
1015 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1016  print '<td class="liste_titre middle">';
1017  $searchpicto = $form->showFilterButtons('left');
1018  print $searchpicto;
1019  print '</td>';
1020 }
1021 // Ref
1022 if (!empty($arrayfields['f.ref']['checked'])) {
1023  print '<td class="liste_titre left">';
1024  print '<input class="flat maxwidth50" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
1025  print '</td>';
1026 }
1027 // Ref supplier
1028 if (!empty($arrayfields['f.ref_supplier']['checked'])) {
1029  print '<td class="liste_titre">';
1030  print '<input class="flat maxwidth75" type="text" name="search_refsupplier" value="'.dol_escape_htmltag($search_refsupplier).'">';
1031  print '</td>';
1032 }
1033 // Type
1034 if (!empty($arrayfields['f.type']['checked'])) {
1035  print '<td class="liste_titre maxwidthonsmartphone">';
1036  $listtype = array(
1037  FactureFournisseur::TYPE_STANDARD=>$langs->trans("InvoiceStandard"),
1038  FactureFournisseur::TYPE_REPLACEMENT=>$langs->trans("InvoiceReplacement"),
1039  FactureFournisseur::TYPE_CREDIT_NOTE=>$langs->trans("InvoiceAvoir"),
1040  FactureFournisseur::TYPE_DEPOSIT=>$langs->trans("InvoiceDeposit"),
1041  );
1042  /*
1043  if (!empty($conf->global->INVOICE_USE_SITUATION))
1044  {
1045  $listtype[Facture::TYPE_SITUATION] = $langs->trans("InvoiceSituation");
1046  }
1047  */
1048  //$listtype[Facture::TYPE_PROFORMA]=$langs->trans("InvoiceProForma"); // A proformat invoice is not an invoice but must be an order.
1049  print $form->selectarray('search_type', $listtype, $search_type, 1, 0, 0, '', 0, 0, 0, 'ASC', 'maxwidth100');
1050  print '</td>';
1051 }
1052 // Label
1053 if (!empty($arrayfields['f.label']['checked'])) {
1054  print '<td class="liste_titre">';
1055  print '<input class="flat maxwidth75" type="text" name="search_label" value="'.dol_escape_htmltag($search_label).'">';
1056  print '</td>';
1057 }
1058 // Date invoice
1059 if (!empty($arrayfields['f.datef']['checked'])) {
1060  print '<td class="liste_titre center">';
1061  print '<div class="nowrap">';
1062  print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
1063  print '</div>';
1064  print '<div class="nowrap">';
1065  print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
1066  print '</div>';
1067  print '</td>';
1068 }
1069 // Date due
1070 if (!empty($arrayfields['f.date_lim_reglement']['checked'])) {
1071  print '<td class="liste_titre center">';
1072  print '<div class="nowrap">';
1073  /*
1074  print $langs->trans('From').' ';
1075  print $form->selectDate($search_datelimit_start ? $search_datelimit_start : -1, 'search_datelimit_start', 0, 0, 1);
1076  print '</div>';
1077  print '<div class="nowrap">';
1078  print $langs->trans('to').' ';*/
1079  print $form->selectDate($search_datelimit_end ? $search_datelimit_end : -1, 'search_datelimit_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("Before"));
1080  print '<br><input type="checkbox" name="search_option" value="late"'.($option == 'late' ? ' checked' : '').'> '.$langs->trans("Alert");
1081  print '</div>';
1082  print '</td>';
1083 }
1084 // Project
1085 if (!empty($arrayfields['p.ref']['checked'])) {
1086  print '<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_project" value="'.dol_escape_htmltag($search_project).'"></td>';
1087 }
1088 // Thirpdarty
1089 if (!empty($arrayfields['s.nom']['checked'])) {
1090  print '<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_company" value="'.dol_escape_htmltag($search_company).'"'.($socid > 0 ? " disabled" : "").'></td>';
1091 }
1092 // Alias
1093 if (!empty($arrayfields['s.name_alias']['checked'])) {
1094  print '<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_company_alias" value="'.dol_escape_htmltag($search_company_alias).'"></td>';
1095 }
1096 // Town
1097 if (!empty($arrayfields['s.town']['checked'])) {
1098  print '<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_town" value="'.dol_escape_htmltag($search_town).'"></td>';
1099 }
1100 // Zip
1101 if (!empty($arrayfields['s.zip']['checked'])) {
1102  print '<td class="liste_titre center"><input class="flat maxwidth50" type="text" name="search_zip" value="'.dol_escape_htmltag($search_zip).'"></td>';
1103 }
1104 // State
1105 if (!empty($arrayfields['state.nom']['checked'])) {
1106  print '<td class="liste_titre">';
1107  print '<input class="flat" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
1108  print '</td>';
1109 }
1110 // Country
1111 if (!empty($arrayfields['country.code_iso']['checked'])) {
1112  print '<td class="liste_titre center">';
1113  print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100');
1114  print '</td>';
1115 }
1116 // Company type
1117 if (!empty($arrayfields['typent.code']['checked'])) {
1118  print '<td class="liste_titre maxwidthonsmartphone center">';
1119  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);
1120  print '</td>';
1121 }
1122 // Condition of payment
1123 if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) {
1124  print '<td class="liste_titre left">';
1125  print $form->getSelectConditionsPaiements($search_paymentcond, 'search_paymentcond', -1, 1, 1, 'maxwidth100');
1126  print '</td>';
1127 }
1128 // Payment mode
1129 if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) {
1130  print '<td class="liste_titre left">';
1131  print $form->select_types_paiements($search_paymentmode, 'search_paymentmode', '', 0, 1, 1, 20, 1, 'maxwidth100', 1);
1132  print '</td>';
1133 }
1134 if (!empty($arrayfields['f.total_ht']['checked'])) {
1135  // Amount without tax
1136  print '<td class="liste_titre right">';
1137  print '<input class="flat" type="text" size="5" name="search_montant_ht" value="'.dol_escape_htmltag($search_montant_ht).'">';
1138  print '</td>';
1139 }
1140 if (!empty($arrayfields['f.total_vat']['checked'])) {
1141  // Amount vat
1142  print '<td class="liste_titre right">';
1143  print '<input class="flat" type="text" size="5" name="search_montant_vat" value="'.dol_escape_htmltag($search_montant_vat).'">';
1144  print '</td>';
1145 }
1146 if (!empty($arrayfields['f.total_localtax1']['checked'])) {
1147  // Amount tax 1
1148  print '<td class="liste_titre right">';
1149  print '<input class="flat" type="text" size="5" name="search_montant_localtax1" value="'.dol_escape_htmltag($search_montant_localtax1).'">';
1150  print '</td>';
1151 }
1152 if (!empty($arrayfields['f.total_localtax2']['checked'])) {
1153  // Amount tax 2
1154  print '<td class="liste_titre right">';
1155  print '<input class="flat" type="text" size="5" name="search_montant_localtax2" value="'.dol_escape_htmltag($search_montant_localtax2).'">';
1156  print '</td>';
1157 }
1158 if (!empty($arrayfields['f.total_ttc']['checked'])) {
1159  // Amount inc tac
1160  print '<td class="liste_titre right">';
1161  print '<input class="flat" type="text" size="5" name="search_montant_ttc" value="'.dol_escape_htmltag($search_montant_ttc).'">';
1162  print '</td>';
1163 }
1164 if (!empty($arrayfields['u.login']['checked'])) {
1165  // Author
1166  print '<td class="liste_titre" align="center">';
1167  print '<input class="flat" size="4" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).'">';
1168  print '</td>';
1169 }
1170 if (!empty($arrayfields['dynamount_payed']['checked'])) {
1171  print '<td class="liste_titre right">';
1172  print '</td>';
1173 }
1174 if (!empty($arrayfields['rtp']['checked'])) {
1175  print '<td class="liste_titre">';
1176  print '</td>';
1177 }
1178 if (!empty($arrayfields['f.multicurrency_code']['checked'])) {
1179  // Currency
1180  print '<td class="liste_titre">';
1181  print $form->selectMultiCurrency($search_multicurrency_code, 'search_multicurrency_code', 1);
1182  print '</td>';
1183 }
1184 if (!empty($arrayfields['f.multicurrency_tx']['checked'])) {
1185  // Currency rate
1186  print '<td class="liste_titre">';
1187  print '<input class="flat" type="text" size="4" name="search_multicurrency_tx" value="'.dol_escape_htmltag($search_multicurrency_tx).'">';
1188  print '</td>';
1189 }
1190 if (!empty($arrayfields['f.multicurrency_total_ht']['checked'])) {
1191  // Amount
1192  print '<td class="liste_titre right">';
1193  print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_ht" value="'.dol_escape_htmltag($search_multicurrency_montant_ht).'">';
1194  print '</td>';
1195 }
1196 if (!empty($arrayfields['f.multicurrency_total_vat']['checked'])) {
1197  // Amount
1198  print '<td class="liste_titre right">';
1199  print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_vat" value="'.dol_escape_htmltag($search_multicurrency_montant_vat).'">';
1200  print '</td>';
1201 }
1202 if (!empty($arrayfields['f.multicurrency_total_ttc']['checked'])) {
1203  // Amount
1204  print '<td class="liste_titre right">';
1205  print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_ttc" value="'.dol_escape_htmltag($search_multicurrency_montant_ttc).'">';
1206  print '</td>';
1207 }
1208 if (!empty($arrayfields['multicurrency_dynamount_payed']['checked'])) {
1209  print '<td class="liste_titre">';
1210  print '</td>';
1211 }
1212 if (!empty($arrayfields['multicurrency_rtp']['checked'])) {
1213  print '<td class="liste_titre right">';
1214  print '</td>';
1215 }
1216 // Extra fields
1217 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
1218 
1219 // Fields from hook
1220 $parameters = array('arrayfields'=>$arrayfields);
1221 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1222 print $hookmanager->resPrint;
1223 // Date creation
1224 if (!empty($arrayfields['f.datec']['checked'])) {
1225  print '<td class="liste_titre">';
1226  print '</td>';
1227 }
1228 // Date modification
1229 if (!empty($arrayfields['f.tms']['checked'])) {
1230  print '<td class="liste_titre">';
1231  print '</td>';
1232 }
1233 // Status
1234 if (!empty($arrayfields['f.fk_statut']['checked'])) {
1235  print '<td class="liste_titre maxwidthonsmartphone right">';
1236  $liststatus = array('0'=>$langs->trans("Draft"), '1'=>$langs->trans("Unpaid"), '2'=>$langs->trans("Paid"));
1237  print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'onrightofpage', 1);
1238  print '</td>';
1239 }
1240 // Action column
1241 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1242  print '<td class="liste_titre middle">';
1243  $searchpicto = $form->showFilterButtons();
1244  print $searchpicto;
1245  print '</td>';
1246 }
1247 
1248 print "</tr>\n";
1249 
1250 print '<tr class="liste_titre">';
1251 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1252  print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
1253 }
1254 if (!empty($arrayfields['f.ref']['checked'])) {
1255  print_liste_field_titre($arrayfields['f.ref']['label'], $_SERVER['PHP_SELF'], 'f.ref,f.rowid', '', $param, '', $sortfield, $sortorder);
1256 }
1257 if (!empty($arrayfields['f.ref_supplier']['checked'])) {
1258  print_liste_field_titre($arrayfields['f.ref_supplier']['label'], $_SERVER["PHP_SELF"], 'f.ref_supplier', '', $param, '', $sortfield, $sortorder);
1259 }
1260 if (!empty($arrayfields['f.type']['checked'])) {
1261  print_liste_field_titre($arrayfields['f.type']['label'], $_SERVER["PHP_SELF"], 'f.type', '', $param, '', $sortfield, $sortorder);
1262 }
1263 if (!empty($arrayfields['f.label']['checked'])) {
1264  print_liste_field_titre($arrayfields['f.label']['label'], $_SERVER['PHP_SELF'], "f.libelle,f.rowid", '', $param, '', $sortfield, $sortorder);
1265 }
1266 if (!empty($arrayfields['f.datef']['checked'])) {
1267  print_liste_field_titre($arrayfields['f.datef']['label'], $_SERVER['PHP_SELF'], 'f.datef,f.rowid', '', $param, '', $sortfield, $sortorder, 'center ');
1268 }
1269 if (!empty($arrayfields['f.date_lim_reglement']['checked'])) {
1270  print_liste_field_titre($arrayfields['f.date_lim_reglement']['label'], $_SERVER['PHP_SELF'], "f.date_lim_reglement", '', $param, '', $sortfield, $sortorder, 'center ');
1271 }
1272 if (!empty($arrayfields['p.ref']['checked'])) {
1273  print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER['PHP_SELF'], "p.ref", '', $param, '', $sortfield, $sortorder);
1274 }
1275 if (!empty($arrayfields['s.nom']['checked'])) {
1276  print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER['PHP_SELF'], 's.nom', '', $param, '', $sortfield, $sortorder);
1277 }
1278 if (!empty($arrayfields['s.name_alias']['checked'])) {
1279  print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER['PHP_SELF'], 's.name_alias', '', $param, '', $sortfield, $sortorder);
1280 }
1281 if (!empty($arrayfields['s.town']['checked'])) {
1282  print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder);
1283 }
1284 if (!empty($arrayfields['s.zip']['checked'])) {
1285  print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder, 'center ');
1286 }
1287 if (!empty($arrayfields['state.nom']['checked'])) {
1288  print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.name_alias", "", $param, '', $sortfield, $sortorder);
1289 }
1290 if (!empty($arrayfields['state.name_alias']['checked'])) {
1291  print_liste_field_titre($arrayfields['state.name_alias']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder);
1292 }
1293 if (!empty($arrayfields['country.code_iso']['checked'])) {
1294  print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center ');
1295 }
1296 if (!empty($arrayfields['typent.code']['checked'])) {
1297  print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center ');
1298 }
1299 if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) {
1300  print_liste_field_titre($arrayfields['f.fk_cond_reglement']['label'], $_SERVER["PHP_SELF"], "f.fk_cond_reglement", "", $param, "", $sortfield, $sortorder);
1301 }
1302 if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) {
1303  print_liste_field_titre($arrayfields['f.fk_mode_reglement']['label'], $_SERVER["PHP_SELF"], "f.fk_mode_reglement", "", $param, "", $sortfield, $sortorder);
1304 }
1305 if (!empty($arrayfields['f.total_ht']['checked'])) {
1306  print_liste_field_titre($arrayfields['f.total_ht']['label'], $_SERVER['PHP_SELF'], 'f.total_ht', '', $param, '', $sortfield, $sortorder, 'right ');
1307 }
1308 if (!empty($arrayfields['f.total_vat']['checked'])) {
1309  print_liste_field_titre($arrayfields['f.total_vat']['label'], $_SERVER['PHP_SELF'], 'f.total_tva', '', $param, '', $sortfield, $sortorder, 'right ');
1310 }
1311 if (!empty($arrayfields['f.total_localtax1']['checked'])) {
1312  print_liste_field_titre($arrayfields['f.total_localtax1']['label'], $_SERVER['PHP_SELF'], 'f.localtax1', '', $param, '', $sortfield, $sortorder, 'right ');
1313 }
1314 if (!empty($arrayfields['f.total_localtax2']['checked'])) {
1315  print_liste_field_titre($arrayfields['f.total_localtax2']['label'], $_SERVER['PHP_SELF'], 'f.localtax2', '', $param, '', $sortfield, $sortorder, 'right ');
1316 }
1317 if (!empty($arrayfields['f.total_ttc']['checked'])) {
1318  print_liste_field_titre($arrayfields['f.total_ttc']['label'], $_SERVER['PHP_SELF'], 'f.total_ttc', '', $param, '', $sortfield, $sortorder, 'right ');
1319 }
1320 if (!empty($arrayfields['u.login']['checked'])) {
1321  print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.login', '', $param, 'align="center"', $sortfield, $sortorder);
1322 }
1323 if (!empty($arrayfields['dynamount_payed']['checked'])) {
1324  print_liste_field_titre($arrayfields['dynamount_payed']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right ');
1325 }
1326 if (!empty($arrayfields['rtp']['checked'])) {
1327  print_liste_field_titre($arrayfields['rtp']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right ');
1328 }
1329 if (!empty($arrayfields['f.multicurrency_code']['checked'])) {
1330  print_liste_field_titre($arrayfields['f.multicurrency_code']['label'], $_SERVER['PHP_SELF'], 'f.multicurrency_code', '', $param, '', $sortfield, $sortorder);
1331 }
1332 if (!empty($arrayfields['f.multicurrency_tx']['checked'])) {
1333  print_liste_field_titre($arrayfields['f.multicurrency_tx']['label'], $_SERVER['PHP_SELF'], 'f.multicurrency_tx', '', $param, '', $sortfield, $sortorder);
1334 }
1335 if (!empty($arrayfields['f.multicurrency_total_ht']['checked'])) {
1336  print_liste_field_titre($arrayfields['f.multicurrency_total_ht']['label'], $_SERVER['PHP_SELF'], 'f.multicurrency_total_ht', '', $param, 'class="right"', $sortfield, $sortorder);
1337 }
1338 if (!empty($arrayfields['f.multicurrency_total_vat']['checked'])) {
1339  print_liste_field_titre($arrayfields['f.multicurrency_total_vat']['label'], $_SERVER['PHP_SELF'], 'f.multicurrency_total_tva', '', $param, 'class="right"', $sortfield, $sortorder);
1340 }
1341 if (!empty($arrayfields['f.multicurrency_total_ttc']['checked'])) {
1342  print_liste_field_titre($arrayfields['f.multicurrency_total_ttc']['label'], $_SERVER['PHP_SELF'], 'f.multicurrency_total_ttc', '', $param, 'class="right"', $sortfield, $sortorder);
1343 }
1344 if (!empty($arrayfields['multicurrency_dynamount_payed']['checked'])) {
1345  print_liste_field_titre($arrayfields['multicurrency_dynamount_payed']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder);
1346 }
1347 if (!empty($arrayfields['multicurrency_rtp']['checked'])) {
1348  print_liste_field_titre($arrayfields['multicurrency_rtp']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder);
1349 }
1350 // Extra fields
1351 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
1352 // Hook fields
1353 $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
1354 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1355 print $hookmanager->resPrint;
1356 if (!empty($arrayfields['f.datec']['checked'])) {
1357  print_liste_field_titre($arrayfields['f.datec']['label'], $_SERVER["PHP_SELF"], "f.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1358 }
1359 if (!empty($arrayfields['f.tms']['checked'])) {
1360  print_liste_field_titre($arrayfields['f.tms']['label'], $_SERVER["PHP_SELF"], "f.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1361 }
1362 if (!empty($arrayfields['f.fk_statut']['checked'])) {
1363  print_liste_field_titre($arrayfields['f.fk_statut']['label'], $_SERVER["PHP_SELF"], "fk_statut,paye,type", "", $param, '', $sortfield, $sortorder, 'right ');
1364 }
1365 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1366  print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
1367 }
1368 print "</tr>\n";
1369 
1370 $facturestatic = new FactureFournisseur($db);
1371 $supplierstatic = new Fournisseur($db);
1372 $projectstatic = new Project($db);
1373 $userstatic = new User($db);
1374 
1375 if ($num > 0) {
1376  $i = 0;
1377  $totalarray = array();
1378  $totalarray['nbfield']=0;
1379  $totalarray['val'] = array();
1380  $totalarray['val']['f.total_ht']=0;
1381  $totalarray['val']['f.total_vat']=0;
1382  $totalarray['val']['f.total_localtax1']=0;
1383  $totalarray['val']['f.total_localtax1']=0;
1384  $totalarray['val']['f.total_ttc']=0;
1385 
1386  while ($i < min($num, $limit)) {
1387  $obj = $db->fetch_object($resql);
1388 
1389  $datelimit = $db->jdate($obj->datelimite);
1390  $facturestatic->id = $obj->facid;
1391  $facturestatic->ref = $obj->ref;
1392  $facturestatic->type = $obj->type;
1393  $facturestatic->ref_supplier = $obj->ref_supplier;
1394  $facturestatic->date_echeance = $db->jdate($obj->datelimite);
1395  $facturestatic->statut = $obj->fk_statut;
1396  $facturestatic->note_public = $obj->note_public;
1397  $facturestatic->note_private = $obj->note_private;
1398  $facturestatic->multicurrency_code = $obj->multicurrency_code;
1399  $facturestatic->multicurrency_tx = $obj->multicurrency_tx;
1400  $facturestatic->multicurrency_total_ht = $obj->multicurrency_total_ht;
1401  $facturestatic->multicurrency_total_tva = $obj->multicurrency_total_vat;
1402  $facturestatic->multicurrency_total_ttc = $obj->multicurrency_total_ttc;
1403 
1404  $thirdparty->id = $obj->socid;
1405  $thirdparty->name = $obj->name;
1406  $thirdparty->name_alias = $obj->alias;
1407  $thirdparty->client = $obj->client;
1408  $thirdparty->fournisseur = $obj->fournisseur;
1409  $thirdparty->code_client = $obj->code_client;
1410  $thirdparty->code_compta_client = $obj->code_compta_client;
1411  $thirdparty->code_fournisseur = $obj->code_fournisseur;
1412  $thirdparty->code_compta_fournisseur = $obj->code_compta_fournisseur;
1413  $thirdparty->email = $obj->email;
1414  $thirdparty->country_code = $obj->country_code;
1415 
1416  $paiement = $facturestatic->getSommePaiement();
1417  $totalcreditnotes = $facturestatic->getSumCreditNotesUsed();
1418  $totaldeposits = $facturestatic->getSumDepositsUsed();
1419  $totalpay = $paiement + $totalcreditnotes + $totaldeposits;
1420  $remaintopay = $obj->total_ttc - $totalpay;
1421  $multicurrency_paiement = $facturestatic->getSommePaiement(1);
1422  $multicurrency_totalcreditnotes = $facturestatic->getSumCreditNotesUsed(1);
1423  $multicurrency_totaldeposits = $facturestatic->getSumDepositsUsed(1);
1424  $multicurrency_totalpay = $multicurrency_paiement + $multicurrency_totalcreditnotes + $multicurrency_totaldeposits;
1425  $multicurrency_remaintopay = price2num($facturestatic->multicurrency_total_ttc - $multicurrency_totalpay);
1426 
1427  $facturestatic->alreadypaid = ($paiement ? $paiement : 0);
1428  $facturestatic->paye = $obj->paye;
1429  $facturestatic->statut = $obj->fk_statut;
1430  $facturestatic->type = $obj->type;
1431 
1432 
1433  //If invoice has been converted and the conversion has been used, we dont have remain to pay on invoice
1434  if ($facturestatic->type == FactureFournisseur::TYPE_CREDIT_NOTE) {
1435  if ($facturestatic->isCreditNoteUsed()) {
1436  $remaintopay = -$facturestatic->getSumFromThisCreditNotesNotUsed();
1437  }
1438  }
1439 
1440  print '<tr class="oddeven">';
1441  // Action column
1442  if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1443  print '<td class="nowrap center">';
1444  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1445  $selected = 0;
1446  if (in_array($obj->facid, $arrayofselected)) {
1447  $selected = 1;
1448  }
1449  print '<input id="cb'.$obj->facid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->facid.'"'.($selected ? ' checked="checked"' : '').'>';
1450  }
1451  print '</td>';
1452  }
1453  if (!empty($arrayfields['f.ref']['checked'])) {
1454  print '<td class="nowraponall">';
1455 
1456  print '<table class="nobordernopadding"><tr class="nocellnopadd">';
1457  // Picto + Ref
1458  print '<td class="nobordernopadding nowraponall">';
1459  print $facturestatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1);
1460 
1461  $filename = dol_sanitizeFileName($obj->ref);
1462  $filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($obj->facid, 2, 0, 0, $facturestatic, 'invoice_supplier').dol_sanitizeFileName($obj->ref);
1463  $subdir = get_exdir($obj->facid, 2, 0, 0, $facturestatic, 'invoice_supplier').dol_sanitizeFileName($obj->ref);
1464  print $formfile->getDocumentsLink('facture_fournisseur', $subdir, $filedir);
1465  print '</td></tr></table>';
1466 
1467  print "</td>\n";
1468  if (!$i) {
1469  $totalarray['nbfield']++;
1470  }
1471  }
1472 
1473  // Supplier ref
1474  if (!empty($arrayfields['f.ref_supplier']['checked'])) {
1475  print '<td class="nowrap tdoverflowmax150" title="'.dol_escape_htmltag($obj->ref_supplier).'">';
1476  print $obj->ref_supplier;
1477  print '</td>';
1478  if (!$i) {
1479  $totalarray['nbfield']++;
1480  }
1481  }
1482 
1483  // Type
1484  if (!empty($arrayfields['f.type']['checked'])) {
1485  print '<td class="nowrap">';
1486  print $facturestatic->getLibType();
1487  print "</td>";
1488  if (!$i) {
1489  $totalarray['nbfield']++;
1490  }
1491  }
1492 
1493  // Label
1494  if (!empty($arrayfields['f.label']['checked'])) {
1495  print '<td class="nowrap">';
1496  print dol_escape_htmltag($obj->label);
1497  print '</td>';
1498  if (!$i) {
1499  $totalarray['nbfield']++;
1500  }
1501  }
1502 
1503  // Date
1504  if (!empty($arrayfields['f.datef']['checked'])) {
1505  print '<td class="center nowrap">';
1506  print dol_print_date($db->jdate($obj->datef), 'day');
1507  print '</td>';
1508  if (!$i) {
1509  $totalarray['nbfield']++;
1510  }
1511  }
1512 
1513  // Date limit
1514  if (!empty($arrayfields['f.date_lim_reglement']['checked'])) {
1515  print '<td class="center nowraponall">'.dol_print_date($datelimit, 'day');
1516  if ($facturestatic->hasDelay()) {
1517  print img_warning($langs->trans('Alert').' - '.$langs->trans('Late'));
1518  }
1519  print '</td>';
1520  if (!$i) {
1521  $totalarray['nbfield']++;
1522  }
1523  }
1524 
1525  // Project
1526  if (!empty($arrayfields['p.ref']['checked'])) {
1527  print '<td class="nowrap">';
1528  if ($obj->project_id > 0) {
1529  $projectstatic->id = $obj->project_id;
1530  $projectstatic->ref = $obj->project_ref;
1531  $projectstatic->title = $obj->project_label;
1532  print $projectstatic->getNomUrl(1);
1533  }
1534  print '</td>';
1535  if (!$i) {
1536  $totalarray['nbfield']++;
1537  }
1538  }
1539 
1540  // Third party
1541  if (!empty($arrayfields['s.nom']['checked'])) {
1542  print '<td class="tdoverflowmax150">';
1543  print $thirdparty->getNomUrl(1, 'supplier', 0, 0, -1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1);
1544  print '</td>';
1545  if (!$i) {
1546  $totalarray['nbfield']++;
1547  }
1548  }
1549  // Alias
1550  if (!empty($arrayfields['s.name_alias']['checked'])) {
1551  print '<td class="tdoverflowmax150">';
1552  print dol_escape_htmltag($thirdparty->name_alias);
1553  print '</td>';
1554  if (!$i) {
1555  $totalarray['nbfield']++;
1556  }
1557  }
1558  // Town
1559  if (!empty($arrayfields['s.town']['checked'])) {
1560  print '<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->town).'">';
1561  print dol_escape_htmltag($obj->town);
1562  print '</td>';
1563  if (!$i) {
1564  $totalarray['nbfield']++;
1565  }
1566  }
1567  // Zip
1568  if (!empty($arrayfields['s.zip']['checked'])) {
1569  print '<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->zip).'">';
1570  print dol_escape_htmltag($obj->zip);
1571  print '</td>';
1572  if (!$i) {
1573  $totalarray['nbfield']++;
1574  }
1575  }
1576  // State
1577  if (!empty($arrayfields['state.nom']['checked'])) {
1578  print '<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->state_name).'">';
1579  print dol_escape_htmltag($obj->state_name);
1580  print "</td>\n";
1581  if (!$i) {
1582  $totalarray['nbfield']++;
1583  }
1584  }
1585  // Country
1586  if (!empty($arrayfields['country.code_iso']['checked'])) {
1587  print '<td class="center">';
1588  $tmparray = getCountry($obj->fk_pays, 'all');
1589  print $tmparray['label'];
1590  print '</td>';
1591  if (!$i) {
1592  $totalarray['nbfield']++;
1593  }
1594  }
1595  // Type ent
1596  if (!empty($arrayfields['typent.code']['checked'])) {
1597  print '<td class="center">';
1598  if (empty($typenArray)) {
1599  $typenArray = $formcompany->typent_array(1);
1600  }
1601  print $typenArray[$obj->typent_code];
1602  print '</td>';
1603  if (!$i) {
1604  $totalarray['nbfield']++;
1605  }
1606  }
1607 
1608  // Payment condition
1609  if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) {
1610  $s = $form->form_conditions_reglement($_SERVER['PHP_SELF'], $obj->fk_cond_reglement, 'none', 1, '', -1, -1, 1);
1611  print '<td class="tdoverflowmax100" title="'.dol_escape_htmltag($s).'">';
1612  print dol_escape_htmltag($s);
1613  print '</td>';
1614  if (!$i) {
1615  $totalarray['nbfield']++;
1616  }
1617  }
1618  // Payment mode
1619  if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) {
1620  $s = $form->form_modes_reglement($_SERVER['PHP_SELF'], $obj->fk_mode_reglement, 'none', '', -1, 0, '', 1);
1621  print '<td class="tdoverflowmax100" title="'.dol_escape_htmltag($s).'">';
1622  print dol_escape_htmltag($s);
1623  print '</td>';
1624  if (!$i) {
1625  $totalarray['nbfield']++;
1626  }
1627  }
1628 
1629  // Amount HT
1630  if (!empty($arrayfields['f.total_ht']['checked'])) {
1631  print '<td class="right nowrap"><span class="amount">'.price($obj->total_ht)."</span></td>\n";
1632  if (!$i) {
1633  $totalarray['nbfield']++;
1634  }
1635  if (!$i) {
1636  $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ht';
1637  }
1638  $totalarray['val']['f.total_ht'] += $obj->total_ht;
1639  }
1640  // Amount VAT
1641  if (!empty($arrayfields['f.total_vat']['checked'])) {
1642  print '<td class="right nowrap"><span class="amount">'.price($obj->total_vat)."</span></td>\n";
1643  if (!$i) {
1644  $totalarray['nbfield']++;
1645  }
1646  if (!$i) {
1647  $totalarray['pos'][$totalarray['nbfield']] = 'f.total_vat';
1648  }
1649  $totalarray['val']['f.total_vat'] += $obj->total_vat;
1650  }
1651  // Amount LocalTax1
1652  if (!empty($arrayfields['f.total_localtax1']['checked'])) {
1653  print '<td class="right nowrap"><span class="amount">'.price($obj->total_localtax1)."</span></td>\n";
1654  if (!$i) {
1655  $totalarray['nbfield']++;
1656  }
1657  if (!$i) {
1658  $totalarray['pos'][$totalarray['nbfield']] = 'f.total_localtax1';
1659  }
1660  $totalarray['val']['f.total_localtax1'] += $obj->total_localtax1;
1661  }
1662  // Amount LocalTax2
1663  if (!empty($arrayfields['f.total_localtax2']['checked'])) {
1664  print '<td class="right nowrap"><span class="amount">'.price($obj->total_localtax2)."</span></td>\n";
1665  if (!$i) {
1666  $totalarray['nbfield']++;
1667  }
1668  if (!$i) {
1669  $totalarray['pos'][$totalarray['nbfield']] = 'f.total_localtax2';
1670  }
1671  $totalarray['val']['f.total_localtax2'] += $obj->total_localtax2;
1672  }
1673  // Amount TTC
1674  if (!empty($arrayfields['f.total_ttc']['checked'])) {
1675  print '<td class="right nowrap"><span class="amount">'.price($obj->total_ttc)."</span></td>\n";
1676  if (!$i) {
1677  $totalarray['nbfield']++;
1678  }
1679  if (!$i) {
1680  $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ttc';
1681  }
1682  $totalarray['val']['f.total_ttc'] += $obj->total_ttc;
1683  }
1684 
1685  $userstatic->id = $obj->fk_user_author;
1686  $userstatic->login = $obj->login;
1687  $userstatic->lastname = $obj->lastname;
1688  $userstatic->firstname = $obj->firstname;
1689  $userstatic->email = $obj->user_email;
1690  $userstatic->statut = $obj->user_statut;
1691  $userstatic->entity = $obj->entity;
1692  $userstatic->photo = $obj->photo;
1693  $userstatic->office_phone = $obj->office_phone;
1694  $userstatic->office_fax = $obj->office_fax;
1695  $userstatic->user_mobile = $obj->user_mobile;
1696  $userstatic->job = $obj->job;
1697  $userstatic->gender = $obj->gender;
1698 
1699  // Author
1700  if (!empty($arrayfields['u.login']['checked'])) {
1701  print '<td class="tdoverflowmax150">';
1702  if ($userstatic->id) {
1703  print $userstatic->getLoginUrl(-1);
1704  } else {
1705  print '&nbsp;';
1706  }
1707  print "</td>\n";
1708  if (!$i) {
1709  $totalarray['nbfield']++;
1710  }
1711  }
1712 
1713  if (!empty($arrayfields['dynamount_payed']['checked'])) {
1714  print '<td class="right nowrap"><span class="amount">'.(!empty($totalpay) ?price($totalpay, 0, $langs) : '').'</span></td>'; // TODO Use a denormalized field
1715  if (!$i) {
1716  $totalarray['nbfield']++;
1717  }
1718  if (!$i) {
1719  $totalarray['pos'][$totalarray['nbfield']] = 'totalam';
1720  }
1721  $totalarray['val']['totalam'] += $totalpay;
1722  }
1723 
1724  if (!empty($arrayfields['rtp']['checked'])) {
1725  print '<td class="right nowrap">'.(!empty($remaintopay) ?price($remaintopay, 0, $langs) : '&nbsp;').'</td>'; // TODO Use a denormalized field
1726  if (!$i) {
1727  $totalarray['nbfield']++;
1728  }
1729  if (!$i) {
1730  $totalarray['pos'][$totalarray['nbfield']] = 'rtp';
1731  }
1732  $totalarray['val']['rtp'] += $remaintopay;
1733  }
1734 
1735  // Currency
1736  if (!empty($arrayfields['f.multicurrency_code']['checked'])) {
1737  print '<td class="nowrap">'.$obj->multicurrency_code.' - '.$langs->trans('Currency'.$obj->multicurrency_code)."</td>\n";
1738  if (!$i) {
1739  $totalarray['nbfield']++;
1740  }
1741  }
1742 
1743  // Currency rate
1744  if (!empty($arrayfields['f.multicurrency_tx']['checked'])) {
1745  print '<td class="nowrap">';
1746  $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code);
1747  print "</td>\n";
1748  if (!$i) {
1749  $totalarray['nbfield']++;
1750  }
1751  }
1752  // Amount HT
1753  if (!empty($arrayfields['f.multicurrency_total_ht']['checked'])) {
1754  print '<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ht)."</span></td>\n";
1755  if (!$i) {
1756  $totalarray['nbfield']++;
1757  }
1758  }
1759  // Amount VAT
1760  if (!empty($arrayfields['f.multicurrency_total_vat']['checked'])) {
1761  print '<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_vat)."</span></td>\n";
1762  if (!$i) {
1763  $totalarray['nbfield']++;
1764  }
1765  }
1766  // Amount TTC
1767  if (!empty($arrayfields['f.multicurrency_total_ttc']['checked'])) {
1768  print '<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ttc)."</span></td>\n";
1769  if (!$i) {
1770  $totalarray['nbfield']++;
1771  }
1772  }
1773  if (!empty($arrayfields['multicurrency_dynamount_payed']['checked'])) {
1774  print '<td class="right nowrap"><span class="amount">'.(!empty($multicurrency_totalpay) ?price($multicurrency_totalpay, 0, $langs) : '').'</span></td>'; // TODO Use a denormalized field
1775  if (!$i) {
1776  $totalarray['nbfield']++;
1777  }
1778  }
1779 
1780  // Pending amount
1781  if (!empty($arrayfields['multicurrency_rtp']['checked'])) {
1782  print '<td class="right nowrap"><span class="amount">';
1783  print (!empty($multicurrency_remaintopay) ? price($multicurrency_remaintopay, 0, $langs) : '');
1784  print '</span></td>'; // TODO Use a denormalized field
1785  if (!$i) {
1786  $totalarray['nbfield']++;
1787  }
1788  }
1789 
1790 
1791  // Extra fields
1792  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1793  // Fields from hook
1794  $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
1795  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1796  print $hookmanager->resPrint;
1797 
1798  // Date creation
1799  if (!empty($arrayfields['f.datec']['checked'])) {
1800  print '<td class="center nowrap">';
1801  print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
1802  print '</td>';
1803  if (!$i) {
1804  $totalarray['nbfield']++;
1805  }
1806  }
1807  // Date modification
1808  if (!empty($arrayfields['f.tms']['checked'])) {
1809  print '<td class="center nowrap">';
1810  print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
1811  print '</td>';
1812  if (!$i) {
1813  $totalarray['nbfield']++;
1814  }
1815  }
1816  // Status
1817  if (!empty($arrayfields['f.fk_statut']['checked'])) {
1818  print '<td class="right nowrap">';
1819  print $facturestatic->LibStatut($obj->paye, $obj->fk_statut, 5, $paiement, $obj->type);
1820  print "</td>";
1821  if (!$i) {
1822  $totalarray['nbfield']++;
1823  }
1824  }
1825 
1826  // Action column
1827  if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1828  print '<td class="nowrap center">';
1829  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1830  $selected = 0;
1831  if (in_array($obj->facid, $arrayofselected)) {
1832  $selected = 1;
1833  }
1834  print '<input id="cb'.$obj->facid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->facid.'"'.($selected ? ' checked="checked"' : '').'>';
1835  }
1836  print '</td>';
1837  }
1838  if (!$i) {
1839  $totalarray['nbfield']++;
1840  }
1841 
1842  print "</tr>\n";
1843 
1844  $i++;
1845  }
1846 
1847  // Show total line
1848  include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
1849 }
1850 
1851 // If no record found
1852 if ($num == 0) {
1853  $colspan = 1;
1854  foreach ($arrayfields as $key => $val) {
1855  if (!empty($val['checked'])) {
1856  $colspan++;
1857  }
1858  }
1859  print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
1860 }
1861 
1862 $db->free($resql);
1863 
1864 $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
1865 $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1866 print $hookmanager->resPrint;
1867 
1868 print "</table>\n";
1869 print '</div>';
1870 
1871 print "</form>\n";
1872 
1873 $hidegeneratedfilelistifempty = 1;
1874 if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
1875  $hidegeneratedfilelistifempty = 0;
1876 }
1877 
1878 // Show list of available documents
1879 $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
1880 $urlsource .= str_replace('&amp;', '&', $param);
1881 
1882 $filedir = $diroutputmassaction;
1883 $genallowed = $user->rights->facture->lire;
1884 $delallowed = $user->rights->facture->creer;
1885 $title = '';
1886 
1887 print $formfile->showdocuments('massfilesarea_supplier_invoice', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
1888 
1889 // End of page
1890 llxFooter();
1891 $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:47
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.