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