dolibarr 24.0.1
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' => '0'),
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$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
567$htmlofselectarray = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, $conf->main_checkbox_left_column); // This also change content of $arrayfields with user setup
568
569
570// Select every potentials, and note each potentials which fit in search parameters
571$tab_level = array();
572$sql = "SELECT code, label, sortorder";
573$sql .= " FROM ".MAIN_DB_PREFIX."c_prospectlevel";
574$sql .= " WHERE active > 0";
575$sql .= " ORDER BY sortorder";
576$resql = $db->query($sql);
577if ($resql) {
578 while ($obj = $db->fetch_object($resql)) {
579 // Compute level text
580 $level = $langs->trans($obj->code);
581 if ($level == $obj->code) {
582 $level = $langs->trans($obj->label);
583 }
584 $tab_level[$obj->code] = $level;
585 }
586} else {
588}
589
590// Build and execute select
591// --------------------------------------------------------------------
592$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,";
593$sql .= " s.entity,";
594$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,";
595$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,";
596$sql .= " s.ip, s.tms as date_modification, s.datec as date_creation, s.import_key,";
597$sql .= " s.code_compta, s.code_compta_fournisseur, s.parent as fk_parent,s.price_level,";
598$sql .= " s2.nom as name2,";
599$sql .= " typent.code as typent_code,";
600$sql .= " staff.code as staff_code,";
601$sql .= " s.fk_forme_juridique as legalform_code,";
602$sql .= " country.code as country_code, country.label as country_label,";
603$sql .= " state.code_departement as state_code, state.nom as state_name,";
604$sql .= " region.code_region as region_code, region.nom as region_name";
605// Add fields from extrafields
606if (!empty($extrafields->attributes[$object->table_element]['label'])) {
607 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
608 $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
609 }
610}
611// Add fields from hooks
612$parameters = array();
613$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
614$sql .= $hookmanager->resPrint;
615$sql = preg_replace('/,\s*$/', '', $sql);
616//$sql .= ", COUNT(rc.rowid) as anotherfield";
617
618$sqlfields = $sql; // $sql fields to remove for count total
619
620$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
621$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s2 ON s.parent = s2.rowid";
622if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
623 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (s.rowid = ef.fk_object)";
624}
625
626$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)";
627$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)";
628$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_effectif as staff on (staff.id = s.fk_effectif)";
629//$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_forme_juridique as legalform on (legalform.rowid = s.fk_forme_juridique)";
630$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)";
631$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as region on (region.code_region = state.fk_region)";
632$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."c_stcomm as st ON s.fk_stcomm = st.id";
633// Add table from hooks
634$parameters = array();
635$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
636$sql .= $hookmanager->resPrint;
637$sql .= " WHERE s.entity IN (".getEntity('societe').")";
638if (!$user->hasRight('fournisseur', 'lire')) {
639 $sql .= " AND (s.fournisseur <> 1 OR s.client <> 0)"; // client=0, fournisseur=0 must be visible
640}
641
642// Force the sales representative if they don't have permissions
643if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
644 $search_sale = array($user->id);
645}
646// Search on sale representative
647if (!empty($search_sale) && $search_sale != '-1') {
648 $search_sale_req = array_filter($search_sale, function (string $value): bool {
649 $value = intval($value);
650 return $value >= 0;
651 });
652
653 $search_sale_req = implode(',', $search_sale_req);
654
655 if (count($search_sale) == 1 && in_array('-2', $search_sale)) {
656 $sql .= " AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = s.rowid)";
657 } elseif (count($search_sale) > 0 && !in_array('-2', $search_sale)) {
658 $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)."))";
659 } elseif (count($search_sale) > 0 && in_array('-2', $search_sale)) {
660 $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)."))";
661 $sql .= " OR NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = s.rowid))";
662 }
663}
664
665// Search for tag/category ($searchCategoryCustomerList is an array of ID)
666if (!empty($searchCategoryCustomerList)) {
667 $searchCategoryCustomerSqlList = array();
668 $listofcategoryid = '';
669 foreach ($searchCategoryCustomerList as $searchCategoryCustomer) {
670 if (intval($searchCategoryCustomer) == -2) {
671 $searchCategoryCustomerSqlList[] = "NOT EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe as ck WHERE s.rowid = ck.fk_soc)";
672 } elseif (intval($searchCategoryCustomer) > 0) {
673 if ($searchCategoryCustomerOperator == 0) {
674 $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).")";
675 } else {
676 $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryCustomer);
677 }
678 }
679 }
680 if ($listofcategoryid) {
681 $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)."))";
682 }
683 if ($searchCategoryCustomerOperator == 1) {
684 if (!empty($searchCategoryCustomerSqlList)) {
685 $sql .= " AND (".implode(' OR ', $searchCategoryCustomerSqlList).")";
686 }
687 } else {
688 if (!empty($searchCategoryCustomerSqlList)) {
689 $sql .= " AND (".implode(' AND ', $searchCategoryCustomerSqlList).")";
690 }
691 }
692}
693
694// Search for tag/category ($searchCategorySupplierList is an array of ID)
695if (!empty($searchCategorySupplierList)) {
696 $searchCategorySupplierSqlList = array();
697 $listofcategoryid = '';
698 foreach ($searchCategorySupplierList as $searchCategorySupplier) {
699 if (intval($searchCategorySupplier) == -2) {
700 $searchCategorySupplierSqlList[] = "NOT EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_fournisseur as ck WHERE s.rowid = ck.fk_soc)";
701 } elseif (intval($searchCategorySupplier) > 0) {
702 if ($searchCategorySupplierOperator == 0) {
703 $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).")";
704 } else {
705 $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategorySupplier);
706 }
707 }
708 }
709 if ($listofcategoryid) {
710 $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)."))";
711 }
712 if ($searchCategorySupplierOperator == 1) {
713 if (!empty($searchCategorySupplierSqlList)) {
714 $sql .= " AND (".implode(' OR ', $searchCategorySupplierSqlList).")";
715 }
716 } else {
717 if (!empty($searchCategorySupplierSqlList)) {
718 $sql .= " AND (".implode(' AND ', $searchCategorySupplierSqlList).")";
719 }
720 }
721}
722if ($search_all) {
723 $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
724}
725if (strlen($search_cti)) {
726 $sql .= natural_search('s.phone', $search_cti);
727}
728if ($search_id > 0) {
729 $sql .= natural_search("s.rowid", $search_id, 1);
730}
731if (empty($arrayfields['s.name_alias']['checked']) && $search_nom) {
732 $sql .= natural_search(array("s.nom", "s.name_alias"), $search_nom);
733} else {
734 if ($search_nom) {
735 $sql .= natural_search("s.nom", $search_nom);
736 }
737 if ($search_alias) {
738 $sql .= natural_search("s.name_alias", $search_alias);
739 }
740}
741if ($search_nom_only) {
742 $sql .= natural_search("s.nom", $search_nom_only);
743}
744if ($search_ref_ext) {
745 $sql .= natural_search("s.ref_ext", $search_ref_ext);
746}
747if ($search_customer_code) {
748 $sql .= natural_search("s.code_client", $search_customer_code);
749}
750if ($search_supplier_code) {
751 $sql .= natural_search("s.code_fournisseur", $search_supplier_code);
752}
753if ($search_account_customer_code) {
754 $sql .= natural_search("s.code_compta", $search_account_customer_code);
755}
756if ($search_account_supplier_code) {
757 $sql .= natural_search("s.code_compta_fournisseur", $search_account_supplier_code);
758}
759if ($search_address) {
760 $sql .= natural_search('s.address', $search_address);
761}
762if (strlen($search_zip)) {
763 $sql .= natural_search("s.zip", $search_zip);
764}
765if ($search_town) {
766 $sql .= natural_search("s.town", $search_town);
767}
768if ($search_state) {
769 $sql .= natural_search("state.nom", $search_state);
770}
771if ($search_region) {
772 $sql .= natural_search("region.nom", $search_region);
773}
774if ($search_country && $search_country != '-1') {
775 $sql .= " AND s.fk_pays IN (".$db->sanitize($search_country).')';
776}
777if ($search_email) {
778 $sql .= natural_search("s.email", $search_email);
779}
780if ($search_noemail) {
781 $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')."))";
782}
783if (strlen($search_phone)) {
784 $sql .= natural_search("s.phone", $search_phone);
785}
786if (strlen($search_phone_mobile)) {
787 $sql .= natural_search("s.phone_mobile", $search_phone_mobile);
788}
789if (strlen($search_fax)) {
790 $sql .= natural_search("s.fax", $search_fax);
791}
792if ($search_url) {
793 $sql .= natural_search("s.url", $search_url);
794}
795if (strlen($search_idprof1)) {
796 $sql .= natural_search("s.siren", $search_idprof1);
797}
798if (strlen($search_idprof2)) {
799 $sql .= natural_search("s.siret", $search_idprof2);
800}
801if (strlen($search_idprof3)) {
802 $sql .= natural_search("s.ape", $search_idprof3);
803}
804if (strlen($search_idprof4)) {
805 $sql .= natural_search("s.idprof4", $search_idprof4);
806}
807if (strlen($search_idprof5)) {
808 $sql .= natural_search("s.idprof5", $search_idprof5);
809}
810if (strlen($search_idprof6)) {
811 $sql .= natural_search("s.idprof6", $search_idprof6);
812}
813if (strlen($search_vat)) {
814 $sql .= natural_search("s.tva_intra", $search_vat);
815}
816// Filter on type of thirdparty
817$reshook = $hookmanager->executeHooks('filterType', array('search_type' => $search_type), $sql);
818if (empty($reshook)) {
819 if ($search_type > 0 && in_array($search_type, array('1,3', '1,2,3', '2,3'))) {
820 $sql .= " AND s.client IN (".$db->sanitize($search_type).")";
821 }
822}
823if ($search_type > 0 && in_array($search_type, array('4'))) {
824 $sql .= " AND s.fournisseur = 1";
825}
826if ($search_type == '0') {
827 $sql .= " AND s.client = 0 AND s.fournisseur = 0";
828}
829if ($search_status != '' && $search_status >= 0) {
830 $sql .= natural_search("s.status", $search_status, 2);
831}
832if (isModEnabled('barcode') && $search_barcode) {
833 $sql .= natural_search("s.barcode", $search_barcode);
834}
835if ($search_price_level && $search_price_level != '-1') {
836 $sql .= natural_search("s.price_level", $search_price_level, 2);
837}
838if ($search_type_thirdparty && $search_type_thirdparty > 0) {
839 $sql .= natural_search("s.fk_typent", $search_type_thirdparty, 2);
840}
841if (!empty($search_staff) && $search_staff != '-1') {
842 $sql .= natural_search("s.fk_effectif", $search_staff, 2);
843}
844if (!empty($search_legalform) && $search_legalform != '-1') {
845 $sql .= natural_search("s.fk_forme_juridique", $search_legalform, 2);
846}
847if ($search_parent_name) {
848 $sql .= natural_search("s2.nom", $search_parent_name);
849}
850if ($search_level) {
851 $sql .= natural_search("s.fk_prospectlevel", implode(',', $search_level), 3);
852}
853if ($search_stcomm) {
854 $sql .= natural_search("s.fk_stcomm", implode(',', $search_stcomm), 2);
855}
856if ($search_import_key) {
857 $sql .= natural_search("s.import_key", $search_import_key);
858}
859if ($search_note_public != '') {
860 $sql .= natural_search('s.note_public', $search_note_public);
861}
862if ($search_note_private != '') {
863 $sql .= natural_search('s.note_private', $search_note_private);
864}
865if ($search_date_creation_start) {
866 $sql .= " AND s.datec >= '".$db->idate($search_date_creation_start)."'";
867}
868if ($search_date_creation_end) {
869 $sql .= " AND s.datec <= '".$db->idate($search_date_creation_end)."'";
870}
871
872if ($search_date_modif_start) {
873 $sql .= " AND s.tms >= '".$db->idate($search_date_modif_start)."'";
874}
875if ($search_date_modif_end) {
876 $sql .= " AND s.tms <= '".$db->idate($search_date_modif_end)."'";
877}
878if ($socid) {
879 $sql .= " AND s.rowid = ".((int) $socid);
880}
881
882// Add where from extra fields
883include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
884// Add where from hooks
885$parameters = array('socid' => $socid, 'sql' => $sql);
886$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
887if (empty($reshook)) {
888 $sql .= $hookmanager->resPrint;
889} else {
890 $sql = $hookmanager->resPrint;
891}
892
893// Add GroupBy from hooks
894$parameters = array('fieldstosearchall' => $fieldstosearchall);
895$reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
896if (empty($reshook)) {
897 $sql .= $hookmanager->resPrint;
898} else {
899 $sql = $hookmanager->resPrint;
900}
901
902// Count total nb of records
903$nbtotalofrecords = '';
904if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
905 /* The fast and low memory method to get and count full list converts the sql into a sql count */
906 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
907 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
908 $resql = $db->query($sqlforcount);
909 if ($resql) {
910 $objforcount = $db->fetch_object($resql);
911 $nbtotalofrecords = $objforcount->nbtotalofrecords;
912 } else {
914 }
915
916 if (($page * $limit) > (int) $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
917 $page = 0;
918 $offset = 0;
919 }
920 $db->free($resql);
921}
922
923// Complete request and execute it with limit
924$sql .= $db->order($sortfield, $sortorder);
925if ($limit) {
926 $sql .= $db->plimit($limit + 1, $offset);
927}
928$resql = $db->query($sql);
929if (!$resql) {
931 exit;
932}
933
934$num = $db->num_rows($resql);
935
936
937// Direct jump if only one record found
938if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && ($search_all != '' || $search_cti != '') && $action != 'list') {
939 $obj = $db->fetch_object($resql);
940 $id = $obj->rowid;
941 if (getDolGlobalString('SOCIETE_ON_SEARCH_AND_LIST_GO_ON_CUSTOMER_OR_SUPPLIER_CARD')) {
942 if ($obj->client > 0) {
943 header("Location: ".DOL_URL_ROOT.'/comm/card.php?socid='.$id);
944 exit;
945 }
946 if ($obj->fournisseur > 0) {
947 header("Location: ".DOL_URL_ROOT.'/fourn/card.php?socid='.$id);
948 exit;
949 }
950 }
951
952 header("Location: ".DOL_URL_ROOT.'/societe/card.php?socid='.$id);
953 exit;
954}
955
956// Output page
957// --------------------------------------------------------------------
958
959$paramsCat = '';
960foreach ($searchCategoryCustomerList as $searchCategoryCustomer) {
961 $paramsCat .= "&search_category_customer_list[]=".urlencode($searchCategoryCustomer);
962}
963foreach ($searchCategorySupplierList as $searchCategorySupplier) {
964 $paramsCat .= "&search_category_supplier_list[]=".urlencode($searchCategorySupplier);
965}
966
967llxHeader('', $title, $help_url, '', 0, 0, array(), array(), $paramsCat, 'bodyforlist');
968
969
970$arrayofselected = is_array($toselect) ? $toselect : array();
971
972$param = '';
973if (!empty($mode)) {
974 $param .= '&mode='.urlencode($mode);
975}
976if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
977 $param .= '&contextpage='.urlencode($contextpage);
978}
979if ($limit > 0 && $limit != $conf->liste_limit) {
980 $param .= '&limit='.((int) $limit);
981}
982if ($optioncss != '') {
983 $param .= '&optioncss='.urlencode($optioncss);
984}
985if ($search_all != '') {
986 $param = "&search_all=".urlencode($search_all);
987}
988if ($search_categ_cus > 0) {
989 $param .= '&search_categ_cus='.urlencode((string) ($search_categ_cus));
990}
991if ($search_categ_sup > 0) {
992 $param .= '&search_categ_sup='.urlencode((string) ($search_categ_sup));
993}
994if ($searchCategoryCustomerOperator == 1) {
995 $param .= "&search_category_customer_operator=".urlencode((string) ($searchCategoryCustomerOperator));
996}
997if ($searchCategorySupplierOperator == 1) {
998 $param .= "&search_category_supplier_operator=".urlencode((string) ($searchCategorySupplierOperator));
999}
1000foreach ($searchCategoryCustomerList as $searchCategoryCustomer) {
1001 $param .= "&search_category_customer_list[]=".urlencode($searchCategoryCustomer);
1002}
1003foreach ($searchCategorySupplierList as $searchCategorySupplier) {
1004 $param .= "&search_category_supplier_list[]=".urlencode($searchCategorySupplier);
1005}
1006if (is_array($search_sale)) {
1007 foreach ($search_sale as $sale_id) {
1008 $param .= '&search_sale[]=' . urlencode($sale_id);
1009 }
1010}
1011if ($search_id > 0) {
1012 $param .= "&search_id=".((int) $search_id);
1013}
1014if ($search_nom != '') {
1015 $param .= "&search_nom=".urlencode($search_nom);
1016}
1017if ($search_alias != '') {
1018 $param .= "&search_alias=".urlencode($search_alias);
1019}
1020if ($search_ref_ext != '') {
1021 $param .= "&search_ref_ext=".urlencode($search_ref_ext);
1022}
1023if ($search_address != '') {
1024 $param .= '&search_address='.urlencode($search_address);
1025}
1026if ($search_zip != '') {
1027 $param .= "&search_zip=".urlencode($search_zip);
1028}
1029if ($search_town != '') {
1030 $param .= "&search_town=".urlencode($search_town);
1031}
1032if ($search_phone != '') {
1033 $param .= "&search_phone=".urlencode($search_phone);
1034}
1035if ($search_phone_mobile != '') {
1036 $param .= "&search_phone_mobile=".urlencode($search_phone_mobile);
1037}
1038if ($search_fax != '') {
1039 $param .= "&search_fax=".urlencode($search_fax);
1040}
1041if ($search_email != '') {
1042 $param .= "&search_email=".urlencode($search_email);
1043}
1044if ($search_noemail != '') {
1045 $param .= "&search_noemail=".urlencode($search_noemail);
1046}
1047if ($search_url != '') {
1048 $param .= "&search_url=".urlencode($search_url);
1049}
1050if ($search_state != '') {
1051 $param .= "&search_state=".urlencode($search_state);
1052}
1053if ($search_region != '') {
1054 $param .= "&search_region=".urlencode($search_region);
1055}
1056if ($search_country != '') {
1057 $param .= "&search_country=".urlencode($search_country);
1058}
1059if ($search_customer_code != '') {
1060 $param .= "&search_customer_code=".urlencode($search_customer_code);
1061}
1062if ($search_supplier_code != '') {
1063 $param .= "&search_supplier_code=".urlencode($search_supplier_code);
1064}
1065if ($search_account_customer_code != '') {
1066 $param .= "&search_account_customer_code=".urlencode($search_account_customer_code);
1067}
1068if ($search_account_supplier_code != '') {
1069 $param .= "&search_account_supplier_code=".urlencode($search_account_supplier_code);
1070}
1071if ($search_barcode != '') {
1072 $param .= "&search_barcode=".urlencode($search_barcode);
1073}
1074if ($search_idprof1 != '') {
1075 $param .= '&search_idprof1='.urlencode($search_idprof1);
1076}
1077if ($search_idprof2 != '') {
1078 $param .= '&search_idprof2='.urlencode($search_idprof2);
1079}
1080if ($search_idprof3 != '') {
1081 $param .= '&search_idprof3='.urlencode($search_idprof3);
1082}
1083if ($search_idprof4 != '') {
1084 $param .= '&search_idprof4='.urlencode($search_idprof4);
1085}
1086if ($search_idprof5 != '') {
1087 $param .= '&search_idprof5='.urlencode($search_idprof5);
1088}
1089if ($search_idprof6 != '') {
1090 $param .= '&search_idprof6='.urlencode($search_idprof6);
1091}
1092if ($search_vat != '') {
1093 $param .= '&search_vat='.urlencode($search_vat);
1094}
1095if ($search_price_level != '') {
1096 $param .= '&search_price_level='.urlencode($search_price_level);
1097}
1098if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) {
1099 $param .= '&search_type_thirdparty='.urlencode((string) ($search_type_thirdparty));
1100}
1101if ($search_type != '') {
1102 $param .= '&search_type='.urlencode($search_type);
1103}
1104if ($search_status != '') {
1105 $param .= '&search_status='.urlencode((string) ($search_status));
1106}
1107if (is_array($search_level) && count($search_level)) {
1108 foreach ($search_level as $slevel) {
1109 $param .= '&search_level[]='.urlencode($slevel);
1110 }
1111}
1112if (is_array($search_stcomm) && count($search_stcomm)) {
1113 foreach ($search_stcomm as $slevel) {
1114 $param .= '&search_stcomm[]='.urlencode($slevel);
1115 }
1116}
1117if ($search_parent_name != '') {
1118 $param .= '&search_parent_name='.urlencode($search_parent_name);
1119}
1120if ($search_import_key != '') {
1121 $param .= '&search_import_key='.urlencode($search_import_key);
1122}
1123if ($search_note_public != '') {
1124 $param .= '&search_note_public='.urlencode($search_note_public);
1125}
1126if ($search_note_private != '') {
1127 $param .= '&search_note_private='.urlencode($search_note_private);
1128}
1129if ($type != '') {
1130 $param .= '&type='.urlencode($type);
1131}
1132if ($search_date_creation_startmonth) {
1133 $param .= '&search_date_creation_startmonth='.urlencode((string) ($search_date_creation_startmonth));
1134}
1135if ($search_date_creation_startyear) {
1136 $param .= '&search_date_creation_startyear='.urlencode((string) ($search_date_creation_startyear));
1137}
1138if ($search_date_creation_startday) {
1139 $param .= '&search_date_creation_startday='.urlencode((string) ($search_date_creation_startday));
1140}
1141if ($search_date_creation_start) {
1142 $param .= '&search_date_creation_start='.urlencode((string) $search_date_creation_start);
1143}
1144if ($search_date_creation_endmonth) {
1145 $param .= '&search_date_creation_endmonth='.urlencode((string) ($search_date_creation_endmonth));
1146}
1147if ($search_date_creation_endyear) {
1148 $param .= '&search_date_creation_endyear='.urlencode((string) ($search_date_creation_endyear));
1149}
1150if ($search_date_creation_endday) {
1151 $param .= '&search_date_creation_endday='.urlencode((string) ($search_date_creation_endday));
1152}
1153if ($search_date_creation_end) {
1154 $param .= '&search_date_creation_end='.urlencode((string) $search_date_creation_end);
1155}
1156if ($search_date_modif_startmonth) {
1157 $param .= '&search_date_modif_startmonth='.urlencode((string) ($search_date_modif_startmonth));
1158}
1159if ($search_date_modif_startyear) {
1160 $param .= '&search_date_modif_startyear='.urlencode((string) ($search_date_modif_startyear));
1161}
1162if ($search_date_modif_startday) {
1163 $param .= '&search_date_modif_startday='.urlencode((string) ($search_date_modif_startday));
1164}
1165if ($search_date_modif_start) {
1166 $param .= '&search_date_modif_start='.urlencode((string) $search_date_modif_start);
1167}
1168if ($search_date_modif_endmonth) {
1169 $param .= '&search_date_modif_endmonth='.urlencode((string) ($search_date_modif_endmonth));
1170}
1171if ($search_date_modif_endyear) {
1172 $param .= '&search_date_modif_endyear='.urlencode((string) ($search_date_modif_endyear));
1173}
1174if ($search_date_modif_endday) {
1175 $param .= '&search_date_modif_endday='.urlencode((string) ($search_date_modif_endday));
1176}
1177if ($search_date_modif_end) {
1178 $param .= '&search_date_modif_end=' . urlencode((string) $search_date_modif_end);
1179}
1180
1181// Add $param from extra fields
1182include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
1183// Add $param from hooks
1184$parameters = array('param' => &$param);
1185$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1186$param .= $hookmanager->resPrint;
1187
1188// Show delete result message
1189if (GETPOST('delsoc')) {
1190 setEventMessages($langs->trans("CompanyDeleted", GETPOST('delsoc')), null, 'mesgs');
1191}
1192
1193// List of mass actions available
1194$arrayofmassactions = array(
1195 'presend' => img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
1196 //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
1197);
1198//if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer");
1199if (isModEnabled('category') && $user->hasRight("societe", "creer")) {
1200 $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag");
1201}
1202if ($user->hasRight("societe", "creer")) {
1203 $arrayofmassactions['preenable'] = img_picto('', 'stop-circle', 'class="pictofixedwidth"').$langs->trans("SetToStatus", $object->LibStatut($object::STATUS_INACTIVITY));
1204}
1205if ($user->hasRight("societe", "creer")) {
1206 $arrayofmassactions['predisable'] = img_picto('', 'stop-circle', 'class="pictofixedwidth"').$langs->trans("SetToStatus", $object->LibStatut($object::STATUS_CEASED));
1207}
1208if ($user->hasRight("societe", "creer")) {
1209 $arrayofmassactions['presetcommercial'] = img_picto('', 'user', 'class="pictofixedwidth"').$langs->trans("AllocateCommercial");
1210 $arrayofmassactions['unsetcommercial'] = img_picto('', 'user', 'class="pictofixedwidth"').$langs->trans("UnallocateCommercial");
1211}
1212
1213if ($user->hasRight('societe', 'supprimer')) {
1214 $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
1215}
1216if (GETPOSTINT('nomassaction') || in_array($massaction, array('presend', 'predelete', 'preaffecttag', 'preenable', 'preclose'))) {
1217 $arrayofmassactions = array();
1218}
1219$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
1220
1221$typefilter = '';
1222$label = 'MenuNewThirdParty';
1223
1224if (!empty($type)) {
1225 $typefilter = '&amp;type='.$type;
1226 if ($type == 'p') {
1227 $label = 'MenuNewProspect';
1228 }
1229 if ($type == 'c') {
1230 $label = 'MenuNewCustomer';
1231 }
1232 if ($type == 'f') {
1233 $label = 'NewSupplier';
1234 }
1235}
1236
1237if ($contextpage == 'poslist' && $type == 't' && (getDolGlobalString('PRODUIT_MULTIPRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_AND_MULTIPRICES'))) {
1238 print get_htmloutput_mesg(img_warning('default').' '.$langs->trans("BecarefullChangeThirdpartyBeforeAddProductToInvoice"), [], 'warning', 1);
1239}
1240
1241$newcardbutton = '';
1242$parameters = array();
1243$reshook = $hookmanager->executeHooks('printNewCardButton', $parameters, $object);
1244if (empty($reshook)) {
1245 // Show the new button only when this page is not opened from the Extended POS (pop-up window)
1246 // but allow it too, when a user has the rights to create a new customer
1247 if ($contextpage != 'poslist') {
1248 $url = DOL_URL_ROOT.'/societe/card.php?action=create'.$typefilter;
1249 if (!empty($socid)) {
1250 $url .= '&socid='.$socid;
1251 }
1252 $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'));
1253 $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'));
1254 $newcardbutton .= dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', $url, '', $user->hasRight('societe', 'creer'));
1255 } elseif ($user->hasRight('societe', 'creer')) {
1256 $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);
1257 $label = 'MenuNewCustomer';
1258 $newcardbutton = dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', $url);
1259 }
1260} else {
1261 $newcardbutton = $hookmanager->resPrint;
1262}
1263
1264print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'" name="formfilter" autocomplete="off" spellcheck="false">'."\n";
1265if ($optioncss != '') {
1266 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
1267}
1268print '<input type="hidden" name="token" value="'.newToken().'">';
1269print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1270if (empty($massaction)) {
1271 print '<input type="hidden" name="action" value="list">';
1272}
1273print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
1274print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
1275//print '<input type="hidden" name="page" value="'.$page.'">';
1276print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
1277if (!empty($place)) {
1278 print '<input type="hidden" name="place" value="'.$place.'">';
1279}
1280print '<input type="hidden" name="page_y" value="">';
1281print '<input type="hidden" name="mode" value="'.$mode.'">';
1282if (empty($arrayfields['customerorsupplier']['checked'])) {
1283 print '<input type="hidden" name="type" value="'.$type.'">';
1284}
1285if (!empty($place)) {
1286 print '<input type="hidden" name="place" value="'.$place.'">';
1287}
1288
1289print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'building', 0, $newcardbutton, '', $limit, 0, 0, 1);
1290
1291$langs->load("other");
1292$textprofid = array();
1293foreach (array(1, 2, 3, 4, 5, 6) as $key) {
1294 $label = $langs->transnoentities("ProfId".$key.$mysoc->country_code);
1295 $textprofid[$key] = '';
1296 if ($label != "ProfId".$key.$mysoc->country_code) { // Get only text between ()
1297 $reg = array();
1298 if (preg_match('/\‍((.*)\‍)/i', $label, $reg)) {
1299 $label = $reg[1];
1300 }
1301 // @phan-suppress-next-line PhanPluginSuspiciousParamPosition
1302 $textprofid[$key] = $langs->trans("ProfIdShortDesc", $key, $mysoc->country_code, $label);
1303 }
1304}
1305
1306// Add code for pre mass action (confirmation or email presend form)
1307$topicmail = "Information";
1308$modelmail = "thirdparty";
1309$objecttmp = new Societe($db);
1310$trackid = 'thi'.$object->id;
1311include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
1312
1313/*
1314if (!empty($search_categ_cus) || !empty($search_categ_sup)) {
1315 print "<div id='ways'>";
1316 $c = new Categorie($db);
1317 $ways = $c->print_all_ways('auto', 'societe/list.php');
1318 print " &gt; ".$ways[0]."<br>\n";
1319 print "</div><br>";
1320}
1321*/
1322
1323if ($search_all) {
1324 $setupstring = '';
1325 foreach ($fieldstosearchall as $key => $val) {
1326 $fieldstosearchall[$key] = $langs->trans($val);
1327 $setupstring .= $key."=".$val.";";
1328 }
1329 print '<!-- Search done like if SOCIETE_QUICKSEARCH_ON_FIELDS = '.$setupstring.' -->'."\n";
1330 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'</div>';
1331}
1332
1333$moreforfilter = '';
1334
1335// Filter for customer categories
1336if (empty($type) || $type == 'c' || $type == 'p') {
1337 if (isModEnabled('category') && $user->hasRight('categorie', 'read')) {
1338 $formcategory = new FormCategory($db);
1339 $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_CUSTOMER, $searchCategoryCustomerList, 'minwidth300', $searchCategoryCustomerOperator ? $searchCategoryCustomerOperator : 0, 1, 1, $langs->transnoentities("CustomersProspectsCategoriesShort"));
1340 }
1341}
1342
1343// Filter for supplier categories
1344if (empty($type) || $type == 'f') {
1345 if (isModEnabled("fournisseur") && isModEnabled('category') && $user->hasRight('categorie', 'read')) {
1346 $formcategory = new FormCategory($db);
1347 $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_SUPPLIER, $searchCategorySupplierList, 'minwidth300', $searchCategorySupplierOperator ? $searchCategorySupplierOperator : 0, 1, 1, $langs->transnoentities("SuppliersCategoriesShort"));
1348 }
1349}
1350
1351// If the user can view prospects other than his'
1352$userlist = $form->select_dolusers('', '', 0, null, 0, '', '', '0', 0, 0, 'u.statut:=:1', 0, '', '', 0, 1);
1353$userlist[-2] = $langs->trans("NoSalesRepresentativeAffected");
1354if ($user->hasRight("societe", "client", "voir") || $socid) {
1355 $moreforfilter .= '<div class="divsearchfield">';
1356 $tmptitle = $langs->transnoentitiesnoconv('SalesRepresentatives');
1357 $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"');
1358 $moreforfilter .= $form->multiselectarray('search_sale', $userlist, $search_sale, 0, 0, '', 0, 300, '', '', $langs->transnoentitiesnoconv('SalesRepresentatives'), 1);
1359 $moreforfilter .= '</div>';
1360}
1361if (!empty($moreforfilter)) {
1362 print '<div class="liste_titre liste_titre_bydiv centpercent">';
1363 print $moreforfilter;
1364 $parameters = array('type' => $type);
1365 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1366 print $hookmanager->resPrint;
1367 print '</div>';
1368}
1369
1370$selectedfields = ($mode != 'kanban' ? $htmlofselectarray : '');
1371$selectedfields .= ((count($arrayofmassactions) && $contextpage != 'poslist') ? $form->showCheckAddButtons('checkforselect', 1) : '');
1372
1373print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
1374print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
1375
1376// Fields title search
1377// --------------------------------------------------------------------
1378print '<tr class="liste_titre_filter">';
1379// Action column
1380if ($conf->main_checkbox_left_column) {
1381 print '<td class="liste_titre maxwidthsearch center actioncolumn">';
1382 $searchpicto = $form->showFilterButtons('left');
1383 print $searchpicto;
1384 print '</td>';
1385}
1386if (!empty($arrayfields['s.rowid']['checked'])) {
1387 print '<td class="liste_titre" data-key="id">';
1388 print '<input class="flat searchstring" type="text" name="search_id" size="1" value="'.dol_escape_htmltag($search_id).'">';
1389 print '</td>';
1390}
1391if (!empty($arrayfields['s.nom']['checked'])) {
1392 print '<td class="liste_titre" data-key="ref">';
1393 if (!empty($search_nom_only) && empty($search_nom)) {
1394 $search_nom = $search_nom_only;
1395 }
1396 print '<input class="flat searchstring maxwidth75imp" type="text" name="search_nom" value="'.dol_escape_htmltag($search_nom).'">';
1397 print '</td>';
1398}
1399if (!empty($arrayfields['s.name_alias']['checked'])) {
1400 print '<td class="liste_titre">';
1401 print '<input class="flat searchstring maxwidth75imp" type="text" name="search_alias" value="'.dol_escape_htmltag($search_alias).'">';
1402 print '</td>';
1403}
1404if (!empty($arrayfields['s.ref_ext']['checked'])) {
1405 print '<td class="liste_titre">';
1406 print '<input class="flat searchstring maxwidth75imp" type="text" name="search_ref_ext" value="'.dol_escape_htmltag($search_ref_ext).'">';
1407 print '</td>';
1408}
1409// Barcode
1410if (!empty($arrayfields['s.barcode']['checked'])) {
1411 print '<td class="liste_titre">';
1412 print '<input class="flat searchstring maxwidth75imp" type="text" name="search_barcode" value="'.dol_escape_htmltag($search_barcode).'">';
1413 print '</td>';
1414}
1415// Customer code
1416if (!empty($arrayfields['s.code_client']['checked'])) {
1417 print '<td class="liste_titre">';
1418 print '<input class="flat searchstring maxwidth75imp" type="text" name="search_customer_code" value="'.dol_escape_htmltag($search_customer_code).'">';
1419 print '</td>';
1420}
1421// Supplier code
1422if (!empty($arrayfields['s.code_fournisseur']['checked'])) {
1423 print '<td class="liste_titre">';
1424 print '<input class="flat searchstring maxwidth75imp" type="text" name="search_supplier_code" value="'.dol_escape_htmltag($search_supplier_code).'">';
1425 print '</td>';
1426}
1427// Account Customer code
1428if (!empty($arrayfields['s.code_compta']['checked'])) {
1429 print '<td class="liste_titre">';
1430 print '<input class="flat searchstring maxwidth75imp" type="text" name="search_account_customer_code" value="'.dol_escape_htmltag($search_account_customer_code).'">';
1431 print '</td>';
1432}
1433// Account Supplier code
1434if (!empty($arrayfields['s.code_compta_fournisseur']['checked'])) {
1435 print '<td class="liste_titre">';
1436 print '<input class="flat maxwidth75imp" type="text" name="search_account_supplier_code" value="'.dol_escape_htmltag($search_account_supplier_code).'">';
1437 print '</td>';
1438}
1439// Address
1440if (!empty($arrayfields['s.address']['checked'])) {
1441 print '<td class="liste_titre">';
1442 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_address" value="'.dol_escape_htmltag($search_address).'">';
1443 print '</td>';
1444}
1445// Zip
1446if (!empty($arrayfields['s.zip']['checked'])) {
1447 print '<td class="liste_titre">';
1448 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_zip" value="'.dol_escape_htmltag($search_zip).'">';
1449 print '</td>';
1450}
1451// Town
1452if (!empty($arrayfields['s.town']['checked'])) {
1453 print '<td class="liste_titre">';
1454 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_town" value="'.dol_escape_htmltag($search_town).'">';
1455 print '</td>';
1456}
1457// State
1458if (!empty($arrayfields['state.nom']['checked'])) {
1459 print '<td class="liste_titre">';
1460 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
1461 print '</td>';
1462}
1463// Region
1464if (!empty($arrayfields['region.nom']['checked'])) {
1465 print '<td class="liste_titre">';
1466 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_region" value="'.dol_escape_htmltag($search_region).'">';
1467 print '</td>';
1468}
1469// Country
1470if (!empty($arrayfields['country.code_iso']['checked'])) {
1471 print '<td class="liste_titre center">';
1472 print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100');
1473 print '</td>';
1474}
1475// Company type
1476if (!empty($arrayfields['typent.code']['checked'])) {
1477 print '<td class="liste_titre maxwidthonsmartphone center">';
1478 // We use showempty=0 here because there is already an unknown value into dictionary.
1479 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);
1480 print '</td>';
1481}
1482// Multiprice level
1483if (!empty($arrayfields['s.price_level']['checked'])) {
1484 print '<td class="liste_titre">';
1485 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_price_level" value="'.dol_escape_htmltag($search_price_level).'">';
1486 print '</td>';
1487}
1488// Staff
1489if (!empty($arrayfields['staff.code']['checked'])) {
1490 print '<td class="liste_titre maxwidthonsmartphone center">';
1491 print $form->selectarray("search_staff", $formcompany->effectif_array(0), $search_staff, 0, 0, 0, '', 0, 0, 0, 'ASC', 'maxwidth100', 1);
1492 print '</td>';
1493}
1494// Legal form
1495if (!empty($arrayfields['legalform.code']['checked'])) {
1496 print '<td class="liste_titre maxwidthonsmartphone center">';
1497 //print $form->selectarray("search_legalform", $formcompany->effectif_array(0), $search_legalform, 0, 0, 0, '', 0, 0, 0, 'ASC', 'maxwidth100', 1);
1498 print '</td>';
1499}
1500if (!empty($arrayfields['s.email']['checked'])) {
1501 // Email
1502 print '<td class="liste_titre">';
1503 print '<input class="flat searchemail maxwidth50imp" type="text" name="search_email" value="'.dol_escape_htmltag($search_email).'">';
1504 print '</td>';
1505}
1506if (!empty($arrayfields['su.noemail']['checked'])) {
1507 // Email
1508 print '<td class="liste_titre center">';
1509 print '<input class="flat searchemail maxwidth50imp" type="checkbox" name="search_noemail" '.($search_noemail ? ' checked="checked"' : '').'">';
1510 print '</td>';
1511}
1512if (!empty($arrayfields['s.phone']['checked'])) {
1513 // Phone
1514 print '<td class="liste_titre">';
1515 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_phone" value="'.dol_escape_htmltag($search_phone).'">';
1516 print '</td>';
1517}
1518if (!empty($arrayfields['s.phone_mobile']['checked'])) {
1519 // PhoneMobile
1520 print '<td class="liste_titre">';
1521 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_phone_mobile" value="'.dol_escape_htmltag($search_phone_mobile).'">';
1522 print '</td>';
1523}
1524if (!empty($arrayfields['s.fax']['checked'])) {
1525 // Fax
1526 print '<td class="liste_titre">';
1527 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_fax" value="'.dol_escape_htmltag($search_fax).'">';
1528 print '</td>';
1529}
1530if (!empty($arrayfields['s.url']['checked'])) {
1531 // Url
1532 print '<td class="liste_titre">';
1533 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_url" value="'.dol_escape_htmltag($search_url).'">';
1534 print '</td>';
1535}
1536if (!empty($arrayfields['s.siren']['checked'])) {
1537 // IdProf1
1538 print '<td class="liste_titre">';
1539 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_idprof1" value="'.dol_escape_htmltag($search_idprof1).'">';
1540 print '</td>';
1541}
1542if (!empty($arrayfields['s.siret']['checked'])) {
1543 // IdProf2
1544 print '<td class="liste_titre">';
1545 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_idprof2" value="'.dol_escape_htmltag($search_idprof2).'">';
1546 print '</td>';
1547}
1548if (!empty($arrayfields['s.ape']['checked'])) {
1549 // IdProf3
1550 print '<td class="liste_titre">';
1551 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_idprof3" value="'.dol_escape_htmltag($search_idprof3).'">';
1552 print '</td>';
1553}
1554if (!empty($arrayfields['s.idprof4']['checked'])) {
1555 // IdProf4
1556 print '<td class="liste_titre">';
1557 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_idprof4" value="'.dol_escape_htmltag($search_idprof4).'">';
1558 print '</td>';
1559}
1560if (!empty($arrayfields['s.idprof5']['checked'])) {
1561 // IdProf5
1562 print '<td class="liste_titre">';
1563 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_idprof5" value="'.dol_escape_htmltag($search_idprof5).'">';
1564 print '</td>';
1565}
1566if (!empty($arrayfields['s.idprof6']['checked'])) {
1567 // IdProf6
1568 print '<td class="liste_titre">';
1569 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_idprof6" value="'.dol_escape_htmltag($search_idprof6).'">';
1570 print '</td>';
1571}
1572if (!empty($arrayfields['s.tva_intra']['checked'])) {
1573 // Vat number
1574 print '<td class="liste_titre">';
1575 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_vat" value="'.dol_escape_htmltag($search_vat).'">';
1576 print '</td>';
1577}
1578
1579// Nature (customer/prospect/supplier)
1580if (!empty($arrayfields['customerorsupplier']['checked'])) {
1581 print '<td class="liste_titre maxwidthonsmartphone center">';
1582 if ($type != '') {
1583 print '<input type="hidden" name="type" value="'.$type.'">';
1584 }
1585 $reshook = $hookmanager->executeHooks('selectProspectCustomerType', array('client_type' => $search_type));
1586 if (empty($reshook)) {
1587 print $formcompany->selectProspectCustomerType($search_type, 'search_type', 'search_type', 'list');
1588 }
1589 print '</td>';
1590}
1591// Sales representatives
1592if (!empty($arrayfields['sales.representative']['checked'])) {
1593 print '<td class="liste_titre">';
1594 print '</td>';
1595}
1596// Prospect level
1597if (!empty($arrayfields['s.fk_prospectlevel']['checked'])) {
1598 print '<td class="liste_titre center">';
1599 print $form->multiselectarray('search_level', $tab_level, $search_level, 0, 0, 'width75', 0, 0, '', '', '', 2);
1600 print '</td>';
1601}
1602// Prospect status
1603if (!empty($arrayfields['s.fk_stcomm']['checked'])) {
1604 print '<td class="liste_titre maxwidthonsmartphone center">';
1605 $arraystcomm = array();
1606 foreach ($prospectstatic->cacheprospectstatus as $key => $val) {
1607 $arraystcomm[$val['id']] = ($langs->trans("StatusProspect".$val['id']) != "StatusProspect".$val['id'] ? $langs->trans("StatusProspect".$val['id']) : $val['label']);
1608 }
1609 //print $form->selectarray('search_stcomm', $arraystcomm, $search_stcomm, -2, 0, 0, '', 0, 0, 0, '', '', 1);
1610 print $form->multiselectarray('search_stcomm', $arraystcomm, $search_stcomm, 0, 0, 'width100', 0, 0, '', '', '', 2);
1611 print '</td>';
1612}
1613if (!empty($arrayfields['s2.nom']['checked'])) {
1614 print '<td class="liste_titre center">';
1615 print '<input class="flat searchstring maxwidth75imp" type="text" name="search_parent_name" value="'.dol_escape_htmltag($search_parent_name).'">';
1616 print '</td>';
1617}
1618// Extra fields
1619include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
1620
1621// Fields from hook
1622$parameters = array('arrayfields' => $arrayfields);
1623$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1624print $hookmanager->resPrint;
1625// IP address
1626if (!empty($arrayfields['s.ip']['checked'])) {
1627 print '<td class="liste_titre center nowraponall">';
1628 print '</td>';
1629}
1630// Creation date
1631if (!empty($arrayfields['s.datec']['checked'])) {
1632 print '<td class="liste_titre center nowraponall">';
1633 print '<div class="nowrapfordate">';
1634 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'));
1635 print '</div>';
1636 print '<div class="nowrapfordate">';
1637 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'));
1638 print '</div>';
1639 print '</td>';
1640}
1641// Modification date
1642if (!empty($arrayfields['s.tms']['checked'])) {
1643 print '<td class="liste_titre center nowraponall">';
1644 print '<div class="nowrapfordate">';
1645 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'));
1646 print '</div>';
1647 print '<div class="nowrapfordate">';
1648 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'));
1649 print '</div>';
1650 print '</td>';
1651}
1652// Note public
1653if (!empty($arrayfields['s.note_public']['checked'])) {
1654 print '<td class="liste_titre">';
1655 print '<input class="flat width75" type="text" name="search_note_public" value="'.dolPrintHTMLForAttribute($search_note_public).'">';
1656 print '</td>';
1657}
1658// Note private
1659if (!empty($arrayfields['s.note_private']['checked'])) {
1660 print '<td class="liste_titre">';
1661 print '<input class="flat width75" type="text" name="search_note_private" value="'.dolPrintHTMLForAttribute($search_note_private).'">';
1662 print '</td>';
1663}
1664// Status
1665if (!empty($arrayfields['s.status']['checked'])) {
1666 print '<td class="liste_titre center minwidth75imp parentonrightofpage">';
1667 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);
1668 print '</td>';
1669}
1670if (!empty($arrayfields['s.import_key']['checked'])) {
1671 print '<td class="liste_titre center">';
1672 print '<input class="flat searchstring maxwidth50" type="text" name="search_import_key" value="'.dol_escape_htmltag($search_import_key).'">';
1673 print '</td>';
1674}
1675// Action column
1676if (!$conf->main_checkbox_left_column) {
1677 print '<td class="liste_titre center maxwidthsearch actioncolumn">';
1678 $searchpicto = $form->showFilterButtons();
1679 print $searchpicto;
1680 print '</td>';
1681}
1682
1683print '</tr>'."\n";
1684
1685$totalarray = array();
1686$totalarray['nbfield'] = 0;
1687
1688// Fields title label
1689// --------------------------------------------------------------------
1690print '<tr class="liste_titre">';
1691// Action column
1692if ($conf->main_checkbox_left_column) {
1693 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
1694 $totalarray['nbfield']++;
1695}
1696if (!empty($arrayfields['s.rowid']['checked'])) {
1697 print_liste_field_titre($arrayfields['s.rowid']['label'], $_SERVER["PHP_SELF"], "s.rowid", "", $param, ' data-key="id"', $sortfield, $sortorder, '');
1698 $totalarray['nbfield']++;
1699}
1700if (!empty($arrayfields['s.nom']['checked'])) {
1701 print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, ' data-key="ref"', $sortfield, $sortorder, ' ');
1702 $totalarray['nbfield']++;
1703}
1704if (!empty($arrayfields['s.name_alias']['checked'])) {
1705 // @phan-suppress-next-line PhanTypeInvalidDimOffset
1706 print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"], "s.name_alias", "", $param, "", $sortfield, $sortorder);
1707 $totalarray['nbfield']++;
1708}
1709if (!empty($arrayfields['s.ref_ext']['checked'])) {
1710 // @phan-suppress-next-line PhanTypeInvalidDimOffset
1711 print_liste_field_titre($arrayfields['s.ref_ext']['label'], $_SERVER["PHP_SELF"], "s.ref_ext", "", $param, "", $sortfield, $sortorder);
1712 $totalarray['nbfield']++;
1713}
1714if (!empty($arrayfields['s.barcode']['checked'])) {
1715 print_liste_field_titre($arrayfields['s.barcode']['label'], $_SERVER["PHP_SELF"], "s.barcode", '', $param, '', $sortfield, $sortorder);
1716 $totalarray['nbfield']++;
1717}
1718if (!empty($arrayfields['s.code_client']['checked'])) {
1719 print_liste_field_titre($arrayfields['s.code_client']['label'], $_SERVER["PHP_SELF"], "s.code_client", "", $param, '', $sortfield, $sortorder);
1720 $totalarray['nbfield']++;
1721}
1722if (!empty($arrayfields['s.code_fournisseur']['checked'])) {
1723 print_liste_field_titre($arrayfields['s.code_fournisseur']['label'], $_SERVER["PHP_SELF"], "s.code_fournisseur", "", $param, '', $sortfield, $sortorder);
1724 $totalarray['nbfield']++;
1725}
1726if (!empty($arrayfields['s.code_compta']['checked'])) {
1727 print_liste_field_titre($arrayfields['s.code_compta']['label'], $_SERVER["PHP_SELF"], "s.code_compta", "", $param, '', $sortfield, $sortorder);
1728 $totalarray['nbfield']++;
1729}
1730if (!empty($arrayfields['s.code_compta_fournisseur']['checked'])) {
1731 print_liste_field_titre($arrayfields['s.code_compta_fournisseur']['label'], $_SERVER["PHP_SELF"], "s.code_compta_fournisseur", "", $param, '', $sortfield, $sortorder);
1732 $totalarray['nbfield']++;
1733}
1734if (!empty($arrayfields['s.address']['checked'])) {
1735 print_liste_field_titre($arrayfields['s.address']['label'], $_SERVER['PHP_SELF'], 's.address', '', $param, '', $sortfield, $sortorder);
1736 $totalarray['nbfield']++;
1737}
1738if (!empty($arrayfields['s.zip']['checked'])) {
1739 print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], "s.zip", "", $param, '', $sortfield, $sortorder);
1740 $totalarray['nbfield']++;
1741}
1742if (!empty($arrayfields['s.town']['checked'])) {
1743 print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], "s.town", "", $param, '', $sortfield, $sortorder);
1744 $totalarray['nbfield']++;
1745}
1746if (!empty($arrayfields['state.nom']['checked'])) {
1747 print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder);
1748 $totalarray['nbfield']++;
1749}
1750if (!empty($arrayfields['region.nom']['checked'])) {
1751 print_liste_field_titre($arrayfields['region.nom']['label'], $_SERVER["PHP_SELF"], "region.nom", "", $param, '', $sortfield, $sortorder);
1752 $totalarray['nbfield']++;
1753}
1754if (!empty($arrayfields['country.code_iso']['checked'])) {
1755 print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center ');
1756 $totalarray['nbfield']++;
1757}
1758if (!empty($arrayfields['typent.code']['checked'])) {
1759 print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, "", $sortfield, $sortorder, 'center ');
1760 $totalarray['nbfield']++;
1761}
1762if (!empty($arrayfields['staff.code']['checked'])) {
1763 print_liste_field_titre($arrayfields['staff.code']['label'], $_SERVER["PHP_SELF"], "staff.code", "", $param, '', $sortfield, $sortorder, 'center ');
1764 $totalarray['nbfield']++;
1765}
1766if (!empty($arrayfields['legalform.code']['checked'])) {
1767 // s.fk_forme_juridique as legalform_code
1768 print_liste_field_titre($arrayfields['legalform.code']['label'], $_SERVER["PHP_SELF"], "legalform_code", "", $param, '', $sortfield, $sortorder);
1769 $totalarray['nbfield']++;
1770}
1771if (!empty($arrayfields['s.price_level']['checked'])) {
1772 print_liste_field_titre($arrayfields['s.price_level']['label'], $_SERVER["PHP_SELF"], "s.price_level", "", $param, '', $sortfield, $sortorder);
1773 $totalarray['nbfield']++;
1774}
1775if (!empty($arrayfields['s.email']['checked'])) {
1776 print_liste_field_titre($arrayfields['s.email']['label'], $_SERVER["PHP_SELF"], "s.email", "", $param, '', $sortfield, $sortorder);
1777 $totalarray['nbfield']++;
1778}
1779if (!empty($arrayfields['su.noemail']['checked'])) {
1780 print_liste_field_titre($arrayfields['su.noemail']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'center ');
1781 $totalarray['nbfield']++;
1782}
1783if (!empty($arrayfields['s.phone']['checked'])) {
1784 print_liste_field_titre($arrayfields['s.phone']['label'], $_SERVER["PHP_SELF"], "s.phone", "", $param, '', $sortfield, $sortorder);
1785 $totalarray['nbfield']++;
1786}
1787if (!empty($arrayfields['s.phone_mobile']['checked'])) {
1788 print_liste_field_titre($arrayfields['s.phone_mobile']['label'], $_SERVER["PHP_SELF"], "s.phone_mobile", "", $param, '', $sortfield, $sortorder);
1789 $totalarray['nbfield']++;
1790}
1791if (!empty($arrayfields['s.fax']['checked'])) {
1792 print_liste_field_titre($arrayfields['s.fax']['label'], $_SERVER["PHP_SELF"], "s.fax", "", $param, '', $sortfield, $sortorder);
1793 $totalarray['nbfield']++;
1794}
1795if (!empty($arrayfields['s.url']['checked'])) {
1796 print_liste_field_titre($arrayfields['s.url']['label'], $_SERVER["PHP_SELF"], "s.url", "", $param, '', $sortfield, $sortorder);
1797 $totalarray['nbfield']++;
1798}
1799if (!empty($arrayfields['s.siren']['checked'])) {
1800 print_liste_field_titre($form->textwithpicto($langs->trans("ProfId1Short"), $textprofid[1], 1, 'info'), $_SERVER["PHP_SELF"], "s.siren", "", $param, '', $sortfield, $sortorder, 'nowrap ');
1801 $totalarray['nbfield']++;
1802}
1803if (!empty($arrayfields['s.siret']['checked'])) {
1804 print_liste_field_titre($form->textwithpicto($langs->trans("ProfId2Short"), $textprofid[2], 1, 'info'), $_SERVER["PHP_SELF"], "s.siret", "", $param, '', $sortfield, $sortorder, 'nowrap ');
1805 $totalarray['nbfield']++;
1806}
1807if (!empty($arrayfields['s.ape']['checked'])) {
1808 print_liste_field_titre($form->textwithpicto($langs->trans("ProfId3Short"), $textprofid[3], 1, 'info'), $_SERVER["PHP_SELF"], "s.ape", "", $param, '', $sortfield, $sortorder, 'nowrap ');
1809 $totalarray['nbfield']++;
1810}
1811if (!empty($arrayfields['s.idprof4']['checked'])) {
1812 print_liste_field_titre($form->textwithpicto($langs->trans("ProfId4Short"), $textprofid[4], 1, 'info'), $_SERVER["PHP_SELF"], "s.idprof4", "", $param, '', $sortfield, $sortorder, 'nowrap ');
1813 $totalarray['nbfield']++;
1814}
1815if (!empty($arrayfields['s.idprof5']['checked'])) {
1816 print_liste_field_titre($form->textwithpicto($langs->trans("ProfId5Short"), $textprofid[5], 1, 'info'), $_SERVER["PHP_SELF"], "s.idprof5", "", $param, '', $sortfield, $sortorder, 'nowrap ');
1817 $totalarray['nbfield']++;
1818}
1819if (!empty($arrayfields['s.idprof6']['checked'])) {
1820 print_liste_field_titre($form->textwithpicto($langs->trans("ProfId6Short"), $textprofid[6], 1, 'info'), $_SERVER["PHP_SELF"], "s.idprof6", "", $param, '', $sortfield, $sortorder, 'nowrap ');
1821 $totalarray['nbfield']++;
1822}
1823if (!empty($arrayfields['s.tva_intra']['checked'])) {
1824 print_liste_field_titre($arrayfields['s.tva_intra']['label'], $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder, 'nowrap ');
1825 $totalarray['nbfield']++;
1826}
1827if (!empty($arrayfields['customerorsupplier']['checked'])) {
1828 print_liste_field_titre($arrayfields['customerorsupplier']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'center '); // type of customer
1829 $totalarray['nbfield']++;
1830}
1831if (!empty($arrayfields['sales.representative']['checked'])) {
1832 print_liste_field_titre($arrayfields['sales.representative']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder);
1833 $totalarray['nbfield']++;
1834}
1835if (!empty($arrayfields['s.fk_prospectlevel']['checked'])) {
1836 print_liste_field_titre($arrayfields['s.fk_prospectlevel']['label'], $_SERVER["PHP_SELF"], "s.fk_prospectlevel", "", $param, '', $sortfield, $sortorder, 'center ');
1837 $totalarray['nbfield']++;
1838}
1839if (!empty($arrayfields['s.fk_stcomm']['checked'])) {
1840 print_liste_field_titre($arrayfields['s.fk_stcomm']['label'], $_SERVER["PHP_SELF"], "s.fk_stcomm", "", $param, '', $sortfield, $sortorder, 'center ');
1841 $totalarray['nbfield']++;
1842}
1843if (!empty($arrayfields['s2.nom']['checked'])) {
1844 print_liste_field_titre($arrayfields['s2.nom']['label'], $_SERVER["PHP_SELF"], "s2.nom", "", $param, '', $sortfield, $sortorder, 'center ');
1845 $totalarray['nbfield']++;
1846}
1847// Extra fields
1848include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
1849// Hook fields
1850$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder);
1851$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1852print $hookmanager->resPrint;
1853// IP Address
1854if (!empty($arrayfields['s.ip']['checked'])) {
1855 print_liste_field_titre($arrayfields['s.ip']['label'], $_SERVER["PHP_SELF"], "s.ip", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1856 $totalarray['nbfield']++; // For the column action
1857}
1858// Date creation
1859if (!empty($arrayfields['s.datec']['checked'])) {
1860 print_liste_field_titre($arrayfields['s.datec']['label'], $_SERVER["PHP_SELF"], "s.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1861 $totalarray['nbfield']++; // For the column action
1862}
1863if (!empty($arrayfields['s.tms']['checked'])) {
1864 print_liste_field_titre($arrayfields['s.tms']['label'], $_SERVER["PHP_SELF"], "s.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1865 $totalarray['nbfield']++; // For the column action
1866}
1867if (!empty($arrayfields['s.note_public']['checked'])) {
1868 print_liste_field_titre($arrayfields['s.note_public']['label'], $_SERVER["PHP_SELF"], "s.note_public", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1869 $totalarray['nbfield']++;
1870}
1871if (!empty($arrayfields['s.note_private']['checked'])) {
1872 print_liste_field_titre($arrayfields['s.note_private']['label'], $_SERVER["PHP_SELF"], "s.note_private", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1873 $totalarray['nbfield']++;
1874}
1875if (!empty($arrayfields['s.status']['checked'])) {
1876 print_liste_field_titre($arrayfields['s.status']['label'], $_SERVER["PHP_SELF"], "s.status", "", $param, '', $sortfield, $sortorder, 'center ');
1877 $totalarray['nbfield']++; // For the column action
1878}
1879if (!empty($arrayfields['s.import_key']['checked'])) {
1880 print_liste_field_titre($arrayfields['s.import_key']['label'], $_SERVER["PHP_SELF"], "s.import_key", "", $param, '', $sortfield, $sortorder, 'center ');
1881 $totalarray['nbfield']++; // For the column action
1882}
1883// Action column
1884if (!$conf->main_checkbox_left_column) {
1885 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
1886 $totalarray['nbfield']++;
1887}
1888print '</tr>'."\n";
1889
1890
1891// Loop on record
1892// --------------------------------------------------------------------
1893$i = 0;
1894$savnbfield = $totalarray['nbfield'];
1895$totalarray = array();
1896$totalarray['nbfield'] = 0;
1897$imaxinloop = ($limit ? min($num, $limit) : $num);
1898while ($i < $imaxinloop) {
1899 $obj = $db->fetch_object($resql);
1900 if (empty($obj)) {
1901 break; // Should not happen
1902 }
1903
1904 $parameters = array('staticdata' => $obj);
1905 // Note that $action and $object may have been modified by hook
1906 // do companystatic fetch in hook if wanted or anything else
1907 $reshook = $hookmanager->executeHooks('loadStaticObject', $parameters, $companystatic, $action);
1908 if (empty($reshook)) {
1909 $companystatic->id = $obj->rowid;
1910 $companystatic->name = $obj->name;
1911 $companystatic->name_alias = $obj->name_alias;
1912 $companystatic->ref_ext = $obj->ref_ext;
1913 $companystatic->logo = $obj->logo;
1914 $companystatic->barcode = $obj->barcode;
1915 $companystatic->canvas = $obj->canvas;
1916 $companystatic->client = $obj->client;
1917 $companystatic->status = $obj->status;
1918 $companystatic->email = $obj->email;
1919 $companystatic->phone = $obj->phone;
1920 $companystatic->phone_mobile = $obj->phone_mobile;
1921 $companystatic->fax = $obj->fax;
1922 $companystatic->address = $obj->address;
1923 $companystatic->zip = $obj->zip;
1924 $companystatic->town = $obj->town;
1925 $companystatic->fournisseur = $obj->fournisseur;
1926 $companystatic->code_client = $obj->code_client;
1927 $companystatic->code_fournisseur = $obj->code_fournisseur;
1928 $companystatic->tva_intra = $obj->tva_intra;
1929 $companystatic->country_code = $obj->country_code;
1930
1931 $companystatic->ip = $obj->ip;
1932
1933 $companystatic->code_compta_client = $obj->code_compta;
1934 $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
1935 $companystatic->note_public = $obj->note_public;
1936 $companystatic->note_private = $obj->note_private;
1937 $companystatic->fk_prospectlevel = $obj->fk_prospectlevel;
1938 $companystatic->parent = $obj->fk_parent;
1939 $companystatic->entity = $obj->entity;
1940
1941 $object = $companystatic;
1942 }
1943
1944 if ($mode == 'kanban') {
1945 if ($i == 0) {
1946 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
1947 print '<div class="box-flex-container kanban">';
1948 }
1949 // Output Kanban
1950 print $companystatic->getKanbanView('', array('selected' => in_array($obj->rowid, $arrayofselected)));
1951 if ($i == ($imaxinloop - 1)) {
1952 print '</div>';
1953 print '</td></tr>';
1954 }
1955 } else {
1956 // Show line of result
1957 $j = 0;
1958 print '<tr data-rowid="'.$companystatic->id.'" class="oddeven row-with-select"';
1959 if ($contextpage == 'poslist') {
1960 print ' onclick="location.href=\'list.php?action=change&token='.newToken().'&contextpage=poslist&idcustomer='.$obj->rowid.'&place='.urlencode($place).'\'"';
1961 }
1962 print '>';
1963
1964 // Action column (Show the massaction button only when this page is not opened from the Extended POS)
1965 if ($conf->main_checkbox_left_column) {
1966 print '<td class="nowrap center actioncolumn">';
1967 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
1968 $selected = 0;
1969 if (in_array($obj->rowid, $arrayofselected)) {
1970 $selected = 1;
1971 }
1972 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
1973 }
1974 print '</td>';
1975 if (!$i) {
1976 $totalarray['nbfield']++;
1977 }
1978 }
1979 if (!empty($arrayfields['s.rowid']['checked'])) {
1980 print '<td class="tdoverflowmax50" data-key="id">';
1981 print dol_escape_htmltag($obj->rowid);
1982 print "</td>\n";
1983 if (!$i) {
1984 $totalarray['nbfield']++;
1985 }
1986 }
1987 if (!empty($arrayfields['s.nom']['checked'])) {
1988 print '<td class="tdoverflowmax200 tdlineheightsmall" data-key="ref">';
1989 print '<div class="inline-block lineheightsmall">';
1990 if ($contextpage == 'poslist') {
1991 print dolPrintHTML($companystatic->name);
1992 } else {
1993 print $companystatic->getNomUrl(1, '', 100, 0, 1, 1);
1994 if (empty($arrayfields['s.name_alias']['checked'])) {
1995 print '<br><span class="spantitle">'.dolPrintHTML($companystatic->name_alias).'</span>';
1996 }
1997 }
1998 print '</div>';
1999 print "</td>\n";
2000 if (!$i) {
2001 $totalarray['nbfield']++;
2002 }
2003 }
2004 if (!empty($arrayfields['s.name_alias']['checked'])) {
2005 print '<td class="tdoverflowmax150" title="'.dolPrintHTMLForAttribute($companystatic->name_alias).'">';
2006 print '<span class="spantitle">';
2007 print dolPrintHTML($companystatic->name_alias);
2008 print '</span>';
2009 print "</td>\n";
2010 if (!$i) {
2011 $totalarray['nbfield']++;
2012 }
2013 }
2014 // Ref ext
2015 if (!empty($arrayfields['s.ref_ext']['checked'])) {
2016 print '<td class="tdoverflowmax150" title="'.dolPrintHTMLForAttribute($companystatic->ref_ext).'">';
2017 print dolPrintHTML($companystatic->ref_ext);
2018 print "</td>\n";
2019 if (!$i) {
2020 $totalarray['nbfield']++;
2021 }
2022 }
2023 // Barcode
2024 if (!empty($arrayfields['s.barcode']['checked'])) {
2025 print '<td class="tdoverflowmax150" title="'.dolPrintHTMLForAttribute($companystatic->barcode).'">'.dolPrintHTML($companystatic->barcode).'</td>';
2026 if (!$i) {
2027 $totalarray['nbfield']++;
2028 }
2029 }
2030 // Customer code
2031 if (!empty($arrayfields['s.code_client']['checked'])) {
2032 print '<td class="nowraponall">'.dolPrintHTML($companystatic->code_client).'</td>';
2033 if (!$i) {
2034 $totalarray['nbfield']++;
2035 }
2036 }
2037 // Supplier code
2038 if (!empty($arrayfields['s.code_fournisseur']['checked'])) {
2039 print '<td class="nowraponall">'.dol_escape_htmltag($companystatic->code_fournisseur).'</td>';
2040 if (!$i) {
2041 $totalarray['nbfield']++;
2042 }
2043 }
2044 // Account customer code
2045 if (!empty($arrayfields['s.code_compta']['checked'])) {
2046 print '<td>'.dolPrintHTML($companystatic->code_compta_client).'</td>';
2047 if (!$i) {
2048 $totalarray['nbfield']++;
2049 }
2050 }
2051 // Account supplier code
2052 if (!empty($arrayfields['s.code_compta_fournisseur']['checked'])) {
2053 print '<td>'.dolPrintHTML($companystatic->code_compta_fournisseur).'</td>';
2054 if (!$i) {
2055 $totalarray['nbfield']++;
2056 }
2057 }
2058 // Address
2059 if (!empty($arrayfields['s.address']['checked'])) {
2060 print '<td class="tdoverflowmax250" title="'.dolPrintHTMLForAttribute($companystatic->address).'">'.dolPrintHTML($companystatic->address).'</td>';
2061 if (!$i) {
2062 $totalarray['nbfield']++;
2063 }
2064 }
2065 // Zip
2066 if (!empty($arrayfields['s.zip']['checked'])) {
2067 print "<td>".dolPrintHTML($companystatic->zip)."</td>\n";
2068 if (!$i) {
2069 $totalarray['nbfield']++;
2070 }
2071 }
2072 // Town
2073 if (!empty($arrayfields['s.town']['checked'])) {
2074 print '<td class="tdoverflowmax150" title="'.dolPrintHTMLForAttribute($companystatic->town).'">'.dolPrintHTML($companystatic->town)."</td>\n";
2075 if (!$i) {
2076 $totalarray['nbfield']++;
2077 }
2078 }
2079 // State
2080 if (!empty($arrayfields['state.nom']['checked'])) {
2081 print "<td>".dolPrintHTML($obj->state_name)."</td>\n";
2082 if (!$i) {
2083 $totalarray['nbfield']++;
2084 }
2085 }
2086 // Region
2087 if (!empty($arrayfields['region.nom']['checked'])) {
2088 print "<td>".dolPrintHTML($obj->region_name)."</td>\n";
2089 if (!$i) {
2090 $totalarray['nbfield']++;
2091 }
2092 }
2093 // Country
2094 if (!empty($arrayfields['country.code_iso']['checked'])) {
2095 print '<td class="center tdoverflowmax100">';
2096 $labelcountry = ($companystatic->country_code && ($langs->trans("Country".$companystatic->country_code) != "Country".$companystatic->country_code)) ? $langs->trans("Country".$companystatic->country_code) : $obj->country_label;
2097 print $labelcountry;
2098 print '</td>';
2099 if (!$i) {
2100 $totalarray['nbfield']++;
2101 }
2102 }
2103 // Type ent
2104 if (!empty($arrayfields['typent.code']['checked'])) {
2105 $typenArray = $formcompany->typent_array(1);
2106 $labeltypeofcompany = empty($typenArray[$obj->typent_code]) ? '' : $typenArray[$obj->typent_code];
2107
2108 print '<td class="center tdoverflowmax125" title="'.dolPrintHTMLForAttribute($labeltypeofcompany).'">';
2109 print dolPrintHTML($labeltypeofcompany);
2110 print '</td>';
2111 if (!$i) {
2112 $totalarray['nbfield']++;
2113 }
2114 }
2115 // Multiprice level
2116 if (!empty($arrayfields['s.price_level']['checked'])) {
2117 print '<td class="center">'.$obj->price_level."</td>\n";
2118 if (!$i) {
2119 $totalarray['nbfield']++;
2120 }
2121 }
2122 // Staff
2123 if (!empty($arrayfields['staff.code']['checked'])) {
2124 print '<td class="center">';
2125 if (!empty($obj->staff_code)) {
2126 if (empty($conf->cache['staffArray'])) {
2127 $conf->cache['staffArray'] = $formcompany->effectif_array(1);
2128 }
2129 print $conf->cache['staffArray'][$obj->staff_code];
2130 }
2131 print '</td>';
2132 if (!$i) {
2133 $totalarray['nbfield']++;
2134 }
2135 }
2136 // Legal form
2137 if (!empty($arrayfields['legalform.code']['checked'])) {
2138 $labeltoshow = '';
2139 if (!empty($obj->legalform_code)) {
2140 if (empty($conf->cache['legalformArray'][$obj->legalform_code])) {
2141 $conf->cache['legalformArray'][$obj->legalform_code] = getFormeJuridiqueLabel($obj->legalform_code);
2142 }
2143 $labeltoshow = $conf->cache['legalformArray'][$obj->legalform_code];
2144 }
2145 print '<td class="center tdoverflowmax100" title="'.dol_escape_htmltag($labeltoshow).'">';
2146 print dol_escape_htmltag($labeltoshow);
2147 print '</td>';
2148 if (!$i) {
2149 $totalarray['nbfield']++;
2150 }
2151 }
2152 // Email
2153 if (!empty($arrayfields['s.email']['checked'])) {
2154 $showinvalidemail = (int) !getDolGlobalInt('MAIN_SHOW_INVALID_EMAIL_IN_LIST'); // to avoid slow display
2155 print '<td class="tdoverflowmax150" title="'.dolPrintHTMLForAttribute($obj->email).'">'.dol_print_email($obj->email, $obj->rowid, $obj->rowid, 1, 0, $showinvalidemail, 1)."</td>\n";
2156 if (!$i) {
2157 $totalarray['nbfield']++;
2158 }
2159 }
2160 // Unsubscribe to ML list
2161 if (!empty($arrayfields['su.noemail']['checked'])) {
2162 print '<td class="center">'.yn($obj->noemail)."</td>\n";
2163 if (!$i) {
2164 $totalarray['nbfield']++;
2165 }
2166 }
2167 if (!empty($arrayfields['s.phone']['checked'])) {
2168 print '<td class="nowraponall">'.dol_print_phone($obj->phone, $companystatic->country_code, 0, $obj->rowid, 'AC_TEL', ' ', 'phone')."</td>\n";
2169 if (!$i) {
2170 $totalarray['nbfield']++;
2171 }
2172 }
2173 if (!empty($arrayfields['s.phone_mobile']['checked'])) {
2174 print '<td class="nowraponall">'.dol_print_phone($obj->phone_mobile, $companystatic->country_code, 0, $obj->rowid, 'AC_TEL', ' ', 'mobile')."</td>\n";
2175 if (!$i) {
2176 $totalarray['nbfield']++;
2177 }
2178 }
2179 if (!empty($arrayfields['s.fax']['checked'])) {
2180 print '<td class="nowraponall">'.dol_print_phone($obj->fax, $companystatic->country_code, 0, $obj->rowid, 'AC_TEL', ' ', 'fax')."</td>\n";
2181 if (!$i) {
2182 $totalarray['nbfield']++;
2183 }
2184 }
2185 if (!empty($arrayfields['s.url']['checked'])) {
2186 print "<td>".dol_print_url($obj->url, '', 0, 1)."</td>\n";
2187 if (!$i) {
2188 $totalarray['nbfield']++;
2189 }
2190 }
2191 if (!empty($arrayfields['s.siren']['checked'])) {
2192 print "<td>".$obj->idprof1."</td>\n";
2193 if (!$i) {
2194 $totalarray['nbfield']++;
2195 }
2196 }
2197 if (!empty($arrayfields['s.siret']['checked'])) {
2198 print "<td>".$obj->idprof2."</td>\n";
2199 if (!$i) {
2200 $totalarray['nbfield']++;
2201 }
2202 }
2203 if (!empty($arrayfields['s.ape']['checked'])) {
2204 print "<td>".$obj->idprof3."</td>\n";
2205 if (!$i) {
2206 $totalarray['nbfield']++;
2207 }
2208 }
2209 if (!empty($arrayfields['s.idprof4']['checked'])) {
2210 print "<td>".$obj->idprof4."</td>\n";
2211 if (!$i) {
2212 $totalarray['nbfield']++;
2213 }
2214 }
2215 if (!empty($arrayfields['s.idprof5']['checked'])) {
2216 print "<td>".$obj->idprof5."</td>\n";
2217 if (!$i) {
2218 $totalarray['nbfield']++;
2219 }
2220 }
2221 if (!empty($arrayfields['s.idprof6']['checked'])) {
2222 print "<td>".$obj->idprof6."</td>\n";
2223 if (!$i) {
2224 $totalarray['nbfield']++;
2225 }
2226 }
2227 // VAT
2228 if (!empty($arrayfields['s.tva_intra']['checked'])) {
2229 print '<td class="tdoverflowmax125" title="'.dol_escape_htmltag($companystatic->tva_intra).'">';
2230 if ($companystatic->tva_intra && !isValidVATID($companystatic)) {
2231 print img_warning("BadVATNumber", '', 'pictofixedwidth');
2232 }
2233 print $companystatic->tva_intra;
2234 print "</td>\n";
2235 if (!$i) {
2236 $totalarray['nbfield']++;
2237 }
2238 }
2239 // Nature
2240 if (!empty($arrayfields['customerorsupplier']['checked'])) {
2241 print '<td class="center">';
2242 $reshook = $hookmanager->executeHooks('getTypeUrl', array('client_type' => $obj->client));
2243 if (empty($reshook)) {
2244 print $companystatic->getTypeUrl(1);
2245 }
2246 print '</td>';
2247 if (!$i) {
2248 $totalarray['nbfield']++;
2249 }
2250 }
2251 // Sales Representative
2252 if (!empty($arrayfields['sales.representative']['checked'])) {
2253 print '<td class="nowraponall tdoverflowmax150">';
2254 $listsalesrepresentatives = $companystatic->getSalesRepresentatives($user);
2255 $nbofsalesrepresentative = count($listsalesrepresentatives);
2256 if ($nbofsalesrepresentative > 6) {
2257 // We print only number
2258 print $nbofsalesrepresentative;
2259 } elseif ($nbofsalesrepresentative > 0) {
2260 $userstatic = new User($db);
2261 $j = 0;
2262 foreach ($listsalesrepresentatives as $val) {
2263 $userstatic->id = $val['id'];
2264 $userstatic->lastname = $val['lastname'];
2265 $userstatic->firstname = $val['firstname'];
2266 $userstatic->email = $val['email'];
2267 $userstatic->entity = $val['entity'];
2268 $userstatic->photo = $val['photo'];
2269 $userstatic->login = $val['login'];
2270 $userstatic->office_phone = $val['office_phone'];
2271 $userstatic->office_fax = $val['office_fax'];
2272 $userstatic->user_mobile = $val['user_mobile'];
2273 $userstatic->job = $val['job'];
2274 $userstatic->gender = $val['gender'];
2275 $userstatic->statut = $val['statut'];
2276 $userstatic->status = $val['statut'];
2277 print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1, '', 0, 0, 12) : $userstatic->getNomUrl(-2);
2278 $j++;
2279 if ($j < $nbofsalesrepresentative) {
2280 print ' ';
2281 }
2282 }
2283 } else {
2284 print '&nbsp;';
2285 }
2286 print '</td>';
2287 if (!$i) {
2288 $totalarray['nbfield']++;
2289 }
2290 }
2291 // Prospect level
2292 if (!empty($arrayfields['s.fk_prospectlevel']['checked'])) {
2293 print '<td class="center nowraponall">';
2294 print $companystatic->getLibProspLevel();
2295 print "</td>";
2296 if (!$i) {
2297 $totalarray['nbfield']++;
2298 }
2299 }
2300 // Prospect status
2301 if (!empty($arrayfields['s.fk_stcomm']['checked'])) {
2302 print '<td class="center nowraponall">';
2303
2304 $prospectid = $obj->rowid;
2305 $statusprospect = $obj->stcomm_id;
2306
2307 $formcompany->selectProspectStatus('status_prospect', $prospectstatic, $statusprospect, $prospectid);
2308
2309 print '</td>';
2310 if (!$i) {
2311 $totalarray['nbfield']++;
2312 }
2313 }
2314 // Parent company
2315 if (!empty($arrayfields['s2.nom']['checked'])) {
2316 print '<td class="center tdoverflowmax100">';
2317 if ($companystatic->parent > 0) {
2318 $companyparent->fetch($companystatic->parent);
2319 print $companyparent->getNomUrl(1);
2320 }
2321 print "</td>";
2322 if (!$i) {
2323 $totalarray['nbfield']++;
2324 }
2325 }
2326 // Extra fields
2327 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
2328 // Fields from hook
2329 $parameters = array('arrayfields' => $arrayfields, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray);
2330 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
2331 print $hookmanager->resPrint;
2332 // IP
2333 if (!empty($arrayfields['s.ip']['checked'])) {
2334 print '<td class="center nowraponall">';
2335 print dol_print_ip($obj->ip);
2336 print '</td>';
2337 if (!$i) {
2338 $totalarray['nbfield']++;
2339 }
2340 }
2341 // Date creation
2342 if (!empty($arrayfields['s.datec']['checked'])) {
2343 print '<td class="center nowraponall">';
2344 print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
2345 print '</td>';
2346 if (!$i) {
2347 $totalarray['nbfield']++;
2348 }
2349 }
2350 // Date modification
2351 if (!empty($arrayfields['s.tms']['checked'])) {
2352 print '<td class="center nowraponall">';
2353 print dol_print_date($db->jdate($obj->date_modification), 'dayhour', 'tzuser');
2354 print '</td>';
2355 if (!$i) {
2356 $totalarray['nbfield']++;
2357 }
2358 }
2359 // Note public
2360 if (!empty($arrayfields['s.note_public']['checked'])) {
2361 print '<td class="flat maxwidth250imp">';
2362 print '<div class="small lineheightsmall twolinesmax-normallineheight">'.dolPrintHTML(dolGetFirstLineOfText($obj->note_public, 5)).'</div>';
2363 print '</td>';
2364 if (!$i) {
2365 $totalarray['nbfield']++;
2366 }
2367 }
2368 // Note private
2369 if (!empty($arrayfields['s.note_private']['checked'])) {
2370 print '<td class="flat maxwidth250imp">';
2371 print '<div class="small lineheightsmall twolinesmax-normallineheight">'.dolPrintHTML(dolGetFirstLineOfText($obj->note_private, 5)).'</div>';
2372 print '</td>';
2373 if (!$i) {
2374 $totalarray['nbfield']++;
2375 }
2376 }
2377 // Status
2378 if (!empty($arrayfields['s.status']['checked'])) {
2379 print '<td class="center nowraponall">'.$companystatic->getLibStatut(5).'</td>';
2380 if (!$i) {
2381 $totalarray['nbfield']++;
2382 }
2383 }
2384 // Import key
2385 if (!empty($arrayfields['s.import_key']['checked'])) {
2386 print '<td class="tdoverflowmax125" title="'.dol_escape_htmltag($obj->import_key).'">';
2387 print dol_escape_htmltag($obj->import_key);
2388 print "</td>\n";
2389 if (!$i) {
2390 $totalarray['nbfield']++;
2391 }
2392 }
2393 // Action column (Show the massaction button only when this page is not opened from the Extended POS)
2394 if (!$conf->main_checkbox_left_column) {
2395 print '<td class="nowrap center actioncolumn">';
2396 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
2397 $selected = 0;
2398 if (in_array($obj->rowid, $arrayofselected)) {
2399 $selected = 1;
2400 }
2401 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
2402 }
2403 print '</td>';
2404 if (!$i) {
2405 $totalarray['nbfield']++;
2406 }
2407 }
2408
2409 print '</tr>'."\n";
2410 }
2411 $i++;
2412}
2413
2414// Show total line
2415include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
2416
2417// If no record found
2418if ($num == 0) {
2419 $colspan = 1;
2420 foreach ($arrayfields as $key => $val) {
2421 if (!empty($val['checked'])) {
2422 $colspan++;
2423 }
2424 }
2425 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
2426}
2427
2428$db->free($resql);
2429
2430$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
2431$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
2432print $hookmanager->resPrint;
2433
2434print '</table>'."\n";
2435print '</div>'."\n";
2436
2437// Line that calls the select_status function by passing it js as the 5th parameter in order to activate the js script
2438$formcompany->selectProspectStatus('status_prospect', $prospectstatic, 0, 0, "js");
2439
2440print '</form>'."\n";
2441
2442// End of page
2443llxFooter();
2444$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:501
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.
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...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
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.