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