dolibarr 19.0.3
list.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2019 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005-2019 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2012 Marcos García <marcosgdf@gmail.com>
6 * Copyright (C) 2013-2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
7 * Copyright (C) 2015 Florian Henry <florian.henry@open-concept.pro>
8 * Copyright (C) 2016-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 .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
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 ($search_sale && $search_sale != '-1' && $search_sale != '-2') {
572 $sql .= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
573}
574if (!$user->hasRight('fournisseur', 'lire')) {
575 $sql .= " AND (s.fournisseur <> 1 OR s.client <> 0)"; // client=0, fournisseur=0 must be visible
576}
577if ($search_sale == -2) {
578 $sql .= " AND sc.fk_user IS NULL";
579} elseif ($search_sale > 0) {
580 $sql .= " AND sc.fk_user = ".((int) $search_sale);
581}
582$searchCategoryCustomerList = $search_categ_cus ? array($search_categ_cus) : array();
583$searchCategoryCustomerOperator = 0;
584// Search for tag/category ($searchCategoryCustomerList is an array of ID)
585if (!empty($searchCategoryCustomerList)) {
586 $searchCategoryCustomerSqlList = array();
587 $listofcategoryid = '';
588 foreach ($searchCategoryCustomerList as $searchCategoryCustomer) {
589 if (intval($searchCategoryCustomer) == -2) {
590 $searchCategoryCustomerSqlList[] = "NOT EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe as ck WHERE s.rowid = ck.fk_soc)";
591 } elseif (intval($searchCategoryCustomer) > 0) {
592 if ($searchCategoryCustomerOperator == 0) {
593 $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).")";
594 } else {
595 $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryCustomer);
596 }
597 }
598 }
599 if ($listofcategoryid) {
600 $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)."))";
601 }
602 if ($searchCategoryCustomerOperator == 1) {
603 if (!empty($searchCategoryCustomerSqlList)) {
604 $sql .= " AND (".implode(' OR ', $searchCategoryCustomerSqlList).")";
605 }
606 } else {
607 if (!empty($searchCategoryCustomerSqlList)) {
608 $sql .= " AND (".implode(' AND ', $searchCategoryCustomerSqlList).")";
609 }
610 }
611}
612// Search Supplier Categories
613$searchCategorySupplierList = $search_categ_sup ? array($search_categ_sup) : array();
614$searchCategorySupplierOperator = 0;
615// Search for tag/category ($searchCategorySupplierList is an array of ID)
616if (!empty($searchCategorySupplierList)) {
617 $searchCategorySupplierSqlList = array();
618 $listofcategoryid = '';
619 foreach ($searchCategorySupplierList as $searchCategorySupplier) {
620 if (intval($searchCategorySupplier) == -2) {
621 $searchCategorySupplierSqlList[] = "NOT EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_fournisseur as ck WHERE s.rowid = ck.fk_soc)";
622 } elseif (intval($searchCategorySupplier) > 0) {
623 if ($searchCategorySupplierOperator == 0) {
624 $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).")";
625 } else {
626 $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategorySupplier);
627 }
628 }
629 }
630 if ($listofcategoryid) {
631 $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)."))";
632 }
633 if ($searchCategorySupplierOperator == 1) {
634 if (!empty($searchCategorySupplierSqlList)) {
635 $sql .= " AND (".implode(' OR ', $searchCategorySupplierSqlList).")";
636 }
637 } else {
638 if (!empty($searchCategorySupplierSqlList)) {
639 $sql .= " AND (".implode(' AND ', $searchCategorySupplierSqlList).")";
640 }
641 }
642}
643if ($search_all) {
644 $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
645}
646if (strlen($search_cti)) {
647 $sql .= natural_search('s.phone', $search_cti);
648}
649if ($search_id > 0) {
650 $sql .= natural_search("s.rowid", $search_id, 1);
651}
652if (empty($arrayfields['s.name_alias']['checked']) && $search_nom) {
653 $sql .= natural_search(array("s.nom", "s.name_alias"), $search_nom);
654} else {
655 if ($search_nom) {
656 $sql .= natural_search("s.nom", $search_nom);
657 }
658
659 if ($search_alias) {
660 $sql .= natural_search("s.name_alias", $search_alias);
661 }
662}
663if ($search_nom_only) {
664 $sql .= natural_search("s.nom", $search_nom_only);
665}
666if ($search_customer_code) {
667 $sql .= natural_search("s.code_client", $search_customer_code);
668}
669if ($search_supplier_code) {
670 $sql .= natural_search("s.code_fournisseur", $search_supplier_code);
671}
672if ($search_account_customer_code) {
673 $sql .= natural_search("s.code_compta", $search_account_customer_code);
674}
675if ($search_account_supplier_code) {
676 $sql .= natural_search("s.code_compta_fournisseur", $search_account_supplier_code);
677}
678if ($search_address) {
679 $sql .= natural_search('s.address', $search_address);
680}
681if (strlen($search_zip)) {
682 $sql .= natural_search("s.zip", $search_zip);
683}
684if ($search_town) {
685 $sql .= natural_search("s.town", $search_town);
686}
687if ($search_state) {
688 $sql .= natural_search("state.nom", $search_state);
689}
690if ($search_region) {
691 $sql .= natural_search("region.nom", $search_region);
692}
693if ($search_country && $search_country != '-1') {
694 $sql .= " AND s.fk_pays IN (".$db->sanitize($search_country).')';
695}
696if ($search_email) {
697 $sql .= natural_search("s.email", $search_email);
698}
699if (strlen($search_phone)) {
700 $sql .= natural_search("s.phone", $search_phone);
701}
702if (strlen($search_fax)) {
703 $sql .= natural_search("s.fax", $search_fax);
704}
705if ($search_url) {
706 $sql .= natural_search("s.url", $search_url);
707}
708if (strlen($search_idprof1)) {
709 $sql .= natural_search("s.siren", $search_idprof1);
710}
711if (strlen($search_idprof2)) {
712 $sql .= natural_search("s.siret", $search_idprof2);
713}
714if (strlen($search_idprof3)) {
715 $sql .= natural_search("s.ape", $search_idprof3);
716}
717if (strlen($search_idprof4)) {
718 $sql .= natural_search("s.idprof4", $search_idprof4);
719}
720if (strlen($search_idprof5)) {
721 $sql .= natural_search("s.idprof5", $search_idprof5);
722}
723if (strlen($search_idprof6)) {
724 $sql .= natural_search("s.idprof6", $search_idprof6);
725}
726if (strlen($search_vat)) {
727 $sql .= natural_search("s.tva_intra", $search_vat);
728}
729// Filter on type of thirdparty
730if ($search_type > 0 && in_array($search_type, array('1,3', '1,2,3', '2,3'))) {
731 $sql .= " AND s.client IN (".$db->sanitize($search_type).")";
732}
733if ($search_type > 0 && in_array($search_type, array('4'))) {
734 $sql .= " AND s.fournisseur = 1";
735}
736if ($search_type == '0') {
737 $sql .= " AND s.client = 0 AND s.fournisseur = 0";
738}
739if ($search_status != '' && $search_status >= 0) {
740 $sql .= natural_search("s.status", $search_status, 2);
741}
742if (isModEnabled('barcode') && $search_barcode) {
743 $sql .= natural_search("s.barcode", $search_barcode);
744}
745if ($search_price_level && $search_price_level != '-1') {
746 $sql .= natural_search("s.price_level", $search_price_level, 2);
747}
748if ($search_type_thirdparty && $search_type_thirdparty > 0) {
749 $sql .= natural_search("s.fk_typent", $search_type_thirdparty, 2);
750}
751if (!empty($search_staff) && $search_staff != '-1') {
752 $sql .= natural_search("s.fk_effectif", $search_staff, 2);
753}
754if ($search_parent_name) {
755 $sql .= natural_search("s2.nom", $search_parent_name);
756}
757if ($search_level) {
758 $sql .= natural_search("s.fk_prospectlevel", join(',', $search_level), 3);
759}
760if ($search_stcomm) {
761 $sql .= natural_search("s.fk_stcomm", join(',', $search_stcomm), 2);
762}
763if ($search_import_key) {
764 $sql .= natural_search("s.import_key", $search_import_key);
765}
766if ($search_date_creation_start) {
767 $sql .= " AND s.datec >= '".$db->idate($search_date_creation_start)."'";
768}
769if ($search_date_creation_end) {
770 $sql .= " AND s.datec <= '".$db->idate($search_date_creation_end)."'";
771}
772
773if ($search_date_modif_start) {
774 $sql .= " AND s.tms >= '".$db->idate($search_date_modif_start)."'";
775}
776if ($search_date_modif_end) {
777 $sql .= " AND s.tms <= '".$db->idate($search_date_modif_end)."'";
778}
779
780// Add where from extra fields
781include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
782// Add where from hooks
783$parameters = array('socid' => $socid);
784$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
785if (empty($reshook)) {
786 if ($socid) {
787 $sql .= " AND s.rowid = ".((int) $socid);
788 }
789}
790$sql .= $hookmanager->resPrint;
791
792// Add GroupBy from hooks
793$parameters = array('fieldstosearchall' => $fieldstosearchall);
794$reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
795$sql .= $hookmanager->resPrint;
796
797// Count total nb of records
798$nbtotalofrecords = '';
799if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
800 /* The fast and low memory method to get and count full list converts the sql into a sql count */
801 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
802 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
803 $resql = $db->query($sqlforcount);
804 if ($resql) {
805 $objforcount = $db->fetch_object($resql);
806 $nbtotalofrecords = $objforcount->nbtotalofrecords;
807 } else {
808 dol_print_error($db);
809 }
810
811 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
812 $page = 0;
813 $offset = 0;
814 }
815 $db->free($resql);
816}
817
818// Complete request and execute it with limit
819$sql .= $db->order($sortfield, $sortorder);
820if ($limit) {
821 $sql .= $db->plimit($limit + 1, $offset);
822}
823
824$resql = $db->query($sql);
825if (!$resql) {
826 dol_print_error($db);
827 exit;
828}
829
830$num = $db->num_rows($resql);
831
832
833// Direct jump if only one record found
834if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && ($search_all != '' || $search_cti != '') && $action != 'list') {
835 $obj = $db->fetch_object($resql);
836 $id = $obj->rowid;
837 if (getDolGlobalString('SOCIETE_ON_SEARCH_AND_LIST_GO_ON_CUSTOMER_OR_SUPPLIER_CARD')) {
838 if ($obj->client > 0) {
839 header("Location: ".DOL_URL_ROOT.'/comm/card.php?socid='.$id);
840 exit;
841 }
842 if ($obj->fournisseur > 0) {
843 header("Location: ".DOL_URL_ROOT.'/fourn/card.php?socid='.$id);
844 exit;
845 }
846 }
847
848 header("Location: ".DOL_URL_ROOT.'/societe/card.php?socid='.$id);
849 exit;
850}
851
852// Output page
853// --------------------------------------------------------------------
854
855llxHeader('', $title, $help_url);
856
857
858$arrayofselected = is_array($toselect) ? $toselect : array();
859
860$param = '';
861if (!empty($mode)) {
862 $param .= '&mode='.urlencode($mode);
863}
864if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
865 $param .= '&contextpage='.urlencode($contextpage);
866}
867if ($limit > 0 && $limit != $conf->liste_limit) {
868 $param .= '&limit='.((int) $limit);
869}
870if ($optioncss != '') {
871 $param .= '&optioncss='.urlencode($optioncss);
872}
873if ($search_all != '') {
874 $param = "&search_all=".urlencode($search_all);
875}
876if ($search_categ_cus > 0) {
877 $param .= '&search_categ_cus='.urlencode($search_categ_cus);
878}
879if ($search_categ_sup > 0) {
880 $param .= '&search_categ_sup='.urlencode($search_categ_sup);
881}
882if ($search_sale > 0) {
883 $param .= '&search_sale='.urlencode($search_sale);
884}
885if ($search_id > 0) {
886 $param .= "&search_id=".urlencode($search_id);
887}
888if ($search_nom != '') {
889 $param .= "&search_nom=".urlencode($search_nom);
890}
891if ($search_alias != '') {
892 $param .= "&search_alias=".urlencode($search_alias);
893}
894if ($search_address != '') {
895 $param .= '&search_address='.urlencode($search_address);
896}
897if ($search_zip != '') {
898 $param .= "&search_zip=".urlencode($search_zip);
899}
900if ($search_town != '') {
901 $param .= "&search_town=".urlencode($search_town);
902}
903if ($search_phone != '') {
904 $param .= "&search_phone=".urlencode($search_phone);
905}
906if ($search_fax != '') {
907 $param .= "&search_fax=".urlencode($search_fax);
908}
909if ($search_email != '') {
910 $param .= "&search_email=".urlencode($search_email);
911}
912if ($search_url != '') {
913 $param .= "&search_url=".urlencode($search_url);
914}
915if ($search_state != '') {
916 $param .= "&search_state=".urlencode($search_state);
917}
918if ($search_region != '') {
919 $param .= "&search_region=".urlencode($search_region);
920}
921if ($search_country != '') {
922 $param .= "&search_country=".urlencode($search_country);
923}
924if ($search_customer_code != '') {
925 $param .= "&search_customer_code=".urlencode($search_customer_code);
926}
927if ($search_supplier_code != '') {
928 $param .= "&search_supplier_code=".urlencode($search_supplier_code);
929}
930if ($search_account_customer_code != '') {
931 $param .= "&search_account_customer_code=".urlencode($search_account_customer_code);
932}
933if ($search_account_supplier_code != '') {
934 $param .= "&search_account_supplier_code=".urlencode($search_account_supplier_code);
935}
936if ($search_barcode != '') {
937 $param .= "&search_barcode=".urlencode($search_barcode);
938}
939if ($search_idprof1 != '') {
940 $param .= '&search_idprof1='.urlencode($search_idprof1);
941}
942if ($search_idprof2 != '') {
943 $param .= '&search_idprof2='.urlencode($search_idprof2);
944}
945if ($search_idprof3 != '') {
946 $param .= '&search_idprof3='.urlencode($search_idprof3);
947}
948if ($search_idprof4 != '') {
949 $param .= '&search_idprof4='.urlencode($search_idprof4);
950}
951if ($search_idprof5 != '') {
952 $param .= '&search_idprof5='.urlencode($search_idprof5);
953}
954if ($search_idprof6 != '') {
955 $param .= '&search_idprof6='.urlencode($search_idprof6);
956}
957if ($search_vat != '') {
958 $param .= '&search_vat='.urlencode($search_vat);
959}
960if ($search_price_level != '') {
961 $param .= '&search_price_level='.urlencode($search_price_level);
962}
963if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) {
964 $param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty);
965}
966if ($search_type != '') {
967 $param .= '&search_type='.urlencode($search_type);
968}
969if ($search_status != '') {
970 $param .= '&search_status='.urlencode($search_status);
971}
972if (is_array($search_level) && count($search_level)) {
973 foreach ($search_level as $slevel) {
974 $param .= '&search_level[]='.urlencode($slevel);
975 }
976}
977if (is_array($search_stcomm) && count($search_stcomm)) {
978 foreach ($search_stcomm as $slevel) {
979 $param .= '&search_stcomm[]='.urlencode($slevel);
980 }
981}
982if ($search_parent_name != '') {
983 $param .= '&search_parent_name='.urlencode($search_parent_name);
984}
985if ($search_import_key != '') {
986 $param .= '&search_import_key='.urlencode($search_import_key);
987}
988if ($type != '') {
989 $param .= '&type='.urlencode($type);
990}
991if ($search_date_creation_startmonth) {
992 $param .= '&search_date_creation_startmonth='.urlencode($search_date_creation_startmonth);
993}
994if ($search_date_creation_startyear) {
995 $param .= '&search_date_creation_startyear='.urlencode($search_date_creation_startyear);
996}
997if ($search_date_creation_startday) {
998 $param .= '&search_date_creation_startday='.urlencode($search_date_creation_startday);
999}
1000if ($search_date_creation_start) {
1001 $param .= '&search_date_creation_start='.urlencode($search_date_creation_start);
1002}
1003if ($search_date_creation_endmonth) {
1004 $param .= '&search_date_creation_endmonth='.urlencode($search_date_creation_endmonth);
1005}
1006if ($search_date_creation_endyear) {
1007 $param .= '&search_date_creation_endyear='.urlencode($search_date_creation_endyear);
1008}
1009if ($search_date_creation_endday) {
1010 $param .= '&search_date_creation_endday='.urlencode($search_date_creation_endday);
1011}
1012if ($search_date_creation_end) {
1013 $param .= '&search_date_creation_end='.urlencode($search_date_creation_end);
1014}
1015if ($search_date_modif_startmonth) {
1016 $param .= '&search_date_modif_startmonth='.urlencode($search_date_modif_startmonth);
1017}
1018if ($search_date_modif_startyear) {
1019 $param .= '&search_date_modif_startyear='.urlencode($search_date_modif_startyear);
1020}
1021if ($search_date_modif_startday) {
1022 $param .= '&search_date_modif_startday='.urlencode($search_date_modif_startday);
1023}
1024if ($search_date_modif_start) {
1025 $param .= '&search_date_modif_start='.urlencode($search_date_modif_start);
1026}
1027if ($search_date_modif_endmonth) {
1028 $param .= '&search_date_modif_endmonth='.urlencode($search_date_modif_endmonth);
1029}
1030if ($search_date_modif_endyear) {
1031 $param .= '&search_date_modif_endyear='.urlencode($search_date_modif_endyear);
1032}
1033if ($search_date_modif_endday) {
1034 $param .= '&search_date_modif_endday='.urlencode($search_date_modif_endday);
1035}
1036if ($search_date_modif_end) {
1037 $param .= '&search_date_modif_end=' . urlencode($search_date_modif_end);
1038}
1039
1040// Add $param from extra fields
1041include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
1042// Add $param from hooks
1043$parameters = array('param' => &$param);
1044$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1045$param .= $hookmanager->resPrint;
1046
1047// Show delete result message
1048if (GETPOST('delsoc')) {
1049 setEventMessages($langs->trans("CompanyDeleted", GETPOST('delsoc')), null, 'mesgs');
1050}
1051
1052// List of mass actions available
1053$arrayofmassactions = array(
1054 'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
1055 //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
1056);
1057//if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer");
1058if (isModEnabled('category') && $user->hasRight("societe", "creer")) {
1059 $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag");
1060}
1061if ($user->hasRight("societe", "creer")) {
1062 $arrayofmassactions['preenable'] = img_picto('', 'stop-circle', 'class="pictofixedwidth"').$langs->trans("SetToStatus", $object->LibStatut($object::STATUS_INACTIVITY));
1063}
1064if ($user->hasRight("societe", "creer")) {
1065 $arrayofmassactions['predisable'] = img_picto('', 'stop-circle', 'class="pictofixedwidth"').$langs->trans("SetToStatus", $object->LibStatut($object::STATUS_CEASED));
1066}
1067if ($user->hasRight("societe", "creer")) {
1068 $arrayofmassactions['presetcommercial'] = img_picto('', 'user', 'class="pictofixedwidth"').$langs->trans("AllocateCommercial");
1069}
1070if ($user->hasRight('societe', 'supprimer')) {
1071 $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
1072}
1073if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete', 'preaffecttag', 'preenable', 'preclose'))) {
1074 $arrayofmassactions = array();
1075}
1076$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
1077
1078$typefilter = '';
1079$label = 'MenuNewThirdParty';
1080
1081if (!empty($type)) {
1082 $typefilter = '&amp;type='.$type;
1083 if ($type == 'p') {
1084 $label = 'MenuNewProspect';
1085 }
1086 if ($type == 'c') {
1087 $label = 'MenuNewCustomer';
1088 }
1089 if ($type == 'f') {
1090 $label = 'NewSupplier';
1091 }
1092}
1093
1094if ($contextpage == 'poslist' && $type == 't' && (getDolGlobalString('PRODUIT_MULTIPRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES'))) {
1095 print get_htmloutput_mesg(img_warning('default').' '.$langs->trans("BecarefullChangeThirdpartyBeforeAddProductToInvoice"), '', 'warning', 1);
1096}
1097
1098// Show the new button only when this page is not opend from the Extended POS (pop-up window)
1099// but allow it too, when a user has the rights to create a new customer
1100if ($contextpage != 'poslist') {
1101 $url = DOL_URL_ROOT.'/societe/card.php?action=create'.$typefilter;
1102 if (!empty($socid)) {
1103 $url .= '&socid='.$socid;
1104 }
1105 $newcardbutton = '';
1106 $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'));
1107 $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'));
1108 $newcardbutton .= dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', $url, '', $user->hasRight('societe', 'creer'));
1109} elseif ($user->hasRight('societe', 'creer')) {
1110 $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);
1111 $label = 'MenuNewCustomer';
1112 $newcardbutton = dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', $url);
1113}
1114
1115print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'" name="formfilter" autocomplete="off">'."\n";
1116if ($optioncss != '') {
1117 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
1118}
1119print '<input type="hidden" name="token" value="'.newToken().'">';
1120print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1121print '<input type="hidden" name="action" value="list">';
1122print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
1123print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
1124//print '<input type="hidden" name="page" value="'.$page.'">';
1125print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
1126if (!empty($place)) {
1127 print '<input type="hidden" name="place" value="'.$place.'">';
1128}
1129print '<input type="hidden" name="page_y" value="">';
1130print '<input type="hidden" name="mode" value="'.$mode.'">';
1131if (empty($arrayfields['customerorsupplier']['checked'])) {
1132 print '<input type="hidden" name="type" value="'.$type.'">';
1133}
1134if (!empty($place)) {
1135 print '<input type="hidden" name="place" value="'.$place.'">';
1136}
1137
1138print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'building', 0, $newcardbutton, '', $limit, 0, 0, 1);
1139
1140$langs->load("other");
1141$textprofid = array();
1142foreach (array(1, 2, 3, 4, 5, 6) as $key) {
1143 $label = $langs->transnoentities("ProfId".$key.$mysoc->country_code);
1144 $textprofid[$key] = '';
1145 if ($label != "ProfId".$key.$mysoc->country_code) { // Get only text between ()
1146 if (preg_match('/\‍((.*)\‍)/i', $label, $reg)) {
1147 $label = $reg[1];
1148 }
1149 $textprofid[$key] = $langs->trans("ProfIdShortDesc", $key, $mysoc->country_code, $label);
1150 }
1151}
1152
1153// Add code for pre mass action (confirmation or email presend form)
1154$topicmail = "Information";
1155$modelmail = "thirdparty";
1156$objecttmp = new Societe($db);
1157$trackid = 'thi'.$object->id;
1158include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
1159
1160if ($search_all) {
1161 $setupstring = '';
1162 foreach ($fieldstosearchall as $key => $val) {
1163 $fieldstosearchall[$key] = $langs->trans($val);
1164 $setupstring .= $key."=".$val.";";
1165 }
1166 print '<!-- Search done like if SOCIETE_QUICKSEARCH_ON_FIELDS = '.$setupstring.' -->'."\n";
1167 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>';
1168}
1169
1170$moreforfilter = '';
1171if (empty($type) || $type == 'c' || $type == 'p') {
1172 if (isModEnabled('categorie') && $user->hasRight("categorie", "lire")) {
1173 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
1174 $moreforfilter .= '<div class="divsearchfield">';
1175 $tmptitle = $langs->trans('Categories');
1176 $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"');
1177 $moreforfilter .= $formother->select_categories('customer', $search_categ_cus, 'search_categ_cus', 1, $langs->trans('CustomersProspectsCategoriesShort'));
1178 $moreforfilter .= '</div>';
1179 }
1180}
1181
1182if (empty($type) || $type == 'f') {
1183 if (isModEnabled("fournisseur") && isModEnabled('categorie') && $user->hasRight("categorie", "lire")) {
1184 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
1185 $moreforfilter .= '<div class="divsearchfield">';
1186 $tmptitle = $langs->trans('Categories');
1187 $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"');
1188 $moreforfilter .= $formother->select_categories('supplier', $search_categ_sup, 'search_categ_sup', 1, $langs->trans('SuppliersCategoriesShort'));
1189 $moreforfilter .= '</div>';
1190 }
1191}
1192
1193// If the user can view prospects other than his'
1194if ($user->hasRight("societe", "client", "voir") || $socid) {
1195 $moreforfilter .= '<div class="divsearchfield">';
1196 $tmptitle = $langs->trans('SalesRepresentatives');
1197 $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"');
1198 $moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $langs->trans('SalesRepresentatives'), ($conf->dol_optimize_smallscreen ? 'maxwidth200' : 'maxwidth300'), 1);
1199 $moreforfilter .= '</div>';
1200}
1201if (!empty($moreforfilter)) {
1202 print '<div class="liste_titre liste_titre_bydiv centpercent">';
1203 print $moreforfilter;
1204 $parameters = array('type'=>$type);
1205 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1206 print $hookmanager->resPrint;
1207 print '</div>';
1208}
1209
1210$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
1211$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields
1212//$selectedfields = ($mode != 'kanban' ? $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')) : ''); // This also change content of $arrayfields
1213$selectedfields .= ((count($arrayofmassactions) && $contextpage != 'poslist') ? $form->showCheckAddButtons('checkforselect', 1) : '');
1214
1215print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
1216print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
1217
1218// Fields title search
1219// --------------------------------------------------------------------
1220print '<tr class="liste_titre_filter">';
1221// Action column
1222if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1223 print '<td class="liste_titre maxwidthsearch center actioncolumn">';
1224 $searchpicto = $form->showFilterButtons('left');
1225 print $searchpicto;
1226 print '</td>';
1227}
1228if (!empty($arrayfields['s.rowid']['checked'])) {
1229 print '<td class="liste_titre" data-key="id">';
1230 print '<input class="flat searchstring" type="text" name="search_id" size="1" value="'.dol_escape_htmltag($search_id).'">';
1231 print '</td>';
1232}
1233if (!empty($arrayfields['s.nom']['checked'])) {
1234 print '<td class="liste_titre" data-key="ref">';
1235 if (!empty($search_nom_only) && empty($search_nom)) {
1236 $search_nom = $search_nom_only;
1237 }
1238 print '<input class="flat searchstring maxwidth75imp" type="text" name="search_nom" value="'.dol_escape_htmltag($search_nom).'">';
1239 print '</td>';
1240}
1241if (!empty($arrayfields['s.name_alias']['checked'])) {
1242 print '<td class="liste_titre">';
1243 print '<input class="flat searchstring maxwidth75imp" type="text" name="search_alias" value="'.dol_escape_htmltag($search_alias).'">';
1244 print '</td>';
1245}
1246// Barcode
1247if (!empty($arrayfields['s.barcode']['checked'])) {
1248 print '<td class="liste_titre">';
1249 print '<input class="flat searchstring maxwidth75imp" type="text" name="search_barcode" value="'.dol_escape_htmltag($search_barcode).'">';
1250 print '</td>';
1251}
1252// Customer code
1253if (!empty($arrayfields['s.code_client']['checked'])) {
1254 print '<td class="liste_titre">';
1255 print '<input class="flat searchstring maxwidth75imp" type="text" name="search_customer_code" value="'.dol_escape_htmltag($search_customer_code).'">';
1256 print '</td>';
1257}
1258// Supplier code
1259if (!empty($arrayfields['s.code_fournisseur']['checked'])) {
1260 print '<td class="liste_titre">';
1261 print '<input class="flat searchstring maxwidth75imp" type="text" name="search_supplier_code" value="'.dol_escape_htmltag($search_supplier_code).'">';
1262 print '</td>';
1263}
1264// Account Customer code
1265if (!empty($arrayfields['s.code_compta']['checked'])) {
1266 print '<td class="liste_titre">';
1267 print '<input class="flat searchstring maxwidth75imp" type="text" name="search_account_customer_code" value="'.dol_escape_htmltag($search_account_customer_code).'">';
1268 print '</td>';
1269}
1270// Account Supplier code
1271if (!empty($arrayfields['s.code_compta_fournisseur']['checked'])) {
1272 print '<td class="liste_titre">';
1273 print '<input class="flat maxwidth75imp" type="text" name="search_account_supplier_code" value="'.dol_escape_htmltag($search_account_supplier_code).'">';
1274 print '</td>';
1275}
1276// Address
1277if (!empty($arrayfields['s.address']['checked'])) {
1278 print '<td class="liste_titre">';
1279 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_address" value="'.dol_escape_htmltag($search_address).'">';
1280 print '</td>';
1281}
1282// Sales representatives
1283if (!empty($arrayfields['sales.representative']['checked'])) {
1284 print '<td class="liste_titre">';
1285 print '</td>';
1286}
1287// Zip
1288if (!empty($arrayfields['s.zip']['checked'])) {
1289 print '<td class="liste_titre">';
1290 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_zip" value="'.dol_escape_htmltag($search_zip).'">';
1291 print '</td>';
1292}
1293// Town
1294if (!empty($arrayfields['s.town']['checked'])) {
1295 print '<td class="liste_titre">';
1296 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_town" value="'.dol_escape_htmltag($search_town).'">';
1297 print '</td>';
1298}
1299// State
1300if (!empty($arrayfields['state.nom']['checked'])) {
1301 print '<td class="liste_titre">';
1302 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
1303 print '</td>';
1304}
1305// Region
1306if (!empty($arrayfields['region.nom']['checked'])) {
1307 print '<td class="liste_titre">';
1308 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_region" value="'.dol_escape_htmltag($search_region).'">';
1309 print '</td>';
1310}
1311// Country
1312if (!empty($arrayfields['country.code_iso']['checked'])) {
1313 print '<td class="liste_titre center">';
1314 print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100');
1315 print '</td>';
1316}
1317// Company type
1318if (!empty($arrayfields['typent.code']['checked'])) {
1319 print '<td class="liste_titre maxwidthonsmartphone center">';
1320 // We use showempty=0 here because there is already an unknown value into dictionary.
1321 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);
1322 print '</td>';
1323}
1324// Multiprice level
1325if (!empty($arrayfields['s.price_level']['checked'])) {
1326 print '<td class="liste_titre">';
1327 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_price_level" value="'.dol_escape_htmltag($search_price_level).'">';
1328 print '</td>';
1329}
1330// Staff
1331if (!empty($arrayfields['staff.code']['checked'])) {
1332 print '<td class="liste_titre maxwidthonsmartphone center">';
1333 print $form->selectarray("search_staff", $formcompany->effectif_array(0), $search_staff, 0, 0, 0, '', 0, 0, 0, 'ASC', 'maxwidth100', 1);
1334 print '</td>';
1335}
1336if (!empty($arrayfields['s.email']['checked'])) {
1337 // Email
1338 print '<td class="liste_titre">';
1339 print '<input class="flat searchemail maxwidth50imp" type="text" name="search_email" value="'.dol_escape_htmltag($search_email).'">';
1340 print '</td>';
1341}
1342if (!empty($arrayfields['s.phone']['checked'])) {
1343 // Phone
1344 print '<td class="liste_titre">';
1345 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_phone" value="'.dol_escape_htmltag($search_phone).'">';
1346 print '</td>';
1347}
1348if (!empty($arrayfields['s.fax']['checked'])) {
1349 // Fax
1350 print '<td class="liste_titre">';
1351 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_fax" value="'.dol_escape_htmltag($search_fax).'">';
1352 print '</td>';
1353}
1354if (!empty($arrayfields['s.url']['checked'])) {
1355 // Url
1356 print '<td class="liste_titre">';
1357 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_url" value="'.dol_escape_htmltag($search_url).'">';
1358 print '</td>';
1359}
1360if (!empty($arrayfields['s.siren']['checked'])) {
1361 // IdProf1
1362 print '<td class="liste_titre">';
1363 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_idprof1" value="'.dol_escape_htmltag($search_idprof1).'">';
1364 print '</td>';
1365}
1366if (!empty($arrayfields['s.siret']['checked'])) {
1367 // IdProf2
1368 print '<td class="liste_titre">';
1369 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_idprof2" value="'.dol_escape_htmltag($search_idprof2).'">';
1370 print '</td>';
1371}
1372if (!empty($arrayfields['s.ape']['checked'])) {
1373 // IdProf3
1374 print '<td class="liste_titre">';
1375 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_idprof3" value="'.dol_escape_htmltag($search_idprof3).'">';
1376 print '</td>';
1377}
1378if (!empty($arrayfields['s.idprof4']['checked'])) {
1379 // IdProf4
1380 print '<td class="liste_titre">';
1381 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_idprof4" value="'.dol_escape_htmltag($search_idprof4).'">';
1382 print '</td>';
1383}
1384if (!empty($arrayfields['s.idprof5']['checked'])) {
1385 // IdProf5
1386 print '<td class="liste_titre">';
1387 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_idprof5" value="'.dol_escape_htmltag($search_idprof5).'">';
1388 print '</td>';
1389}
1390if (!empty($arrayfields['s.idprof6']['checked'])) {
1391 // IdProf6
1392 print '<td class="liste_titre">';
1393 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_idprof6" value="'.dol_escape_htmltag($search_idprof6).'">';
1394 print '</td>';
1395}
1396if (!empty($arrayfields['s.tva_intra']['checked'])) {
1397 // Vat number
1398 print '<td class="liste_titre">';
1399 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_vat" value="'.dol_escape_htmltag($search_vat).'">';
1400 print '</td>';
1401}
1402
1403// Nature (customer/prospect/supplier)
1404if (!empty($arrayfields['customerorsupplier']['checked'])) {
1405 print '<td class="liste_titre maxwidthonsmartphone center">';
1406 if ($type != '') {
1407 print '<input type="hidden" name="type" value="'.$type.'">';
1408 }
1409 print $formcompany->selectProspectCustomerType($search_type, 'search_type', 'search_type', 'list');
1410 print '</td>';
1411}
1412// Prospect level
1413if (!empty($arrayfields['s.fk_prospectlevel']['checked'])) {
1414 print '<td class="liste_titre center">';
1415 print $form->multiselectarray('search_level', $tab_level, $search_level, 0, 0, 'width75', 0, 0, '', '', '', 2);
1416 print '</td>';
1417}
1418// Prospect status
1419if (!empty($arrayfields['s.fk_stcomm']['checked'])) {
1420 print '<td class="liste_titre maxwidthonsmartphone center">';
1421 $arraystcomm = array();
1422 foreach ($prospectstatic->cacheprospectstatus as $key => $val) {
1423 $arraystcomm[$val['id']] = ($langs->trans("StatusProspect".$val['id']) != "StatusProspect".$val['id'] ? $langs->trans("StatusProspect".$val['id']) : $val['label']);
1424 }
1425 //print $form->selectarray('search_stcomm', $arraystcomm, $search_stcomm, -2, 0, 0, '', 0, 0, 0, '', '', 1);
1426 print $form->multiselectarray('search_stcomm', $arraystcomm, $search_stcomm, 0, 0, 'width100', 0, 0, '', '', '', 2);
1427 print '</td>';
1428}
1429if (!empty($arrayfields['s2.nom']['checked'])) {
1430 print '<td class="liste_titre center">';
1431 print '<input class="flat searchstring maxwidth75imp" type="text" name="search_parent_name" value="'.dol_escape_htmltag($search_parent_name).'">';
1432 print '</td>';
1433}
1434// Extra fields
1435include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
1436
1437// Fields from hook
1438$parameters = array('arrayfields'=>$arrayfields);
1439$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1440print $hookmanager->resPrint;
1441// Creation date
1442if (!empty($arrayfields['s.datec']['checked'])) {
1443 print '<td class="liste_titre center nowraponall">';
1444 print '<div class="nowrapfordate">';
1445 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'));
1446 print '</div>';
1447 print '<div class="nowrapfordate">';
1448 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'));
1449 print '</div>';
1450 print '</td>';
1451}
1452// Modification date
1453if (!empty($arrayfields['s.tms']['checked'])) {
1454 print '<td class="liste_titre center nowraponall">';
1455 print '<div class="nowrapfordate">';
1456 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'));
1457 print '</div>';
1458 print '<div class="nowrapfordate">';
1459 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'));
1460 print '</div>';
1461 print '</td>';
1462}
1463// Status
1464if (!empty($arrayfields['s.status']['checked'])) {
1465 print '<td class="liste_titre center minwidth75imp parentonrightofpage">';
1466 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);
1467 print '</td>';
1468}
1469if (!empty($arrayfields['s.import_key']['checked'])) {
1470 print '<td class="liste_titre center">';
1471 print '<input class="flat searchstring maxwidth50" type="text" name="search_import_key" value="'.dol_escape_htmltag($search_import_key).'">';
1472 print '</td>';
1473}
1474// Action column
1475if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1476 print '<td class="liste_titre center maxwidthsearch actioncolumn">';
1477 $searchpicto = $form->showFilterButtons();
1478 print $searchpicto;
1479 print '</td>';
1480}
1481
1482print '</tr>'."\n";
1483
1484$totalarray = array();
1485$totalarray['nbfield'] = 0;
1486
1487// Fields title label
1488// --------------------------------------------------------------------
1489print '<tr class="liste_titre">';
1490// Action column
1491if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1492 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
1493 $totalarray['nbfield']++;
1494}
1495if (!empty($arrayfields['s.rowid']['checked'])) {
1496 print_liste_field_titre($arrayfields['s.rowid']['label'], $_SERVER["PHP_SELF"], "s.rowid", "", $param, ' data-key="id"', $sortfield, $sortorder, '');
1497 $totalarray['nbfield']++;
1498}
1499if (!empty($arrayfields['s.nom']['checked'])) {
1500 print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, ' data-key="ref"', $sortfield, $sortorder, ' ');
1501 $totalarray['nbfield']++;
1502}
1503if (!empty($arrayfields['s.name_alias']['checked'])) {
1504 print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"], "s.name_alias", "", $param, "", $sortfield, $sortorder);
1505 $totalarray['nbfield']++;
1506}
1507if (!empty($arrayfields['s.barcode']['checked'])) {
1508 print_liste_field_titre($arrayfields['s.barcode']['label'], $_SERVER["PHP_SELF"], "s.barcode", $param, '', '', $sortfield, $sortorder);
1509 $totalarray['nbfield']++;
1510}
1511if (!empty($arrayfields['s.code_client']['checked'])) {
1512 print_liste_field_titre($arrayfields['s.code_client']['label'], $_SERVER["PHP_SELF"], "s.code_client", "", $param, '', $sortfield, $sortorder);
1513 $totalarray['nbfield']++;
1514}
1515if (!empty($arrayfields['s.code_fournisseur']['checked'])) {
1516 print_liste_field_titre($arrayfields['s.code_fournisseur']['label'], $_SERVER["PHP_SELF"], "s.code_fournisseur", "", $param, '', $sortfield, $sortorder);
1517 $totalarray['nbfield']++;
1518}
1519if (!empty($arrayfields['s.code_compta']['checked'])) {
1520 print_liste_field_titre($arrayfields['s.code_compta']['label'], $_SERVER["PHP_SELF"], "s.code_compta", "", $param, '', $sortfield, $sortorder);
1521 $totalarray['nbfield']++;
1522}
1523if (!empty($arrayfields['s.code_compta_fournisseur']['checked'])) {
1524 print_liste_field_titre($arrayfields['s.code_compta_fournisseur']['label'], $_SERVER["PHP_SELF"], "s.code_compta_fournisseur", "", $param, '', $sortfield, $sortorder);
1525 $totalarray['nbfield']++;
1526}
1527if (!empty($arrayfields['s.address']['checked'])) {
1528 print_liste_field_titre($arrayfields['s.address']['label'], $_SERVER['PHP_SELF'], 's.address', '', $param, '', $sortfield, $sortorder);
1529 $totalarray['nbfield']++;
1530}
1531if (!empty($arrayfields['sales.representative']['checked'])) {
1532 print_liste_field_titre($arrayfields['sales.representative']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder);
1533 $totalarray['nbfield']++;
1534}
1535if (!empty($arrayfields['s.zip']['checked'])) {
1536 print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], "s.zip", "", $param, '', $sortfield, $sortorder);
1537 $totalarray['nbfield']++;
1538}
1539if (!empty($arrayfields['s.town']['checked'])) {
1540 print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], "s.town", "", $param, '', $sortfield, $sortorder);
1541 $totalarray['nbfield']++;
1542}
1543if (!empty($arrayfields['state.nom']['checked'])) {
1544 print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder);
1545 $totalarray['nbfield']++;
1546}
1547if (!empty($arrayfields['region.nom']['checked'])) {
1548 print_liste_field_titre($arrayfields['region.nom']['label'], $_SERVER["PHP_SELF"], "region.nom", "", $param, '', $sortfield, $sortorder);
1549 $totalarray['nbfield']++;
1550}
1551if (!empty($arrayfields['country.code_iso']['checked'])) {
1552 print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center ');
1553 $totalarray['nbfield']++;
1554}
1555if (!empty($arrayfields['typent.code']['checked'])) {
1556 print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, "", $sortfield, $sortorder, 'center ');
1557 $totalarray['nbfield']++;
1558}
1559if (!empty($arrayfields['staff.code']['checked'])) {
1560 print_liste_field_titre($arrayfields['staff.code']['label'], $_SERVER["PHP_SELF"], "staff.code", "", $param, '', $sortfield, $sortorder, 'center ');
1561 $totalarray['nbfield']++;
1562}
1563if (!empty($arrayfields['s.price_level']['checked'])) {
1564 print_liste_field_titre($arrayfields['s.price_level']['label'], $_SERVER["PHP_SELF"], "s.price_level", "", $param, '', $sortfield, $sortorder);
1565 $totalarray['nbfield']++;
1566}
1567if (!empty($arrayfields['s.email']['checked'])) {
1568 print_liste_field_titre($arrayfields['s.email']['label'], $_SERVER["PHP_SELF"], "s.email", "", $param, '', $sortfield, $sortorder);
1569 $totalarray['nbfield']++;
1570}
1571if (!empty($arrayfields['s.phone']['checked'])) {
1572 print_liste_field_titre($arrayfields['s.phone']['label'], $_SERVER["PHP_SELF"], "s.phone", "", $param, '', $sortfield, $sortorder);
1573 $totalarray['nbfield']++;
1574}
1575if (!empty($arrayfields['s.fax']['checked'])) {
1576 print_liste_field_titre($arrayfields['s.fax']['label'], $_SERVER["PHP_SELF"], "s.fax", "", $param, '', $sortfield, $sortorder);
1577 $totalarray['nbfield']++;
1578}
1579if (!empty($arrayfields['s.url']['checked'])) {
1580 print_liste_field_titre($arrayfields['s.url']['label'], $_SERVER["PHP_SELF"], "s.url", "", $param, '', $sortfield, $sortorder);
1581 $totalarray['nbfield']++;
1582}
1583if (!empty($arrayfields['s.siren']['checked'])) {
1584 print_liste_field_titre($form->textwithpicto($langs->trans("ProfId1Short"), $textprofid[1], 1, 0), $_SERVER["PHP_SELF"], "s.siren", "", $param, '', $sortfield, $sortorder, 'nowrap ');
1585 $totalarray['nbfield']++;
1586}
1587if (!empty($arrayfields['s.siret']['checked'])) {
1588 print_liste_field_titre($form->textwithpicto($langs->trans("ProfId2Short"), $textprofid[2], 1, 0), $_SERVER["PHP_SELF"], "s.siret", "", $param, '', $sortfield, $sortorder, 'nowrap ');
1589 $totalarray['nbfield']++;
1590}
1591if (!empty($arrayfields['s.ape']['checked'])) {
1592 print_liste_field_titre($form->textwithpicto($langs->trans("ProfId3Short"), $textprofid[3], 1, 0), $_SERVER["PHP_SELF"], "s.ape", "", $param, '', $sortfield, $sortorder, 'nowrap ');
1593 $totalarray['nbfield']++;
1594}
1595if (!empty($arrayfields['s.idprof4']['checked'])) {
1596 print_liste_field_titre($form->textwithpicto($langs->trans("ProfId4Short"), $textprofid[4], 1, 0), $_SERVER["PHP_SELF"], "s.idprof4", "", $param, '', $sortfield, $sortorder, 'nowrap ');
1597 $totalarray['nbfield']++;
1598}
1599if (!empty($arrayfields['s.idprof5']['checked'])) {
1600 print_liste_field_titre($form->textwithpicto($langs->trans("ProfId5Short"), $textprofid[5], 1, 0), $_SERVER["PHP_SELF"], "s.idprof5", "", $param, '', $sortfield, $sortorder, 'nowrap ');
1601 $totalarray['nbfield']++;
1602}
1603if (!empty($arrayfields['s.idprof6']['checked'])) {
1604 print_liste_field_titre($form->textwithpicto($langs->trans("ProfId6Short"), $textprofid[6], 1, 0), $_SERVER["PHP_SELF"], "s.idprof6", "", $param, '', $sortfield, $sortorder, 'nowrap ');
1605 $totalarray['nbfield']++;
1606}
1607if (!empty($arrayfields['s.tva_intra']['checked'])) {
1608 print_liste_field_titre($arrayfields['s.tva_intra']['label'], $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder, 'nowrap ');
1609 $totalarray['nbfield']++;
1610}
1611if (!empty($arrayfields['customerorsupplier']['checked'])) {
1612 print_liste_field_titre($arrayfields['customerorsupplier']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'center '); // type of customer
1613 $totalarray['nbfield']++;
1614}
1615if (!empty($arrayfields['s.fk_prospectlevel']['checked'])) {
1616 print_liste_field_titre($arrayfields['s.fk_prospectlevel']['label'], $_SERVER["PHP_SELF"], "s.fk_prospectlevel", "", $param, '', $sortfield, $sortorder, 'center ');
1617 $totalarray['nbfield']++;
1618}
1619if (!empty($arrayfields['s.fk_stcomm']['checked'])) {
1620 print_liste_field_titre($arrayfields['s.fk_stcomm']['label'], $_SERVER["PHP_SELF"], "s.fk_stcomm", "", $param, '', $sortfield, $sortorder, 'center ');
1621 $totalarray['nbfield']++;
1622}
1623if (!empty($arrayfields['s2.nom']['checked'])) {
1624 print_liste_field_titre($arrayfields['s2.nom']['label'], $_SERVER["PHP_SELF"], "s2.nom", "", $param, '', $sortfield, $sortorder, 'center ');
1625 $totalarray['nbfield']++;
1626}
1627// Extra fields
1628include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
1629// Hook fields
1630$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
1631$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1632print $hookmanager->resPrint;
1633if (!empty($arrayfields['s.datec']['checked'])) {
1634 print_liste_field_titre($arrayfields['s.datec']['label'], $_SERVER["PHP_SELF"], "s.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1635 $totalarray['nbfield']++; // For the column action
1636}
1637if (!empty($arrayfields['s.tms']['checked'])) {
1638 print_liste_field_titre($arrayfields['s.tms']['label'], $_SERVER["PHP_SELF"], "s.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1639 $totalarray['nbfield']++; // For the column action
1640}
1641if (!empty($arrayfields['s.status']['checked'])) {
1642 print_liste_field_titre($arrayfields['s.status']['label'], $_SERVER["PHP_SELF"], "s.status", "", $param, '', $sortfield, $sortorder, 'center ');
1643 $totalarray['nbfield']++; // For the column action
1644}
1645if (!empty($arrayfields['s.import_key']['checked'])) {
1646 print_liste_field_titre($arrayfields['s.import_key']['label'], $_SERVER["PHP_SELF"], "s.import_key", "", $param, '', $sortfield, $sortorder, 'center ');
1647 $totalarray['nbfield']++; // For the column action
1648}
1649// Action column
1650if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1651 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
1652 $totalarray['nbfield']++;
1653}
1654print '</tr>'."\n";
1655
1656
1657// Loop on record
1658// --------------------------------------------------------------------
1659$i = 0;
1660$savnbfield = $totalarray['nbfield'];
1661$totalarray = array();
1662$totalarray['nbfield'] = 0;
1663$imaxinloop = ($limit ? min($num, $limit) : $num);
1664while ($i < $imaxinloop) {
1665 $obj = $db->fetch_object($resql);
1666 if (empty($obj)) {
1667 break; // Should not happen
1668 }
1669
1670 $parameters = array('staticdata' => $obj);
1671 // Note that $action and $object may have been modified by hook
1672 // do companystatic fetch in hook if wanted or anything else
1673 $reshook = $hookmanager->executeHooks('loadStaticObject', $parameters, $companystatic, $action);
1674 if (empty($reshook)) {
1675 $companystatic->id = $obj->rowid;
1676 $companystatic->name = $obj->name;
1677 $companystatic->name_alias = $obj->name_alias;
1678 $companystatic->logo = $obj->logo;
1679 $companystatic->barcode = $obj->barcode;
1680 $companystatic->canvas = $obj->canvas;
1681 $companystatic->client = $obj->client;
1682 $companystatic->status = $obj->status;
1683 $companystatic->email = $obj->email;
1684 $companystatic->address = $obj->address;
1685 $companystatic->zip = $obj->zip;
1686 $companystatic->town = $obj->town;
1687 $companystatic->fournisseur = $obj->fournisseur;
1688 $companystatic->code_client = $obj->code_client;
1689 $companystatic->code_fournisseur = $obj->code_fournisseur;
1690 $companystatic->tva_intra = $obj->tva_intra;
1691 $companystatic->country_code = $obj->country_code;
1692
1693 $companystatic->code_compta_client = $obj->code_compta;
1694 $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
1695
1696 $companystatic->fk_prospectlevel = $obj->fk_prospectlevel;
1697 $companystatic->parent = $obj->fk_parent;
1698 $companystatic->entity = $obj->entity;
1699 }
1700
1701 if ($mode == 'kanban') {
1702 if ($i == 0) {
1703 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
1704 print '<div class="box-flex-container kanban">';
1705 }
1706 // Output Kanban
1707 print $companystatic->getKanbanView('', array('selected' => in_array($obj->rowid, $arrayofselected)));
1708 if ($i == ($imaxinloop - 1)) {
1709 print '</div>';
1710 print '</td></tr>';
1711 }
1712 } else {
1713 // Show line of result
1714 $j = 0;
1715 print '<tr data-rowid="'.$object->id.'" class="oddeven"';
1716 if ($contextpage == 'poslist') {
1717 print ' onclick="location.href=\'list.php?action=change&contextpage=poslist&idcustomer='.$obj->rowid.'&place='.urlencode($place).'\'"';
1718 }
1719 print '>';
1720
1721 // Action column (Show the massaction button only when this page is not opend from the Extended POS)
1722 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1723 print '<td class="nowrap center actioncolumn">';
1724 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
1725 $selected = 0;
1726 if (in_array($obj->rowid, $arrayofselected)) {
1727 $selected = 1;
1728 }
1729 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
1730 }
1731 print '</td>';
1732 if (!$i) {
1733 $totalarray['nbfield']++;
1734 }
1735 }
1736 if (!empty($arrayfields['s.rowid']['checked'])) {
1737 print '<td class="tdoverflowmax50" data-key="id">';
1738 print $obj->rowid;
1739 print "</td>\n";
1740 if (!$i) {
1741 $totalarray['nbfield']++;
1742 }
1743 }
1744 if (!empty($arrayfields['s.nom']['checked'])) {
1745 print '<td'.(!getDolGlobalString('MAIN_SOCIETE_SHOW_COMPLETE_NAME') ? ' class="tdoverflowmax200"' : '').' data-key="ref">';
1746 if ($contextpage == 'poslist') {
1747 print dol_escape_htmltag($companystatic->name);
1748 } else {
1749 print $companystatic->getNomUrl(1, '', 100, 0, 1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1);
1750 }
1751 print "</td>\n";
1752 if (!$i) {
1753 $totalarray['nbfield']++;
1754 }
1755 }
1756 if (!empty($arrayfields['s.name_alias']['checked'])) {
1757 print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($companystatic->name_alias).'">';
1758 print dol_escape_htmltag($companystatic->name_alias);
1759 print "</td>\n";
1760 if (!$i) {
1761 $totalarray['nbfield']++;
1762 }
1763 }
1764 // Barcode
1765 if (!empty($arrayfields['s.barcode']['checked'])) {
1766 print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($companystatic->barcode).'">'.dol_escape_htmltag($companystatic->barcode).'</td>';
1767 if (!$i) {
1768 $totalarray['nbfield']++;
1769 }
1770 }
1771 // Customer code
1772 if (!empty($arrayfields['s.code_client']['checked'])) {
1773 print '<td class="nowraponall">'.dol_escape_htmltag($companystatic->code_client).'</td>';
1774 if (!$i) {
1775 $totalarray['nbfield']++;
1776 }
1777 }
1778 // Supplier code
1779 if (!empty($arrayfields['s.code_fournisseur']['checked'])) {
1780 print '<td class="nowraponall">'.dol_escape_htmltag($companystatic->code_fournisseur).'</td>';
1781 if (!$i) {
1782 $totalarray['nbfield']++;
1783 }
1784 }
1785 // Account customer code
1786 if (!empty($arrayfields['s.code_compta']['checked'])) {
1787 print '<td>'.dol_escape_htmltag($companystatic->code_compta_client).'</td>';
1788 if (!$i) {
1789 $totalarray['nbfield']++;
1790 }
1791 }
1792 // Account supplier code
1793 if (!empty($arrayfields['s.code_compta_fournisseur']['checked'])) {
1794 print '<td>'.dol_escape_htmltag($companystatic->code_compta_fournisseur).'</td>';
1795 if (!$i) {
1796 $totalarray['nbfield']++;
1797 }
1798 }
1799 // Address
1800 if (!empty($arrayfields['s.address']['checked'])) {
1801 print '<td class="tdoverflowmax250" title="'.dol_escape_htmltag($companystatic->address).'">'.dol_escape_htmltag($companystatic->address).'</td>';
1802 if (!$i) {
1803 $totalarray['nbfield']++;
1804 }
1805 }
1806 // Sales Representative
1807 if (!empty($arrayfields['sales.representative']['checked'])) {
1808 print '<td class="nowraponall tdoverflowmax200">';
1809 $listsalesrepresentatives = $companystatic->getSalesRepresentatives($user);
1810 $nbofsalesrepresentative = count($listsalesrepresentatives);
1811 if ($nbofsalesrepresentative > 6) {
1812 // We print only number
1813 print $nbofsalesrepresentative;
1814 } elseif ($nbofsalesrepresentative > 0) {
1815 $userstatic = new User($db);
1816 $j = 0;
1817 foreach ($listsalesrepresentatives as $val) {
1818 $userstatic->id = $val['id'];
1819 $userstatic->lastname = $val['lastname'];
1820 $userstatic->firstname = $val['firstname'];
1821 $userstatic->email = $val['email'];
1822 $userstatic->entity = $val['entity'];
1823 $userstatic->photo = $val['photo'];
1824 $userstatic->login = $val['login'];
1825 $userstatic->office_phone = $val['office_phone'];
1826 $userstatic->office_fax = $val['office_fax'];
1827 $userstatic->user_mobile = $val['user_mobile'];
1828 $userstatic->job = $val['job'];
1829 $userstatic->gender = $val['gender'];
1830 $userstatic->statut = $val['statut'];
1831 print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1, '', 0, 0, 12) : $userstatic->getNomUrl(-2);
1832 $j++;
1833 if ($j < $nbofsalesrepresentative) {
1834 print ' ';
1835 }
1836 }
1837 } else {
1838 print '&nbsp;';
1839 }
1840 print '</td>';
1841 if (!$i) {
1842 $totalarray['nbfield']++;
1843 }
1844 }
1845 // Zip
1846 if (!empty($arrayfields['s.zip']['checked'])) {
1847 print "<td>".dol_escape_htmltag($companystatic->zip)."</td>\n";
1848 if (!$i) {
1849 $totalarray['nbfield']++;
1850 }
1851 }
1852 // Town
1853 if (!empty($arrayfields['s.town']['checked'])) {
1854 print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($companystatic->town).'">'.dol_escape_htmltag($companystatic->town)."</td>\n";
1855 if (!$i) {
1856 $totalarray['nbfield']++;
1857 }
1858 }
1859 // State
1860 if (!empty($arrayfields['state.nom']['checked'])) {
1861 print "<td>".dol_escape_htmltag($obj->state_name)."</td>\n";
1862 if (!$i) {
1863 $totalarray['nbfield']++;
1864 }
1865 }
1866 // Region
1867 if (!empty($arrayfields['region.nom']['checked'])) {
1868 print "<td>".dol_escape_htmltag($obj->region_name)."</td>\n";
1869 if (!$i) {
1870 $totalarray['nbfield']++;
1871 }
1872 }
1873 // Country
1874 if (!empty($arrayfields['country.code_iso']['checked'])) {
1875 print '<td class="center tdoverflowmax100">';
1876 $labelcountry = ($companystatic->country_code && ($langs->trans("Country".$companystatic->country_code) != "Country".$companystatic->country_code)) ? $langs->trans("Country".$companystatic->country_code) : $obj->country_label;
1877 print $labelcountry;
1878 print '</td>';
1879 if (!$i) {
1880 $totalarray['nbfield']++;
1881 }
1882 }
1883 // Type ent
1884 if (!empty($arrayfields['typent.code']['checked'])) {
1885 if (!isset($typenArray) || !is_array($typenArray) || count($typenArray) == 0) {
1886 $typenArray = $formcompany->typent_array(1);
1887 }
1888 $labeltypeofcompany= empty($typenArray[$obj->typent_code]) ? '' : $typenArray[$obj->typent_code];
1889
1890 print '<td class="center tdoverflowmax125" title="'.dol_escape_htmltag($labeltypeofcompany).'">';
1891 print dol_escape_htmltag($labeltypeofcompany);
1892 print '</td>';
1893 if (!$i) {
1894 $totalarray['nbfield']++;
1895 }
1896 }
1897 // Multiprice level
1898 if (!empty($arrayfields['s.price_level']['checked'])) {
1899 print '<td class="center">'.$obj->price_level."</td>\n";
1900 if (!$i) {
1901 $totalarray['nbfield']++;
1902 }
1903 }
1904 // Staff
1905 if (!empty($arrayfields['staff.code']['checked'])) {
1906 print '<td class="center">';
1907 if (!empty($obj->staff_code)) {
1908 if (empty($conf->cache['staffArray'])) {
1909 $conf->cache['staffArray'] = $formcompany->effectif_array(1);
1910 }
1911 print $conf->cache['staffArray'][$obj->staff_code];
1912 }
1913 print '</td>';
1914 if (!$i) {
1915 $totalarray['nbfield']++;
1916 }
1917 }
1918 if (!empty($arrayfields['s.email']['checked'])) {
1919 print '<td class="tdoverflowmax150">'.dol_print_email($obj->email, $obj->rowid, $obj->rowid, 'AC_EMAIL', 0, 0, 1)."</td>\n";
1920 if (!$i) {
1921 $totalarray['nbfield']++;
1922 }
1923 }
1924 if (!empty($arrayfields['s.phone']['checked'])) {
1925 print '<td class="nowraponall">'.dol_print_phone($obj->phone, $companystatic->country_code, 0, $obj->rowid, 'AC_TEL', ' ', 'phone')."</td>\n";
1926 if (!$i) {
1927 $totalarray['nbfield']++;
1928 }
1929 }
1930 if (!empty($arrayfields['s.fax']['checked'])) {
1931 print '<td class="nowraponall">'.dol_print_phone($obj->fax, $companystatic->country_code, 0, $obj->rowid, 'AC_TEL', ' ', 'fax')."</td>\n";
1932 if (!$i) {
1933 $totalarray['nbfield']++;
1934 }
1935 }
1936 if (!empty($arrayfields['s.url']['checked'])) {
1937 print "<td>".dol_print_url($obj->url, '', '', 1)."</td>\n";
1938 if (!$i) {
1939 $totalarray['nbfield']++;
1940 }
1941 }
1942 if (!empty($arrayfields['s.siren']['checked'])) {
1943 print "<td>".$obj->idprof1."</td>\n";
1944 if (!$i) {
1945 $totalarray['nbfield']++;
1946 }
1947 }
1948 if (!empty($arrayfields['s.siret']['checked'])) {
1949 print "<td>".$obj->idprof2."</td>\n";
1950 if (!$i) {
1951 $totalarray['nbfield']++;
1952 }
1953 }
1954 if (!empty($arrayfields['s.ape']['checked'])) {
1955 print "<td>".$obj->idprof3."</td>\n";
1956 if (!$i) {
1957 $totalarray['nbfield']++;
1958 }
1959 }
1960 if (!empty($arrayfields['s.idprof4']['checked'])) {
1961 print "<td>".$obj->idprof4."</td>\n";
1962 if (!$i) {
1963 $totalarray['nbfield']++;
1964 }
1965 }
1966 if (!empty($arrayfields['s.idprof5']['checked'])) {
1967 print "<td>".$obj->idprof5."</td>\n";
1968 if (!$i) {
1969 $totalarray['nbfield']++;
1970 }
1971 }
1972 if (!empty($arrayfields['s.idprof6']['checked'])) {
1973 print "<td>".$obj->idprof6."</td>\n";
1974 if (!$i) {
1975 $totalarray['nbfield']++;
1976 }
1977 }
1978 // VAT
1979 if (!empty($arrayfields['s.tva_intra']['checked'])) {
1980 print '<td class="tdoverflowmax125" title="'.dol_escape_htmltag($companystatic->tva_intra).'">';
1981 if ($companystatic->tva_intra && !isValidVATID($companystatic)) {
1982 print img_warning("BadVATNumber", '', 'pictofixedwidth');
1983 }
1984 print $companystatic->tva_intra;
1985 print "</td>\n";
1986 if (!$i) {
1987 $totalarray['nbfield']++;
1988 }
1989 }
1990 // Nature
1991 if (!empty($arrayfields['customerorsupplier']['checked'])) {
1992 print '<td class="center">';
1993 print $companystatic->getTypeUrl(1);
1994 print '</td>';
1995 if (!$i) {
1996 $totalarray['nbfield']++;
1997 }
1998 }
1999 // Prospect level
2000 if (!empty($arrayfields['s.fk_prospectlevel']['checked'])) {
2001 print '<td class="center nowraponall">';
2002 print $companystatic->getLibProspLevel();
2003 print "</td>";
2004 if (!$i) {
2005 $totalarray['nbfield']++;
2006 }
2007 }
2008 // Prospect status
2009 if (!empty($arrayfields['s.fk_stcomm']['checked'])) {
2010 print '<td class="center nowraponall">';
2011
2012 $prospectid = $obj->rowid;
2013 $statusprospect = $obj->stcomm_id;
2014
2015 $formcompany->selectProspectStatus('status_prospect', $prospectstatic, $statusprospect, $prospectid);
2016
2017 print '</td>';
2018 if (!$i) {
2019 $totalarray['nbfield']++;
2020 }
2021 }
2022 // Parent company
2023 if (!empty($arrayfields['s2.nom']['checked'])) {
2024 print '<td class="center tdoverflowmax100">';
2025 if ($companystatic->parent > 0) {
2026 $companyparent->fetch($companystatic->parent);
2027 print $companyparent->getNomUrl(1);
2028 }
2029 print "</td>";
2030 if (!$i) {
2031 $totalarray['nbfield']++;
2032 }
2033 }
2034 // Extra fields
2035 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
2036 // Fields from hook
2037 $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
2038 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
2039 print $hookmanager->resPrint;
2040 // Date creation
2041 if (!empty($arrayfields['s.datec']['checked'])) {
2042 print '<td class="center nowraponall">';
2043 print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
2044 print '</td>';
2045 if (!$i) {
2046 $totalarray['nbfield']++;
2047 }
2048 }
2049 // Date modification
2050 if (!empty($arrayfields['s.tms']['checked'])) {
2051 print '<td class="center nowraponall">';
2052 print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
2053 print '</td>';
2054 if (!$i) {
2055 $totalarray['nbfield']++;
2056 }
2057 }
2058 // Status
2059 if (!empty($arrayfields['s.status']['checked'])) {
2060 print '<td class="center nowraponall">'.$companystatic->getLibStatut(5).'</td>';
2061 if (!$i) {
2062 $totalarray['nbfield']++;
2063 }
2064 }
2065 // Import key
2066 if (!empty($arrayfields['s.import_key']['checked'])) {
2067 print '<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->import_key).'">';
2068 print dol_escape_htmltag($obj->import_key);
2069 print "</td>\n";
2070 if (!$i) {
2071 $totalarray['nbfield']++;
2072 }
2073 }
2074 // Action column (Show the massaction button only when this page is not opend from the Extended POS)
2075 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
2076 print '<td class="nowrap center actioncolumn">';
2077 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
2078 $selected = 0;
2079 if (in_array($obj->rowid, $arrayofselected)) {
2080 $selected = 1;
2081 }
2082 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
2083 }
2084 print '</td>';
2085 if (!$i) {
2086 $totalarray['nbfield']++;
2087 }
2088 }
2089
2090 print '</tr>'."\n";
2091 }
2092 $i++;
2093}
2094
2095// Show total line
2096include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
2097
2098// If no record found
2099if ($num == 0) {
2100 $colspan = 1;
2101 foreach ($arrayfields as $key => $val) {
2102 if (!empty($val['checked'])) {
2103 $colspan++;
2104 }
2105 }
2106 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
2107}
2108
2109$db->free($resql);
2110
2111$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
2112$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
2113print $hookmanager->resPrint;
2114
2115print '</table>'."\n";
2116print '</div>'."\n";
2117
2118// Line that calls the select_status function by passing it js as the 5th parameter in order to activate the js script
2119$formcompany->selectProspectStatus('status_prospect', $prospectstatic, null, null, "js");
2120
2121print '</form>'."\n";
2122
2123// End of page
2124llxFooter();
2125$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...
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_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by 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.