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