dolibarr  19.0.0-dev
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
39 require_once '../main.inc.php';
40 include_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
41 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
42 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
43 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
44 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
45 require_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');
60 if ($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');
119 if (!$sortorder) {
120  $sortorder = "ASC";
121 }
122 if (!$sortfield) {
123  $sortfield = "s.nom";
124 }
125 if (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 
133 if ($type == 'c') {
134  if (empty($contextpage) || $contextpage == 'thirdpartylist') {
135  $contextpage = 'customerlist';
136  } if ($search_type == '') {
137  $search_type = '1,3';
138  }
139 }
140 if ($type == 'p') {
141  if (empty($contextpage) || $contextpage == 'thirdpartylist') {
142  $contextpage = 'prospectlist';
143  } if ($search_type == '') {
144  $search_type = '2,3';
145  }
146 }
147 if ($type == 't') {
148  if (empty($contextpage) || $contextpage == 'poslist') {
149  $contextpage = 'poslist';
150  } if ($search_type == '') {
151  $search_type = '1,2,3';
152  }
153 }
154 if ($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 );
191 if (($tmp = $langs->transnoentities("ProfId4".$mysoc->country_code)) && $tmp != "ProfId4".$mysoc->country_code && $tmp != '-') {
192  $fieldstosearchall['s.idprof4'] = 'ProfId4';
193 }
194 if (($tmp = $langs->transnoentities("ProfId5".$mysoc->country_code)) && $tmp != "ProfId5".$mysoc->country_code && $tmp != '-') {
195  $fieldstosearchall['s.idprof5'] = 'ProfId5';
196 }
197 if (($tmp = $langs->transnoentities("ProfId6".$mysoc->country_code)) && $tmp != "ProfId6".$mysoc->country_code && $tmp != '-') {
198  $fieldstosearchall['s.idprof6'] = 'ProfId6';
199 }
200 if (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'
204 if (!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 );
263 if (!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
268 include 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');
275 if ($user->socid) {
276  $socid = $user->socid;
277 }
278 $result = restrictedArea($user, 'societe', $socid, '');
279 
280 
281 
282 /*
283  * Actions
284  */
285 
286 if ($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 
323 if (GETPOST('cancel', 'alpha')) {
324  $action = 'list';
325  $massaction = '';
326 }
327 if (!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
333 if ($reshook < 0) {
334  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
335 }
336 
337 if (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 
406 if ($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");
437 if ($type == 'c' && (empty($search_type) || ($search_type == '1,3'))) {
438  $title = $langs->trans("Customers");
439 }
440 if ($type == 'p' && (empty($search_type) || ($search_type == '2,3'))) {
441  $title = $langs->trans("Prospects");
442 }
443 if ($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);
456 if ($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)
484 if ($search_sale && $search_sale != '-1') {
485  $sql .= ", sc.fk_soc, sc.fk_user";
486 }
487 // Add fields from extrafields
488 if (!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";
504 if (!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
515 if ($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);
527 if (empty($user->rights->societe->client->voir) && !$socid) {
528  $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
529 }
530 if ($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 }
533 if (empty($user->rights->fournisseur->lire)) {
534  $sql .= " AND (s.fournisseur <> 1 OR s.client <> 0)"; // client=0, fournisseur=0 must be visible
535 }
536 if ($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)
544 if (!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)
574 if (!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 }
601 if ($search_all) {
602  $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
603 }
604 if (strlen($search_cti)) {
605  $sql .= natural_search('s.phone', $search_cti);
606 }
607 if ($search_id > 0) {
608  $sql .= natural_search("s.rowid", $search_id, 1);
609 }
610 if (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 }
621 if ($search_nom_only) {
622  $sql .= natural_search("s.nom", $search_nom_only);
623 }
624 if ($search_customer_code) {
625  $sql .= natural_search("s.code_client", $search_customer_code);
626 }
627 if ($search_supplier_code) {
628  $sql .= natural_search("s.code_fournisseur", $search_supplier_code);
629 }
630 if ($search_account_customer_code) {
631  $sql .= natural_search("s.code_compta", $search_account_customer_code);
632 }
633 if ($search_account_supplier_code) {
634  $sql .= natural_search("s.code_compta_fournisseur", $search_account_supplier_code);
635 }
636 if ($search_address) {
637  $sql .= natural_search('s.address', $search_address);
638 }
639 if (strlen($search_zip)) {
640  $sql .= natural_search("s.zip", $search_zip);
641 }
642 if ($search_town) {
643  $sql .= natural_search("s.town", $search_town);
644 }
645 if ($search_state) {
646  $sql .= natural_search("state.nom", $search_state);
647 }
648 if ($search_region) {
649  $sql .= natural_search("region.nom", $search_region);
650 }
651 if ($search_country && $search_country != '-1') {
652  $sql .= " AND s.fk_pays IN (".$db->sanitize($search_country).')';
653 }
654 if ($search_email) {
655  $sql .= natural_search("s.email", $search_email);
656 }
657 if (strlen($search_phone)) {
658  $sql .= natural_search("s.phone", $search_phone);
659 }
660 if (strlen($search_fax)) {
661  $sql .= natural_search("s.fax", $search_fax);
662 }
663 if ($search_url) {
664  $sql .= natural_search("s.url", $search_url);
665 }
666 if (strlen($search_idprof1)) {
667  $sql .= natural_search("s.siren", $search_idprof1);
668 }
669 if (strlen($search_idprof2)) {
670  $sql .= natural_search("s.siret", $search_idprof2);
671 }
672 if (strlen($search_idprof3)) {
673  $sql .= natural_search("s.ape", $search_idprof3);
674 }
675 if (strlen($search_idprof4)) {
676  $sql .= natural_search("s.idprof4", $search_idprof4);
677 }
678 if (strlen($search_idprof5)) {
679  $sql .= natural_search("s.idprof5", $search_idprof5);
680 }
681 if (strlen($search_idprof6)) {
682  $sql .= natural_search("s.idprof6", $search_idprof6);
683 }
684 if (strlen($search_vat)) {
685  $sql .= natural_search("s.tva_intra", $search_vat);
686 }
687 // Filter on type of thirdparty
688 if ($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 }
691 if ($search_type > 0 && in_array($search_type, array('4'))) {
692  $sql .= " AND s.fournisseur = 1";
693 }
694 if ($search_type == '0') {
695  $sql .= " AND s.client = 0 AND s.fournisseur = 0";
696 }
697 if ($search_status != '' && $search_status >= 0) {
698  $sql .= natural_search("s.status", $search_status, 2);
699 }
700 if (isModEnabled('barcode') && $search_barcode) {
701  $sql .= natural_search("s.barcode", $search_barcode);
702 }
703 if ($search_price_level && $search_price_level != '-1') {
704  $sql .= natural_search("s.price_level", $search_price_level, 2);
705 }
706 if ($search_type_thirdparty && $search_type_thirdparty > 0) {
707  $sql .= natural_search("s.fk_typent", $search_type_thirdparty, 2);
708 }
709 if (!empty($search_staff) && $search_staff != '-1') {
710  $sql .= natural_search("s.fk_effectif", $search_staff, 2);
711 }
712 if ($search_parent_name) {
713  $sql .= natural_search("s2.nom", $search_parent_name);
714 }
715 if ($search_level) {
716  $sql .= natural_search("s.fk_prospectlevel", join(',', $search_level), 3);
717 }
718 if ($search_stcomm) {
719  $sql .= natural_search("s.fk_stcomm", join(',', $search_stcomm), 2);
720 }
721 if ($search_import_key) {
722  $sql .= natural_search("s.import_key", $search_import_key);
723 }
724 // Add where from extra fields
725 include 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
729 if (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 = '';
743 if (!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);
764 if ($limit) {
765  $sql .= $db->plimit($limit + 1, $offset);
766 }
767 
768 $resql = $db->query($sql);
769 if (!$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
778 if ($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 
799 llxHeader('', $title, $help_url);
800 
801 
802 $arrayofselected = is_array($toselect) ? $toselect : array();
803 
804 $param = '';
805 if (!empty($mode)) {
806  $param .= '&mode='.urlencode($mode);
807 }
808 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
809  $param .= '&contextpage='.urlencode($contextpage);
810 }
811 if ($limit > 0 && $limit != $conf->liste_limit) {
812  $param .= '&limit='.((int) $limit);
813 }
814 if ($optioncss != '') {
815  $param .= '&optioncss='.urlencode($optioncss);
816 }
817 if ($search_all != '') {
818  $param = "&search_all=".urlencode($search_all);
819 }
820 if ($search_categ_cus > 0) {
821  $param .= '&search_categ_cus='.urlencode($search_categ_cus);
822 }
823 if ($search_categ_sup > 0) {
824  $param .= '&search_categ_sup='.urlencode($search_categ_sup);
825 }
826 if ($search_sale > 0) {
827  $param .= '&search_sale='.urlencode($search_sale);
828 }
829 if ($search_id > 0) {
830  $param .= "&search_id=".urlencode($search_id);
831 }
832 if ($search_nom != '') {
833  $param .= "&search_nom=".urlencode($search_nom);
834 }
835 if ($search_alias != '') {
836  $param .= "&search_alias=".urlencode($search_alias);
837 }
838 if ($search_address != '') {
839  $param .= '&search_address='.urlencode($search_address);
840 }
841 if ($search_zip != '') {
842  $param .= "&search_zip=".urlencode($search_zip);
843 }
844 if ($search_town != '') {
845  $param .= "&search_town=".urlencode($search_town);
846 }
847 if ($search_phone != '') {
848  $param .= "&search_phone=".urlencode($search_phone);
849 }
850 if ($search_fax != '') {
851  $param .= "&search_fax=".urlencode($search_fax);
852 }
853 if ($search_email != '') {
854  $param .= "&search_email=".urlencode($search_email);
855 }
856 if ($search_url != '') {
857  $param .= "&search_url=".urlencode($search_url);
858 }
859 if ($search_state != '') {
860  $param .= "&search_state=".urlencode($search_state);
861 }
862 if ($search_region != '') {
863  $param .= "&search_region=".urlencode($search_region);
864 }
865 if ($search_country != '') {
866  $param .= "&search_country=".urlencode($search_country);
867 }
868 if ($search_customer_code != '') {
869  $param .= "&search_customer_code=".urlencode($search_customer_code);
870 }
871 if ($search_supplier_code != '') {
872  $param .= "&search_supplier_code=".urlencode($search_supplier_code);
873 }
874 if ($search_account_customer_code != '') {
875  $param .= "&search_account_customer_code=".urlencode($search_account_customer_code);
876 }
877 if ($search_account_supplier_code != '') {
878  $param .= "&search_account_supplier_code=".urlencode($search_account_supplier_code);
879 }
880 if ($search_barcode != '') {
881  $param .= "&search_barcode=".urlencode($search_barcode);
882 }
883 if ($search_idprof1 != '') {
884  $param .= '&search_idprof1='.urlencode($search_idprof1);
885 }
886 if ($search_idprof2 != '') {
887  $param .= '&search_idprof2='.urlencode($search_idprof2);
888 }
889 if ($search_idprof3 != '') {
890  $param .= '&search_idprof3='.urlencode($search_idprof3);
891 }
892 if ($search_idprof4 != '') {
893  $param .= '&search_idprof4='.urlencode($search_idprof4);
894 }
895 if ($search_idprof5 != '') {
896  $param .= '&search_idprof5='.urlencode($search_idprof5);
897 }
898 if ($search_idprof6 != '') {
899  $param .= '&search_idprof6='.urlencode($search_idprof6);
900 }
901 if ($search_vat != '') {
902  $param .= '&search_vat='.urlencode($search_vat);
903 }
904 if ($search_price_level != '') {
905  $param .= '&search_price_level='.urlencode($search_price_level);
906 }
907 if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) {
908  $param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty);
909 }
910 if ($search_type != '') {
911  $param .= '&search_type='.urlencode($search_type);
912 }
913 if ($search_status != '') {
914  $param .= '&search_status='.urlencode($search_status);
915 }
916 if (is_array($search_level) && count($search_level)) {
917  foreach ($search_level as $slevel) {
918  $param .= '&search_level[]='.urlencode($slevel);
919  }
920 }
921 if (is_array($search_stcomm) && count($search_stcomm)) {
922  foreach ($search_stcomm as $slevel) {
923  $param .= '&search_stcomm[]='.urlencode($slevel);
924  }
925 }
926 if ($search_parent_name != '') {
927  $param .= '&search_parent_name='.urlencode($search_parent_name);
928 }
929 if ($search_import_key != '') {
930  $param .= '&search_import_key='.urlencode($search_import_key);
931 }
932 if ($type != '') {
933  $param .= '&type='.urlencode($type);
934 }
935 // Add $param from extra fields
936 include 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
943 if (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");
953 if (isModEnabled('category') && $user->hasRight("societe", "creer")) {
954  $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag");
955 }
956 if ($user->hasRight("societe", "creer")) {
957  $arrayofmassactions['preenable'] = img_picto('', 'stop-circle', 'class="pictofixedwidth"').$langs->trans("SetToStatus", $object->LibStatut($object::STATUS_INACTIVITY));
958 }
959 if ($user->hasRight("societe", "creer")) {
960  $arrayofmassactions['predisable'] = img_picto('', 'stop-circle', 'class="pictofixedwidth"').$langs->trans("SetToStatus", $object->LibStatut($object::STATUS_CEASED));
961 }
962 if ($user->hasRight("societe", "creer")) {
963  $arrayofmassactions['presetcommercial'] = img_picto('', 'user', 'class="pictofixedwidth"').$langs->trans("AllocateCommercial");
964 }
965 if ($user->hasRight('societe', 'supprimer')) {
966  $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
967 }
968 if (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 
976 if (!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 
989 if ($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
995 if ($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 
1010 print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'" name="formfilter" autocomplete="off">'."\n";
1011 if ($optioncss != '') {
1012  print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
1013 }
1014 print '<input type="hidden" name="token" value="'.newToken().'">';
1015 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1016 print '<input type="hidden" name="action" value="list">';
1017 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
1018 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
1019 //print '<input type="hidden" name="page" value="'.$page.'">';
1020 print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
1021 if (!empty($place)) {
1022  print '<input type="hidden" name="place" value="'.$place.'">';
1023 }
1024 print '<input type="hidden" name="page_y" value="">';
1025 print '<input type="hidden" name="mode" value="'.$mode.'">';
1026 if (empty($arrayfields['customerorsupplier']['checked'])) {
1027  print '<input type="hidden" name="type" value="'.$type.'">';
1028 }
1029 if (!empty($place)) {
1030  print '<input type="hidden" name="place" value="'.$place.'">';
1031 }
1032 
1033 print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'building', 0, $newcardbutton, '', $limit, 0, 0, 1);
1034 
1035 $langs->load("other");
1036 $textprofid = array();
1037 foreach (array(1, 2, 3, 4, 5, 6) as $key) {
1038  $label = $langs->transnoentities("ProfId".$key.$mysoc->country_code);
1039  $textprofid[$key] = '';
1040  if ($label != "ProfId".$key.$mysoc->country_code) { // Get only text between ()
1041  if (preg_match('/\‍((.*)\‍)/i', $label, $reg)) {
1042  $label = $reg[1];
1043  }
1044  $textprofid[$key] = $langs->trans("ProfIdShortDesc", $key, $mysoc->country_code, $label);
1045  }
1046 }
1047 
1048 // Add code for pre mass action (confirmation or email presend form)
1049 $topicmail = "Information";
1050 $modelmail = "thirdparty";
1051 $objecttmp = new Societe($db);
1052 $trackid = 'thi'.$object->id;
1053 include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
1054 
1055 if ($search_all) {
1056  $setupstring = '';
1057  foreach ($fieldstosearchall as $key => $val) {
1058  $fieldstosearchall[$key] = $langs->trans($val);
1059  $setupstring .= $key."=".$val.";";
1060  }
1061  print '<!-- Search done like if SOCIETE_QUICKSEARCH_ON_FIELDS = '.$setupstring.' -->'."\n";
1062  print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>';
1063 }
1064 
1065 $moreforfilter = '';
1066 if (empty($type) || $type == 'c' || $type == 'p') {
1067  if (isModEnabled('categorie') && $user->hasRight("categorie", "lire")) {
1068  require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
1069  $moreforfilter .= '<div class="divsearchfield">';
1070  $tmptitle = $langs->trans('Categories');
1071  $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"');
1072  $moreforfilter .= $formother->select_categories('customer', $search_categ_cus, 'search_categ_cus', 1, $langs->trans('CustomersProspectsCategoriesShort'));
1073  $moreforfilter .= '</div>';
1074  }
1075 }
1076 
1077 if (empty($type) || $type == 'f') {
1078  if (isModEnabled("fournisseur") && isModEnabled('categorie') && $user->hasRight("categorie", "lire")) {
1079  require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
1080  $moreforfilter .= '<div class="divsearchfield">';
1081  $tmptitle = $langs->trans('Categories');
1082  $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"');
1083  $moreforfilter .= $formother->select_categories('supplier', $search_categ_sup, 'search_categ_sup', 1, $langs->trans('SuppliersCategoriesShort'));
1084  $moreforfilter .= '</div>';
1085  }
1086 }
1087 
1088 // If the user can view prospects other than his'
1089 if ($user->hasRight("societe", "client", "voir") || $socid) {
1090  $moreforfilter .= '<div class="divsearchfield">';
1091  $tmptitle = $langs->trans('SalesRepresentatives');
1092  $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"');
1093  $moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $langs->trans('SalesRepresentatives'), ($conf->dol_optimize_smallscreen ? 'maxwidth200' : 'maxwidth300'), 1);
1094  $moreforfilter .= '</div>';
1095 }
1096 if (!empty($moreforfilter)) {
1097  print '<div class="liste_titre liste_titre_bydiv centpercent">';
1098  print $moreforfilter;
1099  $parameters = array('type'=>$type);
1100  $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1101  print $hookmanager->resPrint;
1102  print '</div>';
1103 }
1104 
1105 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
1106 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields
1107 //$selectedfields = ($mode != 'kanban' ? $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')) : ''); // This also change content of $arrayfields
1108 $selectedfields .= ((count($arrayofmassactions) && $contextpage != 'poslist') ? $form->showCheckAddButtons('checkforselect', 1) : '');
1109 
1110 print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
1111 print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
1112 
1113 // Fields title search
1114 // --------------------------------------------------------------------
1115 print '<tr class="liste_titre_filter">';
1116 // Action column
1117 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1118  print '<td class="liste_titre maxwidthsearch center actioncolumn">';
1119  $searchpicto = $form->showFilterButtons('left');
1120  print $searchpicto;
1121  print '</td>';
1122 }
1123 if (!empty($arrayfields['s.rowid']['checked'])) {
1124  print '<td class="liste_titre" data-key="id">';
1125  print '<input class="flat searchstring" type="text" name="search_id" size="1" value="'.dol_escape_htmltag($search_id).'">';
1126  print '</td>';
1127 }
1128 if (!empty($arrayfields['s.nom']['checked'])) {
1129  print '<td class="liste_titre" data-key="ref">';
1130  if (!empty($search_nom_only) && empty($search_nom)) {
1131  $search_nom = $search_nom_only;
1132  }
1133  print '<input class="flat searchstring maxwidth75imp" type="text" name="search_nom" value="'.dol_escape_htmltag($search_nom).'">';
1134  print '</td>';
1135 }
1136 if (!empty($arrayfields['s.name_alias']['checked'])) {
1137  print '<td class="liste_titre">';
1138  print '<input class="flat searchstring maxwidth75imp" type="text" name="search_alias" value="'.dol_escape_htmltag($search_alias).'">';
1139  print '</td>';
1140 }
1141 // Barcode
1142 if (!empty($arrayfields['s.barcode']['checked'])) {
1143  print '<td class="liste_titre">';
1144  print '<input class="flat searchstring maxwidth75imp" type="text" name="search_barcode" value="'.dol_escape_htmltag($search_barcode).'">';
1145  print '</td>';
1146 }
1147 // Customer code
1148 if (!empty($arrayfields['s.code_client']['checked'])) {
1149  print '<td class="liste_titre">';
1150  print '<input class="flat searchstring maxwidth75imp" type="text" name="search_customer_code" value="'.dol_escape_htmltag($search_customer_code).'">';
1151  print '</td>';
1152 }
1153 // Supplier code
1154 if (!empty($arrayfields['s.code_fournisseur']['checked'])) {
1155  print '<td class="liste_titre">';
1156  print '<input class="flat searchstring maxwidth75imp" type="text" name="search_supplier_code" value="'.dol_escape_htmltag($search_supplier_code).'">';
1157  print '</td>';
1158 }
1159 // Account Customer code
1160 if (!empty($arrayfields['s.code_compta']['checked'])) {
1161  print '<td class="liste_titre">';
1162  print '<input class="flat searchstring maxwidth75imp" type="text" name="search_account_customer_code" value="'.dol_escape_htmltag($search_account_customer_code).'">';
1163  print '</td>';
1164 }
1165 // Account Supplier code
1166 if (!empty($arrayfields['s.code_compta_fournisseur']['checked'])) {
1167  print '<td class="liste_titre">';
1168  print '<input class="flat maxwidth75imp" type="text" name="search_account_supplier_code" value="'.dol_escape_htmltag($search_account_supplier_code).'">';
1169  print '</td>';
1170 }
1171 // Address
1172 if (!empty($arrayfields['s.address']['checked'])) {
1173  print '<td class="liste_titre">';
1174  print '<input class="flat searchstring maxwidth50imp" type="text" name="search_address" value="'.dol_escape_htmltag($search_address).'">';
1175  print '</td>';
1176 }
1177 // Zip
1178 if (!empty($arrayfields['s.zip']['checked'])) {
1179  print '<td class="liste_titre">';
1180  print '<input class="flat searchstring maxwidth50imp" type="text" name="search_zip" value="'.dol_escape_htmltag($search_zip).'">';
1181  print '</td>';
1182 }
1183 // Town
1184 if (!empty($arrayfields['s.town']['checked'])) {
1185  print '<td class="liste_titre">';
1186  print '<input class="flat searchstring maxwidth50imp" type="text" name="search_town" value="'.dol_escape_htmltag($search_town).'">';
1187  print '</td>';
1188 }
1189 // State
1190 if (!empty($arrayfields['state.nom']['checked'])) {
1191  print '<td class="liste_titre">';
1192  print '<input class="flat searchstring maxwidth50imp" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
1193  print '</td>';
1194 }
1195 // Region
1196 if (!empty($arrayfields['region.nom']['checked'])) {
1197  print '<td class="liste_titre">';
1198  print '<input class="flat searchstring maxwidth50imp" type="text" name="search_region" value="'.dol_escape_htmltag($search_region).'">';
1199  print '</td>';
1200 }
1201 // Country
1202 if (!empty($arrayfields['country.code_iso']['checked'])) {
1203  print '<td class="liste_titre center">';
1204  print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100');
1205  print '</td>';
1206 }
1207 // Company type
1208 if (!empty($arrayfields['typent.code']['checked'])) {
1209  print '<td class="liste_titre maxwidthonsmartphone center">';
1210  // We use showempty=0 here because there is already an unknown value into dictionary.
1211  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);
1212  print '</td>';
1213 }
1214 // Multiprice level
1215 if (!empty($arrayfields['s.price_level']['checked'])) {
1216  print '<td class="liste_titre">';
1217  print '<input class="flat searchstring maxwidth50imp" type="text" name="search_price_level" value="'.dol_escape_htmltag($search_price_level).'">';
1218  print '</td>';
1219 }
1220 // Staff
1221 if (!empty($arrayfields['staff.code']['checked'])) {
1222  print '<td class="liste_titre maxwidthonsmartphone center">';
1223  print $form->selectarray("search_staff", $formcompany->effectif_array(0), $search_staff, 0, 0, 0, '', 0, 0, 0, 'ASC', 'maxwidth100', 1);
1224  print '</td>';
1225 }
1226 if (!empty($arrayfields['s.email']['checked'])) {
1227  // Email
1228  print '<td class="liste_titre">';
1229  print '<input class="flat searchemail maxwidth50imp" type="text" name="search_email" value="'.dol_escape_htmltag($search_email).'">';
1230  print '</td>';
1231 }
1232 if (!empty($arrayfields['s.phone']['checked'])) {
1233  // Phone
1234  print '<td class="liste_titre">';
1235  print '<input class="flat searchstring maxwidth50imp" type="text" name="search_phone" value="'.dol_escape_htmltag($search_phone).'">';
1236  print '</td>';
1237 }
1238 if (!empty($arrayfields['s.fax']['checked'])) {
1239  // Fax
1240  print '<td class="liste_titre">';
1241  print '<input class="flat searchstring maxwidth50imp" type="text" name="search_fax" value="'.dol_escape_htmltag($search_fax).'">';
1242  print '</td>';
1243 }
1244 if (!empty($arrayfields['s.url']['checked'])) {
1245  // Url
1246  print '<td class="liste_titre">';
1247  print '<input class="flat searchstring maxwidth50imp" type="text" name="search_url" value="'.dol_escape_htmltag($search_url).'">';
1248  print '</td>';
1249 }
1250 if (!empty($arrayfields['s.siren']['checked'])) {
1251  // IdProf1
1252  print '<td class="liste_titre">';
1253  print '<input class="flat searchstring maxwidth50imp" type="text" name="search_idprof1" value="'.dol_escape_htmltag($search_idprof1).'">';
1254  print '</td>';
1255 }
1256 if (!empty($arrayfields['s.siret']['checked'])) {
1257  // IdProf2
1258  print '<td class="liste_titre">';
1259  print '<input class="flat searchstring maxwidth50imp" type="text" name="search_idprof2" value="'.dol_escape_htmltag($search_idprof2).'">';
1260  print '</td>';
1261 }
1262 if (!empty($arrayfields['s.ape']['checked'])) {
1263  // IdProf3
1264  print '<td class="liste_titre">';
1265  print '<input class="flat searchstring maxwidth50imp" type="text" name="search_idprof3" value="'.dol_escape_htmltag($search_idprof3).'">';
1266  print '</td>';
1267 }
1268 if (!empty($arrayfields['s.idprof4']['checked'])) {
1269  // IdProf4
1270  print '<td class="liste_titre">';
1271  print '<input class="flat searchstring maxwidth50imp" type="text" name="search_idprof4" value="'.dol_escape_htmltag($search_idprof4).'">';
1272  print '</td>';
1273 }
1274 if (!empty($arrayfields['s.idprof5']['checked'])) {
1275  // IdProf5
1276  print '<td class="liste_titre">';
1277  print '<input class="flat searchstring maxwidth50imp" type="text" name="search_idprof5" value="'.dol_escape_htmltag($search_idprof5).'">';
1278  print '</td>';
1279 }
1280 if (!empty($arrayfields['s.idprof6']['checked'])) {
1281  // IdProf6
1282  print '<td class="liste_titre">';
1283  print '<input class="flat searchstring maxwidth50imp" type="text" name="search_idprof6" value="'.dol_escape_htmltag($search_idprof6).'">';
1284  print '</td>';
1285 }
1286 if (!empty($arrayfields['s.tva_intra']['checked'])) {
1287  // Vat number
1288  print '<td class="liste_titre">';
1289  print '<input class="flat searchstring maxwidth50imp" type="text" name="search_vat" value="'.dol_escape_htmltag($search_vat).'">';
1290  print '</td>';
1291 }
1292 
1293 // Nature (customer/prospect/supplier)
1294 if (!empty($arrayfields['customerorsupplier']['checked'])) {
1295  print '<td class="liste_titre maxwidthonsmartphone center">';
1296  if ($type != '') {
1297  print '<input type="hidden" name="type" value="'.$type.'">';
1298  }
1299  print $formcompany->selectProspectCustomerType($search_type, 'search_type', 'search_type', 'list');
1300  print '</td>';
1301 }
1302 // Prospect level
1303 if (!empty($arrayfields['s.fk_prospectlevel']['checked'])) {
1304  print '<td class="liste_titre center">';
1305  print $form->multiselectarray('search_level', $tab_level, $search_level, 0, 0, 'width75', 0, 0, '', '', '', 2);
1306  print '</td>';
1307 }
1308 // Prospect status
1309 if (!empty($arrayfields['s.fk_stcomm']['checked'])) {
1310  print '<td class="liste_titre maxwidthonsmartphone center">';
1311  $arraystcomm = array();
1312  foreach ($prospectstatic->cacheprospectstatus as $key => $val) {
1313  $arraystcomm[$val['id']] = ($langs->trans("StatusProspect".$val['id']) != "StatusProspect".$val['id'] ? $langs->trans("StatusProspect".$val['id']) : $val['label']);
1314  }
1315  //print $form->selectarray('search_stcomm', $arraystcomm, $search_stcomm, -2, 0, 0, '', 0, 0, 0, '', '', 1);
1316  print $form->multiselectarray('search_stcomm', $arraystcomm, $search_stcomm, 0, 0, 'width100', 0, 0, '', '', '', 2);
1317  print '</td>';
1318 }
1319 if (!empty($arrayfields['s2.nom']['checked'])) {
1320  print '<td class="liste_titre center">';
1321  print '<input class="flat searchstring maxwidth75imp" type="text" name="search_parent_name" value="'.dol_escape_htmltag($search_parent_name).'">';
1322  print '</td>';
1323 }
1324 // Extra fields
1325 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
1326 
1327 // Fields from hook
1328 $parameters = array('arrayfields'=>$arrayfields);
1329 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1330 print $hookmanager->resPrint;
1331 // Date creation
1332 if (!empty($arrayfields['s.datec']['checked'])) {
1333  print '<td class="liste_titre">';
1334  print '</td>';
1335 }
1336 // Date modification
1337 if (!empty($arrayfields['s.tms']['checked'])) {
1338  print '<td class="liste_titre">';
1339  print '</td>';
1340 }
1341 // Status
1342 if (!empty($arrayfields['s.status']['checked'])) {
1343  print '<td class="liste_titre center minwidth75imp parentonrightofpage">';
1344  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);
1345  print '</td>';
1346 }
1347 if (!empty($arrayfields['s.import_key']['checked'])) {
1348  print '<td class="liste_titre center">';
1349  print '<input class="flat searchstring maxwidth50" type="text" name="search_import_key" value="'.dol_escape_htmltag($search_import_key).'">';
1350  print '</td>';
1351 }
1352 // Action column
1353 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1354  print '<td class="liste_titre center maxwidthsearch actioncolumn">';
1355  $searchpicto = $form->showFilterButtons();
1356  print $searchpicto;
1357  print '</td>';
1358 }
1359 
1360 print '</tr>'."\n";
1361 
1362 $totalarray = array();
1363 $totalarray['nbfield'] = 0;
1364 
1365 // Fields title label
1366 // --------------------------------------------------------------------
1367 print '<tr class="liste_titre">';
1368 // Action column
1369 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1370  print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
1371  $totalarray['nbfield']++;
1372 }
1373 if (!empty($arrayfields['s.rowid']['checked'])) {
1374  print_liste_field_titre($arrayfields['s.rowid']['label'], $_SERVER["PHP_SELF"], "s.rowid", "", $param, ' data-key="id"', $sortfield, $sortorder, '');
1375  $totalarray['nbfield']++;
1376 }
1377 if (!empty($arrayfields['s.nom']['checked'])) {
1378  print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, ' data-key="ref"', $sortfield, $sortorder, ' ');
1379  $totalarray['nbfield']++;
1380 }
1381 if (!empty($arrayfields['s.name_alias']['checked'])) {
1382  print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"], "s.name_alias", "", $param, "", $sortfield, $sortorder);
1383  $totalarray['nbfield']++;
1384 }
1385 if (!empty($arrayfields['s.barcode']['checked'])) {
1386  print_liste_field_titre($arrayfields['s.barcode']['label'], $_SERVER["PHP_SELF"], "s.barcode", $param, '', '', $sortfield, $sortorder);
1387  $totalarray['nbfield']++;
1388 }
1389 if (!empty($arrayfields['s.code_client']['checked'])) {
1390  print_liste_field_titre($arrayfields['s.code_client']['label'], $_SERVER["PHP_SELF"], "s.code_client", "", $param, '', $sortfield, $sortorder);
1391  $totalarray['nbfield']++;
1392 }
1393 if (!empty($arrayfields['s.code_fournisseur']['checked'])) {
1394  print_liste_field_titre($arrayfields['s.code_fournisseur']['label'], $_SERVER["PHP_SELF"], "s.code_fournisseur", "", $param, '', $sortfield, $sortorder);
1395  $totalarray['nbfield']++;
1396 }
1397 if (!empty($arrayfields['s.code_compta']['checked'])) {
1398  print_liste_field_titre($arrayfields['s.code_compta']['label'], $_SERVER["PHP_SELF"], "s.code_compta", "", $param, '', $sortfield, $sortorder);
1399  $totalarray['nbfield']++;
1400 }
1401 if (!empty($arrayfields['s.code_compta_fournisseur']['checked'])) {
1402  print_liste_field_titre($arrayfields['s.code_compta_fournisseur']['label'], $_SERVER["PHP_SELF"], "s.code_compta_fournisseur", "", $param, '', $sortfield, $sortorder);
1403  $totalarray['nbfield']++;
1404 }
1405 if (!empty($arrayfields['s.address']['checked'])) {
1406  print_liste_field_titre($arrayfields['s.address']['label'], $_SERVER['PHP_SELF'], 's.address', '', $param, '', $sortfield, $sortorder);
1407  $totalarray['nbfield']++;
1408 }
1409 if (!empty($arrayfields['s.zip']['checked'])) {
1410  print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], "s.zip", "", $param, '', $sortfield, $sortorder);
1411  $totalarray['nbfield']++;
1412 }
1413 if (!empty($arrayfields['s.town']['checked'])) {
1414  print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], "s.town", "", $param, '', $sortfield, $sortorder);
1415  $totalarray['nbfield']++;
1416 }
1417 if (!empty($arrayfields['state.nom']['checked'])) {
1418  print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder);
1419  $totalarray['nbfield']++;
1420 }
1421 if (!empty($arrayfields['region.nom']['checked'])) {
1422  print_liste_field_titre($arrayfields['region.nom']['label'], $_SERVER["PHP_SELF"], "region.nom", "", $param, '', $sortfield, $sortorder);
1423  $totalarray['nbfield']++;
1424 }
1425 if (!empty($arrayfields['country.code_iso']['checked'])) {
1426  print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center ');
1427  $totalarray['nbfield']++;
1428 }
1429 if (!empty($arrayfields['typent.code']['checked'])) {
1430  print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, "", $sortfield, $sortorder, 'center ');
1431  $totalarray['nbfield']++;
1432 }
1433 if (!empty($arrayfields['staff.code']['checked'])) {
1434  print_liste_field_titre($arrayfields['staff.code']['label'], $_SERVER["PHP_SELF"], "staff.code", "", $param, '', $sortfield, $sortorder, 'center ');
1435  $totalarray['nbfield']++;
1436 }
1437 if (!empty($arrayfields['s.price_level']['checked'])) {
1438  print_liste_field_titre($arrayfields['s.price_level']['label'], $_SERVER["PHP_SELF"], "s.price_level", "", $param, '', $sortfield, $sortorder);
1439  $totalarray['nbfield']++;
1440 }
1441 if (!empty($arrayfields['s.email']['checked'])) {
1442  print_liste_field_titre($arrayfields['s.email']['label'], $_SERVER["PHP_SELF"], "s.email", "", $param, '', $sortfield, $sortorder);
1443  $totalarray['nbfield']++;
1444 }
1445 if (!empty($arrayfields['s.phone']['checked'])) {
1446  print_liste_field_titre($arrayfields['s.phone']['label'], $_SERVER["PHP_SELF"], "s.phone", "", $param, '', $sortfield, $sortorder);
1447  $totalarray['nbfield']++;
1448 }
1449 if (!empty($arrayfields['s.fax']['checked'])) {
1450  print_liste_field_titre($arrayfields['s.fax']['label'], $_SERVER["PHP_SELF"], "s.fax", "", $param, '', $sortfield, $sortorder);
1451  $totalarray['nbfield']++;
1452 }
1453 if (!empty($arrayfields['s.url']['checked'])) {
1454  print_liste_field_titre($arrayfields['s.url']['label'], $_SERVER["PHP_SELF"], "s.url", "", $param, '', $sortfield, $sortorder);
1455  $totalarray['nbfield']++;
1456 }
1457 if (!empty($arrayfields['s.siren']['checked'])) {
1458  print_liste_field_titre($form->textwithpicto($langs->trans("ProfId1Short"), $textprofid[1], 1, 0), $_SERVER["PHP_SELF"], "s.siren", "", $param, '', $sortfield, $sortorder, 'nowrap ');
1459  $totalarray['nbfield']++;
1460 }
1461 if (!empty($arrayfields['s.siret']['checked'])) {
1462  print_liste_field_titre($form->textwithpicto($langs->trans("ProfId2Short"), $textprofid[2], 1, 0), $_SERVER["PHP_SELF"], "s.siret", "", $param, '', $sortfield, $sortorder, 'nowrap ');
1463  $totalarray['nbfield']++;
1464 }
1465 if (!empty($arrayfields['s.ape']['checked'])) {
1466  print_liste_field_titre($form->textwithpicto($langs->trans("ProfId3Short"), $textprofid[3], 1, 0), $_SERVER["PHP_SELF"], "s.ape", "", $param, '', $sortfield, $sortorder, 'nowrap ');
1467  $totalarray['nbfield']++;
1468 }
1469 if (!empty($arrayfields['s.idprof4']['checked'])) {
1470  print_liste_field_titre($form->textwithpicto($langs->trans("ProfId4Short"), $textprofid[4], 1, 0), $_SERVER["PHP_SELF"], "s.idprof4", "", $param, '', $sortfield, $sortorder, 'nowrap ');
1471  $totalarray['nbfield']++;
1472 }
1473 if (!empty($arrayfields['s.idprof5']['checked'])) {
1474  print_liste_field_titre($form->textwithpicto($langs->trans("ProfId5Short"), $textprofid[5], 1, 0), $_SERVER["PHP_SELF"], "s.idprof5", "", $param, '', $sortfield, $sortorder, 'nowrap ');
1475  $totalarray['nbfield']++;
1476 }
1477 if (!empty($arrayfields['s.idprof6']['checked'])) {
1478  print_liste_field_titre($form->textwithpicto($langs->trans("ProfId6Short"), $textprofid[6], 1, 0), $_SERVER["PHP_SELF"], "s.idprof6", "", $param, '', $sortfield, $sortorder, 'nowrap ');
1479  $totalarray['nbfield']++;
1480 }
1481 if (!empty($arrayfields['s.tva_intra']['checked'])) {
1482  print_liste_field_titre($arrayfields['s.tva_intra']['label'], $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder, 'nowrap ');
1483  $totalarray['nbfield']++;
1484 }
1485 if (!empty($arrayfields['customerorsupplier']['checked'])) {
1486  print_liste_field_titre($arrayfields['customerorsupplier']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'center '); // type of customer
1487  $totalarray['nbfield']++;
1488 }
1489 if (!empty($arrayfields['s.fk_prospectlevel']['checked'])) {
1490  print_liste_field_titre($arrayfields['s.fk_prospectlevel']['label'], $_SERVER["PHP_SELF"], "s.fk_prospectlevel", "", $param, '', $sortfield, $sortorder, 'center ');
1491  $totalarray['nbfield']++;
1492 }
1493 if (!empty($arrayfields['s.fk_stcomm']['checked'])) {
1494  print_liste_field_titre($arrayfields['s.fk_stcomm']['label'], $_SERVER["PHP_SELF"], "s.fk_stcomm", "", $param, '', $sortfield, $sortorder, 'center ');
1495  $totalarray['nbfield']++;
1496 }
1497 if (!empty($arrayfields['s2.nom']['checked'])) {
1498  print_liste_field_titre($arrayfields['s2.nom']['label'], $_SERVER["PHP_SELF"], "s2.nom", "", $param, '', $sortfield, $sortorder, 'center ');
1499  $totalarray['nbfield']++;
1500 }
1501 // Extra fields
1502 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
1503 // Hook fields
1504 $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
1505 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1506 print $hookmanager->resPrint;
1507 if (!empty($arrayfields['s.datec']['checked'])) {
1508  print_liste_field_titre($arrayfields['s.datec']['label'], $_SERVER["PHP_SELF"], "s.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1509  $totalarray['nbfield']++; // For the column action
1510 }
1511 if (!empty($arrayfields['s.tms']['checked'])) {
1512  print_liste_field_titre($arrayfields['s.tms']['label'], $_SERVER["PHP_SELF"], "s.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1513  $totalarray['nbfield']++; // For the column action
1514 }
1515 if (!empty($arrayfields['s.status']['checked'])) {
1516  print_liste_field_titre($arrayfields['s.status']['label'], $_SERVER["PHP_SELF"], "s.status", "", $param, '', $sortfield, $sortorder, 'center ');
1517  $totalarray['nbfield']++; // For the column action
1518 }
1519 if (!empty($arrayfields['s.import_key']['checked'])) {
1520  print_liste_field_titre($arrayfields['s.import_key']['label'], $_SERVER["PHP_SELF"], "s.import_key", "", $param, '', $sortfield, $sortorder, 'center ');
1521  $totalarray['nbfield']++; // For the column action
1522 }
1523 // Action column
1524 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1525  print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
1526  $totalarray['nbfield']++;
1527 }
1528 print '</tr>'."\n";
1529 
1530 
1531 // Loop on record
1532 // --------------------------------------------------------------------
1533 $i = 0;
1534 $savnbfield = $totalarray['nbfield'];
1535 $totalarray = array();
1536 $totalarray['nbfield'] = 0;
1537 $imaxinloop = ($limit ? min($num, $limit) : $num);
1538 while ($i < $imaxinloop) {
1539  $obj = $db->fetch_object($resql);
1540  if (empty($obj)) {
1541  break; // Should not happen
1542  }
1543 
1544  $parameters = array('staticdata' => $obj);
1545  // Note that $action and $object may have been modified by hook
1546  // do companystatic fetch in hook if wanted or anything else
1547  $reshook = $hookmanager->executeHooks('loadStaticObject', $parameters, $companystatic, $action);
1548  if (empty($reshook)) {
1549  $companystatic->id = $obj->rowid;
1550  $companystatic->name = $obj->name;
1551  $companystatic->name_alias = $obj->name_alias;
1552  $companystatic->logo = $obj->logo;
1553  $companystatic->barcode = $obj->barcode;
1554  $companystatic->canvas = $obj->canvas;
1555  $companystatic->client = $obj->client;
1556  $companystatic->status = $obj->status;
1557  $companystatic->email = $obj->email;
1558  $companystatic->address = $obj->address;
1559  $companystatic->zip = $obj->zip;
1560  $companystatic->town = $obj->town;
1561  $companystatic->fournisseur = $obj->fournisseur;
1562  $companystatic->code_client = $obj->code_client;
1563  $companystatic->code_fournisseur = $obj->code_fournisseur;
1564  $companystatic->tva_intra = $obj->tva_intra;
1565  $companystatic->country_code = $obj->country_code;
1566 
1567  $companystatic->code_compta_client = $obj->code_compta;
1568  $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
1569 
1570  $companystatic->fk_prospectlevel = $obj->fk_prospectlevel;
1571  $companystatic->fk_parent = $obj->fk_parent;
1572  $companystatic->entity = $obj->entity;
1573  }
1574 
1575  if ($mode == 'kanban') {
1576  if ($i == 0) {
1577  print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
1578  print '<div class="box-flex-container kanban">';
1579  }
1580  // Output Kanban
1581  print $companystatic->getKanbanView('', array('selected' => in_array($obj->rowid, $arrayofselected)));
1582  if ($i == ($imaxinloop - 1)) {
1583  print '</div>';
1584  print '</td></tr>';
1585  }
1586  } else {
1587  // Show line of result
1588  $j = 0;
1589  print '<tr data-rowid="'.$object->id.'" class="oddeven"';
1590  if ($contextpage == 'poslist') {
1591  print ' onclick="location.href=\'list.php?action=change&contextpage=poslist&idcustomer='.$obj->rowid.'&place='.urlencode($place).'\'"';
1592  }
1593  print '>';
1594 
1595  // Action column (Show the massaction button only when this page is not opend from the Extended POS)
1596  if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1597  print '<td class="nowrap center actioncolumn">';
1598  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
1599  $selected = 0;
1600  if (in_array($obj->rowid, $arrayofselected)) {
1601  $selected = 1;
1602  }
1603  print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
1604  }
1605  print '</td>';
1606  if (!$i) {
1607  $totalarray['nbfield']++;
1608  }
1609  }
1610  if (!empty($arrayfields['s.rowid']['checked'])) {
1611  print '<td class="tdoverflowmax50" data-key="id">';
1612  print $obj->rowid;
1613  print "</td>\n";
1614  if (!$i) {
1615  $totalarray['nbfield']++;
1616  }
1617  }
1618  if (!empty($arrayfields['s.nom']['checked'])) {
1619  print '<td'.(empty($conf->global->MAIN_SOCIETE_SHOW_COMPLETE_NAME) ? ' class="tdoverflowmax200"' : '').' data-key="ref">';
1620  if ($contextpage == 'poslist') {
1621  print dol_escape_htmltag($companystatic->name);
1622  } else {
1623  print $companystatic->getNomUrl(1, '', 100, 0, 1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1);
1624  }
1625  print "</td>\n";
1626  if (!$i) {
1627  $totalarray['nbfield']++;
1628  }
1629  }
1630  if (!empty($arrayfields['s.name_alias']['checked'])) {
1631  print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($companystatic->name_alias).'">';
1632  print dol_escape_htmltag($companystatic->name_alias);
1633  print "</td>\n";
1634  if (!$i) {
1635  $totalarray['nbfield']++;
1636  }
1637  }
1638  // Barcode
1639  if (!empty($arrayfields['s.barcode']['checked'])) {
1640  print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($companystatic->barcode).'">'.dol_escape_htmltag($companystatic->barcode).'</td>';
1641  if (!$i) {
1642  $totalarray['nbfield']++;
1643  }
1644  }
1645  // Customer code
1646  if (!empty($arrayfields['s.code_client']['checked'])) {
1647  print '<td class="nowraponall">'.dol_escape_htmltag($companystatic->code_client).'</td>';
1648  if (!$i) {
1649  $totalarray['nbfield']++;
1650  }
1651  }
1652  // Supplier code
1653  if (!empty($arrayfields['s.code_fournisseur']['checked'])) {
1654  print '<td class="nowraponall">'.dol_escape_htmltag($companystatic->code_fournisseur).'</td>';
1655  if (!$i) {
1656  $totalarray['nbfield']++;
1657  }
1658  }
1659  // Account customer code
1660  if (!empty($arrayfields['s.code_compta']['checked'])) {
1661  print '<td>'.dol_escape_htmltag($companystatic->code_compta_client).'</td>';
1662  if (!$i) {
1663  $totalarray['nbfield']++;
1664  }
1665  }
1666  // Account supplier code
1667  if (!empty($arrayfields['s.code_compta_fournisseur']['checked'])) {
1668  print '<td>'.dol_escape_htmltag($companystatic->code_compta_fournisseur).'</td>';
1669  if (!$i) {
1670  $totalarray['nbfield']++;
1671  }
1672  }
1673  // Address
1674  if (!empty($arrayfields['s.address']['checked'])) {
1675  print '<td class="tdoverflowmax250" title="'.dol_escape_htmltag($companystatic->address).'">'.dol_escape_htmltag($companystatic->address).'</td>';
1676  if (!$i) {
1677  $totalarray['nbfield']++;
1678  }
1679  }
1680  // Zip
1681  if (!empty($arrayfields['s.zip']['checked'])) {
1682  print "<td>".dol_escape_htmltag($companystatic->zip)."</td>\n";
1683  if (!$i) {
1684  $totalarray['nbfield']++;
1685  }
1686  }
1687  // Town
1688  if (!empty($arrayfields['s.town']['checked'])) {
1689  print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($companystatic->town).'">'.dol_escape_htmltag($companystatic->town)."</td>\n";
1690  if (!$i) {
1691  $totalarray['nbfield']++;
1692  }
1693  }
1694  // State
1695  if (!empty($arrayfields['state.nom']['checked'])) {
1696  print "<td>".dol_escape_htmltag($obj->state_name)."</td>\n";
1697  if (!$i) {
1698  $totalarray['nbfield']++;
1699  }
1700  }
1701  // Region
1702  if (!empty($arrayfields['region.nom']['checked'])) {
1703  print "<td>".dol_escape_htmltag($obj->region_name)."</td>\n";
1704  if (!$i) {
1705  $totalarray['nbfield']++;
1706  }
1707  }
1708  // Country
1709  if (!empty($arrayfields['country.code_iso']['checked'])) {
1710  print '<td class="center tdoverflowmax100">';
1711  $labelcountry = ($companystatic->country_code && ($langs->trans("Country".$companystatic->country_code) != "Country".$companystatic->country_code)) ? $langs->trans("Country".$companystatic->country_code) : $obj->country_label;
1712  print $labelcountry;
1713  print '</td>';
1714  if (!$i) {
1715  $totalarray['nbfield']++;
1716  }
1717  }
1718  // Type ent
1719  if (!empty($arrayfields['typent.code']['checked'])) {
1720  if (!isset($typenArray) || !is_array($typenArray) || count($typenArray) == 0) {
1721  $typenArray = $formcompany->typent_array(1);
1722  }
1723  $labeltypeofcompany= empty($typenArray[$obj->typent_code]) ? '' : $typenArray[$obj->typent_code];
1724 
1725  print '<td class="center tdoverflowmax125" title="'.dol_escape_htmltag($labeltypeofcompany).'">';
1726  print dol_escape_htmltag($labeltypeofcompany);
1727  print '</td>';
1728  if (!$i) {
1729  $totalarray['nbfield']++;
1730  }
1731  }
1732  // Multiprice level
1733  if (!empty($arrayfields['s.price_level']['checked'])) {
1734  print '<td class="center">'.$obj->price_level."</td>\n";
1735  if (!$i) {
1736  $totalarray['nbfield']++;
1737  }
1738  }
1739  // Staff
1740  if (!empty($arrayfields['staff.code']['checked'])) {
1741  print '<td class="center">';
1742  if (!empty($obj->staff_code)) {
1743  if (empty($conf->cache['staffArray'])) {
1744  $conf->cache['staffArray'] = $formcompany->effectif_array(1);
1745  }
1746  print $conf->cache['staffArray'][$obj->staff_code];
1747  }
1748  print '</td>';
1749  if (!$i) {
1750  $totalarray['nbfield']++;
1751  }
1752  }
1753  if (!empty($arrayfields['s.email']['checked'])) {
1754  print '<td class="tdoverflowmax150">'.dol_print_email($obj->email, $obj->rowid, $obj->rowid, 'AC_EMAIL', 0, 0, 1)."</td>\n";
1755  if (!$i) {
1756  $totalarray['nbfield']++;
1757  }
1758  }
1759  if (!empty($arrayfields['s.phone']['checked'])) {
1760  print '<td class="nowraponall">'.dol_print_phone($obj->phone, $companystatic->country_code, 0, $obj->rowid, 'AC_TEL', ' ', 'phone')."</td>\n";
1761  if (!$i) {
1762  $totalarray['nbfield']++;
1763  }
1764  }
1765  if (!empty($arrayfields['s.fax']['checked'])) {
1766  print '<td class="nowraponall">'.dol_print_phone($obj->fax, $companystatic->country_code, 0, $obj->rowid, 'AC_TEL', ' ', 'fax')."</td>\n";
1767  if (!$i) {
1768  $totalarray['nbfield']++;
1769  }
1770  }
1771  if (!empty($arrayfields['s.url']['checked'])) {
1772  print "<td>".dol_print_url($obj->url, '', '', 1)."</td>\n";
1773  if (!$i) {
1774  $totalarray['nbfield']++;
1775  }
1776  }
1777  if (!empty($arrayfields['s.siren']['checked'])) {
1778  print "<td>".$obj->idprof1."</td>\n";
1779  if (!$i) {
1780  $totalarray['nbfield']++;
1781  }
1782  }
1783  if (!empty($arrayfields['s.siret']['checked'])) {
1784  print "<td>".$obj->idprof2."</td>\n";
1785  if (!$i) {
1786  $totalarray['nbfield']++;
1787  }
1788  }
1789  if (!empty($arrayfields['s.ape']['checked'])) {
1790  print "<td>".$obj->idprof3."</td>\n";
1791  if (!$i) {
1792  $totalarray['nbfield']++;
1793  }
1794  }
1795  if (!empty($arrayfields['s.idprof4']['checked'])) {
1796  print "<td>".$obj->idprof4."</td>\n";
1797  if (!$i) {
1798  $totalarray['nbfield']++;
1799  }
1800  }
1801  if (!empty($arrayfields['s.idprof5']['checked'])) {
1802  print "<td>".$obj->idprof5."</td>\n";
1803  if (!$i) {
1804  $totalarray['nbfield']++;
1805  }
1806  }
1807  if (!empty($arrayfields['s.idprof6']['checked'])) {
1808  print "<td>".$obj->idprof6."</td>\n";
1809  if (!$i) {
1810  $totalarray['nbfield']++;
1811  }
1812  }
1813  // VAT
1814  if (!empty($arrayfields['s.tva_intra']['checked'])) {
1815  print '<td class="tdoverflowmax125" title="'.dol_escape_htmltag($companystatic->tva_intra).'">';
1816  if ($companystatic->tva_intra && !isValidVATID($companystatic)) {
1817  print img_warning("BadVATNumber", '', 'pictofixedwidth');
1818  }
1819  print $companystatic->tva_intra;
1820  print "</td>\n";
1821  if (!$i) {
1822  $totalarray['nbfield']++;
1823  }
1824  }
1825  // Type
1826  if (!empty($arrayfields['customerorsupplier']['checked'])) {
1827  print '<td class="center">';
1828  print $companystatic->getTypeUrl(1);
1829  print '</td>';
1830  if (!$i) {
1831  $totalarray['nbfield']++;
1832  }
1833  }
1834 
1835  if (!empty($arrayfields['s.fk_prospectlevel']['checked'])) {
1836  // Prospect level
1837  print '<td class="center nowraponall">';
1838  print $companystatic->getLibProspLevel();
1839  print "</td>";
1840  if (!$i) {
1841  $totalarray['nbfield']++;
1842  }
1843  }
1844 
1845  if (!empty($arrayfields['s.fk_stcomm']['checked'])) {
1846  // Prospect status
1847  print '<td class="center nowraponall">';
1848 
1849  $prospectid = $obj->rowid;
1850  $statusprospect = $obj->stcomm_id;
1851 
1852  $formcompany->selectProspectStatus('status_prospect', $prospectstatic, $statusprospect, $prospectid);
1853 
1854  print '</td>';
1855  if (!$i) {
1856  $totalarray['nbfield']++;
1857  }
1858  }
1859  // Parent company
1860  if (!empty($arrayfields['s2.nom']['checked'])) {
1861  print '<td class="center tdoverflowmax100">';
1862  if ($companystatic->fk_parent > 0) {
1863  $companyparent->fetch($companystatic->fk_parent);
1864  print $companyparent->getNomUrl(1);
1865  }
1866  print "</td>";
1867  if (!$i) {
1868  $totalarray['nbfield']++;
1869  }
1870  }
1871  // Extra fields
1872  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1873  // Fields from hook
1874  $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
1875  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1876  print $hookmanager->resPrint;
1877  // Date creation
1878  if (!empty($arrayfields['s.datec']['checked'])) {
1879  print '<td class="center nowraponall">';
1880  print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
1881  print '</td>';
1882  if (!$i) {
1883  $totalarray['nbfield']++;
1884  }
1885  }
1886  // Date modification
1887  if (!empty($arrayfields['s.tms']['checked'])) {
1888  print '<td class="center nowraponall">';
1889  print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
1890  print '</td>';
1891  if (!$i) {
1892  $totalarray['nbfield']++;
1893  }
1894  }
1895  // Status
1896  if (!empty($arrayfields['s.status']['checked'])) {
1897  print '<td class="center nowraponall">'.$companystatic->getLibStatut(5).'</td>';
1898  if (!$i) {
1899  $totalarray['nbfield']++;
1900  }
1901  }
1902  // Import key
1903  if (!empty($arrayfields['s.import_key']['checked'])) {
1904  print '<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->import_key).'">';
1905  print dol_escape_htmltag($obj->import_key);
1906  print "</td>\n";
1907  if (!$i) {
1908  $totalarray['nbfield']++;
1909  }
1910  }
1911  // Action column (Show the massaction button only when this page is not opend from the Extended POS)
1912  if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1913  print '<td class="nowrap center actioncolumn">';
1914  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
1915  $selected = 0;
1916  if (in_array($obj->rowid, $arrayofselected)) {
1917  $selected = 1;
1918  }
1919  print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
1920  }
1921  print '</td>';
1922  if (!$i) {
1923  $totalarray['nbfield']++;
1924  }
1925  }
1926 
1927  print '</tr>'."\n";
1928  }
1929  $i++;
1930 }
1931 
1932 // Line that calls the select_status function by passing it js as the 5th parameter in order to activate the js script
1933 $formcompany->selectProspectStatus('status_prospect', $prospectstatic, null, null, "js");
1934 
1935 // If no record found
1936 if ($num == 0) {
1937  $colspan = 1;
1938  foreach ($arrayfields as $key => $val) {
1939  if (!empty($val['checked'])) {
1940  $colspan++;
1941  }
1942  }
1943  print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
1944 }
1945 
1946 $db->free($resql);
1947 
1948 $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
1949 $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1950 print $hookmanager->resPrint;
1951 
1952 print '</table>'."\n";
1953 print '</div>'."\n";
1954 
1955 print '</form>'."\n";
1956 
1957 // End of page
1958 llxFooter();
1959 $db->close();
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
Definition: agenda.php:118
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...)
if(isModEnabled('facture') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $sql
Social contributions to pay.
Definition: index.php:746
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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.