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