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