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