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