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