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