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