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