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