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