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