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