dolibarr 24.0.2
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 Eric Seigne <eric.seigne@ryxeo.com>
4 * Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
5 * Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
6 * Copyright (C) 2005-2015 Regis Houssin <regis.houssin@inodbox.com>
7 * Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
8 * Copyright (C) 2010-2020 Juanjo Menent <jmenent@2byte.es>
9 * Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
10 * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
11 * Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
12 * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
13 * Copyright (C) 2015-2022 Ferran Marcet <fmarcet@2byte.es>
14 * Copyright (C) 2017 Josep Lluís Amador <joseplluis@lliuretic.cat>
15 * Copyright (C) 2018 Charlene Benke <charlie@patas-monkey.com>
16 * Copyright (C) 2019-2026 Alexandre Spangaro <alexandre@inovea-conseil.com>
17 * Copyright (C) 2021-2024 Anthony Berton <anthony.berton@bb2a.fr>
18 * Copyright (C) 2023 Nick Fragoulis
19 * Copyright (C) 2023 Joachim Kueter <git-jk@bloxera.com>
20 * Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
21 * Copyright (C) 2024-2026 Frédéric France <frederic.france@free.fr>
22 * Copyright (C) 2024 Solution Libre SAS <contact@solution-libre.fr>
23 * Copyright (C) 2024 William Mead <william.mead@manchenumerique.fr>
24 *
25 * This program is free software; you can redistribute it and/or modify
26 * it under the terms of the GNU General Public License as published by
27 * the Free Software Foundation; either version 3 of the License, or
28 * (at your option) any later version.
29 *
30 * This program is distributed in the hope that it will be useful,
31 * but WITHOUT ANY WARRANTY; without even the implied warranty of
32 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33 * GNU General Public License for more details.
34 *
35 * You should have received a copy of the GNU General Public License
36 * along with this program. If not, see <https://www.gnu.org/licenses/>.
37 */
38
45// Load Dolibarr environment
46require '../../main.inc.php';
56require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
57require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
58require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
59require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
60require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmargin.class.php';
61require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
62require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php';
63require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
64require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
65require_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php';
66require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
67require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
68require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
69require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php';
70require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
71if (isModEnabled('order')) {
72 require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
73}
74if (isModEnabled('category')) {
75 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
76 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcategory.class.php';
77}
78
79// Load translation files required by the page
80$langs->loadLangs(array('banks', 'bills', 'companies', 'products', 'categories', 'cashdesk'));
81
82$search_all = trim(GETPOST('search_all', 'alphanohtml'));
83
84// Get Parameters
85$action = GETPOST('action', 'aZ09');
86$massaction = GETPOST('massaction', 'alpha');
87$show_files = GETPOSTINT('show_files');
88$confirm = GETPOST('confirm', 'alpha');
89$toselect = GETPOST('toselect', 'array:int');
90$optioncss = GETPOST('optioncss', 'alpha');
91$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'invoicelist';
92$mode = GETPOST('mode', 'aZ'); // The output mode ('list', 'kanban', 'hierarchy', 'calendar', ...)
93
94if ($contextpage == 'poslist') {
95 $optioncss = 'print';
96}
97
98$id = (GETPOSTINT('id') ? GETPOSTINT('id') : GETPOSTINT('facid')); // For backward compatibility
99$ref = GETPOST('ref', 'alpha');
100$socid = GETPOSTINT('socid');
101
102$userid = GETPOSTINT('userid');
103$search_ref = GETPOST('sf_ref') ? GETPOST('sf_ref', 'alpha') : GETPOST('search_ref', 'alpha');
104$search_refcustomer = GETPOST('search_refcustomer', 'alpha');
105$search_type = GETPOST('search_type', 'intcomma');
106$search_subtype = GETPOST('search_subtype', 'intcomma');
107$search_project_ref = GETPOST('search_project_ref', 'alpha');
108$search_project = GETPOST('search_project', 'alpha');
109$search_company = GETPOST('search_company', 'alpha');
110$search_company_alias = GETPOST('search_company_alias', 'alpha');
111$search_parent_name = trim(GETPOST('search_parent_name', 'alphanohtml'));
112$search_montant_ht = GETPOST('search_montant_ht', 'alpha');
113$search_montant_vat = GETPOST('search_montant_vat', 'alpha');
114$search_montant_localtax1 = GETPOST('search_montant_localtax1', 'alpha');
115$search_montant_localtax2 = GETPOST('search_montant_localtax2', 'alpha');
116$search_montant_ttc = GETPOST('search_montant_ttc', 'alpha');
117$search_login = GETPOST('search_login', 'alpha');
118$search_multicurrency_code = GETPOST('search_multicurrency_code', 'alpha');
119$search_multicurrency_tx = GETPOST('search_multicurrency_tx', 'alpha');
120$search_multicurrency_montant_ht = GETPOST('search_multicurrency_montant_ht', 'alpha');
121$search_multicurrency_montant_vat = GETPOST('search_multicurrency_montant_vat', 'alpha');
122$search_multicurrency_montant_ttc = GETPOST('search_multicurrency_montant_ttc', 'alpha');
123$search_dispute_status = GETPOST('search_dispute_status', 'intcomma');
124$search_status = GETPOST('search_status', 'array:intcomma');
125// if (empty($search_status) && GETPOSTISSET('search_status')) {
126// // The parameter exists in the URL but was not recognized as an array.
127// $search_status = GETPOST('search_status', 'intcomma');
128// if ($search_status !== '' && $search_status !== '-1') {
129// $search_status = array($search_status);
130// } else {
131// $search_status = '';
132// }
133// } elseif (is_array($search_status) && count($search_status) == 0) {
134// $search_status = '';
135// }
136$search_paymentmode = GETPOST('search_paymentmode', 'intcomma');
137$search_paymentterms = GETPOST('search_paymentterms', 'intcomma');
138$search_bankaccount = GETPOST('search_bankaccount', 'intcomma');
139$search_fk_input_reason = GETPOSTINT('search_fk_input_reason');
140$search_module_source = GETPOST('search_module_source', 'alpha');
141$search_pos_source = GETPOST('search_pos_source', 'alpha');
142$search_town = GETPOST('search_town', 'alpha');
143$search_zip = GETPOST('search_zip', 'alpha');
144$search_state = GETPOST("search_state");
145$search_country = GETPOST("search_country", 'aZ09');
146$search_customer_code = GETPOST("search_customer_code", 'alphanohtml');
147$search_type_thirdparty = GETPOST("search_type_thirdparty", 'intcomma');
148$search_user = GETPOST('search_user', 'intcomma');
149$search_sale = GETPOST('search_sale', 'intcomma');
150
151$search_date_startday = GETPOSTINT('search_date_startday');
152$search_date_startmonth = GETPOSTINT('search_date_startmonth');
153$search_date_startyear = GETPOSTINT('search_date_startyear');
154$search_date_endday = GETPOSTINT('search_date_endday');
155$search_date_endmonth = GETPOSTINT('search_date_endmonth');
156$search_date_endyear = GETPOSTINT('search_date_endyear');
157$search_date_start = GETPOSTDATE('search_date_start', 'getpost'); // Use tzserver because date invoice is a date without hour
158$search_date_end = GETPOSTDATE('search_date_end', 'getpostend');
159
160$search_date_valid_startday = GETPOSTINT('search_date_valid_startday');
161$search_date_valid_startmonth = GETPOSTINT('search_date_valid_startmonth');
162$search_date_valid_startyear = GETPOSTINT('search_date_valid_startyear');
163$search_date_valid_endday = GETPOSTINT('search_date_valid_endday');
164$search_date_valid_endmonth = GETPOSTINT('search_date_valid_endmonth');
165$search_date_valid_endyear = GETPOSTINT('search_date_valid_endyear');
166$search_date_valid_start = GETPOSTDATE('search_date_valid_start', 'getpost');
167$search_date_valid_end = GETPOSTDATE('search_date_valid_end', 'getpostend');
168$search_note_private = GETPOST('search_note_private', 'alpha');
169$search_note_public = GETPOST('search_note_public', 'alpha');
170
171$search_datelimit_startday = GETPOSTINT('search_datelimit_startday');
172$search_datelimit_startmonth = GETPOSTINT('search_datelimit_startmonth');
173$search_datelimit_startyear = GETPOSTINT('search_datelimit_startyear');
174$search_datelimit_endday = GETPOSTINT('search_datelimit_endday');
175$search_datelimit_endmonth = GETPOSTINT('search_datelimit_endmonth');
176$search_datelimit_endyear = GETPOSTINT('search_datelimit_endyear');
177$search_datelimit_start = GETPOSTDATE('search_datelimit_start', 'getpost'); // Use tzserver because date invoice is a date without hour
178$search_datelimit_end = GETPOSTDATE('search_datelimit_end', 'getpostend');
179
180
181$search_datec_start = GETPOSTDATE('search_datec_start', 'getpost', 'tzuserrel');
182$search_datec_end = GETPOSTDATE('search_datec_end', 'getpostend', 'tzuserrel');
183$search_datem_start = GETPOSTDATE('search_datem_start', 'getpost', 'tzuserrel');
184$search_datem_end = GETPOSTDATE('search_datem_end', 'getpostend', 'tzuserrel');
185
186$search_categ_cus = GETPOST("search_categ_cus", 'intcomma');
187$searchCategoryInvoiceOperator = 0;
188if (GETPOSTISSET('formfilteraction')) {
189 $searchCategoryInvoiceOperator = GETPOSTINT('search_category_invoice_operator');
190} elseif (getDolGlobalString('MAIN_SEARCH_CAT_OR_BY_DEFAULT')) {
191 $searchCategoryInvoiceOperator = getDolGlobalString('MAIN_SEARCH_CAT_OR_BY_DEFAULT');
192}
193$searchCategoryInvoiceList = GETPOST('search_category_invoice_list', 'array:int');
194// to dump type seen by phpstan during analyse
195// \PHPStan\dumpType($searchCategoryInvoiceList);
196$search_product_category = GETPOST('search_product_category', 'intcomma');
197$search_fac_rec_source_title = GETPOST("search_fac_rec_source_title", 'alpha');
198$search_fk_fac_rec_source = GETPOST('search_fk_fac_rec_source', 'int');
199$search_import_key = trim(GETPOST("search_import_key", "alpha"));
200
201$search_option = GETPOST('search_option');
202if ($search_option == 'late') {
203 $search_status = array('1');
204}
205
206$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
207$sortfield = GETPOST('sortfield', 'aZ09comma');
208$sortorder = GETPOST('sortorder', 'aZ09comma');
209$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
210if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
211 // If $page is not defined, or '' or -1 or if we click on clear filters
212 $page = 0;
213}
214
215if ($contextpage == 'poslist' && !GETPOSTISSET('limit')) {
216 $limit = 5;
217}
218
219$offset = $limit * $page;
220if (!$sortorder && getDolGlobalString('INVOICE_DEFAULT_UNPAYED_SORT_ORDER') && $search_status == '1') {
221 $sortorder = getDolGlobalString('INVOICE_DEFAULT_UNPAYED_SORT_ORDER');
222}
223if (!$sortorder) {
224 $sortorder = 'DESC';
225}
226if (!$sortfield) {
227 $sortfield = 'f.datef,f.rowid';
228}
229$pageprev = $page - 1;
230$pagenext = $page + 1;
231
232$diroutputmassaction = $conf->invoice->dir_output.'/temp/massgeneration/'.$user->id;
233
234$now = dol_now();
235$error = 0;
236$sql = '';
237
238// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
239$object = new Facture($db);
240$hookmanager->initHooks(array($contextpage));
241
242// Fetch optionals attributes and labels
243$extrafields->fetch_name_optionals_label($object->table_element);
244
245$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_') ?: [];
246
247// List of fields to search into when doing a "search in all"
248$fieldstosearchall = array(
249 'f.ref' => 'Ref',
250 'f.ref_client' => 'RefCustomer',
251 'f.note_public' => 'NotePublic',
252 's.nom' => "ThirdParty",
253 's.code_client' => "CustomerCodeShort",
254 's.name_alias' => "AliasNameShort",
255 's.zip' => "Zip",
256 's.town' => "Town",
257 'pd.description' => 'ProductDescription',
258);
259if (empty($user->socid)) {
260 $fieldstosearchall["f.note_private"] = "NotePrivate";
261}
262
263// Show POS fields if cashdesk or takepos module enabled or if global configuration to show POS fields on order list is enabled
264$showpos = (isModEnabled('cashdesk') || isModEnabled('takepos') || getDolGlobalInt('INVOICE_SHOW_POS')) ? '1' : '0';
265
266$checkedtypetiers = '0';
267$arrayfields = array(
268 'f.ref' => array('label' => "Ref", 'checked' => '1', 'position' => 5),
269 'f.ref_client' => array('label' => "RefCustomer", 'checked' => '-1', 'position' => 10),
270 'f.type' => array('label' => "Type", 'checked' => '0', 'position' => 15),
271 'f.subtype' => array('label' => "InvoiceSubtype", 'checked' => '0', 'position' => 17),
272 'f.datef' => array('label' => "DateInvoice", 'checked' => '1', 'position' => 20),
273 'f.date_valid' => array('label' => "DateValidation", 'checked' => '0', 'position' => 22),
274 'f.date_lim_reglement' => array('label' => "DateDue", 'checked' => '1', 'position' => 25),
275 'f.date_closing' => array('label' => "DateClosing", 'checked' => '0', 'position' => 30),
276 'p.ref' => array('label' => "ProjectRef", 'langfile' => 'projects', 'checked' => '1', 'enabled' => (isModEnabled('project') ? '1' : '0'), 'position' => 40),
277 'p.title' => array('label' => "ProjectLabel", 'langfile' => 'projects', 'checked' => '0', 'enabled' => (isModEnabled('project') ? '1' : '0'), 'position' => 41),
278 's.nom' => array('label' => "ThirdParty", 'checked' => '1', 'position' => 50),
279 's.name_alias' => array('label' => "AliasNameShort", 'checked' => '-1', 'position' => 51),
280 's.code_client' => array('label' => "CustomerCodeShort", 'checked' => '-1', 'position' => 52),
281 's2.nom' => array('label' => 'ParentCompany', 'position' => 32, 'checked' => '0'),
282 's.town' => array('label' => "Town", 'checked' => '-1', 'position' => 55),
283 's.zip' => array('label' => "Zip", 'checked' => '-1', 'position' => 60),
284 'state.nom' => array('label' => "StateShort", 'checked' => '0', 'position' => 65),
285 'country.code_iso' => array('label' => "Country", 'checked' => '0', 'position' => 70),
286 'typent.code' => array('label' => "ThirdPartyType", 'checked' => $checkedtypetiers, 'position' => 75),
287 'f.fk_mode_reglement' => array('label' => "PaymentMode", 'checked' => '1', 'position' => 80),
288 'f.fk_cond_reglement' => array('label' => "PaymentConditionsShort", 'checked' => '0', 'position' => 85),
289 'ba.label' => array('label' => "DefaultBankAccount", 'langfile' => 'banks', 'checked' => '0', 'enabled' => (isModEnabled('bank') ? '1' : '0'), 'position' => 192),
290 'f.fk_input_reason' => array('label' => "Source", 'checked' => 0, 'enabled' => 1, 'position' => 88),
291 'f.module_source' => array('label' => "POSModule", 'langfile' => 'cashdesk', 'checked' => ($contextpage == 'poslist' ? '1' : '0'), 'enabled' => $showpos, 'position' => 90),
292 'f.pos_source' => array('label' => "POSTerminal", 'langfile' => 'cashdesk', 'checked' => ($contextpage == 'poslist' ? '1' : '0'), 'enabled' => $showpos, 'position' => 91),
293 'f.total_ht' => array('label' => "AmountHT", 'checked' => '1', 'position' => 95),
294 'f.total_tva' => array('label' => "AmountVAT", 'checked' => '0', 'position' => 100),
295 'f.total_localtax1' => array('label' => $langs->transcountry("AmountLT1", $mysoc->country_code), 'checked' => '0', 'enabled' => ($mysoc->localtax1_assuj == "1"), 'position' => 110),
296 'f.total_localtax2' => array('label' => $langs->transcountry("AmountLT2", $mysoc->country_code), 'checked' => '0', 'enabled' => ($mysoc->localtax2_assuj == "1"), 'position' => 120),
297 'f.total_ttc' => array('label' => "AmountTTC", 'checked' => '0', 'position' => 130),
298 'dynamount_payed' => array('label' => "AlreadyPaid", 'checked' => '0', 'position' => 140),
299 'rtp' => array('label' => "RemainderToPay", 'checked' => '0', 'position' => 150), // Not enabled by default because slow
300 'f.multicurrency_code' => array('label' => 'Currency', 'checked' => '0', 'enabled' => (!isModEnabled('multicurrency') ? '0' : '1'), 'position' => 280),
301 'f.multicurrency_tx' => array('label' => 'CurrencyRate', 'checked' => '0', 'enabled' => (!isModEnabled('multicurrency') ? '0' : '1'), 'position' => 285),
302 'f.multicurrency_total_ht' => array('label' => 'MulticurrencyAmountHT', 'checked' => '0', 'enabled' => (!isModEnabled('multicurrency') ? '0' : '1'), 'position' => 290),
303 'f.multicurrency_total_vat' => array('label' => 'MulticurrencyAmountVAT', 'checked' => '0', 'enabled' => (!isModEnabled('multicurrency') ? '0' : '1'), 'position' => 291),
304 'f.multicurrency_total_ttc' => array('label' => 'MulticurrencyAmountTTC', 'checked' => '0', 'enabled' => (!isModEnabled('multicurrency') ? '0' : '1'), 'position' => 292),
305 'multicurrency_dynamount_payed' => array('label' => 'MulticurrencyAlreadyPaid', 'checked' => '0', 'enabled' => (!isModEnabled('multicurrency') ? '0' : '1'), 'position' => 295),
306 'multicurrency_rtp' => array('label' => 'MulticurrencyRemainderToPay', 'checked' => '0', 'enabled' => (!isModEnabled('multicurrency') ? '0' : '1'), 'position' => 296), // Not enabled by default because slow
307 'total_pa' => array('label' => ((getDolGlobalString('MARGIN_TYPE') == '1') ? 'BuyingPrice' : 'CostPrice'), 'checked' => '0', 'position' => 300, 'enabled' => (!isModEnabled('margin') || !$user->hasRight('margins', 'liretous') ? '0' : '1')),
308 'total_margin' => array('label' => 'Margin', 'langfile' => 'margins', 'checked' => '0', 'position' => 301, 'enabled' => (!isModEnabled('margin') || !$user->hasRight('margins', 'liretous') ? '0' : '1')),
309 'total_margin_rate' => array('label' => 'MarginRate', 'langfile' => 'margins', 'checked' => '0', 'position' => 302, 'enabled' => (!isModEnabled('margin') || !$user->hasRight('margins', 'liretous') || !getDolGlobalString('DISPLAY_MARGIN_RATES') ? '0' : '1')),
310 'total_mark_rate' => array('label' => 'MarkRate', 'langfile' => 'margins', 'checked' => '0', 'position' => 303, 'enabled' => (!isModEnabled('margin') || !$user->hasRight('margins', 'liretous') || !getDolGlobalString('DISPLAY_MARK_RATES') ? '0' : '1')),
311 'f.datec' => array('label' => "DateCreation", 'checked' => '0', 'position' => 500),
312 'f.tms' => array('type' => 'timestamp', 'label' => 'DateModificationShort', 'enabled' => '1', 'visible' => -1, 'notnull' => 1, 'position' => 502),
313 'u.login' => array('label' => "UserAuthor", 'checked' => '0', 'visible' => -1, 'position' => 504),
314 'sale_representative' => array('label' => "SaleRepresentativesOfThirdParty", 'checked' => '0', 'position' => 506),
315 //'f.fk_user_author' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-1, 'position'=>506),
316 //'f.fk_user_modif' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-1, 'notnull'=>-1, 'position'=>508),
317 //'f.fk_user_valid' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>510),
318 //'f.fk_user_closing' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserClosing', 'enabled'=>1, 'visible'=>-1, 'position'=>512),
319 'f.note_public' => array('label' => 'NotePublic', 'checked' => '0', 'position' => 520, 'enabled' => (!getDolGlobalInt('MAIN_LIST_HIDE_PUBLIC_NOTES'))),
320 'f.note_private' => array('label' => 'NotePrivate', 'checked' => '0', 'position' => 521, 'enabled' => (!getDolGlobalInt('MAIN_LIST_HIDE_PRIVATE_NOTES'))),
321 'f.fk_fac_rec_source' => array('label' => 'GeneratedFromTemplate', 'checked' => '0', 'position' => 530, 'enabled' => '1'),
322 'f.import_key' => array('type' => 'varchar(14)', 'label' => 'ImportId', 'enabled' => '1', 'visible' => -2, 'position' => 990),
323 'f.dispute_status' => array('label' => "DisputeStatus", 'checked' => '-1', 'position' => 999),
324 'f.fk_statut' => array('label' => "Status", 'checked' => '1', 'position' => 1000),
325);
326if ($user->socid) {
327 unset($arrayfields['f.note_private']);
328}
329if (getDolGlobalString("INVOICE_USE_SITUATION") && getDolGlobalString('INVOICE_USE_RETAINED_WARRANTY')) {
330 $arrayfields['f.retained_warranty'] = array('label' => $langs->trans("RetainedWarranty"), 'checked' => '0', 'position' => 86);
331}
332
333$subtypearray = $object->getArrayOfInvoiceSubtypes(0);
334if (empty($subtypearray)) {
335 unset($arrayfields['f.subtype']);
336}
337
338// Overwrite $arrayfields from columns into ->fields (transition before removal of $arrayoffields)
339foreach ($object->fields as $key => $val) {
340 // If $val['visible']==0, then we never show the field
341
342 if (!empty($val['visible'])) {
343 $visible = (int) dol_eval((string) $val['visible'], 1, 1, '1');
344 $newkey = '';
345 if (array_key_exists($key, $arrayfields)) {
346 $newkey = $key;
347 } elseif (array_key_exists('f.'.$key, $arrayfields)) {
348 $newkey = 'f.'.$key;
349 } elseif (array_key_exists('s.'.$key, $arrayfields)) {
350 $newkey = 's.'.$key;
351 }
352 if ($newkey) {
353 $arrayfields[$newkey] = array(
354 'label' => $val['label'],
355 'checked' => (($visible < 0) ? '0' : '1'),
356 'enabled' => (string) (int) (abs($visible) != 3 && (bool) dol_eval((string) $val['enabled'], 1)),
357 'position' => $val['position'],
358 'help' => empty($val['help']) ? '' : $val['help'],
359 );
360 }
361 }
362}
363// Extra fields
364include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
365// Add hook to complete $arrayfield
366$parameters = array('arrayfields' => &$arrayfields);
367$reshook = $hookmanager->executeHooks('completeArrayFields', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
368
369// For POS context, we force some fields
370if ($contextpage == 'poslist') {
371 $arrayfields["f.module_source"]['checked'] = 1;
372 $arrayfields["f.pos_source"]['checked'] = 1;
373 $arrayfields["f.date_lim_reglement"]['checked'] = 0;
374 $arrayfields["f.total_ttc"]['checked'] = 1;
375 $arrayfields["f.tms"]['checked'] = 1;
376 $arrayfields["p.ref"]['checked'] = 0;
377}
378
379$object->fields = dol_sort_array($object->fields, 'position');
380$arrayfields = dol_sort_array($arrayfields, 'position');
381
382
383// Check only if it's an internal user, external users are already filtered by $socid
384if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) {
385 $search_sale = $user->id;
386}
387
388// Security check
389$fieldid = (!empty($ref) ? 'ref' : 'rowid');
390if (!empty($user->socid)) {
391 $socid = $user->socid;
392}
393if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) {
394 $search_sale = $user->id;
395}
396
397$result = restrictedArea($user, 'facture', $id, '', '', 'fk_soc', $fieldid);
398
399
400/*
401 * Actions
402 */
403
404if (GETPOST('cancel', 'alpha')) {
405 $action = 'list';
406 $massaction = '';
407}
408if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
409 $massaction = '';
410}
411
412
413$parameters = array('socid' => $socid, 'arrayfields' => &$arrayfields);
414$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
415if ($reshook < 0) {
416 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
417}
418
419
420include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
421
422// Do we click on purge search criteria ?
423if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha') || GETPOST('button_removefilter.x', 'alpha')) { // All tests are required to be compatible with all browsers
424 $search_user = '';
425 $search_sale = '';
426 $search_product_category = '';
427 $searchCategoryInvoiceList = array();
428 $search_ref = '';
429 $search_refcustomer = '';
430 $search_type = '';
431 $search_subtype = '';
432 $search_project_ref = '';
433 $search_project = '';
434 $search_company = '';
435 $search_company_alias = '';
436 $search_parent_name = '';
437 $search_montant_ht = '';
438 $search_montant_vat = '';
439 $search_montant_localtax1 = '';
440 $search_montant_localtax2 = '';
441 $search_montant_ttc = '';
442 $search_login = '';
443 $search_multicurrency_code = '';
444 $search_multicurrency_tx = '';
445 $search_multicurrency_montant_ht = '';
446 $search_multicurrency_montant_vat = '';
447 $search_multicurrency_montant_ttc = '';
448 $search_dispute_status = '';
449 $search_status = [];
450 $search_paymentmode = '';
451 $search_paymentterms = '';
452 $search_bankaccount = '';
453 $search_fk_input_reason = '';
454 $search_module_source = '';
455 $search_pos_source = '';
456 $search_town = '';
457 $search_zip = "";
458 $search_state = "";
459 $search_country = '';
460 $search_type_thirdparty = '';
461 $search_customer_code = '';
462 $search_date_startday = '';
463 $search_date_startmonth = '';
464 $search_date_startyear = '';
465 $search_date_endday = '';
466 $search_date_endmonth = '';
467 $search_date_endyear = '';
468 $search_date_start = '';
469 $search_date_end = '';
470 $search_date_valid_startday = '';
471 $search_date_valid_startmonth = '';
472 $search_date_valid_startyear = '';
473 $search_date_valid_endday = '';
474 $search_date_valid_endmonth = '';
475 $search_date_valid_endyear = '';
476 $search_date_valid_start = '';
477 $search_date_valid_end = '';
478 $search_datelimit_startday = '';
479 $search_datelimit_startmonth = '';
480 $search_datelimit_startyear = '';
481 $search_datelimit_endday = '';
482 $search_datelimit_endmonth = '';
483 $search_datelimit_endyear = '';
484 $search_datelimit_start = '';
485 $search_datelimit_end = '';
486
487 $search_datec_start = '';
488 $search_datec_end = '';
489
490 $search_datem_start = '';
491 $search_datem_end = '';
492
493 $search_fac_rec_source_title = '';
494 $search_option = '';
495 $search_import_key = '';
496 $search_categ_cus = 0;
497
498 $search_all = '';
499 $toselect = array();
500 $search_array_options = array();
501}
502
503if (empty($reshook)) {
504 $objectclass = 'Facture';
505 $objectlabel = 'Invoices';
506 $permissiontoread = $user->hasRight("facture", "lire");
507 $permissiontoadd = $user->hasRight("facture", "creer");
508 $permissiontodelete = $user->hasRight("facture", "supprimer");
509 $uploaddir = $conf->invoice->dir_output;
510 include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
511}
512
513if ($action == 'makepayment_confirm' && $user->hasRight('facture', 'paiement')) {
514 require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
515 $arrayofselected = is_array($toselect) ? $toselect : array();
516 if (!empty($arrayofselected)) {
517 $bankid = GETPOSTINT('bankid');
518 $paiementid = GETPOSTINT('paiementid');
519 $note_private = GETPOST('note_private', 'restricthtml');
520 $paiementdate = dol_mktime(12, 0, 0, GETPOSTINT('datepaimentmonth'), GETPOSTINT('datepaimentday'), GETPOSTINT('datepaimentyear'));
521 if (empty($paiementdate)) {
522 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors');
523 $error++;
524 $action = 'makepayment';
525 }
526
527 if (!$error) {
528 foreach ($arrayofselected as $toselectid) {
529 $errorpayment = 0;
530 $facture = new Facture($db);
531 $result = $facture->fetch($toselectid);
532
533 $db->begin();
534
535 if ($result < 0) {
536 setEventMessage($facture->error, 'errors');
537 $errorpayment++;
538 } else {
539 if ($facture->type != Facture::TYPE_CREDIT_NOTE && $facture->status == Facture::STATUS_VALIDATED && $facture->paye == 0) {
540 // Get both the base-currency and invoice-currency paid amount in a single query
541 $sommePaiement = $facture->getSommePaiement(-1);
542 $paiementAmount = $sommePaiement['alreadypaid'];
543
544 $totalcreditnotes = $facture->getSumCreditNotesUsed();
545 $totaldeposits = $facture->getSumDepositsUsed();
546
547 $totalallpayments = $paiementAmount + $totalcreditnotes + $totaldeposits;
548 $remaintopay = (float) price2num($facture->total_ttc - $totalallpayments);
549
550 // hook to finalize the remaining amount, considering e.g. cash discount agreements
551 $parameters = array('remaintopay' => $remaintopay);
552 $reshook = $hookmanager->executeHooks('finalizeAmountOfInvoice', $parameters, $facture, $action); // Note that $action and $object may have been modified by some hooks
553 if ($reshook > 0) {
554 if (!empty($remain = (float) $hookmanager->resArray['remaintopay'])) {
555 $remaintopay = $remain;
556 }
557 } elseif ($reshook < 0) {
558 $error++;
559 setEventMessages($facture->ref.' '.$langs->trans("ProcessingError"), $hookmanager->errors, 'errors');
560 }
561
562 // Remain to pay in the invoice currency (may differ from $remaintopay when multicurrency is used)
563 $multicurrency_remaintopay = (float) price2num($facture->multicurrency_total_ttc - $sommePaiement['alreadypaid_multicurrency']);
564
565 if ($remaintopay != 0) {
566 $resultBank = $facture->setBankAccount($bankid);
567 if ($resultBank < 0) {
568 setEventMessages($facture->error, null, 'errors');
569 $errorpayment++;
570 } else {
571 $paiement = new Paiement($db);
572 $paiement->datepaye = $paiementdate;
573 $paiement->amounts[$facture->id] = $remaintopay; // Array with all payments dispatching with invoice id
574 $paiement->multicurrency_amounts[$facture->id] = (float) $multicurrency_remaintopay;
575 $paiement->paiementid = $paiementid;
576 $paiement->note_private = $note_private;
577 $paiement_id = $paiement->create($user, 1, $facture->thirdparty);
578 if ($paiement_id < 0) {
579 $langs->load("errors");
580 setEventMessages($facture->ref.' '.$langs->trans($paiement->error), $paiement->errors, 'errors');
581 $errorpayment++;
582 } else {
583 $result = $paiement->addPaymentToBank($user, 'payment', '', $bankid, '', '');
584 if ($result < 0) {
585 $langs->load("errors");
586 setEventMessages($facture->ref.' '.$langs->trans($paiement->error), $paiement->errors, 'errors');
587 $errorpayment++;
588 }
589 }
590 }
591 } else {
592 setEventMessage($langs->trans('NoPaymentAvailable', $facture->ref), 'warnings');
593 $errorpayment++;
594 }
595 } else {
596 setEventMessage($langs->trans('BulkPaymentNotPossibleForInvoice', $facture->ref), 'warnings');
597 $errorpayment++;
598 }
599 }
600
601 if (empty($errorpayment)) {
602 setEventMessage($langs->trans('PaymentRegisteredAndInvoiceSetToPaid', $facture->ref));
603 $db->commit();
604 } else {
605 $db->rollback();
606 }
607 }
608 }
609 }
610} elseif ($massaction == 'withdrawrequest') {
611 $langs->load("withdrawals");
612
613 if (!$user->hasRight('prelevement', 'bons', 'creer')) {
614 $error++;
615 setEventMessages($langs->trans("NotEnoughPermissions"), null, 'errors');
616 } else {
617 //Checking error
618 $error = 0;
619
620 $arrayofselected = is_array($toselect) ? $toselect : array();
621 $listofbills = array();
622 foreach ($arrayofselected as $toselectid) {
623 $objecttmp = new Facture($db);
624 $result = $objecttmp->fetch($toselectid);
625 if ($result > 0) {
626 $totalpaid = $objecttmp->getSommePaiement();
627 $totalcreditnotes = $objecttmp->getSumCreditNotesUsed();
628 $totaldeposits = $objecttmp->getSumDepositsUsed();
629 $objecttmp->resteapayer = price2num($objecttmp->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits, 'MT');
630
631 // hook to finalize the remaining amount, considering e.g. cash discount agreements
632 $parameters = array('remaintopay' => $objecttmp->resteapayer);
633 $reshook = $hookmanager->executeHooks('finalizeAmountOfInvoice', $parameters, $objecttmp, $action); // Note that $action and $object may have been modified by some hooks
634 if ($reshook > 0) {
635 if (!empty($remaintopay = $hookmanager->resArray['remaintopay'])) {
636 $objecttmp->resteapayer = $remaintopay;
637 }
638 } elseif ($reshook < 0) {
639 $error++;
640 setEventMessages($objecttmp->ref.' '.$langs->trans("ProcessingError"), $hookmanager->errors, 'errors');
641 }
642
643 if ($objecttmp->statut == Facture::STATUS_DRAFT) {
644 $error++;
645 setEventMessages($objecttmp->ref.' '.$langs->trans("Draft"), $objecttmp->errors, 'errors');
646 } elseif ($objecttmp->paye || $objecttmp->resteapayer == 0) {
647 $error++;
648 setEventMessages($objecttmp->ref.' '.$langs->trans("AlreadyPaid"), $objecttmp->errors, 'errors');
649 } elseif ($objecttmp->resteapayer < 0) {
650 $error++;
651 setEventMessages($objecttmp->ref.' '.$langs->trans("AmountMustBePositive"), $objecttmp->errors, 'errors');
652 }
653
654 $rsql = "SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande";
655 $rsql .= " , pfd.date_traite as date_traite";
656 $rsql .= " , pfd.amount";
657 $rsql .= " , u.rowid as user_id, u.lastname, u.firstname, u.login";
658 $rsql .= " FROM ".MAIN_DB_PREFIX."prelevement_demande as pfd";
659 $rsql .= " , ".MAIN_DB_PREFIX."user as u";
660 $rsql .= " WHERE fk_facture = ".((int) $objecttmp->id);
661 $rsql .= " AND pfd.fk_user_demande = u.rowid";
662 $rsql .= " AND pfd.traite = 0";
663 $rsql .= " ORDER BY pfd.date_demande DESC";
664
665 $numprlv = 0;
666 $result_sql = $db->query($rsql);
667 if ($result_sql) {
668 $numprlv = $db->num_rows($result_sql);
669 }
670
671 if ($numprlv > 0) {
672 $error++;
673 setEventMessages($objecttmp->ref.' '.$langs->trans("RequestAlreadyDone"), $objecttmp->errors, 'warnings');
674 } elseif (!empty($objecttmp->mode_reglement_code) && $objecttmp->mode_reglement_code != 'PRE') {
675 $langs->load("errors");
676 $error++;
677 setEventMessages($objecttmp->ref.' '.$langs->trans("ErrorThisPaymentModeIsNotDirectDebit"), $objecttmp->errors, 'errors');
678 } else {
679 $listofbills[] = $objecttmp; // $listofbills will only contains invoices with good payment method and no request already done
680 }
681 }
682 }
683
684 //Massive withdraw request for request with no errors
685 if (!empty($listofbills)) {
686 $nbwithdrawrequestok = 0;
687 foreach ($listofbills as $aBill) {
688 // Note: The 2 following SQL requests are wrong but it works because we have one record into pfd for one record into pl and for into p for the same fk_facture_fourn.
689 // The table prelevement and prelevement_lignes must be removed in future and merged into prelevement_demande
690 // Step 1: Move field fk_... of llx_prelevement into llx_prelevement_lignes
691 // Step 2: Move field fk_... + status into prelevement_demande.
692 $pending = 0;
693 // Get pending requests open with no transfer receipt yet
694 $sql = "SELECT SUM(pfd.amount) as amount";
695 $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_demande as pfd";
696 //if ($type == 'bank-transfer') {
697 //$sql .= " WHERE pfd.fk_facture_fourn = ".((int) $aBill->id);
698 //} else {
699 $sql .= " WHERE pfd.fk_facture = ".((int) $aBill->id);
700 //}
701 $sql .= " AND pfd.traite = 0";
702 //$sql .= " AND pfd.type = 'ban'";
703 $resql = $db->query($sql);
704 if ($resql) {
705 $obj = $db->fetch_object($resql);
706 if ($obj) {
707 $pending += (float) $obj->amount;
708 }
709 } else {
711 }
712 // Get pending request with a transfer receipt generated but not yet processed
713 $sqlPending = "SELECT SUM(pl.amount) as amount";
714 $sqlPending .= " FROM ".$db->prefix()."prelevement_lignes as pl";
715 $sqlPending .= " INNER JOIN ".$db->prefix()."prelevement as p ON p.fk_prelevement_lignes = pl.rowid";
716 //if ($type == 'bank-transfer') {
717 //$sqlPending .= " WHERE p.fk_facture_fourn = ".((int) $aBill->id);
718 //} else {
719 $sqlPending .= " WHERE p.fk_facture = ".((int) $aBill->id);
720 //}
721 $sqlPending .= " AND (pl.statut IS NULL OR pl.statut = 0)";
722 $resPending = $db->query($sqlPending);
723 if ($resPending) {
724 if ($objPending = $db->fetch_object($resPending)) {
725 $pending += (float) $objPending->amount;
726 }
727 }
728 $db->free($resPending);
729
730 $requestAmount = $aBill->resteapayer - $pending;
731
732 $db->begin();
733 $result = $aBill->demande_prelevement($user, $requestAmount, 'direct-debit', 'facture');
734 if ($requestAmount > 0) {
735 if ($result > 0) {
736 $db->commit();
737 $nbwithdrawrequestok++;
738 } else {
739 $db->rollback();
740 setEventMessages($aBill->error, $aBill->errors, 'errors');
741 }
742 } else {
743 $aBill->error = 'WithdrawRequestErrorNilAmount';
744 $aBill->errors[] = $aBill->error;
745 setEventMessages($aBill->error, $aBill->errors, 'errors');
746 }
747 }
748 if ($nbwithdrawrequestok > 0) {
749 setEventMessages($langs->trans("WithdrawRequestsDone", $nbwithdrawrequestok), null, 'mesgs');
750 }
751 }
752 }
753}
754
755
756
757/*
758 * View
759 */
760
761$form = new Form($db);
762$formother = new FormOther($db);
763$formfile = new FormFile($db);
764$formmargin = new FormMargin($db);
765$facturestatic = new Facture($db);
766$accountstatic = new Account($db);
767$formcompany = new FormCompany($db);
768$companystatic = new Societe($db);
769$companyparent = new Societe($db);
770
771$company_url_list = array();
772
773if ($socid > 0) {
774 $soc = new Societe($db);
775 $soc->fetch($socid);
776 if (empty($search_company)) {
777 $search_company = $soc->name;
778 }
779} else {
780 $soc = null;
781}
782
783$title = $langs->trans('BillsCustomers').' '.(($socid > 0 && $soc !== null) ? ' - '.$soc->name : '');
784$help_url = 'EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes';
785
786$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
787$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
788
789// Build and execute select
790// --------------------------------------------------------------------
791$sql = 'SELECT';
792$sql .= ' f.rowid as id, f.ref, f.ref_client, f.fk_soc, f.type, f.subtype, f.note_private, f.note_public, f.increment, f.fk_mode_reglement, f.fk_cond_reglement, ba.rowid as bid, ba.ref as bref, ba.label as blabel, ba.number as bnumber, ba.account_number as baccount_number, ba.fk_accountancy_journal as baccountancy_journal, f.total_ht, f.total_tva, f.total_ttc,';
793$sql .= ' f.localtax1 as total_localtax1, f.localtax2 as total_localtax2,';
794$sql .= ' f.fk_user_author,';
795$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,';
796$sql .= ' f.datef, f.date_valid, f.date_lim_reglement as datelimite,';
797$sql .= " f.fk_input_reason,";
798$sql .= " f.module_source, f.pos_source,";
799$sql .= ' f.paye as paye, f.fk_statut as status, f.import_key, f.close_code,';
800$sql .= ' f.datec as date_creation, f.tms as date_modification, f.date_closing as date_closing,';
801$sql .= ' f.retained_warranty, f.retained_warranty_date_limit, f.situation_final, f.situation_cycle_ref, f.situation_counter,';
802$sql .= ' f.payment_reference, f.dispute_status,';
803$sql .= ' s.rowid as socid, s.nom as name, s.name_alias as alias, s.email, s.phone, s.fax, s.address, 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,';
804$sql .= " s.parent as fk_parent,";
805$sql .= " s2.nom as name2,";
806$sql .= ' typent.code as typent_code,';
807$sql .= ' state.code_departement as state_code, state.nom as state_name,';
808$sql .= ' country.code as country_code,';
809$sql .= ' f.fk_fac_rec_source,';
810$sql .= ' p.rowid as project_id, p.ref as project_ref, p.title as project_label,';
811$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';
812// 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).
813// A Better solution to be able to sort on already paid or remain to pay is to store amount_payed in a denormalized field.
814// We disable this. It create a bug when searching with search_all and sorting on status. Also it create performance troubles.
815/*
816if (!$search_all) {
817 $sql .= ', SUM(pf.amount) as dynamount_payed, SUM(pf.multicurrency_amount) as multicurrency_dynamount_payed';
818}
819*/
820// Add fields from extrafields
821if (!empty($extrafields->attributes[$object->table_element]['label'])) {
822 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
823 $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
824 }
825}
826// Add fields from hooks
827$parameters = array();
828$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
829$sql .= $hookmanager->resPrint;
830$sql = preg_replace('/,\s*$/', '', $sql);
831
832$sqlfields = $sql; // $sql fields to remove for count total
833
834$sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s';
835$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s2 ON s2.rowid = s.parent";
836$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)";
837$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)";
838$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)";
839$sql .= ', '.MAIN_DB_PREFIX.'facture as f';
840// Add a special index hint if we sort on datef. But only if there is not search filter set to avoid bad query plan
841if ($sortfield == "f.datef") {
842 $hasAnotherfilter = false;
843 foreach ($search_array_options as $v) {
844 if ($v !== '' && (string) $v !== '-1') {
845 $hasAnotherfilter = true;
846 break;
847 }
848 }
849 if (!$hasAnotherfilter) {
850 $sql .= $db->hintindex('idx_facture_datef');
851 }
852}
853if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
854 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (f.rowid = ef.fk_object)";
855}
856if (!empty($search_fac_rec_source_title)) {
857 $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_rec as facrec ON f.fk_fac_rec_source = facrec.rowid';
858}
859$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = f.fk_projet";
860$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user AS u ON f.fk_user_author = u.rowid';
861$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON ba.rowid = f.fk_account';
862// Add table from hooks
863$parameters = array();
864$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
865$sql .= $hookmanager->resPrint;
866
867$sql .= ' WHERE f.fk_soc = s.rowid';
868$sql .= ' AND f.entity IN ('.getEntity('invoice').')';
869if ($socid > 0) {
870 $sql .= ' AND s.rowid = '.((int) $socid);
871}
872if ($userid) {
873 if ($userid == -1) {
874 $sql .= ' AND f.fk_user_author IS NULL';
875 } else {
876 $sql .= ' AND f.fk_user_author = '.((int) $userid);
877 }
878}
879if ($search_ref) {
880 $sql .= natural_search('f.ref', $search_ref);
881}
882if ($search_refcustomer) {
883 $sql .= natural_search('f.ref_client', $search_refcustomer);
884}
885if ($search_type != '' && $search_type != '-1') {
886 $sql .= " AND f.type IN (".$db->sanitize($db->escape($search_type)).")";
887}
888if ($search_subtype != '' && $search_subtype != '-1') {
889 $sql .= " AND f.subtype IN (".$db->sanitize($db->escape($search_subtype)).")";
890}
891if ($search_project_ref) {
892 $sql .= natural_search('p.ref', $search_project_ref);
893}
894if ($search_project) {
895 $sql .= natural_search('p.title', $search_project);
896}
897if (empty($arrayfields['s.name_alias']['checked']) && $search_company) {
898 $sql .= natural_search(array("s.nom", "s.name_alias"), $search_company);
899} else {
900 if ($search_company) {
901 $sql .= natural_search('s.nom', $search_company);
902 }
903 if ($search_company_alias) {
904 $sql .= natural_search('s.name_alias', $search_company_alias);
905 }
906}
907if ($search_parent_name) {
908 $sql .= natural_search('s2.nom', $search_parent_name);
909}
910if ($search_customer_code) {
911 $sql .= natural_search('s.code_client', $search_customer_code);
912}
913if ($search_town) {
914 $sql .= natural_search('s.town', $search_town);
915}
916if ($search_zip) {
917 $sql .= natural_search("s.zip", $search_zip);
918}
919if ($search_state) {
920 $sql .= natural_search("state.nom", $search_state);
921}
922if (strlen(trim($search_country))) {
923 $arrayofcode = getCountriesInEEC();
924 $country_code_in_EEC = $country_code_in_EEC_without_me = '';
925 foreach ($arrayofcode as $key => $value) {
926 $country_code_in_EEC .= ($country_code_in_EEC ? "," : "")."'".$value."'";
927 if ($value != $mysoc->country_code) {
928 $country_code_in_EEC_without_me .= ($country_code_in_EEC_without_me ? "," : "")."'".$value."'";
929 }
930 }
931 if ($search_country == 'special_allnotme') {
932 $sql .= " AND country.code <> '".$db->escape($mysoc->country_code)."'";
933 } elseif ($search_country == 'special_eec') {
934 $sql .= " AND country.code IN (".$db->sanitize($country_code_in_EEC, 1).")";
935 } elseif ($search_country == 'special_eecnotme') {
936 $sql .= " AND country.code IN (".$db->sanitize($country_code_in_EEC_without_me, 1).")";
937 } elseif ($search_country == 'special_noteec') {
938 $sql .= " AND country.code NOT IN (".$db->sanitize($country_code_in_EEC, 1).")";
939 } else {
940 $sql .= natural_search("country.code", $search_country);
941 }
942}
943if ($search_type_thirdparty != '' && $search_type_thirdparty != '-1') {
944 $sql .= " AND s.fk_typent IN (".$db->sanitize($db->escape($search_type_thirdparty)).')';
945}
946if ($search_montant_ht != '') {
947 $sql .= natural_search('f.total_ht', $search_montant_ht, 1);
948}
949if ($search_montant_vat != '') {
950 $sql .= natural_search('f.total_tva', $search_montant_vat, 1);
951}
952if ($search_montant_localtax1 != '') {
953 $sql .= natural_search('f.localtax1', $search_montant_localtax1, 1);
954}
955if ($search_montant_localtax2 != '') {
956 $sql .= natural_search('f.localtax2', $search_montant_localtax2, 1);
957}
958if ($search_montant_ttc != '') {
959 $sql .= natural_search('f.total_ttc', $search_montant_ttc, 1);
960}
961if ($search_multicurrency_code != '') {
962 $sql .= " AND f.multicurrency_code = '".$db->escape($search_multicurrency_code)."'";
963}
964if ($search_multicurrency_tx != '') {
965 $sql .= natural_search('f.multicurrency_tx', $search_multicurrency_tx, 1);
966}
967if ($search_multicurrency_montant_ht != '') {
968 $sql .= natural_search('f.multicurrency_total_ht', $search_multicurrency_montant_ht, 1);
969}
970if ($search_multicurrency_montant_vat != '') {
971 $sql .= natural_search('f.multicurrency_total_tva', $search_multicurrency_montant_vat, 1);
972}
973if ($search_multicurrency_montant_ttc != '') {
974 $sql .= natural_search('f.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1);
975}
976if ($search_login) {
977 $sql .= natural_search(array('u.login', 'u.firstname', 'u.lastname'), $search_login);
978}
979if ($search_dispute_status != '-1' && $search_dispute_status != '') {
980 if ($search_dispute_status == '0') {
981 $sql .= " AND (f.dispute_status IS NULL OR f.dispute_status = 0)";
982 } else {
983 $sql .= " AND f.dispute_status IN (".$db->sanitize($search_dispute_status).")";
984 }
985}
986if (is_array($search_status) && count($search_status) > 0) {
987 $search_statusArray = $search_status;
988 $sql .= " AND f.fk_statut IN (" . $db->sanitize(implode(',', array_map('intval', $search_statusArray))) . ")";
989}
990
991if ($search_paymentmode > 0) {
992 $sql .= " AND f.fk_mode_reglement = ".((int) $search_paymentmode);
993}
994if ($search_paymentterms > 0) {
995 $sql .= " AND f.fk_cond_reglement = ".((int) $search_paymentterms);
996}
997if ($search_bankaccount > 0) {
998 $sql .= " AND ba.rowid = ".((int) $search_bankaccount);
999}
1000if ($search_fk_input_reason > 0) {
1001 $sql .= " AND f.fk_input_reason = ".((int) $search_fk_input_reason);
1002}
1003if ($search_module_source) {
1004 $sql .= natural_search("f.module_source", $search_module_source);
1005}
1006if ($search_pos_source) {
1007 $sql .= natural_search("f.pos_source", $search_pos_source);
1008}
1009if ($search_date_start) {
1010 $sql .= " AND f.datef >= '".$db->idate($search_date_start)."'";
1011}
1012if ($search_date_end) {
1013 $sql .= " AND f.datef <= '".$db->idate($search_date_end)."'";
1014}
1015if ($search_date_valid_start) {
1016 $sql .= " AND f.date_valid >= '".$db->idate($search_date_valid_start)."'";
1017}
1018if ($search_date_valid_end) {
1019 $sql .= " AND f.date_valid <= '".$db->idate($search_date_valid_end)."'";
1020}
1021if ($search_datelimit_start) {
1022 $sql .= " AND f.date_lim_reglement >= '".$db->idate($search_datelimit_start)."'";
1023}
1024if ($search_datelimit_end) {
1025 $sql .= " AND f.date_lim_reglement <= '".$db->idate($search_datelimit_end)."'";
1026}
1027if ($search_note_public) {
1028 $sql .= " AND p.note_public LIKE '%".$db->escape($db->escapeforlike($search_note_public))."%'";
1029}
1030if ($search_note_private) {
1031 $sql .= " AND p.note_private LIKE '%".$db->escape($db->escapeforlike($search_note_private))."%'";
1032}
1033if ($search_datec_start) {
1034 $sql .= " AND f.datec >= '".$db->idate($search_datec_start)."'";
1035}
1036if ($search_datec_end) {
1037 $sql .= " AND f.datec <= '".$db->idate($search_datec_end)."'";
1038}
1039if ($search_datem_start) {
1040 $sql .= " AND f.tms >= '".$db->idate($search_datem_start)."'";
1041}
1042if ($search_datem_end) {
1043 $sql .= " AND f.tms <= '".$db->idate($search_datem_end)."'";
1044}
1045if ($search_option == 'late') {
1046 $sql .= " AND f.date_lim_reglement < '".$db->idate(dol_now() - $conf->invoice->client->warning_delay)."'";
1047}
1048/*if ($search_sale > 0) {
1049 $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $search_sale);
1050}*/
1051if (!empty($search_fac_rec_source_title)) {
1052 $sql .= natural_search('facrec.titre', $search_fac_rec_source_title);
1053}
1054if ($search_fk_fac_rec_source) {
1055 $sql .= ' AND f.fk_fac_rec_source = ' . (int) $search_fk_fac_rec_source;
1056}
1057if ($search_import_key) {
1058 $sql .= natural_search("f.import_key", $search_import_key);
1059}
1060// Search on user
1061if ($search_user > 0) {
1062 $sql .= " AND EXISTS (";
1063 $sql .= " SELECT ec.fk_c_type_contact, ec.element_id, ec.fk_socpeople";
1064 $sql .= " FROM ".MAIN_DB_PREFIX."element_contact as ec";
1065 $sql .= " INNER JOIN ".MAIN_DB_PREFIX."c_type_contact as tc";
1066 $sql .= " ON ec.fk_c_type_contact = tc.rowid AND tc.element = 'facture' AND tc.source = 'internal'";
1067 $sql .= " WHERE ec.element_id = f.rowid AND ec.fk_socpeople = ".((int) $search_user).")";
1068}
1069// Search on sale representative
1070if ($search_sale && $search_sale != '-1') {
1071 if ($search_sale == -2) {
1072 $sql .= " AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = f.fk_soc)";
1073 } elseif ($search_sale > 0) {
1074 $sql .= " AND EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = f.fk_soc AND sc.fk_user = ".((int) $search_sale).")";
1075 }
1076}
1077
1078// Search for tag/category ($searchCategoryInvoiceList is an array of ID)
1079if (!empty($searchCategoryInvoiceList)) {
1080 $searchCategoryInvoiceSqlList = array();
1081 $listofcategoryid = '';
1082 foreach ($searchCategoryInvoiceList as $searchCategoryInvoice) {
1083 if (intval($searchCategoryInvoice) == -2) {
1084 $searchCategoryInvoiceSqlList[] = "NOT EXISTS (SELECT ck.fk_invoice FROM ".MAIN_DB_PREFIX."categorie_invoice as ck WHERE f.rowid = ck.fk_invoice)";
1085 } elseif (intval($searchCategoryInvoice) > 0) {
1086 if ($searchCategoryInvoiceOperator == 0) {
1087 $searchCategoryInvoiceSqlList[] = " EXISTS (SELECT ck.fk_invoice FROM ".MAIN_DB_PREFIX."categorie_invoice as ck WHERE f.rowid = ck.fk_invoice AND ck.fk_categorie = ".((int) $searchCategoryInvoice).")";
1088 } else {
1089 $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryInvoice);
1090 }
1091 }
1092 }
1093 if ($listofcategoryid) {
1094 $searchCategoryInvoiceSqlList[] = " EXISTS (SELECT ck.fk_invoice FROM ".MAIN_DB_PREFIX."categorie_invoice as ck WHERE f.rowid = ck.fk_invoice AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))";
1095 }
1096 if ($searchCategoryInvoiceOperator == 1) {
1097 if (!empty($searchCategoryInvoiceSqlList)) {
1098 $sql .= " AND (".implode(' OR ', $searchCategoryInvoiceSqlList).")";
1099 }
1100 } else {
1101 if (!empty($searchCategoryInvoiceSqlList)) {
1102 $sql .= " AND (".implode(' AND ', $searchCategoryInvoiceSqlList).")";
1103 }
1104 }
1105}
1106
1107// Search for tag/category ($searchCategoryProductList is an array of ID)
1108$searchCategoryProductList = $search_product_category ? array($search_product_category) : array();
1109$searchCategoryProductOperator = 0;
1110if (!empty($searchCategoryProductList)) {
1111 $searchCategoryProductSqlList = array();
1112 $listofcategoryid = '';
1113 foreach ($searchCategoryProductList as $searchCategoryProduct) {
1114 if (intval($searchCategoryProduct) == -2) {
1115 $searchCategoryProductSqlList[] = "NOT EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck, ".MAIN_DB_PREFIX."facturedet as fd WHERE fd.fk_facture = f.rowid AND fd.fk_product = ck.fk_product)";
1116 } elseif (intval($searchCategoryProduct) > 0) {
1117 if ($searchCategoryProductOperator == 0) {
1118 $searchCategoryProductSqlList[] = " EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck, ".MAIN_DB_PREFIX."facturedet as fd WHERE fd.fk_facture = f.rowid AND fd.fk_product = ck.fk_product AND ck.fk_categorie = ".((int) $searchCategoryProduct).")";
1119 } else {
1120 $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProduct);
1121 }
1122 }
1123 }
1124 if ($listofcategoryid) {
1125 $searchCategoryProductSqlList[] = " EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck, ".MAIN_DB_PREFIX."facturedet as fd WHERE fd.fk_facture = f.rowid AND fd.fk_product = ck.fk_product AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))";
1126 }
1127 if ($searchCategoryProductOperator == 1) {
1128 if (!empty($searchCategoryProductSqlList)) {
1129 $sql .= " AND (".implode(' OR ', $searchCategoryProductSqlList).")";
1130 }
1131 } else {
1132 if (!empty($searchCategoryProductSqlList)) {
1133 $sql .= " AND (".implode(' AND ', $searchCategoryProductSqlList).")";
1134 }
1135 }
1136}
1137$searchCategoryCustomerList = $search_categ_cus ? array($search_categ_cus) : array();
1138$searchCategoryCustomerOperator = 0;
1139// Search for tag/category ($searchCategoryCustomerList is an array of ID)
1140if (!empty($searchCategoryCustomerList)) {
1141 $searchCategoryCustomerSqlList = array();
1142 $listofcategoryid = '';
1143 foreach ($searchCategoryCustomerList as $searchCategoryCustomer) {
1144 if (intval($searchCategoryCustomer) == -2) {
1145 $searchCategoryCustomerSqlList[] = "NOT EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe as ck WHERE s.rowid = ck.fk_soc)";
1146 } elseif (intval($searchCategoryCustomer) > 0) {
1147 if ($searchCategoryCustomerOperator == 0) {
1148 $searchCategoryCustomerSqlList[] = " EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe as ck WHERE s.rowid = ck.fk_soc AND ck.fk_categorie = ".((int) $searchCategoryCustomer).")";
1149 } else {
1150 $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryCustomer);
1151 }
1152 }
1153 }
1154 if ($listofcategoryid) {
1155 $searchCategoryCustomerSqlList[] = " EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe as ck WHERE s.rowid = ck.fk_soc AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))";
1156 }
1157 if ($searchCategoryCustomerOperator == 1) {
1158 if (!empty($searchCategoryCustomerSqlList)) {
1159 $sql .= " AND (".implode(' OR ', $searchCategoryCustomerSqlList).")";
1160 }
1161 } else {
1162 if (!empty($searchCategoryCustomerSqlList)) {
1163 $sql .= " AND (".implode(' AND ', $searchCategoryCustomerSqlList).")";
1164 }
1165 }
1166}
1167// Add where from extra fields
1168include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
1169// Add where from hooks
1170$parameters = array();
1171$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1172$sql .= $hookmanager->resPrint;
1173
1174if ($search_all) {
1175 // Prepare the $sqltoadd for fields pd.* that need a test by doing a "or exits"
1176 $sqltoadd = '';
1177 $fieldstosearchallwithoutpd = array();
1178 $fieldstosearchallwithpd = array();
1179 foreach ($fieldstosearchall as $key => $val) {
1180 if (!preg_match('/^pd\./', $key)) {
1181 $fieldstosearchallwithoutpd[$key] = $val;
1182 } else {
1183 $fieldstosearchallwithpd[$key] = $val;
1184 }
1185 }
1186
1187 if (count($fieldstosearchallwithpd) > 0) {
1188 $sqltoadd .= " OR EXISTS (SELECT pd.rowid FROM ".MAIN_DB_PREFIX."facturedet as pd WHERE pd.fk_facture = f.rowid";
1189 $sqltoadd .= natural_search(array_keys($fieldstosearchallwithpd), '__KEYTOSEARCH__');
1190 $sqltoadd .= ')';
1191 }
1192
1193 $sql .= natural_search(array_keys($fieldstosearchallwithoutpd), $search_all, 0, 0, $sqltoadd);
1194}
1195// Add HAVING from hooks
1196$parameters = array();
1197$reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1198if (empty($reshook)) {
1199 $sql .= empty($hookmanager->resPrint) ? "" : " HAVING 1=1 ".$hookmanager->resPrint;
1200} else {
1201 $sql = $hookmanager->resPrint;
1202}
1203
1204// Count total nb of records
1205$nbtotalofrecords = '';
1206if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
1207 /* The fast and low memory method to get and count full list converts the sql into a sql count */
1208 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
1209 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
1210
1211 $resql = $db->query($sqlforcount);
1212 if ($resql) {
1213 $objforcount = $db->fetch_object($resql);
1214 $nbtotalofrecords = $objforcount->nbtotalofrecords;
1215 } else {
1217 }
1218
1219 if (($page * $limit) > (int) $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
1220 $page = 0;
1221 $offset = 0;
1222 }
1223 $db->free($resql);
1224}
1225
1226// Complete request and execute it with limit
1227$sql .= $db->order($sortfield, $sortorder);
1228if ($limit) {
1229 $sql .= $db->plimit($limit + 1, $offset);
1230}
1231
1232$resql = $db->query($sql);
1233if (!$resql) {
1235 exit;
1236}
1237
1238$num = $db->num_rows($resql);
1239
1240$arrayofselected = is_array($toselect) ? $toselect : array();
1241
1242if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all) {
1243 $obj = $db->fetch_object($resql);
1244 $id = $obj->id;
1245
1246 header("Location: ".DOL_URL_ROOT.'/compta/facture/card.php?id='.$id);
1247 exit;
1248}
1249
1250// Output page
1251// --------------------------------------------------------------------
1252
1253llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'bodyforlist'.($contextpage == 'poslist' ? ' '.$contextpage : ''));
1254
1255
1256if ($search_fk_fac_rec_source) {
1257 $object = new FactureRec($db);
1258 $object->fetch((int) $search_fk_fac_rec_source);
1259
1260 $head = invoice_rec_prepare_head($object);
1261
1262 print dol_get_fiche_head($head, 'generated', $langs->trans('InvoicesGeneratedFromRec'), -1, $object->picto); // Add a div
1263}
1264
1265$param = '';
1266if (!empty($mode)) {
1267 $param .= '&mode='.urlencode($mode);
1268}
1269if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
1270 $param .= '&contextpage='.urlencode($contextpage);
1271}
1272if ($limit > 0 && $limit != $conf->liste_limit) {
1273 $param .= '&limit='.((int) $limit);
1274}
1275if ($optioncss != '') {
1276 $param .= '&optioncss='.urlencode($optioncss);
1277}
1278if ($show_files) {
1279 $param .= '&show_files='.urlencode((string) ($show_files));
1280}
1281if ($search_all) {
1282 $param .= '&search_all='.urlencode($search_all);
1283}
1284if ($socid > 0) {
1285 $param .= '&socid='.((int) $socid);
1286}
1287if ($search_date_startday) {
1288 $param .= '&search_date_startday='.urlencode((string) ($search_date_startday));
1289}
1290if ($search_date_startmonth) {
1291 $param .= '&search_date_startmonth='.urlencode((string) ($search_date_startmonth));
1292}
1293if ($search_date_startyear) {
1294 $param .= '&search_date_startyear='.urlencode((string) ($search_date_startyear));
1295}
1296if ($search_date_endday) {
1297 $param .= '&search_date_endday='.urlencode((string) ($search_date_endday));
1298}
1299if ($search_date_endmonth) {
1300 $param .= '&search_date_endmonth='.urlencode((string) ($search_date_endmonth));
1301}
1302if ($search_date_endyear) {
1303 $param .= '&search_date_endyear='.urlencode((string) ($search_date_endyear));
1304}
1305if ($search_date_valid_startday) {
1306 $param .= '&search_date_valid_startday='.urlencode((string) ($search_date_valid_startday));
1307}
1308if ($search_date_valid_startmonth) {
1309 $param .= '&search_date_valid_startmonth='.urlencode((string) ($search_date_valid_startmonth));
1310}
1311if ($search_date_valid_startyear) {
1312 $param .= '&search_date_valid_startyear='.urlencode((string) ($search_date_valid_startyear));
1313}
1314if ($search_date_valid_endday) {
1315 $param .= '&search_date_valid_endday='.urlencode((string) ($search_date_valid_endday));
1316}
1317if ($search_date_valid_endmonth) {
1318 $param .= '&search_date_valid_endmonth='.urlencode((string) ($search_date_valid_endmonth));
1319}
1320if ($search_date_valid_endyear) {
1321 $param .= '&search_date_valid_endyear='.urlencode((string) ($search_date_valid_endyear));
1322}
1323if ($search_datelimit_startday) {
1324 $param .= '&search_datelimit_startday='.urlencode((string) ($search_datelimit_startday));
1325}
1326if ($search_datelimit_startmonth) {
1327 $param .= '&search_datelimit_startmonth='.urlencode((string) ($search_datelimit_startmonth));
1328}
1329if ($search_datelimit_startyear) {
1330 $param .= '&search_datelimit_startyear='.urlencode((string) ($search_datelimit_startyear));
1331}
1332if ($search_datelimit_endday) {
1333 $param .= '&search_datelimit_endday='.urlencode((string) ($search_datelimit_endday));
1334}
1335if ($search_datelimit_endmonth) {
1336 $param .= '&search_datelimit_endmonth='.urlencode((string) ($search_datelimit_endmonth));
1337}
1338if ($search_datelimit_endyear) {
1339 $param .= '&search_datelimit_endyear='.urlencode((string) ($search_datelimit_endyear));
1340}
1341if ($search_ref) {
1342 $param .= '&search_ref='.urlencode($search_ref);
1343}
1344if ($search_refcustomer) {
1345 $param .= '&search_refcustomer='.urlencode($search_refcustomer);
1346}
1347if ($search_project_ref) {
1348 $param .= '&search_project_ref='.urlencode($search_project_ref);
1349}
1350if ($search_project) {
1351 $param .= '&search_project='.urlencode($search_project);
1352}
1353if ($search_type != '') {
1354 $param .= '&search_type='.urlencode($search_type);
1355}
1356if ($search_subtype != '') {
1357 $param .= '&search_subtype='.urlencode($search_subtype);
1358}
1359if ($search_company) {
1360 $param .= '&search_company='.urlencode($search_company);
1361}
1362if ($search_company_alias) {
1363 $param .= '&search_company_alias='.urlencode($search_company_alias);
1364}
1365if ($search_parent_name != '') {
1366 $param .= '&search_parent_name='.urlencode($search_parent_name);
1367}
1368if ($search_town) {
1369 $param .= '&search_town='.urlencode($search_town);
1370}
1371if ($search_zip) {
1372 $param .= '&search_zip='.urlencode($search_zip);
1373}
1374if ($search_country) {
1375 $param .= "&search_country=".urlencode($search_country);
1376}
1377if ($search_type_thirdparty != '') {
1378 $param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty);
1379}
1380if ($search_customer_code) {
1381 $param .= '&search_customer_code='.urlencode($search_customer_code);
1382}
1383if ($search_sale > 0) {
1384 $param .= '&search_sale='.urlencode((string) $search_sale);
1385}
1386if ($search_user > 0) {
1387 $param .= '&search_user='.urlencode((string) $search_user);
1388}
1389if ($search_login) {
1390 $param .= '&search_login='.urlencode($search_login);
1391}
1392if ($searchCategoryInvoiceOperator == 1) {
1393 $param .= "&search_category_invoice_operator=".urlencode((string) ($searchCategoryInvoiceOperator));
1394}
1395foreach ($searchCategoryInvoiceList as $searchCategoryInvoice) {
1396 $param .= "&search_category_invoice_list[]=".urlencode($searchCategoryInvoice);
1397}
1398if ($search_product_category > 0) {
1399 $param .= '&search_product_category='.urlencode((string) $search_product_category);
1400}
1401if ($search_montant_ht != '') {
1402 $param .= '&search_montant_ht='.urlencode($search_montant_ht);
1403}
1404if ($search_montant_vat != '') {
1405 $param .= '&search_montant_vat='.urlencode($search_montant_vat);
1406}
1407if ($search_montant_localtax1 != '') {
1408 $param .= '&search_montant_localtax1='.urlencode($search_montant_localtax1);
1409}
1410if ($search_montant_localtax2 != '') {
1411 $param .= '&search_montant_localtax2='.urlencode($search_montant_localtax2);
1412}
1413if ($search_montant_ttc != '') {
1414 $param .= '&search_montant_ttc='.urlencode($search_montant_ttc);
1415}
1416if ($search_multicurrency_code != '') {
1417 $param .= '&search_multicurrency_code='.urlencode($search_multicurrency_code);
1418}
1419if ($search_multicurrency_tx != '') {
1420 $param .= '&search_multicurrency_tx='.urlencode($search_multicurrency_tx);
1421}
1422if ($search_multicurrency_montant_ht != '') {
1423 $param .= '&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht);
1424}
1425if ($search_multicurrency_montant_vat != '') {
1426 $param .= '&search_multicurrency_montant_vat='.urlencode($search_multicurrency_montant_vat);
1427}
1428if ($search_multicurrency_montant_ttc != '') {
1429 $param .= '&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc);
1430}
1431if ($search_dispute_status != '') {
1432 $param .= '&search_dispute_status='.urlencode($search_dispute_status);
1433}
1434if (count($search_status) > 0) {
1435 foreach ($search_status as $key => $val) {
1436 $param .= '&search_status[]='.urlencode($val);
1437 }
1438}
1439if ($search_paymentmode > 0) {
1440 $param .= '&search_paymentmode='.urlencode((string) ($search_paymentmode));
1441}
1442if ($search_paymentterms > 0) {
1443 $param .= '&search_paymentterms='.urlencode((string) ($search_paymentterms));
1444}
1445if ($search_bankaccount > 0) {
1446 $param .= '&search_bankaccount='.urlencode((string) ($search_bankaccount));
1447}
1448if ($search_fk_input_reason > 0) {
1449 $param .= '&search_fk_input_reason='.urlencode((string) $search_fk_input_reason);
1450}
1451if ($search_module_source) {
1452 $param .= '&search_module_source='.urlencode($search_module_source);
1453}
1454if ($search_pos_source) {
1455 $param .= '&search_pos_source='.urlencode($search_pos_source);
1456}
1457if ($search_option) {
1458 $param .= "&search_option=".urlencode($search_option);
1459}
1460if ($search_categ_cus > 0) {
1461 $param .= '&search_categ_cus='.urlencode((string) ($search_categ_cus));
1462}
1463if (!empty($search_fac_rec_source_title)) {
1464 $param .= '&search_fac_rec_source_title='.urlencode($search_fac_rec_source_title);
1465}
1466if ($search_fk_fac_rec_source) {
1467 $param .= '&search_fk_fac_rec_source=' . (int) $search_fk_fac_rec_source;
1468}
1469if ($search_import_key != '') {
1470 $param .= '&search_import_key='.urlencode($search_import_key);
1471}
1472
1473// Add $param from extra fields
1474include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
1475// Add $param from hooks
1476$parameters = array('param' => &$param);
1477$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1478$param .= $hookmanager->resPrint;
1479
1480$arrayofmassactions = array(
1481 'validate' => img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"),
1482 'generate_doc' => img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
1483 'builddoc' => img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
1484 'presend' => img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
1485);
1486
1487if (isModEnabled('category') && $user->hasRight('facture', 'creer')) {
1488 $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag");
1489}
1490if ($user->hasRight('facture', 'paiement')) {
1491 $arrayofmassactions['makepayment'] = img_picto('', 'payment', 'class="pictofixedwidth"').$langs->trans("MakePaymentAndClassifyPayed");
1492}
1493if (isModEnabled('prelevement') && $user->hasRight('prelevement', 'bons', 'creer')) {
1494 $langs->load("withdrawals");
1495 $arrayofmassactions['withdrawrequest'] = img_picto('', 'payment', 'class="pictofixedwidth"').$langs->trans("MakeWithdrawRequest");
1496}
1497if ($user->hasRight('facture', 'supprimer')) {
1498 if (!getDolGlobalString('INVOICE_DIABLE_MASS_DELETION_ON_DRAFT_INVOICES')) {
1499 $arrayofmassactions['predeletedraft'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Deletedraft");
1500 }
1501}
1502if ($user->hasRight("facture", "creer")) {
1503 if (!getDolGlobalInt('STOCK_CALCULATE_ON_BILL')) {
1504 $arrayofmassactions['precreatecreditnote'] = img_picto('', 'undo', 'class="pictofixedwidth"').$langs->trans("cancelByCreditNote");
1505 }
1506}
1507if (in_array($massaction, array('presend', 'predelete', 'makepayment'))) {
1508 $arrayofmassactions = array();
1509}
1510$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
1511
1512
1513// Show the new button only when this page is not opened from the Extended POS
1514$newcardbutton = '';
1515if ($contextpage != 'poslist') {
1516 $url = DOL_URL_ROOT.'/compta/facture/card.php?action=create';
1517 if (!empty($object->socid)) {
1518 $url .= '&socid='.urlencode((string) $object->socid);
1519 }
1520 if (!empty($object->id)) {
1521 $url .= '&fac_rec='.urlencode((string) $object->id);
1522 }
1523 $newcardbutton = '';
1524 $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'));
1525 $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'));
1526 $newcardbutton .= dolGetButtonTitle($langs->trans('Statistics'), '', 'fa fa-chart-bar imgforviewmode', DOL_URL_ROOT.'/compta/facture/stats/index.php?'.preg_replace('/(&|\?)*(mode|groupby)=[^&]+/', '', $param), '', ($mode == 'statistics' ? 2 : 1), array('morecss' => 'reposition'));
1527 $newcardbutton .= dolGetButtonTitleSeparator();
1528 $newcardbutton .= dolGetButtonTitle($langs->trans('NewBill'), '', 'fa fa-plus-circle', $url, '', $user->hasRight("facture", "creer"));
1529}
1530
1531
1532// Lines of title fields
1533$i = 0;
1534print '<form method="POST" id="searchFormList" name="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
1535if ($optioncss != '') {
1536 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
1537}
1538print '<input type="hidden" name="token" value="'.newToken().'">';
1539print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1540if (!in_array($massaction, array('makepayment'))) {
1541 print '<input type="hidden" name="action" value="list">';
1542}
1543print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
1544print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
1545// print '<input type="hidden" name="search_status" value="'.$search_status.'">';
1546print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
1547print '<input type="hidden" name="socid" value="'.$socid.'">';
1548print '<input type="hidden" name="mode" value="'.$mode.'">';
1549
1550print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'bill', 0, $newcardbutton, '', $limit, 0, 0, 1);
1551
1552$topicmail = "SendBillRef";
1553$modelmail = "facture_send";
1554$objecttmp = new Facture($db);
1555$trackid = 'inv'.$object->id;
1556include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
1557
1558if ($massaction == 'makepayment') {
1559 $formconfirm = '';
1560 $formquestion = array(
1561 // 'text' => $langs->trans("ConfirmClone"),
1562 // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
1563 // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
1564 array('type' => 'date', 'name' => 'datepaiment', 'label' => $langs->trans("Date"), 'datenow' => 1),
1565 array('type' => 'other', 'name' => 'paiementid', 'label' => $langs->trans("PaymentMode"), 'value' => $form->select_types_paiements(GETPOST('search_paymentmode'), 'paiementid', '', 0, 0, 1, 0, 1, '', 1)),
1566 array('type' => 'other', 'name' => 'bankid', 'label' => $langs->trans("BankAccount"), 'value' => $form->select_comptes('', 'bankid', 0, '', 0, '', 0, '', 1)),
1567 array('type' => 'other', 'name' => 'note_private', 'label' => $langs->trans("Comments"), 'value' => '<textarea name="note_private" id="note_private" class="minwidth200" rows="3"></textarea>'),
1568 //array('type' => 'other', 'name' => 'invoicesid', 'label' => '', 'value'=>'<input type="hidden" id="invoicesid" name="invoicesid" value="'.implode('#',GETPOST('toselect','array')).'">'),
1569 );
1570 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans('MakePaymentAndClassifyPayed'), $langs->trans('EnterPaymentReceivedFromCustomer'), 'makepayment_confirm', $formquestion, 1, 0, 200, 500, 1);
1571 print $formconfirm;
1572}
1573
1574if ($search_all) {
1575 foreach ($fieldstosearchall as $key => $val) {
1576 $fieldstosearchall[$key] = $langs->trans($val);
1577 }
1578 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'</div>';
1579}
1580
1581// If the user can view prospects other than his'
1582$moreforfilter = '';
1583
1584if (isModEnabled('category') && $user->hasRight('categorie', 'read')) {
1585 $formcategory = new FormCategory($db);
1586 $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_INVOICE, $searchCategoryInvoiceList, 'minwidth300', $searchCategoryInvoiceOperator ? $searchCategoryInvoiceOperator : 0);
1587}
1588if ($user->hasRight("user", "user", "lire")) {
1589 $langs->load("commercial");
1590 $moreforfilter .= '<div class="divsearchfield">';
1591 $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative');
1592 $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'maxwidth200');
1593 $moreforfilter .= '</div>';
1594}
1595// If the user can view other users
1596if ($user->hasRight("user", "user", "lire")) {
1597 $moreforfilter .= '<div class="divsearchfield">';
1598 $tmptitle = $langs->trans('LinkedToSpecificUsers');
1599 $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_user, 'search_user', $tmptitle, null, 0, '', '', '0', 0, 0, '', 0, '', 'maxwidth200');
1600 $moreforfilter .= '</div>';
1601}
1602// Filter on product tags
1603if (isModEnabled('category') && $user->hasRight("categorie", "lire") && ($user->hasRight("produit", "lire") || $user->hasRight("service", "lire"))) {
1604 include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
1605 $moreforfilter .= '<div class="divsearchfield">';
1606 $tmptitle = $langs->trans('IncludingProductWithTag');
1607 $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, '', 'parent', 0, 0, 1);
1608 $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$form->selectarray('search_product_category', $cate_arbo, $search_product_category, $tmptitle, 0, 0, '', 0, 0, 0, '', 'maxwidth300 widthcentpercentminusx', 1);
1609 $moreforfilter .= '</div>';
1610}
1611if (isModEnabled('category') && $user->hasRight("categorie", "lire")) {
1612 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
1613 $moreforfilter .= '<div class="divsearchfield">';
1614 $tmptitle = $langs->trans('CustomersProspectsCategoriesShort');
1615 $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$formother->select_categories('customer', $search_categ_cus, 'search_categ_cus', 1, $tmptitle);
1616 $moreforfilter .= '</div>';
1617}
1618// alert on due date
1619$moreforfilter .= '<div class="divsearchfield">';
1620$moreforfilter .= '<label for="search_option">'.$langs->trans('Alert').' </label><input type="checkbox" name="search_option" id="search_option" value="late"'.($search_option == 'late' ? ' checked' : '').'>';
1621$moreforfilter .= '</div>';
1622
1623$parameters = array();
1624$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1625if (empty($reshook)) {
1626 $moreforfilter .= $hookmanager->resPrint;
1627} else {
1628 $moreforfilter = $hookmanager->resPrint;
1629}
1630
1631if (!empty($moreforfilter)) {
1632 print '<div class="liste_titre liste_titre_bydiv centpercent">';
1633 print $moreforfilter;
1634 print '</div>';
1635}
1636
1637
1638$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
1639$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, $conf->main_checkbox_left_column); // This also change content of $arrayfields
1640
1641// Show the massaction checkboxes only when this page is not opened from the Extended POS
1642if ($massactionbutton && $contextpage != 'poslist') {
1643 $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
1644}
1645
1646print '<div class="div-table-responsive">';
1647print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
1648
1649// Fields title search
1650// --------------------------------------------------------------------
1651print '<tr class="liste_titre_filter">';
1652
1653// Action column
1654if ($conf->main_checkbox_left_column) {
1655 print '<td class="liste_titre center maxwidthsearch actioncolumn">';
1656 $searchpicto = $form->showFilterButtons('left');
1657 print $searchpicto;
1658 print '</td>';
1659}
1660
1661if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER_IN_LIST')) {
1662 print '<td class="liste_titre">';
1663 print '</td>';
1664}
1665// Ref
1666if (!empty($arrayfields['f.ref']['checked'])) {
1667 print '<td class="liste_titre">';
1668 print '<input class="flat maxwidth75imp" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
1669 print '</td>';
1670}
1671// Ref customer
1672if (!empty($arrayfields['f.ref_client']['checked'])) {
1673 print '<td class="liste_titre">';
1674 print '<input class="flat maxwidth50imp" type="text" name="search_refcustomer" value="'.dol_escape_htmltag($search_refcustomer).'">';
1675 print '</td>';
1676}
1677// Type
1678if (!empty($arrayfields['f.type']['checked'])) {
1679 print '<td class="liste_titre maxwidthonsmartphone">';
1680 $listtype = array(
1681 Facture::TYPE_STANDARD => $langs->trans("InvoiceStandard"),
1682 Facture::TYPE_DEPOSIT => $langs->trans("InvoiceDeposit"),
1683 Facture::TYPE_CREDIT_NOTE => $langs->trans("InvoiceAvoir"),
1684 Facture::TYPE_REPLACEMENT => $langs->trans("InvoiceReplacement"),
1685 );
1686 if (getDolGlobalString('INVOICE_USE_SITUATION')) {
1687 $listtype[Facture::TYPE_SITUATION] = $langs->trans("InvoiceSituation");
1688 }
1689 //$listtype[Facture::TYPE_PROFORMA]=$langs->trans("InvoiceProForma"); // A proformat invoice is not an invoice but must be an order.
1690 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1691 print $form->selectarray('search_type', $listtype, $search_type, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth75');
1692 print '</td>';
1693}
1694// Invoice Subtype
1695if (!empty($arrayfields['f.subtype']['checked'])) {
1696 print '<td class="liste_titre maxwidthonsmartphone" align="center">';
1697 print $form->selectarray('search_subtype', $subtypearray, $search_subtype, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth100');
1698 print '</td>';
1699}
1700// Date invoice
1701if (!empty($arrayfields['f.datef']['checked'])) {
1702 print '<td class="liste_titre center">';
1703 print '<div class="nowrapfordate">';
1704 print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
1705 print '</div>';
1706 print '<div class="nowrapfordate">';
1707 print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
1708 print '</div>';
1709 print '</td>';
1710}
1711// Date valid
1712if (!empty($arrayfields['f.date_valid']['checked'])) {
1713 print '<td class="liste_titre center">';
1714 print '<div class="nowrapfordate">';
1715 print $form->selectDate($search_date_valid_start ? $search_date_valid_start : -1, 'search_date_valid_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
1716 print '</div>';
1717 print '<div class="nowrapfordate">';
1718 print $form->selectDate($search_date_valid_end ? $search_date_valid_end : -1, 'search_date_valid_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
1719 print '</div>';
1720 print '</td>';
1721}
1722// Date due
1723if (!empty($arrayfields['f.date_lim_reglement']['checked'])) {
1724 print '<td class="liste_titre center">';
1725 print '<div class="nowrapfordate">';
1726 print $form->selectDate($search_datelimit_start ? $search_datelimit_start : -1, 'search_datelimit_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
1727 print '</div>';
1728 print '<div class="nowrapfordate">';
1729 print $form->selectDate($search_datelimit_end ? $search_datelimit_end : -1, 'search_datelimit_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
1730 print '</div>';
1731 print '</td>';
1732}
1733// Project ref
1734if (!empty($arrayfields['p.ref']['checked'])) {
1735 print '<td class="liste_titre"><input class="flat maxwidth50imp" type="text" name="search_project_ref" value="'.dol_escape_htmltag($search_project_ref).'"></td>';
1736}
1737// Project label
1738if (!empty($arrayfields['p.title']['checked'])) {
1739 print '<td class="liste_titre"><input class="flat maxwidth50imp" type="text" name="search_project" value="'.dol_escape_htmltag($search_project).'"></td>';
1740}
1741// Thirdparty
1742if (!empty($arrayfields['s.nom']['checked'])) {
1743 print '<td class="liste_titre"><input class="flat maxwidth75imp" type="text" name="search_company" value="'.dol_escape_htmltag((string) $search_company).'"'.($socid > 0 ? " disabled" : "").'></td>';
1744}
1745// Alias
1746if (!empty($arrayfields['s.name_alias']['checked'])) {
1747 print '<td class="liste_titre"><input class="flat maxwidth75imp" type="text" name="search_company_alias" value="'.dol_escape_htmltag($search_company_alias).'"></td>';
1748}
1749// Parent company
1750if (!empty($arrayfields['s2.nom']['checked'])) {
1751 print '<td class="liste_titre">';
1752 print '<input class="flat maxwidth100" type="text" name="search_parent_name" value="'.dol_escape_htmltag($search_parent_name).'">';
1753 print '</td>';
1754}
1755// Customer Code
1756if (!empty($arrayfields['s.code_client']['checked'])) {
1757 print '<td class="liste_titre"><input class="flat maxwidth75imp" type="text" name="search_customer_code" value="'.dol_escape_htmltag($search_customer_code).'"></td>';
1758}
1759// Town
1760if (!empty($arrayfields['s.town']['checked'])) {
1761 print '<td class="liste_titre"><input class="flat maxwidth75imp" type="text" name="search_town" value="'.dol_escape_htmltag($search_town).'"></td>';
1762}
1763// Zip
1764if (!empty($arrayfields['s.zip']['checked'])) {
1765 print '<td class="liste_titre"><input class="flat maxwidth50imp" type="text" name="search_zip" value="'.dol_escape_htmltag($search_zip).'"></td>';
1766}
1767// State
1768if (!empty($arrayfields['state.nom']['checked'])) {
1769 print '<td class="liste_titre">';
1770 print '<input class="flat maxwidth50imp" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
1771 print '</td>';
1772}
1773// Country
1774if (!empty($arrayfields['country.code_iso']['checked'])) {
1775 print '<td class="liste_titre center">';
1776 print $form->select_country($search_country, 'search_country', '', 0, 'minwidth150imp maxwidth150', 'code2', 1, 0, 1, array(), 1);
1777 print '</td>';
1778}
1779// Company type
1780if (!empty($arrayfields['typent.code']['checked'])) {
1781 print '<td class="liste_titre maxwidthonsmartphone center">';
1782 print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0, '', 0, 0, 0, getDolGlobalString('SOCIETE_SORT_ON_TYPEENT', 'ASC'), 'maxwidth100', 1);
1783 print '</td>';
1784}
1785// Payment mode
1786if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) {
1787 print '<td class="liste_titre">';
1788 print $form->select_types_paiements($search_paymentmode, 'search_paymentmode', '', 0, 1, 1, 0, 1, 'minwidth100 maxwidth100', 1);
1789 print '</td>';
1790}
1791// Payment terms
1792if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) {
1793 print '<td class="liste_titre left">';
1794 print $form->getSelectConditionsPaiements((int) $search_paymentterms, 'search_paymentterms', -1, 1, 1, 'minwidth100 maxwidth100');
1795 print '</td>';
1796}
1797// Bank account
1798if (!empty($arrayfields['ba.label']['checked'])) {
1799 print '<td class="liste_titre">';
1800 $form->select_comptes($search_bankaccount, 'search_bankaccount', 0, '', 1, '', 0, 'maxwidth125');
1801 print '</td>';
1802}
1803// Channel
1804if (!empty($arrayfields['f.fk_input_reason']['checked'])) {
1805 print '<td class="liste_titre">';
1806 $form->selectInputReason($search_fk_input_reason, 'search_fk_input_reason', '', 1, '', 1);
1807 print '</td>';
1808}
1809// Module source
1810if (!empty($arrayfields['f.module_source']['checked'])) {
1811 print '<td class="liste_titre">';
1812 print '<input class="flat maxwidth75" type="text" name="search_module_source" value="'.dol_escape_htmltag($search_module_source).'">';
1813 print '</td>';
1814}
1815// POS Terminal
1816if (!empty($arrayfields['f.pos_source']['checked'])) {
1817 print '<td class="liste_titre">';
1818 print '<input class="flat maxwidth50" type="text" name="search_pos_source" value="'.dol_escape_htmltag($search_pos_source).'">';
1819 print '</td>';
1820}
1821if (!empty($arrayfields['f.total_ht']['checked'])) {
1822 // Amount without tax
1823 print '<td class="liste_titre right">';
1824 print '<input class="flat" type="text" size="4" name="search_montant_ht" value="'.dol_escape_htmltag($search_montant_ht).'">';
1825 print '</td>';
1826}
1827if (!empty($arrayfields['f.total_tva']['checked'])) {
1828 // Amount vat
1829 print '<td class="liste_titre right">';
1830 print '<input class="flat" type="text" size="4" name="search_montant_vat" value="'.dol_escape_htmltag($search_montant_vat).'">';
1831 print '</td>';
1832}
1833if (!empty($arrayfields['f.total_localtax1']['checked'])) {
1834 // Localtax1
1835 print '<td class="liste_titre right">';
1836 print '<input class="flat" type="text" size="4" name="search_montant_localtax1" value="'.dol_escape_htmltag($search_montant_localtax1).'">';
1837 print '</td>';
1838}
1839if (!empty($arrayfields['f.total_localtax2']['checked'])) {
1840 // Localtax2
1841 print '<td class="liste_titre right">';
1842 print '<input class="flat" type="text" size="4" name="search_montant_localtax2" value="'.dol_escape_htmltag($search_montant_localtax2).'">';
1843 print '</td>';
1844}
1845if (!empty($arrayfields['f.total_ttc']['checked'])) {
1846 // Amount inc tax
1847 print '<td class="liste_titre right">';
1848 print '<input class="flat" type="text" size="4" name="search_montant_ttc" value="'.dol_escape_htmltag($search_montant_ttc).'">';
1849 print '</td>';
1850}
1851if (!empty($arrayfields['u.login']['checked'])) {
1852 // Author
1853 print '<td class="liste_titre" align="center">';
1854 print '<input class="flat" size="4" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).'">';
1855 print '</td>';
1856}
1857if (!empty($arrayfields['sale_representative']['checked'])) {
1858 print '<td class="liste_titre"></td>';
1859}
1860if (!empty($arrayfields['f.retained_warranty']['checked'])) {
1861 print '<td class="liste_titre" align="right">';
1862 print '</td>';
1863}
1864if (!empty($arrayfields['dynamount_payed']['checked'])) {
1865 print '<td class="liste_titre right">';
1866 print '</td>';
1867}
1868if (!empty($arrayfields['rtp']['checked'])) {
1869 print '<td class="liste_titre">';
1870 print '</td>';
1871}
1872if (!empty($arrayfields['f.multicurrency_code']['checked'])) {
1873 // Currency
1874 print '<td class="liste_titre">';
1875 print $form->selectMultiCurrency($search_multicurrency_code, 'search_multicurrency_code', 1);
1876 print '</td>';
1877}
1878if (!empty($arrayfields['f.multicurrency_tx']['checked'])) {
1879 // Currency rate
1880 print '<td class="liste_titre">';
1881 print '<input class="flat" type="text" size="4" name="search_multicurrency_tx" value="'.dol_escape_htmltag($search_multicurrency_tx).'">';
1882 print '</td>';
1883}
1884if (!empty($arrayfields['f.multicurrency_total_ht']['checked'])) {
1885 // Amount
1886 print '<td class="liste_titre right">';
1887 print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_ht" value="'.dol_escape_htmltag($search_multicurrency_montant_ht).'">';
1888 print '</td>';
1889}
1890if (!empty($arrayfields['f.multicurrency_total_vat']['checked'])) {
1891 // Amount
1892 print '<td class="liste_titre right">';
1893 print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_vat" value="'.dol_escape_htmltag($search_multicurrency_montant_vat).'">';
1894 print '</td>';
1895}
1896if (!empty($arrayfields['f.multicurrency_total_ttc']['checked'])) {
1897 // Amount
1898 print '<td class="liste_titre right">';
1899 print '<input class="flat width75" type="text" name="search_multicurrency_montant_ttc" value="'.dol_escape_htmltag($search_multicurrency_montant_ttc).'">';
1900 print '</td>';
1901}
1902if (!empty($arrayfields['multicurrency_dynamount_payed']['checked'])) {
1903 print '<td class="liste_titre">';
1904 print '</td>';
1905}
1906if (!empty($arrayfields['multicurrency_rtp']['checked'])) {
1907 print '<td class="liste_titre right">';
1908 print '</td>';
1909}
1910if (!empty($arrayfields['total_pa']['checked'])) {
1911 print '<td class="liste_titre right">';
1912 print '</td>';
1913}
1914if (!empty($arrayfields['total_margin']['checked'])) {
1915 print '<td class="liste_titre right">';
1916 print '</td>';
1917}
1918if (!empty($arrayfields['total_margin_rate']['checked'])) {
1919 print '<td class="liste_titre right">';
1920 print '</td>';
1921}
1922if (!empty($arrayfields['total_mark_rate']['checked'])) {
1923 print '<td class="liste_titre right">';
1924 print '</td>';
1925}
1926
1927// Extra fields
1928include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
1929
1930// Fields from hook
1931$parameters = array('arrayfields' => $arrayfields);
1932$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1933print $hookmanager->resPrint;
1934// Date creation
1935if (!empty($arrayfields['f.datec']['checked'])) {
1936 print '<td class="liste_titre center">';
1937 print '<div class="nowrapfordate">';
1938 print $form->selectDate($search_datec_start ? $search_datec_start : -1, 'search_datec_start', 1, 1, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'), 'tzuserrel');
1939 print '</div>';
1940 print '<div class="nowrapfordate">';
1941 print $form->selectDate($search_datec_end ? $search_datec_end : -1, 'search_datec_end', 1, 1, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'), 'tzuserrel');
1942 print '</div>';
1943 print '</td>';
1944}
1945// Date modification
1946if (!empty($arrayfields['f.tms']['checked'])) {
1947 print '<td class="liste_titre center">';
1948 print '<div class="nowrapfordate">';
1949 print $form->selectDate($search_datem_start ? $search_datem_start : -1, 'search_datem_start', 1, 1, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'), 'tzuserrel');
1950 print '</div>';
1951 print '<div class="nowrapfordate">';
1952 print $form->selectDate($search_datem_end ? $search_datem_end : -1, 'search_datem_end', 1, 1, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'), 'tzuserrel');
1953 print '</div>';
1954 print '</td>';
1955}
1956// Date closing
1957if (!empty($arrayfields['f.date_closing']['checked'])) {
1958 print '<td class="liste_titre">';
1959 print '</td>';
1960}
1961if (!empty($arrayfields['f.note_public']['checked'])) {
1962 // Note public
1963 print '<td class="liste_titre">';
1964 print '<input class="flat maxwidth75" type="text" name="search_note_public" value="'.dol_escape_htmltag($search_note_public).'">';
1965 print '</td>';
1966}
1967if (!empty($arrayfields['f.note_private']['checked'])) {
1968 // Note private
1969 print '<td class="liste_titre">';
1970 print '<input class="flat maxwidth75" type="text" name="search_note_private" value="'.dol_escape_htmltag($search_note_private).'">';
1971 print '</td>';
1972}
1973if (!empty($arrayfields['f.fk_fac_rec_source']['checked'])) {
1974 // Template Invoice
1975 print '<td class="liste_titre maxwidthonsmartphone right">';
1976 print '<input class="flat maxwidth50imp" type="text" name="search_fac_rec_source_title" id="search_fac_rec_source_title" value="'.dol_escape_htmltag($search_fac_rec_source_title).'">';
1977 print '</td>';
1978}
1979// Import key
1980if (!empty($arrayfields['f.import_key']['checked'])) {
1981 print '<td class="liste_titre maxwidthonsmartphone center">';
1982 print '<input class="flat searchstring maxwidth50" type="text" name="search_import_key" value="'.dol_escape_htmltag($search_import_key).'">';
1983 print '</td>';
1984}
1985// Dispute status
1986if (!empty($arrayfields['f.dispute_status']['checked'])) {
1987 print '<td class="liste_titre center parentonrightofpage">';
1988 $liststatus = Facture::ARRAY_OF_DISPUTE_STATUS;
1989 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1990 print $form->selectarray('search_dispute_status', $liststatus, $search_dispute_status, 1, 0, 0, '', 1, 0, 0, '', 'search_status width100 onrightofpage', 1);
1991 print '</td>';
1992}
1993// Status
1994if (!empty($arrayfields['f.fk_statut']['checked'])) {
1995 print '<td class="liste_titre center parentonrightofpage">';
1996 $liststatus = array(
1997 '0' => $langs->trans("BillShortStatusDraft"),
1998 '1' => $langs->trans("BillShortStatusNotPaid"),
1999 '2' => $langs->trans("BillShortStatusPaid"),
2000 '3' => $langs->trans("BillShortStatusCanceled")
2001 );
2002 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
2003 print $form->multiselectarray('search_status', $liststatus, $search_status, 0, 0, 'minwidth125', 1, 0);
2004 print '</td>';
2005}
2006// Action column
2007if (!$conf->main_checkbox_left_column) {
2008 print '<td class="liste_titre center maxwidthsearch actioncolumn">';
2009 $searchpicto = $form->showFilterButtons();
2010 print $searchpicto;
2011 print '</td>';
2012}
2013print "</tr>\n";
2014
2015$totalarray = array();
2016$totalarray['nbfield'] = 0;
2017
2018// Fields title label
2019// --------------------------------------------------------------------
2020print '<tr class="liste_titre">';
2021// Action column
2022if ($conf->main_checkbox_left_column) {
2023 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
2024 $totalarray['nbfield']++;
2025}
2026if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER_IN_LIST')) {
2027 print_liste_field_titre('#', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder);
2028 $totalarray['nbfield']++;
2029}
2030if (!empty($arrayfields['f.ref']['checked'])) {
2031 print_liste_field_titre($arrayfields['f.ref']['label'], $_SERVER['PHP_SELF'], 'f.ref', '', $param, '', $sortfield, $sortorder);
2032 $totalarray['nbfield']++;
2033}
2034if (!empty($arrayfields['f.ref_client']['checked'])) {
2035 print_liste_field_titre($arrayfields['f.ref_client']['label'], $_SERVER["PHP_SELF"], 'f.ref_client', '', $param, '', $sortfield, $sortorder);
2036 $totalarray['nbfield']++;
2037}
2038if (!empty($arrayfields['f.type']['checked'])) {
2039 print_liste_field_titre($arrayfields['f.type']['label'], $_SERVER["PHP_SELF"], 'f.type', '', $param, '', $sortfield, $sortorder);
2040 $totalarray['nbfield']++;
2041}
2042if (!empty($arrayfields['f.subtype']['checked'])) {
2043 print_liste_field_titre($arrayfields['f.subtype']['label'], $_SERVER["PHP_SELF"], 'f.subtype', '', $param, '', $sortfield, $sortorder);
2044}
2045if (!empty($arrayfields['f.datef']['checked'])) {
2046 print_liste_field_titre($arrayfields['f.datef']['label'], $_SERVER['PHP_SELF'], 'f.datef', '', $param, '', $sortfield, $sortorder, 'center ');
2047 $totalarray['nbfield']++;
2048}
2049if (!empty($arrayfields['f.date_valid']['checked'])) {
2050 print_liste_field_titre($arrayfields['f.date_valid']['label'], $_SERVER['PHP_SELF'], 'f.date_valid', '', $param, '', $sortfield, $sortorder, 'center ');
2051 $totalarray['nbfield']++;
2052}
2053if (!empty($arrayfields['f.date_lim_reglement']['checked'])) {
2054 print_liste_field_titre($arrayfields['f.date_lim_reglement']['label'], $_SERVER['PHP_SELF'], "f.date_lim_reglement", '', $param, '', $sortfield, $sortorder, 'center ');
2055 $totalarray['nbfield']++;
2056}
2057if (!empty($arrayfields['p.ref']['checked'])) {
2058 $langs->load("projects");
2059 print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER['PHP_SELF'], "p.ref", '', $param, '', $sortfield, $sortorder);
2060 $totalarray['nbfield']++;
2061}
2062if (!empty($arrayfields['p.title']['checked'])) {
2063 print_liste_field_titre($arrayfields['p.title']['label'], $_SERVER['PHP_SELF'], "p.title", '', $param, '', $sortfield, $sortorder);
2064 $totalarray['nbfield']++;
2065}
2066if (!empty($arrayfields['s.nom']['checked'])) {
2067 print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER['PHP_SELF'], 's.nom', '', $param, '', $sortfield, $sortorder);
2068 $totalarray['nbfield']++;
2069}
2070if (!empty($arrayfields['s.name_alias']['checked'])) {
2071 // False positive @phan-suppress-next-line PhanTypeInvalidDimOffset
2072 print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER['PHP_SELF'], 's.name_alias', '', $param, '', $sortfield, $sortorder);
2073 $totalarray['nbfield']++;
2074}
2075if (!empty($arrayfields['s2.nom']['checked'])) {
2076 print_liste_field_titre($arrayfields['s2.nom']['label'], $_SERVER['PHP_SELF'], 's2.nom', '', $param, '', $sortfield, $sortorder);
2077 $totalarray['nbfield']++;
2078}
2079if (!empty($arrayfields['s.code_client']['checked'])) {
2080 print_liste_field_titre($arrayfields['s.code_client']['label'], $_SERVER['PHP_SELF'], 's.code_client', '', $param, '', $sortfield, $sortorder);
2081 $totalarray['nbfield']++;
2082}
2083if (!empty($arrayfields['s.town']['checked'])) {
2084 print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder);
2085 $totalarray['nbfield']++;
2086}
2087if (!empty($arrayfields['s.zip']['checked'])) {
2088 print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder);
2089 $totalarray['nbfield']++;
2090}
2091if (!empty($arrayfields['state.nom']['checked'])) {
2092 print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder);
2093 $totalarray['nbfield']++;
2094}
2095if (!empty($arrayfields['country.code_iso']['checked'])) {
2096 print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center ');
2097 $totalarray['nbfield']++;
2098}
2099if (!empty($arrayfields['typent.code']['checked'])) {
2100 print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center ');
2101 $totalarray['nbfield']++;
2102}
2103if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) {
2104 print_liste_field_titre($arrayfields['f.fk_mode_reglement']['label'], $_SERVER["PHP_SELF"], "f.fk_mode_reglement", "", $param, "", $sortfield, $sortorder);
2105 $totalarray['nbfield']++;
2106}
2107if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) {
2108 print_liste_field_titre($arrayfields['f.fk_cond_reglement']['label'], $_SERVER["PHP_SELF"], "f.fk_cond_reglement", "", $param, "", $sortfield, $sortorder);
2109 $totalarray['nbfield']++;
2110}
2111if (!empty($arrayfields['ba.label']['checked'])) {
2112 print_liste_field_titre($arrayfields['ba.label']['label'], $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder);
2113 $totalarray['nbfield']++;
2114}
2115if (!empty($arrayfields['f.fk_input_reason']['checked'])) {
2116 print_liste_field_titre($arrayfields['f.fk_input_reason']['label'], $_SERVER['PHP_SELF'], 'f.fk_input_reason', '', $param, '', $sortfield, $sortorder);
2117}
2118if (!empty($arrayfields['f.module_source']['checked'])) {
2119 print_liste_field_titre($arrayfields['f.module_source']['label'], $_SERVER["PHP_SELF"], "f.module_source", "", $param, "", $sortfield, $sortorder);
2120 $totalarray['nbfield']++;
2121}
2122if (!empty($arrayfields['f.pos_source']['checked'])) {
2123 print_liste_field_titre($arrayfields['f.pos_source']['label'], $_SERVER["PHP_SELF"], "f.pos_source", "", $param, "", $sortfield, $sortorder);
2124 $totalarray['nbfield']++;
2125}
2126if (!empty($arrayfields['f.total_ht']['checked'])) {
2127 print_liste_field_titre($arrayfields['f.total_ht']['label'], $_SERVER['PHP_SELF'], 'f.total_ht', '', $param, '', $sortfield, $sortorder, 'right ');
2128 $totalarray['nbfield']++;
2129}
2130if (!empty($arrayfields['f.total_tva']['checked'])) {
2131 print_liste_field_titre($arrayfields['f.total_tva']['label'], $_SERVER['PHP_SELF'], 'f.total_tva', '', $param, '', $sortfield, $sortorder, 'right ');
2132 $totalarray['nbfield']++;
2133}
2134if (!empty($arrayfields['f.total_localtax1']['checked'])) {
2135 print_liste_field_titre($arrayfields['f.total_localtax1']['label'], $_SERVER['PHP_SELF'], 'f.localtax1', '', $param, '', $sortfield, $sortorder, 'right ');
2136 $totalarray['nbfield']++;
2137}
2138if (!empty($arrayfields['f.total_localtax2']['checked'])) {
2139 print_liste_field_titre($arrayfields['f.total_localtax2']['label'], $_SERVER['PHP_SELF'], 'f.localtax2', '', $param, '', $sortfield, $sortorder, 'right ');
2140 $totalarray['nbfield']++;
2141}
2142if (!empty($arrayfields['f.total_ttc']['checked'])) {
2143 print_liste_field_titre($arrayfields['f.total_ttc']['label'], $_SERVER['PHP_SELF'], 'f.total_ttc', '', $param, '', $sortfield, $sortorder, 'right ');
2144 $totalarray['nbfield']++;
2145}
2146if (!empty($arrayfields['u.login']['checked'])) {
2147 print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.login', '', $param, '', $sortfield, $sortorder, 'center ');
2148 $totalarray['nbfield']++;
2149}
2150if (!empty($arrayfields['sale_representative']['checked'])) {
2151 print_liste_field_titre($arrayfields['sale_representative']['label'], $_SERVER["PHP_SELF"], "", "", "$param", '', $sortfield, $sortorder);
2152 $totalarray['nbfield']++;
2153}
2154if (!empty($arrayfields['f.retained_warranty']['checked'])) {
2155 print_liste_field_titre($arrayfields['f.retained_warranty']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right ');
2156 $totalarray['nbfield']++;
2157}
2158if (!empty($arrayfields['dynamount_payed']['checked'])) {
2159 print_liste_field_titre($arrayfields['dynamount_payed']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right ');
2160 $totalarray['nbfield']++;
2161}
2162if (!empty($arrayfields['rtp']['checked'])) {
2163 print_liste_field_titre($arrayfields['rtp']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right ');
2164 $totalarray['nbfield']++;
2165}
2166if (!empty($arrayfields['f.multicurrency_code']['checked'])) {
2167 print_liste_field_titre($arrayfields['f.multicurrency_code']['label'], $_SERVER['PHP_SELF'], 'f.multicurrency_code', '', $param, '', $sortfield, $sortorder);
2168 $totalarray['nbfield']++;
2169}
2170if (!empty($arrayfields['f.multicurrency_tx']['checked'])) {
2171 print_liste_field_titre($arrayfields['f.multicurrency_tx']['label'], $_SERVER['PHP_SELF'], 'f.multicurrency_tx', '', $param, '', $sortfield, $sortorder);
2172 $totalarray['nbfield']++;
2173}
2174if (!empty($arrayfields['f.multicurrency_total_ht']['checked'])) {
2175 print_liste_field_titre($arrayfields['f.multicurrency_total_ht']['label'], $_SERVER['PHP_SELF'], 'f.multicurrency_total_ht', '', $param, '', $sortfield, $sortorder, 'right ');
2176 $totalarray['nbfield']++;
2177}
2178if (!empty($arrayfields['f.multicurrency_total_vat']['checked'])) {
2179 print_liste_field_titre($arrayfields['f.multicurrency_total_vat']['label'], $_SERVER['PHP_SELF'], 'f.multicurrency_total_tva', '', $param, '', $sortfield, $sortorder, 'right ');
2180 $totalarray['nbfield']++;
2181}
2182if (!empty($arrayfields['f.multicurrency_total_ttc']['checked'])) {
2183 print_liste_field_titre($arrayfields['f.multicurrency_total_ttc']['label'], $_SERVER['PHP_SELF'], 'f.multicurrency_total_ttc', '', $param, '', $sortfield, $sortorder, 'right ');
2184 $totalarray['nbfield']++;
2185}
2186if (!empty($arrayfields['multicurrency_dynamount_payed']['checked'])) {
2187 print_liste_field_titre($arrayfields['multicurrency_dynamount_payed']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right ');
2188 $totalarray['nbfield']++;
2189}
2190if (!empty($arrayfields['multicurrency_rtp']['checked'])) {
2191 print_liste_field_titre($arrayfields['multicurrency_rtp']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right ');
2192 $totalarray['nbfield']++;
2193}
2194if (!empty($arrayfields['total_pa']['checked'])) {
2195 print_liste_field_titre($arrayfields['total_pa']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right ');
2196 $totalarray['nbfield']++;
2197}
2198if (!empty($arrayfields['total_margin']['checked'])) {
2199 print_liste_field_titre($arrayfields['total_margin']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right ');
2200 $totalarray['nbfield']++;
2201}
2202if (!empty($arrayfields['total_margin_rate']['checked'])) {
2203 print_liste_field_titre($arrayfields['total_margin_rate']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right ');
2204 $totalarray['nbfield']++;
2205}
2206if (!empty($arrayfields['total_mark_rate']['checked'])) {
2207 print_liste_field_titre($arrayfields['total_mark_rate']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right ');
2208 $totalarray['nbfield']++;
2209}
2210// Extra fields
2211include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
2212// Hook fields
2213$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'totalarray' => &$totalarray);
2214$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
2215print $hookmanager->resPrint;
2216if (!empty($arrayfields['f.datec']['checked'])) {
2217 print_liste_field_titre($arrayfields['f.datec']['label'], $_SERVER["PHP_SELF"], "f.datec", "", $param, '', $sortfield, $sortorder, 'nowraponall center ');
2218 $totalarray['nbfield']++;
2219}
2220if (!empty($arrayfields['f.tms']['checked'])) {
2221 print_liste_field_titre($arrayfields['f.tms']['label'], $_SERVER["PHP_SELF"], "f.tms", "", $param, '', $sortfield, $sortorder, 'nowraponall center ');
2222 $totalarray['nbfield']++;
2223}
2224if (!empty($arrayfields['f.date_closing']['checked'])) {
2225 print_liste_field_titre($arrayfields['f.date_closing']['label'], $_SERVER["PHP_SELF"], "f.date_closing", "", $param, '', $sortfield, $sortorder, 'nowraponall center ');
2226 $totalarray['nbfield']++;
2227}
2228if (!empty($arrayfields['f.note_public']['checked'])) {
2229 print_liste_field_titre($arrayfields['f.note_public']['label'], $_SERVER["PHP_SELF"], "f.note_public", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
2230 $totalarray['nbfield']++;
2231}
2232if (!empty($arrayfields['f.note_private']['checked'])) {
2233 print_liste_field_titre($arrayfields['f.note_private']['label'], $_SERVER["PHP_SELF"], "f.note_private", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
2234 $totalarray['nbfield']++;
2235}
2236if (!empty($arrayfields['f.fk_fac_rec_source']['checked'])) {
2237 print_liste_field_titre($arrayfields['f.fk_fac_rec_source']['label'], $_SERVER["PHP_SELF"], "facrec.titre", "", $param, '', $sortfield, $sortorder);
2238 $totalarray['nbfield']++;
2239}
2240// Import key
2241if (!empty($arrayfields['f.import_key']['checked'])) {
2242 print_liste_field_titre($arrayfields['f.import_key']['label'], $_SERVER["PHP_SELF"], "f.import_key", "", $param, '', $sortfield, $sortorder, 'center ');
2243 $totalarray['nbfield']++;
2244}
2245// Dispute status
2246if (!empty($arrayfields['f.dispute_status']['checked'])) {
2247 print_liste_field_titre($arrayfields['f.dispute_status']['label'], $_SERVER["PHP_SELF"], "f.dispute_status,f.ref", "", $param, '', $sortfield, $sortorder, 'center ');
2248 $totalarray['nbfield']++;
2249}
2250// Status
2251if (!empty($arrayfields['f.fk_statut']['checked'])) {
2252 print_liste_field_titre($arrayfields['f.fk_statut']['label'], $_SERVER["PHP_SELF"], "f.fk_statut,f.paye,f.type", "", $param, '', $sortfield, $sortorder, 'center ');
2253 $totalarray['nbfield']++;
2254}
2255// Action column
2256if (!$conf->main_checkbox_left_column) {
2257 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'maxwidthsearch center ');
2258 $totalarray['nbfield']++;
2259}
2260
2261print "</tr>\n";
2262
2263$projectstatic = new Project($db);
2264$discount = new DiscountAbsolute($db);
2265$userstatic = new User($db);
2266
2267// Loop on record
2268// --------------------------------------------------------------------
2269if ($num > 0) {
2270 $i = 0;
2271 $savnbfield = $totalarray['nbfield'];
2272 $totalarray = array();
2273 $totalarray['nbfield'] = 0;
2274 $totalarray['val'] = array();
2275 $totalarray['val']['f.total_ht'] = 0;
2276 $totalarray['val']['f.total_tva'] = 0;
2277 $totalarray['val']['f.total_localtax1'] = 0;
2278 $totalarray['val']['f.total_localtax1'] = 0;
2279 $totalarray['val']['f.total_ttc'] = 0;
2280 $totalarray['val']['dynamount_payed'] = 0;
2281 $totalarray['val']['rtp'] = 0;
2282
2283 $typenArray = $formcompany->typent_array(1);
2284
2285 $with_margin_info = false;
2286 if (isModEnabled('margin') && (
2287 !empty($arrayfields['total_pa']['checked'])
2288 || !empty($arrayfields['total_margin']['checked'])
2289 || !empty($arrayfields['total_margin_rate']['checked'])
2290 || !empty($arrayfields['total_mark_rate']['checked'])
2291 )
2292 ) {
2293 $with_margin_info = true;
2294 }
2295 $total_ht = 0;
2296 $total_margin = 0;
2297
2298 $imaxinloop = ($limit ? min($num, $limit) : $num);
2299 while ($i < $imaxinloop) {
2300 $obj = $db->fetch_object($resql);
2301 if (empty($obj)) {
2302 break; // Should not happen
2303 }
2304
2305 $datelimit = $db->jdate($obj->datelimite);
2306
2307 $facturestatic->id = $obj->id;
2308 $facturestatic->ref = $obj->ref;
2309 $facturestatic->ref_client = $obj->ref_client; // deprecated
2310 $facturestatic->ref_customer = $obj->ref_client;
2311 $facturestatic->type = $obj->type;
2312 $facturestatic->subtype = $obj->subtype;
2313 $facturestatic->total_ht = $obj->total_ht;
2314 $facturestatic->total_tva = $obj->total_tva;
2315 $facturestatic->total_ttc = $obj->total_ttc;
2316 $facturestatic->multicurrency_code = $obj->multicurrency_code;
2317 $facturestatic->multicurrency_tx = $obj->multicurrency_tx;
2318 $facturestatic->multicurrency_total_ht = $obj->multicurrency_total_ht;
2319 $facturestatic->multicurrency_total_tva = $obj->multicurrency_total_vat;
2320 $facturestatic->multicurrency_total_ttc = $obj->multicurrency_total_ttc;
2321 $facturestatic->status = $obj->status;
2322 $facturestatic->close_code = $obj->close_code;
2323 $facturestatic->total_ttc = $obj->total_ttc;
2324 $facturestatic->paye = $obj->paye;
2325 $facturestatic->socid = $obj->fk_soc;
2326
2327 $facturestatic->date = $db->jdate($obj->datef);
2328 $facturestatic->date_validation = $db->jdate($obj->date_valid);
2329 $facturestatic->date_lim_reglement = $db->jdate($obj->datelimite);
2330
2331 $facturestatic->note_public = $obj->note_public;
2332 $facturestatic->note_private = $obj->note_private;
2333
2334 if (getDolGlobalString('INVOICE_USE_SITUATION') && getDolGlobalString('INVOICE_USE_RETAINED_WARRANTY')) {
2335 $facturestatic->retained_warranty = $obj->retained_warranty;
2336 $facturestatic->retained_warranty_date_limit = $obj->retained_warranty_date_limit;
2337 $facturestatic->situation_final = $obj->retained_warranty_date_limit;
2338 $facturestatic->situation_final = $obj->retained_warranty_date_limit;
2339 $facturestatic->situation_cycle_ref = $obj->situation_cycle_ref;
2340 $facturestatic->situation_counter = $obj->situation_counter;
2341 }
2342
2343 $facturestatic->payment_reference = $obj->payment_reference;
2344 $facturestatic->dispute_status = $obj->dispute_status;
2345
2346 $companystatic->id = $obj->socid;
2347 $companystatic->name = $obj->name;
2348 $companystatic->name_alias = $obj->alias;
2349 $companystatic->client = $obj->client;
2350 $companystatic->fournisseur = $obj->fournisseur;
2351 $companystatic->code_client = $obj->code_client;
2352 $companystatic->code_compta_client = $obj->code_compta_client;
2353 $companystatic->code_fournisseur = $obj->code_fournisseur;
2354 $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
2355 $companystatic->email = $obj->email;
2356 $companystatic->phone = $obj->phone;
2357 $companystatic->fax = $obj->fax;
2358 $companystatic->address = $obj->address;
2359 $companystatic->zip = $obj->zip;
2360 $companystatic->town = $obj->town;
2361 $companystatic->country_code = $obj->country_code;
2362
2363 $projectstatic->id = $obj->project_id;
2364 $projectstatic->ref = $obj->project_ref;
2365 $projectstatic->title = $obj->project_label;
2366
2367 $paiement = $facturestatic->getSommePaiement();
2368 $totalcreditnotes = $facturestatic->getSumCreditNotesUsed();
2369 $totaldeposits = $facturestatic->getSumDepositsUsed();
2370 $totalallpayments = $paiement + $totalcreditnotes + $totaldeposits;
2371 $remaintopay = $obj->total_ttc - $totalallpayments;
2372
2373 $multicurrency_paiement = $facturestatic->getSommePaiement(1);
2374 $multicurrency_totalcreditnotes = $facturestatic->getSumCreditNotesUsed(1);
2375 $multicurrency_totaldeposits = $facturestatic->getSumDepositsUsed(1);
2376
2377 $totalallpayments = $paiement + $totalcreditnotes + $totaldeposits;
2378 $remaintopay = price2num($facturestatic->total_ttc - $totalallpayments);
2379
2380 $multicurrency_totalpay = $multicurrency_paiement + $multicurrency_totalcreditnotes + $multicurrency_totaldeposits;
2381 $multicurrency_remaintopay = (float) price2num($facturestatic->multicurrency_total_ttc - $multicurrency_totalpay);
2382
2383 if ($facturestatic->status == Facture::STATUS_CLOSED) {
2384 $remaintopay = 0;
2385 $multicurrency_remaintopay = 0;
2386 }
2387 if ($facturestatic->type == Facture::TYPE_CREDIT_NOTE && $obj->paye == 1) { // If credit note closed, we take into account the amount not yet consumed
2388 $remaincreditnote = $discount->getAvailableDiscounts($companystatic, null, 'rc.fk_facture_source='.$facturestatic->id);
2389 $remaintopay = -$remaincreditnote;
2390 $totalallpayments = price2num($facturestatic->total_ttc - $remaintopay);
2391 $multicurrency_remaincreditnote = $discount->getAvailableDiscounts($companystatic, null, 'rc.fk_facture_source='.$facturestatic->id, 0, 0, 1);
2392 $multicurrency_remaintopay = -$multicurrency_remaincreditnote;
2393 $multicurrency_totalpay = (float) price2num($facturestatic->multicurrency_total_ttc - $multicurrency_remaintopay);
2394 }
2395
2396 $facturestatic->alreadypaid = $paiement;
2397 $facturestatic->totalpaid = $paiement;
2398 $facturestatic->totalcreditnotes = $totalcreditnotes;
2399 $facturestatic->totaldeposits = $totaldeposits;
2400
2401 $marginInfo = array();
2402 if ($with_margin_info) {
2403 $facturestatic->fetch_lines();
2404 $marginInfo = $formmargin->getMarginInfosArray($facturestatic);
2405 $total_ht += $obj->total_ht;
2406 $total_margin += $marginInfo['total_margin'];
2407 }
2408
2409 $object = $facturestatic;
2410
2411 if ($mode == 'kanban') {
2412 if ($i == 0) {
2413 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
2414 print '<div class="box-flex-container kanban">';
2415 }
2416 // Output Kanban
2417 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
2418 $selected = 0;
2419 if (in_array($object->id, $arrayofselected)) {
2420 $selected = 1;
2421 }
2422 }
2423
2424 $arraydata = array('alreadypaid' => $paiement, 'thirdparty' => $companystatic->getNomUrl(1, '', 12), 'userauthor' => $userstatic->getNomUrl(1), 'selected' => in_array($object->id, $arrayofselected));
2425 print $facturestatic->getKanbanView('', $arraydata);
2426 if ($i == ($imaxinloop - 1)) {
2427 print '</div>';
2428 print '</td></tr>';
2429 }
2430 } else {
2431 // Show line of result
2432 $j = 0;
2433 print '<tr data-rowid="'.$object->id.'" class="oddeven row-with-select status'.$object->status.((getDolGlobalInt('MAIN_FINISHED_LINES_OPACITY') == 1 && $obj->status > 1) ? ' opacitymedium' : '').'"';
2434 if ($contextpage == 'poslist') {
2435 print ' onclick="parent.$(\'#poslines\').load(\'invoice.php?action=history&placeid='.$obj->id.'\', function() {parent.$.colorbox.close();';
2436 if (strpos($obj->ref, 'PROV') !== false) {
2437 //If is a draft invoice, load var to be able to add products
2438 $place = str_replace(")", "", str_replace("(PROV-POS".$_SESSION["takeposterminal"]."-", "", $obj->ref));
2439 print 'parent.place=\''.dol_escape_js($place).'\'';
2440 }
2441 print '});"';
2442 }
2443 print '>';
2444
2445 // Action column
2446 if ($conf->main_checkbox_left_column) {
2447 print '<td class="nowrap center">';
2448 if (($massactionbutton || $massaction) && $contextpage != 'poslist') { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
2449 $selected = 0;
2450 if (in_array($obj->id, $arrayofselected)) {
2451 $selected = 1;
2452 }
2453 print '<input id="cb'.$obj->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->id.'"'.($selected ? ' checked="checked"' : '').'>';
2454 }
2455 print '</td>';
2456 if (!$i) {
2457 $totalarray['nbfield']++;
2458 }
2459 }
2460
2461 // No
2462 if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER_IN_LIST')) {
2463 print '<td>'.(($offset * $limit) + $i).'</td>';
2464 if (!$i) {
2465 $totalarray['nbfield']++;
2466 }
2467 }
2468
2469 // Ref
2470 if (!empty($arrayfields['f.ref']['checked'])) {
2471 print '<td class="nowraponall">';
2472
2473 print '<table class="nobordernopadding"><tr class="nocellnopadd">';
2474
2475 print '<td class="nobordernopadding nowraponall">';
2476 if ($contextpage == 'poslist') {
2477 print dolPrintHTML($obj->ref);
2478 } else {
2479 print $facturestatic->getNomUrl(1, '', 200, 0, '', 0, 1);
2480 }
2481
2482 $filename = dol_sanitizeFileName($obj->ref);
2483 $filepath = $conf->invoice->multidir_output[$obj->entity] ?? $conf->invoice->dir_output;
2484 $filedir = $filepath.'/'.$filename;
2485
2486 $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->id;
2487 print $formfile->getDocumentsLink($facturestatic->element, $filename, $filedir);
2488 print '</td>';
2489 print '</tr>';
2490 print '</table>';
2491
2492 print "</td>\n";
2493 if (!$i) {
2494 $totalarray['nbfield']++;
2495 }
2496 }
2497
2498 // Customer ref
2499 if (!empty($arrayfields['f.ref_client']['checked'])) {
2500 $tdcss = (getDolGlobalInt('MAIN_SHOW_GLOBAL_REF_CUSTOMER_SUPPLIER') ? 'class="minwidth400 maxwidth400"' : 'class="nowrap tdoverflowmax200"');
2501 print '<td title="'.dolPrintHTMLForAttribute($obj->ref_client).'" '.$tdcss.'>';
2502 print dol_escape_htmltag($obj->ref_client);
2503 print '</td>';
2504 if (!$i) {
2505 $totalarray['nbfield']++;
2506 }
2507 }
2508
2509 // Type
2510 if (!empty($arrayfields['f.type']['checked'])) {
2511 print '<td class="nowraponall tdoverflowmax100" title="'.$facturestatic->getLibType().'">';
2512 print $facturestatic->getLibType(2);
2513 print "</td>";
2514 if (!$i) {
2515 $totalarray['nbfield']++;
2516 }
2517 }
2518
2519 // Invoice Subtype
2520 if (!empty($arrayfields['f.subtype']['checked'])) {
2521 $labeltoshow = '';
2522 if ($facturestatic->subtype > 0) {
2523 $labeltoshow = $facturestatic->getSubtypeLabel('facture');
2524 }
2525 print '<td class="nowraponall tdoverflowmax300" title="'.$labeltoshow.'">';
2526 print $labeltoshow;
2527 print "</td>";
2528 if (!$i) {
2529 $totalarray['nbfield']++;
2530 }
2531 }
2532
2533 // Date
2534 if (!empty($arrayfields['f.datef']['checked'])) {
2535 print '<td align="center" class="nowraponall">';
2536 print dol_print_date($db->jdate($obj->datef), 'day');
2537 print '</td>';
2538 if (!$i) {
2539 $totalarray['nbfield']++;
2540 }
2541 }
2542
2543 // Date
2544 if (!empty($arrayfields['f.date_valid']['checked'])) {
2545 print '<td align="center" class="nowraponall">';
2546 print dol_print_date($db->jdate($obj->date_valid), 'day');
2547 print '</td>';
2548 if (!$i) {
2549 $totalarray['nbfield']++;
2550 }
2551 }
2552
2553 // Date limit
2554 if (!empty($arrayfields['f.date_lim_reglement']['checked'])) {
2555 print '<td align="center" class="nowraponall">'.dol_print_date($datelimit, 'day');
2556 if ($facturestatic->hasDelay()) {
2557 print img_warning($langs->trans('Alert').' - '.$langs->trans('Late'));
2558 }
2559 print '</td>';
2560 if (!$i) {
2561 $totalarray['nbfield']++;
2562 }
2563 }
2564
2565 // Project ref
2566 if (!empty($arrayfields['p.ref']['checked'])) {
2567 print '<td class="nocellnopadd nowraponall">';
2568 if ($obj->project_id > 0) {
2569 print $projectstatic->getNomUrl(1);
2570 }
2571 print '</td>';
2572 if (!$i) {
2573 $totalarray['nbfield']++;
2574 }
2575 }
2576
2577 // Project label
2578 if (!empty($arrayfields['p.title']['checked'])) {
2579 print '<td class="nowraponall">';
2580 if ($obj->project_id > 0) {
2581 print dol_escape_htmltag($projectstatic->title);
2582 }
2583 print '</td>';
2584 if (!$i) {
2585 $totalarray['nbfield']++;
2586 }
2587 }
2588
2589 // Third party
2590 if (!empty($arrayfields['s.nom']['checked'])) {
2591 print '<td class="tdoverflowmax150">';
2592 if ($contextpage == 'poslist') {
2593 print dol_escape_htmltag($companystatic->name);
2594 } else {
2595 print $companystatic->getNomUrl(1, 'customer', 0, 0, -1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1);
2596 }
2597 print '</td>';
2598 if (!$i) {
2599 $totalarray['nbfield']++;
2600 }
2601 }
2602 // Alias name
2603 if (!empty($arrayfields['s.name_alias']['checked'])) {
2604 print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($companystatic->name_alias).'">';
2605 print dol_escape_htmltag($companystatic->name_alias);
2606 print '</td>';
2607 if (!$i) {
2608 $totalarray['nbfield']++;
2609 }
2610 }
2611 // Parent company
2612 if (!empty($arrayfields['s2.nom']['checked'])) {
2613 print '<td class="tdoverflowmax200">';
2614 if ($obj->fk_parent > 0) {
2615 if (!isset($company_url_list[$obj->fk_parent])) {
2616 $companyparent = new Societe($db);
2617 $res = $companyparent->fetch($obj->fk_parent);
2618 if ($res > 0) {
2619 $company_url_list[$obj->fk_parent] = $companyparent->getNomUrl(1);
2620 }
2621 }
2622 if (isset($company_url_list[$obj->fk_parent])) {
2623 print $company_url_list[$obj->fk_parent];
2624 }
2625 }
2626 print "</td>";
2627 if (!$i) {
2628 $totalarray['nbfield']++;
2629 }
2630 }
2631 // Customer Code
2632 if (!empty($arrayfields['s.code_client']['checked'])) {
2633 print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($companystatic->code_client).'">';
2634 print dol_escape_htmltag($companystatic->code_client);
2635 print '</td>';
2636 if (!$i) {
2637 $totalarray['nbfield']++;
2638 }
2639 }
2640 // Town
2641 if (!empty($arrayfields['s.town']['checked'])) {
2642 print '<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->town).'">';
2643 print dolPrintLabel($obj->town);
2644 print '</td>';
2645 if (!$i) {
2646 $totalarray['nbfield']++;
2647 }
2648 }
2649 // Zip
2650 if (!empty($arrayfields['s.zip']['checked'])) {
2651 print '<td class="nowraponall">';
2652 print dolPrintLabel($obj->zip);
2653 print '</td>';
2654 if (!$i) {
2655 $totalarray['nbfield']++;
2656 }
2657 }
2658 // State
2659 if (!empty($arrayfields['state.nom']['checked'])) {
2660 print '<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->state_name).'">'.dol_escape_htmltag($obj->state_name)."</td>\n";
2661 if (!$i) {
2662 $totalarray['nbfield']++;
2663 }
2664 }
2665 // Country
2666 if (!empty($arrayfields['country.code_iso']['checked'])) {
2667 $tmparray = getCountry($obj->fk_pays, 'all');
2668 print '<td class="center tdoverflowmax100" title="'.dol_escape_htmltag($tmparray['label']).'">';
2669 print dolPrintLabel($tmparray['label']);
2670 print '</td>';
2671 if (!$i) {
2672 $totalarray['nbfield']++;
2673 }
2674 }
2675 // Type ent
2676 if (!empty($arrayfields['typent.code']['checked'])) {
2677 if (!is_array($typenArray) || count($typenArray) == 0) {
2678 $typenArray = $formcompany->typent_array(1);
2679 }
2680 print '<td class="center tdoverflowmax100" title="'.dolPrintHTMLForAttribute($typenArray[$obj->typent_code]).'">';
2681 if (!empty($obj->typent_code)) {
2682 print $typenArray[$obj->typent_code];
2683 }
2684 print '</td>';
2685 if (!$i) {
2686 $totalarray['nbfield']++;
2687 }
2688 }
2689 // Staff
2690 if (!empty($arrayfields['staff.code']['checked'])) {
2691 if (!is_array($conf->cache['staff']) || count($conf->cache['staff']) == 0) {
2692 $conf->cache['staff'] = $formcompany->effectif_array(1);
2693 }
2694 print '<td class="center tdoverflowmax100" title="'.dolPrintHTML($conf->cache['staff'][$obj->staff_code]).'">';
2695 print $conf->cache['staff'][$obj->staff_code];
2696 print '</td>';
2697 if (!$i) {
2698 $totalarray['nbfield']++;
2699 }
2700 }
2701
2702 // Payment mode
2703 if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) {
2704 $s = $form->form_modes_reglement($_SERVER['PHP_SELF'], $obj->fk_mode_reglement, 'none', '', -1, 0, '', 1);
2705 print '<td class="tdoverflowmax100" title="'.dol_escape_htmltag($s).'">';
2706 print $s;
2707 print '</td>';
2708 if (!$i) {
2709 $totalarray['nbfield']++;
2710 }
2711 }
2712
2713 // Payment terms
2714 if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) {
2715 $s = $form->form_conditions_reglement($_SERVER['PHP_SELF'], $obj->fk_cond_reglement, 'none', 0, '', -1, -1, 1);
2716 print '<td class="tdoverflowmax100" title="'.dol_escape_htmltag($s).'">';
2717 print $s;
2718 print '</td>';
2719 if (!$i) {
2720 $totalarray['nbfield']++;
2721 }
2722 }
2723
2724 // Bank account
2725 if (!empty($arrayfields['ba.label']['checked'])) {
2726 print '<td>';
2727 if (!empty($obj->bid)) {
2728 $accountstatic->id = $obj->bid;
2729 $accountstatic->ref = $obj->bref;
2730 $accountstatic->label = $obj->blabel;
2731 $accountstatic->number = $obj->bnumber;
2732 $accountstatic->account_number = $obj->baccount_number;
2733 $accountstatic->accountancy_journal = $obj->baccountancy_journal;
2734 print $accountstatic->getNomUrl(1);
2735 }
2736 print '</td>';
2737 if (!$i) {
2738 $totalarray['nbfield']++;
2739 }
2740 }
2741
2742 // Input channel
2743 if (!empty($arrayfields['f.fk_input_reason']['checked'])) {
2744 print '<td>';
2745 $form->formInputReason($_SERVER['PHP_SELF'], (string) $obj->fk_input_reason, 'none');
2746 print '</td>';
2747 if (!$i) {
2748 $totalarray['nbfield']++;
2749 }
2750 }
2751
2752 // Module Source
2753 if (!empty($arrayfields['f.module_source']['checked'])) {
2754 print '<td>';
2755 print dol_escape_htmltag($obj->module_source);
2756 print '</td>';
2757 if (!$i) {
2758 $totalarray['nbfield']++;
2759 }
2760 }
2761 // POS Terminal
2762 if (!empty($arrayfields['f.pos_source']['checked'])) {
2763 print '<td>';
2764 print dol_escape_htmltag($obj->pos_source);
2765 print '</td>';
2766 if (!$i) {
2767 $totalarray['nbfield']++;
2768 }
2769 }
2770
2771 // Amount HT
2772 if (!empty($arrayfields['f.total_ht']['checked'])) {
2773 print '<td class="right nowraponall"><span class="amount">'.price($obj->total_ht)."</span></td>\n";
2774 if (!$i) {
2775 $totalarray['nbfield']++;
2776 }
2777 if (!$i) {
2778 $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ht';
2779 }
2780 $totalarray['val']['f.total_ht'] += $obj->total_ht;
2781 }
2782 // Amount VAT
2783 if (!empty($arrayfields['f.total_tva']['checked'])) {
2784 print '<td class="right nowraponall amount">'.price($obj->total_tva)."</td>\n";
2785 if (!$i) {
2786 $totalarray['nbfield']++;
2787 }
2788 if (!$i) {
2789 $totalarray['pos'][$totalarray['nbfield']] = 'f.total_tva';
2790 }
2791 $totalarray['val']['f.total_tva'] += $obj->total_tva;
2792 }
2793 // Amount LocalTax1
2794 if (!empty($arrayfields['f.total_localtax1']['checked'])) {
2795 print '<td class="right nowraponall amount">'.price($obj->total_localtax1)."</td>\n";
2796 if (!$i) {
2797 $totalarray['nbfield']++;
2798 }
2799 if (!$i) {
2800 $totalarray['pos'][$totalarray['nbfield']] = 'f.total_localtax1';
2801 }
2802 $totalarray['val']['f.total_localtax1'] += $obj->total_localtax1;
2803 }
2804 // Amount LocalTax2
2805 if (!empty($arrayfields['f.total_localtax2']['checked'])) {
2806 print '<td class="right nowraponall amount">'.price($obj->total_localtax2)."</td>\n";
2807 if (!$i) {
2808 $totalarray['nbfield']++;
2809 }
2810 if (!$i) {
2811 $totalarray['pos'][$totalarray['nbfield']] = 'f.total_localtax2';
2812 }
2813 $totalarray['val']['f.total_localtax2'] += $obj->total_localtax2;
2814 }
2815 // Amount TTC
2816 if (!empty($arrayfields['f.total_ttc']['checked'])) {
2817 print '<td class="right nowraponall amount">'.price($obj->total_ttc)."</td>\n";
2818 if (!$i) {
2819 $totalarray['nbfield']++;
2820 }
2821 if (!$i) {
2822 $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ttc';
2823 }
2824 $totalarray['val']['f.total_ttc'] += $obj->total_ttc;
2825 }
2826
2827 $userstatic->id = $obj->fk_user_author;
2828 $userstatic->login = $obj->login;
2829 $userstatic->lastname = $obj->lastname;
2830 $userstatic->firstname = $obj->firstname;
2831 $userstatic->email = $obj->user_email;
2832 $userstatic->status = $obj->user_statut;
2833 $userstatic->entity = $obj->entity;
2834 $userstatic->photo = $obj->photo;
2835 $userstatic->office_phone = $obj->office_phone;
2836 $userstatic->office_fax = $obj->office_fax;
2837 $userstatic->user_mobile = $obj->user_mobile;
2838 $userstatic->job = $obj->job;
2839 $userstatic->gender = $obj->gender;
2840
2841 // Author
2842 if (!empty($arrayfields['u.login']['checked'])) {
2843 print '<td class="tdoverflowmax100">';
2844 if ($userstatic->id) {
2845 print $userstatic->getNomUrl(-1);
2846 } else {
2847 print '&nbsp;';
2848 }
2849 print "</td>\n";
2850 if (!$i) {
2851 $totalarray['nbfield']++;
2852 }
2853 }
2854
2855 if (!empty($arrayfields['sale_representative']['checked'])) {
2856 // Sales representatives
2857 print '<td>';
2858 if ($obj->socid > 0) {
2859 $listsalesrepresentatives = $companystatic->getSalesRepresentatives($user);
2860 if ($listsalesrepresentatives < 0) {
2862 }
2863 $nbofsalesrepresentative = count($listsalesrepresentatives);
2864 if ($nbofsalesrepresentative > 6) {
2865 // We print only number
2866 print $nbofsalesrepresentative;
2867 } elseif ($nbofsalesrepresentative > 0) {
2868 $j = 0;
2869 foreach ($listsalesrepresentatives as $val) {
2870 $userstatic->id = $val['id'];
2871 $userstatic->lastname = $val['lastname'];
2872 $userstatic->firstname = $val['firstname'];
2873 $userstatic->email = $val['email'];
2874 $userstatic->status = $val['statut'];
2875 $userstatic->entity = $val['entity'];
2876 $userstatic->photo = $val['photo'];
2877 $userstatic->login = $val['login'];
2878 $userstatic->office_phone = $val['office_phone'];
2879 $userstatic->office_fax = $val['office_fax'];
2880 $userstatic->user_mobile = $val['user_mobile'];
2881 $userstatic->job = $val['job'];
2882 $userstatic->gender = $val['gender'];
2883 //print '<div class="float">':
2884 print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1, '', 0, 0, 12) : $userstatic->getNomUrl(-2);
2885 $j++;
2886 if ($j < $nbofsalesrepresentative) {
2887 print ' ';
2888 }
2889 //print '</div>';
2890 }
2891 }
2892 //else print $langs->trans("NoSalesRepresentativeAffected");
2893 }
2894 print '</td>';
2895 if (!$i) {
2896 $totalarray['nbfield']++;
2897 }
2898 }
2899
2900 if (!empty($arrayfields['f.retained_warranty']['checked'])) {
2901 print '<td align="right">'.(!empty($obj->retained_warranty) ? price($obj->retained_warranty).'%' : '&nbsp;').'</td>';
2902 if (!$i) {
2903 $totalarray['nbfield']++;
2904 }
2905 }
2906
2907 if (!empty($arrayfields['dynamount_payed']['checked'])) {
2908 print '<td class="right nowraponall amount">'.(!empty($totalallpayments) ? price($totalallpayments, 0, $langs) : '&nbsp;').'</td>'; // TODO Use a denormalized field
2909 if (!$i) {
2910 $totalarray['nbfield']++;
2911 }
2912 if (!$i) {
2913 $totalarray['pos'][$totalarray['nbfield']] = 'dynamount_payed';
2914 }
2915 $totalarray['val']['dynamount_payed'] += $totalallpayments;
2916 }
2917
2918 // Pending amount
2919 if (!empty($arrayfields['rtp']['checked'])) {
2920 print '<td class="right nowraponall amount">';
2921 print(!empty($remaintopay) ? price($remaintopay, 0, $langs) : '&nbsp;');
2922 print '</td>'; // TODO Use a denormalized field
2923 if (!$i) {
2924 $totalarray['nbfield']++;
2925 }
2926 if (!$i) {
2927 $totalarray['pos'][$totalarray['nbfield']] = 'rtp';
2928 }
2929 $totalarray['val']['rtp'] += $remaintopay;
2930 }
2931
2932
2933 // Currency
2934 if (!empty($arrayfields['f.multicurrency_code']['checked'])) {
2935 if (!getDolGlobalString('MAIN_SHOW_ONLY_CODE_MULTICURRENCY') && !empty($obj->multicurrency_code)) {
2936 $title = $obj->multicurrency_code.' - '.$langs->transnoentitiesnoconv('Currency'.$obj->multicurrency_code);
2937 $label = $langs->transnoentitiesnoconv('Currency'.$obj->multicurrency_code);
2938 } else {
2939 $title = $obj->multicurrency_code;
2940 $label = $obj->multicurrency_code;
2941 }
2942 print '<td class="nowraponall tdoverflowmax125" title="'.dolPrintHTMLForAttribute($title).'">';
2943 print dolPrintHTML($label);
2944 print "</td>\n";
2945 if (!$i) {
2946 $totalarray['nbfield']++;
2947 }
2948 }
2949
2950 // Currency rate
2951 if (!empty($arrayfields['f.multicurrency_tx']['checked'])) {
2952 print '<td class="nowraponall">';
2953 $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->id, $obj->multicurrency_tx, 'none', $obj->multicurrency_code);
2954 print "</td>\n";
2955 if (!$i) {
2956 $totalarray['nbfield']++;
2957 }
2958 }
2959 // Amount HT
2960 if (!empty($arrayfields['f.multicurrency_total_ht']['checked'])) {
2961 print '<td class="right nowraponall amount">'.price($obj->multicurrency_total_ht)."</td>\n";
2962 if (!$i) {
2963 $totalarray['nbfield']++;
2964 }
2965 }
2966 // Amount VAT
2967 if (!empty($arrayfields['f.multicurrency_total_vat']['checked'])) {
2968 print '<td class="right nowraponall amount">'.price($obj->multicurrency_total_vat)."</td>\n";
2969 if (!$i) {
2970 $totalarray['nbfield']++;
2971 }
2972 }
2973 // Amount TTC
2974 if (!empty($arrayfields['f.multicurrency_total_ttc']['checked'])) {
2975 print '<td class="right nowraponall amount">'.price($obj->multicurrency_total_ttc)."</td>\n";
2976 if (!$i) {
2977 $totalarray['nbfield']++;
2978 }
2979 }
2980 // Dyn amount
2981 if (!empty($arrayfields['multicurrency_dynamount_payed']['checked'])) {
2982 print '<td class="right nowraponall amount">'.(!empty($multicurrency_totalpay) ? price($multicurrency_totalpay, 0, $langs) : '&nbsp;').'</td>'; // TODO Use a denormalized field
2983 if (!$i) {
2984 $totalarray['nbfield']++;
2985 }
2986 }
2987
2988 // Pending amount
2989 if (!empty($arrayfields['multicurrency_rtp']['checked'])) {
2990 print '<td class="right nowraponall amount">';
2991 print(!empty($multicurrency_remaintopay) ? price($multicurrency_remaintopay, 0, $langs) : '&nbsp;');
2992 print '</td>'; // TODO Use a denormalized field ?
2993 if (!$i) {
2994 $totalarray['nbfield']++;
2995 }
2996 }
2997
2998 // Total buying or cost price
2999 if (!empty($arrayfields['total_pa']['checked'])) {
3000 print '<td class="right nowrap">'.price($marginInfo['pa_total'], 0, $langs, 1, -1, 'MT').'</td>';
3001 if (!$i) {
3002 $totalarray['nbfield']++;
3003 $totalarray['pos'][$totalarray['nbfield']] = 'total_pa';
3004 }
3005 if (empty($totalarray['val']['total_pa'])) {
3006 $totalarray['val']['total_pa'] = 0;
3007 }
3008 $totalarray['val']['total_pa'] += $marginInfo['pa_total'];
3009 }
3010 // Total margin
3011 if (!empty($arrayfields['total_margin']['checked'])) {
3012 print '<td class="right nowrap">'.price($marginInfo['total_margin'], 0, $langs, 1, -1, 'MT').'</td>';
3013 if (!$i) {
3014 $totalarray['nbfield']++;
3015 $totalarray['pos'][$totalarray['nbfield']] = 'total_margin';
3016 }
3017 if (empty($totalarray['val']['total_margin'])) {
3018 $totalarray['val']['total_margin'] = 0;
3019 }
3020 $totalarray['val']['total_margin'] += $marginInfo['total_margin'];
3021 }
3022 // Total margin rate
3023 if (!empty($arrayfields['total_margin_rate']['checked'])) {
3024 print '<td class="right nowrap">'.(($marginInfo['total_margin_rate'] == '') ? '' : price($marginInfo['total_margin_rate'], 0, '', 0, 0, 2).'%').'</td>';
3025 if (!$i) {
3026 $totalarray['nbfield']++;
3027 }
3028 }
3029 // Total mark rate
3030 if (!empty($arrayfields['total_mark_rate']['checked'])) {
3031 print '<td class="right nowrap">'.(($marginInfo['total_mark_rate'] == '') ? '' : price($marginInfo['total_mark_rate'], 0, '', 0, 0, 2).'%').'</td>';
3032 if (!$i) {
3033 $totalarray['nbfield']++;
3034 $totalarray['pos'][$totalarray['nbfield']] = 'total_mark_rate';
3035 }
3036 if ($i >= $imaxinloop - 1) {
3037 if (!empty($total_ht)) {
3038 $totalarray['val']['total_mark_rate'] = price2num($total_margin * 100 / $total_ht, 'MT');
3039 } else {
3040 $totalarray['val']['total_mark_rate'] = '';
3041 }
3042 }
3043 }
3044
3045 // Extra fields
3046 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
3047 // Fields from hook
3048 $parameters = array('arrayfields' => $arrayfields, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray);
3049 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
3050 print $hookmanager->resPrint;
3051 // Date creation
3052 if (!empty($arrayfields['f.datec']['checked'])) {
3053 print '<td class="nowraponall center">';
3054 print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuserrel');
3055 print '</td>';
3056 if (!$i) {
3057 $totalarray['nbfield']++;
3058 }
3059 }
3060 // Date modification
3061 if (!empty($arrayfields['f.tms']['checked'])) {
3062 print '<td class="nowraponall center">';
3063 print dol_print_date($db->jdate($obj->date_modification), 'dayhour', 'tzuserrel');
3064 print '</td>';
3065 if (!$i) {
3066 $totalarray['nbfield']++;
3067 }
3068 }
3069 // Date closing
3070 if (!empty($arrayfields['f.date_closing']['checked'])) {
3071 print '<td class="nowraponall center">';
3072 print dol_print_date($db->jdate($obj->date_closing), 'dayhour', 'tzuserrel');
3073 print '</td>';
3074 if (!$i) {
3075 $totalarray['nbfield']++;
3076 }
3077 }
3078 // Note public
3079 if (!empty($arrayfields['f.note_public']['checked'])) {
3080 print '<td class="sensiblehtmlcontent center">';
3081 print '<div class="small lineheightsmall twolinesmax-normallineheight">'.dolPrintHTML(dolGetFirstLineOfText($obj->note_public, 5)).'</div>';
3082 print '</td>';
3083 if (!$i) {
3084 $totalarray['nbfield']++;
3085 }
3086 }
3087 // Note private
3088 if (!empty($arrayfields['f.note_private']['checked'])) {
3089 print '<td class="sensiblehtmlcontent center">';
3090 print '<div class="small lineheightsmall twolinesmax-normallineheight">'.dolPrintHTML(dolGetFirstLineOfText($obj->note_private, 5)).'</div>';
3091 print '</td>';
3092 if (!$i) {
3093 $totalarray['nbfield']++;
3094 }
3095 }
3096 // Template Invoice
3097 if (!empty($arrayfields['f.fk_fac_rec_source']['checked'])) {
3098 print '<td class="center">';
3099 if (!empty($obj->fk_fac_rec_source)) {
3100 $facrec = new FactureRec($db);
3101 $result = $facrec->fetch($obj->fk_fac_rec_source);
3102 if ($result < 0) {
3103 setEventMessages($facrec->error, $facrec->errors, 'errors');
3104 } else {
3105 print $facrec->getNomUrl();
3106 }
3107 }
3108 print '</td>';
3109 if (!$i) {
3110 $totalarray['nbfield']++;
3111 }
3112 }
3113
3114 // Import key
3115 if (!empty($arrayfields['f.import_key']['checked'])) {
3116 print '<td class="nowrap center">'.dol_escape_htmltag($obj->import_key).'</td>';
3117 if (!$i) {
3118 $totalarray['nbfield']++;
3119 }
3120 }
3121
3122 // Dispute status
3123 if (!empty($arrayfields['f.dispute_status']['checked'])) {
3124 print '<td class="nowrap center">';
3125 if ($facturestatic->dispute_status) {
3126 $liststatus = Facture::ARRAY_OF_DISPUTE_STATUS;
3127 print $langs->trans($liststatus[$facturestatic->dispute_status]['label']);
3128 }
3129 print "</td>";
3130 if (!$i) {
3131 $totalarray['nbfield']++;
3132 }
3133 }
3134
3135 // Status
3136 if (!empty($arrayfields['f.fk_statut']['checked'])) {
3137 print '<td class="nowrap center">';
3138 print $facturestatic->getLibStatut(5, $totalallpayments);
3139 print "</td>";
3140 if (!$i) {
3141 $totalarray['nbfield']++;
3142 }
3143 }
3144
3145 // Action column (Show the massaction button only when this page is not opened from the Extended POS)
3146
3147 if (!$conf->main_checkbox_left_column) {
3148 print '<td class="nowrap center">';
3149 if (($massactionbutton || $massaction) && $contextpage != 'poslist') { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
3150 $selected = 0;
3151 if (in_array($obj->id, $arrayofselected)) {
3152 $selected = 1;
3153 }
3154 print '<input id="cb'.$obj->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->id.'"'.($selected ? ' checked="checked"' : '').'>';
3155 }
3156 print '</td>';
3157 if (!$i) {
3158 $totalarray['nbfield']++;
3159 }
3160 }
3161
3162 print "</tr>\n";
3163 }
3164
3165 $i++;
3166 }
3167
3168 // Use correct digits number for totals
3169 $totalarray['val']['total_pa'] = (isset($totalarray['val']['total_pa']) ? price2num($totalarray['val']['total_pa'], 'MT') : null);
3170 $totalarray['val']['total_margin'] = (isset($totalarray['val']['total_margin']) ? price2num($totalarray['val']['total_margin'], 'MT') : null);
3171
3172 // Show total line
3173 include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
3174}
3175
3176// If no record found
3177if ($num == 0) {
3178 $colspan = 1;
3179 foreach ($arrayfields as $key => $val) {
3180 if (!empty($val['checked'])) {
3181 $colspan++;
3182 }
3183 }
3184 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
3185}
3186
3187$db->free($resql);
3188
3189$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
3190$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
3191print $hookmanager->resPrint;
3192
3193print '</table>'."\n";
3194print '</div>'."\n";
3195
3196print '</form>'."\n";
3197
3198// Show the file area only when this page is not opened from the Extended POS
3199if ($contextpage != 'poslist') {
3200 $hidegeneratedfilelistifempty = 1;
3201 if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
3202 $hidegeneratedfilelistifempty = 0;
3203 }
3204
3205 // Show list of available documents
3206 $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
3207 $urlsource .= str_replace('&amp;', '&', $param);
3208
3209 $filedir = $diroutputmassaction;
3210 $genallowed = $user->hasRight("facture", "lire");
3211 $delallowed = $user->hasRight("facture", "creer");
3212 $title = '';
3213
3214 print $formfile->showdocuments('massfilesarea_invoices', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
3215}
3216
3217// End of page
3218llxFooter();
3219$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
$totalarray
Definition list.php:501
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
Class to manage bank accounts.
Class to manage absolute discounts.
Class to manage invoices.
const TYPE_REPLACEMENT
Replacement invoice.
const STATUS_DRAFT
Draft status.
const TYPE_STANDARD
Standard invoice.
const TYPE_SITUATION
Situation invoice.
const STATUS_VALIDATED
Validated (need to be paid)
const TYPE_DEPOSIT
Deposit invoice.
const TYPE_CREDIT_NOTE
Credit note invoice.
const STATUS_CLOSED
Classified paid.
Class to manage invoice templates.
Class to manage forms for categories.
Class to build HTML component for third parties management Only common components are here.
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
Class to manage "other" html components Only common components are here.
Class to help generate other html components Only common components are here.
Class to manage payments of customer invoices.
Class to manage projects.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
getCountry($searchkey, $withcode='', $dbtouse=null, $outputlangs=null, $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
getCountriesInEEC()
Return list of countries that are inside the EEC (European Economic Community) Note: Try to keep this...
global $mysoc
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
dol_now($mode='gmt')
Return date for now.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
GETPOSTDATE($prefix, $hourTime='', $gm='auto', $saverestore='')
Helper function that combines values of a dolibarr DatePicker (such as Form\selectDate) for year,...
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
dolPrintHTML($s, $allowiframe=0, $moreallowedtags=array())
Return a string (that can be on several lines) ready to be output on a HTML page.
dolGetFirstLineOfText($text, $nboflines=1, $charset='UTF-8')
Return first line of text.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
setEventMessage($mesgs, $style='mesgs', $noduplicate=0, $attop=0)
Set event message in dol_events session object.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
natural_search($fields, $value, $mode=0, $nofirstand=0, $sqltoadd='')
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
dolPrintLabel($s, $escapeonlyhtmltags=0)
Return a string label (so on 1 line only and that should not contains any HTML) ready to be output on...
dolGetButtonTitleSeparator($moreClass="")
Add space between dolGetButtonTitle.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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...
invoice_rec_prepare_head($object)
Return array head with list of tabs to view object information.
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $nodie=0, $mode='')
Check permissions of a user to show a page and an object.