dolibarr  17.0.4
list.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2019 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2005-2019 Regis Houssin <regis.houssin@inodbox.com>
5  * Copyright (C) 2012 Marcos García <marcosgdf@gmail.com>
6  * Copyright (C) 2013-2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
7  * Copyright (C) 2015 Florian Henry <florian.henry@open-concept.pro>
8  * Copyright (C) 2016-2018 Josep Lluis Amador <joseplluis@lliuretic.cat>
9  * Copyright (C) 2016 Ferran Marcet <fmarcet@2byte.es>
10  * Copyright (C) 2017 Rui Strecht <rui.strecht@aliartalentos.com>
11  * Copyright (C) 2017 Juanjo Menent <jmenent@2byte.es>
12  * Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
13  * Copyright (C) 2020 Open-Dsi <support@open-dsi.fr>
14  * Copyright (C) 2021 Frédéric France <frederic.france@netlogic.fr>
15  * Copyright (C) 2022 Anthony Berton <anthony.berton@bb2a.fr>
16  *
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");
106 $search_stcomm = GETPOST('search_stcomm', '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'=>"Workforce", '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_level) {
709  $sql .= natural_search("s.fk_prospectlevel", join(',', $search_level), 3);
710 }
711 if ($search_parent_name) {
712  $sql .= natural_search("s2.nom", $search_parent_name);
713 }
714 if ($search_stcomm != '' && $search_stcomm != '-2') { // -2 is not filter
715  $sql .= natural_search("s.fk_stcomm", $search_stcomm, 1);
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 ($obj->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 (is_array($search_level) && count($search_level)) {
900  foreach ($search_level as $slevel) {
901  $param .= '&search_level[]='.urlencode($slevel);
902  }
903 }
904 if ($search_status != '') {
905  $param .= '&search_status='.urlencode($search_status);
906 }
907 if ($search_stcomm != '' && $search_stcomm != '-2') { // -2 is no filter
908  $param .= '&search_stcomm='.urlencode($search_stcomm);
909 }
910 if ($search_parent_name != '') {
911  $param .= '&search_parent_name='.urlencode($search_parent_name);
912 }
913 if ($search_import_key != '') {
914  $param .= '&search_import_key='.urlencode($search_import_key);
915 }
916 if ($type != '') {
917  $param .= '&type='.urlencode($type);
918 }
919 if ($optioncss != '') {
920  $param .= '&optioncss='.urlencode($optioncss);
921 }
922 // Add $param from extra fields
923 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
924 
925 // Show delete result message
926 if (GETPOST('delsoc')) {
927  setEventMessages($langs->trans("CompanyDeleted", GETPOST('delsoc')), null, 'mesgs');
928 }
929 
930 // List of mass actions available
931 $arrayofmassactions = array(
932  'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
933  //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
934 );
935 //if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer");
936 if (isModEnabled('category') && $user->hasRight("societe", "creer")) {
937  $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag");
938 }
939 if ($user->hasRight("societe", "creer")) {
940  $arrayofmassactions['preenable'] = img_picto('', 'stop-circle', 'class="pictofixedwidth"').$langs->trans("SetToStatus", $object->LibStatut($object::STATUS_INACTIVITY));
941 }
942 if ($user->hasRight("societe", "creer")) {
943  $arrayofmassactions['predisable'] = img_picto('', 'stop-circle', 'class="pictofixedwidth"').$langs->trans("SetToStatus", $object->LibStatut($object::STATUS_CEASED));
944 }
945 if ($user->hasRight("societe", "creer")) {
946  $arrayofmassactions['presetcommercial'] = img_picto('', 'user', 'class="pictofixedwidth"').$langs->trans("AllocateCommercial");
947 }
948 if ($user->hasRight('societe', 'supprimer')) {
949  $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
950 }
951 if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete', 'preaffecttag', 'preenable', 'preclose'))) {
952  $arrayofmassactions = array();
953 }
954 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
955 
956 $typefilter = '';
957 $label = 'MenuNewThirdParty';
958 
959 if (!empty($type)) {
960  $typefilter = '&amp;type='.$type;
961  if ($type == 'p') {
962  $label = 'MenuNewProspect';
963  }
964  if ($type == 'c') {
965  $label = 'MenuNewCustomer';
966  }
967  if ($type == 'f') {
968  $label = 'NewSupplier';
969  }
970 }
971 
972 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))) {
973  print get_htmloutput_mesg(img_warning('default').' '.$langs->trans("BecarefullChangeThirdpartyBeforeAddProductToInvoice"), '', 'warning', 1);
974 }
975 
976 // Show the new button only when this page is not opend from the Extended POS (pop-up window)
977 // but allow it too, when a user has the rights to create a new customer
978 if ($contextpage != 'poslist') {
979  $url = DOL_URL_ROOT.'/societe/card.php?action=create'.$typefilter;
980  if (!empty($socid)) {
981  $url .= '&socid='.$socid;
982  }
983  $newcardbutton = dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', $url, '', $user->hasRight("societe", "creer"));
984 } elseif ($user->hasRight("societe", "creer")) {
985  $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);
986  $label = 'MenuNewCustomer';
987  $newcardbutton = dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', $url);
988 }
989 
990 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'" name="formfilter" autocomplete="off">';
991 if ($optioncss != '') {
992  print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
993 }
994 print '<input type="hidden" name="token" value="'.newToken().'">';
995 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
996 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
997 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
998 //print '<input type="hidden" name="page" value="'.$page.'">';
999 print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
1000 if (!empty($place)) {
1001  print '<input type="hidden" name="place" value="'.$place.'">';
1002 }
1003 
1004 print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'building', 0, $newcardbutton, '', $limit, 0, 0, 1);
1005 
1006 $langs->load("other");
1007 $textprofid = array();
1008 foreach (array(1, 2, 3, 4, 5, 6) as $key) {
1009  $label = $langs->transnoentities("ProfId".$key.$mysoc->country_code);
1010  $textprofid[$key] = '';
1011  if ($label != "ProfId".$key.$mysoc->country_code) { // Get only text between ()
1012  if (preg_match('/\‍((.*)\‍)/i', $label, $reg)) {
1013  $label = $reg[1];
1014  }
1015  $textprofid[$key] = $langs->trans("ProfIdShortDesc", $key, $mysoc->country_code, $label);
1016  }
1017 }
1018 
1019 // Add code for pre mass action (confirmation or email presend form)
1020 $topicmail = "Information";
1021 $modelmail = "thirdparty";
1022 $objecttmp = new Societe($db);
1023 $trackid = 'thi'.$object->id;
1024 include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
1025 
1026 if ($search_all) {
1027  foreach ($fieldstosearchall as $key => $val) {
1028  $fieldstosearchall[$key] = $langs->trans($val);
1029  }
1030  print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>';
1031 }
1032 
1033 // Filter on categories
1034 $moreforfilter = '';
1035 if (empty($type) || $type == 'c' || $type == 'p') {
1036  if (isModEnabled('categorie') && $user->hasRight("categorie", "lire")) {
1037  require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
1038  $moreforfilter .= '<div class="divsearchfield">';
1039  $tmptitle = $langs->trans('Categories');
1040  $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"');
1041  $moreforfilter .= $formother->select_categories('customer', $search_categ_cus, 'search_categ_cus', 1, $langs->trans('CustomersProspectsCategoriesShort'));
1042  $moreforfilter .= '</div>';
1043  }
1044 }
1045 
1046 if (empty($type) || $type == 'f') {
1047  if (isModEnabled("fournisseur") && isModEnabled('categorie') && $user->hasRight("categorie", "lire")) {
1048  require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
1049  $moreforfilter .= '<div class="divsearchfield">';
1050  $tmptitle = $langs->trans('Categories');
1051  $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"');
1052  $moreforfilter .= $formother->select_categories('supplier', $search_categ_sup, 'search_categ_sup', 1, $langs->trans('SuppliersCategoriesShort'));
1053  $moreforfilter .= '</div>';
1054  }
1055 }
1056 
1057 // If the user can view prospects other than his'
1058 if ($user->hasRight("societe", "client", "voir") || $socid) {
1059  $moreforfilter .= '<div class="divsearchfield">';
1060  $tmptitle = $langs->trans('SalesRepresentatives');
1061  $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"');
1062  $moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $langs->trans('SalesRepresentatives'), ($conf->dol_optimize_smallscreen ? 'maxwidth200' : 'maxwidth300'), 1);
1063  $moreforfilter .= '</div>';
1064 }
1065 if ($moreforfilter) {
1066  print '<div class="liste_titre liste_titre_bydiv centpercent">';
1067  print $moreforfilter;
1068  $parameters = array('type'=>$type);
1069  $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1070  print $hookmanager->resPrint;
1071  print '</div>';
1072 }
1073 
1074 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
1075 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields
1076 // Show the massaction checkboxes only when this page is not opend from the Extended POS
1077 if ($massactionbutton && $contextpage != 'poslist') {
1078  $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
1079 }
1080 
1081 if (empty($arrayfields['customerorsupplier']['checked'])) {
1082  print '<input type="hidden" name="type" value="'.$type.'">';
1083 }
1084 
1085 print '<div class="div-table-responsive">';
1086 print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
1087 
1088 // Fields title search
1089 print '<tr class="liste_titre_filter">';
1090 if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
1091  // Action column
1092  print '<td class="liste_titre center actioncolumn">';
1093  $searchpicto = $form->showFilterButtons('left');
1094  print $searchpicto;
1095  print '</td>';
1096 }
1097 if (!empty($arrayfields['s.rowid']['checked'])) {
1098  print '<td class="liste_titre" data-key="id">';
1099  print '<input class="flat searchstring" type="text" name="search_id" size="1" value="'.dol_escape_htmltag($search_id).'">';
1100  print '</td>';
1101 }
1102 if (!empty($arrayfields['s.nom']['checked'])) {
1103  print '<td class="liste_titre" data-key="ref">';
1104  if (!empty($search_nom_only) && empty($search_nom)) {
1105  $search_nom = $search_nom_only;
1106  }
1107  print '<input class="flat searchstring maxwidth75imp" type="text" name="search_nom" value="'.dol_escape_htmltag($search_nom).'">';
1108  print '</td>';
1109 }
1110 if (!empty($arrayfields['s.name_alias']['checked'])) {
1111  print '<td class="liste_titre">';
1112  print '<input class="flat searchstring maxwidth75imp" type="text" name="search_alias" value="'.dol_escape_htmltag($search_alias).'">';
1113  print '</td>';
1114 }
1115 // Barcode
1116 if (!empty($arrayfields['s.barcode']['checked'])) {
1117  print '<td class="liste_titre">';
1118  print '<input class="flat searchstring maxwidth75imp" type="text" name="search_barcode" value="'.dol_escape_htmltag($search_barcode).'">';
1119  print '</td>';
1120 }
1121 // Customer code
1122 if (!empty($arrayfields['s.code_client']['checked'])) {
1123  print '<td class="liste_titre">';
1124  print '<input class="flat searchstring maxwidth75imp" type="text" name="search_customer_code" value="'.dol_escape_htmltag($search_customer_code).'">';
1125  print '</td>';
1126 }
1127 // Supplier code
1128 if (!empty($arrayfields['s.code_fournisseur']['checked'])) {
1129  print '<td class="liste_titre">';
1130  print '<input class="flat searchstring maxwidth75imp" type="text" name="search_supplier_code" value="'.dol_escape_htmltag($search_supplier_code).'">';
1131  print '</td>';
1132 }
1133 // Account Customer code
1134 if (!empty($arrayfields['s.code_compta']['checked'])) {
1135  print '<td class="liste_titre">';
1136  print '<input class="flat searchstring maxwidth75imp" type="text" name="search_account_customer_code" value="'.dol_escape_htmltag($search_account_customer_code).'">';
1137  print '</td>';
1138 }
1139 // Account Supplier code
1140 if (!empty($arrayfields['s.code_compta_fournisseur']['checked'])) {
1141  print '<td class="liste_titre">';
1142  print '<input class="flat maxwidth75imp" type="text" name="search_account_supplier_code" value="'.dol_escape_htmltag($search_account_supplier_code).'">';
1143  print '</td>';
1144 }
1145 // Address
1146 if (!empty($arrayfields['s.address']['checked'])) {
1147  print '<td class="liste_titre">';
1148  print '<input class="flat searchstring maxwidth50imp" type="text" name="search_address" value="'.dol_escape_htmltag($search_address).'">';
1149  print '</td>';
1150 }
1151 // Zip
1152 if (!empty($arrayfields['s.zip']['checked'])) {
1153  print '<td class="liste_titre">';
1154  print '<input class="flat searchstring maxwidth50imp" type="text" name="search_zip" value="'.dol_escape_htmltag($search_zip).'">';
1155  print '</td>';
1156 }
1157 // Town
1158 if (!empty($arrayfields['s.town']['checked'])) {
1159  print '<td class="liste_titre">';
1160  print '<input class="flat searchstring maxwidth50imp" type="text" name="search_town" value="'.dol_escape_htmltag($search_town).'">';
1161  print '</td>';
1162 }
1163 // State
1164 if (!empty($arrayfields['state.nom']['checked'])) {
1165  print '<td class="liste_titre">';
1166  print '<input class="flat searchstring maxwidth50imp" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
1167  print '</td>';
1168 }
1169 // Region
1170 if (!empty($arrayfields['region.nom']['checked'])) {
1171  print '<td class="liste_titre">';
1172  print '<input class="flat searchstring maxwidth50imp" type="text" name="search_region" value="'.dol_escape_htmltag($search_region).'">';
1173  print '</td>';
1174 }
1175 // Country
1176 if (!empty($arrayfields['country.code_iso']['checked'])) {
1177  print '<td class="liste_titre center">';
1178  print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100');
1179  print '</td>';
1180 }
1181 // Company type
1182 if (!empty($arrayfields['typent.code']['checked'])) {
1183  print '<td class="liste_titre maxwidthonsmartphone center">';
1184  // We use showempty=0 here because there is already an unknown value into dictionary.
1185  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);
1186  print '</td>';
1187 }
1188 // Multiprice level
1189 if (!empty($arrayfields['s.price_level']['checked'])) {
1190  print '<td class="liste_titre">';
1191  print '<input class="flat searchstring maxwidth50imp" type="text" name="search_price_level" value="'.dol_escape_htmltag($search_price_level).'">';
1192  print '</td>';
1193 }
1194 // Staff
1195 if (!empty($arrayfields['staff.code']['checked'])) {
1196  print '<td class="liste_titre maxwidthonsmartphone center">';
1197  print $form->selectarray("search_staff", $formcompany->effectif_array(0), $search_staff, 0, 0, 0, '', 0, 0, 0, 'ASC', 'maxwidth100', 1);
1198  print '</td>';
1199 }
1200 if (!empty($arrayfields['s.email']['checked'])) {
1201  // Email
1202  print '<td class="liste_titre">';
1203  print '<input class="flat searchemail maxwidth50imp" type="text" name="search_email" value="'.dol_escape_htmltag($search_email).'">';
1204  print '</td>';
1205 }
1206 if (!empty($arrayfields['s.phone']['checked'])) {
1207  // Phone
1208  print '<td class="liste_titre">';
1209  print '<input class="flat searchstring maxwidth50imp" type="text" name="search_phone" value="'.dol_escape_htmltag($search_phone).'">';
1210  print '</td>';
1211 }
1212 if (!empty($arrayfields['s.fax']['checked'])) {
1213  // Fax
1214  print '<td class="liste_titre">';
1215  print '<input class="flat searchstring maxwidth50imp" type="text" name="search_fax" value="'.dol_escape_htmltag($search_fax).'">';
1216  print '</td>';
1217 }
1218 if (!empty($arrayfields['s.url']['checked'])) {
1219  // Url
1220  print '<td class="liste_titre">';
1221  print '<input class="flat searchstring maxwidth50imp" type="text" name="search_url" value="'.dol_escape_htmltag($search_url).'">';
1222  print '</td>';
1223 }
1224 if (!empty($arrayfields['s.siren']['checked'])) {
1225  // IdProf1
1226  print '<td class="liste_titre">';
1227  print '<input class="flat searchstring maxwidth50imp" type="text" name="search_idprof1" value="'.dol_escape_htmltag($search_idprof1).'">';
1228  print '</td>';
1229 }
1230 if (!empty($arrayfields['s.siret']['checked'])) {
1231  // IdProf2
1232  print '<td class="liste_titre">';
1233  print '<input class="flat searchstring maxwidth50imp" type="text" name="search_idprof2" value="'.dol_escape_htmltag($search_idprof2).'">';
1234  print '</td>';
1235 }
1236 if (!empty($arrayfields['s.ape']['checked'])) {
1237  // IdProf3
1238  print '<td class="liste_titre">';
1239  print '<input class="flat searchstring maxwidth50imp" type="text" name="search_idprof3" value="'.dol_escape_htmltag($search_idprof3).'">';
1240  print '</td>';
1241 }
1242 if (!empty($arrayfields['s.idprof4']['checked'])) {
1243  // IdProf4
1244  print '<td class="liste_titre">';
1245  print '<input class="flat searchstring maxwidth50imp" type="text" name="search_idprof4" value="'.dol_escape_htmltag($search_idprof4).'">';
1246  print '</td>';
1247 }
1248 if (!empty($arrayfields['s.idprof5']['checked'])) {
1249  // IdProf5
1250  print '<td class="liste_titre">';
1251  print '<input class="flat searchstring maxwidth50imp" type="text" name="search_idprof5" value="'.dol_escape_htmltag($search_idprof5).'">';
1252  print '</td>';
1253 }
1254 if (!empty($arrayfields['s.idprof6']['checked'])) {
1255  // IdProf6
1256  print '<td class="liste_titre">';
1257  print '<input class="flat searchstring maxwidth50imp" type="text" name="search_idprof6" value="'.dol_escape_htmltag($search_idprof6).'">';
1258  print '</td>';
1259 }
1260 if (!empty($arrayfields['s.tva_intra']['checked'])) {
1261  // Vat number
1262  print '<td class="liste_titre">';
1263  print '<input class="flat searchstring maxwidth50imp" type="text" name="search_vat" value="'.dol_escape_htmltag($search_vat).'">';
1264  print '</td>';
1265 }
1266 
1267 // Nature (customer/prospect/supplier)
1268 if (!empty($arrayfields['customerorsupplier']['checked'])) {
1269  print '<td class="liste_titre maxwidthonsmartphone center">';
1270  if ($type != '') {
1271  print '<input type="hidden" name="type" value="'.$type.'">';
1272  }
1273  print $formcompany->selectProspectCustomerType($search_type, 'search_type', 'search_type', 'list');
1274  print '</td>';
1275 }
1276 // Prospect level
1277 if (!empty($arrayfields['s.fk_prospectlevel']['checked'])) {
1278  print '<td class="liste_titre center">';
1279  print $form->multiselectarray('search_level', $tab_level, $search_level, 0, 0, 'width75', 0, 0, '', '', '', 2);
1280  print '</td>';
1281 }
1282 // Prospect status
1283 if (!empty($arrayfields['s.fk_stcomm']['checked'])) {
1284  print '<td class="liste_titre maxwidthonsmartphone center">';
1285  $arraystcomm = array();
1286  foreach ($prospectstatic->cacheprospectstatus as $key => $val) {
1287  $arraystcomm[$val['id']] = ($langs->trans("StatusProspect".$val['id']) != "StatusProspect".$val['id'] ? $langs->trans("StatusProspect".$val['id']) : $val['label']);
1288  }
1289  print $form->selectarray('search_stcomm', $arraystcomm, $search_stcomm, -2, 0, 0, '', 0, 0, 0, '', '', 1);
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 (!empty($obj->staff_code)) {
1648  if (empty($conf->cache['staffArray'])) {
1649  $conf->cache['staffArray'] = $formcompany->effectif_array(1);
1650  }
1651  print $conf->cache['staffArray'][$obj->staff_code];
1652  }
1653  print '</td>';
1654  if (!$i) {
1655  $totalarray['nbfield']++;
1656  }
1657  }
1658  if (!empty($arrayfields['s.email']['checked'])) {
1659  print '<td class="tdoverflowmax150">'.dol_print_email($obj->email, $obj->rowid, $obj->rowid, 'AC_EMAIL', 0, 0, 1)."</td>\n";
1660  if (!$i) {
1661  $totalarray['nbfield']++;
1662  }
1663  }
1664  if (!empty($arrayfields['s.phone']['checked'])) {
1665  print '<td class="nowraponall">'.dol_print_phone($obj->phone, $companystatic->country_code, 0, $obj->rowid, 'AC_TEL', ' ', 'phone')."</td>\n";
1666  if (!$i) {
1667  $totalarray['nbfield']++;
1668  }
1669  }
1670  if (!empty($arrayfields['s.fax']['checked'])) {
1671  print '<td class="nowraponall">'.dol_print_phone($obj->fax, $companystatic->country_code, 0, $obj->rowid, 'AC_TEL', ' ', 'fax')."</td>\n";
1672  if (!$i) {
1673  $totalarray['nbfield']++;
1674  }
1675  }
1676  if (!empty($arrayfields['s.url']['checked'])) {
1677  print "<td>".dol_print_url($obj->url, '', '', 1)."</td>\n";
1678  if (!$i) {
1679  $totalarray['nbfield']++;
1680  }
1681  }
1682  if (!empty($arrayfields['s.siren']['checked'])) {
1683  print "<td>".$obj->idprof1."</td>\n";
1684  if (!$i) {
1685  $totalarray['nbfield']++;
1686  }
1687  }
1688  if (!empty($arrayfields['s.siret']['checked'])) {
1689  print "<td>".$obj->idprof2."</td>\n";
1690  if (!$i) {
1691  $totalarray['nbfield']++;
1692  }
1693  }
1694  if (!empty($arrayfields['s.ape']['checked'])) {
1695  print "<td>".$obj->idprof3."</td>\n";
1696  if (!$i) {
1697  $totalarray['nbfield']++;
1698  }
1699  }
1700  if (!empty($arrayfields['s.idprof4']['checked'])) {
1701  print "<td>".$obj->idprof4."</td>\n";
1702  if (!$i) {
1703  $totalarray['nbfield']++;
1704  }
1705  }
1706  if (!empty($arrayfields['s.idprof5']['checked'])) {
1707  print "<td>".$obj->idprof5."</td>\n";
1708  if (!$i) {
1709  $totalarray['nbfield']++;
1710  }
1711  }
1712  if (!empty($arrayfields['s.idprof6']['checked'])) {
1713  print "<td>".$obj->idprof6."</td>\n";
1714  if (!$i) {
1715  $totalarray['nbfield']++;
1716  }
1717  }
1718  // VAT
1719  if (!empty($arrayfields['s.tva_intra']['checked'])) {
1720  print '<td class="tdoverflowmax125" title="'.dol_escape_htmltag($companystatic->tva_intra).'">';
1721  if ($companystatic->tva_intra && !isValidVATID($companystatic)) {
1722  print img_warning("BadVATNumber", '', 'pictofixedwidth');
1723  }
1724  print $companystatic->tva_intra;
1725  print "</td>\n";
1726  if (!$i) {
1727  $totalarray['nbfield']++;
1728  }
1729  }
1730  // Type
1731  if (!empty($arrayfields['customerorsupplier']['checked'])) {
1732  print '<td class="center">';
1733  print $companystatic->getTypeUrl(1);
1734  print '</td>';
1735  if (!$i) {
1736  $totalarray['nbfield']++;
1737  }
1738  }
1739 
1740  if (!empty($arrayfields['s.fk_prospectlevel']['checked'])) {
1741  // Prospect level
1742  print '<td class="center">';
1743  print $companystatic->getLibProspLevel();
1744  print "</td>";
1745  if (!$i) {
1746  $totalarray['nbfield']++;
1747  }
1748  }
1749 
1750  if (!empty($arrayfields['s.fk_stcomm']['checked'])) {
1751  // Prospect status
1752  print '<td class="center nowrap"><div class="nowraponall">';
1753  print '<div class="inline-block">';
1754  print $companystatic->LibProspCommStatut($obj->stcomm_id, 2, $prospectstatic->cacheprospectstatus[$obj->stcomm_id]['label'], $obj->stcomm_picto);
1755  print '</div> - <div class="inline-block">';
1756  foreach ($prospectstatic->cacheprospectstatus as $key => $val) {
1757  $titlealt = 'default';
1758  if (!empty($val['code']) && !in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) {
1759  $titlealt = $val['label'];
1760  }
1761  if ($obj->stcomm_id != $val['id']) {
1762  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>';
1763  }
1764  }
1765  print '</div></div></td>';
1766  if (!$i) {
1767  $totalarray['nbfield']++;
1768  }
1769  }
1770  // Parent company
1771  if (!empty($arrayfields['s2.nom']['checked'])) {
1772  print '<td class="center tdoverflowmax100">';
1773  if ($companystatic->fk_parent > 0) {
1774  $companyparent->fetch($companystatic->fk_parent);
1775  print $companyparent->getNomUrl(1);
1776  }
1777  print "</td>";
1778  if (!$i) {
1779  $totalarray['nbfield']++;
1780  }
1781  }
1782  // Extra fields
1783  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1784  // Fields from hook
1785  $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
1786  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1787  print $hookmanager->resPrint;
1788  // Date creation
1789  if (!empty($arrayfields['s.datec']['checked'])) {
1790  print '<td class="center nowraponall">';
1791  print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
1792  print '</td>';
1793  if (!$i) {
1794  $totalarray['nbfield']++;
1795  }
1796  }
1797  // Date modification
1798  if (!empty($arrayfields['s.tms']['checked'])) {
1799  print '<td class="center nowraponall">';
1800  print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
1801  print '</td>';
1802  if (!$i) {
1803  $totalarray['nbfield']++;
1804  }
1805  }
1806  // Status
1807  if (!empty($arrayfields['s.status']['checked'])) {
1808  print '<td class="center nowraponall">'.$companystatic->getLibStatut(5).'</td>';
1809  if (!$i) {
1810  $totalarray['nbfield']++;
1811  }
1812  }
1813  // Import key
1814  if (!empty($arrayfields['s.import_key']['checked'])) {
1815  print '<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->import_key).'">';
1816  print dol_escape_htmltag($obj->import_key);
1817  print "</td>\n";
1818  if (!$i) {
1819  $totalarray['nbfield']++;
1820  }
1821  }
1822  // Action column (Show the massaction button only when this page is not opend from the Extended POS)
1823  if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
1824  print '<td class="nowrap center actioncolumn">';
1825  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
1826  $selected = 0;
1827  if (in_array($obj->rowid, $arrayofselected)) {
1828  $selected = 1;
1829  }
1830  print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
1831  }
1832  print '</td>';
1833  if (!$i) {
1834  $totalarray['nbfield']++;
1835  }
1836  }
1837 
1838  print '</tr>'."\n";
1839  $i++;
1840 }
1841 
1842 // If no record found
1843 if ($num == 0) {
1844  $colspan = 1;
1845  foreach ($arrayfields as $key => $val) {
1846  if (!empty($val['checked'])) {
1847  $colspan++;
1848  }
1849  }
1850  print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
1851 }
1852 
1853 $db->free($resql);
1854 
1855 $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
1856 $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1857 print $hookmanager->resPrint;
1858 
1859 print "</table>";
1860 print "</div>";
1861 
1862 print '</form>';
1863 
1864 // End of page
1865 llxFooter();
1866 $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,...