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 $totalpay = $paiementAmount + $totalcreditnotes + $totaldeposits;
426 $remaintopay = price2num($facture->total_ttc - $totalpay);
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']['totalam'] = 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 $totalpay = $paiement + $totalcreditnotes + $totaldeposits;
1914 $remaintopay = price2num($facturestatic->total_ttc - $totalpay);
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 $totalpay = 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
1934 $marginInfo = array();
1935 if ($with_margin_info === true) {
1936 $facturestatic->fetch_lines();
1937 $marginInfo = $formmargin->getMarginInfosArray($facturestatic);
1938 $total_ht += $obj->total_ht;
1939 $total_margin += $marginInfo['total_margin'];
1940 }
1941
1942 if ($mode == 'kanban') {
1943 if ($i == 0) {
1944 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
1945 print '<div class="box-flex-container kanban">';
1946 }
1947 // Output Kanban
1948 print $facturestatic->getKanbanView('', array('thirdparty'=>$companystatic->getNomUrl(1, 'company', 15), 'userauthor'=>$userstatic->getNomUrl(1), 'selected' => in_array($object->id, $arrayofselected)));
1949 if ($i == ($imaxinloop - 1)) {
1950 print '</div>';
1951 print '</td></tr>';
1952 }
1953 } else {
1954 print '<tr class="oddeven"';
1955 if ($contextpage == 'poslist') {
1956 print ' onclick="parent.$(\'#poslines\').load(\'invoice.php?action=history&placeid='.$obj->id.'\', function() {parent.$.colorbox.close();';
1957 if (strpos($obj->ref, 'PROV') !== false) {
1958 //If is a draft invoice, load var to be able to add products
1959 $place = str_replace(")", "", str_replace("(PROV-POS".$_SESSION["takeposterminal"]."-", "", $obj->ref));
1960 print 'parent.place=\''.$place.'\'';
1961 }
1962 print '});"';
1963 }
1964 print '>';
1965
1966 // Action column
1967 if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
1968 print '<td class="nowrap center">';
1969 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
1970 $selected = 0;
1971 if (in_array($obj->id, $arrayofselected)) {
1972 $selected = 1;
1973 }
1974 print '<input id="cb'.$obj->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->id.'"'.($selected ? ' checked="checked"' : '').'>';
1975 }
1976 print '</td>';
1977 if (!$i) {
1978 $totalarray['nbfield']++;
1979 }
1980 }
1981
1982 // No
1983 if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
1984 print '<td>'.(($offset * $limit) + $i).'</td>';
1985 if (!$i) {
1986 $totalarray['nbfield']++;
1987 }
1988 }
1989
1990 // Ref
1991 if (!empty($arrayfields['f.ref']['checked'])) {
1992 print '<td class="nowraponall">';
1993
1994 print '<table class="nobordernopadding"><tr class="nocellnopadd">';
1995
1996 print '<td class="nobordernopadding nowraponall">';
1997 if ($contextpage == 'poslist') {
1998 print dol_escape_htmltag($obj->ref);
1999 } else {
2000 print $facturestatic->getNomUrl(1, '', 200, 0, '', 0, 1);
2001 }
2002
2003 $filename = dol_sanitizeFileName($obj->ref);
2004 $filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($obj->ref);
2005 $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->id;
2006 print $formfile->getDocumentsLink($facturestatic->element, $filename, $filedir);
2007 print '</td>';
2008 print '</tr>';
2009 print '</table>';
2010
2011 print "</td>\n";
2012 if (!$i) {
2013 $totalarray['nbfield']++;
2014 }
2015 }
2016
2017 // Customer ref
2018 if (!empty($arrayfields['f.ref_client']['checked'])) {
2019 print '<td class="nowrap tdoverflowmax200">';
2020 print dol_escape_htmltag($obj->ref_client);
2021 print '</td>';
2022 if (!$i) {
2023 $totalarray['nbfield']++;
2024 }
2025 }
2026
2027 // Type
2028 if (!empty($arrayfields['f.type']['checked'])) {
2029 print '<td class="nowraponall tdoverflowmax100" title="'.$facturestatic->getLibType().'">';
2030 print $facturestatic->getLibType(2);
2031 print "</td>";
2032 if (!$i) {
2033 $totalarray['nbfield']++;
2034 }
2035 }
2036
2037 // Date
2038 if (!empty($arrayfields['f.datef']['checked'])) {
2039 print '<td align="center" class="nowraponall">';
2040 print dol_print_date($db->jdate($obj->datef), 'day');
2041 print '</td>';
2042 if (!$i) {
2043 $totalarray['nbfield']++;
2044 }
2045 }
2046
2047 // Date
2048 if (!empty($arrayfields['f.date_valid']['checked'])) {
2049 print '<td align="center" class="nowraponall">';
2050 print dol_print_date($db->jdate($obj->date_valid), 'day');
2051 print '</td>';
2052 if (!$i) {
2053 $totalarray['nbfield']++;
2054 }
2055 }
2056
2057 // Date limit
2058 if (!empty($arrayfields['f.date_lim_reglement']['checked'])) {
2059 print '<td align="center" class="nowraponall">'.dol_print_date($datelimit, 'day');
2060 if ($facturestatic->hasDelay()) {
2061 print img_warning($langs->trans('Alert').' - '.$langs->trans('Late'));
2062 }
2063 print '</td>';
2064 if (!$i) {
2065 $totalarray['nbfield']++;
2066 }
2067 }
2068
2069 // Project ref
2070 if (!empty($arrayfields['p.ref']['checked'])) {
2071 print '<td class="nocellnopadd nowraponall">';
2072 if ($obj->project_id > 0) {
2073 print $projectstatic->getNomUrl(1);
2074 }
2075 print '</td>';
2076 if (!$i) {
2077 $totalarray['nbfield']++;
2078 }
2079 }
2080
2081 // Project title
2082 if (!empty($arrayfields['p.title']['checked'])) {
2083 print '<td class="nowraponall">';
2084 if ($obj->project_id > 0) {
2085 print dol_escape_htmltag($projectstatic->title);
2086 }
2087 print '</td>';
2088 if (!$i) {
2089 $totalarray['nbfield']++;
2090 }
2091 }
2092
2093 // Third party
2094 if (!empty($arrayfields['s.nom']['checked'])) {
2095 print '<td class="tdoverflowmax200">';
2096 if ($contextpage == 'poslist') {
2097 print dol_escape_htmltag($companystatic->name);
2098 } else {
2099 print $companystatic->getNomUrl(1, 'customer', 0, 0, -1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1);
2100 }
2101 print '</td>';
2102 if (!$i) {
2103 $totalarray['nbfield']++;
2104 }
2105 }
2106 // Alias
2107 if (!empty($arrayfields['s.name_alias']['checked'])) {
2108 print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($companystatic->name_alias).'">';
2109 print dol_escape_htmltag($companystatic->name_alias);
2110 print '</td>';
2111 if (!$i) {
2112 $totalarray['nbfield']++;
2113 }
2114 }
2115 // Parent company
2116 if (!empty($arrayfields['s2.nom']['checked'])) {
2117 print '<td class="tdoverflowmax200">';
2118 if ($obj->fk_parent > 0) {
2119 if (!isset($company_url_list[$obj->fk_parent])) {
2120 $companyparent = new Societe($db);
2121 $res = $companyparent->fetch($obj->fk_parent);
2122 if ($res > 0) {
2123 $company_url_list[$obj->fk_parent] = $companyparent->getNomUrl(1);
2124 }
2125 }
2126 if (isset($company_url_list[$obj->fk_parent])) {
2127 print $company_url_list[$obj->fk_parent];
2128 }
2129 }
2130 print "</td>";
2131 if (!$i) {
2132 $totalarray['nbfield']++;
2133 }
2134 }
2135 // Customer Code
2136 if (!empty($arrayfields['s.code_client']['checked'])) {
2137 print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($companystatic->code_client).'">';
2138 print dol_escape_htmltag($companystatic->code_client);
2139 print '</td>';
2140 if (!$i) {
2141 $totalarray['nbfield']++;
2142 }
2143 }
2144 // Town
2145 if (!empty($arrayfields['s.town']['checked'])) {
2146 print '<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->town).'">';
2147 print dol_escape_htmltag($obj->town);
2148 print '</td>';
2149 if (!$i) {
2150 $totalarray['nbfield']++;
2151 }
2152 }
2153 // Zip
2154 if (!empty($arrayfields['s.zip']['checked'])) {
2155 print '<td class="nowraponall">';
2156 print dol_escape_htmltag($obj->zip);
2157 print '</td>';
2158 if (!$i) {
2159 $totalarray['nbfield']++;
2160 }
2161 }
2162 // State
2163 if (!empty($arrayfields['state.nom']['checked'])) {
2164 print "<td>".dol_escape_htmltag($obj->state_name)."</td>\n";
2165 if (!$i) {
2166 $totalarray['nbfield']++;
2167 }
2168 }
2169 // Country
2170 if (!empty($arrayfields['country.code_iso']['checked'])) {
2171 print '<td class="center">';
2172 $tmparray = getCountry($obj->fk_pays, 'all');
2173 print $tmparray['label'];
2174 print '</td>';
2175 if (!$i) {
2176 $totalarray['nbfield']++;
2177 }
2178 }
2179 // Type ent
2180 if (!empty($arrayfields['typent.code']['checked'])) {
2181 print '<td class="center">';
2182 if (!is_array($typenArray) || count($typenArray) == 0) {
2183 $typenArray = $formcompany->typent_array(1);
2184 }
2185 print $typenArray[$obj->typent_code];
2186 print '</td>';
2187 if (!$i) {
2188 $totalarray['nbfield']++;
2189 }
2190 }
2191 // Staff
2192 if (!empty($arrayfields['staff.code']['checked'])) {
2193 print '<td class="center">';
2194 if (!is_array($conf->cache['staff']) || count($conf->cache['staff']) == 0) {
2195 $conf->cache['staff'] = $formcompany->effectif_array(1);
2196 }
2197 print $conf->cache['staff'][$obj->staff_code];
2198 print '</td>';
2199 if (!$i) {
2200 $totalarray['nbfield']++;
2201 }
2202 }
2203
2204 // Payment mode
2205 if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) {
2206 $s = $form->form_modes_reglement($_SERVER['PHP_SELF'], $obj->fk_mode_reglement, 'none', '', -1, 0, '', 1);
2207 print '<td class="tdoverflowmax100" title="'.dol_escape_htmltag($s).'">';
2208 print $s;
2209 print '</td>';
2210 if (!$i) {
2211 $totalarray['nbfield']++;
2212 }
2213 }
2214
2215 // Payment terms
2216 if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) {
2217 $s = $form->form_conditions_reglement($_SERVER['PHP_SELF'], $obj->fk_cond_reglement, 'none', 0, '', -1, -1, 1);
2218 print '<td class="tdoverflowmax100" title="'.dol_escape_htmltag($s).'">';
2219 print $s;
2220 print '</td>';
2221 if (!$i) {
2222 $totalarray['nbfield']++;
2223 }
2224 }
2225
2226 // Module Source
2227 if (!empty($arrayfields['f.module_source']['checked'])) {
2228 print '<td>';
2229 print dol_escape_htmltag($obj->module_source);
2230 print '</td>';
2231 if (!$i) {
2232 $totalarray['nbfield']++;
2233 }
2234 }
2235
2236 // POS Terminal
2237 if (!empty($arrayfields['f.pos_source']['checked'])) {
2238 print '<td>';
2239 print dol_escape_htmltag($obj->pos_source);
2240 print '</td>';
2241 if (!$i) {
2242 $totalarray['nbfield']++;
2243 }
2244 }
2245
2246 // Amount HT
2247 if (!empty($arrayfields['f.total_ht']['checked'])) {
2248 print '<td class="right nowraponall amount">'.price($obj->total_ht)."</td>\n";
2249 if (!$i) {
2250 $totalarray['nbfield']++;
2251 }
2252 if (!$i) {
2253 $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ht';
2254 }
2255 $totalarray['val']['f.total_ht'] += $obj->total_ht;
2256 }
2257 // Amount VAT
2258 if (!empty($arrayfields['f.total_tva']['checked'])) {
2259 print '<td class="right nowraponall amount">'.price($obj->total_tva)."</td>\n";
2260 if (!$i) {
2261 $totalarray['nbfield']++;
2262 }
2263 if (!$i) {
2264 $totalarray['pos'][$totalarray['nbfield']] = 'f.total_tva';
2265 }
2266 $totalarray['val']['f.total_tva'] += $obj->total_tva;
2267 }
2268 // Amount LocalTax1
2269 if (!empty($arrayfields['f.total_localtax1']['checked'])) {
2270 print '<td class="right nowraponall amount">'.price($obj->total_localtax1)."</td>\n";
2271 if (!$i) {
2272 $totalarray['nbfield']++;
2273 }
2274 if (!$i) {
2275 $totalarray['pos'][$totalarray['nbfield']] = 'f.total_localtax1';
2276 }
2277 $totalarray['val']['f.total_localtax1'] += $obj->total_localtax1;
2278 }
2279 // Amount LocalTax2
2280 if (!empty($arrayfields['f.total_localtax2']['checked'])) {
2281 print '<td class="right nowraponall amount">'.price($obj->total_localtax2)."</td>\n";
2282 if (!$i) {
2283 $totalarray['nbfield']++;
2284 }
2285 if (!$i) {
2286 $totalarray['pos'][$totalarray['nbfield']] = 'f.total_localtax2';
2287 }
2288 $totalarray['val']['f.total_localtax2'] += $obj->total_localtax2;
2289 }
2290 // Amount TTC
2291 if (!empty($arrayfields['f.total_ttc']['checked'])) {
2292 print '<td class="right nowraponall amount">'.price($obj->total_ttc)."</td>\n";
2293 if (!$i) {
2294 $totalarray['nbfield']++;
2295 }
2296 if (!$i) {
2297 $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ttc';
2298 }
2299 $totalarray['val']['f.total_ttc'] += $obj->total_ttc;
2300 }
2301
2302 $userstatic->id = $obj->fk_user_author;
2303 $userstatic->login = $obj->login;
2304 $userstatic->lastname = $obj->lastname;
2305 $userstatic->firstname = $obj->firstname;
2306 $userstatic->email = $obj->user_email;
2307 $userstatic->statut = $obj->user_statut;
2308 $userstatic->entity = $obj->entity;
2309 $userstatic->photo = $obj->photo;
2310 $userstatic->office_phone = $obj->office_phone;
2311 $userstatic->office_fax = $obj->office_fax;
2312 $userstatic->user_mobile = $obj->user_mobile;
2313 $userstatic->job = $obj->job;
2314 $userstatic->gender = $obj->gender;
2315
2316 // Author
2317 if (!empty($arrayfields['u.login']['checked'])) {
2318 print '<td class="tdoverflowmax200">';
2319 if ($userstatic->id) {
2320 print $userstatic->getNomUrl(-1);
2321 } else {
2322 print '&nbsp;';
2323 }
2324 print "</td>\n";
2325 if (!$i) {
2326 $totalarray['nbfield']++;
2327 }
2328 }
2329
2330 if (!empty($arrayfields['sale_representative']['checked'])) {
2331 // Sales representatives
2332 print '<td>';
2333 if ($obj->socid > 0) {
2334 $listsalesrepresentatives = $companystatic->getSalesRepresentatives($user);
2335 if ($listsalesrepresentatives < 0) {
2336 dol_print_error($db);
2337 }
2338 $nbofsalesrepresentative = count($listsalesrepresentatives);
2339 if ($nbofsalesrepresentative > 6) {
2340 // We print only number
2341 print $nbofsalesrepresentative;
2342 } elseif ($nbofsalesrepresentative > 0) {
2343 $j = 0;
2344 foreach ($listsalesrepresentatives as $val) {
2345 $userstatic->id = $val['id'];
2346 $userstatic->lastname = $val['lastname'];
2347 $userstatic->firstname = $val['firstname'];
2348 $userstatic->email = $val['email'];
2349 $userstatic->statut = $val['statut'];
2350 $userstatic->entity = $val['entity'];
2351 $userstatic->photo = $val['photo'];
2352 $userstatic->login = $val['login'];
2353 $userstatic->office_phone = $val['office_phone'];
2354 $userstatic->office_fax = $val['office_fax'];
2355 $userstatic->user_mobile = $val['user_mobile'];
2356 $userstatic->job = $val['job'];
2357 $userstatic->gender = $val['gender'];
2358 //print '<div class="float">':
2359 print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1, '', 0, 0, 12) : $userstatic->getNomUrl(-2);
2360 $j++;
2361 if ($j < $nbofsalesrepresentative) {
2362 print ' ';
2363 }
2364 //print '</div>';
2365 }
2366 }
2367 //else print $langs->trans("NoSalesRepresentativeAffected");
2368 } else {
2369 print '&nbsp;';
2370 }
2371 print '</td>';
2372 if (!$i) {
2373 $totalarray['nbfield']++;
2374 }
2375 }
2376
2377 if (!empty($arrayfields['f.retained_warranty']['checked'])) {
2378 print '<td align="right">'.(!empty($obj->retained_warranty) ? price($obj->retained_warranty).'%' : '&nbsp;').'</td>';
2379 if (!$i) {
2380 $totalarray['nbfield']++;
2381 }
2382 }
2383
2384 if (!empty($arrayfields['dynamount_payed']['checked'])) {
2385 print '<td class="right nowraponall amount">'.(!empty($totalpay) ? price($totalpay, 0, $langs) : '&nbsp;').'</td>'; // TODO Use a denormalized field
2386 if (!$i) {
2387 $totalarray['nbfield']++;
2388 }
2389 if (!$i) {
2390 $totalarray['pos'][$totalarray['nbfield']] = 'totalam';
2391 }
2392 $totalarray['val']['totalam'] += $totalpay;
2393 }
2394
2395 // Pending amount
2396 if (!empty($arrayfields['rtp']['checked'])) {
2397 print '<td class="right nowraponall amount">';
2398 print (!empty($remaintopay) ? price($remaintopay, 0, $langs) : '&nbsp;');
2399 print '</td>'; // TODO Use a denormalized field
2400 if (!$i) {
2401 $totalarray['nbfield']++;
2402 }
2403 if (!$i) {
2404 $totalarray['pos'][$totalarray['nbfield']] = 'rtp';
2405 }
2406 $totalarray['val']['rtp'] += $remaintopay;
2407 }
2408
2409
2410 // Currency
2411 if (!empty($arrayfields['f.multicurrency_code']['checked'])) {
2412 print '<td class="nowraponall tdoverflowmax125" title="'.dol_escape_htmltag($obj->multicurrency_code.' - '.$langs->transnoentitiesnoconv('Currency'.$obj->multicurrency_code)).'">';
2413 if (empty($conf->global->MAIN_SHOW_ONLY_CODE_MULTICURRENCY)) {
2414 print $langs->transnoentitiesnoconv('Currency'.$obj->multicurrency_code);
2415 } else {
2416 print dol_escape_htmltag($obj->multicurrency_code);
2417 }
2418 print "</td>\n";
2419 if (!$i) {
2420 $totalarray['nbfield']++;
2421 }
2422 }
2423
2424 // Currency rate
2425 if (!empty($arrayfields['f.multicurrency_tx']['checked'])) {
2426 print '<td class="nowraponall">';
2427 $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code);
2428 print "</td>\n";
2429 if (!$i) {
2430 $totalarray['nbfield']++;
2431 }
2432 }
2433 // Amount HT
2434 if (!empty($arrayfields['f.multicurrency_total_ht']['checked'])) {
2435 print '<td class="right nowraponall amount">'.price($obj->multicurrency_total_ht)."</td>\n";
2436 if (!$i) {
2437 $totalarray['nbfield']++;
2438 }
2439 }
2440 // Amount VAT
2441 if (!empty($arrayfields['f.multicurrency_total_vat']['checked'])) {
2442 print '<td class="right nowraponall amount">'.price($obj->multicurrency_total_vat)."</td>\n";
2443 if (!$i) {
2444 $totalarray['nbfield']++;
2445 }
2446 }
2447 // Amount TTC
2448 if (!empty($arrayfields['f.multicurrency_total_ttc']['checked'])) {
2449 print '<td class="right nowraponall amount">'.price($obj->multicurrency_total_ttc)."</td>\n";
2450 if (!$i) {
2451 $totalarray['nbfield']++;
2452 }
2453 }
2454 if (!empty($arrayfields['multicurrency_dynamount_payed']['checked'])) {
2455 print '<td class="right nowraponall amount">'.(!empty($multicurrency_totalpay) ? price($multicurrency_totalpay, 0, $langs) : '&nbsp;').'</td>'; // TODO Use a denormalized field
2456 if (!$i) {
2457 $totalarray['nbfield']++;
2458 }
2459 }
2460
2461 // Pending amount
2462 if (!empty($arrayfields['multicurrency_rtp']['checked'])) {
2463 print '<td class="right nowraponall">';
2464 print (!empty($multicurrency_remaintopay) ? price($multicurrency_remaintopay, 0, $langs) : '&nbsp;');
2465 print '</td>'; // TODO Use a denormalized field ?
2466 if (!$i) {
2467 $totalarray['nbfield']++;
2468 }
2469 }
2470
2471 // Total buying or cost price
2472 if (!empty($arrayfields['total_pa']['checked'])) {
2473 print '<td class="right nowrap">'.price($marginInfo['pa_total'], 0, $langs, 1, -1, 'MT').'</td>';
2474 if (!$i) {
2475 $totalarray['nbfield']++;
2476 $totalarray['pos'][$totalarray['nbfield']] = 'total_pa';
2477 }
2478 $totalarray['val']['total_pa'] += $marginInfo['pa_total'];
2479 }
2480 // Total margin
2481 if (!empty($arrayfields['total_margin']['checked'])) {
2482 print '<td class="right nowrap">'.price($marginInfo['total_margin'], 0, $langs, 1, -1, 'MT').'</td>';
2483 if (!$i) {
2484 $totalarray['nbfield']++;
2485 $totalarray['pos'][$totalarray['nbfield']] = 'total_margin';
2486 }
2487 $totalarray['val']['total_margin'] += $marginInfo['total_margin'];
2488 }
2489 // Total margin rate
2490 if (!empty($arrayfields['total_margin_rate']['checked'])) {
2491 print '<td class="right nowrap">'.(($marginInfo['total_margin_rate'] == '') ? '' : price($marginInfo['total_margin_rate'], null, null, null, null, 2).'%').'</td>';
2492 if (!$i) {
2493 $totalarray['nbfield']++;
2494 }
2495 }
2496 // Total mark rate
2497 if (!empty($arrayfields['total_mark_rate']['checked'])) {
2498 print '<td class="right nowrap">'.(($marginInfo['total_mark_rate'] == '') ? '' : price($marginInfo['total_mark_rate'], null, null, null, null, 2).'%').'</td>';
2499 if (!$i) {
2500 $totalarray['nbfield']++;
2501 $totalarray['pos'][$totalarray['nbfield']] = 'total_mark_rate';
2502 }
2503 if ($i >= $imaxinloop - 1) {
2504 if (!empty($total_ht)) {
2505 $totalarray['val']['total_mark_rate'] = price2num($total_margin * 100 / $total_ht, 'MT');
2506 } else {
2507 $totalarray['val']['total_mark_rate'] = '';
2508 }
2509 }
2510 }
2511
2512 // Extra fields
2513 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
2514 // Fields from hook
2515 $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
2516 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
2517 print $hookmanager->resPrint;
2518 // Date creation
2519 if (!empty($arrayfields['f.datec']['checked'])) {
2520 print '<td class="nowraponall center">';
2521 print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
2522 print '</td>';
2523 if (!$i) {
2524 $totalarray['nbfield']++;
2525 }
2526 }
2527 // Date modification
2528 if (!empty($arrayfields['f.tms']['checked'])) {
2529 print '<td class="nowraponall center">';
2530 print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
2531 print '</td>';
2532 if (!$i) {
2533 $totalarray['nbfield']++;
2534 }
2535 }
2536 // Date closing
2537 if (!empty($arrayfields['f.date_closing']['checked'])) {
2538 print '<td class="nowraponall center">';
2539 print dol_print_date($db->jdate($obj->date_closing), 'dayhour', 'tzuser');
2540 print '</td>';
2541 if (!$i) {
2542 $totalarray['nbfield']++;
2543 }
2544 }
2545 // Note public
2546 if (!empty($arrayfields['f.note_public']['checked'])) {
2547 print '<td class="center">';
2548 print dol_string_nohtmltag($obj->note_public);
2549 print '</td>';
2550 if (!$i) {
2551 $totalarray['nbfield']++;
2552 }
2553 }
2554 // Note private
2555 if (!empty($arrayfields['f.note_private']['checked'])) {
2556 print '<td class="center">';
2557 print dol_string_nohtmltag($obj->note_private);
2558 print '</td>';
2559 if (!$i) {
2560 $totalarray['nbfield']++;
2561 }
2562 }
2563 // Template Invoice
2564 if (!empty($arrayfields['f.fk_fac_rec_source']['checked'])) {
2565 print '<td class="center">';
2566 if (!empty($obj->fk_fac_rec_source)) {
2567 $facrec = new FactureRec($db);
2568 $result = $facrec->fetch($obj->fk_fac_rec_source);
2569 if ($result < 0) {
2570 setEventMessages($facrec->error, $facrec->errors, 'errors');
2571 } else {
2572 print $facrec->getNomUrl();
2573 }
2574 }
2575 print '</td>';
2576 if (!$i) {
2577 $totalarray['nbfield']++;
2578 }
2579 }
2580 // Status
2581 if (!empty($arrayfields['f.fk_statut']['checked'])) {
2582 print '<td class="nowrap right">';
2583 print $facturestatic->getLibStatut(5, $paiement);
2584 print "</td>";
2585 if (!$i) {
2586 $totalarray['nbfield']++;
2587 }
2588 }
2589
2590 // Action column (Show the massaction button only when this page is not opend from the Extended POS)
2591
2592 if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
2593 print '<td class="nowrap center">';
2594 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
2595 $selected = 0;
2596 if (in_array($obj->id, $arrayofselected)) {
2597 $selected = 1;
2598 }
2599 print '<input id="cb'.$obj->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->id.'"'.($selected ? ' checked="checked"' : '').'>';
2600 }
2601 print '</td>';
2602 if (!$i) {
2603 $totalarray['nbfield']++;
2604 }
2605 }
2606
2607 print "</tr>\n";
2608 }
2609
2610 $i++;
2611 }
2612
2613 // Use correct digits number for totals
2614 $totalarray['val']['total_pa'] = (isset($totalarray['val']['total_pa']) ? price2num($totalarray['val']['total_pa'], 'MT') : null);
2615 $totalarray['val']['total_margin'] = (isset($totalarray['val']['total_margin']) ? price2num($totalarray['val']['total_margin'], 'MT') : null);
2616
2617 // Show total line
2618 include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
2619 }
2620
2621 // If no record found
2622 if ($num == 0) {
2623 $colspan = 1;
2624 foreach ($arrayfields as $key => $val) {
2625 if (!empty($val['checked'])) {
2626 $colspan++;
2627 }
2628 }
2629 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
2630 }
2631
2632 $db->free($resql);
2633
2634 $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
2635 $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
2636 print $hookmanager->resPrint;
2637
2638 print '</table>'."\n";
2639 print '</div>'."\n";
2640
2641 print '</form>'."\n";
2642
2643 // Show the file area only when this page is not opend from the Extended POS
2644 if ($contextpage != 'poslist') {
2645 $hidegeneratedfilelistifempty = 1;
2646 if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
2647 $hidegeneratedfilelistifempty = 0;
2648 }
2649
2650 // Show list of available documents
2651 $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
2652 $urlsource .= str_replace('&amp;', '&', $param);
2653
2654 $filedir = $diroutputmassaction;
2655 $genallowed = $user->hasRight("facture", "lire");
2656 $delallowed = $user->hasRight("facture", "creer");
2657 $title = '';
2658
2659 print $formfile->showdocuments('massfilesarea_invoices', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
2660 }
2661} else {
2662 dol_print_error($db);
2663}
2664
2665// End of page
2666llxFooter();
2667$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.