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