dolibarr  13.0.2
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 
36 require '../main.inc.php';
37 require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
38 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
39 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
40 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
41 
42 // Load translation files required by the page
43 $langs->loadLangs(array("companies", "suppliers", "categories"));
44 
45 $socialnetworks = getArrayOfSocialNetworks();
46 
47 $action = GETPOST('action', 'aZ09');
48 $massaction = GETPOST('massaction', 'alpha');
49 $show_files = GETPOST('show_files', 'int');
50 $confirm = GETPOST('confirm', 'alpha');
51 $toselect = GETPOST('toselect', 'array');
52 $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'contactlist';
53 
54 // Security check
55 $id = GETPOST('id', 'int');
56 $contactid = GETPOST('id', 'int');
57 $ref = ''; // There is no ref for contacts
58 if ($user->socid) $socid = $user->socid;
59 $result = restrictedArea($user, 'contact', $contactid, '');
60 
61 $sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
62 $search_cti = preg_replace('/^0+/', '', preg_replace('/[^0-9]/', '', GETPOST('search_cti', 'alphanohtml'))); // Phone number without any special chars
63 $search_phone = GETPOST("search_phone", 'alpha');
64 
65 $search_id = GETPOST("search_id", "int");
66 $search_firstlast_only = GETPOST("search_firstlast_only", 'alpha');
67 $search_lastname = GETPOST("search_lastname", 'alpha');
68 $search_firstname = GETPOST("search_firstname", 'alpha');
69 $search_societe = GETPOST("search_societe", 'alpha');
70 $search_poste = GETPOST("search_poste", 'alpha');
71 $search_phone_perso = GETPOST("search_phone_perso", 'alpha');
72 $search_phone_pro = GETPOST("search_phone_pro", 'alpha');
73 $search_phone_mobile = GETPOST("search_phone_mobile", 'alpha');
74 $search_fax = GETPOST("search_fax", 'alpha');
75 $search_email = GETPOST("search_email", 'alpha');
76 $search_no_email = GETPOST("search_no_email", 'int');
77 if (!empty($conf->socialnetworks->enabled)) {
78  foreach ($socialnetworks as $key => $value) {
79  if ($value['active']) {
80  $search_[$key] = GETPOST("search_".$key, 'alpha');
81  }
82  }
83 }
84 $search_priv = GETPOST("search_priv", 'alpha');
85 $search_categ = GETPOST("search_categ", 'int');
86 $search_categ_thirdparty = GETPOST("search_categ_thirdparty", 'int');
87 $search_categ_supplier = GETPOST("search_categ_supplier", 'int');
88 $search_status = GETPOST("search_status", 'int');
89 $search_type = GETPOST('search_type', 'alpha');
90 $search_zip = GETPOST('search_zip', 'alpha');
91 $search_town = GETPOST('search_town', 'alpha');
92 $search_import_key = GETPOST("search_import_key", "alpha");
93 $search_country = GETPOST("search_country", 'intcomma');
94 $search_roles = GETPOST("search_roles", 'array');
95 $search_level = GETPOST("search_level", "array");
96 $search_stcomm = GETPOST('search_stcomm', 'int');
97 
98 if ($search_status == '') $search_status = 1; // always display active customer first
99 
100 $optioncss = GETPOST('optioncss', 'alpha');
101 
102 
103 $type = GETPOST("type", 'aZ');
104 $view = GETPOST("view", 'alpha');
105 
106 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
107 $sortfield = GETPOST('sortfield', 'aZ09comma');
108 $sortorder = GETPOST('sortorder', 'aZ09comma');
109 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
110 $userid = GETPOST('userid', 'int');
111 $begin = GETPOST('begin');
112 if (!$sortorder) $sortorder = "ASC";
113 if (!$sortfield) $sortfield = "p.lastname";
114 if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { $page = 0; }
115 $offset = $limit * $page;
116 
117 $titre = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("ListOfContacts") : $langs->trans("ListOfContactsAddresses"));
118 if ($type == "p")
119 {
120  if (empty($contextpage) || $contextpage == 'contactlist') $contextpage = 'contactprospectlist';
121  $titre .= ' ('.$langs->trans("ThirdPartyProspects").')';
122  $urlfiche = "card.php";
123 }
124 if ($type == "c")
125 {
126  if (empty($contextpage) || $contextpage == 'contactlist') $contextpage = 'contactcustomerlist';
127  $titre .= ' ('.$langs->trans("ThirdPartyCustomers").')';
128  $urlfiche = "card.php";
129 } elseif ($type == "f")
130 {
131  if (empty($contextpage) || $contextpage == 'contactlist') $contextpage = 'contactsupplierlist';
132  $titre .= ' ('.$langs->trans("ThirdPartySuppliers").')';
133  $urlfiche = "card.php";
134 } elseif ($type == "o")
135 {
136  if (empty($contextpage) || $contextpage == 'contactlist') $contextpage = 'contactotherlist';
137  $titre .= ' ('.$langs->trans("OthersNotLinkedToThirdParty").')';
138  $urlfiche = "";
139 }
140 
141 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
142 $object = new Contact($db);
143 $hookmanager->initHooks(array('contactlist'));
144 $extrafields = new ExtraFields($db);
145 
146 // fetch optionals attributes and labels
147 $extrafields->fetch_name_optionals_label($object->table_element);
148 
149 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
150 
151 // List of fields to search into when doing a "search in all"
152 $fieldstosearchall = array();
153 foreach ($object->fields as $key => $val)
154 {
155  // don't allow search in private notes for external users when doing "search in all"
156  if (!empty($user->socid) && $key == "note_private") {
157  continue;
158  }
159 
160  if (empty($val['searchall'])) {
161  continue;
162  }
163 
164  $fieldstosearchall['p.'.$key] = $val['label'];
165 }
166 
167 // Add none object fields for "search in all"
168 if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) {
169  $fieldstosearchall['s.nom'] = "ThirdParty";
170 }
171 
172 // Definition of fields for list
173 $arrayfields = array();
174 foreach ($object->fields as $key => $val) {
175  // If $val['visible']==0, then we never show the field
176  if (empty($val['visible'])) {
177  continue;
178  }
179 
180  $arrayfields['p.'.$key] = array(
181  'label'=>$val['label'],
182  'checked'=>(($val['visible'] < 0) ? 0 : 1),
183  'enabled'=>($val['enabled'] && ($val['visible'] != 3)),
184  'position'=>$val['position']);
185 }
186 
187 // Add none object fields to fields for list
188 $arrayfields['country.code_iso'] = array('label'=>"Country", 'position'=>22, 'checked'=>0);
189 if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) {
190  $arrayfields['s.nom'] = array('label'=>"ThirdParty", 'position'=>25, 'checked'=>1);
191 }
192 
193 if (!empty($conf->socialnetworks->enabled)) {
194  foreach ($socialnetworks as $key => $value) {
195  if ($value['active']) {
196  $arrayfields['p.'.$key] = array(
197  'label' => $value['label'],
198  'checked' => 0,
199  'position' => 300
200  );
201  }
202  }
203 }
204 
205 // Extra fields
206 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
207 
208 $object->fields = dol_sort_array($object->fields, 'position');
209 $arrayfields = dol_sort_array($arrayfields, 'position');
210 
211 
212 if (($id > 0 || !empty($ref)) && $action != 'add')
213 {
214  $result = $object->fetch($id, $ref);
215  if ($result < 0) dol_print_error($db);
216 }
217 
218 
219 /*
220  * Actions
221  */
222 
223 if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
224 if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
225 
226 $parameters = array();
227 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
228 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
229 
230 if (empty($reshook))
231 {
232  // Selection of new fields
233  include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
234 
235  // Did we click on purge search criteria ?
236  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
237  {
238  $sall = "";
239  $search_id = '';
240  $search_firstlast_only = "";
241  $search_lastname = "";
242  $search_firstname = "";
243  $search_societe = "";
244  $search_town = "";
245  $search_zip = "";
246  $search_country = "";
247  $search_poste = "";
248  $search_phone = "";
249  $search_phone_perso = "";
250  $search_phone_pro = "";
251  $search_phone_mobile = "";
252  $search_fax = "";
253  $search_email = "";
254  $search_no_email = -1;
255  if (!empty($conf->socialnetworks->enabled)) {
256  foreach ($socialnetworks as $key => $value) {
257  if ($value['active']) {
258  $search_[$key] = "";
259  }
260  }
261  }
262  $search_priv = "";
263  $search_stcomm = '';
264  $search_level = '';
265  $search_status = -1;
266  $search_categ = '';
267  $search_categ_thirdparty = '';
268  $search_categ_supplier = '';
269  $search_import_key = '';
270  $toselect = '';
271  $search_array_options = array();
272  $search_roles = array();
273  }
274 
275  // Mass actions
276  $objectclass = 'Contact';
277  $objectlabel = 'Contact';
278  $permissiontoread = $user->rights->societe->lire;
279  $permissiontodelete = $user->rights->societe->supprimer;
280  $uploaddir = $conf->societe->dir_output;
281  include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
282 
283  if ($action == 'setstcomm')
284  {
285  $object = new Contact($db);
286  $result = $object->fetch(GETPOST('stcommcontactid'));
287  $object->stcomm_id = dol_getIdFromCode($db, GETPOST('stcomm', 'alpha'), 'c_stcommcontact');
288  $result = $object->update($object->id, $user);
289  if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
290 
291  $action = '';
292  }
293 }
294 
295 if ($search_priv < 0) $search_priv = '';
296 
297 
298 /*
299  * View
300  */
301 
302 $form = new Form($db);
303 $formother = new FormOther($db);
304 $formcompany = new FormCompany($db);
305 $contactstatic = new Contact($db);
306 
307 if (!empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES)) {
308  $contactstatic->loadCacheOfProspStatus();
309 }
310 
311 $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
312 
313 // Select every potentiels, and note each potentiels which fit in search parameters
314 $tab_level = array();
315 $sql = "SELECT code, label, sortorder";
316 $sql .= " FROM ".MAIN_DB_PREFIX."c_prospectcontactlevel";
317 $sql .= " WHERE active > 0";
318 $sql .= " ORDER BY sortorder";
319 $resql = $db->query($sql);
320 if ($resql)
321 {
322  while ($obj = $db->fetch_object($resql))
323  {
324  // Compute level text
325  $level = $langs->trans($obj->code);
326  if ($level == $obj->code) $level = $langs->trans($obj->label);
327  $tab_level[$obj->code] = $level;
328  }
329 }
330 else dol_print_error($db);
331 
332 $sql = "SELECT s.rowid as socid, s.nom as name,";
333 $sql .= " p.rowid, p.lastname as lastname, p.statut, p.firstname, p.zip, p.town, p.poste, p.email, p.no_email,";
334 $sql .= " p.socialnetworks, p.photo,";
335 $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,";
336 $sql .= " st.libelle as stcomm, st.picto as stcomm_picto, p.fk_stcommcontact as stcomm_id, p.fk_prospectcontactlevel,";
337 $sql .= " co.label as country, co.code as country_code";
338 // Add fields from extrafields
339 if (!empty($extrafields->attributes[$object->table_element]['label'])) {
340  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : '');
341 }
342 // Add fields from hooks
343 $parameters = array();
344 $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
345 $sql .= $hookmanager->resPrint;
346 $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as p";
347 if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (p.rowid = ef.fk_object)";
348 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = p.fk_pays";
349 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc";
350 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_stcommcontact as st ON st.id = p.fk_stcommcontact";
351 if (!empty($search_categ)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_contact as cc ON p.rowid = cc.fk_socpeople"; // We need this table joined to the select in order to filter by categ
352 if (!empty($search_categ_thirdparty)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cs ON s.rowid = cs.fk_soc"; // We need this table joined to the select in order to filter by categ
353 if (!empty($search_categ_supplier)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_fournisseur as cs2 ON s.rowid = cs2.fk_soc"; // We need this table joined to the select in order to filter by categ
354 if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
355 $sql .= ' WHERE p.entity IN ('.getEntity('socpeople').')';
356 if (!$user->rights->societe->client->voir && !$socid) //restriction
357 {
358  $sql .= " AND (sc.fk_user = ".$user->id." OR p.fk_soc IS NULL)";
359 }
360 if (!empty($userid)) // propre au commercial
361 {
362  $sql .= " AND p.fk_user_creat=".$db->escape($userid);
363 }
364 if ($search_level) $sql .= natural_search("p.fk_prospectcontactlevel", join(',', $search_level), 3);
365 if ($search_stcomm != '' && $search_stcomm != -2) $sql .= natural_search("p.fk_stcommcontact", $search_stcomm, 2);
366 
367 // Filter to exclude not owned private contacts
368 if ($search_priv != '0' && $search_priv != '1')
369 {
370  $sql .= " AND (p.priv='0' OR (p.priv='1' AND p.fk_user_creat=".$user->id."))";
371 } else {
372  if ($search_priv == '0') $sql .= " AND p.priv='0'";
373  if ($search_priv == '1') $sql .= " AND (p.priv='1' AND p.fk_user_creat=".$user->id.")";
374 }
375 
376 if ($search_categ > 0) $sql .= " AND cc.fk_categorie = ".$db->escape($search_categ);
377 if ($search_categ == -2) $sql .= " AND cc.fk_categorie IS NULL";
378 if ($search_categ_thirdparty > 0) $sql .= " AND cs.fk_categorie = ".$db->escape($search_categ_thirdparty);
379 if ($search_categ_thirdparty == -2) $sql .= " AND cs.fk_categorie IS NULL";
380 if ($search_categ_supplier > 0) $sql .= " AND cs2.fk_categorie = ".$db->escape($search_categ_supplier);
381 if ($search_categ_supplier == -2) $sql .= " AND cs2.fk_categorie IS NULL";
382 
383 if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall);
384 if (strlen($search_phone)) $sql .= natural_search(array('p.phone', 'p.phone_perso', 'p.phone_mobile'), $search_phone);
385 if (strlen($search_cti)) $sql .= natural_search(array('p.phone', 'p.phone_perso', 'p.phone_mobile'), $search_cti);
386 if (strlen($search_firstlast_only)) $sql .= natural_search(array('p.lastname', 'p.firstname'), $search_firstlast_only);
387 
388 if ($search_id > 0) $sql .= natural_search('p.rowid', $search_id, 1);
389 if ($search_lastname) $sql .= natural_search('p.lastname', $search_lastname);
390 if ($search_firstname) $sql .= natural_search('p.firstname', $search_firstname);
391 if ($search_societe) $sql .= natural_search(empty($conf->global->SOCIETE_DISABLE_CONTACTS) ? 's.nom' : 'p.fk_soc', $search_societe);
392 if ($search_country) $sql .= " AND p.fk_pays IN (".$search_country.')';
393 if (strlen($search_poste)) $sql .= natural_search('p.poste', $search_poste);
394 if (strlen($search_phone_perso)) $sql .= natural_search('p.phone_perso', $search_phone_perso);
395 if (strlen($search_phone_pro)) $sql .= natural_search('p.phone', $search_phone_pro);
396 if (strlen($search_phone_mobile)) $sql .= natural_search('p.phone_mobile', $search_phone_mobile);
397 if (strlen($search_fax)) $sql .= natural_search('p.fax', $search_fax);
398 if (!empty($conf->socialnetworks->enabled)) {
399  foreach ($socialnetworks as $key => $value) {
400  if ($value['active'] && strlen($search_[$key])) {
401  $sql .= ' AND p.socialnetworks LIKE \'%"'.$key.'":"'.$search_[$key].'%\'';
402  }
403  }
404 }
405 if (strlen($search_email)) $sql .= natural_search('p.email', $search_email);
406 if (strlen($search_zip)) $sql .= natural_search("p.zip", $search_zip);
407 if (strlen($search_town)) $sql .= natural_search("p.town", $search_town);
408 if (count($search_roles) > 0) {
409  $sql .= " AND p.rowid IN (SELECT sc.fk_socpeople FROM ".MAIN_DB_PREFIX."societe_contacts as sc WHERE sc.fk_c_type_contact IN (".implode(',', $search_roles)."))";
410 }
411 
412 if ($search_no_email != '' && $search_no_email >= 0) $sql .= " AND p.no_email = ".$db->escape($search_no_email);
413 if ($search_status != '' && $search_status >= 0) $sql .= " AND p.statut = ".$db->escape($search_status);
414 if ($search_import_key) $sql .= natural_search("p.import_key", $search_import_key);
415 if ($type == "o") // filtre sur type
416 {
417  $sql .= " AND p.fk_soc IS NULL";
418 } elseif ($type == "f") // filtre sur type
419 {
420  $sql .= " AND s.fournisseur = 1";
421 } elseif ($type == "c") // filtre sur type
422 {
423  $sql .= " AND s.client IN (1, 3)";
424 } elseif ($type == "p") // filtre sur type
425 {
426  $sql .= " AND s.client IN (2, 3)";
427 }
428 if (!empty($socid))
429 {
430  $sql .= " AND s.rowid = ".$socid;
431 }
432 // Add where from extra fields
433 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
434 // Add where from hooks
435 $parameters = array();
436 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
437 $sql .= $hookmanager->resPrint;
438 // Add order
439 if ($view == "recent")
440 {
441  $sql .= $db->order("p.datec", "DESC");
442 } else {
443  $sql .= $db->order($sortfield, $sortorder);
444 }
445 
446 // Count total nb of records
447 $nbtotalofrecords = '';
448 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
449 {
450  $resql = $db->query($sql);
451  $nbtotalofrecords = $db->num_rows($resql);
452  if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
453  {
454  $page = 0;
455  $offset = 0;
456  }
457 }
458 
459 $sql .= $db->plimit($limit + 1, $offset);
460 
461 $resql = $db->query($sql);
462 if (!$resql)
463 {
464  dol_print_error($db);
465  exit;
466 }
467 
468 $num = $db->num_rows($resql);
469 
470 $arrayofselected = is_array($toselect) ? $toselect : array();
471 
472 if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && ($sall != '' || $search_cti != ''))
473 {
474  $obj = $db->fetch_object($resql);
475  $id = $obj->rowid;
476  header("Location: ".DOL_URL_ROOT.'/contact/card.php?id='.$id);
477  exit;
478 }
479 
480 $help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:M&oacute;dulo_Empresas';
481 llxHeader('', $title, $help_url);
482 
483 $param = '';
484 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&amp;contextpage='.$contextpage;
485 if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&amp;limit='.$limit;
486 $param .= '&amp;begin='.urlencode($begin).'&amp;userid='.urlencode($userid).'&amp;contactname='.urlencode($sall);
487 $param .= '&amp;type='.urlencode($type).'&amp;view='.urlencode($view);
488 if (!empty($search_categ)) $param .= '&amp;search_categ='.urlencode($search_categ);
489 if (!empty($search_categ_thirdparty)) $param .= '&amp;search_categ_thirdparty='.urlencode($search_categ_thirdparty);
490 if (!empty($search_categ_supplier)) $param .= '&amp;search_categ_supplier='.urlencode($search_categ_supplier);
491 if ($sall != '') $param .= '&amp;sall='.urlencode($sall);
492 if ($search_id > 0) $param .= "&amp;search_id=".urlencode($search_id);
493 if ($search_lastname != '') $param .= '&amp;search_lastname='.urlencode($search_lastname);
494 if ($search_firstname != '') $param .= '&amp;search_firstname='.urlencode($search_firstname);
495 if ($search_societe != '') $param .= '&amp;search_societe='.urlencode($search_societe);
496 if ($search_zip != '') $param .= '&amp;search_zip='.urlencode($search_zip);
497 if ($search_town != '') $param .= '&amp;search_town='.urlencode($search_town);
498 if ($search_country != '') $param .= "&search_country=".urlencode($search_country);
499 if ($search_poste != '') $param .= '&amp;search_poste='.urlencode($search_poste);
500 if ($search_phone_pro != '') $param .= '&amp;search_phone_pro='.urlencode($search_phone_pro);
501 if ($search_phone_perso != '') $param .= '&amp;search_phone_perso='.urlencode($search_phone_perso);
502 if ($search_phone_mobile != '') $param .= '&amp;search_phone_mobile='.urlencode($search_phone_mobile);
503 if ($search_fax != '') $param .= '&amp;search_fax='.urlencode($search_fax);
504 if ($search_email != '') $param .= '&amp;search_email='.urlencode($search_email);
505 if ($search_no_email != '') $param .= '&amp;search_no_email='.urlencode($search_no_email);
506 if ($search_status != '') $param .= '&amp;search_status='.urlencode($search_status);
507 if ($search_priv == '0' || $search_priv == '1') $param .= "&amp;search_priv=".urlencode($search_priv);
508 if ($search_stcomm != '') $param .= '&search_stcomm='.urlencode($search_stcomm);
509 if (is_array($search_level) && count($search_level)) {
510  foreach ($search_level as $slevel) {
511  $param .= '&search_level[]='.urlencode($slevel);
512  }
513 }
514 if ($search_import_key != '') $param .= '&amp;search_import_key='.urlencode($search_import_key);
515 if ($optioncss != '') $param .= '&amp;optioncss='.urlencode($optioncss);
516 if (count($search_roles) > 0) $param .= implode('&search_roles[]=', $search_roles);
517 
518 // Add $param from extra fields
519 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
520 
521 // List of mass actions available
522 $arrayofmassactions = array(
523 // 'presend'=>$langs->trans("SendByMail"),
524 // 'builddoc'=>$langs->trans("PDFMerge"),
525 );
526 //if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer");
527 if ($user->rights->societe->supprimer) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
528 if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array();
529 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
530 
531 $newcardbutton = dolGetButtonTitle($langs->trans('NewContactAddress'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/contact/card.php?action=create', '', $user->rights->societe->contact->creer);
532 
533 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'" name="formfilter">';
534 if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
535 print '<input type="hidden" name="token" value="'.newToken().'">';
536 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
537 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
538 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
539 //print '<input type="hidden" name="page" value="'.$page.'">';
540 print '<input type="hidden" name="type" value="'.$type.'">';
541 print '<input type="hidden" name="view" value="'.dol_escape_htmltag($view).'">';
542 
543 print_barre_liste($titre, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'address', 0, $newcardbutton, '', $limit, 0, 0, 1);
544 
545 $topicmail = "Information";
546 $modelmail = "contact";
547 $objecttmp = new Contact($db);
548 $trackid = 'ctc'.$object->id;
549 include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
550 
551 if ($sall)
552 {
553  foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val);
554  print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>';
555 }
556 if ($search_firstlast_only)
557 {
558  print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_firstlast_only).$langs->trans("Lastname").", ".$langs->trans("Firstname").'</div>';
559 }
560 
561 $moreforfilter = '';
562 if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire)
563 {
564  require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
565  $moreforfilter .= '<div class="divsearchfield">';
566  $moreforfilter .= $langs->trans('Categories').': ';
567  $moreforfilter .= $formother->select_categories(Categorie::TYPE_CONTACT, $search_categ, 'search_categ', 1);
568  $moreforfilter .= '</div>';
569  if (empty($type) || $type == 'c' || $type == 'p')
570  {
571  $moreforfilter .= '<div class="divsearchfield">';
572  if ($type == 'c') $moreforfilter .= $langs->trans('CustomersCategoriesShort').': ';
573  elseif ($type == 'p') $moreforfilter .= $langs->trans('ProspectsCategoriesShort').': ';
574  else $moreforfilter .= $langs->trans('CustomersProspectsCategoriesShort').': ';
575  $moreforfilter .= $formother->select_categories(Categorie::TYPE_CUSTOMER, $search_categ_thirdparty, 'search_categ_thirdparty', 1);
576  $moreforfilter .= '</div>';
577  }
578  if (empty($type) || $type == 'f')
579  {
580  $moreforfilter .= '<div class="divsearchfield">';
581  $moreforfilter .= $langs->trans('SuppliersCategoriesShort').': ';
582  $moreforfilter .= $formother->select_categories(Categorie::TYPE_SUPPLIER, $search_categ_supplier, 'search_categ_supplier', 1);
583  $moreforfilter .= '</div>';
584  }
585 }
586 
587 $moreforfilter .= '<div class="divsearchfield">';
588 $moreforfilter .= $langs->trans('Roles').': ';
589 $moreforfilter .= $formcompany->showRoles("search_roles", $objecttmp, 'edit', $search_roles);
590 $moreforfilter .= '</div>';
591 
592 print '<div class="liste_titre liste_titre_bydiv centpercent">';
593 print $moreforfilter;
594 $parameters = array('type'=>$type);
595 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
596 print $hookmanager->resPrint;
597 print '</div>';
598 
599 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
600 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
601 if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
602 
603 print '<div class="div-table-responsive">';
604 print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
605 
606 // Lines for filter fields
607 print '<tr class="liste_titre_filter">';
608 if (!empty($arrayfields['p.rowid']['checked']))
609 {
610  print '<td class="liste_titre">';
611  print '<input class="flat searchstring" type="text" name="search_id" size="1" value="'.dol_escape_htmltag($search_id).'">';
612  print '</td>';
613 }
614 if (!empty($arrayfields['p.lastname']['checked']))
615 {
616  print '<td class="liste_titre">';
617  print '<input class="flat" type="text" name="search_lastname" size="6" value="'.dol_escape_htmltag($search_lastname).'">';
618  print '</td>';
619 }
620 if (!empty($arrayfields['p.firstname']['checked']))
621 {
622  print '<td class="liste_titre">';
623  print '<input class="flat" type="text" name="search_firstname" size="6" value="'.dol_escape_htmltag($search_firstname).'">';
624  print '</td>';
625 }
626 if (!empty($arrayfields['p.poste']['checked']))
627 {
628  print '<td class="liste_titre">';
629  print '<input class="flat" type="text" name="search_poste" size="5" value="'.dol_escape_htmltag($search_poste).'">';
630  print '</td>';
631 }
632 if (!empty($arrayfields['p.zip']['checked']))
633 {
634  print '<td class="liste_titre">';
635  print '<input class="flat" type="text" name="search_zip" size="3" value="'.dol_escape_htmltag($search_zip).'">';
636  print '</td>';
637 }
638 if (!empty($arrayfields['p.town']['checked']))
639 {
640  print '<td class="liste_titre">';
641  print '<input class="flat" type="text" name="search_town" size="5" value="'.dol_escape_htmltag($search_town).'">';
642  print '</td>';
643 }
644 // State
645 /*if (! empty($arrayfields['state.nom']['checked']))
646  {
647  print '<td class="liste_titre">';
648  print '<input class="flat searchstring" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
649  print '</td>';
650  }
651  // Region
652  if (! empty($arrayfields['region.nom']['checked']))
653  {
654  print '<td class="liste_titre">';
655  print '<input class="flat searchstring" size="4" type="text" name="search_region" value="'.dol_escape_htmltag($search_region).'">';
656  print '</td>';
657  }*/
658 // Country
659 if (!empty($arrayfields['country.code_iso']['checked']))
660 {
661  print '<td class="liste_titre center">';
662  print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100');
663  print '</td>';
664 }
665 if (!empty($arrayfields['p.phone']['checked']))
666 {
667  print '<td class="liste_titre">';
668  print '<input class="flat" type="text" name="search_phone_pro" size="6" value="'.dol_escape_htmltag($search_phone_pro).'">';
669  print '</td>';
670 }
671 if (!empty($arrayfields['p.phone_perso']['checked']))
672 {
673  print '<td class="liste_titre">';
674  print '<input class="flat" type="text" name="search_phone_perso" size="6" value="'.dol_escape_htmltag($search_phone_perso).'">';
675  print '</td>';
676 }
677 if (!empty($arrayfields['p.phone_mobile']['checked']))
678 {
679  print '<td class="liste_titre">';
680  print '<input class="flat" type="text" name="search_phone_mobile" size="6" value="'.dol_escape_htmltag($search_phone_mobile).'">';
681  print '</td>';
682 }
683 if (!empty($arrayfields['p.fax']['checked']))
684 {
685  print '<td class="liste_titre">';
686  print '<input class="flat" type="text" name="search_fax" size="6" value="'.dol_escape_htmltag($search_fax).'">';
687  print '</td>';
688 }
689 if (!empty($arrayfields['p.email']['checked']))
690 {
691  print '<td class="liste_titre">';
692  print '<input class="flat" type="text" name="search_email" size="6" value="'.dol_escape_htmltag($search_email).'">';
693  print '</td>';
694 }
695 if (!empty($arrayfields['p.no_email']['checked']))
696 {
697  print '<td class="liste_titre center">';
698  print $form->selectarray('search_no_email', array('-1'=>'', '0'=>$langs->trans('No'), '1'=>$langs->trans('Yes')), $search_no_email);
699  print '</td>';
700 }
701 if (!empty($conf->socialnetworks->enabled)) {
702  foreach ($socialnetworks as $key => $value) {
703  if ($value['active']) {
704  if (!empty($arrayfields['p.'.$key]['checked']))
705  {
706  print '<td class="liste_titre">';
707  print '<input class="flat" type="text" name="search_'.$key.'" size="6" value="'.dol_escape_htmltag($search_[$key]).'">';
708  print '</td>';
709  }
710  }
711  }
712 }
713 if (!empty($arrayfields['p.fk_soc']['checked']) || !empty($arrayfields['s.nom']['checked']))
714 {
715  print '<td class="liste_titre">';
716  print '<input class="flat" type="text" name="search_societe" size="8" value="'.dol_escape_htmltag($search_societe).'">';
717  print '</td>';
718 }
719 if (!empty($arrayfields['p.priv']['checked']))
720 {
721  print '<td class="liste_titre center">';
722  $selectarray = array('0'=>$langs->trans("ContactPublic"), '1'=>$langs->trans("ContactPrivate"));
723  print $form->selectarray('search_priv', $selectarray, $search_priv, 1);
724  print '</td>';
725 }
726 // Prospect level
727 if (!empty($arrayfields['p.fk_prospectcontactlevel']['checked']))
728 {
729  print '<td class="liste_titre center">';
730  print $form->multiselectarray('search_level', $tab_level, $search_level, 0, 0, 'width75', 0, 0, '', '', '', 2);
731  print '</td>';
732 }
733 // Prospect status
734 if (!empty($arrayfields['p.fk_stcommcontact']['checked']))
735 {
736  print '<td class="liste_titre maxwidthonsmartphone center">';
737  $arraystcomm = array();
738  foreach ($contactstatic->cacheprospectstatus as $key => $val)
739  {
740  $arraystcomm[$val['id']] = ($langs->trans("StatusProspect".$val['id']) != "StatusProspect".$val['id'] ? $langs->trans("StatusProspect".$val['id']) : $val['label']);
741  }
742  print $form->selectarray('search_stcomm', $arraystcomm, $search_stcomm, -2, 0, 0, '', 0, 0, 0, '', 'nowrap ');
743  print '</td>';
744 }
745 // Extra fields
746 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
747 
748 // Fields from hook
749 $parameters = array('arrayfields'=>$arrayfields);
750 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
751 print $hookmanager->resPrint;
752 // Date creation
753 if (!empty($arrayfields['p.datec']['checked']))
754 {
755  print '<td class="liste_titre">';
756  print '</td>';
757 }
758 // Date modification
759 if (!empty($arrayfields['p.tms']['checked']))
760 {
761  print '<td class="liste_titre">';
762  print '</td>';
763 }
764 // Status
765 if (!empty($arrayfields['p.statut']['checked']))
766 {
767  print '<td class="liste_titre center">';
768  print $form->selectarray('search_status', array('-1'=>'', '0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), $search_status);
769  print '</td>';
770 }
771 if (!empty($arrayfields['p.import_key']['checked']))
772 {
773  print '<td class="liste_titre center">';
774  print '<input class="flat searchstring" type="text" name="search_import_key" size="3" value="'.dol_escape_htmltag($search_import_key).'">';
775  print '</td>';
776 }
777 // Action column
778 print '<td class="liste_titre maxwidthsearch">';
779 $searchpicto = $form->showFilterAndCheckAddButtons(0);
780 print $searchpicto;
781 print '</td>';
782 
783 print '</tr>';
784 
785 // Ligne des titres
786 print '<tr class="liste_titre">';
787 if (!empty($arrayfields['p.rowid']['checked'])) print_liste_field_titre($arrayfields['p.rowid']['label'], $_SERVER["PHP_SELF"], "p.rowid", "", $param, "", $sortfield, $sortorder);
788 if (!empty($arrayfields['p.lastname']['checked'])) print_liste_field_titre($arrayfields['p.lastname']['label'], $_SERVER["PHP_SELF"], "p.lastname", $begin, $param, '', $sortfield, $sortorder);
789 if (!empty($arrayfields['p.firstname']['checked'])) print_liste_field_titre($arrayfields['p.firstname']['label'], $_SERVER["PHP_SELF"], "p.firstname", $begin, $param, '', $sortfield, $sortorder);
790 if (!empty($arrayfields['p.poste']['checked'])) print_liste_field_titre($arrayfields['p.poste']['label'], $_SERVER["PHP_SELF"], "p.poste", $begin, $param, '', $sortfield, $sortorder);
791 if (!empty($arrayfields['p.zip']['checked'])) print_liste_field_titre($arrayfields['p.zip']['label'], $_SERVER["PHP_SELF"], "p.zip", $begin, $param, '', $sortfield, $sortorder);
792 if (!empty($arrayfields['p.town']['checked'])) print_liste_field_titre($arrayfields['p.town']['label'], $_SERVER["PHP_SELF"], "p.town", $begin, $param, '', $sortfield, $sortorder);
793 //if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'],$_SERVER["PHP_SELF"],"state.nom","",$param,'',$sortfield,$sortorder);
794 //if (! empty($arrayfields['region.nom']['checked'])) print_liste_field_titre($arrayfields['region.nom']['label'],$_SERVER["PHP_SELF"],"region.nom","",$param,'',$sortfield,$sortorder);
795 if (!empty($arrayfields['country.code_iso']['checked'])) {
796  print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "co.code_iso", "", $param, '', $sortfield, $sortorder, 'center ');
797 }
798 if (!empty($arrayfields['p.phone']['checked'])) print_liste_field_titre($arrayfields['p.phone']['label'], $_SERVER["PHP_SELF"], "p.phone", $begin, $param, '', $sortfield, $sortorder);
799 if (!empty($arrayfields['p.phone_perso']['checked'])) print_liste_field_titre($arrayfields['p.phone_perso']['label'], $_SERVER["PHP_SELF"], "p.phone_perso", $begin, $param, '', $sortfield, $sortorder);
800 if (!empty($arrayfields['p.phone_mobile']['checked'])) print_liste_field_titre($arrayfields['p.phone_mobile']['label'], $_SERVER["PHP_SELF"], "p.phone_mobile", $begin, $param, '', $sortfield, $sortorder);
801 if (!empty($arrayfields['p.fax']['checked'])) print_liste_field_titre($arrayfields['p.fax']['label'], $_SERVER["PHP_SELF"], "p.fax", $begin, $param, '', $sortfield, $sortorder);
802 if (!empty($arrayfields['p.email']['checked'])) print_liste_field_titre($arrayfields['p.email']['label'], $_SERVER["PHP_SELF"], "p.email", $begin, $param, '', $sortfield, $sortorder);
803 if (!empty($arrayfields['p.no_email']['checked'])) print_liste_field_titre($arrayfields['p.no_email']['label'], $_SERVER["PHP_SELF"], "p.no_email", $begin, $param, '', $sortfield, $sortorder, 'center ');
804 if (!empty($conf->socialnetworks->enabled)) {
805  foreach ($socialnetworks as $key => $value) {
806  if ($value['active'] && !empty($arrayfields['p.'.$key]['checked'])) {
807  print_liste_field_titre($arrayfields['p.'.$key]['label'], $_SERVER["PHP_SELF"], "p.".$key, $begin, $param, '', $sortfield, $sortorder);
808  }
809  }
810 }
811 if (!empty($arrayfields['p.fk_soc']['checked'])) print_liste_field_titre($arrayfields['p.fk_soc']['label'], $_SERVER["PHP_SELF"], "p.fk_soc", $begin, $param, '', $sortfield, $sortorder);
812 if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", $begin, $param, '', $sortfield, $sortorder);
813 if (!empty($arrayfields['p.priv']['checked'])) print_liste_field_titre($arrayfields['p.priv']['label'], $_SERVER["PHP_SELF"], "p.priv", $begin, $param, '', $sortfield, $sortorder, 'center ');
814 if (!empty($arrayfields['p.fk_prospectcontactlevel']['checked'])) print_liste_field_titre($arrayfields['p.fk_prospectcontactlevel']['label'], $_SERVER["PHP_SELF"], "p.fk_prospectcontactlevel", "", $param, '', $sortfield, $sortorder, 'center ');
815 if (!empty($arrayfields['p.fk_stcommcontact']['checked'])) print_liste_field_titre($arrayfields['p.fk_stcommcontact']['label'], $_SERVER["PHP_SELF"], "p.fk_stcommcontact", "", $param, '', $sortfield, $sortorder, 'center ');
816 // Extra fields
817 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
818 // Hook fields
819 $parameters = array(
820  'arrayfields'=>$arrayfields,
821  'param'=>$param,
822  'sortfield'=>$sortfield,
823  'sortorder'=>$sortorder,
824 );
825 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
826 print $hookmanager->resPrint;
827 if (!empty($arrayfields['p.datec']['checked'])) {
828  print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
829 }
830 if (!empty($arrayfields['p.tms']['checked'])) {
831  print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
832 }
833 if (!empty($arrayfields['p.statut']['checked'])) {
834  print_liste_field_titre($arrayfields['p.statut']['label'], $_SERVER["PHP_SELF"], "p.statut", "", $param, '', $sortfield, $sortorder, 'center ');
835 }
836 if (!empty($arrayfields['p.import_key']['checked'])) {
837  print_liste_field_titre($arrayfields['p.import_key']['label'], $_SERVER["PHP_SELF"], "p.import_key", "", $param, '', $sortfield, $sortorder, 'center ');
838 }
839 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
840 print "</tr>\n";
841 
842 
843 $i = 0;
844 $totalarray = array();
845 while ($i < min($num, $limit))
846 {
847  $obj = $db->fetch_object($resql);
848 
849  $arraysocialnetworks = (array) json_decode($obj->socialnetworks, true);
850  $contactstatic->lastname = $obj->lastname;
851  $contactstatic->firstname = '';
852  $contactstatic->id = $obj->rowid;
853  $contactstatic->statut = $obj->statut;
854  $contactstatic->poste = $obj->poste;
855  $contactstatic->email = $obj->email;
856  $contactstatic->phone_pro = $obj->phone_pro;
857  $contactstatic->phone_perso = $obj->phone_perso;
858  $contactstatic->phone_mobile = $obj->phone_mobile;
859  $contactstatic->zip = $obj->zip;
860  $contactstatic->town = $obj->town;
861  $contactstatic->socialnetworks = $arraysocialnetworks;
862  $contactstatic->country = $obj->country;
863  $contactstatic->country_code = $obj->country_code;
864  $contactstatic->photo = $obj->photo;
865 
866  $contactstatic->fk_prospectlevel = $obj->fk_prospectcontactlevel;
867 
868  print '<tr class="oddeven">';
869 
870  // ID
871  if (!empty($arrayfields['p.rowid']['checked']))
872  {
873  print '<td class="tdoverflowmax50">';
874  print $obj->rowid;
875  print "</td>\n";
876  if (!$i) $totalarray['nbfield']++;
877  }
878  // Name
879  if (!empty($arrayfields['p.lastname']['checked']))
880  {
881  print '<td class="middle tdoverflowmax200">';
882  print $contactstatic->getNomUrl(1);
883  print '</td>';
884  if (!$i) $totalarray['nbfield']++;
885  }
886  // Firstname
887  if (!empty($arrayfields['p.firstname']['checked']))
888  {
889  print '<td class="tdoverflowmax200">'.$obj->firstname.'</td>';
890  if (!$i) $totalarray['nbfield']++;
891  }
892  // Job position
893  if (!empty($arrayfields['p.poste']['checked']))
894  {
895  print '<td class="tdoverflowmax100">'.$obj->poste.'</td>';
896  if (!$i) $totalarray['nbfield']++;
897  }
898  // Zip
899  if (!empty($arrayfields['p.zip']['checked']))
900  {
901  print '<td>'.$obj->zip.'</td>';
902  if (!$i) $totalarray['nbfield']++;
903  }
904  // Town
905  if (!empty($arrayfields['p.town']['checked']))
906  {
907  print '<td>'.$obj->town.'</td>';
908  if (!$i) $totalarray['nbfield']++;
909  }
910  // State
911  /*if (! empty($arrayfields['state.nom']['checked']))
912  {
913  print "<td>".$obj->state_name."</td>\n";
914  if (! $i) $totalarray['nbfield']++;
915  }
916  // Region
917  if (! empty($arrayfields['region.nom']['checked']))
918  {
919  print "<td>".$obj->region_name."</td>\n";
920  if (! $i) $totalarray['nbfield']++;
921  }*/
922  // Country
923  if (!empty($arrayfields['country.code_iso']['checked']))
924  {
925  print '<td class="center">';
926  $tmparray = getCountry($obj->fk_pays, 'all');
927  print $tmparray['label'];
928  print '</td>';
929  if (!$i) $totalarray['nbfield']++;
930  }
931  // Phone
932  if (!empty($arrayfields['p.phone']['checked']))
933  {
934  print '<td>'.dol_print_phone($obj->phone_pro, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL').'</td>';
935  if (!$i) $totalarray['nbfield']++;
936  }
937  // Phone perso
938  if (!empty($arrayfields['p.phone_perso']['checked']))
939  {
940  print '<td>'.dol_print_phone($obj->phone_perso, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL').'</td>';
941  if (!$i) $totalarray['nbfield']++;
942  }
943  // Phone mobile
944  if (!empty($arrayfields['p.phone_mobile']['checked']))
945  {
946  print '<td>'.dol_print_phone($obj->phone_mobile, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL').'</td>';
947  if (!$i) $totalarray['nbfield']++;
948  }
949  // Fax
950  if (!empty($arrayfields['p.fax']['checked']))
951  {
952  print '<td>'.dol_print_phone($obj->fax, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL').'</td>';
953  if (!$i) $totalarray['nbfield']++;
954  }
955  // EMail
956  if (!empty($arrayfields['p.email']['checked']))
957  {
958  print '<td>'.dol_print_email($obj->email, $obj->rowid, $obj->socid, 'AC_EMAIL', 18).'</td>';
959  if (!$i) $totalarray['nbfield']++;
960  }
961  // No EMail
962  if (!empty($arrayfields['p.no_email']['checked']))
963  {
964  print '<td class="center">'.yn($obj->no_email).'</td>';
965  if (!$i) $totalarray['nbfield']++;
966  }
967  if (!empty($conf->socialnetworks->enabled)) {
968  foreach ($socialnetworks as $key => $value) {
969  if ($value['active'] && !empty($arrayfields['p.'.$key]['checked'])) {
970  print '<td>'.dol_print_socialnetworks($arraysocialnetworks[$key], $obj->rowid, $obj->socid, $key, $socialnetworks).'</td>';
971  if (!$i) $totalarray['nbfield']++;
972  }
973  }
974  }
975  // Company
976  if (!empty($arrayfields['p.fk_soc']['checked']) || !empty($arrayfields['s.nom']['checked']))
977  {
978  print '<td>';
979  if ($obj->socid)
980  {
981  $objsoc = new Societe($db);
982  $objsoc->fetch($obj->socid);
983  print $objsoc->getNomUrl(1);
984  } else print '&nbsp;';
985  print '</td>';
986  if (!$i) $totalarray['nbfield']++;
987  }
988 
989  // Private/Public
990  if (!empty($arrayfields['p.priv']['checked']))
991  {
992  print '<td class="center">'.$contactstatic->LibPubPriv($obj->priv).'</td>';
993  if (!$i) $totalarray['nbfield']++;
994  }
995 
996  if (!empty($arrayfields['p.fk_prospectcontactlevel']['checked']))
997  {
998  // Prospect level
999  print '<td class="center">';
1000  print $contactstatic->getLibProspLevel();
1001  print "</td>";
1002  if (!$i) $totalarray['nbfield']++;
1003  }
1004 
1005  if (!empty($arrayfields['p.fk_stcommcontact']['checked']))
1006  {
1007  // Prospect status
1008  print '<td class="center nowrap"><div class="nowrap">';
1009  print '<div class="inline-block">'.$contactstatic->libProspCommStatut($obj->stcomm_id, 2, $contactstatic->cacheprospectstatus[$obj->stcomm_id]['label'], $obj->stcomm_picto);
1010  print '</div> - <div class="inline-block">';
1011  foreach ($contactstatic->cacheprospectstatus as $key => $val) {
1012  $titlealt = 'default';
1013  if (!empty($val['code']) && !in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) $titlealt = $val['label'];
1014  if ($obj->stcomm_id != $val['id']) print '<a class="pictosubstatus" href="'.$_SERVER["PHP_SELF"].'?stcommcontactid='.$obj->rowid.'&stcomm='.$val['code'].'&action=setstcomm&token='.newToken().$param.($page ? '&page='.urlencode($page) : '').'">'.img_action($titlealt, $val['code'], $val['picto']).'</a>';
1015  }
1016  print '</div></div></td>';
1017  if (!$i) $totalarray['nbfield']++;
1018  }
1019 
1020  // Extra fields
1021  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1022  // Fields from hook
1023  $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
1024  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
1025  print $hookmanager->resPrint;
1026  // Date creation
1027  if (!empty($arrayfields['p.datec']['checked']))
1028  {
1029  print '<td class="center">';
1030  print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
1031  print '</td>';
1032  if (!$i) $totalarray['nbfield']++;
1033  }
1034  // Date modification
1035  if (!empty($arrayfields['p.tms']['checked']))
1036  {
1037  print '<td class="center">';
1038  print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
1039  print '</td>';
1040  if (!$i) $totalarray['nbfield']++;
1041  }
1042  // Status
1043  if (!empty($arrayfields['p.statut']['checked']))
1044  {
1045  print '<td class="center">'.$contactstatic->getLibStatut(5).'</td>';
1046  if (!$i) $totalarray['nbfield']++;
1047  }
1048  if (!empty($arrayfields['p.import_key']['checked']))
1049  {
1050  print '<td class="tdoverflowmax100">';
1051  print $obj->import_key;
1052  print "</td>\n";
1053  if (!$i) $totalarray['nbfield']++;
1054  }
1055 
1056  // Action column
1057  print '<td class="nowrap center">';
1058  if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1059  {
1060  $selected = 0;
1061  if (in_array($obj->rowid, $arrayofselected)) $selected = 1;
1062  print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
1063  }
1064  print '</td>';
1065  if (!$i) $totalarray['nbfield']++;
1066 
1067  print "</tr>\n";
1068  $i++;
1069 }
1070 
1071 $db->free($resql);
1072 
1073 $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
1074 $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook
1075 print $hookmanager->resPrint;
1076 
1077 print "</table>";
1078 print "</div>";
1079 
1080 //if ($num > $limit || $page) print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies.png', 0, '', '', $limit, 1);
1081 
1082 print '</form>';
1083 
1084 
1085 llxFooter();
1086 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class to manage contact/addresses.
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.
getArrayOfSocialNetworks()
Get array of social network dictionary.
img_action($titlealt, $numaction, $picto= '')
Show logo action.
llxHeader()
Empty header.
Definition: wrapper.php:45
Class to build HTML component for third parties management Only common components are here...
Class to manage standard extra fields.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
print_barre_liste($titre, $page, $file, $options= '', $sortfield= '', $sortorder= '', $morehtmlcenter= '', $num=-1, $totalnboflines= '', $picto= 'generic', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow= '')
Print a title with navigation controls for pagination.
Class to manage generation of HTML components Only common components must be here.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
Class to manage third parties objects (customers, suppliers, prospects...)
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
Class to manage categories.
Classe permettant la generation de composants html autre Only common components are here...
if(!GETPOST('transkey', 'alphanohtml')&&!GETPOST('transphrase', 'alphanohtml')) else
View.
Definition: notice.php:44
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
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...
print $_SERVER["PHP_SELF"]
Edit parameters.
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...
dol_getIdFromCode($db, $key, $tablename, $fieldkey= 'code', $fieldid= 'id', $entityfilter=0)
Return an id or code from a code or id.
print
Draft customers invoices.
Definition: index.php:89
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1232
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
newToken()
Return the value of token currently saved into session with name &#39;newtoken&#39;.
llxFooter()
Empty footer.
Definition: wrapper.php:59
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
getCountry($searchkey, $withcode= '', $dbtouse=0, $outputlangs= '', $entconv=1, $searchlabel= '')
Return country label, code or id from an id, code or label.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...