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