dolibarr 23.0.4
list.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2002-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2019 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005-2013 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2013-2019 Philippe Grand <philippe.grand@atoo-net.com>
6 * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
7 * Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
8 * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
9 * Copyright (C) 2015-2007 Juanjo Menent <jmenent@2byte.es>
10 * Copyright (C) 2015 Abbes Bahfir <bafbes@gmail.com>
11 * Copyright (C) 2015-2016 Ferran Marcet <fmarcet@2byte.es>
12 * Copyright (C) 2017 Josep Lluís Amador <joseplluis@lliuretic.cat>
13 * Copyright (C) 2018-2022 Charlene Benke <charlene@patas-monkey.com>
14 * Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
15 * Copyright (C) 2019-2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
16 * Copyright (C) 2023 Nick Fragoulis
17 * Copyright (C) 2023 Joachim Kueter <git-jk@bloxera.com>
18 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
19 *
20 * This program is free software; you can redistribute it and/or modify
21 * it under the terms of the GNU General Public License as published by
22 * the Free Software Foundation; either version 3 of the License, or
23 * (at your option) any later version.
24 *
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
29 *
30 * You should have received a copy of the GNU General Public License
31 * along with this program. If not, see <https://www.gnu.org/licenses/>.
32 */
33
40// Load Dolibarr environment
41require '../../main.inc.php';
42require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
43require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
44require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
45require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
46require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
47require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php';
48require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
49require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
50require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
51require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
52
62// Load translation files required by the page
63$langs->loadLangs(array('products', 'bills', 'companies', 'projects'));
64
65$action = GETPOST('action', 'aZ09');
66$massaction = GETPOST('massaction', 'alpha');
67$show_files = GETPOSTINT('show_files');
68$confirm = GETPOST('confirm', 'alpha');
69$toselect = GETPOST('toselect', 'array:int');
70$optioncss = GETPOST('optioncss', 'alpha');
71$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'supplierinvoicelist';
72$mode = GETPOST('mode', 'aZ'); // The output mode ('list', 'kanban', 'hierarchy', 'calendar', ...)
73
74$search_all = trim(GETPOST('search_all', 'alphanohtml'));
75$search_label = GETPOST("search_label", "alpha");
76$search_amount_no_tax = GETPOST("search_amount_no_tax", "alpha");
77$search_amount_all_tax = GETPOST("search_amount_all_tax", "alpha");
78$search_ref = GETPOST('sf_ref') ? GETPOST('sf_ref', 'alpha') : GETPOST('search_ref', 'alpha');
79$search_refsupplier = GETPOST('search_refsupplier', 'alpha');
80$search_type = GETPOST('search_type', 'intcomma');
81$search_subtype = GETPOST('search_subtype', 'intcomma');
82$search_project = GETPOST('search_project', 'alpha');
83$search_company = GETPOST('search_company', 'alpha');
84$search_company_alias = GETPOST('search_company_alias', 'alpha');
85$search_montant_ht = GETPOST('search_montant_ht', 'alpha');
86$search_montant_vat = GETPOST('search_montant_vat', 'alpha');
87$search_montant_localtax1 = GETPOST('search_montant_localtax1', 'alpha');
88$search_montant_localtax2 = GETPOST('search_montant_localtax2', 'alpha');
89$search_montant_ttc = GETPOST('search_montant_ttc', 'alpha');
90$search_login = GETPOST('search_login', 'alpha');
91$search_multicurrency_code = GETPOST('search_multicurrency_code', 'alpha');
92$search_multicurrency_tx = GETPOST('search_multicurrency_tx', 'alpha');
93$search_multicurrency_montant_ht = GETPOST('search_multicurrency_montant_ht', 'alpha');
94$search_multicurrency_montant_vat = GETPOST('search_multicurrency_montant_vat', 'alpha');
95$search_multicurrency_montant_ttc = GETPOST('search_multicurrency_montant_ttc', 'alpha');
96$search_status = GETPOST('search_status', 'intcomma'); // Can be '' or a numeric
97$search_paymentmode = GETPOST('search_paymentmode', 'intcomma');
98$search_paymentcond = GETPOST('search_paymentcond') ? GETPOSTINT('search_paymentcond') : '';
99$search_vat_reverse_charge = GETPOST('search_vat_reverse_charge', 'alpha');
100$search_town = GETPOST('search_town', 'alpha');
101$search_zip = GETPOST('search_zip', 'alpha');
102$search_state = GETPOST("search_state");
103$search_note_private = GETPOST('search_note_private', 'alpha');
104$search_note_public = GETPOST('search_note_public', 'alpha');
105$search_country = GETPOST("search_country", 'aZ09');
106$search_type_thirdparty = GETPOST("search_type_thirdparty", 'intcomma');
107$search_user = GETPOST('search_user', 'intcomma');
108$search_sale = GETPOST('search_sale', 'intcomma');
109$search_date_start = GETPOSTDATE('search_date_start', '', 'tzserver');
110$search_date_end = GETPOSTDATE('search_date_end', '23:59:59', 'tzserver');
111$search_datelimit_startday = GETPOSTINT('search_datelimit_startday');
112$search_datelimit_startmonth = GETPOSTINT('search_datelimit_startmonth');
113$search_datelimit_startyear = GETPOSTINT('search_datelimit_startyear');
114$search_datelimit_endday = GETPOSTINT('search_datelimit_endday');
115$search_datelimit_endmonth = GETPOSTINT('search_datelimit_endmonth');
116$search_datelimit_endyear = GETPOSTINT('search_datelimit_endyear');
117$search_datelimit_start = dol_mktime(0, 0, 0, $search_datelimit_startmonth, $search_datelimit_startday, $search_datelimit_startyear);
118$search_datelimit_end = dol_mktime(23, 59, 59, $search_datelimit_endmonth, $search_datelimit_endday, $search_datelimit_endyear);
119$search_categ_sup = GETPOST("search_categ_sup", 'intcomma');
120$searchCategorySupplierInvoiceList = GETPOST('search_category_supplier_invoice_list', 'array:int');
121$searchCategorySupplierInvoiceOperator = 0;
122if (GETPOSTISSET('formfilteraction')) {
123 $searchCategorySupplierInvoiceOperator = GETPOSTINT('search_category_supplier_invoice_operator');
124} elseif (getDolGlobalString('MAIN_SEARCH_CAT_OR_BY_DEFAULT')) {
125 $searchCategorySupplierInvoiceOperator = getDolGlobalString('MAIN_SEARCH_CAT_OR_BY_DEFAULT');
126}
127$search_product_category = GETPOST('search_product_category', 'intcomma');
128$search_fk_fac_rec_source = GETPOST('search_fk_fac_rec_source', 'int');
129
130$option = GETPOST('search_option');
131if ($option == 'late') {
132 $search_status = '1';
133}
134$filter = GETPOST('filtre', 'alpha');
135
136// Load variable for pagination
137$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
138$sortfield = GETPOST('sortfield', 'aZ09comma');
139$sortorder = GETPOST('sortorder', 'aZ09comma');
140$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
141if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
142 // If $page is not defined, or '' or -1 or if we click on clear filters
143 $page = 0;
144}
145$offset = $limit * $page;
146if (!$sortorder) {
147 $sortorder = "DESC";
148}
149if (!$sortfield) {
150 $sortfield = "f.datef,f.rowid";
151}
152$pageprev = $page - 1;
153$pagenext = $page + 1;
154
155$socid = GETPOSTINT('socid');
156
157// Security check
158if ($user->socid > 0) {
159 $action = '';
160 $socid = $user->socid;
161}
162
163$diroutputmassaction = $conf->fournisseur->facture->dir_output.'/temp/massgeneration/'.$user->id;
164
165$now = dol_now();
166
167// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
168$object = new FactureFournisseur($db);
169$hookmanager->initHooks(array('supplierinvoicelist'));
170$extrafields = new ExtraFields($db);
171
172// Fetch optionals attributes and labels
173$extrafields->fetch_name_optionals_label($object->table_element);
174
175$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
176
177// List of fields to search into when doing a "search in all"
178$fieldstosearchall = array(
179 'f.ref' => 'Ref',
180 'f.ref_supplier' => 'RefSupplier',
181 'f.note_public' => 'NotePublic',
182 's.nom' => "ThirdParty",
183 's.code_fournisseur' => "SupplierCodeShort",
184 'pd.description' => 'Description',
185);
186if (empty($user->socid)) {
187 $fieldstosearchall["f.note_private"] = "NotePrivate";
188}
189
190$checkedtypetiers = '0';
191$arrayfields = array(
192 'f.ref' => array('label' => "Ref", 'checked' => '1', 'position' => 5),
193 'f.ref_supplier' => array('label' => "RefSupplier", 'checked' => '1', 'position' => 7),
194 'f.type' => array('label' => "Type", 'checked' => '0', 'position' => 15),
195 'f.subtype' => array('label' => "InvoiceSubtype", 'checked' => '0', 'position' => 17),
196 'f.label' => array('label' => "Label", 'checked' => '0', 'position' => 20),
197 'f.datef' => array('label' => "DateInvoice", 'checked' => '1', 'position' => 25),
198 'f.date_lim_reglement' => array('label' => "DateDue", 'checked' => '1', 'position' => 27),
199 'p.ref' => array('label' => "ProjectRef", 'checked' => '1', 'position' => 30, 'enabled' => (isModEnabled('project') ? '1' : '0')),
200 's.nom' => array('label' => "ThirdParty", 'checked' => '1', 'position' => 41),
201 's.name_alias' => array('label' => "AliasNameShort", 'checked' => '0', 'position' => 42),
202 's.town' => array('label' => "Town", 'checked' => '-1', 'position' => 43),
203 's.zip' => array('label' => "Zip", 'checked' => '-1', 'position' => 44),
204 'state.nom' => array('label' => "StateShort", 'checked' => '0', 'position' => 45),
205 'country.code_iso' => array('label' => "Country", 'checked' => '0', 'position' => 46),
206 'typent.code' => array('label' => "ThirdPartyType", 'checked' => $checkedtypetiers, 'position' => 48),
207 'f.vat_reverse_charge' => array('label' => "VATReverseCharge", 'checked' => '0', 'position' => 49, 'enabled' => (getDolGlobalString('ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE') ? '1' : '0')),
208 'f.fk_mode_reglement' => array('label' => "PaymentMode", 'checked' => '0', 'position' => 52),
209 'f.fk_cond_reglement' => array('label' => "PaymentConditionsShort", 'checked' => '0', 'position' => 50),
210 'f.total_ht' => array('label' => "AmountHT", 'checked' => '1', 'position' => 105),
211 'f.total_vat' => array('label' => "AmountVAT", 'checked' => '0', 'position' => 110),
212 'f.total_localtax1' => array('label' => $langs->transcountry("AmountLT1", $mysoc->country_code), 'checked' => '0', 'enabled' => (string) (int) ($mysoc->localtax1_assuj == "1"), 'position' => 95),
213 'f.total_localtax2' => array('label' => $langs->transcountry("AmountLT2", $mysoc->country_code), 'checked' => '0', 'enabled' => (string) (int) ($mysoc->localtax2_assuj == "1"), 'position' => 100),
214 'f.total_ttc' => array('label' => "AmountTTC", 'checked' => '1', 'position' => 115),
215 'dynamount_payed' => array('label' => "Paid", 'checked' => '0', 'position' => 116),
216 'rtp' => array('label' => "Rest", 'checked' => '0', 'position' => 117),
217 'f.multicurrency_code' => array('label' => 'Currency', 'checked' => '0', 'position' => 205, 'enabled' => (!isModEnabled("multicurrency") ? '0' : '1')),
218 'f.multicurrency_tx' => array('label' => 'CurrencyRate', 'checked' => '0', 'position' => 206, 'enabled' => (!isModEnabled("multicurrency") ? '0' : '1')),
219 'f.multicurrency_total_ht' => array('label' => 'MulticurrencyAmountHT', 'position' => 207, 'checked' => '0', 'enabled' => (!isModEnabled("multicurrency") ? '0' : '1')),
220 'f.multicurrency_total_vat' => array('label' => 'MulticurrencyAmountVAT', 'position' => 208, 'checked' => '0', 'enabled' => (!isModEnabled("multicurrency") ? '0' : '1')),
221 'f.multicurrency_total_ttc' => array('label' => 'MulticurrencyAmountTTC', 'position' => 209, 'checked' => '0', 'enabled' => (!isModEnabled("multicurrency") ? '0' : '1')),
222 'multicurrency_dynamount_payed' => array('label' => 'MulticurrencyAlreadyPaid', 'position' => 210, 'checked' => '0', 'enabled' => (!isModEnabled("multicurrency") ? '0' : '1')),
223 'multicurrency_rtp' => array('label' => 'MulticurrencyRemainderToPay', 'checked' => '0', 'position' => 211, 'enabled' => (!isModEnabled("multicurrency") ? '0' : '1')), // Not enabled by default because slow
224 'u.login' => array('label' => "Author", 'checked' => '-1', 'position' => 500),
225 'f.datec' => array('label' => "DateCreation", 'checked' => '0', 'position' => 501),
226 'f.tms' => array('label' => "DateModificationShort", 'checked' => '0', 'position' => 502),
227 'f.nb_docs' => array('label' => "Documents", 'checked' => '-1', 'position' => 510),
228 'f.note_public' => array('label' => 'NotePublic', 'checked' => '0', 'position' => 520, 'enabled' => (getDolGlobalInt('MAIN_LIST_HIDE_PUBLIC_NOTES') ? '0' : '1')),
229 'f.note_private' => array('label' => 'NotePrivate', 'checked' => '0', 'position' => 521, 'enabled' => (getDolGlobalInt('MAIN_LIST_HIDE_PRIVATE_NOTES') ? '0' : '1')),
230 'f.fk_statut' => array('label' => "Status", 'checked' => '1', 'position' => 1000),
231);
232// Extra fields
233include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
234// Add hook to complete $arrayfield
235$parameters = array('arrayfields' => &$arrayfields);
236$reshook = $hookmanager->executeHooks('completeArrayFields', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
237
238$subtypearray = $object->getArrayOfInvoiceSubtypes(0);
239if (empty($subtypearray)) {
240 unset($arrayfields['f.subtype']);
241}
242
243$object->fields = dol_sort_array($object->fields, 'position');
244$arrayfields = dol_sort_array($arrayfields, 'position');
245
246if (!isModEnabled('supplier_invoice')) {
248}
249if ((!$user->hasRight("fournisseur", "facture", "lire") && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD'))
250 || (!$user->hasRight("supplier_invoice", "lire") && getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD'))) {
252}
253
254// Check only if it' an internal user
255if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) {
256 $search_sale = $user->id;
257}
258
259$permissiontoread = ($user->hasRight("fournisseur", "facture", "lire") || $user->hasRight("supplier_invoice", "lire"));
260$permissiontoadd = ($user->hasRight("fournisseur", "facture", "creer") || $user->hasRight("supplier_invoice", "creer"));
261$permissiontodelete = ($user->hasRight("fournisseur", "facture", "supprimer") || $user->hasRight("supplier_invoice", "supprimer"));
262
263
264/*
265 * Actions
266 */
267$error = 0;
268if (GETPOST('cancel', 'alpha')) {
269 $action = 'list';
270 $massaction = '';
271}
272if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
273 $massaction = '';
274}
275
276$parameters = array('socid' => $socid, 'arrayfields' => &$arrayfields);
277$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
278if ($reshook < 0) {
279 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
280}
281
282if (empty($reshook)) {
283 // Selection of new fields
284 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
285
286 // Purge search criteria
287 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
288 $search_all = "";
289 $search_user = '';
290 $search_sale = '';
291 $search_product_category = '';
292 $searchCategorySupplierInvoiceList = array();
293 $search_ref = "";
294 $search_refsupplier = "";
295 $search_type = "";
296 $search_subtype = '';
297 $search_label = "";
298 $search_project = '';
299 $search_company = "";
300 $search_company_alias = "";
301 $search_amount_no_tax = "";
302 $search_amount_all_tax = "";
303 $search_montant_ht = '';
304 $search_montant_vat = '';
305 $search_montant_localtax1 = '';
306 $search_montant_localtax2 = '';
307 $search_montant_ttc = '';
308 $search_login = '';
309 $search_multicurrency_code = '';
310 $search_multicurrency_tx = '';
311 $search_multicurrency_montant_ht = '';
312 $search_multicurrency_montant_vat = '';
313 $search_multicurrency_montant_ttc = '';
314 $search_status = '';
315 $search_paymentmode = '';
316 $search_paymentcond = '';
317 $search_vat_reverse_charge = '';
318 $search_town = '';
319 $search_zip = "";
320 $search_state = "";
321 $search_country = '';
322 $search_type_thirdparty = '';
323 $search_date_start = '';
324 $search_date_end = '';
325 $search_datelimit_startday = '';
326 $search_datelimit_startmonth = '';
327 $search_datelimit_startyear = '';
328 $search_datelimit_endday = '';
329 $search_datelimit_endmonth = '';
330 $search_datelimit_endyear = '';
331 $search_datelimit_start = '';
332 $search_datelimit_end = '';
333 $search_note_private = '';
334 $search_note_public = '';
335 $toselect = array();
336 $search_array_options = array();
337 $search_categ_sup = 0;
338 $filter = '';
339 $option = '';
340 }
341
342 // Mass actions
343 $objectclass = 'FactureFournisseur';
344 $objectlabel = 'SupplierInvoices';
345
346 $uploaddir = $conf->fournisseur->facture->dir_output;
347
348 include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
349
350 if ($massaction == 'banktransfertrequest') {
351 $langs->load("withdrawals");
352
353 if (!$user->hasRight("paymentbybanktransfer", "create")) {
354 $error++;
355 setEventMessages($langs->trans("NotEnoughPermissions"), null, 'errors');
356 } else {
357 //Checking error
358 $error = 0;
359
360 $arrayofselected = is_array($toselect) ? $toselect : array();
361 $listofbills = array();
362 foreach ($arrayofselected as $toselectid) {
363 $objecttmp = new FactureFournisseur($db);
364 $result = $objecttmp->fetch($toselectid);
365 if ($result > 0) {
366 $totalpaid = $objecttmp->getSommePaiement();
367 $totalcreditnotes = $objecttmp->getSumCreditNotesUsed();
368 $totaldeposits = $objecttmp->getSumDepositsUsed();
369 $objecttmp->resteapayer = price2num($objecttmp->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits, 'MT');
370
371 // hook to finalize the remaining amount, considering e.g. cash discount agreements
372 $parameters = array('remaintopay' => $objecttmp->resteapayer);
373 $reshook = $hookmanager->executeHooks('finalizeAmountOfInvoice', $parameters, $objecttmp, $action); // Note that $action and $object may have been modified by some hooks
374 if ($reshook > 0) {
375 // print $hookmanager->resPrint;
376 if (!empty($remaintopay = $hookmanager->resArray['remaintopay'])) {
377 $objecttmp->resteapayer = $remaintopay;
378 }
379 } elseif ($reshook < 0) {
380 $error++;
381 setEventMessages($objecttmp->ref.' '.$langs->trans("ProcessingError"), $hookmanager->errors, 'errors');
382 }
383
384 if ($objecttmp->status == FactureFournisseur::STATUS_DRAFT) {
385 $error++;
386 setEventMessages($objecttmp->ref.' '.$langs->trans("Draft"), $objecttmp->errors, 'errors');
387 } elseif ($objecttmp->paid || $objecttmp->resteapayer == 0) {
388 $error++;
389 setEventMessages($objecttmp->ref.' '.$langs->trans("AlreadyPaid"), $objecttmp->errors, 'errors');
390 } elseif ($objecttmp->resteapayer < 0) {
391 $error++;
392 setEventMessages($objecttmp->ref.' '.$langs->trans("AmountMustBePositive"), $objecttmp->errors, 'errors');
393 }
394
395 $rsql = "SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande";
396 $rsql .= " , pfd.date_traite as date_traite";
397 $rsql .= " , pfd.amount";
398 $rsql .= " , u.rowid as user_id, u.lastname, u.firstname, u.login";
399 $rsql .= " FROM ".MAIN_DB_PREFIX."prelevement_demande as pfd";
400 $rsql .= " , ".MAIN_DB_PREFIX."user as u";
401 $rsql .= " WHERE fk_facture_fourn = ".((int) $objecttmp->id);
402 $rsql .= " AND pfd.fk_user_demande = u.rowid";
403 $rsql .= " AND pfd.traite = 0";
404 $rsql .= " ORDER BY pfd.date_demande DESC";
405
406 $numprlv = 0;
407 $result_sql = $db->query($rsql);
408 if ($result_sql) {
409 $numprlv = $db->num_rows($result_sql);
410 }
411
412 if ($numprlv > 0) {
413 $error++;
414 setEventMessages($objecttmp->ref.' '.$langs->trans("RequestAlreadyDone"), $objecttmp->errors, 'warnings');
415 } elseif (!empty($objecttmp->mode_reglement_code) && $objecttmp->mode_reglement_code != 'VIR') {
416 $langs->load("errors");
417 $error++;
418 setEventMessages($objecttmp->ref.' '.$langs->trans("ErrorThisPaymentModeIsNotCreditTransfer"), $objecttmp->errors, 'errors');
419 } else {
420 $listofbills[] = $objecttmp; // $listofbills will only contains invoices with good payment method and no request already done
421 }
422 }
423 }
424
425 // Massive withdraw request for request with no errors
426 if (!empty($listofbills)) {
427 $nbwithdrawrequestok = 0;
428 foreach ($listofbills as $aBill) {
429 // Note: The 2 following SQL requests are wrong but it works because we have one record into pfd for one record into pl and for into p for the same fk_facture_fourn.
430 // The table prelevement and prelevement_lignes and must be removed in future and merged into prelevement_demande
431 // Step 1: Move field fk_... of llx_prelevement into llx_prelevement_lignes
432 // Step 2: Move field fk_... + status into prelevement_demande.
433 $pending = 0;
434 // Get pending requests open with no transfer receipt yet
435 $sql = "SELECT SUM(pfd.amount) as amount";
436 $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_demande as pfd";
437 //if ($type == 'bank-transfer') {
438 $sql .= " WHERE pfd.fk_facture_fourn = ".((int) $aBill->id);
439 //} else {
440 // $sql .= " WHERE pfd.fk_facture = ".((int) $aBill->id);
441 //}
442 $sql .= " AND pfd.traite = 0";
443 //$sql .= " AND pfd.type = 'ban'";
444 $resql = $db->query($sql);
445 if ($resql) {
446 $obj = $db->fetch_object($resql);
447 if ($obj) {
448 $pending += (float) $obj->amount;
449 }
450 } else {
451 dol_print_error($db);
452 }
453 // Get pending request with a transfer receipt generated but not yet processed
454 $sqlPending = "SELECT SUM(pl.amount) as amount";
455 $sqlPending .= " FROM ".$db->prefix()."prelevement_lignes as pl";
456 $sqlPending .= " INNER JOIN ".$db->prefix()."prelevement as p ON p.fk_prelevement_lignes = pl.rowid";
457 //if ($type == 'bank-transfer') {
458 $sqlPending .= " WHERE p.fk_facture_fourn = ".((int) $aBill->id);
459 //} else {
460 // $sqlPending .= " WHERE p.fk_facture = ".((int) $aBill->id);
461 //}
462 $sqlPending .= " AND (pl.statut IS NULL OR pl.statut = 0)";
463 $resPending = $db->query($sqlPending);
464 if ($resPending) {
465 if ($objPending = $db->fetch_object($resPending)) {
466 $pending += (float) $objPending->amount;
467 }
468 }
469 $db->free($resPending);
470
471 $requestAmount = $aBill->resteapayer - $pending;
472 if ($requestAmount > 0) {
473 $db->begin();
474 $result = $aBill->demande_prelevement($user, $requestAmount, 'bank-transfer', 'supplier_invoice');
475 if ($result > 0) {
476 $db->commit();
477 $nbwithdrawrequestok++;
478 } else {
479 $db->rollback();
480 setEventMessages($aBill->error, $aBill->errors, 'errors');
481 }
482 } else {
483 $aBill->error = 'WithdrawRequestErrorNilAmount';
484 $aBill->errors[] = $aBill->error;
485 setEventMessages($aBill->error, $aBill->errors, 'errors');
486 }
487 }
488 if ($nbwithdrawrequestok > 0) {
489 setEventMessages($langs->trans("WithdrawRequestsDone", $nbwithdrawrequestok), null, 'mesgs');
490 }
491 }
492 }
493 }
494}
495
496
497/*
498 * View
499 */
500
501$form = new Form($db);
502$formother = new FormOther($db);
503$formfile = new FormFile($db);
504$facturestatic = new FactureFournisseur($db);
505$formcompany = new FormCompany($db);
506$thirdparty = new Societe($db);
507$subtypearray = $object->getArrayOfInvoiceSubtypes(0);
508$now = dol_now();
509
510$soc = null;
511if ($socid > 0) {
512 $soc = new Societe($db);
513 $soc->fetch($socid);
514 if (empty($search_company)) {
515 $search_company = $soc->name;
516 }
517}
518
519$title = $langs->trans("BillsSuppliers").($socid && ($soc !== null) ? ' - '.$soc->name : '');
520$help_url = 'EN:Suppliers_Invoices|FR:FactureFournisseur|ES:Facturas_de_proveedores';
521
522// Build and execute select
523// --------------------------------------------------------------------
524$sql = "SELECT";
525$sql .= " f.rowid as facid, f.ref, f.ref_supplier, f.type, f.subtype, f.datef, f.date_lim_reglement as datelimite, f.fk_mode_reglement, f.fk_cond_reglement, f.vat_reverse_charge,";
526$sql .= " f.total_ht, f.total_ttc, f.total_tva as total_vat, f.paye as paye, f.close_code, f.fk_statut as fk_statut, f.libelle as label, f.datec as date_creation, f.tms as date_modification,";
527$sql .= " f.localtax1 as total_localtax1, f.localtax2 as total_localtax2,";
528$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,';
529$sql .= " f.note_public, f.note_private,";
530$sql .= " f.fk_user_author,";
531$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,";
532$sql .= " typent.code as typent_code,";
533$sql .= " state.code_departement as state_code, state.nom as state_name,";
534$sql .= " country.code as country_code,";
535$sql .= " p.rowid as project_id, p.ref as project_ref, p.title as project_label,";
536$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';
537// Add fields from extrafields
538if (!empty($extrafields->attributes[$object->table_element]['label'])) {
539 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
540 $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
541 }
542}
543// Add fields from hooks
544$parameters = array();
545$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
546$sql .= $hookmanager->resPrint;
547$sql = preg_replace('/,\s*$/', '', $sql);
548
549$sqlfields = $sql; // $sql fields to remove for count total
550
551$sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s';
552$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)";
553$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)";
554$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)";
555$sql .= ', '.MAIN_DB_PREFIX.'facture_fourn as f';
556if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
557 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (f.rowid = ef.fk_object)";
558}
559$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user AS u ON f.fk_user_author = u.rowid';
560$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = f.fk_projet";
561if ($search_user > 0) {
562 $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec";
563 $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as tc";
564}
565// Add table from hooks
566$parameters = array();
567$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
568$sql .= $hookmanager->resPrint;
569$sql .= ' WHERE f.fk_soc = s.rowid';
570$sql .= ' AND f.entity IN ('.getEntity('facture_fourn').')';
571if ($socid > 0) {
572 $sql .= ' AND s.rowid = '.((int) $socid);
573}
574if ($search_ref) {
575 if (is_numeric($search_ref)) {
576 $sql .= natural_search(array('f.ref'), $search_ref);
577 } else {
578 $sql .= natural_search('f.ref', $search_ref);
579 }
580}
581if ($search_ref) {
582 $sql .= natural_search('f.ref', $search_ref);
583}
584if ($search_refsupplier) {
585 $sql .= natural_search('f.ref_supplier', $search_refsupplier);
586}
587if ($search_type != '' && $search_type >= 0) {
588 if ($search_type == '0') {
589 $sql .= " AND f.type = 0"; // standard
590 }
591 if ($search_type == '1') {
592 $sql .= " AND f.type = 1"; // replacement
593 }
594 if ($search_type == '2') {
595 $sql .= " AND f.type = 2"; // credit note
596 }
597 if ($search_type == '3') {
598 $sql .= " AND f.type = 3"; // deposit
599 }
600 //if ($search_type == '4') $sql.=" AND f.type = 4"; // proforma
601 //if ($search_type == '5') $sql.=" AND f.type = 5"; // situation
602}
603if ($search_subtype != '' && $search_subtype != '-1') {
604 $sql .= " AND f.subtype IN (".$db->sanitize($db->escape($search_subtype)).")";
605}
606if ($search_project) {
607 $sql .= natural_search('p.ref', $search_project);
608}
609if (empty($arrayfields['s.name_alias']['checked']) && $search_company) {
610 $sql .= natural_search(array("s.nom", "s.name_alias"), $search_company);
611} else {
612 if ($search_company) {
613 $sql .= natural_search('s.nom', $search_company);
614 }
615 if ($search_company_alias) {
616 $sql .= natural_search('s.name_alias', $search_company_alias);
617 }
618}
619if ($search_town) {
620 $sql .= natural_search('s.town', $search_town);
621}
622if ($search_zip) {
623 $sql .= natural_search("s.zip", $search_zip);
624}
625if ($search_state) {
626 $sql .= natural_search("state.nom", $search_state);
627}
628if (strlen(trim($search_country))) {
629 $arrayofcode = getCountriesInEEC();
630 $country_code_in_EEC = $country_code_in_EEC_without_me = '';
631 foreach ($arrayofcode as $key => $value) {
632 $country_code_in_EEC .= ($country_code_in_EEC ? "," : "")."'".$value."'";
633 if ($value != $mysoc->country_code) {
634 $country_code_in_EEC_without_me .= ($country_code_in_EEC_without_me ? "," : "")."'".$value."'";
635 }
636 }
637 if ($search_country == 'special_allnotme') {
638 $sql .= " AND country.code <> '".$db->escape($mysoc->country_code)."'";
639 } elseif ($search_country == 'special_eec') {
640 $sql .= " AND country.code IN (".$db->sanitize($country_code_in_EEC, 1).")";
641 } elseif ($search_country == 'special_eecnotme') {
642 $sql .= " AND country.code IN (".$db->sanitize($country_code_in_EEC_without_me, 1).")";
643 } elseif ($search_country == 'special_noteec') {
644 $sql .= " AND country.code NOT IN (".$db->sanitize($country_code_in_EEC, 1).")";
645 } else {
646 $sql .= natural_search("country.code", $search_country);
647 }
648}
649if ($search_type_thirdparty != '' && $search_type_thirdparty >= 0) {
650 $sql .= " AND s.fk_typent IN (".$db->sanitize($search_type_thirdparty).')';
651}
652if ($search_montant_ht != '') {
653 $sql .= natural_search('f.total_ht', $search_montant_ht, 1);
654}
655if ($search_montant_vat != '') {
656 $sql .= natural_search('f.total_tva', $search_montant_vat, 1);
657}
658if ($search_montant_localtax1 != '') {
659 $sql .= natural_search('f.localtax1', $search_montant_localtax1, 1);
660}
661if ($search_montant_localtax2 != '') {
662 $sql .= natural_search('f.localtax2', $search_montant_localtax2, 1);
663}
664if ($search_montant_ttc != '') {
665 $sql .= natural_search('f.total_ttc', $search_montant_ttc, 1);
666}
667if ($search_multicurrency_code != '') {
668 $sql .= " AND f.multicurrency_code = '".$db->escape($search_multicurrency_code)."'";
669}
670if ($search_multicurrency_tx != '') {
671 $sql .= natural_search('f.multicurrency_tx', $search_multicurrency_tx, 1);
672}
673if ($search_multicurrency_montant_ht != '') {
674 $sql .= natural_search('f.multicurrency_total_ht', $search_multicurrency_montant_ht, 1);
675}
676if ($search_multicurrency_montant_vat != '') {
677 $sql .= natural_search('f.multicurrency_total_tva', $search_multicurrency_montant_vat, 1);
678}
679if ($search_multicurrency_montant_ttc != '') {
680 $sql .= natural_search('f.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1);
681}
682if ($search_login) {
683 $sql .= natural_search(array('u.login', 'u.lastname', 'u.firstname'), $search_login);
684}
685if ($search_status != '' && $search_status >= 0) {
686 $sql .= " AND f.fk_statut = ".((int) $search_status);
687}
688if ($search_paymentmode > 0) {
689 $sql .= " AND f.fk_mode_reglement = ".((int) $search_paymentmode);
690}
691if ($search_paymentcond > 0) {
692 $sql .= " AND f.fk_cond_reglement = ".((int) $search_paymentcond);
693}
694if ($search_vat_reverse_charge != '') {
695 $sql .= " AND f.vat_reverse_charge = ".((int) $search_vat_reverse_charge);
696}
697if ($search_date_start) {
698 $sql .= " AND f.datef >= '" . $db->idate($search_date_start) . "'";
699}
700if ($search_date_end) {
701 $sql .= " AND f.datef <= '" . $db->idate($search_date_end) . "'";
702}
703if ($search_note_public) {
704 $sql .= " AND f.note_public LIKE '%".$db->escape($db->escapeforlike($search_note_public))."%'";
705}
706if ($search_note_private) {
707 $sql .= " AND f.note_private LIKE '%".$db->escape($db->escapeforlike($search_note_private))."%'";
708}
709if ($search_datelimit_start) {
710 $sql .= " AND f.date_lim_reglement >= '" . $db->idate($search_datelimit_start) . "'";
711}
712if ($search_datelimit_end) {
713 $sql .= " AND f.date_lim_reglement <= '" . $db->idate($search_datelimit_end) . "'";
714}
715if ($option == 'late') {
716 $sql .= " AND f.date_lim_reglement < '".$db->idate(dol_now() - $conf->facture->fournisseur->warning_delay)."'";
717}
718if ($search_label) {
719 $sql .= natural_search('f.libelle', $search_label);
720}
721if ($search_fk_fac_rec_source) {
722 $sql .= " AND f.fk_fac_rec_source = ".(int) $search_fk_fac_rec_source;
723}
724// Search on sale representative
725if ($search_sale && $search_sale != '-1') {
726 if ($search_sale == -2) {
727 $sql .= " AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = f.fk_soc)";
728 } elseif ($search_sale > 0) {
729 $sql .= " AND EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = f.fk_soc AND sc.fk_user = ".((int) $search_sale).")";
730 }
731}
732// Search for tag/category ($searchCategorySupplierInvoiceList is an array of ID)
733if (!empty($searchCategorySupplierInvoiceList)) {
734 $searchCategorySupplierInvoiceSqlList = array();
735 $listofcategoryid = '';
736 foreach ($searchCategorySupplierInvoiceList as $searchCategorySupplierInvoice) {
737 if (intval($searchCategorySupplierInvoice) == -2) {
738 $searchCategorySupplierInvoiceSqlList[] = "NOT EXISTS (SELECT ck.fk_supplier_invoice FROM ".MAIN_DB_PREFIX."categorie_supplier_invoice as ck WHERE f.rowid = ck.fk_supplier_invoice)";
739 } elseif (intval($searchCategorySupplierInvoice) > 0) {
740 if ($searchCategorySupplierInvoiceOperator == 0) {
741 $searchCategorySupplierInvoiceSqlList[] = " EXISTS (SELECT ck.fk_supplier_invoice FROM ".MAIN_DB_PREFIX."categorie_supplier_invoice as ck WHERE f.rowid = ck.fk_supplier_invoice AND ck.fk_categorie = ".((int) $searchCategorySupplierInvoice).")";
742 } else {
743 $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategorySupplierInvoice);
744 }
745 }
746 }
747 if ($listofcategoryid) {
748 $searchCategorySupplierInvoiceSqlList[] = " EXISTS (SELECT ck.fk_supplier_invoice FROM ".MAIN_DB_PREFIX."categorie_supplier_invoice as ck WHERE f.rowid = ck.fk_supplier_invoice AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))";
749 }
750 if ($searchCategorySupplierInvoiceOperator == 1) {
751 if (!empty($searchCategorySupplierInvoiceSqlList)) {
752 $sql .= " AND (".implode(' OR ', $searchCategorySupplierInvoiceSqlList).")";
753 }
754 } else {
755 if (!empty($searchCategorySupplierInvoiceSqlList)) {
756 $sql .= " AND (".implode(' AND ', $searchCategorySupplierInvoiceSqlList).")";
757 }
758 }
759}
760$searchCategorySupplierList = $search_categ_sup ? array($search_categ_sup) : array();
761$searchCategorySupplierOperator = 0;
762// Search for tag/category ($searchCategorySupplierList is an array of ID)
763if (!empty($searchCategorySupplierList)) {
764 $searchCategorySupplierSqlList = array();
765 $listofcategoryid = '';
766 foreach ($searchCategorySupplierList as $searchCategorySupplier) {
767 if (intval($searchCategorySupplier) == -2) {
768 $searchCategorySupplierSqlList[] = "NOT EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_fournisseur as ck WHERE s.rowid = ck.fk_soc)";
769 } elseif (intval($searchCategorySupplier) > 0) {
770 if ($searchCategorySupplierOperator == 0) {
771 $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).")";
772 } else {
773 $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategorySupplier);
774 }
775 }
776 }
777 if ($listofcategoryid) {
778 $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)."))";
779 }
780 if ($searchCategorySupplierOperator == 1) {
781 if (!empty($searchCategorySupplierSqlList)) {
782 $sql .= " AND (".implode(' OR ', $searchCategorySupplierSqlList).")";
783 }
784 } else {
785 if (!empty($searchCategorySupplierSqlList)) {
786 $sql .= " AND (".implode(' AND ', $searchCategorySupplierSqlList).")";
787 }
788 }
789}
790// Search for tag/category ($searchCategoryProductList is an array of ID)
791$searchCategoryProductList = $search_product_category ? array($search_product_category) : array();
792$searchCategoryProductOperator = 0;
793if (!empty($searchCategoryProductList)) {
794 $searchCategoryProductSqlList = array();
795 $listofcategoryid = '';
796 foreach ($searchCategoryProductList as $searchCategoryProduct) {
797 if (intval($searchCategoryProduct) == -2) {
798 $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)";
799 } elseif (intval($searchCategoryProduct) > 0) {
800 if ($searchCategoryProductOperator == 0) {
801 $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).")";
802 } else {
803 $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProduct);
804 }
805 }
806 }
807 if ($listofcategoryid) {
808 $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)."))";
809 }
810 if ($searchCategoryProductOperator == 1) {
811 if (!empty($searchCategoryProductSqlList)) {
812 $sql .= " AND (".implode(' OR ', $searchCategoryProductSqlList).")";
813 }
814 } else {
815 if (!empty($searchCategoryProductSqlList)) {
816 $sql .= " AND (".implode(' AND ', $searchCategoryProductSqlList).")";
817 }
818 }
819}
820if ($filter && $filter != -1) {
821 $aFilter = explode(',', $filter);
822 foreach ($aFilter as $fil) {
823 $filt = explode(':', $fil);
824 // The parameter comes from the URL: without a colon there is no value to compare to,
825 // and $filt[1] would be an undefined key passed to trim(), deprecated since PHP 8.1.
826 if (count($filt) < 2) {
827 continue;
828 }
829 $sql .= " AND ".$db->escape(trim($filt[0]))." = '".$db->escape(trim($filt[1]))."'";
830 }
831}
832
833if ($search_all) {
834 unset($fieldstosearchall['pd.description']);
835 $sql .= "AND (";
836 $sql .= natural_search(array_keys($fieldstosearchall), $search_all, 0, 1);
837 $sql .= " OR EXISTS (SELECT rowid FROM ".MAIN_DB_PREFIX."facture_fourn_det as pd WHERE f.rowid = pd.fk_facture_fourn AND pd.description LIKE '%".$db->escape($db->escapeforlike($search_all))."%')";
838 $sql .= ")";
839 $fieldstosearchall['pd.description'] = 'Description';
840}
841
842if ($search_user > 0) {
843 $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);
844}
845// Add where from extra fields
846include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
847// Add where from hooks
848$parameters = array();
849$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
850if (empty($reshook)) {
851 $sql .= $hookmanager->resPrint;
852} else {
853 $sql = $hookmanager->resPrint;
854}
855
856// Add HAVING from hooks
857$parameters = array();
858$reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
859if (empty($reshook)) {
860 $sql .= empty($hookmanager->resPrint) ? "" : " HAVING 1=1 ".$hookmanager->resPrint;
861} else {
862 $sql = $hookmanager->resPrint;
863}
864
865// Count total nb of records
866$nbtotalofrecords = '';
867if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
868 /* The fast and low memory method to get and count full list converts the sql into a sql count */
869 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
870
871 $resql = $db->query($sqlforcount);
872 if ($resql) {
873 $objforcount = $db->fetch_object($resql);
874 $nbtotalofrecords = $objforcount->nbtotalofrecords;
875 } else {
876 dol_print_error($db);
877 }
878
879 if (($page * $limit) > (int) $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
880 $page = 0;
881 $offset = 0;
882 }
883 $db->free($resql);
884}
885
886// Complete request and execute it with limit
887$sql .= $db->order($sortfield, $sortorder);
888if ($limit) {
889 $sql .= $db->plimit($limit + 1, $offset);
890}
891//print $sql;
892
893$resql = $db->query($sql);
894if (!$resql) {
895 dol_print_error($db);
896 exit;
897}
898
899$num = $db->num_rows($resql);
900
901// Direct jump if only one record found
902if ($num == 1 && getDolGlobalInt('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
903 $obj = $db->fetch_object($resql);
904 $id = $obj->facid;
905 header("Location: ".DOL_URL_ROOT.'/fourn/facture/card.php?facid='.$id);
906 exit;
907}
908
909// Output page
910// --------------------------------------------------------------------
911
912llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'bodyforlist mod-fourn-facture page-list');
913
914if ($search_fk_fac_rec_source) {
915 require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture-rec.class.php';
916 require_once DOL_DOCUMENT_ROOT . '/core/lib/invoice.lib.php';
918 $object->fetch((int) $search_fk_fac_rec_source);
919
920 $head = supplier_invoice_rec_prepare_head($object);
921 print dol_get_fiche_head($head, 'generated', $langs->trans('InvoicesGeneratedFromRec'), -1, $object->picto); // Add a div
922}
923
924if ($socid) {
925 $soc = new Societe($db);
926 $soc->fetch($socid);
927 if (empty($search_company)) {
928 $search_company = $soc->name;
929 $search_company_alias = $soc->name_alias;
930 }
931}
932
933$arrayofselected = is_array($toselect) ? $toselect : array();
934
935$param = '&socid='.$socid;
936if (!empty($mode)) {
937 $param .= '&mode='.urlencode($mode);
938}
939if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
940 $param .= '&contextpage='.urlencode($contextpage);
941}
942if ($limit > 0 && $limit != $conf->liste_limit) {
943 $param .= '&limit='.((int) $limit);
944}
945if ($optioncss != '') {
946 $param .= '&optioncss='.urlencode($optioncss);
947}
948if ($search_all) {
949 $param .= '&search_all='.urlencode($search_all);
950}
951if ($search_date_start) {
952 $param .= buildParamDate('search_date_start', null, '', 'tzserver');
953}
954if ($search_date_end) {
955 $param .= buildParamDate('search_date_end', null, '', 'tzserver');
956}
957if ($search_datelimit_startday) {
958 $param .= '&search_datelimit_startday='.urlencode((string) ($search_datelimit_startday));
959}
960if ($search_datelimit_startmonth) {
961 $param .= '&search_datelimit_startmonth='.urlencode((string) ($search_datelimit_startmonth));
962}
963if ($search_datelimit_startyear) {
964 $param .= '&search_datelimit_startyear='.urlencode((string) ($search_datelimit_startyear));
965}
966if ($search_datelimit_endday) {
967 $param .= '&search_datelimit_endday='.urlencode((string) ($search_datelimit_endday));
968}
969if ($search_datelimit_endmonth) {
970 $param .= '&search_datelimit_endmonth='.urlencode((string) ($search_datelimit_endmonth));
971}
972if ($search_datelimit_endyear) {
973 $param .= '&search_datelimit_endyear='.urlencode((string) ($search_datelimit_endyear));
974}
975if ($search_ref) {
976 $param .= '&search_ref='.urlencode($search_ref);
977}
978if ($search_refsupplier) {
979 $param .= '&search_refsupplier='.urlencode($search_refsupplier);
980}
981if ($search_type != '') {
982 $param .= '&search_type='.urlencode($search_type);
983}
984if ($search_subtype != '') {
985 $param .= '&search_subtype='.urlencode($search_subtype);
986}
987if ($search_label) {
988 $param .= '&search_label='.urlencode($search_label);
989}
990if ($search_company) {
991 $param .= '&search_company='.urlencode($search_company);
992}
993if ($search_company_alias) {
994 $param .= '&search_company_alias='.urlencode($search_company_alias);
995}
996if ($search_login) {
997 $param .= '&search_login='.urlencode($search_login);
998}
999if ($searchCategorySupplierInvoiceOperator == 1) {
1000 $param .= "&search_category_supplier_invoice_operator=".urlencode((string) ($searchCategorySupplierInvoiceOperator));
1001}
1002foreach ($searchCategorySupplierInvoiceList as $searchCategorySupplierInvoice) {
1003 $param .= "&search_category_invoice_list[]=".urlencode($searchCategorySupplierInvoice);
1004}
1005if ($search_montant_ht != '') {
1006 $param .= '&search_montant_ht='.urlencode($search_montant_ht);
1007}
1008if ($search_montant_vat != '') {
1009 $param .= '&search_montant_vat='.urlencode($search_montant_vat);
1010}
1011if ($search_montant_localtax1 != '') {
1012 $param .= '&search_montant_localtax1='.urlencode($search_montant_localtax1);
1013}
1014if ($search_montant_localtax2 != '') {
1015 $param .= '&search_montant_localtax2='.urlencode($search_montant_localtax2);
1016}
1017if ($search_montant_ttc != '') {
1018 $param .= '&search_montant_ttc='.urlencode($search_montant_ttc);
1019}
1020if ($search_multicurrency_code != '') {
1021 $param .= '&search_multicurrency_code='.urlencode($search_multicurrency_code);
1022}
1023if ($search_multicurrency_tx != '') {
1024 $param .= '&search_multicurrency_tx='.urlencode($search_multicurrency_tx);
1025}
1026if ($search_multicurrency_montant_ht != '') {
1027 $param .= '&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht);
1028}
1029if ($search_multicurrency_montant_vat != '') {
1030 $param .= '&search_multicurrency_montant_vat='.urlencode($search_multicurrency_montant_vat);
1031}
1032if ($search_multicurrency_montant_ttc != '') {
1033 $param .= '&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc);
1034}
1035if ($search_amount_no_tax) {
1036 $param .= '&search_amount_no_tax='.urlencode($search_amount_no_tax);
1037}
1038if ($search_amount_all_tax) {
1039 $param .= '&search_amount_all_tax='.urlencode($search_amount_all_tax);
1040}
1041if ($search_status >= 0) {
1042 $param .= "&search_status=".urlencode($search_status);
1043}
1044if ($search_paymentmode) {
1045 $param .= '&search_paymentmode='.urlencode((string) ($search_paymentmode));
1046}
1047if ($search_paymentcond) {
1048 $param .= '&search_paymentcond='.urlencode((string) ($search_paymentcond));
1049}
1050if ($search_vat_reverse_charge != '') {
1051 $param .= '&search_vat_reverse_charge='.urlencode((string) ($search_vat_reverse_charge));
1052}
1053if ($show_files) {
1054 $param .= '&show_files='.urlencode((string) ($show_files));
1055}
1056if ($option) {
1057 $param .= "&search_option=".urlencode($option);
1058}
1059if ($search_categ_sup > 0) {
1060 $param .= '&search_categ_sup='.$search_categ_sup;
1061}
1062if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) {
1063 $param .= '&search_type_thirdparty='.$search_type_thirdparty;
1064}
1065if ($search_fk_fac_rec_source) {
1066 $param .= '&search_fk_fac_rec_source=' . (int) $search_fk_fac_rec_source;
1067}
1068
1069// Add $param from extra fields
1070include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
1071// Add $param from hooks
1072$parameters = array('param' => &$param);
1073$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1074$param .= $hookmanager->resPrint;
1075
1076// List of mass actions available
1077$arrayofmassactions = array(
1078 'validate' => img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"),
1079 'generate_doc' => img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
1080 'builddoc' => img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
1081 //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
1082);
1083if (isModEnabled('category') && $user->hasRight("fournisseur", "facture", "lire")) {
1084 $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag");
1085}
1086if (isModEnabled('paymentbybanktransfer') && $user->hasRight("paymentbybanktransfer", "create")) {
1087 $langs->load('withdrawals');
1088 $arrayofmassactions['banktransfertrequest'] = img_picto('', 'payment', 'class="pictofixedwidth"').$langs->trans("MakeBankTransferOrder");
1089}
1090if (!empty($permissiontodelete)) {
1091 $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
1092}
1093if (GETPOSTINT('nomassaction') || in_array($massaction, array('presend', 'predelete'))) {
1094 $arrayofmassactions = array();
1095}
1096$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
1097
1098$url = DOL_URL_ROOT.'/fourn/facture/card.php?action=create';
1099if (!empty($object->socid)) {
1100 $url .= '&socid='.urlencode((string) ($object->socid));
1101}
1102if (!empty($object->id)) {
1103 $url .= '&fac_rec='.urlencode((string) $object->id);
1104}
1105$i = 0;
1106print '<form method="POST" id="searchFormList" name="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
1107if ($optioncss != '') {
1108 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
1109}
1110print '<input type="hidden" name="token" value="'.newToken().'">';
1111print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1112print '<input type="hidden" name="action" value="list">';
1113print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
1114print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
1115print '<input type="hidden" name="socid" value="'.$socid.'">';
1116print '<input type="hidden" name="page" value="'.$page.'">';
1117print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
1118print '<input type="hidden" name="page_y" value="">';
1119print '<input type="hidden" name="mode" value="'.$mode.'">';
1120
1121$newcardbutton = '';
1122$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'));
1123$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'));
1124$newcardbutton .= dolGetButtonTitleSeparator();
1125$newcardbutton .= dolGetButtonTitle($langs->trans('NewBill'), '', 'fa fa-plus-circle', $url, '', (int) ($user->hasRight("fournisseur", "facture", "creer") || $user->hasRight("supplier_invoice", "creer")));
1126
1127print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'supplier_invoice', 0, $newcardbutton, '', $limit, 0, 0, 1);
1128
1129// Add code for pre mass action (confirmation or email presend form)
1130$topicmail = "SendBillRef";
1131$modelmail = "invoice_supplier_send";
1132$objecttmp = new FactureFournisseur($db);
1133$trackid = 'sinv'.$object->id;
1134include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
1135
1136if ($search_all) {
1137 $setupstring = '';
1138 foreach ($fieldstosearchall as $key => $val) {
1139 $fieldstosearchall[$key] = $langs->trans($val);
1140 $setupstring .= $key."=".$val.";";
1141 }
1142 print '<!-- Search done like if SUPPLIER_INVOICE_QUICKSEARCH_ON_FIELDS = '.$setupstring.' -->'."\n";
1143 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'</div>'."\n";
1144}
1145
1146// If the user can view prospects other than his'
1147$moreforfilter = '';
1148if (isModEnabled('category') && $user->hasRight('categorie', 'read')) {
1149 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcategory.class.php';
1150 $formcategory = new FormCategory($db);
1151 $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_SUPPLIER_INVOICE, $searchCategorySupplierInvoiceList, 'minwidth300', $searchCategorySupplierInvoiceOperator ? $searchCategorySupplierInvoiceOperator : 0);
1152}
1153if ($user->hasRight("user", "user", "lire")) {
1154 $langs->load("commercial");
1155 $moreforfilter .= '<div class="divsearchfield">';
1156 $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative');
1157 $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'maxwidth200');
1158 $moreforfilter .= '</div>';
1159}
1160// If the user can view prospects other than his'
1161if ($user->hasRight("user", "user", "lire")) {
1162 $moreforfilter .= '<div class="divsearchfield">';
1163 $tmptitle = $langs->trans('LinkedToSpecificUsers');
1164 $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_user, 'search_user', $tmptitle, null, 0, '', '', '', 0, 0, '', 0, '', 'maxwidth200');
1165 $moreforfilter .= '</div>';
1166}
1167// If the user can view prospects other than his'
1168if (isModEnabled('category') && $user->hasRight('categorie', 'lire') && ($user->hasRight('produit', 'lire') || $user->hasRight('service', 'lire'))) {
1169 include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
1170 $moreforfilter .= '<div class="divsearchfield">';
1171 $tmptitle = $langs->trans('IncludingProductWithTag');
1172 $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, '', 'parent', 0, 0, 1);
1173 $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$form->selectarray('search_product_category', $cate_arbo, $search_product_category, $tmptitle, 0, 0, '', 0, 0, 0, '', 'maxwidth300 widthcentpercentminusx', 1);
1174 $moreforfilter .= '</div>';
1175}
1176
1177if (isModEnabled('category')) {
1178 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
1179 $moreforfilter .= '<div class="divsearchfield">';
1180 $tmptitle = $langs->trans('SuppliersCategoriesShort');
1181 $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$formother->select_categories('supplier', $search_categ_sup, 'search_categ_sup', 1, $tmptitle);
1182 $moreforfilter .= '</div>';
1183}
1184$parameters = array();
1185$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1186if (empty($reshook)) {
1187 $moreforfilter .= $hookmanager->resPrint;
1188} else {
1189 $moreforfilter = $hookmanager->resPrint;
1190}
1191
1192if (!empty($moreforfilter)) {
1193 print '<div class="liste_titre liste_titre_bydiv centpercent">';
1194 print $moreforfilter;
1195 print '</div>';
1196}
1197
1198$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
1199$htmlofselectarray = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields with user setup
1200$selectedfields = ($mode != 'kanban' ? $htmlofselectarray : '');
1201$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
1202
1203print '<div class="div-table-responsive">';
1204print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
1205
1206// Fields title search
1207// --------------------------------------------------------------------
1208print '<tr class="liste_titre_filter">';
1209// Action column
1210if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1211 print '<td class="liste_titre center maxwidthsearch">';
1212 $searchpicto = $form->showFilterButtons('left');
1213 print $searchpicto;
1214 print '</td>';
1215}
1216// Ref
1217if (!empty($arrayfields['f.ref']['checked'])) {
1218 print '<td class="liste_titre left">';
1219 print '<input class="flat maxwidth50" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
1220 print '</td>';
1221}
1222// Ref supplier
1223if (!empty($arrayfields['f.ref_supplier']['checked'])) {
1224 print '<td class="liste_titre">';
1225 print '<input class="flat maxwidth75" type="text" name="search_refsupplier" value="'.dol_escape_htmltag($search_refsupplier).'">';
1226 print '</td>';
1227}
1228// Type
1229if (!empty($arrayfields['f.type']['checked'])) {
1230 print '<td class="liste_titre maxwidthonsmartphone">';
1231 $typearray = array(
1232 FactureFournisseur::TYPE_STANDARD => $langs->trans("InvoiceStandard"),
1233 FactureFournisseur::TYPE_REPLACEMENT => $langs->trans("InvoiceReplacement"),
1234 FactureFournisseur::TYPE_CREDIT_NOTE => $langs->trans("InvoiceAvoir"),
1235 FactureFournisseur::TYPE_DEPOSIT => $langs->trans("InvoiceDeposit"),
1236 );
1237 print $form->selectarray('search_type', $typearray, $search_type, 1, 0, 0, '', 0, 0, 0, 'ASC', 'maxwidth100');
1238 print '</td>';
1239}
1240// Invoice Subtype
1241if (!empty($arrayfields['f.subtype']['checked'])) {
1242 print '<td class="liste_titre maxwidthonsmartphone" align="center">';
1243 print $form->selectarray('search_subtype', $subtypearray, $search_subtype, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth100');
1244 print '</td>';
1245}
1246// Label
1247if (!empty($arrayfields['f.label']['checked'])) {
1248 print '<td class="liste_titre">';
1249 print '<input class="flat maxwidth75" type="text" name="search_label" value="'.dol_escape_htmltag($search_label).'">';
1250 print '</td>';
1251}
1252// Date invoice
1253if (!empty($arrayfields['f.datef']['checked'])) {
1254 print '<td class="liste_titre center">';
1255 print '<div class="nowrapfordate">';
1256 print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
1257 print '</div>';
1258 print '<div class="nowrapfordate">';
1259 print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
1260 print '</div>';
1261 print '</td>';
1262}
1263// Date due
1264if (!empty($arrayfields['f.date_lim_reglement']['checked'])) {
1265 print '<td class="liste_titre center">';
1266 print '<div class="">';
1267 /*
1268 print $langs->trans('From').' ';
1269 print $form->selectDate($search_datelimit_start ? $search_datelimit_start : -1, 'search_datelimit_start', 0, 0, 1);
1270 print '</div>';
1271 print '<div class="nowrap">';
1272 print $langs->trans('to').' ';*/
1273 print $form->selectDate($search_datelimit_end ? $search_datelimit_end : -1, 'search_datelimit_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("Before"));
1274 //print '<br>';
1275 print '<div class="nowraponall inline-block valignmiddle"><input type="checkbox" class="valignmiddle" name="search_option" id="search_option" value="late"'.($option == 'late' ? ' checked' : '').'><label for="search_option" class="valignmiddle">'.$langs->trans("Alert").'</label></div>';
1276 print '</div>';
1277 print '</td>';
1278}
1279// Project
1280if (!empty($arrayfields['p.ref']['checked'])) {
1281 print '<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_project" value="'.dol_escape_htmltag($search_project).'"></td>';
1282}
1283// Thirpdarty
1284if (!empty($arrayfields['s.nom']['checked'])) {
1285 print '<td class="liste_titre"><input class="flat maxwidth100" type="text" name="search_company" value="'.dol_escape_htmltag((string) $search_company).'"'.($socid > 0 ? " disabled" : "").'></td>';
1286}
1287// Alias
1288if (!empty($arrayfields['s.name_alias']['checked'])) {
1289 print '<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_company_alias" value="'.dol_escape_htmltag($search_company_alias).'"></td>';
1290}
1291// Town
1292if (!empty($arrayfields['s.town']['checked'])) {
1293 print '<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_town" value="'.dol_escape_htmltag($search_town).'"></td>';
1294}
1295// Zip
1296if (!empty($arrayfields['s.zip']['checked'])) {
1297 print '<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_zip" value="'.dol_escape_htmltag($search_zip).'"></td>';
1298}
1299// State
1300if (!empty($arrayfields['state.nom']['checked'])) {
1301 print '<td class="liste_titre">';
1302 print '<input class="flat maxwidth50imp" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
1303 print '</td>';
1304}
1305// Country
1306if (!empty($arrayfields['country.code_iso']['checked'])) {
1307 print '<td class="liste_titre center">';
1308 print $form->select_country($search_country, 'search_country', '', 0, 'minwidth150imp maxwidth150', 'code2', 1, 0, 1, array(), 1);
1309 print '</td>';
1310}
1311// Company type
1312if (!empty($arrayfields['typent.code']['checked'])) {
1313 print '<td class="liste_titre maxwidthonsmartphone center">';
1314 print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0, '', 0, 0, 0, (!getDolGlobalString('SOCIETE_SORT_ON_TYPEENT') ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT), '', 1);
1315 print '</td>';
1316}
1317// VAT Reverse Charge
1318if (!empty($arrayfields['f.vat_reverse_charge']['checked'])) {
1319 print '<td class="liste_titre center">';
1320 print $form->selectyesno('search_vat_reverse_charge', $search_vat_reverse_charge, 1, 0, 1, 1);
1321 print '</td>';
1322}
1323// Condition of payment
1324if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) {
1325 print '<td class="liste_titre left">';
1326 print $form->getSelectConditionsPaiements($search_paymentcond, 'search_paymentcond', -1, 1, 1, 'maxwidth100');
1327 print '</td>';
1328}
1329// Payment mode
1330if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) {
1331 print '<td class="liste_titre">';
1332 print $form->select_types_paiements($search_paymentmode, 'search_paymentmode', '', 0, 1, 1, 20, 1, 'maxwidth100', 1);
1333 print '</td>';
1334}
1335if (!empty($arrayfields['f.total_ht']['checked'])) {
1336 // Amount without tax
1337 print '<td class="liste_titre right">';
1338 print '<input class="flat" type="text" size="5" name="search_montant_ht" value="'.dol_escape_htmltag($search_montant_ht).'">';
1339 print '</td>';
1340}
1341if (!empty($arrayfields['f.total_vat']['checked'])) {
1342 // Amount vat
1343 print '<td class="liste_titre right">';
1344 print '<input class="flat" type="text" size="5" name="search_montant_vat" value="'.dol_escape_htmltag($search_montant_vat).'">';
1345 print '</td>';
1346}
1347if (!empty($arrayfields['f.total_localtax1']['checked'])) {
1348 // Amount tax 1
1349 print '<td class="liste_titre right">';
1350 print '<input class="flat" type="text" size="5" name="search_montant_localtax1" value="'.dol_escape_htmltag($search_montant_localtax1).'">';
1351 print '</td>';
1352}
1353if (!empty($arrayfields['f.total_localtax2']['checked'])) {
1354 // Amount tax 2
1355 print '<td class="liste_titre right">';
1356 print '<input class="flat" type="text" size="5" name="search_montant_localtax2" value="'.dol_escape_htmltag($search_montant_localtax2).'">';
1357 print '</td>';
1358}
1359if (!empty($arrayfields['f.total_ttc']['checked'])) {
1360 // Amount inc tac
1361 print '<td class="liste_titre right">';
1362 print '<input class="flat" type="text" size="5" name="search_montant_ttc" value="'.dol_escape_htmltag($search_montant_ttc).'">';
1363 print '</td>';
1364}
1365if (!empty($arrayfields['f.nb_docs']['checked'])) {
1366 // Nb of attached documents
1367 print '<td class="liste_titre" align="center">';
1368 print '</td>';
1369}
1370if (!empty($arrayfields['u.login']['checked'])) {
1371 // Author
1372 print '<td class="liste_titre" align="center">';
1373 print '<input class="flat" size="4" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).'">';
1374 print '</td>';
1375}
1376if (!empty($arrayfields['dynamount_payed']['checked'])) {
1377 print '<td class="liste_titre right">';
1378 print '</td>';
1379}
1380if (!empty($arrayfields['rtp']['checked'])) {
1381 print '<td class="liste_titre">';
1382 print '</td>';
1383}
1384if (!empty($arrayfields['f.multicurrency_code']['checked'])) {
1385 // Currency
1386 print '<td class="liste_titre">';
1387 print $form->selectMultiCurrency($search_multicurrency_code, 'search_multicurrency_code', 1);
1388 print '</td>';
1389}
1390if (!empty($arrayfields['f.multicurrency_tx']['checked'])) {
1391 // Currency rate
1392 print '<td class="liste_titre">';
1393 print '<input class="flat" type="text" size="4" name="search_multicurrency_tx" value="'.dol_escape_htmltag($search_multicurrency_tx).'">';
1394 print '</td>';
1395}
1396if (!empty($arrayfields['f.multicurrency_total_ht']['checked'])) {
1397 // Amount
1398 print '<td class="liste_titre right">';
1399 print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_ht" value="'.dol_escape_htmltag($search_multicurrency_montant_ht).'">';
1400 print '</td>';
1401}
1402if (!empty($arrayfields['f.multicurrency_total_vat']['checked'])) {
1403 // Amount
1404 print '<td class="liste_titre right">';
1405 print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_vat" value="'.dol_escape_htmltag($search_multicurrency_montant_vat).'">';
1406 print '</td>';
1407}
1408if (!empty($arrayfields['f.multicurrency_total_ttc']['checked'])) {
1409 // Amount
1410 print '<td class="liste_titre right">';
1411 print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_ttc" value="'.dol_escape_htmltag($search_multicurrency_montant_ttc).'">';
1412 print '</td>';
1413}
1414if (!empty($arrayfields['multicurrency_dynamount_payed']['checked'])) {
1415 print '<td class="liste_titre">';
1416 print '</td>';
1417}
1418if (!empty($arrayfields['multicurrency_rtp']['checked'])) {
1419 print '<td class="liste_titre right">';
1420 print '</td>';
1421}
1422// Extra fields
1423include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
1424
1425// Fields from hook
1426$parameters = array('arrayfields' => $arrayfields);
1427$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1428print $hookmanager->resPrint;
1429// Date creation
1430if (!empty($arrayfields['f.datec']['checked'])) {
1431 print '<td class="liste_titre">';
1432 print '</td>';
1433}
1434// Date modification
1435if (!empty($arrayfields['f.tms']['checked'])) {
1436 print '<td class="liste_titre">';
1437 print '</td>';
1438}
1439if (!empty($arrayfields['f.note_public']['checked'])) {
1440 // Note public
1441 print '<td class="liste_titre">';
1442 print '<input class="flat maxwidth75" type="text" name="search_note_public" value="'.dol_escape_htmltag($search_note_public).'">';
1443 print '</td>';
1444}
1445if (!empty($arrayfields['f.note_private']['checked'])) {
1446 // Note private
1447 print '<td class="liste_titre">';
1448 print '<input class="flat maxwidth75" type="text" name="search_note_private" value="'.dol_escape_htmltag($search_note_private).'">';
1449 print '</td>';
1450}
1451// Status
1452if (!empty($arrayfields['f.fk_statut']['checked'])) {
1453 print '<td class="liste_titre center parentonrightofpage">';
1454 $liststatus = array('0' => $langs->trans("Draft"), '1' => $langs->trans("Unpaid"), '2' => $langs->trans("Paid"));
1455 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1456 print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'center search_status width100 onrightofpage', 1);
1457 print '</td>';
1458}
1459// Action column
1460if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1461 print '<td class="liste_titre center maxwidthsearch">';
1462 $searchpicto = $form->showFilterButtons();
1463 print $searchpicto;
1464 print '</td>';
1465}
1466
1467print "</tr>\n";
1468
1469$totalarray = array();
1470$totalarray['nbfield'] = 0;
1471
1472// Fields title label
1473// --------------------------------------------------------------------
1474print '<tr class="liste_titre">';
1475// Action column
1476if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1477 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
1478 $totalarray['nbfield']++;
1479}
1480if (!empty($arrayfields['f.ref']['checked'])) {
1481 print_liste_field_titre($arrayfields['f.ref']['label'], $_SERVER['PHP_SELF'], 'f.ref,f.rowid', '', $param, '', $sortfield, $sortorder);
1482 $totalarray['nbfield']++;
1483}
1484if (!empty($arrayfields['f.ref_supplier']['checked'])) {
1485 print_liste_field_titre($arrayfields['f.ref_supplier']['label'], $_SERVER["PHP_SELF"], 'f.ref_supplier', '', $param, '', $sortfield, $sortorder);
1486 $totalarray['nbfield']++;
1487}
1488if (!empty($arrayfields['f.type']['checked'])) {
1489 print_liste_field_titre($arrayfields['f.type']['label'], $_SERVER["PHP_SELF"], 'f.type', '', $param, '', $sortfield, $sortorder);
1490 $totalarray['nbfield']++;
1491}
1492if (!empty($arrayfields['f.subtype']['checked'])) {
1493 print_liste_field_titre($arrayfields['f.subtype']['label'], $_SERVER["PHP_SELF"], 'f.subtype', '', $param, '', $sortfield, $sortorder);
1494}
1495if (!empty($arrayfields['f.label']['checked'])) {
1496 print_liste_field_titre($arrayfields['f.label']['label'], $_SERVER['PHP_SELF'], "f.libelle,f.rowid", '', $param, '', $sortfield, $sortorder);
1497 $totalarray['nbfield']++;
1498}
1499if (!empty($arrayfields['f.datef']['checked'])) {
1500 print_liste_field_titre($arrayfields['f.datef']['label'], $_SERVER['PHP_SELF'], 'f.datef,f.rowid', '', $param, '', $sortfield, $sortorder, 'center ');
1501 $totalarray['nbfield']++;
1502}
1503if (!empty($arrayfields['f.date_lim_reglement']['checked'])) {
1504 print_liste_field_titre($arrayfields['f.date_lim_reglement']['label'], $_SERVER['PHP_SELF'], "f.date_lim_reglement", '', $param, '', $sortfield, $sortorder, 'center ');
1505 $totalarray['nbfield']++;
1506}
1507if (!empty($arrayfields['p.ref']['checked'])) {
1508 print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER['PHP_SELF'], "p.ref", '', $param, '', $sortfield, $sortorder);
1509 $totalarray['nbfield']++;
1510}
1511if (!empty($arrayfields['s.nom']['checked'])) {
1512 print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER['PHP_SELF'], 's.nom', '', $param, '', $sortfield, $sortorder);
1513 $totalarray['nbfield']++;
1514}
1515if (!empty($arrayfields['s.name_alias']['checked'])) {
1516 // @phan-suppress-next-line PhanTypeInvalidDimOffset
1517 print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER['PHP_SELF'], 's.name_alias', '', $param, '', $sortfield, $sortorder);
1518 $totalarray['nbfield']++;
1519}
1520if (!empty($arrayfields['s.town']['checked'])) {
1521 print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder);
1522 $totalarray['nbfield']++;
1523}
1524if (!empty($arrayfields['s.zip']['checked'])) {
1525 print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder);
1526 $totalarray['nbfield']++;
1527}
1528if (!empty($arrayfields['state.nom']['checked'])) {
1529 print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.name_alias", "", $param, '', $sortfield, $sortorder);
1530 $totalarray['nbfield']++;
1531}
1532if (!empty($arrayfields['state.name_alias']['checked'])) {
1533 print_liste_field_titre($arrayfields['state.name_alias']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder);
1534 $totalarray['nbfield']++;
1535}
1536if (!empty($arrayfields['country.code_iso']['checked'])) {
1537 print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center ');
1538 $totalarray['nbfield']++;
1539}
1540if (!empty($arrayfields['typent.code']['checked'])) {
1541 print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center ');
1542 $totalarray['nbfield']++;
1543}
1544if (!empty($arrayfields['f.vat_reverse_charge']['checked'])) {
1545 print_liste_field_titre($arrayfields['f.vat_reverse_charge']['label'], $_SERVER["PHP_SELF"], "f.vat_reverse_charge", "", $param, "", $sortfield, $sortorder, 'center ');
1546 $totalarray['nbfield']++;
1547}
1548if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) {
1549 print_liste_field_titre($arrayfields['f.fk_cond_reglement']['label'], $_SERVER["PHP_SELF"], "f.fk_cond_reglement", "", $param, "", $sortfield, $sortorder);
1550 $totalarray['nbfield']++;
1551}
1552if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) {
1553 print_liste_field_titre($arrayfields['f.fk_mode_reglement']['label'], $_SERVER["PHP_SELF"], "f.fk_mode_reglement", "", $param, "", $sortfield, $sortorder);
1554 $totalarray['nbfield']++;
1555}
1556if (!empty($arrayfields['f.total_ht']['checked'])) {
1557 print_liste_field_titre($arrayfields['f.total_ht']['label'], $_SERVER['PHP_SELF'], 'f.total_ht', '', $param, '', $sortfield, $sortorder, 'right ');
1558 $totalarray['nbfield']++;
1559}
1560if (!empty($arrayfields['f.total_vat']['checked'])) {
1561 print_liste_field_titre($arrayfields['f.total_vat']['label'], $_SERVER['PHP_SELF'], 'f.total_tva', '', $param, '', $sortfield, $sortorder, 'right ');
1562 $totalarray['nbfield']++;
1563}
1564if (!empty($arrayfields['f.total_localtax1']['checked'])) {
1565 print_liste_field_titre($arrayfields['f.total_localtax1']['label'], $_SERVER['PHP_SELF'], 'f.localtax1', '', $param, '', $sortfield, $sortorder, 'right ');
1566 $totalarray['nbfield']++;
1567}
1568if (!empty($arrayfields['f.total_localtax2']['checked'])) {
1569 print_liste_field_titre($arrayfields['f.total_localtax2']['label'], $_SERVER['PHP_SELF'], 'f.localtax2', '', $param, '', $sortfield, $sortorder, 'right ');
1570 $totalarray['nbfield']++;
1571}
1572if (!empty($arrayfields['f.total_ttc']['checked'])) {
1573 print_liste_field_titre($arrayfields['f.total_ttc']['label'], $_SERVER['PHP_SELF'], 'f.total_ttc', '', $param, '', $sortfield, $sortorder, 'right ');
1574 $totalarray['nbfield']++;
1575}
1576if (!empty($arrayfields['f.nb_docs']['checked'])) {
1577 print_liste_field_titre($arrayfields['f.nb_docs']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right ');
1578 $totalarray['nbfield']++;
1579}
1580if (!empty($arrayfields['u.login']['checked'])) {
1581 print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.login', '', $param, '', $sortfield, $sortorder);
1582 $totalarray['nbfield']++;
1583}
1584if (!empty($arrayfields['dynamount_payed']['checked'])) {
1585 print_liste_field_titre($arrayfields['dynamount_payed']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right ');
1586 $totalarray['nbfield']++;
1587}
1588if (!empty($arrayfields['rtp']['checked'])) {
1589 print_liste_field_titre($arrayfields['rtp']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder);
1590 $totalarray['nbfield']++;
1591}
1592if (!empty($arrayfields['f.multicurrency_code']['checked'])) {
1593 print_liste_field_titre($arrayfields['f.multicurrency_code']['label'], $_SERVER['PHP_SELF'], 'f.multicurrency_code', '', $param, '', $sortfield, $sortorder);
1594 $totalarray['nbfield']++;
1595}
1596if (!empty($arrayfields['f.multicurrency_tx']['checked'])) {
1597 print_liste_field_titre($arrayfields['f.multicurrency_tx']['label'], $_SERVER['PHP_SELF'], 'f.multicurrency_tx', '', $param, '', $sortfield, $sortorder);
1598 $totalarray['nbfield']++;
1599}
1600if (!empty($arrayfields['f.multicurrency_total_ht']['checked'])) {
1601 print_liste_field_titre($arrayfields['f.multicurrency_total_ht']['label'], $_SERVER['PHP_SELF'], 'f.multicurrency_total_ht', '', $param, '"', $sortfield, $sortorder, 'right ');
1602 $totalarray['nbfield']++;
1603}
1604if (!empty($arrayfields['f.multicurrency_total_vat']['checked'])) {
1605 print_liste_field_titre($arrayfields['f.multicurrency_total_vat']['label'], $_SERVER['PHP_SELF'], 'f.multicurrency_total_tva', '', $param, '', $sortfield, $sortorder, 'right ');
1606 $totalarray['nbfield']++;
1607}
1608if (!empty($arrayfields['f.multicurrency_total_ttc']['checked'])) {
1609 print_liste_field_titre($arrayfields['f.multicurrency_total_ttc']['label'], $_SERVER['PHP_SELF'], 'f.multicurrency_total_ttc', '', $param, '', $sortfield, $sortorder, 'right ');
1610 $totalarray['nbfield']++;
1611}
1612if (!empty($arrayfields['multicurrency_dynamount_payed']['checked'])) {
1613 print_liste_field_titre($arrayfields['multicurrency_dynamount_payed']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right ');
1614 $totalarray['nbfield']++;
1615}
1616if (!empty($arrayfields['multicurrency_rtp']['checked'])) {
1617 print_liste_field_titre($arrayfields['multicurrency_rtp']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right ');
1618 $totalarray['nbfield']++;
1619}
1620// Extra fields
1621include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
1622// Hook fields
1623$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'totalarray' => &$totalarray);
1624$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1625print $hookmanager->resPrint;
1626if (!empty($arrayfields['f.datec']['checked'])) {
1627 print_liste_field_titre($arrayfields['f.datec']['label'], $_SERVER["PHP_SELF"], "f.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1628 $totalarray['nbfield']++;
1629}
1630if (!empty($arrayfields['f.tms']['checked'])) {
1631 print_liste_field_titre($arrayfields['f.tms']['label'], $_SERVER["PHP_SELF"], "f.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1632 $totalarray['nbfield']++;
1633}
1634if (!empty($arrayfields['f.note_public']['checked'])) {
1635 print_liste_field_titre($arrayfields['f.note_public']['label'], $_SERVER["PHP_SELF"], "f.note_public", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1636 $totalarray['nbfield']++;
1637}
1638if (!empty($arrayfields['f.note_private']['checked'])) {
1639 print_liste_field_titre($arrayfields['f.note_private']['label'], $_SERVER["PHP_SELF"], "f.note_private", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1640 $totalarray['nbfield']++;
1641}
1642if (!empty($arrayfields['f.fk_statut']['checked'])) {
1643 print_liste_field_titre($arrayfields['f.fk_statut']['label'], $_SERVER["PHP_SELF"], "fk_statut,paye,type", "", $param, '', $sortfield, $sortorder, 'center ');
1644 $totalarray['nbfield']++;
1645}
1646// Action column
1647if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1648 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
1649 $totalarray['nbfield']++;
1650}
1651print '</tr>'."\n";
1652
1653$facturestatic = new FactureFournisseur($db);
1654$supplierstatic = new Fournisseur($db);
1655$projectstatic = new Project($db);
1656$userstatic = new User($db);
1657$discount = new DiscountAbsolute($db);
1658
1659// Loop on record
1660// --------------------------------------------------------------------
1661$i = 0;
1662$savnbfield = $totalarray['nbfield'];
1663$totalarray = array();
1664$totalarray['nbfield'] = 0;
1665$totalarray['val'] = array();
1666$totalarray['val']['f.total_ht'] = 0;
1667$totalarray['val']['f.total_vat'] = 0;
1668$totalarray['val']['f.total_localtax1'] = 0;
1669$totalarray['val']['f.total_localtax2'] = 0;
1670$totalarray['val']['f.total_ttc'] = 0;
1671$totalarray['val']['totalam'] = 0;
1672$totalarray['val']['rtp'] = 0;
1673
1674$imaxinloop = ($limit ? min($num, $limit) : $num);
1675while ($i < $imaxinloop) {
1676 $obj = $db->fetch_object($resql);
1677 if (empty($obj)) {
1678 break; // Should not happen
1679 }
1680
1681 $datelimit = $db->jdate($obj->datelimite);
1682
1683 $userstatic->id = $obj->fk_user_author;
1684 $userstatic->login = $obj->login;
1685 $userstatic->lastname = $obj->lastname;
1686 $userstatic->firstname = $obj->firstname;
1687 $userstatic->email = $obj->user_email;
1688 $userstatic->statut = $obj->user_statut;
1689 $userstatic->status = $obj->user_statut;
1690 $userstatic->entity = $obj->entity;
1691 $userstatic->photo = $obj->photo;
1692 $userstatic->office_phone = $obj->office_phone;
1693 $userstatic->office_fax = $obj->office_fax;
1694 $userstatic->user_mobile = $obj->user_mobile;
1695 $userstatic->job = $obj->job;
1696 $userstatic->gender = $obj->gender;
1697 $facturestatic->id = $obj->facid;
1698 $facturestatic->ref = $obj->ref;
1699 $facturestatic->type = $obj->type;
1700 $facturestatic->subtype = $obj->subtype;
1701 $facturestatic->total_ht = $obj->total_ht;
1702 $facturestatic->total_tva = $obj->total_vat;
1703 $facturestatic->total_ttc = $obj->total_ttc;
1704 $facturestatic->close_code = $obj->close_code;
1705 $facturestatic->ref_supplier = $obj->ref_supplier;
1706 $facturestatic->date_echeance = $db->jdate($obj->datelimite);
1707 $facturestatic->statut = $obj->fk_statut;
1708 $facturestatic->status = $obj->fk_statut;
1709 $facturestatic->note_public = $obj->note_public;
1710 $facturestatic->note_private = $obj->note_private;
1711 $facturestatic->multicurrency_code = $obj->multicurrency_code;
1712 $facturestatic->multicurrency_tx = $obj->multicurrency_tx;
1713 $facturestatic->multicurrency_total_ht = $obj->multicurrency_total_ht;
1714 $facturestatic->multicurrency_total_tva = $obj->multicurrency_total_vat;
1715 $facturestatic->multicurrency_total_ttc = $obj->multicurrency_total_ttc;
1716 $thirdparty->id = $obj->socid;
1717 $thirdparty->name = $obj->name;
1718 $thirdparty->name_alias = $obj->alias;
1719 $thirdparty->client = $obj->client;
1720 $thirdparty->fournisseur = $obj->fournisseur;
1721 $thirdparty->code_client = $obj->code_client;
1722 $thirdparty->code_compta_client = $obj->code_compta_client;
1723 $thirdparty->code_fournisseur = $obj->code_fournisseur;
1724 $thirdparty->code_compta_fournisseur = $obj->code_compta_fournisseur;
1725 $thirdparty->email = $obj->email;
1726 $thirdparty->country_code = $obj->country_code;
1727
1728 $paiement = $facturestatic->getSommePaiement();
1729 $totalcreditnotes = $facturestatic->getSumCreditNotesUsed();
1730 $totaldeposits = $facturestatic->getSumDepositsUsed();
1731 $totalpay = $paiement + $totalcreditnotes + $totaldeposits;
1732 $remaintopay = $obj->total_ttc - $totalpay;
1733
1734 $multicurrency_paiement = $facturestatic->getSommePaiement(1);
1735 $multicurrency_totalcreditnotes = $facturestatic->getSumCreditNotesUsed(1);
1736 $multicurrency_totaldeposits = $facturestatic->getSumDepositsUsed(1);
1737
1738 $totalpay = $paiement + $totalcreditnotes + $totaldeposits;
1739 $remaintopay = price2num($facturestatic->total_ttc - $totalpay);
1740
1741 $multicurrency_totalpay = $multicurrency_paiement + $multicurrency_totalcreditnotes + $multicurrency_totaldeposits;
1742 $multicurrency_remaintopay = (float) price2num($facturestatic->multicurrency_total_ttc - $multicurrency_totalpay);
1743
1744 if ($facturestatic->status == FactureFournisseur::STATUS_CLOSED && $facturestatic->close_code == 'discount_vat') { // If invoice closed with discount for anticipated payment
1745 $remaintopay = 0;
1746 $multicurrency_remaintopay = 0;
1747 }
1748 if ($facturestatic->type == FactureFournisseur::TYPE_CREDIT_NOTE && $obj->paye == 1) { // If credit note closed, we take into account the amount not yet consumed
1749 $remaincreditnote = $discount->getAvailableDiscounts($thirdparty, null, 'rc.fk_facture_source='.$facturestatic->id);
1750 $remaintopay = -$remaincreditnote;
1751 $totalpay = price2num($facturestatic->total_ttc - $remaintopay);
1752 $multicurrency_remaincreditnote = $discount->getAvailableDiscounts($thirdparty, null, 'rc.fk_facture_source='.$facturestatic->id, 0, 0, 1);
1753 $multicurrency_remaintopay = -$multicurrency_remaincreditnote;
1754 $multicurrency_totalpay = (float) price2num($facturestatic->multicurrency_total_ttc - $multicurrency_remaintopay);
1755 }
1756
1757 $facturestatic->alreadypaid = ($paiement ? $paiement : 0);
1758
1759 $facturestatic->paye = $obj->paye;
1760 $facturestatic->paid = $obj->paye;
1761
1762 $facturestatic->date = $db->jdate($obj->datef);
1763
1764 $object = $facturestatic;
1765
1766 //If invoice has been converted and the conversion has been used, we don't have remain to pay on invoice
1767 if ($facturestatic->type == FactureFournisseur::TYPE_CREDIT_NOTE) {
1768 if ($facturestatic->isCreditNoteUsed()) {
1769 $remaintopay = -$facturestatic->getSumFromThisCreditNotesNotUsed();
1770 }
1771 }
1772
1773 if ($mode == 'kanban') {
1774 if ($i == 0) {
1775 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
1776 print '<div class="box-flex-container kanban">';
1777 }
1778 // Output Kanban
1779 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1780 $selected = 0;
1781 if (in_array($object->id, $arrayofselected)) {
1782 $selected = 1;
1783 }
1784 }
1785
1786 $arraydata = array('alreadypaid' => $paiement, 'thirdparty' => $thirdparty->getNomUrl(1, '', 12), 'selected' => in_array($object->id, $arrayofselected));
1787 print $facturestatic->getKanbanView('', $arraydata);
1788 if ($i == ($imaxinloop - 1)) {
1789 print '</div>';
1790 print '</td></tr>';
1791 }
1792 } else {
1793 // Show line of result
1794 $j = 0;
1795 print '<tr data-rowid="'.$object->id.'" class="oddeven row-with-select '.((getDolGlobalInt('MAIN_FINISHED_LINES_OPACITY') == 1 && $obj->fk_statut > 1) ? 'opacitymedium' : '').'">';
1796
1797 // Action column
1798 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1799 print '<td class="nowrap center">';
1800 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1801 $selected = 0;
1802 if (in_array($obj->facid, $arrayofselected)) {
1803 $selected = 1;
1804 }
1805 print '<input id="cb'.$obj->facid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->facid.'"'.($selected ? ' checked="checked"' : '').'>';
1806 }
1807 print '</td>';
1808 if (!$i) {
1809 $totalarray['nbfield']++;
1810 }
1811 }
1812 if (!empty($arrayfields['f.ref']['checked'])) {
1813 print '<td class="nowraponall">';
1814
1815 print '<table class="nobordernopadding"><tr class="nocellnopadd">';
1816 // Picto + Ref
1817 print '<td class="nobordernopadding nowraponall">';
1818 print $facturestatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1);
1819
1820 $filename = dol_sanitizeFileName($obj->ref);
1821 $filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($obj->facid, 2, 0, 0, $facturestatic, 'invoice_supplier').dol_sanitizeFileName($obj->ref);
1822 $subdir = get_exdir($obj->facid, 2, 0, 0, $facturestatic, 'invoice_supplier').dol_sanitizeFileName($obj->ref);
1823 print $formfile->getDocumentsLink('facture_fournisseur', $subdir, $filedir);
1824 print '</td></tr></table>';
1825
1826 print "</td>\n";
1827 if (!$i) {
1828 $totalarray['nbfield']++;
1829 }
1830 }
1831
1832 // Supplier ref
1833 if (!empty($arrayfields['f.ref_supplier']['checked'])) {
1834 print '<td class="nowrap tdoverflowmax150" title="'.dol_escape_htmltag($obj->ref_supplier).'">';
1835 print $obj->ref_supplier;
1836 print '</td>';
1837 if (!$i) {
1838 $totalarray['nbfield']++;
1839 }
1840 }
1841
1842 // Type
1843 if (!empty($arrayfields['f.type']['checked'])) {
1844 print '<td class="nowrap">';
1845 print $facturestatic->getLibType();
1846 print "</td>";
1847 if (!$i) {
1848 $totalarray['nbfield']++;
1849 }
1850 }
1851
1852 // Invoice Subtype
1853 if (!empty($arrayfields['f.subtype']['checked'])) {
1854 $labeltoshow = '';
1855 if ($facturestatic->subtype > 0) {
1856 $labeltoshow = $facturestatic->getSubtypeLabel('facture_fourn');
1857 }
1858 print '<td class="nowraponall tdoverflowmax300" title="'.$labeltoshow.'">';
1859 print $labeltoshow;
1860 print "</td>";
1861 if (!$i) {
1862 $totalarray['nbfield']++;
1863 }
1864 }
1865
1866 // Label
1867 if (!empty($arrayfields['f.label']['checked'])) {
1868 print '<td class="nowrap tdoverflowmax125" title="'.dol_escape_htmltag($obj->label).'">';
1869 print dol_escape_htmltag($obj->label);
1870 print '</td>';
1871 if (!$i) {
1872 $totalarray['nbfield']++;
1873 }
1874 }
1875
1876 // Date
1877 if (!empty($arrayfields['f.datef']['checked'])) {
1878 print '<td class="center nowrap">';
1879 print dol_print_date($db->jdate($obj->datef), 'day');
1880 print '</td>';
1881 if (!$i) {
1882 $totalarray['nbfield']++;
1883 }
1884 }
1885
1886 // Date limit
1887 if (!empty($arrayfields['f.date_lim_reglement']['checked'])) {
1888 print '<td class="center nowraponall">'.dol_print_date($datelimit, 'day');
1889 if ($facturestatic->hasDelay()) {
1890 print img_warning($langs->trans('Alert').' - '.$langs->trans('Late'));
1891 }
1892 print '</td>';
1893 if (!$i) {
1894 $totalarray['nbfield']++;
1895 }
1896 }
1897
1898 // Project
1899 if (!empty($arrayfields['p.ref']['checked'])) {
1900 print '<td class="nowrap">';
1901 if ($obj->project_id > 0) {
1902 $projectstatic->id = $obj->project_id;
1903 $projectstatic->ref = $obj->project_ref;
1904 $projectstatic->title = $obj->project_label;
1905 print $projectstatic->getNomUrl(1);
1906 }
1907 print '</td>';
1908 if (!$i) {
1909 $totalarray['nbfield']++;
1910 }
1911 }
1912
1913 // Third party
1914 if (!empty($arrayfields['s.nom']['checked'])) {
1915 print '<td class="tdoverflowmax125">';
1916 print $thirdparty->getNomUrl(1, 'supplier', 0, 0, -1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1);
1917 print '</td>';
1918 if (!$i) {
1919 $totalarray['nbfield']++;
1920 }
1921 }
1922 // Alias
1923 if (!empty($arrayfields['s.name_alias']['checked'])) {
1924 print '<td class="tdoverflowmax150">';
1925 print dol_escape_htmltag($thirdparty->name_alias);
1926 print '</td>';
1927 if (!$i) {
1928 $totalarray['nbfield']++;
1929 }
1930 }
1931 // Town
1932 if (!empty($arrayfields['s.town']['checked'])) {
1933 print '<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->town).'">';
1934 print dol_escape_htmltag($obj->town);
1935 print '</td>';
1936 if (!$i) {
1937 $totalarray['nbfield']++;
1938 }
1939 }
1940 // Zip
1941 if (!empty($arrayfields['s.zip']['checked'])) {
1942 print '<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->zip).'">';
1943 print dol_escape_htmltag($obj->zip);
1944 print '</td>';
1945 if (!$i) {
1946 $totalarray['nbfield']++;
1947 }
1948 }
1949 // State
1950 if (!empty($arrayfields['state.nom']['checked'])) {
1951 print '<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->state_name).'">';
1952 print dol_escape_htmltag($obj->state_name);
1953 print "</td>\n";
1954 if (!$i) {
1955 $totalarray['nbfield']++;
1956 }
1957 }
1958 // Country
1959 if (!empty($arrayfields['country.code_iso']['checked'])) {
1960 print '<td class="center">';
1961 $tmparray = getCountry($obj->fk_pays, 'all');
1962 print $tmparray['label'];
1963 print '</td>';
1964 if (!$i) {
1965 $totalarray['nbfield']++;
1966 }
1967 }
1968 // Type ent
1969 if (!empty($arrayfields['typent.code']['checked'])) {
1970 print '<td class="center">';
1971 if (empty($typenArray)) {
1972 $typenArray = $formcompany->typent_array(1);
1973 }
1974 print $typenArray[$obj->typent_code];
1975 print '</td>';
1976 if (!$i) {
1977 $totalarray['nbfield']++;
1978 }
1979 }
1980 // VAT Reverse Charge
1981 if (!empty($arrayfields['f.vat_reverse_charge']['checked'])) {
1982 print '<td class="center">';
1983 print yn($obj->vat_reverse_charge);
1984 print '</td>';
1985 if (!$i) {
1986 $totalarray['nbfield']++;
1987 }
1988 }
1989
1990 // Payment condition
1991 if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) {
1992 $s = $form->form_conditions_reglement($_SERVER['PHP_SELF'], $obj->fk_cond_reglement, 'none', 1, '', -1, -1, 1);
1993 print '<td class="tdoverflowmax100" title="'.dol_escape_htmltag($s).'">';
1994 print dol_escape_htmltag($s);
1995 print '</td>';
1996 if (!$i) {
1997 $totalarray['nbfield']++;
1998 }
1999 }
2000 // Payment mode
2001 if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) {
2002 $s = $form->form_modes_reglement($_SERVER['PHP_SELF'], $obj->fk_mode_reglement, 'none', '', -1, 0, '', 1);
2003 print '<td class="tdoverflowmax100" title="'.dol_escape_htmltag($s).'">';
2004 print dol_escape_htmltag($s);
2005 print '</td>';
2006 if (!$i) {
2007 $totalarray['nbfield']++;
2008 }
2009 }
2010
2011 // Amount HT
2012 if (!empty($arrayfields['f.total_ht']['checked'])) {
2013 print '<td class="right nowrap"><span class="amount">'.price($obj->total_ht)."</span></td>\n";
2014 if (!$i) {
2015 $totalarray['nbfield']++;
2016 $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ht';
2017 }
2018 $totalarray['val']['f.total_ht'] += $obj->total_ht;
2019 }
2020 // Amount VAT
2021 if (!empty($arrayfields['f.total_vat']['checked'])) {
2022 print '<td class="right nowrap"><span class="amount">'.price($obj->total_vat)."</span></td>\n";
2023 if (!$i) {
2024 $totalarray['nbfield']++;
2025 $totalarray['pos'][$totalarray['nbfield']] = 'f.total_vat';
2026 }
2027 $totalarray['val']['f.total_vat'] += $obj->total_vat;
2028 }
2029 // Amount LocalTax1
2030 if (!empty($arrayfields['f.total_localtax1']['checked'])) {
2031 print '<td class="right nowrap"><span class="amount">'.price($obj->total_localtax1)."</span></td>\n";
2032 if (!$i) {
2033 $totalarray['nbfield']++;
2034 $totalarray['pos'][$totalarray['nbfield']] = 'f.total_localtax1';
2035 }
2036 $totalarray['val']['f.total_localtax1'] += $obj->total_localtax1;
2037 }
2038 // Amount LocalTax2
2039 if (!empty($arrayfields['f.total_localtax2']['checked'])) {
2040 print '<td class="right nowrap"><span class="amount">'.price($obj->total_localtax2)."</span></td>\n";
2041 if (!$i) {
2042 $totalarray['nbfield']++;
2043 $totalarray['pos'][$totalarray['nbfield']] = 'f.total_localtax2';
2044 }
2045 $totalarray['val']['f.total_localtax2'] += $obj->total_localtax2;
2046 }
2047 // Amount TTC
2048 if (!empty($arrayfields['f.total_ttc']['checked'])) {
2049 print '<td class="right nowrap"><span class="amount">'.price($obj->total_ttc)."</span></td>\n";
2050 if (!$i) {
2051 $totalarray['nbfield']++;
2052 $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ttc';
2053 }
2054 $totalarray['val']['f.total_ttc'] += $obj->total_ttc;
2055 }
2056
2057 // Number of attached documents (may slow your application on large lists)
2058 if (!empty($arrayfields['f.nb_docs']['checked'])) {
2059 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
2060 require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
2061 $upload_dir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($facturestatic->id, 2, 0, 0, $facturestatic, 'invoice_supplier').$facturestatic->ref;
2062 $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
2063 $nbLinks = Link::count($db, $facturestatic->element, $facturestatic->id);
2064 $nbTotal = $nbFiles + $nbLinks;
2065 echo '<td class="center">'.(empty($nbTotal) ? '' : $nbTotal).'</td>';
2066 if (!$i) {
2067 $totalarray['nbfield']++;
2068 }
2069 }
2070
2071 // Author
2072 if (!empty($arrayfields['u.login']['checked'])) {
2073 print '<td class="tdoverflowmax100">';
2074 if ($userstatic->id) {
2075 print $userstatic->getNomUrl(-1);
2076 } else {
2077 print '&nbsp;';
2078 }
2079 print "</td>\n";
2080 if (!$i) {
2081 $totalarray['nbfield']++;
2082 }
2083 }
2084
2085 // Dynamic amount paid
2086 if (!empty($arrayfields['dynamount_payed']['checked'])) {
2087 print '<td class="right nowrap"><span class="amount">'.(!empty($totalpay) ? price($totalpay, 0, $langs) : '').'</span></td>'; // TODO Use a denormalized field
2088 if (!$i) {
2089 $totalarray['nbfield']++;
2090 $totalarray['pos'][$totalarray['nbfield']] = 'totalam';
2091 }
2092 $totalarray['val']['totalam'] += $totalpay;
2093 }
2094
2095 // Remain to pay
2096 if (!empty($arrayfields['rtp']['checked'])) {
2097 print '<td class="right nowrap">'.(!empty($remaintopay) ? price($remaintopay, 0, $langs) : '&nbsp;').'</td>'; // TODO Use a denormalized field
2098 if (!$i) {
2099 $totalarray['nbfield']++;
2100 $totalarray['pos'][$totalarray['nbfield']] = 'rtp';
2101 }
2102 $totalarray['val']['rtp'] += $remaintopay;
2103 }
2104
2105 // Currency
2106 if (!empty($arrayfields['f.multicurrency_code']['checked'])) {
2107 print '<td class="nowrap">'.$obj->multicurrency_code.' - '.$langs->trans('Currency'.$obj->multicurrency_code)."</td>\n";
2108 if (!$i) {
2109 $totalarray['nbfield']++;
2110 }
2111 }
2112
2113 // Currency rate
2114 if (!empty($arrayfields['f.multicurrency_tx']['checked'])) {
2115 print '<td class="nowrap">';
2116 $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->facid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code);
2117 print "</td>\n";
2118 if (!$i) {
2119 $totalarray['nbfield']++;
2120 }
2121 }
2122 // Amount HT
2123 if (!empty($arrayfields['f.multicurrency_total_ht']['checked'])) {
2124 print '<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ht)."</span></td>\n";
2125 if (!$i) {
2126 $totalarray['nbfield']++;
2127 }
2128 }
2129 // Amount VAT
2130 if (!empty($arrayfields['f.multicurrency_total_vat']['checked'])) {
2131 print '<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_vat)."</span></td>\n";
2132 if (!$i) {
2133 $totalarray['nbfield']++;
2134 }
2135 }
2136 // Amount TTC
2137 if (!empty($arrayfields['f.multicurrency_total_ttc']['checked'])) {
2138 print '<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ttc)."</span></td>\n";
2139 if (!$i) {
2140 $totalarray['nbfield']++;
2141 }
2142 }
2143 // Dynamic amount paid
2144 if (!empty($arrayfields['multicurrency_dynamount_payed']['checked'])) {
2145 print '<td class="right nowrap"><span class="amount">'.(!empty($multicurrency_totalpay) ? price($multicurrency_totalpay, 0, $langs) : '').'</span></td>'; // TODO Use a denormalized field
2146 if (!$i) {
2147 $totalarray['nbfield']++;
2148 }
2149 }
2150
2151 // Pending amount
2152 if (!empty($arrayfields['multicurrency_rtp']['checked'])) {
2153 print '<td class="right nowrap"><span class="amount">';
2154 print(!empty($multicurrency_remaintopay) ? price($multicurrency_remaintopay, 0, $langs) : '');
2155 print '</span></td>'; // TODO Use a denormalized field
2156 if (!$i) {
2157 $totalarray['nbfield']++;
2158 }
2159 }
2160
2161
2162 // Extra fields
2163 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
2164 // Fields from hook
2165 $parameters = array('arrayfields' => $arrayfields, 'object' => $object, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray);
2166 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
2167 print $hookmanager->resPrint;
2168
2169 // Date creation
2170 if (!empty($arrayfields['f.datec']['checked'])) {
2171 print '<td class="center nowraponall">';
2172 print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
2173 print '</td>';
2174 if (!$i) {
2175 $totalarray['nbfield']++;
2176 }
2177 }
2178 // Date modification
2179 if (!empty($arrayfields['f.tms']['checked'])) {
2180 print '<td class="center nowraponall">';
2181 print dol_print_date($db->jdate($obj->date_modification), 'dayhour', 'tzuser');
2182 print '</td>';
2183 if (!$i) {
2184 $totalarray['nbfield']++;
2185 }
2186 }
2187 // Note public
2188 if (!empty($arrayfields['f.note_public']['checked'])) {
2189 print '<td class="sensiblehtmlcontent center">';
2190 print '<div class="small lineheightsmall twolinesmax-normallineheight">'.dolPrintHTML(dolGetFirstLineOfText($obj->note_public, 5)).'</div>';
2191 print '</td>';
2192 if (!$i) {
2193 $totalarray['nbfield']++;
2194 }
2195 }
2196 // Note private
2197 if (!empty($arrayfields['f.note_private']['checked'])) {
2198 print '<td class="sensiblehtmlcontent center">';
2199 print '<div class="small lineheightsmall twolinesmax-normallineheight">'.dolPrintHTML(dolGetFirstLineOfText($obj->note_private, 5)).'</div>';
2200 print '</td>';
2201 if (!$i) {
2202 $totalarray['nbfield']++;
2203 }
2204 }
2205 // Status
2206 if (!empty($arrayfields['f.fk_statut']['checked'])) {
2207 print '<td class="center nowrap">';
2208 print $facturestatic->getLibStatut(5, $paiement);
2209 print "</td>";
2210 if (!$i) {
2211 $totalarray['nbfield']++;
2212 }
2213 }
2214
2215 // Action column
2216 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
2217 print '<td class="nowrap center">';
2218 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
2219 $selected = 0;
2220 if (in_array($obj->facid, $arrayofselected)) {
2221 $selected = 1;
2222 }
2223 print '<input id="cb'.$obj->facid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->facid.'"'.($selected ? ' checked="checked"' : '').'>';
2224 }
2225 print '</td>';
2226 if (!$i) {
2227 $totalarray['nbfield']++;
2228 }
2229 }
2230
2231 print '</tr>'."\n";
2232 }
2233
2234 $i++;
2235}
2236
2237// Show total line
2238include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
2239
2240// If no record found
2241if ($num == 0) {
2242 $colspan = 1;
2243 foreach ($arrayfields as $key => $val) {
2244 if (!empty($val['checked'])) {
2245 $colspan++;
2246 }
2247 }
2248 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
2249}
2250
2251$db->free($resql);
2252
2253$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
2254$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
2255print $hookmanager->resPrint;
2256
2257print '</table>'."\n";
2258print '</div>'."\n";
2259
2260print '</form>'."\n";
2261
2262if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
2263 $hidegeneratedfilelistifempty = 1;
2264 if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
2265 $hidegeneratedfilelistifempty = 0;
2266 }
2267
2268 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
2269 $formfile = new FormFile($db);
2270
2271 // Show list of available documents
2272 $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
2273 $urlsource .= str_replace('&amp;', '&', $param);
2274
2275 $filedir = $diroutputmassaction;
2276 $genallowed = $permissiontoread;
2277 $delallowed = $permissiontoadd;
2278 $title = '';
2279
2280 print $formfile->showdocuments('massfilesarea_supplier_invoice', '', $filedir, $urlsource, 0, (int) $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
2281}
2282
2283// End of page
2284llxFooter();
2285$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
$totalarray
Definition export.php:1216
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
Class to manage absolute discounts.
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.
const STATUS_CLOSED
Classified paid.
Class to manage invoice templates.
Class to manage forms for categories.
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.
Class 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=null, $outputlangs=null, $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
getCountriesInEEC()
Return list of countries that are inside the EEC (European Economic Community) Note: Try to keep this...
global $mysoc
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
Definition files.lib.php:64
dol_now($mode='gmt')
Return date for now.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
GETPOSTDATE($prefix, $hourTime='', $gm='auto', $saverestore='')
Helper function that combines values of a dolibarr DatePicker (such as Form\selectDate) for year,...
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dolGetFirstLineOfText($text, $nboflines=1, $charset='UTF-8')
Return first line of text.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
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.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
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.
natural_search($fields, $value, $mode=0, $nofirstand=0, $sqltoadd='')
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get 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.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
buildParamDate($prefix, $timestamp=null, $hourTime='', $gm='auto')
Helper function that combines values of a dolibarr DatePicker (such as Form\selectDate) for year,...
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
dol_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...
supplier_invoice_rec_prepare_head($object)
Return array head with list of tabs to view object information.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.