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