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