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