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) 2003 Eric Seigne <erics@rycks.com>
4  * Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
5  * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
6  * Copyright (C) 2013-2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
7  * Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
8  * Copyright (C) 2013 Alexandre Spangaro <aspangaro@open-dsi.fr>
9  * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
10  * Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
11  * Copyright (C) 2018 Juanjo Menent <jmenent@2byte.es>
12  * Copyright (C) 2019 Frédéric France <frederic.france@netlogic.fr>
13  * Copyright (C) 2019 Josep Lluís Amador <joseplluis@lliuretic.cat>
14  * Copyright (C) 2020 Open-Dsi <support@open-dsi.fr>
15  *
16  * This program is free software; you can redistribute it and/or modify
17  * it under the terms of the GNU General Public License as published by
18  * the Free Software Foundation; either version 3 of the License, or
19  * (at your option) any later version.
20  *
21  * This program is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24  * GNU General Public License for more details.
25  *
26  * You should have received a copy of the GNU General Public License
27  * along with this program. If not, see <https://www.gnu.org/licenses/>.
28  */
29 
37 // Load Dolibarr environment
38 require '../main.inc.php';
39 require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
40 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
41 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
42 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
43 
44 // Load translation files required by the page
45 $langs->loadLangs(array("companies", "suppliers", "categories"));
46 
47 $socialnetworks = getArrayOfSocialNetworks();
48 
49 // Get parameters
50 $action = GETPOST('action', 'aZ09');
51 $massaction = GETPOST('massaction', 'alpha');
52 $show_files = GETPOST('show_files', 'int');
53 $confirm = GETPOST('confirm', 'alpha');
54 $toselect = GETPOST('toselect', 'array');
55 $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'contactlist';
56 
57 // Security check
58 $id = GETPOST('id', 'int');
59 $contactid = GETPOST('id', 'int');
60 $ref = ''; // There is no ref for contacts
61 if ($user->socid) {
62  $socid = $user->socid;
63 }
64 $result = restrictedArea($user, 'contact', $contactid, '');
65 
66 $sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
67 $search_cti = preg_replace('/^0+/', '', preg_replace('/[^0-9]/', '', GETPOST('search_cti', 'alphanohtml'))); // Phone number without any special chars
68 $search_phone = GETPOST("search_phone", 'alpha');
69 
70 $search_id = GETPOST("search_id", "int");
71 $search_firstlast_only = GETPOST("search_firstlast_only", 'alpha');
72 $search_lastname = GETPOST("search_lastname", 'alpha');
73 $search_firstname = GETPOST("search_firstname", 'alpha');
74 $search_societe = GETPOST("search_societe", 'alpha');
75 $search_societe_alias = GETPOST("search_societe_alias", 'alpha');
76 $search_poste = GETPOST("search_poste", 'alpha');
77 $search_phone_perso = GETPOST("search_phone_perso", 'alpha');
78 $search_phone_pro = GETPOST("search_phone_pro", 'alpha');
79 $search_phone_mobile = GETPOST("search_phone_mobile", 'alpha');
80 $search_fax = GETPOST("search_fax", 'alpha');
81 $search_email = GETPOST("search_email", 'alpha');
82 if (isModEnabled('mailing')) {
83  $search_no_email = GETPOSTISSET("search_no_email") ? GETPOST("search_no_email", 'int') : -1;
84 } else {
85  $search_no_email = -1;
86 }
87 if (isModEnabled('socialnetworks')) {
88  foreach ($socialnetworks as $key => $value) {
89  if ($value['active']) {
90  $search_[$key] = GETPOST("search_".$key, 'alpha');
91  }
92  }
93 }
94 $search_priv = GETPOST("search_priv", 'alpha');
95 $search_categ = GETPOST("search_categ", 'int');
96 $search_categ_thirdparty = GETPOST("search_categ_thirdparty", 'int');
97 $search_categ_supplier = GETPOST("search_categ_supplier", 'int');
98 $search_status = GETPOST("search_status", 'int');
99 $search_type = GETPOST('search_type', 'alpha');
100 $search_address = GETPOST('search_address', 'alpha');
101 $search_zip = GETPOST('search_zip', 'alpha');
102 $search_town = GETPOST('search_town', 'alpha');
103 $search_import_key = GETPOST("search_import_key", "alpha");
104 $search_country = GETPOST("search_country", 'intcomma');
105 $search_roles = GETPOST("search_roles", 'array');
106 $search_level = GETPOST("search_level", "array");
107 $search_stcomm = GETPOST('search_stcomm', 'int');
108 
109 if ($search_status === '') {
110  $search_status = 1; // always display active customer first
111 }
112 if ($search_no_email === '') {
113  $search_no_email = -1;
114 }
115 
116 $optioncss = GETPOST('optioncss', 'alpha');
117 
118 
119 $type = GETPOST("type", 'aZ');
120 $view = GETPOST("view", 'alpha');
121 
122 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
123 $sortfield = GETPOST('sortfield', 'aZ09comma');
124 $sortorder = GETPOST('sortorder', 'aZ09comma');
125 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
126 $userid = GETPOST('userid', 'int');
127 $begin = GETPOST('begin');
128 if (!$sortorder) {
129  $sortorder = "ASC";
130 }
131 if (!$sortfield) {
132  $sortfield = "p.lastname";
133 }
134 if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
135  $page = 0;
136 }
137 $offset = $limit * $page;
138 
139 
140 $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
141 if ($type == "p") {
142  if (empty($contextpage) || $contextpage == 'contactlist') {
143  $contextpage = 'contactprospectlist';
144  }
145  $title .= ' ('.$langs->trans("ThirdPartyProspects").')';
146  $urlfiche = "card.php";
147 }
148 if ($type == "c") {
149  if (empty($contextpage) || $contextpage == 'contactlist') {
150  $contextpage = 'contactcustomerlist';
151  }
152  $title .= ' ('.$langs->trans("ThirdPartyCustomers").')';
153  $urlfiche = "card.php";
154 } elseif ($type == "f") {
155  if (empty($contextpage) || $contextpage == 'contactlist') {
156  $contextpage = 'contactsupplierlist';
157  }
158  $title .= ' ('.$langs->trans("ThirdPartySuppliers").')';
159  $urlfiche = "card.php";
160 } elseif ($type == "o") {
161  if (empty($contextpage) || $contextpage == 'contactlist') {
162  $contextpage = 'contactotherlist';
163  }
164  $title .= ' ('.$langs->trans("OthersNotLinkedToThirdParty").')';
165  $urlfiche = "";
166 }
167 
168 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
169 $object = new Contact($db);
170 $hookmanager->initHooks(array('contactlist'));
171 $extrafields = new ExtraFields($db);
172 
173 // fetch optionals attributes and labels
174 $extrafields->fetch_name_optionals_label($object->table_element);
175 
176 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
177 
178 // List of fields to search into when doing a "search in all"
179 $fieldstosearchall = array();
180 foreach ($object->fields as $key => $val) {
181  // don't allow search in private notes for external users when doing "search in all"
182  if (!empty($user->socid) && $key == "note_private") {
183  continue;
184  }
185 
186  if (empty($val['searchall'])) {
187  continue;
188  }
189 
190  $fieldstosearchall['p.'.$key] = $val['label'];
191 }
192 
193 // Add none object fields for "search in all"
194 if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) {
195  $fieldstosearchall['s.nom'] = "ThirdParty";
196  $fieldstosearchall['s.name_alias'] = "AliasNames";
197 }
198 
199 // Definition of fields for list
200 $arrayfields = array();
201 foreach ($object->fields as $key => $val) {
202  // If $val['visible']==0, then we never show the field
203  if (empty($val['visible'])) {
204  continue;
205  }
206 
207  $arrayfields['p.'.$key] = array(
208  'label'=>$val['label'],
209  'checked'=>(($val['visible'] < 0) ? 0 : 1),
210  'enabled'=>($val['enabled'] && ($val['visible'] != 3)),
211  'position'=>$val['position']);
212 }
213 
214 // Add none object fields to fields for list
215 $arrayfields['country.code_iso'] = array('label'=>"Country", 'position'=>66, 'checked'=>0);
216 if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) {
217  $arrayfields['s.nom'] = array('label'=>"ThirdParty", 'position'=>113, 'checked'=> 1);
218  $arrayfields['s.name_alias'] = array('label'=>"AliasNameShort", 'position'=>114, 'checked'=> 1);
219 }
220 
221 $arrayfields['unsubscribed'] = array(
222  'label'=>'No_Email',
223  'checked'=>0,
224  'enabled'=>(isModEnabled('mailing')),
225  'position'=>111);
226 
227 if (isModEnabled('socialnetworks')) {
228  foreach ($socialnetworks as $key => $value) {
229  if ($value['active']) {
230  $arrayfields['p.'.$key] = array(
231  'label' => $value['label'],
232  'checked' => 0,
233  'position' => 300
234  );
235  }
236  }
237 }
238 
239 // Extra fields
240 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
241 
242 $object->fields = dol_sort_array($object->fields, 'position');
243 $arrayfields = dol_sort_array($arrayfields, 'position');
244 
245 
246 if (($id > 0 || !empty($ref)) && $action != 'add') {
247  $result = $object->fetch($id, $ref);
248  if ($result < 0) {
249  dol_print_error($db);
250  }
251 }
252 
253 
254 /*
255  * Actions
256  */
257 
258 if (GETPOST('cancel', 'alpha')) {
259  $action = 'list'; $massaction = '';
260 }
261 if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
262  $massaction = '';
263 }
264 
265 $parameters = array();
266 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
267 if ($reshook < 0) {
268  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
269 }
270 
271 if (empty($reshook)) {
272  // Selection of new fields
273  include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
274 
275  // Did we click on purge search criteria ?
276  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
277  $sall = "";
278  $search_id = '';
279  $search_firstlast_only = "";
280  $search_lastname = "";
281  $search_firstname = "";
282  $search_societe = "";
283  $search_societe_alias = "";
284  $search_town = "";
285  $search_address = "";
286  $search_zip = "";
287  $search_country = "";
288  $search_poste = "";
289  $search_phone = "";
290  $search_phone_perso = "";
291  $search_phone_pro = "";
292  $search_phone_mobile = "";
293  $search_fax = "";
294  $search_email = "";
295  $search_no_email = -1;
296  if (isModEnabled('socialnetworks')) {
297  foreach ($socialnetworks as $key => $value) {
298  if ($value['active']) {
299  $search_[$key] = "";
300  }
301  }
302  }
303  $search_priv = "";
304  $search_stcomm = '';
305  $search_level = '';
306  $search_status = -1;
307  $search_categ = '';
308  $search_categ_thirdparty = '';
309  $search_categ_supplier = '';
310  $search_import_key = '';
311  $toselect = array();
312  $search_array_options = array();
313  $search_roles = array();
314  }
315 
316  // Mass actions
317  $objectclass = 'Contact';
318  $objectlabel = 'Contact';
319  $permissiontoread = $user->hasRight('societe', 'lire');
320  $permissiontodelete = $user->hasRight('societe', 'supprimer');
321  $permissiontoadd = $user->rights->societe->creer;
322  $uploaddir = $conf->societe->dir_output;
323  include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
324 
325  if ($action == 'setstcomm') {
326  $object = new Contact($db);
327  $result = $object->fetch(GETPOST('stcommcontactid'));
328  $object->stcomm_id = dol_getIdFromCode($db, GETPOST('stcomm', 'alpha'), 'c_stcommcontact');
329  $result = $object->update($object->id, $user);
330  if ($result < 0) {
331  setEventMessages($object->error, $object->errors, 'errors');
332  }
333 
334  $action = '';
335  }
336 }
337 
338 if ($search_priv < 0) {
339  $search_priv = '';
340 }
341 
342 
343 /*
344  * View
345  */
346 
347 $form = new Form($db);
348 $formother = new FormOther($db);
349 $formcompany = new FormCompany($db);
350 $contactstatic = new Contact($db);
351 
352 $morejs=array();
353 $morecss = array();
354 
355 if (!empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES)) {
356  $contactstatic->loadCacheOfProspStatus();
357 }
358 
359 // Select every potentiels, and note each potentiels which fit in search parameters
360 $tab_level = array();
361 $sql = "SELECT code, label, sortorder";
362 $sql .= " FROM ".MAIN_DB_PREFIX."c_prospectcontactlevel";
363 $sql .= " WHERE active > 0";
364 $sql .= " ORDER BY sortorder";
365 $resql = $db->query($sql);
366 if ($resql) {
367  while ($obj = $db->fetch_object($resql)) {
368  // Compute level text
369  $level = $langs->trans($obj->code);
370  if ($level == $obj->code) {
371  $level = $langs->trans($obj->label);
372  }
373  $tab_level[$obj->code] = $level;
374  }
375 } else {
376  dol_print_error($db);
377 }
378 
379 $sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias as alias,";
380 $sql .= " p.rowid, p.lastname as lastname, p.statut, p.firstname, p.address, p.zip, p.town, p.poste, p.email,";
381 $sql .= " p.socialnetworks, p.photo,";
382 $sql .= " p.phone as phone_pro, p.phone_mobile, p.phone_perso, p.fax, p.fk_pays, p.priv, p.datec as date_creation, p.tms as date_update,";
383 $sql .= " p.import_key,";
384 $sql .= " st.libelle as stcomm, st.picto as stcomm_picto, p.fk_stcommcontact as stcomm_id, p.fk_prospectcontactlevel,";
385 $sql .= " co.label as country, co.code as country_code";
386 // Add fields from extrafields
387 if (!empty($extrafields->attributes[$object->table_element]['label'])) {
388  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
389  $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
390  }
391 }
392 if (isModEnabled('mailing')) {
393  $sql .= ", (SELECT count(*) FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = p.email) as unsubscribed";
394 }
395 // Add fields from hooks
396 $parameters = array();
397 $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
398 $sql .= $hookmanager->resPrint;
399 
400 $sqlfields = $sql; // $sql fields to remove for count total
401 
402 $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as p";
403 if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
404  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (p.rowid = ef.fk_object)";
405 }
406 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = p.fk_pays";
407 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc";
408 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_stcommcontact as st ON st.id = p.fk_stcommcontact";
409 if (empty($user->rights->societe->client->voir) && !$socid) {
410  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
411 }
412 $sql .= ' WHERE p.entity IN ('.getEntity('contact').')';
413 if (empty($user->rights->societe->client->voir) && !$socid) { //restriction
414  $sql .= " AND (sc.fk_user = ".((int) $user->id)." OR p.fk_soc IS NULL)";
415 }
416 if (!empty($userid)) { // propre au commercial
417  $sql .= " AND p.fk_user_creat=".((int) $userid);
418 }
419 if ($search_level) {
420  $sql .= natural_search("p.fk_prospectcontactlevel", join(',', $search_level), 3);
421 }
422 if ($search_stcomm != '' && $search_stcomm != -2) {
423  $sql .= natural_search("p.fk_stcommcontact", $search_stcomm, 2);
424 }
425 
426 // Filter to exclude not owned private contacts
427 if ($search_priv != '0' && $search_priv != '1') {
428  $sql .= " AND (p.priv='0' OR (p.priv='1' AND p.fk_user_creat=".((int) $user->id)."))";
429 } else {
430  if ($search_priv == '0') {
431  $sql .= " AND p.priv='0'";
432  }
433  if ($search_priv == '1') {
434  $sql .= " AND (p.priv='1' AND p.fk_user_creat=".((int) $user->id).")";
435  }
436 }
437 $searchCategoryContactList = $search_categ ? array($search_categ) : array();
438 $searchCategoryContactOperator = 0;
439 // Search for tag/category ($searchCategoryContactList is an array of ID)
440 if (!empty($searchCategoryContactList)) {
441  $searchCategoryContactSqlList = array();
442  $listofcategoryid = '';
443  foreach ($searchCategoryContactList as $searchCategoryContact) {
444  if (intval($searchCategoryContact) == -2) {
445  $searchCategoryContactSqlList[] = "NOT EXISTS (SELECT ck.fk_socpeople FROM ".MAIN_DB_PREFIX."categorie_contact as ck WHERE p.rowid = ck.fk_socpeople)";
446  } elseif (intval($searchCategoryContact) > 0) {
447  if ($searchCategoryContactOperator == 0) {
448  $searchCategoryContactSqlList[] = " EXISTS (SELECT ck.fk_socpeople FROM ".MAIN_DB_PREFIX."categorie_contact as ck WHERE p.rowid = ck.fk_socpeople AND ck.fk_categorie = ".((int) $searchCategoryContact).")";
449  } else {
450  $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryContact);
451  }
452  }
453  }
454  if ($listofcategoryid) {
455  $searchCategoryContactSqlList[] = " EXISTS (SELECT ck.fk_socpeople FROM ".MAIN_DB_PREFIX."categorie_contact as ck WHERE p.rowid = ck.fk_socpeople AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))";
456  }
457  if ($searchCategoryContactOperator == 1) {
458  if (!empty($searchCategoryContactSqlList)) {
459  $sql .= " AND (".implode(' OR ', $searchCategoryContactSqlList).")";
460  }
461  } else {
462  if (!empty($searchCategoryContactSqlList)) {
463  $sql .= " AND (".implode(' AND ', $searchCategoryContactSqlList).")";
464  }
465  }
466 }
467 $searchCategoryCustomerList = $search_categ_thirdparty ? array($search_categ_thirdparty) : array();
468 $searchCategoryCustomerOperator = 0;
469 // Search for tag/category ($searchCategoryCustomerList is an array of ID)
470 if (!empty($searchCategoryCustomerList)) {
471  $searchCategoryCustomerSqlList = array();
472  $listofcategoryid = '';
473  foreach ($searchCategoryCustomerList as $searchCategoryCustomer) {
474  if (intval($searchCategoryCustomer) == -2) {
475  $searchCategoryCustomerSqlList[] = "NOT EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe as ck WHERE s.rowid = ck.fk_soc)";
476  } elseif (intval($searchCategoryCustomer) > 0) {
477  if ($searchCategoryCustomerOperator == 0) {
478  $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).")";
479  } else {
480  $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryCustomer);
481  }
482  }
483  }
484  if ($listofcategoryid) {
485  $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)."))";
486  }
487  if ($searchCategoryCustomerOperator == 1) {
488  if (!empty($searchCategoryCustomerSqlList)) {
489  $sql .= " AND (".implode(' OR ', $searchCategoryCustomerSqlList).")";
490  }
491  } else {
492  if (!empty($searchCategoryCustomerSqlList)) {
493  $sql .= " AND (".implode(' AND ', $searchCategoryCustomerSqlList).")";
494  }
495  }
496 }
497 $searchCategorySupplierList = $search_categ_supplier ? array($search_categ_supplier) : array();
498 $searchCategorySupplierOperator = 0;
499 // Search for tag/category ($searchCategorySupplierList is an array of ID)
500 if (!empty($searchCategorySupplierList)) {
501  $searchCategorySupplierSqlList = array();
502  $listofcategoryid = '';
503  foreach ($searchCategorySupplierList as $searchCategorySupplier) {
504  if (intval($searchCategorySupplier) == -2) {
505  $searchCategorySupplierSqlList[] = "NOT EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_fournisseur as ck WHERE s.rowid = ck.fk_soc)";
506  } elseif (intval($searchCategorySupplier) > 0) {
507  if ($searchCategorySupplierOperator == 0) {
508  $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).")";
509  } else {
510  $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategorySupplier);
511  }
512  }
513  }
514  if ($listofcategoryid) {
515  $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)."))";
516  }
517  if ($searchCategorySupplierOperator == 1) {
518  if (!empty($searchCategorySupplierSqlList)) {
519  $sql .= " AND (".implode(' OR ', $searchCategorySupplierSqlList).")";
520  }
521  } else {
522  if (!empty($searchCategorySupplierSqlList)) {
523  $sql .= " AND (".implode(' AND ', $searchCategorySupplierSqlList).")";
524  }
525  }
526 }
527 
528 if ($sall) {
529  $sql .= natural_search(array_keys($fieldstosearchall), $sall);
530 }
531 if (strlen($search_phone)) {
532  $sql .= natural_search(array('p.phone', 'p.phone_perso', 'p.phone_mobile'), $search_phone);
533 }
534 if (strlen($search_cti)) {
535  $sql .= natural_search(array('p.phone', 'p.phone_perso', 'p.phone_mobile'), $search_cti);
536 }
537 if (strlen($search_firstlast_only)) {
538  $sql .= natural_search(array('p.lastname', 'p.firstname'), $search_firstlast_only);
539 }
540 
541 if ($search_id > 0) {
542  $sql .= natural_search('p.rowid', $search_id, 1);
543 }
544 if ($search_lastname) {
545  $sql .= natural_search('p.lastname', $search_lastname);
546 }
547 if ($search_firstname) {
548  $sql .= natural_search('p.firstname', $search_firstname);
549 }
550 if (empty($arrayfields['s.name_alias']['checked']) && $search_societe) {
551  $sql .= natural_search(array("s.nom", "s.name_alias"), $search_societe);
552 } else {
553  if ($search_societe) {
554  $sql .= natural_search('s.nom', $search_societe);
555  }
556  if ($search_societe_alias) {
557  $sql .= natural_search('s.name_alias', $search_societe_alias);
558  }
559 }
560 if ($search_country) {
561  $sql .= " AND p.fk_pays IN (".$db->sanitize($search_country).')';
562 }
563 if (strlen($search_poste)) {
564  $sql .= natural_search('p.poste', $search_poste);
565 }
566 if (strlen($search_phone_perso)) {
567  $sql .= natural_search('p.phone_perso', $search_phone_perso);
568 }
569 if (strlen($search_phone_pro)) {
570  $sql .= natural_search('p.phone', $search_phone_pro);
571 }
572 if (strlen($search_phone_mobile)) {
573  $sql .= natural_search('p.phone_mobile', $search_phone_mobile);
574 }
575 if (strlen($search_fax)) {
576  $sql .= natural_search('p.fax', $search_fax);
577 }
578 if (isModEnabled('socialnetworks')) {
579  foreach ($socialnetworks as $key => $value) {
580  if ($value['active'] && strlen($search_[$key])) {
581  $searchkeyinjsonformat = preg_replace('/"$/', '', preg_replace('/^"/', '', json_encode($search_[$key])));
582  if (in_array($db->type, array('mysql', 'mysqli'))) {
583  $sql .= " AND p.socialnetworks REGEXP '\"".$db->escape($db->escapeforlike($key))."\":\"[^\"]*".$db->escape($db->escapeforlike($searchkeyinjsonformat))."'";
584  } elseif ($db->type == 'pgsql') {
585  $sql .= " AND p.socialnetworks ~ '\"".$db->escape($db->escapeforlike($key))."\":\"[^\"]*".$db->escape($db->escapeforlike($searchkeyinjsonformat))."'";
586  } else {
587  // Works with all database but not reliable because search only for social network code starting with earched value
588  $sql .= " AND p.socialnetworks LIKE '%\"".$db->escape($db->escapeforlike($key))."\":\"".$db->escape($db->escapeforlike($searchkeyinjsonformat))."%'";
589  }
590  }
591  }
592 }
593 //print $sql;
594 if (strlen($search_email)) {
595  $sql .= natural_search('p.email', $search_email);
596 }
597 if (strlen($search_address)) {
598  $sql .= natural_search("p.address", $search_address);
599 }
600 if (strlen($search_zip)) {
601  $sql .= natural_search("p.zip", $search_zip);
602 }
603 if (strlen($search_town)) {
604  $sql .= natural_search("p.town", $search_town);
605 }
606 if (count($search_roles) > 0) {
607  $sql .= " AND p.rowid IN (SELECT sc.fk_socpeople FROM ".MAIN_DB_PREFIX."societe_contacts as sc WHERE sc.fk_c_type_contact IN (".$db->sanitize(implode(',', $search_roles))."))";
608 }
609 if ($search_no_email != -1 && $search_no_email > 0) {
610  $sql .= " AND (SELECT count(*) FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = p.email) > 0";
611 }
612 if ($search_no_email != -1 && $search_no_email == 0) {
613  $sql .= " AND (SELECT count(*) FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = p.email) = 0 AND p.email IS NOT NULL AND p.email <> ''";
614 }
615 if ($search_status != '' && $search_status >= 0) {
616  $sql .= " AND p.statut = ".((int) $search_status);
617 }
618 if ($search_import_key) {
619  $sql .= natural_search("p.import_key", $search_import_key);
620 }
621 if ($type == "o") { // filtre sur type
622  $sql .= " AND p.fk_soc IS NULL";
623 } elseif ($type == "f") { // filtre sur type
624  $sql .= " AND s.fournisseur = 1";
625 } elseif ($type == "c") { // filtre sur type
626  $sql .= " AND s.client IN (1, 3)";
627 } elseif ($type == "p") { // filtre sur type
628  $sql .= " AND s.client IN (2, 3)";
629 }
630 if (!empty($socid)) {
631  $sql .= " AND s.rowid = ".((int) $socid);
632 }
633 // Add where from extra fields
634 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
635 // Add where from hooks
636 $parameters = array();
637 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
638 $sql .= $hookmanager->resPrint;
639 //print $sql;
640 
641 // Count total nb of records
642 $nbtotalofrecords = '';
643 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
644  /* The fast and low memory method to get and count full list converts the sql into a sql count */
645  $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
646  $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
647  $resql = $db->query($sqlforcount);
648  if ($resql) {
649  $objforcount = $db->fetch_object($resql);
650  $nbtotalofrecords = $objforcount->nbtotalofrecords;
651  } else {
652  dol_print_error($db);
653  }
654 
655  if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
656  $page = 0;
657  $offset = 0;
658  }
659  $db->free($resql);
660 }
661 
662 // Complete request and execute it with limit
663 if ($view == "recent") {
664  $sql .= $db->order("p.datec", "DESC");
665 } else {
666  $sql .= $db->order($sortfield, $sortorder);
667 }
668 if ($limit) {
669  $sql .= $db->plimit($limit + 1, $offset);
670 }
671 
672 $resql = $db->query($sql);
673 if (!$resql) {
674  dol_print_error($db);
675  exit;
676 }
677 
678 $num = $db->num_rows($resql);
679 
680 $arrayofselected = is_array($toselect) ? $toselect : array();
681 
682 if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && ($sall != '' || $search_cti != '')) {
683  $obj = $db->fetch_object($resql);
684  $id = $obj->rowid;
685  header("Location: ".DOL_URL_ROOT.'/contact/card.php?id='.$id);
686  exit;
687 }
688 
689 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
690 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
691 
692 $help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:M&oacute;dulo_Empresas';
693 llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'bodyforlist');
694 
695 $param = '';
696 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
697  $param .= '&contextpage='.urlencode($contextpage);
698 }
699 if ($limit > 0 && $limit != $conf->liste_limit) {
700  $param .= '&limit='.((int) $limit);
701 }
702 $param .= '&begin='.urlencode($begin).'&userid='.urlencode($userid).'&contactname='.urlencode($sall);
703 $param .= '&type='.urlencode($type).'&view='.urlencode($view);
704 if (!empty($search_categ) && $search_categ != '-1') {
705  $param .= '&search_categ='.urlencode($search_categ);
706 }
707 if (!empty($search_categ_thirdparty) && $search_categ_thirdparty != '-1') {
708  $param .= '&search_categ_thirdparty='.urlencode($search_categ_thirdparty);
709 }
710 if (!empty($search_categ_supplier) && $search_categ_supplier != '-1') {
711  $param .= '&search_categ_supplier='.urlencode($search_categ_supplier);
712 }
713 if ($sall != '') {
714  $param .= '&sall='.urlencode($sall);
715 }
716 if ($search_id > 0) {
717  $param .= "&search_id=".urlencode($search_id);
718 }
719 if ($search_lastname != '') {
720  $param .= '&search_lastname='.urlencode($search_lastname);
721 }
722 if ($search_firstname != '') {
723  $param .= '&search_firstname='.urlencode($search_firstname);
724 }
725 if ($search_societe != '') {
726  $param .= '&search_societe='.urlencode($search_societe);
727 }
728 if ($search_societe_alias != '') {
729  $param .= '&search_societe_alias='.urlencode($search_societe_alias);
730 }
731 if ($search_address != '') {
732  $param .= '&search_address='.urlencode($search_address);
733 }
734 if ($search_zip != '') {
735  $param .= '&search_zip='.urlencode($search_zip);
736 }
737 if ($search_town != '') {
738  $param .= '&search_town='.urlencode($search_town);
739 }
740 if ($search_country != '') {
741  $param .= "&search_country=".urlencode($search_country);
742 }
743 if ($search_poste != '') {
744  $param .= '&search_poste='.urlencode($search_poste);
745 }
746 if ($search_phone_pro != '') {
747  $param .= '&search_phone_pro='.urlencode($search_phone_pro);
748 }
749 if ($search_phone_perso != '') {
750  $param .= '&search_phone_perso='.urlencode($search_phone_perso);
751 }
752 if ($search_phone_mobile != '') {
753  $param .= '&search_phone_mobile='.urlencode($search_phone_mobile);
754 }
755 if ($search_fax != '') {
756  $param .= '&search_fax='.urlencode($search_fax);
757 }
758 if ($search_email != '') {
759  $param .= '&search_email='.urlencode($search_email);
760 }
761 if ($search_no_email != '') {
762  $param .= '&search_no_email='.urlencode($search_no_email);
763 }
764 if ($search_status != '') {
765  $param .= '&search_status='.urlencode($search_status);
766 }
767 if ($search_priv == '0' || $search_priv == '1') {
768  $param .= "&search_priv=".urlencode($search_priv);
769 }
770 if ($search_stcomm != '') {
771  $param .= '&search_stcomm='.urlencode($search_stcomm);
772 }
773 if (is_array($search_level) && count($search_level)) {
774  foreach ($search_level as $slevel) {
775  $param .= '&search_level[]='.urlencode($slevel);
776  }
777 }
778 if ($search_import_key != '') {
779  $param .= '&amp;search_import_key='.urlencode($search_import_key);
780 }
781 if ($optioncss != '') {
782  $param .= '&amp;optioncss='.urlencode($optioncss);
783 }
784 if (count($search_roles) > 0) {
785  $param .= implode('&search_roles[]=', $search_roles);
786 }
787 
788 // Add $param from extra fields
789 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
790 
791 // List of mass actions available
792 $arrayofmassactions = array(
793 // 'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
794 // 'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
795 );
796 //if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer");
797 if ($user->hasRight('societe', 'supprimer')) {
798  $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
799 }
800 if (isModEnabled('category') && $user->rights->societe->creer) {
801  $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag");
802 }
803 if (in_array($massaction, array('presend', 'predelete','preaffecttag'))) {
804  $arrayofmassactions = array();
805 }
806 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
807 
808 $newcardbutton = dolGetButtonTitle($langs->trans('NewContactAddress'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/contact/card.php?action=create', '', $user->rights->societe->contact->creer);
809 
810 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'" name="formfilter">';
811 if ($optioncss != '') {
812  print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
813 }
814 print '<input type="hidden" name="token" value="'.newToken().'">';
815 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
816 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
817 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
818 //print '<input type="hidden" name="page" value="'.$page.'">';
819 print '<input type="hidden" name="type" value="'.$type.'">';
820 print '<input type="hidden" name="view" value="'.dol_escape_htmltag($view).'">';
821 
822 print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'address', 0, $newcardbutton, '', $limit, 0, 0, 1);
823 
824 $topicmail = "Information";
825 $modelmail = "contact";
826 $objecttmp = new Contact($db);
827 $trackid = 'ctc'.$object->id;
828 include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
829 
830 if ($sall) {
831  foreach ($fieldstosearchall as $key => $val) {
832  $fieldstosearchall[$key] = $langs->trans($val);
833  }
834  print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>';
835 }
836 if ($search_firstlast_only) {
837  print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_firstlast_only).$langs->trans("Lastname").", ".$langs->trans("Firstname").'</div>';
838 }
839 
840 $moreforfilter = '';
841 if (isModEnabled('categorie') && $user->rights->categorie->lire) {
842  require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
843  $moreforfilter .= '<div class="divsearchfield">';
844  $tmptitle = $langs->trans('ContactCategoriesShort');
845  $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"');
846  $moreforfilter .= $formother->select_categories(Categorie::TYPE_CONTACT, $search_categ, 'search_categ', 1, $tmptitle);
847  $moreforfilter .= '</div>';
848  if (empty($type) || $type == 'c' || $type == 'p') {
849  $moreforfilter .= '<div class="divsearchfield">';
850  $tmptitle = '';
851  if ($type == 'c') {
852  $tmptitle .= $langs->trans('CustomersCategoriesShort');
853  } elseif ($type == 'p') {
854  $tmptitle .= $langs->trans('ProspectsCategoriesShort');
855  } else {
856  $tmptitle .= $langs->trans('CustomersProspectsCategoriesShort');
857  }
858  $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"');
859  $moreforfilter .= $formother->select_categories(Categorie::TYPE_CUSTOMER, $search_categ_thirdparty, 'search_categ_thirdparty', 1, $tmptitle);
860  $moreforfilter .= '</div>';
861  }
862 
863  if (isModEnabled("fournisseur") && (empty($type) || $type == 'f')) {
864  $moreforfilter .= '<div class="divsearchfield">';
865  $tmptitle = $langs->trans('SuppliersCategoriesShort');
866  $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"');
867  $moreforfilter .= $formother->select_categories(Categorie::TYPE_SUPPLIER, $search_categ_supplier, 'search_categ_supplier', 1, $tmptitle);
868  $moreforfilter .= '</div>';
869  }
870 }
871 
872 $moreforfilter .= '<div class="divsearchfield">';
873 $moreforfilter .= $langs->trans('Roles').': ';
874 $moreforfilter .= $formcompany->showRoles("search_roles", $objecttmp, 'edit', $search_roles);
875 $moreforfilter .= '</div>';
876 
877 print '<div class="liste_titre liste_titre_bydiv centpercent">';
878 print $moreforfilter;
879 $parameters = array('type'=>$type);
880 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
881 print $hookmanager->resPrint;
882 print '</div>';
883 
884 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
885 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields
886 if ($massactionbutton) {
887  $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
888 }
889 
890 print '<div class="div-table-responsive">';
891 print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
892 
893 // Lines for filter fields
894 print '<tr class="liste_titre_filter">';
895 // Action column
896 if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
897  print '<td class="liste_titre maxwidthsearch">';
898  $searchpicto = $form->showFilterButtons('left');
899  print $searchpicto;
900  print '</td>';
901 }
902 if (!empty($arrayfields['p.rowid']['checked'])) {
903  print '<td class="liste_titre">';
904  print '<input class="flat searchstring" type="text" name="search_id" size="1" value="'.dol_escape_htmltag($search_id).'">';
905  print '</td>';
906 }
907 if (!empty($arrayfields['p.lastname']['checked'])) {
908  print '<td class="liste_titre">';
909  print '<input class="flat" type="text" name="search_lastname" size="6" value="'.dol_escape_htmltag($search_lastname).'">';
910  print '</td>';
911 }
912 if (!empty($arrayfields['p.firstname']['checked'])) {
913  print '<td class="liste_titre">';
914  print '<input class="flat" type="text" name="search_firstname" size="6" value="'.dol_escape_htmltag($search_firstname).'">';
915  print '</td>';
916 }
917 if (!empty($arrayfields['p.poste']['checked'])) {
918  print '<td class="liste_titre">';
919  print '<input class="flat" type="text" name="search_poste" size="5" value="'.dol_escape_htmltag($search_poste).'">';
920  print '</td>';
921 }
922 if (!empty($arrayfields['p.address']['checked'])) {
923  print '<td class="liste_titre">';
924  print '<input class="flat" type="text" name="search_address" size="6" value="'.dol_escape_htmltag($search_address).'">';
925  print '</td>';
926 }
927 if (!empty($arrayfields['p.zip']['checked'])) {
928  print '<td class="liste_titre">';
929  print '<input class="flat" type="text" name="search_zip" size="3" value="'.dol_escape_htmltag($search_zip).'">';
930  print '</td>';
931 }
932 if (!empty($arrayfields['p.town']['checked'])) {
933  print '<td class="liste_titre">';
934  print '<input class="flat" type="text" name="search_town" size="5" value="'.dol_escape_htmltag($search_town).'">';
935  print '</td>';
936 }
937 // State
938 /*if (!empty($arrayfields['state.nom']['checked']))
939  {
940  print '<td class="liste_titre">';
941  print '<input class="flat searchstring" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
942  print '</td>';
943  }
944  // Region
945  if (!empty($arrayfields['region.nom']['checked']))
946  {
947  print '<td class="liste_titre">';
948  print '<input class="flat searchstring" size="4" type="text" name="search_region" value="'.dol_escape_htmltag($search_region).'">';
949  print '</td>';
950  }*/
951 // Country
952 if (!empty($arrayfields['country.code_iso']['checked'])) {
953  print '<td class="liste_titre center">';
954  print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100');
955  print '</td>';
956 }
957 if (!empty($arrayfields['p.phone']['checked'])) {
958  print '<td class="liste_titre">';
959  print '<input class="flat" type="text" name="search_phone_pro" size="6" value="'.dol_escape_htmltag($search_phone_pro).'">';
960  print '</td>';
961 }
962 if (!empty($arrayfields['p.phone_perso']['checked'])) {
963  print '<td class="liste_titre">';
964  print '<input class="flat" type="text" name="search_phone_perso" size="6" value="'.dol_escape_htmltag($search_phone_perso).'">';
965  print '</td>';
966 }
967 if (!empty($arrayfields['p.phone_mobile']['checked'])) {
968  print '<td class="liste_titre">';
969  print '<input class="flat" type="text" name="search_phone_mobile" size="6" value="'.dol_escape_htmltag($search_phone_mobile).'">';
970  print '</td>';
971 }
972 if (!empty($arrayfields['p.fax']['checked'])) {
973  print '<td class="liste_titre">';
974  print '<input class="flat" type="text" name="search_fax" size="6" value="'.dol_escape_htmltag($search_fax).'">';
975  print '</td>';
976 }
977 if (!empty($arrayfields['p.email']['checked'])) {
978  print '<td class="liste_titre">';
979  print '<input class="flat" type="text" name="search_email" size="6" value="'.dol_escape_htmltag($search_email).'">';
980  print '</td>';
981 }
982 if (!empty($arrayfields['unsubscribed']['checked'])) {
983  print '<td class="liste_titre center">';
984  print $form->selectarray('search_no_email', array('-1'=>'', '0'=>$langs->trans('No'), '1'=>$langs->trans('Yes')), $search_no_email);
985  print '</td>';
986 }
987 if (isModEnabled('socialnetworks')) {
988  foreach ($socialnetworks as $key => $value) {
989  if ($value['active']) {
990  if (!empty($arrayfields['p.'.$key]['checked'])) {
991  print '<td class="liste_titre">';
992  print '<input class="flat" type="text" name="search_'.$key.'" size="6" value="'.dol_escape_htmltag($search_[$key]).'">';
993  print '</td>';
994  }
995  }
996  }
997 }
998 if (!empty($arrayfields['p.fk_soc']['checked']) || !empty($arrayfields['s.nom']['checked'])) {
999  print '<td class="liste_titre">';
1000  print '<input class="flat" type="text" name="search_societe" size="8" value="'.dol_escape_htmltag($search_societe).'">';
1001  print '</td>';
1002 }
1003 // Alias
1004 if (!empty($arrayfields['s.name_alias']['checked'])) {
1005  print '<td class="liste_titre" align="left">';
1006  print '<input class="flat maxwidth100" type="text" name="search_societe_alias" value="'.dol_escape_htmltag($search_societe_alias).'">';
1007  print '</td>';
1008 }
1009 if (!empty($arrayfields['p.priv']['checked'])) {
1010  print '<td class="liste_titre center">';
1011  $selectarray = array('0'=>$langs->trans("ContactPublic"), '1'=>$langs->trans("ContactPrivate"));
1012  print $form->selectarray('search_priv', $selectarray, $search_priv, 1);
1013  print '</td>';
1014 }
1015 // Prospect level
1016 if (!empty($arrayfields['p.fk_prospectcontactlevel']['checked'])) {
1017  print '<td class="liste_titre center">';
1018  print $form->multiselectarray('search_level', $tab_level, $search_level, 0, 0, 'width75', 0, 0, '', '', '', 2);
1019  print '</td>';
1020 }
1021 // Prospect status
1022 if (!empty($arrayfields['p.fk_stcommcontact']['checked'])) {
1023  print '<td class="liste_titre maxwidthonsmartphone center">';
1024  $arraystcomm = array();
1025  foreach ($contactstatic->cacheprospectstatus as $key => $val) {
1026  $arraystcomm[$val['id']] = ($langs->trans("StatusProspect".$val['id']) != "StatusProspect".$val['id'] ? $langs->trans("StatusProspect".$val['id']) : $val['label']);
1027  }
1028  print $form->selectarray('search_stcomm', $arraystcomm, $search_stcomm, -2, 0, 0, '', 0, 0, 0, '', 'nowrap ');
1029  print '</td>';
1030 }
1031 // Extra fields
1032 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
1033 
1034 // Fields from hook
1035 $parameters = array('arrayfields'=>$arrayfields);
1036 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1037 print $hookmanager->resPrint;
1038 // Date creation
1039 if (!empty($arrayfields['p.datec']['checked'])) {
1040  print '<td class="liste_titre">';
1041  print '</td>';
1042 }
1043 // Date modification
1044 if (!empty($arrayfields['p.tms']['checked'])) {
1045  print '<td class="liste_titre">';
1046  print '</td>';
1047 }
1048 // Status
1049 if (!empty($arrayfields['p.statut']['checked'])) {
1050  print '<td class="liste_titre center">';
1051  print $form->selectarray('search_status', array('-1'=>'', '0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), $search_status, 0, 0, 0, '', 0, 0, 0, '', 'minwidth75 onrightofpage');
1052  print '</td>';
1053 }
1054 if (!empty($arrayfields['p.import_key']['checked'])) {
1055  print '<td class="liste_titre center">';
1056  print '<input class="flat searchstring" type="text" name="search_import_key" size="3" value="'.dol_escape_htmltag($search_import_key).'">';
1057  print '</td>';
1058 }
1059 // Action column
1060 if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
1061  print '<td class="liste_titre maxwidthsearch">';
1062  $searchpicto = $form->showFilterAndCheckAddButtons(0);
1063  print $searchpicto;
1064  print '</td>';
1065 }
1066 print '</tr>';
1067 
1068 // Ligne des titres
1069 print '<tr class="liste_titre">';
1070 if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
1071  print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
1072 }
1073 if (!empty($arrayfields['p.rowid']['checked'])) {
1074  print_liste_field_titre($arrayfields['p.rowid']['label'], $_SERVER["PHP_SELF"], "p.rowid", "", $param, "", $sortfield, $sortorder);
1075 }
1076 if (!empty($arrayfields['p.lastname']['checked'])) {
1077  print_liste_field_titre($arrayfields['p.lastname']['label'], $_SERVER["PHP_SELF"], "p.lastname", $begin, $param, '', $sortfield, $sortorder);
1078 }
1079 if (!empty($arrayfields['p.firstname']['checked'])) {
1080  print_liste_field_titre($arrayfields['p.firstname']['label'], $_SERVER["PHP_SELF"], "p.firstname", $begin, $param, '', $sortfield, $sortorder);
1081 }
1082 if (!empty($arrayfields['p.poste']['checked'])) {
1083  print_liste_field_titre($arrayfields['p.poste']['label'], $_SERVER["PHP_SELF"], "p.poste", $begin, $param, '', $sortfield, $sortorder);
1084 }
1085 if (!empty($arrayfields['p.address']['checked'])) {
1086  print_liste_field_titre($arrayfields['p.address']['label'], $_SERVER["PHP_SELF"], "p.address", $begin, $param, '', $sortfield, $sortorder);
1087 }
1088 if (!empty($arrayfields['p.zip']['checked'])) {
1089  print_liste_field_titre($arrayfields['p.zip']['label'], $_SERVER["PHP_SELF"], "p.zip", $begin, $param, '', $sortfield, $sortorder);
1090 }
1091 if (!empty($arrayfields['p.town']['checked'])) {
1092  print_liste_field_titre($arrayfields['p.town']['label'], $_SERVER["PHP_SELF"], "p.town", $begin, $param, '', $sortfield, $sortorder);
1093 }
1094 //if (!empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'],$_SERVER["PHP_SELF"],"state.nom","",$param,'',$sortfield,$sortorder);
1095 //if (!empty($arrayfields['region.nom']['checked'])) print_liste_field_titre($arrayfields['region.nom']['label'],$_SERVER["PHP_SELF"],"region.nom","",$param,'',$sortfield,$sortorder);
1096 if (!empty($arrayfields['country.code_iso']['checked'])) {
1097  print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "co.code_iso", "", $param, '', $sortfield, $sortorder, 'center ');
1098 }
1099 if (!empty($arrayfields['p.phone']['checked'])) {
1100  print_liste_field_titre($arrayfields['p.phone']['label'], $_SERVER["PHP_SELF"], "p.phone", $begin, $param, '', $sortfield, $sortorder);
1101 }
1102 if (!empty($arrayfields['p.phone_perso']['checked'])) {
1103  print_liste_field_titre($arrayfields['p.phone_perso']['label'], $_SERVER["PHP_SELF"], "p.phone_perso", $begin, $param, '', $sortfield, $sortorder);
1104 }
1105 if (!empty($arrayfields['p.phone_mobile']['checked'])) {
1106  print_liste_field_titre($arrayfields['p.phone_mobile']['label'], $_SERVER["PHP_SELF"], "p.phone_mobile", $begin, $param, '', $sortfield, $sortorder);
1107 }
1108 if (!empty($arrayfields['p.fax']['checked'])) {
1109  print_liste_field_titre($arrayfields['p.fax']['label'], $_SERVER["PHP_SELF"], "p.fax", $begin, $param, '', $sortfield, $sortorder);
1110 }
1111 if (!empty($arrayfields['p.email']['checked'])) {
1112  print_liste_field_titre($arrayfields['p.email']['label'], $_SERVER["PHP_SELF"], "p.email", $begin, $param, '', $sortfield, $sortorder);
1113 }
1114 if (!empty($arrayfields['unsubscribed']['checked'])) {
1115  print_liste_field_titre($arrayfields['unsubscribed']['label'], $_SERVER["PHP_SELF"], "unsubscribed", $begin, $param, '', $sortfield, $sortorder, 'center ');
1116 }
1117 if (isModEnabled('socialnetworks')) {
1118  foreach ($socialnetworks as $key => $value) {
1119  if ($value['active'] && !empty($arrayfields['p.'.$key]['checked'])) {
1120  print_liste_field_titre($arrayfields['p.'.$key]['label'], $_SERVER["PHP_SELF"], "p.".$key, $begin, $param, '', $sortfield, $sortorder);
1121  }
1122  }
1123 }
1124 if (!empty($arrayfields['p.fk_soc']['checked'])) {
1125  print_liste_field_titre($arrayfields['p.fk_soc']['label'], $_SERVER["PHP_SELF"], "p.fk_soc", $begin, $param, '', $sortfield, $sortorder);
1126 }
1127 if (!empty($arrayfields['s.nom']['checked'])) {
1128  print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", $begin, $param, '', $sortfield, $sortorder);
1129 }
1130 if (!empty($arrayfields['s.name_alias']['checked'])) {
1131  print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"], "s.name_alias", $begin, $param, '', $sortfield, $sortorder);
1132 }
1133 if (!empty($arrayfields['p.priv']['checked'])) {
1134  print_liste_field_titre($arrayfields['p.priv']['label'], $_SERVER["PHP_SELF"], "p.priv", $begin, $param, '', $sortfield, $sortorder, 'center ');
1135 }
1136 if (!empty($arrayfields['p.fk_prospectcontactlevel']['checked'])) {
1137  print_liste_field_titre($arrayfields['p.fk_prospectcontactlevel']['label'], $_SERVER["PHP_SELF"], "p.fk_prospectcontactlevel", "", $param, '', $sortfield, $sortorder, 'center ');
1138 }
1139 if (!empty($arrayfields['p.fk_stcommcontact']['checked'])) {
1140  print_liste_field_titre($arrayfields['p.fk_stcommcontact']['label'], $_SERVER["PHP_SELF"], "p.fk_stcommcontact", "", $param, '', $sortfield, $sortorder, 'center ');
1141 }
1142 // Extra fields
1143 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
1144 // Hook fields
1145 $parameters = array(
1146  'arrayfields'=>$arrayfields,
1147  'param'=>$param,
1148  'sortfield'=>$sortfield,
1149  'sortorder'=>$sortorder,
1150 );
1151 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1152 print $hookmanager->resPrint;
1153 if (!empty($arrayfields['p.datec']['checked'])) {
1154  print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1155 }
1156 if (!empty($arrayfields['p.tms']['checked'])) {
1157  print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1158 }
1159 if (!empty($arrayfields['p.statut']['checked'])) {
1160  print_liste_field_titre($arrayfields['p.statut']['label'], $_SERVER["PHP_SELF"], "p.statut", "", $param, '', $sortfield, $sortorder, 'center ');
1161 }
1162 if (!empty($arrayfields['p.import_key']['checked'])) {
1163  print_liste_field_titre($arrayfields['p.import_key']['label'], $_SERVER["PHP_SELF"], "p.import_key", "", $param, '', $sortfield, $sortorder, 'center ');
1164 }
1165 if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
1166  print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
1167 }
1168 print "</tr>\n";
1169 
1170 
1171 $i = 0;
1172 $totalarray = array();
1173 $totalarray['nbfield'] = 0;
1174 while ($i < min($num, $limit)) {
1175  $obj = $db->fetch_object($resql);
1176 
1177  $arraysocialnetworks = (array) json_decode($obj->socialnetworks, true);
1178  $contactstatic->lastname = $obj->lastname;
1179  $contactstatic->firstname = '';
1180  $contactstatic->id = $obj->rowid;
1181  $contactstatic->statut = $obj->statut;
1182  $contactstatic->poste = $obj->poste;
1183  $contactstatic->email = $obj->email;
1184  $contactstatic->phone_pro = $obj->phone_pro;
1185  $contactstatic->phone_perso = $obj->phone_perso;
1186  $contactstatic->phone_mobile = $obj->phone_mobile;
1187  $contactstatic->address = $obj->address;
1188  $contactstatic->zip = $obj->zip;
1189  $contactstatic->town = $obj->town;
1190  $contactstatic->socialnetworks = $arraysocialnetworks;
1191  $contactstatic->country = $obj->country;
1192  $contactstatic->country_code = $obj->country_code;
1193  $contactstatic->photo = $obj->photo;
1194  $contactstatic->import_key = $obj->import_key;
1195 
1196  $contactstatic->fk_prospectlevel = $obj->fk_prospectcontactlevel;
1197 
1198  print '<tr class="oddeven">';
1199 
1200  // Action column
1201  if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
1202  print '<td class="nowrap center">';
1203  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1204  $selected = 0;
1205  if (in_array($obj->rowid, $arrayofselected)) {
1206  $selected = 1;
1207  }
1208  print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
1209  }
1210  print '</td>';
1211  }
1212  // ID
1213  if (!empty($arrayfields['p.rowid']['checked'])) {
1214  print '<td class="tdoverflowmax50">';
1215  print dol_escape_htmltag($obj->rowid);
1216  print "</td>\n";
1217  if (!$i) {
1218  $totalarray['nbfield']++;
1219  }
1220  }
1221  // Name
1222  if (!empty($arrayfields['p.lastname']['checked'])) {
1223  print '<td class="middle tdoverflowmax150">';
1224  print $contactstatic->getNomUrl(1);
1225  print '</td>';
1226  if (!$i) {
1227  $totalarray['nbfield']++;
1228  }
1229  }
1230  // Firstname
1231  if (!empty($arrayfields['p.firstname']['checked'])) {
1232  print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($obj->firstname).'">'.dol_escape_htmltag($obj->firstname).'</td>';
1233  if (!$i) {
1234  $totalarray['nbfield']++;
1235  }
1236  }
1237  // Job position
1238  if (!empty($arrayfields['p.poste']['checked'])) {
1239  print '<td class="tdoverflowmax100">'.dol_escape_htmltag($obj->poste).'</td>';
1240  if (!$i) {
1241  $totalarray['nbfield']++;
1242  }
1243  }
1244  // Address
1245  if (!empty($arrayfields['p.address']['checked'])) {
1246  print '<td>'.dol_escape_htmltag($obj->address).'</td>';
1247  if (!$i) {
1248  $totalarray['nbfield']++;
1249  }
1250  }
1251  // Zip
1252  if (!empty($arrayfields['p.zip']['checked'])) {
1253  print '<td>'.dol_escape_htmltag($obj->zip).'</td>';
1254  if (!$i) {
1255  $totalarray['nbfield']++;
1256  }
1257  }
1258  // Town
1259  if (!empty($arrayfields['p.town']['checked'])) {
1260  print '<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->town).'">'.dol_escape_htmltag($obj->town).'</td>';
1261  if (!$i) {
1262  $totalarray['nbfield']++;
1263  }
1264  }
1265  // State
1266  /*if (!empty($arrayfields['state.nom']['checked']))
1267  {
1268  print "<td>".$obj->state_name."</td>\n";
1269  if (! $i) $totalarray['nbfield']++;
1270  }
1271  // Region
1272  if (!empty($arrayfields['region.nom']['checked']))
1273  {
1274  print "<td>".$obj->region_name."</td>\n";
1275  if (! $i) $totalarray['nbfield']++;
1276  }*/
1277  // Country
1278  if (!empty($arrayfields['country.code_iso']['checked'])) {
1279  print '<td class="center">';
1280  $tmparray = getCountry($obj->fk_pays, 'all');
1281  print dol_escape_htmltag($tmparray['label']);
1282  print '</td>';
1283  if (!$i) {
1284  $totalarray['nbfield']++;
1285  }
1286  }
1287  // Phone
1288  if (!empty($arrayfields['p.phone']['checked'])) {
1289  print '<td class="nowraponall tdoverflowmax150">'.dol_print_phone($obj->phone_pro, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL', ' ', 'phone').'</td>';
1290  if (!$i) {
1291  $totalarray['nbfield']++;
1292  }
1293  }
1294  // Phone perso
1295  if (!empty($arrayfields['p.phone_perso']['checked'])) {
1296  print '<td class="nowraponall tdoverflowmax150">'.dol_print_phone($obj->phone_perso, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL', ' ', 'phone').'</td>';
1297  if (!$i) {
1298  $totalarray['nbfield']++;
1299  }
1300  }
1301  // Phone mobile
1302  if (!empty($arrayfields['p.phone_mobile']['checked'])) {
1303  print '<td class="nowraponall tdoverflowmax150">'.dol_print_phone($obj->phone_mobile, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL', ' ', 'mobile').'</td>';
1304  if (!$i) {
1305  $totalarray['nbfield']++;
1306  }
1307  }
1308  // Fax
1309  if (!empty($arrayfields['p.fax']['checked'])) {
1310  print '<td class="nowraponall tdoverflowmax150">'.dol_print_phone($obj->fax, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL', ' ', 'fax').'</td>';
1311  if (!$i) {
1312  $totalarray['nbfield']++;
1313  }
1314  }
1315  // EMail
1316  if (!empty($arrayfields['p.email']['checked'])) {
1317  print '<td class="nowraponall tdoverflowmax300">'.dol_print_email($obj->email, $obj->rowid, $obj->socid, 'AC_EMAIL', 18, 0, 1).'</td>';
1318  if (!$i) {
1319  $totalarray['nbfield']++;
1320  }
1321  }
1322  // No EMail
1323  if (!empty($arrayfields['unsubscribed']['checked'])) {
1324  print '<td class="center">';
1325  if (empty($obj->email)) {
1326  //print '<span class="opacitymedium">'.$langs->trans("NoEmail").'</span>';
1327  } else {
1328  print yn(($obj->unsubscribed > 0) ? 1 : 0);
1329  }
1330  print '</td>';
1331  if (!$i) {
1332  $totalarray['nbfield']++;
1333  }
1334  }
1335  if (isModEnabled('socialnetworks')) {
1336  foreach ($socialnetworks as $key => $value) {
1337  if ($value['active'] && !empty($arrayfields['p.'.$key]['checked'])) {
1338  print '<td class="tdoverflowmax100">'.(empty($arraysocialnetworks[$key]) ? '' : dol_print_socialnetworks($arraysocialnetworks[$key], $obj->rowid, $obj->socid, $key, $socialnetworks)).'</td>';
1339  if (!$i) {
1340  $totalarray['nbfield']++;
1341  }
1342  }
1343  }
1344  }
1345  // Company
1346  if (!empty($arrayfields['p.fk_soc']['checked']) || !empty($arrayfields['s.nom']['checked'])) {
1347  print '<td class="tdoverflowmax200">';
1348  if ($obj->socid) {
1349  $objsoc = new Societe($db);
1350  $objsoc->fetch($obj->socid);
1351  $option_link = 'customer';
1352  if ($objsoc->client == 0 && $objsoc->fournisseur > 0) {
1353  $option_link = 'supplier';
1354  }
1355  print $objsoc->getNomUrl(1, $option_link, 100, 0, 1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1);
1356  } else {
1357  print '&nbsp;';
1358  }
1359  print '</td>';
1360  if (!$i) {
1361  $totalarray['nbfield']++;
1362  }
1363  }
1364 
1365  // Alias name
1366  if (!empty($arrayfields['s.name_alias']['checked'])) {
1367  print '<td class="nocellnopadd">';
1368  print $obj->alias;
1369  print '</td>';
1370  if (!$i) {
1371  $totalarray['nbfield']++;
1372  }
1373  }
1374 
1375  // Private/Public
1376  if (!empty($arrayfields['p.priv']['checked'])) {
1377  print '<td class="center">'.$contactstatic->LibPubPriv($obj->priv).'</td>';
1378  if (!$i) {
1379  $totalarray['nbfield']++;
1380  }
1381  }
1382 
1383  if (!empty($arrayfields['p.fk_prospectcontactlevel']['checked'])) {
1384  // Prospect level
1385  print '<td class="center">';
1386  print $contactstatic->getLibProspLevel();
1387  print "</td>";
1388  if (!$i) {
1389  $totalarray['nbfield']++;
1390  }
1391  }
1392 
1393  if (!empty($arrayfields['p.fk_stcommcontact']['checked'])) {
1394  // Prospect status
1395  print '<td class="center nowrap"><div class="nowrap">';
1396  print '<div class="inline-block">'.$contactstatic->libProspCommStatut($obj->stcomm_id, 2, $contactstatic->cacheprospectstatus[$obj->stcomm_id]['label'], $obj->stcomm_picto);
1397  print '</div> - <div class="inline-block">';
1398  foreach ($contactstatic->cacheprospectstatus as $key => $val) {
1399  $titlealt = 'default';
1400  if (!empty($val['code']) && !in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) {
1401  $titlealt = $val['label'];
1402  }
1403  if ($obj->stcomm_id != $val['id']) {
1404  print '<a class="pictosubstatus" href="'.$_SERVER["PHP_SELF"].'?stcommcontactid='.$obj->rowid.'&stcomm='.urlencode($val['code']).'&action=setstcomm&token='.newToken().$param.($page ? '&page='.urlencode($page) : '').'">'.img_action($titlealt, $val['code'], $val['picto']).'</a>';
1405  }
1406  }
1407  print '</div></div></td>';
1408  if (!$i) {
1409  $totalarray['nbfield']++;
1410  }
1411  }
1412 
1413  // Extra fields
1414  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1415  // Fields from hook
1416  $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
1417  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1418  print $hookmanager->resPrint;
1419  // Date creation
1420  if (!empty($arrayfields['p.datec']['checked'])) {
1421  print '<td class="center nowraponall">';
1422  print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
1423  print '</td>';
1424  if (!$i) {
1425  $totalarray['nbfield']++;
1426  }
1427  }
1428  // Date modification
1429  if (!empty($arrayfields['p.tms']['checked'])) {
1430  print '<td class="center nowraponall">';
1431  print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
1432  print '</td>';
1433  if (!$i) {
1434  $totalarray['nbfield']++;
1435  }
1436  }
1437  // Status
1438  if (!empty($arrayfields['p.statut']['checked'])) {
1439  print '<td class="center">'.$contactstatic->getLibStatut(5).'</td>';
1440  if (!$i) {
1441  $totalarray['nbfield']++;
1442  }
1443  }
1444  // Import key
1445  if (!empty($arrayfields['p.import_key']['checked'])) {
1446  print '<td class="tdoverflowmax100">';
1447  print dol_escape_htmltag($obj->import_key);
1448  print "</td>\n";
1449  if (!$i) {
1450  $totalarray['nbfield']++;
1451  }
1452  }
1453 
1454  // Action column
1455  if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
1456  print '<td class="nowrap center">';
1457  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1458  $selected = 0;
1459  if (in_array($obj->rowid, $arrayofselected)) {
1460  $selected = 1;
1461  }
1462  print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
1463  }
1464  print '</td>';
1465  }
1466  if (!$i) {
1467  $totalarray['nbfield']++;
1468  }
1469 
1470  print "</tr>\n";
1471  $i++;
1472 }
1473 
1474 // Show total line
1475 include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
1476 
1477 // If no record found
1478 if ($num == 0) {
1479  $colspan = 1;
1480  foreach ($arrayfields as $key => $val) {
1481  if (!empty($val['checked'])) {
1482  $colspan++;
1483  }
1484  }
1485  print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
1486 }
1487 
1488 $db->free($resql);
1489 
1490 $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
1491 $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1492 print $hookmanager->resPrint;
1493 
1494 print '</table>'."\n";
1495 print '</div>'."\n";
1496 
1497 print '</form>'."\n";
1498 
1499 // End of page
1500 llxFooter();
1501 $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
llxFooter()
Empty footer.
Definition: wrapper.php:70
Class to manage contact/addresses.
Class to manage standard extra fields.
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...)
getCountry($searchkey, $withcode='', $dbtouse=0, $outputlangs='', $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
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
dol_print_socialnetworks($value, $cid, $socid, $type, $dictsocialnetworks=array())
Show social network link.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
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.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
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...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
img_action($titlealt, $numaction, $picto='')
Show logo action.
getArrayOfSocialNetworks()
Get array of social network dictionary.
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.
$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.