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