dolibarr 21.0.3
list.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2019 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005-2019 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2012 Marcos García <marcosgdf@gmail.com>
6 * Copyright (C) 2013-2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
7 * Copyright (C) 2015 Florian Henry <florian.henry@open-concept.pro>
8 * Copyright (C) 2016-2024 Josep Lluis Amador <joseplluis@lliuretic.cat>
9 * Copyright (C) 2016 Ferran Marcet <fmarcet@2byte.es>
10 * Copyright (C) 2017 Rui Strecht <rui.strecht@aliartalentos.com>
11 * Copyright (C) 2017 Juanjo Menent <jmenent@2byte.es>
12 * Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
13 * Copyright (C) 2020 Open-Dsi <support@open-dsi.fr>
14 * Copyright (C) 2021-2025 Frédéric France <frederic.france@free.fr>
15 * Copyright (C) 2022 Anthony Berton <anthony.berton@bb2a.fr>
16 * Copyright (C) 2023 William Mead <william.mead@manchenumerique.fr>
17 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
18 * Copyright (C) 2024 Benjamin Falière <benjamin.faliere@altairis.fr>
19 * Copyright (C) 2024 Nick Fragoulis
20 *
21 * This program is free software; you can redistribute it and/or modify
22 * it under the terms of the GNU General Public License as published by
23 * the Free Software Foundation; either version 3 of the License, or
24 * (at your option) any later version.
25 *
26 * This program is distributed in the hope that it will be useful,
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 * GNU General Public License for more details.
30 *
31 * You should have received a copy of the GNU General Public License
32 * along with this program. If not, see <https://www.gnu.org/licenses/>.
33 */
34
41// Load Dolibarr environment
42require_once '../main.inc.php';
43include_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
44require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
45require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
46require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
47require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
48require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php';
49if (isModEnabled('category')) {
50 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
51 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcategory.class.php';
52}
53
63// Load translation files required by the page
64$langs->loadLangs(array("companies", "commercial", "customers", "suppliers", "bills", "compta", "categories", "cashdesk"));
65
66
67// Get parameters
68$action = GETPOST('action', 'aZ09');
69$massaction = GETPOST('massaction', 'alpha');
70$show_files = GETPOSTINT('show_files');
71$confirm = GETPOST('confirm', 'alpha');
72$toselect = GETPOST('toselect', 'array');
73$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'thirdpartylist';
74$optioncss = GETPOST('optioncss', 'alpha');
75if ($contextpage == 'poslist') {
76 $optioncss = 'print';
77}
78$mode = GETPOST("mode", 'alpha');
79
80// search fields
81$search_all = trim(GETPOST('search_all', 'alphanohtml'));
82$search_cti = preg_replace('/^0+/', '', preg_replace('/[^0-9]/', '', GETPOST('search_cti', 'alphanohtml'))); // Phone number without any special chars
83
84$search_id = GETPOST("search_id", 'int');
85$search_nom = trim(GETPOST("search_nom", 'restricthtml'));
86$search_alias = trim(GETPOST("search_alias", 'restricthtml'));
87$search_nom_only = trim(GETPOST("search_nom_only", 'restricthtml'));
88$search_ref_ext = trim(GETPOST("search_ref_ext", 'restricthtml'));
89$search_barcode = trim(GETPOST("search_barcode", 'alpha'));
90$search_customer_code = trim(GETPOST('search_customer_code', 'alpha'));
91$search_supplier_code = trim(GETPOST('search_supplier_code', 'alpha'));
92$search_account_customer_code = trim(GETPOST('search_account_customer_code', 'alpha'));
93$search_account_supplier_code = trim(GETPOST('search_account_supplier_code', 'alpha'));
94$search_address = trim(GETPOST('search_address', 'alpha'));
95$search_zip = trim(GETPOST("search_zip", 'alpha'));
96$search_town = trim(GETPOST("search_town", 'alpha'));
97$search_state = trim(GETPOST("search_state", 'alpha'));
98$search_region = trim(GETPOST("search_region", 'alpha'));
99$search_email = trim(GETPOST('search_email', 'alpha'));
100$search_phone = trim(GETPOST('search_phone', 'alpha'));
101$search_phone_mobile = trim(GETPOST('search_phone_mobile', 'alpha'));
102$search_fax = trim(GETPOST('search_fax', 'alpha'));
103$search_url = trim(GETPOST('search_url', 'alpha'));
104$search_idprof1 = trim(GETPOST('search_idprof1', 'alpha'));
105$search_idprof2 = trim(GETPOST('search_idprof2', 'alpha'));
106$search_idprof3 = trim(GETPOST('search_idprof3', 'alpha'));
107$search_idprof4 = trim(GETPOST('search_idprof4', 'alpha'));
108$search_idprof5 = trim(GETPOST('search_idprof5', 'alpha'));
109$search_idprof6 = trim(GETPOST('search_idprof6', 'alpha'));
110$search_vat = trim(GETPOST('search_vat', 'alpha'));
111$search_sale = "";
112if (GETPOSTISARRAY('search_sale')) {
113 $search_sale = GETPOST('search_sale', 'array:int');
114} elseif (GETPOSTISSET('search_sale')) {
115 $search_sale = array(GETPOSTINT('search_sale'));
116}
117$search_categ_cus = GETPOSTINT("search_categ_cus");
118$search_categ_sup = GETPOSTINT("search_categ_sup");
119$searchCategoryCustomerOperator = GETPOSTINT('search_category_customer_operator');
120$searchCategorySupplierOperator = GETPOSTINT('search_category_supplier_operator');
121if (GETPOSTISSET('formfilteraction')) {
122 $searchCategoryCustomerOperator = GETPOST('search_category_customer_operator');
123 $searchCategorySupplierOperator = GETPOST('search_category_supplier_operator');
124} elseif (getDolGlobalString('MAIN_SEARCH_CAT_OR_BY_DEFAULT')) {
125 $searchCategoryCustomerOperator = getDolGlobalString('MAIN_SEARCH_CAT_OR_BY_DEFAULT');
126 $searchCategorySupplierOperator = getDolGlobalString('MAIN_SEARCH_CAT_OR_BY_DEFAULT');
127}
128$searchCategoryCustomerList = GETPOST('search_category_customer_list', 'array');
129if (!empty($search_categ_cus) && empty($searchCategoryCustomerList)) {
130 $searchCategoryCustomerList = array($search_categ_cus);
131}
132$searchCategorySupplierList = GETPOST('search_category_supplier_list', 'array');
133if (!empty($search_categ_sup) && empty($searchCategorySupplierList)) {
134 $searchCategorySupplierList = array($search_categ_sup);
135}
136$search_country = GETPOST("search_country", 'aZ09');
137$search_type_thirdparty = GETPOST("search_type_thirdparty", 'intcomma');
138$search_price_level = GETPOST('search_price_level', 'int');
139$search_staff = GETPOST("search_staff", 'int');
140$search_legalform = GETPOST("search_legalform", 'int');
141$search_status = GETPOST("search_status", 'intcomma');
142$search_type = GETPOST('search_type', 'alpha');
143$search_level = GETPOST("search_level", "array:alpha");
144$search_stcomm = GETPOST('search_stcomm', "array:int");
145$search_import_key = trim(GETPOST("search_import_key", "alpha"));
146$search_parent_name = trim(GETPOST('search_parent_name', 'alpha'));
147
148$search_date_creation_startmonth = GETPOSTINT('search_date_creation_startmonth');
149$search_date_creation_startyear = GETPOSTINT('search_date_creation_startyear');
150$search_date_creation_startday = GETPOSTINT('search_date_creation_startday');
151$search_date_creation_start = dol_mktime(0, 0, 0, $search_date_creation_startmonth, $search_date_creation_startday, $search_date_creation_startyear); // Use tzserver
152$search_date_creation_endmonth = GETPOSTINT('search_date_creation_endmonth');
153$search_date_creation_endyear = GETPOSTINT('search_date_creation_endyear');
154$search_date_creation_endday = GETPOSTINT('search_date_creation_endday');
155$search_date_creation_end = dol_mktime(23, 59, 59, $search_date_creation_endmonth, $search_date_creation_endday, $search_date_creation_endyear); // Use tzserver
156
157$search_date_modif_startmonth = GETPOSTINT('search_date_modif_startmonth');
158$search_date_modif_startyear = GETPOSTINT('search_date_modif_startyear');
159$search_date_modif_startday = GETPOSTINT('search_date_modif_startday');
160$search_date_modif_start = dol_mktime(0, 0, 0, $search_date_modif_startmonth, $search_date_modif_startday, $search_date_modif_startyear); // Use tzserver
161$search_date_modif_endmonth = GETPOSTINT('search_date_modif_endmonth');
162$search_date_modif_endyear = GETPOSTINT('search_date_modif_endyear');
163$search_date_modif_endday = GETPOSTINT('search_date_modif_endday');
164$search_date_modif_end = dol_mktime(23, 59, 59, $search_date_modif_endmonth, $search_date_modif_endday, $search_date_modif_endyear); // Use tzserver
165
166$type = GETPOST('type', 'alpha');
167$place = GETPOST('place', 'aZ09') ? GETPOST('place', 'aZ09') : '0'; // $place is string id of table for Bar or Restaurant
168
169$diroutputmassaction = $conf->societe->dir_output.'/temp/massgeneration/'.$user->id;
170
171// Load variable for pagination
172$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
173$sortfield = GETPOST('sortfield', 'aZ09comma');
174$sortorder = GETPOST('sortorder', 'aZ09comma');
175$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
176if (!$sortorder) {
177 $sortorder = "ASC";
178}
179if (!$sortfield) {
180 $sortfield = "s.nom";
181}
182if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
183 // If $page is not defined, or '' or -1 or if we click on clear filters
184 $page = 0;
185}
186$offset = $limit * $page;
187$pageprev = $page - 1;
188$pagenext = $page + 1;
189
190if ($type == 'c') {
191 if (empty($contextpage) || $contextpage == 'thirdpartylist') {
192 $contextpage = 'customerlist';
193 }
194 if ($search_type == '') {
195 $search_type = '1,3';
196 }
197}
198if ($type == 'p') {
199 if (empty($contextpage) || $contextpage == 'thirdpartylist') {
200 $contextpage = 'prospectlist';
201 }
202 if ($search_type == '') {
203 $search_type = '2,3';
204 }
205}
206if ($type == 't') {
207 if (empty($contextpage) || $contextpage == 'poslist') {
208 $contextpage = 'poslist';
209 }
210 if ($search_type == '') {
211 $search_type = '1,2,3';
212 }
213}
214if ($type == 'f') {
215 if (empty($contextpage) || $contextpage == 'thirdpartylist') {
216 $contextpage = 'supplierlist';
217 }
218 if ($search_type == '') {
219 $search_type = '4';
220 }
221}
222// Initialize a technical objects to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
223$object = new Societe($db);
224$extrafields = new ExtraFields($db);
225$hookmanager->initHooks(array($contextpage, 'thirdpartylist'));
226
227// Fetch optionals attributes and labels
228$extrafields->fetch_name_optionals_label($object->table_element);
229
230$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
231
232// List of fields to search into when doing a "search in all"
233$fieldstosearchall = array(
234 's.nom' => "ThirdPartyName",
235 's.name_alias' => "AliasNameShort",
236 's.code_client' => "CustomerCode",
237 's.code_fournisseur' => "SupplierCode",
238 's.code_compta' => "CustomerAccountancyCodeShort",
239 's.code_compta_fournisseur' => "SupplierAccountancyCodeShort",
240 's.zip' => "Zip",
241 's.town' => "Town",
242 's.email' => "EMail",
243 's.url' => "URL",
244 's.tva_intra' => "VATIntra",
245 's.siren' => "ProfId1",
246 's.siret' => "ProfId2",
247 's.ape' => "ProfId3",
248 's.phone' => "Phone",
249 's.phone_mobile' => "PhoneMobile",
250 's.fax' => "Fax",
251);
252if (($tmp = $langs->transnoentities("ProfId4".$mysoc->country_code)) && $tmp != "ProfId4".$mysoc->country_code && $tmp != '-') {
253 $fieldstosearchall['s.idprof4'] = 'ProfId4';
254}
255if (($tmp = $langs->transnoentities("ProfId5".$mysoc->country_code)) && $tmp != "ProfId5".$mysoc->country_code && $tmp != '-') {
256 $fieldstosearchall['s.idprof5'] = 'ProfId5';
257}
258if (($tmp = $langs->transnoentities("ProfId6".$mysoc->country_code)) && $tmp != "ProfId6".$mysoc->country_code && $tmp != '-') {
259 $fieldstosearchall['s.idprof6'] = 'ProfId6';
260}
261if (isModEnabled('barcode')) {
262 $fieldstosearchall['s.barcode'] = 'Gencod';
263}
264// Personalized search criteria. Example: $conf->global->THIRDPARTY_QUICKSEARCH_ON_FIELDS = 's.nom=ThirdPartyName;s.name_alias=AliasNameShort;s.code_client=CustomerCode'
265if (getDolGlobalString('THIRDPARTY_QUICKSEARCH_ON_FIELDS')) {
266 $fieldstosearchall = dolExplodeIntoArray($conf->global->THIRDPARTY_QUICKSEARCH_ON_FIELDS);
267}
268
269
270// Define list of fields to show into list
271$checkedcustomercode = (in_array($contextpage, array('thirdpartylist', 'customerlist', 'prospectlist', 'poslist')) ? 1 : 0);
272$checkedsuppliercode = (in_array($contextpage, array('supplierlist')) ? 1 : 0);
273$checkedcustomeraccountcode = (in_array($contextpage, array('customerlist')) ? 1 : 0);
274$checkedsupplieraccountcode = (in_array($contextpage, array('supplierlist')) ? 1 : 0);
275$checkedtypetiers = 1;
276$checkedprofid1 = 0;
277$checkedprofid2 = 0;
278$checkedprofid3 = 0;
279$checkedprofid4 = 0;
280$checkedprofid5 = 0;
281$checkedprofid6 = 0;
282//$checkedprofid4=((($tmp = $langs->transnoentities("ProfId4".$mysoc->country_code)) && $tmp != "ProfId4".$mysoc->country_code && $tmp != '-') ? 1 : 0);
283//$checkedprofid5=((($tmp = $langs->transnoentities("ProfId5".$mysoc->country_code)) && $tmp != "ProfId5".$mysoc->country_code && $tmp != '-') ? 1 : 0);
284//$checkedprofid6=((($tmp = $langs->transnoentities("ProfId6".$mysoc->country_code)) && $tmp != "ProfId6".$mysoc->country_code && $tmp != '-') ? 1 : 0);
285$checkprospectlevel = (in_array($contextpage, array('prospectlist')) ? 1 : 0);
286$checkstcomm = (in_array($contextpage, array('prospectlist')) ? 1 : 0);
287$arrayfields = array(
288 's.rowid' => array('label' => "TechnicalID", 'position' => 1, 'checked' => -1, 'enabled' => 1),
289 's.nom' => array('label' => "ThirdPartyName", 'position' => 2, 'checked' => 1),
290 's.name_alias' => array('label' => "AliasNameShort", 'position' => 3, 'checked' => 1),
291 's.ref_ext' => array('label' => "RefExt", 'position' => 4, 'checked' => -1, 'enabled' => getDolGlobalInt('MAIN_LIST_SHOW_REF_EXT')),
292 's.barcode' => array('label' => "Gencod", 'position' => 5, 'checked' => 1, 'enabled' => isModEnabled('barcode')),
293 's.code_client' => array('label' => "CustomerCodeShort", 'position' => 10, 'checked' => $checkedcustomercode),
294 's.code_fournisseur' => array('label' => "SupplierCodeShort", 'position' => 11, 'checked' => $checkedsuppliercode, 'enabled' => (isModEnabled("supplier_order") || isModEnabled("supplier_invoice"))),
295 's.code_compta' => array('label' => "CustomerAccountancyCodeShort", 'position' => 13, 'checked' => $checkedcustomeraccountcode),
296 's.code_compta_fournisseur' => array('label' => "SupplierAccountancyCodeShort", 'position' => 14, 'checked' => $checkedsupplieraccountcode, 'enabled' => (isModEnabled("supplier_order") || isModEnabled("supplier_invoice"))),
297 's.address' => array('label' => "Address", 'position' => 19, 'checked' => 0),
298 's.zip' => array('label' => "Zip", 'position' => 20, 'checked' => 1),
299 's.town' => array('label' => "Town", 'position' => 21, 'checked' => 0),
300 'state.nom' => array('label' => "State", 'position' => 22, 'checked' => 0),
301 'region.nom' => array('label' => "Region", 'position' => 23, 'checked' => 0),
302 'country.code_iso' => array('label' => "Country", 'position' => 24, 'checked' => 0),
303 's.email' => array('label' => "Email", 'position' => 25, 'checked' => 0),
304 's.url' => array('label' => "Url", 'position' => 26, 'checked' => 0),
305 's.phone' => array('label' => "Phone", 'position' => 27, 'checked' => 1),
306 's.fax' => array('label' => "Fax", 'position' => 28, 'checked' => 0),
307 'typent.code' => array('label' => "ThirdPartyType", 'position' => 29, 'checked' => $checkedtypetiers),
308 'staff.code' => array('label' => "Workforce", 'position' => 31, 'checked' => 0),
309 'legalform.code' => array('label' => 'JuridicalStatus', 'position' => 32, 'checked' => 0),
310 's.phone_mobile' => array('label' => "PhoneMobile", 'position' => 35, 'checked' => 0),
311 's.siren' => array('label' => "ProfId1Short", 'position' => 40, 'checked' => $checkedprofid1),
312 's.siret' => array('label' => "ProfId2Short", 'position' => 41, 'checked' => $checkedprofid2),
313 's.ape' => array('label' => "ProfId3Short", 'position' => 42, 'checked' => $checkedprofid3),
314 's.idprof4' => array('label' => "ProfId4Short", 'position' => 43, 'checked' => $checkedprofid4),
315 's.idprof5' => array('label' => "ProfId5Short", 'position' => 44, 'checked' => $checkedprofid5),
316 's.idprof6' => array('label' => "ProfId6Short", 'position' => 45, 'checked' => $checkedprofid6),
317 's.tva_intra' => array('label' => "VATIntraShort", 'position' => 50, 'checked' => 0),
318 'customerorsupplier' => array('label' => 'NatureOfThirdParty', 'position' => 61, 'checked' => 1),
319 's.fk_prospectlevel' => array('label' => "ProspectLevel", 'position' => 62, 'checked' => $checkprospectlevel),
320 's.fk_stcomm' => array('label' => "StatusProsp", 'position' => 63, 'checked' => $checkstcomm),
321 's2.nom' => array('label' => 'ParentCompany', 'position' => 64, 'checked' => 0),
322 's.ip' => array('type'=>'ip', 'label' => "IPAddress", 'checked' => -2, 'position' => 500),
323 's.datec' => array('label' => "DateCreation", 'checked' => 0, 'position' => 501),
324 's.tms' => array('label' => "DateModificationShort", 'checked' => 0, 'position' => 505),
325 's.note_public' => array('label' => 'NotePublic', 'checked' => 0, 'position' => 520, 'enabled' => (!getDolGlobalInt('MAIN_LIST_HIDE_PUBLIC_NOTES'))),
326 's.note_private' => array('label' => 'NotePrivate', 'checked' => 0, 'position' => 521, 'enabled' => (!getDolGlobalInt('MAIN_LIST_HIDE_PRIVATE_NOTES'))),
327 's.status' => array('label' => "Status", 'checked' => 1, 'position' => 1000),
328 's.import_key' => array('label' => "ImportId", 'checked' => 0, 'position' => 1100),
329);
330if (getDolGlobalString('PRODUIT_MULTIPRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_AND_MULTIPRICES')) {
331 $arrayfields['s.price_level'] = array('label' => "PriceLevel", 'position' => 30, 'checked' => 0);
332}
333
334// Add non object fields to fields for list
335$arrayfields['sales.representative'] = array('label' => $langs->trans("SalesRepresentatives"), 'checked' => 1, 'position' => 12);
336
337// Extra fields
338include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
339
340// @phpstan-ignore-next-line
341$object->fields = dol_sort_array($object->fields, 'position');
342$arrayfields = dol_sort_array($arrayfields, 'position');
343'@phan-var-force array<string,array{label:string,checked?:int<0,1>,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan
344
345// Security check
346$socid = GETPOSTINT('socid');
347if ($user->socid) {
348 $socid = $user->socid;
349}
350$result = restrictedArea($user, 'societe', $socid, '');
351
352$permissiontoadd = $user->hasRight('societe', 'lire');
353
354
355/*
356 * Actions
357 */
358
359if ($action == "change" && $user->hasRight('takepos', 'run')) { // Change customer for TakePOS
360 $idcustomer = GETPOSTINT('idcustomer');
361
362 // Check if draft invoice already exists, if not create it
363 $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")' AND entity IN (".getEntity('invoice').")";
364 $result = $db->query($sql);
365 $num_lines = $db->num_rows($result);
366 if ($num_lines == 0) {
367 require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
368 $invoice = new Facture($db);
369 $constforthirdpartyid = 'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"];
370 $invoice->socid = getDolGlobalInt($constforthirdpartyid);
371 $invoice->date = dol_now();
372 $invoice->module_source = 'takepos';
373 $invoice->pos_source = $_SESSION["takeposterminal"];
374 $placeid = $invoice->create($user);
375 $sql = "UPDATE ".MAIN_DB_PREFIX."facture set ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")' where rowid = ".((int) $placeid);
376 $db->query($sql);
377 }
378
379 $sql = "UPDATE ".MAIN_DB_PREFIX."facture set fk_soc=".((int) $idcustomer)." where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'";
380 $resql = $db->query($sql); ?>
381 <script>
382 console.log("Reload page invoice.php with place=<?php print $place; ?>");
383 parent.$("#poslines").load("invoice.php?place=<?php print $place; ?>", function() {
384 //parent.$("#poslines").scrollTop(parent.$("#poslines")[0].scrollHeight);
385 <?php if (!$resql) { ?>
386 alert('Error failed to update customer on draft invoice.');
387 <?php } ?>
388 parent.$.colorbox.close(); /* Close the popup */
389 });
390 </script>
391 <?php
392 exit;
393}
394
395if (GETPOST('cancel', 'alpha')) {
396 $action = 'list';
397 $massaction = '';
398}
399if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
400 $massaction = '';
401}
402
403$parameters = array('arrayfields' => &$arrayfields);
404$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
405if ($reshook < 0) {
406 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
407}
408
409if (empty($reshook)) {
410 // Selection of new fields
411 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
412
413 // Purge search criteria
414 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
415 $search_id = '';
416 $search_nom = '';
417 $search_alias = '';
418 $search_ref_ext = '';
419 $search_categ_cus = 0;
420 $search_categ_sup = 0;
421 $searchCategoryCustomerOperator = 0;
422 $searchCategorySupplierOperator = 0;
423 $searchCategoryCustomerList = array();
424 $searchCategorySupplierList = array();
425 $search_sale = array();
426 $search_barcode = "";
427 $search_customer_code = '';
428 $search_supplier_code = '';
429 $search_account_customer_code = '';
430 $search_account_supplier_code = '';
431 $search_address = '';
432 $search_zip = "";
433 $search_town = "";
434 $search_state = "";
435 $search_region = "";
436 $search_country = '';
437 $search_email = '';
438 $search_phone = '';
439 $search_phone_mobile = '';
440 $search_fax = '';
441 $search_url = '';
442 $search_idprof1 = '';
443 $search_idprof2 = '';
444 $search_idprof3 = '';
445 $search_idprof4 = '';
446 $search_idprof5 = '';
447 $search_idprof6 = '';
448 $search_vat = '';
449 $search_type = '';
450 $search_price_level = '';
451 $search_type_thirdparty = '';
452 $search_staff = '';
453 $search_legalform = '';
454 $search_date_creation_startmonth = "";
455 $search_date_creation_startyear = "";
456 $search_date_creation_startday = "";
457 $search_date_creation_start = "";
458 $search_date_creation_endmonth = "";
459 $search_date_creation_endyear = "";
460 $search_date_creation_endday = "";
461 $search_date_creation_end = "";
462 $search_date_modif_startmonth = "";
463 $search_date_modif_startyear = "";
464 $search_date_modif_startday = "";
465 $search_date_modif_start = "";
466 $search_date_modif_endmonth = "";
467 $search_date_modif_endyear = "";
468 $search_date_modif_endday = "";
469 $search_date_modif_end = "";
470 $search_status = -1;
471 $search_stcomm = '';
472 $search_level = '';
473 $search_parent_name = '';
474 $search_import_key = '';
475
476 $search_all = '';
477 $toselect = array();
478 $search_array_options = array();
479 }
480
481 // Mass actions
482 $objectclass = 'Societe';
483 $objectlabel = 'ThirdParty';
484 $permissiontoread = $user->hasRight('societe', 'lire');
485 $permissiontodelete = $user->hasRight('societe', 'supprimer');
486 $permissiontoadd = $user->hasRight("societe", "creer");
487 $uploaddir = $conf->societe->dir_output;
488
489 global $error;
490 include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
491
492 if (!$error && $action == 'setstcomm' && $permissiontoadd) {
493 $object = new Client($db);
494 $result = $object->fetch(GETPOST('stcommsocid'));
495 $object->stcomm_id = dol_getIdFromCode($db, GETPOST('stcomm', 'alpha'), 'c_stcomm');
496 $result = $object->update($object->id, $user);
497 if ($result < 0) {
498 setEventMessages($object->error, $object->errors, 'errors');
499 }
500
501 $action = '';
502 }
503}
504
505if ($search_status == '' && empty($search_all)) {
506 $search_status = 1; // display active thirdparty only by default
507}
508
509
510
511/*
512 * View
513 */
514
515/*
516 REM: Rules on permissions to see thirdparties
517 Internal or External user + No permission to see customers => See nothing
518 Internal user socid=0 + Permission to see ALL customers => See all thirdparties
519 Internal user socid=0 + No permission to see ALL customers => See only thirdparties linked to user that are sale representative
520 External user socid=x + Permission to see ALL customers => Can see only himself
521 External user socid=x + No permission to see ALL customers => Can see only himself
522 */
523
524$form = new Form($db);
525$formother = new FormOther($db);
526$companystatic = new Societe($db);
527$companyparent = new Societe($db);
528$formcompany = new FormCompany($db);
529$prospectstatic = new Client($db);
530$prospectstatic->client = 2;
531$prospectstatic->loadCacheOfProspStatus();
532
533$now = dol_now();
534
535$title = $langs->trans("ThirdParties");
536if ($type == 'c' && (empty($search_type) || ($search_type == '1,3'))) {
537 $title = $langs->trans("Customers");
538}
539if ($type == 'p' && (empty($search_type) || ($search_type == '2,3'))) {
540 $title = $langs->trans("Prospects");
541}
542if ($type == 'f' && (empty($search_type) || ($search_type == '4'))) {
543 $title = $langs->trans("Suppliers");
544}
545$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
546
547
548// Select every potentials, and note each potentials which fit in search parameters
549$tab_level = array();
550$sql = "SELECT code, label, sortorder";
551$sql .= " FROM ".MAIN_DB_PREFIX."c_prospectlevel";
552$sql .= " WHERE active > 0";
553$sql .= " ORDER BY sortorder";
554$resql = $db->query($sql);
555if ($resql) {
556 while ($obj = $db->fetch_object($resql)) {
557 // Compute level text
558 $level = $langs->trans($obj->code);
559 if ($level == $obj->code) {
560 $level = $langs->trans($obj->label);
561 }
562 $tab_level[$obj->code] = $level;
563 }
564} else {
565 dol_print_error($db);
566}
567
568// Build and execute select
569// --------------------------------------------------------------------
570$sql = "SELECT s.rowid, s.nom as name, s.name_alias, s.ref_ext, s.barcode, s.address, s.town, s.zip, s.datec, s.code_client, s.code_fournisseur, s.logo,";
571$sql .= " s.entity,";
572$sql .= " st.libelle as stcomm, st.picto as stcomm_picto, s.fk_stcomm as stcomm_id, s.fk_prospectlevel, s.prefix_comm, s.client, s.fournisseur, s.canvas, s.status as status, s.note_private, s.note_public,";
573$sql .= " s.email, s.phone, s.phone_mobile, s.fax, s.url, s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4 as idprof4, s.idprof5 as idprof5, s.idprof6 as idprof6, s.tva_intra, s.fk_pays,";
574$sql .= " s.ip, s.tms as date_modification, s.datec as date_creation, s.import_key,";
575$sql .= " s.code_compta, s.code_compta_fournisseur, s.parent as fk_parent,s.price_level,";
576$sql .= " s2.nom as name2,";
577$sql .= " typent.code as typent_code,";
578$sql .= " staff.code as staff_code,";
579$sql .= " s.fk_forme_juridique as legalform_code,";
580$sql .= " country.code as country_code, country.label as country_label,";
581$sql .= " state.code_departement as state_code, state.nom as state_name,";
582$sql .= " region.code_region as region_code, region.nom as region_name";
583// Add fields from extrafields
584if (!empty($extrafields->attributes[$object->table_element]['label'])) {
585 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
586 $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
587 }
588}
589// Add fields from hooks
590$parameters = array();
591$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
592$sql .= $hookmanager->resPrint;
593$sql = preg_replace('/,\s*$/', '', $sql);
594//$sql .= ", COUNT(rc.rowid) as anotherfield";
595
596$sqlfields = $sql; // $sql fields to remove for count total
597
598$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
599$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s2 ON s.parent = s2.rowid";
600if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
601 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (s.rowid = ef.fk_object)";
602}
603
604$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)";
605$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)";
606$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_effectif as staff on (staff.id = s.fk_effectif)";
607//$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_forme_juridique as legalform on (legalform.rowid = s.fk_forme_juridique)";
608$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)";
609$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as region on (region.code_region = state.fk_region)";
610$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."c_stcomm as st ON s.fk_stcomm = st.id";
611// Add table from hooks
612$parameters = array();
613$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
614$sql .= $hookmanager->resPrint;
615$sql .= " WHERE s.entity IN (".getEntity('societe').")";
616if (!$user->hasRight('fournisseur', 'lire')) {
617 $sql .= " AND (s.fournisseur <> 1 OR s.client <> 0)"; // client=0, fournisseur=0 must be visible
618}
619
620// Force the sales representative if they don't have permissions
621if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
622 $search_sale = array($user->id);
623}
624// Search on sale representative
625if (!empty($search_sale) && $search_sale != '-1') {
626 $search_sale_req = array_filter($search_sale, function (string $value): bool {
627 $value = intval($value);
628 return $value >= 0;
629 });
630
631 $search_sale_req = implode(',', $search_sale_req);
632
633 if (count($search_sale) == 1 && in_array('-2', $search_sale)) {
634 $sql .= " AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = s.rowid)";
635 } elseif (count($search_sale) > 0 && !in_array('-2', $search_sale)) {
636 $sql .= " AND EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = s.rowid AND sc.fk_user IN (".$db->sanitize($search_sale_req)."))";
637 } elseif (count($search_sale) > 0 && in_array('-2', $search_sale)) {
638 $sql .= " AND (EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = s.rowid AND sc.fk_user IN (".$db->sanitize($search_sale_req)."))";
639 $sql .= " OR NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = s.rowid))";
640 }
641}
642
643// Search for tag/category ($searchCategoryCustomerList is an array of ID)
644if (!empty($searchCategoryCustomerList)) {
645 $searchCategoryCustomerSqlList = array();
646 $listofcategoryid = '';
647 foreach ($searchCategoryCustomerList as $searchCategoryCustomer) {
648 if (intval($searchCategoryCustomer) == -2) {
649 $searchCategoryCustomerSqlList[] = "NOT EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe as ck WHERE s.rowid = ck.fk_soc)";
650 } elseif (intval($searchCategoryCustomer) > 0) {
651 if ($searchCategoryCustomerOperator == 0) {
652 $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).")";
653 } else {
654 $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryCustomer);
655 }
656 }
657 }
658 if ($listofcategoryid) {
659 $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)."))";
660 }
661 if ($searchCategoryCustomerOperator == 1) {
662 if (!empty($searchCategoryCustomerSqlList)) {
663 $sql .= " AND (".implode(' OR ', $searchCategoryCustomerSqlList).")";
664 }
665 } else {
666 if (!empty($searchCategoryCustomerSqlList)) {
667 $sql .= " AND (".implode(' AND ', $searchCategoryCustomerSqlList).")";
668 }
669 }
670}
671
672// Search for tag/category ($searchCategorySupplierList is an array of ID)
673if (!empty($searchCategorySupplierList)) {
674 $searchCategorySupplierSqlList = array();
675 $listofcategoryid = '';
676 foreach ($searchCategorySupplierList as $searchCategorySupplier) {
677 if (intval($searchCategorySupplier) == -2) {
678 $searchCategorySupplierSqlList[] = "NOT EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_fournisseur as ck WHERE s.rowid = ck.fk_soc)";
679 } elseif (intval($searchCategorySupplier) > 0) {
680 if ($searchCategorySupplierOperator == 0) {
681 $searchCategorySupplierSqlList[] = " EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_fournisseur as ck WHERE s.rowid = ck.fk_soc AND ck.fk_categorie = ".((int) $searchCategorySupplier).")";
682 } else {
683 $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategorySupplier);
684 }
685 }
686 }
687 if ($listofcategoryid) {
688 $searchCategorySupplierSqlList[] = " EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_fournisseur as ck WHERE s.rowid = ck.fk_soc AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))";
689 }
690 if ($searchCategorySupplierOperator == 1) {
691 if (!empty($searchCategorySupplierSqlList)) {
692 $sql .= " AND (".implode(' OR ', $searchCategorySupplierSqlList).")";
693 }
694 } else {
695 if (!empty($searchCategorySupplierSqlList)) {
696 $sql .= " AND (".implode(' AND ', $searchCategorySupplierSqlList).")";
697 }
698 }
699}
700if ($search_all) {
701 $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
702}
703if (strlen($search_cti)) {
704 $sql .= natural_search('s.phone', $search_cti);
705}
706if ($search_id > 0) {
707 $sql .= natural_search("s.rowid", $search_id, 1);
708}
709if (empty($arrayfields['s.name_alias']['checked']) && $search_nom) {
710 $sql .= natural_search(array("s.nom", "s.name_alias"), $search_nom);
711} else {
712 if ($search_nom) {
713 $sql .= natural_search("s.nom", $search_nom);
714 }
715
716 if ($search_alias) {
717 $sql .= natural_search("s.name_alias", $search_alias);
718 }
719}
720if ($search_nom_only) {
721 $sql .= natural_search("s.nom", $search_nom_only);
722}
723if ($search_ref_ext) {
724 $sql .= natural_search("s.ref_ext", $search_ref_ext);
725}
726if ($search_customer_code) {
727 $sql .= natural_search("s.code_client", $search_customer_code);
728}
729if ($search_supplier_code) {
730 $sql .= natural_search("s.code_fournisseur", $search_supplier_code);
731}
732if ($search_account_customer_code) {
733 $sql .= natural_search("s.code_compta", $search_account_customer_code);
734}
735if ($search_account_supplier_code) {
736 $sql .= natural_search("s.code_compta_fournisseur", $search_account_supplier_code);
737}
738if ($search_address) {
739 $sql .= natural_search('s.address', $search_address);
740}
741if (strlen($search_zip)) {
742 $sql .= natural_search("s.zip", $search_zip);
743}
744if ($search_town) {
745 $sql .= natural_search("s.town", $search_town);
746}
747if ($search_state) {
748 $sql .= natural_search("state.nom", $search_state);
749}
750if ($search_region) {
751 $sql .= natural_search("region.nom", $search_region);
752}
753if ($search_country && $search_country != '-1') {
754 $sql .= " AND s.fk_pays IN (".$db->sanitize($search_country).')';
755}
756if ($search_email) {
757 $sql .= natural_search("s.email", $search_email);
758}
759if (strlen($search_phone)) {
760 $sql .= natural_search("s.phone", $search_phone);
761}
762if (strlen($search_phone_mobile)) {
763 $sql .= natural_search("s.phone_mobile", $search_phone_mobile);
764}
765if (strlen($search_fax)) {
766 $sql .= natural_search("s.fax", $search_fax);
767}
768if ($search_url) {
769 $sql .= natural_search("s.url", $search_url);
770}
771if (strlen($search_idprof1)) {
772 $sql .= natural_search("s.siren", $search_idprof1);
773}
774if (strlen($search_idprof2)) {
775 $sql .= natural_search("s.siret", $search_idprof2);
776}
777if (strlen($search_idprof3)) {
778 $sql .= natural_search("s.ape", $search_idprof3);
779}
780if (strlen($search_idprof4)) {
781 $sql .= natural_search("s.idprof4", $search_idprof4);
782}
783if (strlen($search_idprof5)) {
784 $sql .= natural_search("s.idprof5", $search_idprof5);
785}
786if (strlen($search_idprof6)) {
787 $sql .= natural_search("s.idprof6", $search_idprof6);
788}
789if (strlen($search_vat)) {
790 $sql .= natural_search("s.tva_intra", $search_vat);
791}
792// Filter on type of thirdparty
793if ($search_type > 0 && in_array($search_type, array('1,3', '1,2,3', '2,3'))) {
794 $sql .= " AND s.client IN (".$db->sanitize($search_type).")";
795}
796if ($search_type > 0 && in_array($search_type, array('4'))) {
797 $sql .= " AND s.fournisseur = 1";
798}
799if ($search_type == '0') {
800 $sql .= " AND s.client = 0 AND s.fournisseur = 0";
801}
802if ($search_status != '' && $search_status >= 0) {
803 $sql .= natural_search("s.status", $search_status, 2);
804}
805if (isModEnabled('barcode') && $search_barcode) {
806 $sql .= natural_search("s.barcode", $search_barcode);
807}
808if ($search_price_level && $search_price_level != '-1') {
809 $sql .= natural_search("s.price_level", $search_price_level, 2);
810}
811if ($search_type_thirdparty && $search_type_thirdparty > 0) {
812 $sql .= natural_search("s.fk_typent", $search_type_thirdparty, 2);
813}
814if (!empty($search_staff) && $search_staff != '-1') {
815 $sql .= natural_search("s.fk_effectif", $search_staff, 2);
816}
817if (!empty($search_legalform) && $search_legalform != '-1') {
818 $sql .= natural_search("s.fk_forme_juridique", $search_legalform, 2);
819}
820if ($search_parent_name) {
821 $sql .= natural_search("s2.nom", $search_parent_name);
822}
823if ($search_level) {
824 $sql .= natural_search("s.fk_prospectlevel", implode(',', $search_level), 3);
825}
826if ($search_stcomm) {
827 $sql .= natural_search("s.fk_stcomm", implode(',', $search_stcomm), 2);
828}
829if ($search_import_key) {
830 $sql .= natural_search("s.import_key", $search_import_key);
831}
832if ($search_date_creation_start) {
833 $sql .= " AND s.datec >= '".$db->idate($search_date_creation_start)."'";
834}
835if ($search_date_creation_end) {
836 $sql .= " AND s.datec <= '".$db->idate($search_date_creation_end)."'";
837}
838
839if ($search_date_modif_start) {
840 $sql .= " AND s.tms >= '".$db->idate($search_date_modif_start)."'";
841}
842if ($search_date_modif_end) {
843 $sql .= " AND s.tms <= '".$db->idate($search_date_modif_end)."'";
844}
845
846// Add where from extra fields
847include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
848// Add where from hooks
849$parameters = array('socid' => $socid);
850$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
851if (empty($reshook)) {
852 if ($socid) {
853 $sql .= " AND s.rowid = ".((int) $socid);
854 }
855}
856$sql .= $hookmanager->resPrint;
857
858// Add GroupBy from hooks
859$parameters = array('fieldstosearchall' => $fieldstosearchall);
860$reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
861$sql .= $hookmanager->resPrint;
862
863// Count total nb of records
864$nbtotalofrecords = '';
865if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
866 /* The fast and low memory method to get and count full list converts the sql into a sql count */
867 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
868 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
869 $resql = $db->query($sqlforcount);
870 if ($resql) {
871 $objforcount = $db->fetch_object($resql);
872 $nbtotalofrecords = $objforcount->nbtotalofrecords;
873 } else {
874 dol_print_error($db);
875 }
876
877 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
878 $page = 0;
879 $offset = 0;
880 }
881 $db->free($resql);
882}
883
884// Complete request and execute it with limit
885$sql .= $db->order($sortfield, $sortorder);
886if ($limit) {
887 $sql .= $db->plimit($limit + 1, $offset);
888}
889$resql = $db->query($sql);
890if (!$resql) {
891 dol_print_error($db);
892 exit;
893}
894
895$num = $db->num_rows($resql);
896
897
898// Direct jump if only one record found
899if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && ($search_all != '' || $search_cti != '') && $action != 'list') {
900 $obj = $db->fetch_object($resql);
901 $id = $obj->rowid;
902 if (getDolGlobalString('SOCIETE_ON_SEARCH_AND_LIST_GO_ON_CUSTOMER_OR_SUPPLIER_CARD')) {
903 if ($obj->client > 0) {
904 header("Location: ".DOL_URL_ROOT.'/comm/card.php?socid='.$id);
905 exit;
906 }
907 if ($obj->fournisseur > 0) {
908 header("Location: ".DOL_URL_ROOT.'/fourn/card.php?socid='.$id);
909 exit;
910 }
911 }
912
913 header("Location: ".DOL_URL_ROOT.'/societe/card.php?socid='.$id);
914 exit;
915}
916
917// Output page
918// --------------------------------------------------------------------
919
920$paramsCat = '';
921foreach ($searchCategoryCustomerList as $searchCategoryCustomer) {
922 $paramsCat .= "&search_category_customer_list[]=".urlencode($searchCategoryCustomer);
923}
924foreach ($searchCategorySupplierList as $searchCategorySupplier) {
925 $paramsCat .= "&search_category_supplier_list[]=".urlencode($searchCategorySupplier);
926}
927
928llxHeader('', $title, $help_url, '', 0, 0, array(), array(), $paramsCat, 'bodyforlist');
929
930
931$arrayofselected = is_array($toselect) ? $toselect : array();
932
933$param = '';
934if (!empty($mode)) {
935 $param .= '&mode='.urlencode($mode);
936}
937if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
938 $param .= '&contextpage='.urlencode($contextpage);
939}
940if ($limit > 0 && $limit != $conf->liste_limit) {
941 $param .= '&limit='.((int) $limit);
942}
943if ($optioncss != '') {
944 $param .= '&optioncss='.urlencode($optioncss);
945}
946if ($search_all != '') {
947 $param = "&search_all=".urlencode($search_all);
948}
949if ($search_categ_cus > 0) {
950 $param .= '&search_categ_cus='.urlencode((string) ($search_categ_cus));
951}
952if ($search_categ_sup > 0) {
953 $param .= '&search_categ_sup='.urlencode((string) ($search_categ_sup));
954}
955if ($searchCategoryCustomerOperator == 1) {
956 $param .= "&search_category_customer_operator=".urlencode((string) ($searchCategoryCustomerOperator));
957}
958if ($searchCategorySupplierOperator == 1) {
959 $param .= "&search_category_supplier_operator=".urlencode((string) ($searchCategorySupplierOperator));
960}
961foreach ($searchCategoryCustomerList as $searchCategoryCustomer) {
962 $param .= "&search_category_customer_list[]=".urlencode($searchCategoryCustomer);
963}
964foreach ($searchCategorySupplierList as $searchCategorySupplier) {
965 $param .= "&search_category_supplier_list[]=".urlencode($searchCategorySupplier);
966}
967if (is_array($search_sale)) {
968 foreach ($search_sale as $sale_id) {
969 $param .= '&search_sale[]=' . urlencode($sale_id);
970 }
971}
972if ($search_id > 0) {
973 $param .= "&search_id=".((int) $search_id);
974}
975if ($search_nom != '') {
976 $param .= "&search_nom=".urlencode($search_nom);
977}
978if ($search_alias != '') {
979 $param .= "&search_alias=".urlencode($search_alias);
980}
981if ($search_ref_ext != '') {
982 $param .= "&search_ref_ext=".urlencode($search_ref_ext);
983}
984if ($search_address != '') {
985 $param .= '&search_address='.urlencode($search_address);
986}
987if ($search_zip != '') {
988 $param .= "&search_zip=".urlencode($search_zip);
989}
990if ($search_town != '') {
991 $param .= "&search_town=".urlencode($search_town);
992}
993if ($search_phone != '') {
994 $param .= "&search_phone=".urlencode($search_phone);
995}
996if ($search_phone_mobile != '') {
997 $param .= "&search_phone_mobile=".urlencode($search_phone_mobile);
998}
999if ($search_fax != '') {
1000 $param .= "&search_fax=".urlencode($search_fax);
1001}
1002if ($search_email != '') {
1003 $param .= "&search_email=".urlencode($search_email);
1004}
1005if ($search_url != '') {
1006 $param .= "&search_url=".urlencode($search_url);
1007}
1008if ($search_state != '') {
1009 $param .= "&search_state=".urlencode($search_state);
1010}
1011if ($search_region != '') {
1012 $param .= "&search_region=".urlencode($search_region);
1013}
1014if ($search_country != '') {
1015 $param .= "&search_country=".urlencode($search_country);
1016}
1017if ($search_customer_code != '') {
1018 $param .= "&search_customer_code=".urlencode($search_customer_code);
1019}
1020if ($search_supplier_code != '') {
1021 $param .= "&search_supplier_code=".urlencode($search_supplier_code);
1022}
1023if ($search_account_customer_code != '') {
1024 $param .= "&search_account_customer_code=".urlencode($search_account_customer_code);
1025}
1026if ($search_account_supplier_code != '') {
1027 $param .= "&search_account_supplier_code=".urlencode($search_account_supplier_code);
1028}
1029if ($search_barcode != '') {
1030 $param .= "&search_barcode=".urlencode($search_barcode);
1031}
1032if ($search_idprof1 != '') {
1033 $param .= '&search_idprof1='.urlencode($search_idprof1);
1034}
1035if ($search_idprof2 != '') {
1036 $param .= '&search_idprof2='.urlencode($search_idprof2);
1037}
1038if ($search_idprof3 != '') {
1039 $param .= '&search_idprof3='.urlencode($search_idprof3);
1040}
1041if ($search_idprof4 != '') {
1042 $param .= '&search_idprof4='.urlencode($search_idprof4);
1043}
1044if ($search_idprof5 != '') {
1045 $param .= '&search_idprof5='.urlencode($search_idprof5);
1046}
1047if ($search_idprof6 != '') {
1048 $param .= '&search_idprof6='.urlencode($search_idprof6);
1049}
1050if ($search_vat != '') {
1051 $param .= '&search_vat='.urlencode($search_vat);
1052}
1053if ($search_price_level != '') {
1054 $param .= '&search_price_level='.urlencode($search_price_level);
1055}
1056if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) {
1057 $param .= '&search_type_thirdparty='.urlencode((string) ($search_type_thirdparty));
1058}
1059if ($search_type != '') {
1060 $param .= '&search_type='.urlencode($search_type);
1061}
1062if ($search_status != '') {
1063 $param .= '&search_status='.urlencode((string) ($search_status));
1064}
1065if (is_array($search_level) && count($search_level)) {
1066 foreach ($search_level as $slevel) {
1067 $param .= '&search_level[]='.urlencode($slevel);
1068 }
1069}
1070if (is_array($search_stcomm) && count($search_stcomm)) {
1071 foreach ($search_stcomm as $slevel) {
1072 $param .= '&search_stcomm[]='.urlencode($slevel);
1073 }
1074}
1075if ($search_parent_name != '') {
1076 $param .= '&search_parent_name='.urlencode($search_parent_name);
1077}
1078if ($search_import_key != '') {
1079 $param .= '&search_import_key='.urlencode($search_import_key);
1080}
1081if ($type != '') {
1082 $param .= '&type='.urlencode($type);
1083}
1084if ($search_date_creation_startmonth) {
1085 $param .= '&search_date_creation_startmonth='.urlencode((string) ($search_date_creation_startmonth));
1086}
1087if ($search_date_creation_startyear) {
1088 $param .= '&search_date_creation_startyear='.urlencode((string) ($search_date_creation_startyear));
1089}
1090if ($search_date_creation_startday) {
1091 $param .= '&search_date_creation_startday='.urlencode((string) ($search_date_creation_startday));
1092}
1093if ($search_date_creation_start) {
1094 $param .= '&search_date_creation_start='.urlencode($search_date_creation_start);
1095}
1096if ($search_date_creation_endmonth) {
1097 $param .= '&search_date_creation_endmonth='.urlencode((string) ($search_date_creation_endmonth));
1098}
1099if ($search_date_creation_endyear) {
1100 $param .= '&search_date_creation_endyear='.urlencode((string) ($search_date_creation_endyear));
1101}
1102if ($search_date_creation_endday) {
1103 $param .= '&search_date_creation_endday='.urlencode((string) ($search_date_creation_endday));
1104}
1105if ($search_date_creation_end) {
1106 $param .= '&search_date_creation_end='.urlencode($search_date_creation_end);
1107}
1108if ($search_date_modif_startmonth) {
1109 $param .= '&search_date_modif_startmonth='.urlencode((string) ($search_date_modif_startmonth));
1110}
1111if ($search_date_modif_startyear) {
1112 $param .= '&search_date_modif_startyear='.urlencode((string) ($search_date_modif_startyear));
1113}
1114if ($search_date_modif_startday) {
1115 $param .= '&search_date_modif_startday='.urlencode((string) ($search_date_modif_startday));
1116}
1117if ($search_date_modif_start) {
1118 $param .= '&search_date_modif_start='.urlencode($search_date_modif_start);
1119}
1120if ($search_date_modif_endmonth) {
1121 $param .= '&search_date_modif_endmonth='.urlencode((string) ($search_date_modif_endmonth));
1122}
1123if ($search_date_modif_endyear) {
1124 $param .= '&search_date_modif_endyear='.urlencode((string) ($search_date_modif_endyear));
1125}
1126if ($search_date_modif_endday) {
1127 $param .= '&search_date_modif_endday='.urlencode((string) ($search_date_modif_endday));
1128}
1129if ($search_date_modif_end) {
1130 $param .= '&search_date_modif_end=' . urlencode($search_date_modif_end);
1131}
1132
1133// Add $param from extra fields
1134include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
1135// Add $param from hooks
1136$parameters = array('param' => &$param);
1137$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1138$param .= $hookmanager->resPrint;
1139
1140// Show delete result message
1141if (GETPOST('delsoc')) {
1142 setEventMessages($langs->trans("CompanyDeleted", GETPOST('delsoc')), null, 'mesgs');
1143}
1144
1145// List of mass actions available
1146$arrayofmassactions = array(
1147 'presend' => img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
1148 //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
1149);
1150//if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer");
1151if (isModEnabled('category') && $user->hasRight("societe", "creer")) {
1152 $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag");
1153}
1154if ($user->hasRight("societe", "creer")) {
1155 $arrayofmassactions['preenable'] = img_picto('', 'stop-circle', 'class="pictofixedwidth"').$langs->trans("SetToStatus", $object->LibStatut($object::STATUS_INACTIVITY));
1156}
1157if ($user->hasRight("societe", "creer")) {
1158 $arrayofmassactions['predisable'] = img_picto('', 'stop-circle', 'class="pictofixedwidth"').$langs->trans("SetToStatus", $object->LibStatut($object::STATUS_CEASED));
1159}
1160if ($user->hasRight("societe", "creer")) {
1161 $arrayofmassactions['presetcommercial'] = img_picto('', 'user', 'class="pictofixedwidth"').$langs->trans("AllocateCommercial");
1162 $arrayofmassactions['unsetcommercial'] = img_picto('', 'user', 'class="pictofixedwidth"').$langs->trans("UnallocateCommercial");
1163}
1164
1165if ($user->hasRight('societe', 'supprimer')) {
1166 $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
1167}
1168if (GETPOSTINT('nomassaction') || in_array($massaction, array('presend', 'predelete', 'preaffecttag', 'preenable', 'preclose'))) {
1169 $arrayofmassactions = array();
1170}
1171$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
1172
1173$typefilter = '';
1174$label = 'MenuNewThirdParty';
1175
1176if (!empty($type)) {
1177 $typefilter = '&amp;type='.$type;
1178 if ($type == 'p') {
1179 $label = 'MenuNewProspect';
1180 }
1181 if ($type == 'c') {
1182 $label = 'MenuNewCustomer';
1183 }
1184 if ($type == 'f') {
1185 $label = 'NewSupplier';
1186 }
1187}
1188
1189if ($contextpage == 'poslist' && $type == 't' && (getDolGlobalString('PRODUIT_MULTIPRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_AND_MULTIPRICES'))) {
1190 print get_htmloutput_mesg(img_warning('default').' '.$langs->trans("BecarefullChangeThirdpartyBeforeAddProductToInvoice"), [], 'warning', 1);
1191}
1192
1193// Show the new button only when this page is not opend from the Extended POS (pop-up window)
1194// but allow it too, when a user has the rights to create a new customer
1195if ($contextpage != 'poslist') {
1196 $url = DOL_URL_ROOT.'/societe/card.php?action=create'.$typefilter;
1197 if (!empty($socid)) {
1198 $url .= '&socid='.$socid;
1199 }
1200 $newcardbutton = '';
1201 $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'));
1202 $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'));
1203 $newcardbutton .= dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', $url, '', $user->hasRight('societe', 'creer'));
1204} elseif ($user->hasRight('societe', 'creer')) {
1205 $url = DOL_URL_ROOT.'/societe/card.php?action=create&type=t&contextpage=poslist&optioncss=print&backtopage='.urlencode($_SERVER["PHP_SELF"].'?type=t&contextpage=poslist&nomassaction=1&optioncss=print&place='.$place);
1206 $label = 'MenuNewCustomer';
1207 $newcardbutton = dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', $url);
1208}
1209
1210print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'" name="formfilter" autocomplete="off">'."\n";
1211if ($optioncss != '') {
1212 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
1213}
1214print '<input type="hidden" name="token" value="'.newToken().'">';
1215print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1216if (empty($massaction)) {
1217 print '<input type="hidden" name="action" value="list">';
1218}
1219print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
1220print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
1221//print '<input type="hidden" name="page" value="'.$page.'">';
1222print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
1223if (!empty($place)) {
1224 print '<input type="hidden" name="place" value="'.$place.'">';
1225}
1226print '<input type="hidden" name="page_y" value="">';
1227print '<input type="hidden" name="mode" value="'.$mode.'">';
1228if (empty($arrayfields['customerorsupplier']['checked'])) {
1229 print '<input type="hidden" name="type" value="'.$type.'">';
1230}
1231if (!empty($place)) {
1232 print '<input type="hidden" name="place" value="'.$place.'">';
1233}
1234
1235print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'building', 0, $newcardbutton, '', $limit, 0, 0, 1);
1236
1237$langs->load("other");
1238$textprofid = array();
1239foreach (array(1, 2, 3, 4, 5, 6) as $key) {
1240 $label = $langs->transnoentities("ProfId".$key.$mysoc->country_code);
1241 $textprofid[$key] = '';
1242 if ($label != "ProfId".$key.$mysoc->country_code) { // Get only text between ()
1243 $reg = array();
1244 if (preg_match('/\‍((.*)\‍)/i', $label, $reg)) {
1245 $label = $reg[1];
1246 }
1247 // @phan-suppress-next-line PhanPluginSuspiciousParamPosition
1248 $textprofid[$key] = $langs->trans("ProfIdShortDesc", $key, $mysoc->country_code, $label);
1249 }
1250}
1251
1252// Add code for pre mass action (confirmation or email presend form)
1253$topicmail = "Information";
1254$modelmail = "thirdparty";
1255$objecttmp = new Societe($db);
1256$trackid = 'thi'.$object->id;
1257include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
1258
1259/*
1260if (!empty($search_categ_cus) || !empty($search_categ_sup)) {
1261 print "<div id='ways'>";
1262 $c = new Categorie($db);
1263 $ways = $c->print_all_ways(' &gt; ', 'societe/list.php');
1264 print " &gt; ".$ways[0]."<br>\n";
1265 print "</div><br>";
1266}
1267*/
1268
1269if ($search_all) {
1270 $setupstring = '';
1271 foreach ($fieldstosearchall as $key => $val) {
1272 $fieldstosearchall[$key] = $langs->trans($val);
1273 $setupstring .= $key."=".$val.";";
1274 }
1275 print '<!-- Search done like if SOCIETE_QUICKSEARCH_ON_FIELDS = '.$setupstring.' -->'."\n";
1276 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'</div>';
1277}
1278
1279$moreforfilter = '';
1280
1281// Filter for customer categories
1282if (empty($type) || $type == 'c' || $type == 'p') {
1283 if (isModEnabled('category') && $user->hasRight('categorie', 'read')) {
1284 $formcategory = new FormCategory($db);
1285 $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_CUSTOMER, $searchCategoryCustomerList, 'minwidth300', $searchCategoryCustomerOperator ? $searchCategoryCustomerOperator : 0, 1, 1, $langs->transnoentities("CustomersProspectsCategoriesShort"));
1286 }
1287}
1288
1289// Filter for supplier categories
1290if (empty($type) || $type == 'f') {
1291 if (isModEnabled("fournisseur") && isModEnabled('category') && $user->hasRight('categorie', 'read')) {
1292 $formcategory = new FormCategory($db);
1293 $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_SUPPLIER, $searchCategorySupplierList, 'minwidth300', $searchCategorySupplierOperator ? $searchCategorySupplierOperator : 0, 1, 1, $langs->transnoentities("SuppliersCategoriesShort"));
1294 }
1295}
1296
1297// If the user can view prospects other than his'
1298$userlist = $form->select_dolusers('', '', 0, null, 0, '', '', 0, 0, 0, 'u.statut:=:1', 0, '', '', 0, 1);
1299$userlist[-2] = $langs->trans("NoSalesRepresentativeAffected");
1300if ($user->hasRight("societe", "client", "voir") || $socid) {
1301 $moreforfilter .= '<div class="divsearchfield">';
1302 $tmptitle = $langs->transnoentitiesnoconv('SalesRepresentatives');
1303 $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"');
1304 $moreforfilter .= $form->multiselectarray('search_sale', $userlist, $search_sale, 0, 0, '', 0, 300, '', '', $langs->transnoentitiesnoconv('SalesRepresentatives'), 1);
1305 $moreforfilter .= '</div>';
1306}
1307if (!empty($moreforfilter)) {
1308 print '<div class="liste_titre liste_titre_bydiv centpercent">';
1309 print $moreforfilter;
1310 $parameters = array('type' => $type);
1311 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1312 print $hookmanager->resPrint;
1313 print '</div>';
1314}
1315
1316$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
1317$htmlofselectarray = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields with user setup
1318$selectedfields = ($mode != 'kanban' ? $htmlofselectarray : '');
1319$selectedfields .= ((count($arrayofmassactions) && $contextpage != 'poslist') ? $form->showCheckAddButtons('checkforselect', 1) : '');
1320
1321print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
1322print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
1323
1324// Fields title search
1325// --------------------------------------------------------------------
1326print '<tr class="liste_titre_filter">';
1327// Action column
1328if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1329 print '<td class="liste_titre maxwidthsearch center actioncolumn">';
1330 $searchpicto = $form->showFilterButtons('left');
1331 print $searchpicto;
1332 print '</td>';
1333}
1334if (!empty($arrayfields['s.rowid']['checked'])) {
1335 print '<td class="liste_titre" data-key="id">';
1336 print '<input class="flat searchstring" type="text" name="search_id" size="1" value="'.dol_escape_htmltag($search_id).'">';
1337 print '</td>';
1338}
1339if (!empty($arrayfields['s.nom']['checked'])) {
1340 print '<td class="liste_titre" data-key="ref">';
1341 if (!empty($search_nom_only) && empty($search_nom)) {
1342 $search_nom = $search_nom_only;
1343 }
1344 print '<input class="flat searchstring maxwidth75imp" type="text" name="search_nom" value="'.dol_escape_htmltag($search_nom).'">';
1345 print '</td>';
1346}
1347if (!empty($arrayfields['s.name_alias']['checked'])) {
1348 print '<td class="liste_titre">';
1349 print '<input class="flat searchstring maxwidth75imp" type="text" name="search_alias" value="'.dol_escape_htmltag($search_alias).'">';
1350 print '</td>';
1351}
1352if (!empty($arrayfields['s.ref_ext']['checked'])) {
1353 print '<td class="liste_titre">';
1354 print '<input class="flat searchstring maxwidth75imp" type="text" name="search_ref_ext" value="'.dol_escape_htmltag($search_ref_ext).'">';
1355 print '</td>';
1356}
1357// Barcode
1358if (!empty($arrayfields['s.barcode']['checked'])) {
1359 print '<td class="liste_titre">';
1360 print '<input class="flat searchstring maxwidth75imp" type="text" name="search_barcode" value="'.dol_escape_htmltag($search_barcode).'">';
1361 print '</td>';
1362}
1363// Customer code
1364if (!empty($arrayfields['s.code_client']['checked'])) {
1365 print '<td class="liste_titre">';
1366 print '<input class="flat searchstring maxwidth75imp" type="text" name="search_customer_code" value="'.dol_escape_htmltag($search_customer_code).'">';
1367 print '</td>';
1368}
1369// Supplier code
1370if (!empty($arrayfields['s.code_fournisseur']['checked'])) {
1371 print '<td class="liste_titre">';
1372 print '<input class="flat searchstring maxwidth75imp" type="text" name="search_supplier_code" value="'.dol_escape_htmltag($search_supplier_code).'">';
1373 print '</td>';
1374}
1375// Account Customer code
1376if (!empty($arrayfields['s.code_compta']['checked'])) {
1377 print '<td class="liste_titre">';
1378 print '<input class="flat searchstring maxwidth75imp" type="text" name="search_account_customer_code" value="'.dol_escape_htmltag($search_account_customer_code).'">';
1379 print '</td>';
1380}
1381// Account Supplier code
1382if (!empty($arrayfields['s.code_compta_fournisseur']['checked'])) {
1383 print '<td class="liste_titre">';
1384 print '<input class="flat maxwidth75imp" type="text" name="search_account_supplier_code" value="'.dol_escape_htmltag($search_account_supplier_code).'">';
1385 print '</td>';
1386}
1387// Address
1388if (!empty($arrayfields['s.address']['checked'])) {
1389 print '<td class="liste_titre">';
1390 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_address" value="'.dol_escape_htmltag($search_address).'">';
1391 print '</td>';
1392}
1393// Sales representatives
1394if (!empty($arrayfields['sales.representative']['checked'])) {
1395 print '<td class="liste_titre">';
1396 print '</td>';
1397}
1398// Zip
1399if (!empty($arrayfields['s.zip']['checked'])) {
1400 print '<td class="liste_titre">';
1401 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_zip" value="'.dol_escape_htmltag($search_zip).'">';
1402 print '</td>';
1403}
1404// Town
1405if (!empty($arrayfields['s.town']['checked'])) {
1406 print '<td class="liste_titre">';
1407 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_town" value="'.dol_escape_htmltag($search_town).'">';
1408 print '</td>';
1409}
1410// State
1411if (!empty($arrayfields['state.nom']['checked'])) {
1412 print '<td class="liste_titre">';
1413 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
1414 print '</td>';
1415}
1416// Region
1417if (!empty($arrayfields['region.nom']['checked'])) {
1418 print '<td class="liste_titre">';
1419 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_region" value="'.dol_escape_htmltag($search_region).'">';
1420 print '</td>';
1421}
1422// Country
1423if (!empty($arrayfields['country.code_iso']['checked'])) {
1424 print '<td class="liste_titre center">';
1425 print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100');
1426 print '</td>';
1427}
1428// Company type
1429if (!empty($arrayfields['typent.code']['checked'])) {
1430 print '<td class="liste_titre maxwidthonsmartphone center">';
1431 // We use showempty=0 here because there is already an unknown value into dictionary.
1432 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), 'minwidth50 maxwidth125', 1);
1433 print '</td>';
1434}
1435// Multiprice level
1436if (!empty($arrayfields['s.price_level']['checked'])) {
1437 print '<td class="liste_titre">';
1438 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_price_level" value="'.dol_escape_htmltag($search_price_level).'">';
1439 print '</td>';
1440}
1441// Staff
1442if (!empty($arrayfields['staff.code']['checked'])) {
1443 print '<td class="liste_titre maxwidthonsmartphone center">';
1444 print $form->selectarray("search_staff", $formcompany->effectif_array(0), $search_staff, 0, 0, 0, '', 0, 0, 0, 'ASC', 'maxwidth100', 1);
1445 print '</td>';
1446}
1447// Legal form
1448if (!empty($arrayfields['legalform.code']['checked'])) {
1449 print '<td class="liste_titre maxwidthonsmartphone center">';
1450 //print $form->selectarray("search_legalform", $formcompany->effectif_array(0), $search_legalform, 0, 0, 0, '', 0, 0, 0, 'ASC', 'maxwidth100', 1);
1451 print '</td>';
1452}
1453if (!empty($arrayfields['s.email']['checked'])) {
1454 // Email
1455 print '<td class="liste_titre">';
1456 print '<input class="flat searchemail maxwidth50imp" type="text" name="search_email" value="'.dol_escape_htmltag($search_email).'">';
1457 print '</td>';
1458}
1459if (!empty($arrayfields['s.phone']['checked'])) {
1460 // Phone
1461 print '<td class="liste_titre">';
1462 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_phone" value="'.dol_escape_htmltag($search_phone).'">';
1463 print '</td>';
1464}
1465if (!empty($arrayfields['s.phone_mobile']['checked'])) {
1466 // PhoneMobile
1467 print '<td class="liste_titre">';
1468 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_phone_mobile" value="'.dol_escape_htmltag($search_phone_mobile).'">';
1469 print '</td>';
1470}
1471if (!empty($arrayfields['s.fax']['checked'])) {
1472 // Fax
1473 print '<td class="liste_titre">';
1474 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_fax" value="'.dol_escape_htmltag($search_fax).'">';
1475 print '</td>';
1476}
1477if (!empty($arrayfields['s.url']['checked'])) {
1478 // Url
1479 print '<td class="liste_titre">';
1480 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_url" value="'.dol_escape_htmltag($search_url).'">';
1481 print '</td>';
1482}
1483if (!empty($arrayfields['s.siren']['checked'])) {
1484 // IdProf1
1485 print '<td class="liste_titre">';
1486 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_idprof1" value="'.dol_escape_htmltag($search_idprof1).'">';
1487 print '</td>';
1488}
1489if (!empty($arrayfields['s.siret']['checked'])) {
1490 // IdProf2
1491 print '<td class="liste_titre">';
1492 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_idprof2" value="'.dol_escape_htmltag($search_idprof2).'">';
1493 print '</td>';
1494}
1495if (!empty($arrayfields['s.ape']['checked'])) {
1496 // IdProf3
1497 print '<td class="liste_titre">';
1498 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_idprof3" value="'.dol_escape_htmltag($search_idprof3).'">';
1499 print '</td>';
1500}
1501if (!empty($arrayfields['s.idprof4']['checked'])) {
1502 // IdProf4
1503 print '<td class="liste_titre">';
1504 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_idprof4" value="'.dol_escape_htmltag($search_idprof4).'">';
1505 print '</td>';
1506}
1507if (!empty($arrayfields['s.idprof5']['checked'])) {
1508 // IdProf5
1509 print '<td class="liste_titre">';
1510 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_idprof5" value="'.dol_escape_htmltag($search_idprof5).'">';
1511 print '</td>';
1512}
1513if (!empty($arrayfields['s.idprof6']['checked'])) {
1514 // IdProf6
1515 print '<td class="liste_titre">';
1516 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_idprof6" value="'.dol_escape_htmltag($search_idprof6).'">';
1517 print '</td>';
1518}
1519if (!empty($arrayfields['s.tva_intra']['checked'])) {
1520 // Vat number
1521 print '<td class="liste_titre">';
1522 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_vat" value="'.dol_escape_htmltag($search_vat).'">';
1523 print '</td>';
1524}
1525
1526// Nature (customer/prospect/supplier)
1527if (!empty($arrayfields['customerorsupplier']['checked'])) {
1528 print '<td class="liste_titre maxwidthonsmartphone center">';
1529 if ($type != '') {
1530 print '<input type="hidden" name="type" value="'.$type.'">';
1531 }
1532 print $formcompany->selectProspectCustomerType($search_type, 'search_type', 'search_type', 'list');
1533 print '</td>';
1534}
1535// Prospect level
1536if (!empty($arrayfields['s.fk_prospectlevel']['checked'])) {
1537 print '<td class="liste_titre center">';
1538 print $form->multiselectarray('search_level', $tab_level, $search_level, 0, 0, 'width75', 0, 0, '', '', '', 2);
1539 print '</td>';
1540}
1541// Prospect status
1542if (!empty($arrayfields['s.fk_stcomm']['checked'])) {
1543 print '<td class="liste_titre maxwidthonsmartphone center">';
1544 $arraystcomm = array();
1545 foreach ($prospectstatic->cacheprospectstatus as $key => $val) {
1546 $arraystcomm[$val['id']] = ($langs->trans("StatusProspect".$val['id']) != "StatusProspect".$val['id'] ? $langs->trans("StatusProspect".$val['id']) : $val['label']);
1547 }
1548 //print $form->selectarray('search_stcomm', $arraystcomm, $search_stcomm, -2, 0, 0, '', 0, 0, 0, '', '', 1);
1549 print $form->multiselectarray('search_stcomm', $arraystcomm, $search_stcomm, 0, 0, 'width100', 0, 0, '', '', '', 2);
1550 print '</td>';
1551}
1552if (!empty($arrayfields['s2.nom']['checked'])) {
1553 print '<td class="liste_titre center">';
1554 print '<input class="flat searchstring maxwidth75imp" type="text" name="search_parent_name" value="'.dol_escape_htmltag($search_parent_name).'">';
1555 print '</td>';
1556}
1557// Extra fields
1558include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
1559
1560// Fields from hook
1561$parameters = array('arrayfields' => $arrayfields);
1562$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1563print $hookmanager->resPrint;
1564// IP address
1565if (!empty($arrayfields['s.ip']['checked'])) {
1566 print '<td class="liste_titre center nowraponall">';
1567 print '</td>';
1568}
1569// Creation date
1570if (!empty($arrayfields['s.datec']['checked'])) {
1571 print '<td class="liste_titre center nowraponall">';
1572 print '<div class="nowrapfordate">';
1573 print $form->selectDate($search_date_creation_start ? $search_date_creation_start : -1, 'search_date_creation_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
1574 print '</div>';
1575 print '<div class="nowrapfordate">';
1576 print $form->selectDate($search_date_creation_end ? $search_date_creation_end : -1, 'search_date_creation_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
1577 print '</div>';
1578 print '</td>';
1579}
1580// Modification date
1581if (!empty($arrayfields['s.tms']['checked'])) {
1582 print '<td class="liste_titre center nowraponall">';
1583 print '<div class="nowrapfordate">';
1584 print $form->selectDate($search_date_modif_start ? $search_date_modif_start : -1, 'search_date_modif_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
1585 print '</div>';
1586 print '<div class="nowrapfordate">';
1587 print $form->selectDate($search_date_modif_end ? $search_date_modif_end : -1, 'search_date_modif_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
1588 print '</div>';
1589 print '</td>';
1590}
1591if (!empty($arrayfields['s.note_public']['checked'])) {
1592 // Note public
1593 print '<td class="liste_titre">';
1594 print '</td>';
1595}
1596if (!empty($arrayfields['s.note_private']['checked'])) {
1597 // Note private
1598 print '<td class="liste_titre">';
1599 print '</td>';
1600}
1601// Status
1602if (!empty($arrayfields['s.status']['checked'])) {
1603 print '<td class="liste_titre center minwidth75imp parentonrightofpage">';
1604 print $form->selectarray('search_status', array('0' => $langs->trans('ActivityCeased'), '1' => $langs->trans('InActivity')), $search_status, 1, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage', 1);
1605 print '</td>';
1606}
1607if (!empty($arrayfields['s.import_key']['checked'])) {
1608 print '<td class="liste_titre center">';
1609 print '<input class="flat searchstring maxwidth50" type="text" name="search_import_key" value="'.dol_escape_htmltag($search_import_key).'">';
1610 print '</td>';
1611}
1612// Action column
1613if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1614 print '<td class="liste_titre center maxwidthsearch actioncolumn">';
1615 $searchpicto = $form->showFilterButtons();
1616 print $searchpicto;
1617 print '</td>';
1618}
1619
1620print '</tr>'."\n";
1621
1622$totalarray = array();
1623$totalarray['nbfield'] = 0;
1624
1625// Fields title label
1626// --------------------------------------------------------------------
1627print '<tr class="liste_titre">';
1628// Action column
1629if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1630 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
1631 $totalarray['nbfield']++;
1632}
1633if (!empty($arrayfields['s.rowid']['checked'])) {
1634 print_liste_field_titre($arrayfields['s.rowid']['label'], $_SERVER["PHP_SELF"], "s.rowid", "", $param, ' data-key="id"', $sortfield, $sortorder, '');
1635 $totalarray['nbfield']++;
1636}
1637if (!empty($arrayfields['s.nom']['checked'])) {
1638 print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, ' data-key="ref"', $sortfield, $sortorder, ' ');
1639 $totalarray['nbfield']++;
1640}
1641if (!empty($arrayfields['s.name_alias']['checked'])) {
1642 // @phan-suppress-next-line PhanTypeInvalidDimOffset
1643 print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"], "s.name_alias", "", $param, "", $sortfield, $sortorder);
1644 $totalarray['nbfield']++;
1645}
1646if (!empty($arrayfields['s.ref_ext']['checked'])) {
1647 // @phan-suppress-next-line PhanTypeInvalidDimOffset
1648 print_liste_field_titre($arrayfields['s.ref_ext']['label'], $_SERVER["PHP_SELF"], "s.ref_ext", "", $param, "", $sortfield, $sortorder);
1649 $totalarray['nbfield']++;
1650}
1651if (!empty($arrayfields['s.barcode']['checked'])) {
1652 print_liste_field_titre($arrayfields['s.barcode']['label'], $_SERVER["PHP_SELF"], "s.barcode", $param, '', '', $sortfield, $sortorder);
1653 $totalarray['nbfield']++;
1654}
1655if (!empty($arrayfields['s.code_client']['checked'])) {
1656 print_liste_field_titre($arrayfields['s.code_client']['label'], $_SERVER["PHP_SELF"], "s.code_client", "", $param, '', $sortfield, $sortorder);
1657 $totalarray['nbfield']++;
1658}
1659if (!empty($arrayfields['s.code_fournisseur']['checked'])) {
1660 print_liste_field_titre($arrayfields['s.code_fournisseur']['label'], $_SERVER["PHP_SELF"], "s.code_fournisseur", "", $param, '', $sortfield, $sortorder);
1661 $totalarray['nbfield']++;
1662}
1663if (!empty($arrayfields['s.code_compta']['checked'])) {
1664 print_liste_field_titre($arrayfields['s.code_compta']['label'], $_SERVER["PHP_SELF"], "s.code_compta", "", $param, '', $sortfield, $sortorder);
1665 $totalarray['nbfield']++;
1666}
1667if (!empty($arrayfields['s.code_compta_fournisseur']['checked'])) {
1668 print_liste_field_titre($arrayfields['s.code_compta_fournisseur']['label'], $_SERVER["PHP_SELF"], "s.code_compta_fournisseur", "", $param, '', $sortfield, $sortorder);
1669 $totalarray['nbfield']++;
1670}
1671if (!empty($arrayfields['s.address']['checked'])) {
1672 print_liste_field_titre($arrayfields['s.address']['label'], $_SERVER['PHP_SELF'], 's.address', '', $param, '', $sortfield, $sortorder);
1673 $totalarray['nbfield']++;
1674}
1675if (!empty($arrayfields['sales.representative']['checked'])) {
1676 print_liste_field_titre($arrayfields['sales.representative']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder);
1677 $totalarray['nbfield']++;
1678}
1679if (!empty($arrayfields['s.zip']['checked'])) {
1680 print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], "s.zip", "", $param, '', $sortfield, $sortorder);
1681 $totalarray['nbfield']++;
1682}
1683if (!empty($arrayfields['s.town']['checked'])) {
1684 print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], "s.town", "", $param, '', $sortfield, $sortorder);
1685 $totalarray['nbfield']++;
1686}
1687if (!empty($arrayfields['state.nom']['checked'])) {
1688 print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder);
1689 $totalarray['nbfield']++;
1690}
1691if (!empty($arrayfields['region.nom']['checked'])) {
1692 print_liste_field_titre($arrayfields['region.nom']['label'], $_SERVER["PHP_SELF"], "region.nom", "", $param, '', $sortfield, $sortorder);
1693 $totalarray['nbfield']++;
1694}
1695if (!empty($arrayfields['country.code_iso']['checked'])) {
1696 print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center ');
1697 $totalarray['nbfield']++;
1698}
1699if (!empty($arrayfields['typent.code']['checked'])) {
1700 print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, "", $sortfield, $sortorder, 'center ');
1701 $totalarray['nbfield']++;
1702}
1703if (!empty($arrayfields['staff.code']['checked'])) {
1704 print_liste_field_titre($arrayfields['staff.code']['label'], $_SERVER["PHP_SELF"], "staff.code", "", $param, '', $sortfield, $sortorder, 'center ');
1705 $totalarray['nbfield']++;
1706}
1707if (!empty($arrayfields['legalform.code']['checked'])) {
1708 // s.fk_forme_juridique as legalform_code
1709 print_liste_field_titre($arrayfields['legalform.code']['label'], $_SERVER["PHP_SELF"], "legalform_code", "", $param, '', $sortfield, $sortorder);
1710 $totalarray['nbfield']++;
1711}
1712if (!empty($arrayfields['s.price_level']['checked'])) {
1713 print_liste_field_titre($arrayfields['s.price_level']['label'], $_SERVER["PHP_SELF"], "s.price_level", "", $param, '', $sortfield, $sortorder);
1714 $totalarray['nbfield']++;
1715}
1716if (!empty($arrayfields['s.email']['checked'])) {
1717 print_liste_field_titre($arrayfields['s.email']['label'], $_SERVER["PHP_SELF"], "s.email", "", $param, '', $sortfield, $sortorder);
1718 $totalarray['nbfield']++;
1719}
1720if (!empty($arrayfields['s.phone']['checked'])) {
1721 print_liste_field_titre($arrayfields['s.phone']['label'], $_SERVER["PHP_SELF"], "s.phone", "", $param, '', $sortfield, $sortorder);
1722 $totalarray['nbfield']++;
1723}
1724if (!empty($arrayfields['s.phone_mobile']['checked'])) {
1725 print_liste_field_titre($arrayfields['s.phone_mobile']['label'], $_SERVER["PHP_SELF"], "s.phone_mobile", "", $param, '', $sortfield, $sortorder);
1726 $totalarray['nbfield']++;
1727}
1728if (!empty($arrayfields['s.fax']['checked'])) {
1729 print_liste_field_titre($arrayfields['s.fax']['label'], $_SERVER["PHP_SELF"], "s.fax", "", $param, '', $sortfield, $sortorder);
1730 $totalarray['nbfield']++;
1731}
1732if (!empty($arrayfields['s.url']['checked'])) {
1733 print_liste_field_titre($arrayfields['s.url']['label'], $_SERVER["PHP_SELF"], "s.url", "", $param, '', $sortfield, $sortorder);
1734 $totalarray['nbfield']++;
1735}
1736if (!empty($arrayfields['s.siren']['checked'])) {
1737 print_liste_field_titre($form->textwithpicto($langs->trans("ProfId1Short"), $textprofid[1], 1, 0), $_SERVER["PHP_SELF"], "s.siren", "", $param, '', $sortfield, $sortorder, 'nowrap ');
1738 $totalarray['nbfield']++;
1739}
1740if (!empty($arrayfields['s.siret']['checked'])) {
1741 print_liste_field_titre($form->textwithpicto($langs->trans("ProfId2Short"), $textprofid[2], 1, 0), $_SERVER["PHP_SELF"], "s.siret", "", $param, '', $sortfield, $sortorder, 'nowrap ');
1742 $totalarray['nbfield']++;
1743}
1744if (!empty($arrayfields['s.ape']['checked'])) {
1745 print_liste_field_titre($form->textwithpicto($langs->trans("ProfId3Short"), $textprofid[3], 1, 0), $_SERVER["PHP_SELF"], "s.ape", "", $param, '', $sortfield, $sortorder, 'nowrap ');
1746 $totalarray['nbfield']++;
1747}
1748if (!empty($arrayfields['s.idprof4']['checked'])) {
1749 print_liste_field_titre($form->textwithpicto($langs->trans("ProfId4Short"), $textprofid[4], 1, 0), $_SERVER["PHP_SELF"], "s.idprof4", "", $param, '', $sortfield, $sortorder, 'nowrap ');
1750 $totalarray['nbfield']++;
1751}
1752if (!empty($arrayfields['s.idprof5']['checked'])) {
1753 print_liste_field_titre($form->textwithpicto($langs->trans("ProfId5Short"), $textprofid[5], 1, 0), $_SERVER["PHP_SELF"], "s.idprof5", "", $param, '', $sortfield, $sortorder, 'nowrap ');
1754 $totalarray['nbfield']++;
1755}
1756if (!empty($arrayfields['s.idprof6']['checked'])) {
1757 print_liste_field_titre($form->textwithpicto($langs->trans("ProfId6Short"), $textprofid[6], 1, 0), $_SERVER["PHP_SELF"], "s.idprof6", "", $param, '', $sortfield, $sortorder, 'nowrap ');
1758 $totalarray['nbfield']++;
1759}
1760if (!empty($arrayfields['s.tva_intra']['checked'])) {
1761 print_liste_field_titre($arrayfields['s.tva_intra']['label'], $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder, 'nowrap ');
1762 $totalarray['nbfield']++;
1763}
1764if (!empty($arrayfields['customerorsupplier']['checked'])) {
1765 print_liste_field_titre($arrayfields['customerorsupplier']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'center '); // type of customer
1766 $totalarray['nbfield']++;
1767}
1768if (!empty($arrayfields['s.fk_prospectlevel']['checked'])) {
1769 print_liste_field_titre($arrayfields['s.fk_prospectlevel']['label'], $_SERVER["PHP_SELF"], "s.fk_prospectlevel", "", $param, '', $sortfield, $sortorder, 'center ');
1770 $totalarray['nbfield']++;
1771}
1772if (!empty($arrayfields['s.fk_stcomm']['checked'])) {
1773 print_liste_field_titre($arrayfields['s.fk_stcomm']['label'], $_SERVER["PHP_SELF"], "s.fk_stcomm", "", $param, '', $sortfield, $sortorder, 'center ');
1774 $totalarray['nbfield']++;
1775}
1776if (!empty($arrayfields['s2.nom']['checked'])) {
1777 print_liste_field_titre($arrayfields['s2.nom']['label'], $_SERVER["PHP_SELF"], "s2.nom", "", $param, '', $sortfield, $sortorder, 'center ');
1778 $totalarray['nbfield']++;
1779}
1780// Extra fields
1781include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
1782// Hook fields
1783$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder);
1784$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1785print $hookmanager->resPrint;
1786// IP Address
1787if (!empty($arrayfields['s.ip']['checked'])) {
1788 print_liste_field_titre($arrayfields['s.ip']['label'], $_SERVER["PHP_SELF"], "s.ip", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1789 $totalarray['nbfield']++; // For the column action
1790}
1791// Date creation
1792if (!empty($arrayfields['s.datec']['checked'])) {
1793 print_liste_field_titre($arrayfields['s.datec']['label'], $_SERVER["PHP_SELF"], "s.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1794 $totalarray['nbfield']++; // For the column action
1795}
1796if (!empty($arrayfields['s.tms']['checked'])) {
1797 print_liste_field_titre($arrayfields['s.tms']['label'], $_SERVER["PHP_SELF"], "s.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1798 $totalarray['nbfield']++; // For the column action
1799}
1800if (!empty($arrayfields['s.status']['checked'])) {
1801 print_liste_field_titre($arrayfields['s.status']['label'], $_SERVER["PHP_SELF"], "s.status", "", $param, '', $sortfield, $sortorder, 'center ');
1802 $totalarray['nbfield']++; // For the column action
1803}
1804if (!empty($arrayfields['s.note_public']['checked'])) {
1805 print_liste_field_titre($arrayfields['s.note_public']['label'], $_SERVER["PHP_SELF"], "s.note_public", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1806 $totalarray['nbfield']++;
1807}
1808if (!empty($arrayfields['s.note_private']['checked'])) {
1809 print_liste_field_titre($arrayfields['s.note_private']['label'], $_SERVER["PHP_SELF"], "s.note_private", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1810 $totalarray['nbfield']++;
1811}
1812if (!empty($arrayfields['s.import_key']['checked'])) {
1813 print_liste_field_titre($arrayfields['s.import_key']['label'], $_SERVER["PHP_SELF"], "s.import_key", "", $param, '', $sortfield, $sortorder, 'center ');
1814 $totalarray['nbfield']++; // For the column action
1815}
1816// Action column
1817if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1818 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
1819 $totalarray['nbfield']++;
1820}
1821print '</tr>'."\n";
1822
1823
1824// Loop on record
1825// --------------------------------------------------------------------
1826$i = 0;
1827$savnbfield = $totalarray['nbfield'];
1828$totalarray = array();
1829$totalarray['nbfield'] = 0;
1830$imaxinloop = ($limit ? min($num, $limit) : $num);
1831while ($i < $imaxinloop) {
1832 $obj = $db->fetch_object($resql);
1833 if (empty($obj)) {
1834 break; // Should not happen
1835 }
1836
1837 $parameters = array('staticdata' => $obj);
1838 // Note that $action and $object may have been modified by hook
1839 // do companystatic fetch in hook if wanted or anything else
1840 $reshook = $hookmanager->executeHooks('loadStaticObject', $parameters, $companystatic, $action);
1841 if (empty($reshook)) {
1842 $companystatic->id = $obj->rowid;
1843 $companystatic->name = $obj->name;
1844 $companystatic->name_alias = $obj->name_alias;
1845 $companystatic->ref_ext = $obj->ref_ext;
1846 $companystatic->logo = $obj->logo;
1847 $companystatic->barcode = $obj->barcode;
1848 $companystatic->canvas = $obj->canvas;
1849 $companystatic->client = $obj->client;
1850 $companystatic->status = $obj->status;
1851 $companystatic->email = $obj->email;
1852 $companystatic->phone = $obj->phone;
1853 $companystatic->phone_mobile = $obj->phone_mobile;
1854 $companystatic->fax = $obj->fax;
1855 $companystatic->address = $obj->address;
1856 $companystatic->zip = $obj->zip;
1857 $companystatic->town = $obj->town;
1858 $companystatic->fournisseur = $obj->fournisseur;
1859 $companystatic->code_client = $obj->code_client;
1860 $companystatic->code_fournisseur = $obj->code_fournisseur;
1861 $companystatic->tva_intra = $obj->tva_intra;
1862 $companystatic->country_code = $obj->country_code;
1863
1864 $companystatic->ip = $obj->ip;
1865
1866 $companystatic->code_compta_client = $obj->code_compta;
1867 $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
1868 $companystatic->note_public = $obj->note_public;
1869 $companystatic->note_private = $obj->note_private;
1870 $companystatic->fk_prospectlevel = $obj->fk_prospectlevel;
1871 $companystatic->parent = $obj->fk_parent;
1872 $companystatic->entity = $obj->entity;
1873
1874 $object = $companystatic;
1875 }
1876
1877 if ($mode == 'kanban') {
1878 if ($i == 0) {
1879 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
1880 print '<div class="box-flex-container kanban">';
1881 }
1882 // Output Kanban
1883 print $companystatic->getKanbanView('', array('selected' => in_array($obj->rowid, $arrayofselected)));
1884 if ($i == ($imaxinloop - 1)) {
1885 print '</div>';
1886 print '</td></tr>';
1887 }
1888 } else {
1889 // Show line of result
1890 $j = 0;
1891 print '<tr data-rowid="'.$companystatic->id.'" class="oddeven"';
1892 if ($contextpage == 'poslist') {
1893 print ' onclick="location.href=\'list.php?action=change&contextpage=poslist&idcustomer='.$obj->rowid.'&place='.urlencode($place).'\'"';
1894 }
1895 print '>';
1896
1897 // Action column (Show the massaction button only when this page is not opend from the Extended POS)
1898 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1899 print '<td class="nowrap center actioncolumn">';
1900 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
1901 $selected = 0;
1902 if (in_array($obj->rowid, $arrayofselected)) {
1903 $selected = 1;
1904 }
1905 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
1906 }
1907 print '</td>';
1908 if (!$i) {
1909 $totalarray['nbfield']++;
1910 }
1911 }
1912 if (!empty($arrayfields['s.rowid']['checked'])) {
1913 print '<td class="tdoverflowmax50" data-key="id">';
1914 print dol_escape_htmltag($obj->rowid);
1915 print "</td>\n";
1916 if (!$i) {
1917 $totalarray['nbfield']++;
1918 }
1919 }
1920 if (!empty($arrayfields['s.nom']['checked'])) {
1921 print '<td'.(getDolGlobalString('MAIN_SOCIETE_SHOW_COMPLETE_NAME') ? '' : ' class="tdoverflowmax200"').' data-key="ref">';
1922 if ($contextpage == 'poslist') {
1923 print dol_escape_htmltag($companystatic->name);
1924 } else {
1925 print $companystatic->getNomUrl(1, '', 100, 0, 1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1);
1926 }
1927 print "</td>\n";
1928 if (!$i) {
1929 $totalarray['nbfield']++;
1930 }
1931 }
1932 if (!empty($arrayfields['s.name_alias']['checked'])) {
1933 print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($companystatic->name_alias).'">';
1934 print dol_escape_htmltag($companystatic->name_alias);
1935 print "</td>\n";
1936 if (!$i) {
1937 $totalarray['nbfield']++;
1938 }
1939 }
1940 // Ref ext
1941 if (!empty($arrayfields['s.ref_ext']['checked'])) {
1942 print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($companystatic->ref_ext).'">';
1943 print dol_escape_htmltag($companystatic->ref_ext);
1944 print "</td>\n";
1945 if (!$i) {
1946 $totalarray['nbfield']++;
1947 }
1948 }
1949 // Barcode
1950 if (!empty($arrayfields['s.barcode']['checked'])) {
1951 print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($companystatic->barcode).'">'.dol_escape_htmltag($companystatic->barcode).'</td>';
1952 if (!$i) {
1953 $totalarray['nbfield']++;
1954 }
1955 }
1956 // Customer code
1957 if (!empty($arrayfields['s.code_client']['checked'])) {
1958 print '<td class="nowraponall">'.dol_escape_htmltag($companystatic->code_client).'</td>';
1959 if (!$i) {
1960 $totalarray['nbfield']++;
1961 }
1962 }
1963 // Supplier code
1964 if (!empty($arrayfields['s.code_fournisseur']['checked'])) {
1965 print '<td class="nowraponall">'.dol_escape_htmltag($companystatic->code_fournisseur).'</td>';
1966 if (!$i) {
1967 $totalarray['nbfield']++;
1968 }
1969 }
1970 // Account customer code
1971 if (!empty($arrayfields['s.code_compta']['checked'])) {
1972 print '<td>'.dol_escape_htmltag($companystatic->code_compta_client).'</td>';
1973 if (!$i) {
1974 $totalarray['nbfield']++;
1975 }
1976 }
1977 // Account supplier code
1978 if (!empty($arrayfields['s.code_compta_fournisseur']['checked'])) {
1979 print '<td>'.dol_escape_htmltag($companystatic->code_compta_fournisseur).'</td>';
1980 if (!$i) {
1981 $totalarray['nbfield']++;
1982 }
1983 }
1984 // Address
1985 if (!empty($arrayfields['s.address']['checked'])) {
1986 print '<td class="tdoverflowmax250" title="'.dol_escape_htmltag($companystatic->address).'">'.dol_escape_htmltag($companystatic->address).'</td>';
1987 if (!$i) {
1988 $totalarray['nbfield']++;
1989 }
1990 }
1991 // Sales Representative
1992 if (!empty($arrayfields['sales.representative']['checked'])) {
1993 print '<td class="nowraponall tdoverflowmax200">';
1994 $listsalesrepresentatives = $companystatic->getSalesRepresentatives($user);
1995 $nbofsalesrepresentative = count($listsalesrepresentatives);
1996 if ($nbofsalesrepresentative > 6) {
1997 // We print only number
1998 print $nbofsalesrepresentative;
1999 } elseif ($nbofsalesrepresentative > 0) {
2000 $userstatic = new User($db);
2001 $j = 0;
2002 foreach ($listsalesrepresentatives as $val) {
2003 $userstatic->id = $val['id'];
2004 $userstatic->lastname = $val['lastname'];
2005 $userstatic->firstname = $val['firstname'];
2006 $userstatic->email = $val['email'];
2007 $userstatic->entity = $val['entity'];
2008 $userstatic->photo = $val['photo'];
2009 $userstatic->login = $val['login'];
2010 $userstatic->office_phone = $val['office_phone'];
2011 $userstatic->office_fax = $val['office_fax'];
2012 $userstatic->user_mobile = $val['user_mobile'];
2013 $userstatic->job = $val['job'];
2014 $userstatic->gender = $val['gender'];
2015 $userstatic->statut = $val['statut'];
2016 $userstatic->status = $val['statut'];
2017 print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1, '', 0, 0, 12) : $userstatic->getNomUrl(-2);
2018 $j++;
2019 if ($j < $nbofsalesrepresentative) {
2020 print ' ';
2021 }
2022 }
2023 } else {
2024 print '&nbsp;';
2025 }
2026 print '</td>';
2027 if (!$i) {
2028 $totalarray['nbfield']++;
2029 }
2030 }
2031 // Zip
2032 if (!empty($arrayfields['s.zip']['checked'])) {
2033 print "<td>".dol_escape_htmltag($companystatic->zip)."</td>\n";
2034 if (!$i) {
2035 $totalarray['nbfield']++;
2036 }
2037 }
2038 // Town
2039 if (!empty($arrayfields['s.town']['checked'])) {
2040 print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($companystatic->town).'">'.dol_escape_htmltag($companystatic->town)."</td>\n";
2041 if (!$i) {
2042 $totalarray['nbfield']++;
2043 }
2044 }
2045 // State
2046 if (!empty($arrayfields['state.nom']['checked'])) {
2047 print "<td>".dol_escape_htmltag($obj->state_name)."</td>\n";
2048 if (!$i) {
2049 $totalarray['nbfield']++;
2050 }
2051 }
2052 // Region
2053 if (!empty($arrayfields['region.nom']['checked'])) {
2054 print "<td>".dol_escape_htmltag($obj->region_name)."</td>\n";
2055 if (!$i) {
2056 $totalarray['nbfield']++;
2057 }
2058 }
2059 // Country
2060 if (!empty($arrayfields['country.code_iso']['checked'])) {
2061 print '<td class="center tdoverflowmax100">';
2062 $labelcountry = ($companystatic->country_code && ($langs->trans("Country".$companystatic->country_code) != "Country".$companystatic->country_code)) ? $langs->trans("Country".$companystatic->country_code) : $obj->country_label;
2063 print $labelcountry;
2064 print '</td>';
2065 if (!$i) {
2066 $totalarray['nbfield']++;
2067 }
2068 }
2069 // Type ent
2070 if (!empty($arrayfields['typent.code']['checked'])) {
2071 if (!isset($typenArray) || !is_array($typenArray) || count($typenArray) == 0) {
2072 $typenArray = $formcompany->typent_array(1);
2073 }
2074 $labeltypeofcompany = empty($typenArray[$obj->typent_code]) ? '' : $typenArray[$obj->typent_code];
2075
2076 print '<td class="center tdoverflowmax125" title="'.dol_escape_htmltag($labeltypeofcompany).'">';
2077 print dol_escape_htmltag($labeltypeofcompany);
2078 print '</td>';
2079 if (!$i) {
2080 $totalarray['nbfield']++;
2081 }
2082 }
2083 // Multiprice level
2084 if (!empty($arrayfields['s.price_level']['checked'])) {
2085 print '<td class="center">'.$obj->price_level."</td>\n";
2086 if (!$i) {
2087 $totalarray['nbfield']++;
2088 }
2089 }
2090 // Staff
2091 if (!empty($arrayfields['staff.code']['checked'])) {
2092 print '<td class="center">';
2093 if (!empty($obj->staff_code)) {
2094 if (empty($conf->cache['staffArray'])) {
2095 $conf->cache['staffArray'] = $formcompany->effectif_array(1);
2096 }
2097 print $conf->cache['staffArray'][$obj->staff_code];
2098 }
2099 print '</td>';
2100 if (!$i) {
2101 $totalarray['nbfield']++;
2102 }
2103 }
2104 // Legal form
2105 if (!empty($arrayfields['legalform.code']['checked'])) {
2106 $labeltoshow = '';
2107 if (!empty($obj->legalform_code)) {
2108 if (empty($conf->cache['legalformArray'][$obj->legalform_code])) {
2109 $conf->cache['legalformArray'][$obj->legalform_code] = getFormeJuridiqueLabel($obj->legalform_code);
2110 }
2111 $labeltoshow = $conf->cache['legalformArray'][$obj->legalform_code];
2112 }
2113 print '<td class="center tdoverflowmax100" title="'.dol_escape_htmltag($labeltoshow).'">';
2114 print dol_escape_htmltag($labeltoshow);
2115 print '</td>';
2116 if (!$i) {
2117 $totalarray['nbfield']++;
2118 }
2119 }
2120 // Email
2121 if (!empty($arrayfields['s.email']['checked'])) {
2122 print '<td class="tdoverflowmax150">'.dol_print_email($obj->email, $obj->rowid, $obj->rowid, 1, 0, 0, 1)."</td>\n";
2123 if (!$i) {
2124 $totalarray['nbfield']++;
2125 }
2126 }
2127 if (!empty($arrayfields['s.phone']['checked'])) {
2128 print '<td class="nowraponall">'.dol_print_phone($obj->phone, $companystatic->country_code, 0, $obj->rowid, 'AC_TEL', ' ', 'phone')."</td>\n";
2129 if (!$i) {
2130 $totalarray['nbfield']++;
2131 }
2132 }
2133 if (!empty($arrayfields['s.phone_mobile']['checked'])) {
2134 print '<td class="nowraponall">'.dol_print_phone($obj->phone_mobile, $companystatic->country_code, 0, $obj->rowid, 'AC_TEL', ' ', 'phone_mobile')."</td>\n";
2135 if (!$i) {
2136 $totalarray['nbfield']++;
2137 }
2138 }
2139 if (!empty($arrayfields['s.fax']['checked'])) {
2140 print '<td class="nowraponall">'.dol_print_phone($obj->fax, $companystatic->country_code, 0, $obj->rowid, 'AC_TEL', ' ', 'fax')."</td>\n";
2141 if (!$i) {
2142 $totalarray['nbfield']++;
2143 }
2144 }
2145 if (!empty($arrayfields['s.url']['checked'])) {
2146 print "<td>".dol_print_url($obj->url, '', 0, 1)."</td>\n";
2147 if (!$i) {
2148 $totalarray['nbfield']++;
2149 }
2150 }
2151 if (!empty($arrayfields['s.siren']['checked'])) {
2152 print "<td>".$obj->idprof1."</td>\n";
2153 if (!$i) {
2154 $totalarray['nbfield']++;
2155 }
2156 }
2157 if (!empty($arrayfields['s.siret']['checked'])) {
2158 print "<td>".$obj->idprof2."</td>\n";
2159 if (!$i) {
2160 $totalarray['nbfield']++;
2161 }
2162 }
2163 if (!empty($arrayfields['s.ape']['checked'])) {
2164 print "<td>".$obj->idprof3."</td>\n";
2165 if (!$i) {
2166 $totalarray['nbfield']++;
2167 }
2168 }
2169 if (!empty($arrayfields['s.idprof4']['checked'])) {
2170 print "<td>".$obj->idprof4."</td>\n";
2171 if (!$i) {
2172 $totalarray['nbfield']++;
2173 }
2174 }
2175 if (!empty($arrayfields['s.idprof5']['checked'])) {
2176 print "<td>".$obj->idprof5."</td>\n";
2177 if (!$i) {
2178 $totalarray['nbfield']++;
2179 }
2180 }
2181 if (!empty($arrayfields['s.idprof6']['checked'])) {
2182 print "<td>".$obj->idprof6."</td>\n";
2183 if (!$i) {
2184 $totalarray['nbfield']++;
2185 }
2186 }
2187 // VAT
2188 if (!empty($arrayfields['s.tva_intra']['checked'])) {
2189 print '<td class="tdoverflowmax125" title="'.dol_escape_htmltag($companystatic->tva_intra).'">';
2190 if ($companystatic->tva_intra && !isValidVATID($companystatic)) {
2191 print img_warning("BadVATNumber", '', 'pictofixedwidth');
2192 }
2193 print $companystatic->tva_intra;
2194 print "</td>\n";
2195 if (!$i) {
2196 $totalarray['nbfield']++;
2197 }
2198 }
2199 // Nature
2200 if (!empty($arrayfields['customerorsupplier']['checked'])) {
2201 print '<td class="center">';
2202 print $companystatic->getTypeUrl(1);
2203 print '</td>';
2204 if (!$i) {
2205 $totalarray['nbfield']++;
2206 }
2207 }
2208 // Prospect level
2209 if (!empty($arrayfields['s.fk_prospectlevel']['checked'])) {
2210 print '<td class="center nowraponall">';
2211 print $companystatic->getLibProspLevel();
2212 print "</td>";
2213 if (!$i) {
2214 $totalarray['nbfield']++;
2215 }
2216 }
2217 // Prospect status
2218 if (!empty($arrayfields['s.fk_stcomm']['checked'])) {
2219 print '<td class="center nowraponall">';
2220
2221 $prospectid = $obj->rowid;
2222 $statusprospect = $obj->stcomm_id;
2223
2224 $formcompany->selectProspectStatus('status_prospect', $prospectstatic, $statusprospect, $prospectid);
2225
2226 print '</td>';
2227 if (!$i) {
2228 $totalarray['nbfield']++;
2229 }
2230 }
2231 // Parent company
2232 if (!empty($arrayfields['s2.nom']['checked'])) {
2233 print '<td class="center tdoverflowmax100">';
2234 if ($companystatic->parent > 0) {
2235 $companyparent->fetch($companystatic->parent);
2236 print $companyparent->getNomUrl(1);
2237 }
2238 print "</td>";
2239 if (!$i) {
2240 $totalarray['nbfield']++;
2241 }
2242 }
2243 // Extra fields
2244 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
2245 // Fields from hook
2246 $parameters = array('arrayfields' => $arrayfields, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray);
2247 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
2248 print $hookmanager->resPrint;
2249 // IP
2250 if (!empty($arrayfields['s.ip']['checked'])) {
2251 print '<td class="center nowraponall">';
2252 print dol_print_ip($obj->ip);
2253 print '</td>';
2254 if (!$i) {
2255 $totalarray['nbfield']++;
2256 }
2257 }
2258 // Date creation
2259 if (!empty($arrayfields['s.datec']['checked'])) {
2260 print '<td class="center nowraponall">';
2261 print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
2262 print '</td>';
2263 if (!$i) {
2264 $totalarray['nbfield']++;
2265 }
2266 }
2267 // Date modification
2268 if (!empty($arrayfields['s.tms']['checked'])) {
2269 print '<td class="center nowraponall">';
2270 print dol_print_date($db->jdate($obj->date_modification), 'dayhour', 'tzuser');
2271 print '</td>';
2272 if (!$i) {
2273 $totalarray['nbfield']++;
2274 }
2275 }
2276 // Note public
2277 if (!empty($arrayfields['s.note_public']['checked'])) {
2278 print '<td class="flat maxwidth250imp">';
2279 print dolPrintHTML(dolGetFirstLineOfText($obj->note_public), 5);
2280 print '</td>';
2281 if (!$i) {
2282 $totalarray['nbfield']++;
2283 }
2284 }
2285 // Note private
2286 if (!empty($arrayfields['s.note_private']['checked'])) {
2287 print '<td class="flat maxwidth250imp">';
2288 print dolPrintHTML(dolGetFirstLineOfText($obj->note_private), 5);
2289 print '</td>';
2290 if (!$i) {
2291 $totalarray['nbfield']++;
2292 }
2293 }
2294 // Status
2295 if (!empty($arrayfields['s.status']['checked'])) {
2296 print '<td class="center nowraponall">'.$companystatic->getLibStatut(5).'</td>';
2297 if (!$i) {
2298 $totalarray['nbfield']++;
2299 }
2300 }
2301 // Import key
2302 if (!empty($arrayfields['s.import_key']['checked'])) {
2303 print '<td class="tdoverflowmax125" title="'.dol_escape_htmltag($obj->import_key).'">';
2304 print dol_escape_htmltag($obj->import_key);
2305 print "</td>\n";
2306 if (!$i) {
2307 $totalarray['nbfield']++;
2308 }
2309 }
2310 // Action column (Show the massaction button only when this page is not opend from the Extended POS)
2311 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
2312 print '<td class="nowrap center actioncolumn">';
2313 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
2314 $selected = 0;
2315 if (in_array($obj->rowid, $arrayofselected)) {
2316 $selected = 1;
2317 }
2318 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
2319 }
2320 print '</td>';
2321 if (!$i) {
2322 $totalarray['nbfield']++;
2323 }
2324 }
2325
2326 print '</tr>'."\n";
2327 }
2328 $i++;
2329}
2330
2331// Show total line
2332include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
2333
2334// If no record found
2335if ($num == 0) {
2336 $colspan = 1;
2337 foreach ($arrayfields as $key => $val) {
2338 if (!empty($val['checked'])) {
2339 $colspan++;
2340 }
2341 }
2342 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
2343}
2344
2345$db->free($resql);
2346
2347$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
2348$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
2349print $hookmanager->resPrint;
2350
2351print '</table>'."\n";
2352print '</div>'."\n";
2353
2354// Line that calls the select_status function by passing it js as the 5th parameter in order to activate the js script
2355$formcompany->selectProspectStatus('status_prospect', $prospectstatic, null, null, "js");
2356
2357print '</form>'."\n";
2358
2359// End of page
2360llxFooter();
2361$db->close();
$id
Definition account.php:48
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
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
$object ref
Definition info.php:89
Class to manage customers or prospects.
Class to manage standard extra fields.
Class to manage invoices.
Class to manage forms for categories.
Class to build HTML component for third parties management Only common components are here.
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 to manage third parties objects (customers, suppliers, prospects...)
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...
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='', $useCache=true)
Return an id or code from a code or id.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
dolExplodeIntoArray($string, $delimiter=';', $kv='=')
Split a string with 2 keys into key array.
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_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
GETPOSTISARRAY($paramname, $method=0)
Return true if the parameter $paramname is submit from a POST OR GET as an array.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
get_htmloutput_mesg($mesgstring='', $mesgarray=[], $style='ok', $keepembedded=0)
Get formatted messages to output (Used to show messages on html output).
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
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.