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