dolibarr 25.0.0-alpha
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-2026 Alexandre Spangaro <alexandre@inovea-conseil.com>
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-2025 Frédéric France <frederic.france@free.fr>
13 * Copyright (C) 2019 Josep Lluís Amador <joseplluis@lliuretic.cat>
14 * Copyright (C) 2020 Open-Dsi <support@open-dsi.fr>
15 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
16 * Copyright (C) 2024 Benjamin Falière <benjamin.faliere@altairis.fr>
17 *
18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation; either version 3 of the License, or
21 * (at your option) any later version.
22 *
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
27 *
28 * You should have received a copy of the GNU General Public License
29 * along with this program. If not, see <https://www.gnu.org/licenses/>.
30 */
31
39// Load Dolibarr environment
40require '../main.inc.php';
48require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
49require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
50require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
51require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
52
53// Load translation files required by the page
54$langs->loadLangs(array("companies", "categories", "suppliers", "other"));
55
56$socialnetworks = getArrayOfSocialNetworks();
57
58// Get parameters
59$action = GETPOST('action', 'aZ09');
60$massaction = GETPOST('massaction', 'alpha');
61$show_files = GETPOSTINT('show_files');
62$confirm = GETPOST('confirm', 'alpha');
63$toselect = GETPOST('toselect', 'array:int');
64$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'contactlist';
65$optioncss = GETPOST('optioncss', 'alpha');
66if ($contextpage == 'poslist') {
67 $optioncss = 'print';
68}
69$mode = GETPOST('mode', 'alpha');
70
71// Security check
72$id = GETPOSTINT('id');
73$contactid = GETPOSTINT('id');
74$ref = ''; // There is no ref for contacts
75
76// Search fields
77$search_all = trim(GETPOST('search_all', 'alphanohtml'));
78$search_cti = preg_replace('/^0+/', '', preg_replace('/[^0-9]/', '', GETPOST('search_cti', 'alphanohtml'))); // Phone number without any special chars
79$search_phone = GETPOST("search_phone", 'alpha');
80
81$search_id = GETPOST("search_id", "intcomma");
82$search_ref_ext = GETPOST("search_ref_ext", "alpha");
83$search_firstlast_only = GETPOST("search_firstlast_only", 'alpha');
84$search_lastname = GETPOST("search_lastname", 'alpha');
85$search_firstname = GETPOST("search_firstname", 'alpha');
86$search_societe = GETPOST("search_societe", 'alpha');
87$search_societe_alias = GETPOST("search_societe_alias", 'alpha');
88$search_poste = GETPOST("search_poste", 'alpha');
89$search_phone_perso = GETPOST("search_phone_perso", 'alpha');
90$search_phone_pro = GETPOST("search_phone_pro", 'alpha');
91$search_phone_mobile = GETPOST("search_phone_mobile", 'alpha');
92$search_fax = GETPOST("search_fax", 'alpha');
93$search_email = GETPOST("search_email", 'alpha');
94if (isModEnabled('mailing')) {
95 $search_no_email = GETPOSTISSET("search_no_email") ? GETPOSTINT("search_no_email") : -1;
96} else {
97 $search_no_email = -1;
98}
99
100$search_ = array();
101
102if (isModEnabled('socialnetworks')) {
103 foreach ($socialnetworks as $key => $value) {
104 if ($value['active']) {
105 $search_[$key] = GETPOST("search_".$key, 'alpha');
106 }
107 }
108}
109$search_priv = GETPOST("search_priv", 'alpha');
110$search_sale = GETPOST('search_sale', 'intcomma');
111$search_categ = GETPOST("search_categ", 'intcomma');
112$search_categ_thirdparty = GETPOST("search_categ_thirdparty", 'intcomma');
113$search_categ_supplier = GETPOST("search_categ_supplier", 'intcomma');
114$search_status = GETPOST("search_status", "intcomma");
115$search_type = GETPOST('search_type', 'alpha');
116$search_address = GETPOST('search_address', 'alpha');
117$search_zip = GETPOST('search_zip', 'alpha');
118$search_town = GETPOST('search_town', 'alpha');
119$search_state = trim(GETPOST("search_state", 'alpha'));
120$search_region = trim(GETPOST("search_region", 'alpha'));
121$search_import_key = GETPOST("search_import_key", 'alpha');
122$search_country = GETPOST("search_country", 'aZ09');
123$search_roles = GETPOST("search_roles", 'array');
124$search_level = GETPOST("search_level", 'array');
125$search_stcomm = GETPOST('search_stcomm', 'intcomma');
126
127$search_date_creation_startmonth = GETPOSTINT('search_date_creation_startmonth');
128$search_date_creation_startyear = GETPOSTINT('search_date_creation_startyear');
129$search_date_creation_startday = GETPOSTINT('search_date_creation_startday');
130$search_date_creation_start = dol_mktime(0, 0, 0, $search_date_creation_startmonth, $search_date_creation_startday, $search_date_creation_startyear); // Use tzserver
131$search_date_creation_endmonth = GETPOSTINT('search_date_creation_endmonth');
132$search_date_creation_endyear = GETPOSTINT('search_date_creation_endyear');
133$search_date_creation_endday = GETPOSTINT('search_date_creation_endday');
134$search_date_creation_end = dol_mktime(23, 59, 59, $search_date_creation_endmonth, $search_date_creation_endday, $search_date_creation_endyear); // Use tzserver
135
136$search_date_modif_startmonth = GETPOSTINT('search_date_modif_startmonth');
137$search_date_modif_startyear = GETPOSTINT('search_date_modif_startyear');
138$search_date_modif_startday = GETPOSTINT('search_date_modif_startday');
139$search_date_modif_start = dol_mktime(0, 0, 0, $search_date_modif_startmonth, $search_date_modif_startday, $search_date_modif_startyear); // Use tzserver
140$search_date_modif_endmonth = GETPOSTINT('search_date_modif_endmonth');
141$search_date_modif_endyear = GETPOSTINT('search_date_modif_endyear');
142$search_date_modif_endday = GETPOSTINT('search_date_modif_endday');
143$search_date_modif_end = dol_mktime(23, 59, 59, $search_date_modif_endmonth, $search_date_modif_endday, $search_date_modif_endyear); // Use tzserver
144
145$search_birthday_start = dol_mktime(0, 0, 0, GETPOSTINT('search_birthday_startmonth'), GETPOSTINT('search_birthday_startday'), GETPOSTINT('search_birthday_startyear'));
146$search_birthday_end = dol_mktime(23, 59, 59, GETPOSTINT('search_birthday_endmonth'), GETPOSTINT('search_birthday_endday'), GETPOSTINT('search_birthday_endyear'));
147$search_note_public = GETPOST('search_note_public', 'alphanohtml');
148$search_note_private = GETPOST('search_note_private', 'alphanohtml');
149
150if ($search_status === '') {
151 $search_status = 1; // always display active customer first
152}
153if ($search_no_email === '') {
154 $search_no_email = -1;
155}
156
157$optioncss = GETPOST('optioncss', 'alpha');
158
159$place = GETPOST('place', 'aZ09') ? GETPOST('place', 'aZ09') : '0'; // $place is string id of table for Bar or Restaurant
160
161$type = GETPOST("type", 'aZ');
162$view = GETPOST("view", 'alpha');
163
164$userid = GETPOSTINT('userid');
165$begin = GETPOST('begin');
166
167// Load variable for pagination
168$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
169$sortfield = GETPOST('sortfield', 'aZ09comma');
170$sortorder = GETPOST('sortorder', 'aZ09comma');
171$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
172if (!$sortorder) {
173 $sortorder = "ASC";
174}
175if (!$sortfield) {
176 $sortfield = "p.lastname";
177}
178if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
179 // If $page is not defined, or '' or -1 or if we click on clear filters
180 $page = 0;
181}
182$offset = $limit * $page;
183$pageprev = $page - 1;
184$pagenext = $page + 1;
185
186
187$title = (getDolGlobalString('SOCIETE_ADDRESSES_MANAGEMENT') ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
188if ($type == "p") {
189 if (empty($contextpage) || $contextpage == 'contactlist') {
190 $contextpage = 'contactprospectlist';
191 }
192 $title .= ' ('.$langs->trans("ThirdPartyProspects").')';
193}
194if ($type == "c") {
195 if (empty($contextpage) || $contextpage == 'contactlist') {
196 $contextpage = 'contactcustomerlist';
197 }
198 $title .= ' ('.$langs->trans("ThirdPartyCustomers").')';
199} elseif ($type == "f") {
200 if (empty($contextpage) || $contextpage == 'contactlist') {
201 $contextpage = 'contactsupplierlist';
202 }
203 $title .= ' ('.$langs->trans("ThirdPartySuppliers").')';
204} elseif ($type == "o") {
205 if (empty($contextpage) || $contextpage == 'contactlist') {
206 $contextpage = 'contactotherlist';
207 }
208 $title .= ' ('.$langs->trans("OthersNotLinkedToThirdParty").')';
209}
210
211// Initialize a technical object
212$object = new Contact($db);
213$extrafields = new ExtraFields($db);
214$hookmanager->initHooks(array($contextpage));
215
216if ($user->socid > 0) {
217 $socid = $user->socid;
218}
219$result = restrictedArea($user, 'contact', $contactid, '');
220
221// fetch optionals attributes and labels
222$extrafields->fetch_name_optionals_label($object->table_element);
223
224$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
225
226// List of fields to search into when doing a "search in all"
227$fieldstosearchall = array();
228foreach ($object->fields as $key => $val) {
229 // don't allow search in private notes for external users when doing "search in all"
230 if (!empty($user->socid) && $key == "note_private") {
231 continue;
232 }
233
234 if (empty($val['searchall'])) {
235 continue;
236 }
237
238 $fieldstosearchall['p.'.$key] = $val['label'];
239}
240
241// Add none object fields for "search in all"
242if (!getDolGlobalString('SOCIETE_DISABLE_CONTACTS')) {
243 $fieldstosearchall['s.nom'] = "ThirdParty";
244 $fieldstosearchall['s.name_alias'] = "AliasNames";
245}
246
247$parameters = array('fieldstosearchall' => $fieldstosearchall);
248$reshook = $hookmanager->executeHooks('completeFieldsToSearchAll', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
249if ($reshook > 0) {
250 $fieldstosearchall = empty($hookmanager->resArray['fieldstosearchall']) ? array() : $hookmanager->resArray['fieldstosearchall'];
251} elseif ($reshook == 0) {
252 $fieldstosearchall = array_merge($fieldstosearchall, empty($hookmanager->resArray['fieldstosearchall']) ? array() : $hookmanager->resArray['fieldstosearchall']);
253}
254
255// Definition of array of fields for columns
256$arrayfields = array();
257foreach ($object->fields as $key => $val) {
258 // If $val['visible']==0, then we never show the field
259 if (!empty($val['visible'])) {
260 $visible = (int) dol_eval((string) $val['visible'], 1);
261 $arrayfields['p.'.$key] = array(
262 'label' => $val['label'],
263 'checked' => (($visible < 0) ? '0' : '1'),
264 'enabled' => (string) (int) (abs($visible) != 3 && (bool) dol_eval((string) $val['enabled'], 1)),
265 'position' => $val['position'],
266 'help' => isset($val['help']) ? $val['help'] : ''
267 );
268 }
269}
270
271// Add none object fields to fields for list
272$arrayfields['state.nom'] = array('label' => "State", 'position' => 66, 'checked' => '0');
273$arrayfields['region.nom'] = array('label' => "Region", 'position' => 67, 'checked' => '0');
274$arrayfields['country.code_iso'] = array('label' => "Country", 'position' => 68, 'checked' => '0');
275if (!getDolGlobalString('SOCIETE_DISABLE_CONTACTS')) {
276 $arrayfields['s.nom'] = array('label' => "ThirdParty", 'position' => 113, 'checked' => '1');
277 $arrayfields['s.name_alias'] = array('label' => "AliasNameShort", 'position' => 114, 'checked' => '1');
278}
279
280$arrayfields['unsubscribed'] = array(
281 'label' => 'No_Email',
282 'checked' => '0',
283 'enabled' => (string) (int) (isModEnabled('mailing')),
284 'position' => 111);
285
286if (isModEnabled('socialnetworks')) {
287 foreach ($socialnetworks as $key => $value) {
288 if ($value['active']) {
289 $arrayfields['p.'.$key] = array(
290 'label' => $value['label'],
291 'checked' => '0',
292 'position' => 299
293 );
294 }
295 }
296}
297
298$arrayfields['p.note_public'] = array('label' => 'NotePublic', 'position' => 350, 'checked' => '-1');
299$arrayfields['p.note_private'] = array('label' => 'NotePrivate', 'position' => 351, 'checked' => '-1');
300
301
302// Extra fields
303include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
304
305// Add hook to complete $arrayfields
306$parameters = array('arrayfields' => &$arrayfields);
307$reshook = $hookmanager->executeHooks('completeArrayFields', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
308
309$object->fields = dol_sort_array($object->fields, 'position');
310//$arrayfields['anotherfield'] = array('type'=>'integer', 'label'=>'AnotherField', 'checked'=>1, 'enabled'=>1, 'position'=>90, 'csslist'=>'right');
311$arrayfields = dol_sort_array($arrayfields, 'position');
312
313
314if (($id > 0 || !empty($ref)) && $action != 'add') {
315 $result = $object->fetch($id, $ref);
316 if ($result < 0) {
318 }
319}
320
321$permissiontoread = $user->hasRight('societe', 'contact', 'lire');
322$permissiontodelete = $user->hasRight('societe', 'contact', 'supprimer');
323$permissiontoadd = $user->hasRight('societe', 'contact', 'creer');
324
325if (!$permissiontoread) {
327}
328
329
330/*
331 * Actions
332 */
333
334if ($action == "change" && $user->hasRight('takepos', 'run')) { // Change customer for TakePOS
335 $idcustomer = GETPOSTINT('idcustomer');
336 $idcontact = GETPOSTINT('idcontact');
337
338 // Check if draft invoice already exists, if not create it
339 $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")' AND entity IN (".getEntity('invoice').")";
340 $result = $db->query($sql);
341 $num_lines = $db->num_rows($result);
342 if ($num_lines == 0) {
343 require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
344 $invoice = new Facture($db);
345 $constforthirdpartyid = 'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"];
346 $invoice->socid = getDolGlobalInt($constforthirdpartyid);
347 $invoice->date = dol_now();
348 $invoice->module_source = 'takepos';
349 $invoice->pos_source = $_SESSION["takeposterminal"];
350 $placeid = $invoice->create($user);
351 $sql = "UPDATE ".MAIN_DB_PREFIX."facture set ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")' where rowid = ".((int) $placeid);
352 $db->query($sql);
353 }
354
355 $sql = "UPDATE ".MAIN_DB_PREFIX."facture set fk_soc=".((int) $idcustomer)." where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'";
356 $resql = $db->query($sql);
357
358 // set contact on invoice
359 if (!isset($invoice)) {
360 require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
361 $invoice = new Facture($db);
362 $invoice->fetch(0, "(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")");
363 $invoice->delete_linked_contact('external', 'BILLING');
364 }
365 $invoice->add_contact($idcontact, 'BILLING'); ?>
366 <script>
367 console.log("Reload page invoice.php with place=<?php print $place; ?>");
368 parent.$("#poslines").load("invoice.php?place=<?php print $place; ?>", function() {
369 //parent.$("#poslines").scrollTop(parent.$("#poslines")[0].scrollHeight);
370 <?php if (!$resql) { ?>
371 alert('Error failed to update customer on draft invoice.');
372 <?php } ?>
373 parent.$("#idcustomer").val(<?php echo $idcustomer; ?>);
374 parent.$.colorbox.close(); /* Close the popup */
375 });
376 </script>
377 <?php
378 exit;
379}
380
381if (GETPOST('cancel', 'alpha')) {
382 $action = 'list';
383 $massaction = '';
384}
385if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
386 $massaction = '';
387}
388
389$parameters = array('arrayfields' => &$arrayfields);
390$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
391if ($reshook < 0) {
392 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
393}
394
395if (empty($reshook)) {
396 // Selection of new fields
397 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
398
399 // Purge search criteria
400 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
401 $search_all = "";
402 $search_id = '';
403 $search_ref_ext = '';
404 $search_firstlast_only = "";
405 $search_lastname = "";
406 $search_firstname = "";
407 $search_societe = "";
408 $search_societe_alias = "";
409 $search_town = "";
410 $search_address = "";
411 $search_zip = "";
412 $search_state = "";
413 $search_region = "";
414 $search_country = "";
415 $search_poste = "";
416 $search_phone = "";
417 $search_phone_perso = "";
418 $search_phone_pro = "";
419 $search_phone_mobile = "";
420 $search_fax = "";
421 $search_email = "";
422 $search_no_email = -1;
423 if (isModEnabled('socialnetworks')) {
424 foreach ($socialnetworks as $key => $value) {
425 if ($value['active']) {
426 $search_[$key] = "";
427 }
428 }
429 }
430 $search_priv = "";
431 $search_stcomm = '';
432 $search_level = '';
433 $search_date_creation_startmonth = "";
434 $search_date_creation_startyear = "";
435 $search_date_creation_startday = "";
436 $search_date_creation_start = "";
437 $search_date_creation_endmonth = "";
438 $search_date_creation_endyear = "";
439 $search_date_creation_endday = "";
440 $search_date_creation_end = "";
441 $search_date_modif_startmonth = "";
442 $search_date_modif_startyear = "";
443 $search_date_modif_startday = "";
444 $search_date_modif_start = "";
445 $search_date_modif_endmonth = "";
446 $search_date_modif_endyear = "";
447 $search_date_modif_endday = "";
448 $search_date_modif_end = "";
449 $search_status = -1;
450 $search_sale = '';
451 $search_categ = '';
452 $search_categ_thirdparty = '';
453 $search_categ_supplier = '';
454 $search_import_key = '';
455 $toselect = array();
456 $search_array_options = array();
457 $search_roles = array();
458 $search_birthday_start = '';
459 $search_birthday_end = '';
460 $search_note_public = "";
461 $search_note_private = "";
462 }
463
464 // Mass actions
465 $objectclass = 'Contact';
466 $objectlabel = 'Contact';
467 $uploaddir = $conf->societe->dir_output;
468 include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
469
470 if ($action == 'setstcomm' && $permissiontoadd) {
471 $object = new Contact($db);
472 $result = $object->fetch(GETPOSTINT('stcommcontactid'));
473 $object->stcomm_id = dol_getIdFromCode($db, GETPOST('stcomm', 'alpha'), 'c_stcommcontact');
474 $result = $object->update($object->id, $user);
475 if ($result < 0) {
476 setEventMessages($object->error, $object->errors, 'errors');
477 }
478
479 $action = '';
480 }
481}
482
483if ($search_priv < 0) {
484 $search_priv = '';
485}
486
487// The user has no rights to see other third-party than their own
488if (!$user->hasRight('societe', 'client', 'voir')) {
489 $socid = $user->socid;
490}
491
492
493/*
494 * View
495 */
496
497$form = new Form($db);
498$formother = new FormOther($db);
499$formcompany = new FormCompany($db);
500$contactstatic = new Contact($db);
501
502$title = $langs->trans("ContactsAddresses");
503$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:M&oacute;dulo_Empresas';
504$morejs = array();
505$morecss = array();
506
507if (getDolGlobalString('THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES')) {
508 $contactstatic->loadCacheOfProspStatus();
509}
510
511$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
512$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
513
514// Select every potentials, and note each potentials which fit in search parameters
515$tab_level = array();
516$sql = "SELECT code, label, sortorder";
517$sql .= " FROM ".MAIN_DB_PREFIX."c_prospectcontactlevel";
518$sql .= " WHERE active > 0";
519$sql .= " ORDER BY sortorder";
520$resql = $db->query($sql);
521if ($resql) {
522 while ($obj = $db->fetch_object($resql)) {
523 // Compute level text
524 $level = $langs->trans($obj->code);
525 if ($level == $obj->code) {
526 $level = $langs->trans($obj->label);
527 }
528 $tab_level[$obj->code] = $level;
529 }
530} else {
532}
533
534// Build and execute select
535// --------------------------------------------------------------------
536$sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias as alias,";
537$sql .= " p.rowid, p.ref_ext, p.lastname as lastname, p.statut, p.firstname, p.address, p.zip, p.town, p.poste, p.email, p.birthday,";
538$sql .= " p.socialnetworks, p.photo,";
539$sql .= " p.phone as phone_pro, p.phone_mobile, p.phone_perso, p.fax, p.fk_pays, p.priv, p.ip, p.datec as date_creation, p.tms as date_modification,";
540$sql .= " p.import_key, p.fk_stcommcontact as stcomm_id, p.fk_prospectlevel, p.note_public, p.note_private,";
541$sql .= " st.libelle as stcomm, st.picto as stcomm_picto,";
542$sql .= " co.label as country, co.code as country_code,";
543$sql .= " state.code_departement as state_code, state.nom as state_name,";
544$sql .= " region.code_region as region_code, region.nom as region_name";
545// Add fields from extrafields
546if (!empty($extrafields->attributes[$object->table_element]['label'])) {
547 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
548 $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
549 }
550}
551if (isModEnabled('mailing')) {
552 $sql .= ", (SELECT count(*) FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = p.email) as unsubscribed";
553}
554
555// Add fields from hooks
556$parameters = array();
557$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
558$sql .= $hookmanager->resPrint;
559$sql = preg_replace('/,\s*$/', '', $sql);
560
561$sqlfields = $sql; // $sql fields to remove for count total
562
563$sql .= " FROM ".MAIN_DB_PREFIX."socpeople as p";
564if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
565 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (p.rowid = ef.fk_object)";
566}
567$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = p.fk_pays";
568$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc";
569$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = p.fk_departement)";
570$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as region on (region.code_region = state.fk_region)";
571$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_stcommcontact as st ON st.id = p.fk_stcommcontact";
572
573// Add fields from hooks - ListFrom
574$parameters = array();
575$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
576$sql .= $hookmanager->resPrint;
577$sql .= ' WHERE p.entity IN ('.getEntity('contact').')';
578if (!empty($userid)) { // propre au commercial
579 $sql .= " AND p.fk_user_creat=".((int) $userid);
580}
581if ($search_level) {
582 $sql .= natural_search("p.fk_prospectlevel", implode(',', $search_level), 3);
583}
584if ($search_stcomm != '' && $search_stcomm != -2) {
585 $sql .= natural_search("p.fk_stcommcontact", $search_stcomm, 2);
586}
587
588// Filter to exclude not owned private contacts
589if ($search_priv != '0' && $search_priv != '1') {
590 $sql .= " AND (p.priv='0' OR (p.priv='1' AND p.fk_user_creat=".((int) $user->id)."))";
591} else {
592 if ($search_priv == '0') {
593 $sql .= " AND p.priv='0'";
594 }
595 if ($search_priv == '1') {
596 $sql .= " AND (p.priv='1' AND p.fk_user_creat=".((int) $user->id).")";
597 }
598}
599// Search on sale representative
600if (!empty($search_sale) && $search_sale != '-1') {
601 if ($search_sale == -2) {
602 $sql .= " AND NOT EXISTS (SELECT sc.fk_soc FROM ".$db->prefix()."societe_commerciaux as sc WHERE sc.fk_soc = p.fk_soc)";
603 } elseif ($search_sale > 0) {
604 $sql .= " AND EXISTS (SELECT sc.fk_soc FROM ".$db->prefix()."societe_commerciaux as sc WHERE sc.fk_soc = p.fk_soc AND sc.fk_user = ".((int) $search_sale).")";
605 }
606}
607
608// Search Contact Categories
609$searchCategoryContactList = $search_categ ? array($search_categ) : array();
610$searchCategoryContactOperator = 0;
611// Search for tag/category ($searchCategoryContactList is an array of ID)
612if (!empty($searchCategoryContactList)) {
613 $searchCategoryContactSqlList = array();
614 $listofcategoryid = '';
615 foreach ($searchCategoryContactList as $searchCategoryContact) {
616 if (intval($searchCategoryContact) == -2) {
617 $searchCategoryContactSqlList[] = "NOT EXISTS (SELECT ck.fk_socpeople FROM ".MAIN_DB_PREFIX."categorie_contact as ck WHERE p.rowid = ck.fk_socpeople)";
618 } elseif (intval($searchCategoryContact) > 0) {
619 if ($searchCategoryContactOperator == 0) {
620 $searchCategoryContactSqlList[] = " EXISTS (SELECT ck.fk_socpeople FROM ".MAIN_DB_PREFIX."categorie_contact as ck WHERE p.rowid = ck.fk_socpeople AND ck.fk_categorie = ".((int) $searchCategoryContact).")";
621 } else {
622 $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryContact);
623 }
624 }
625 }
626 if ($listofcategoryid) {
627 $searchCategoryContactSqlList[] = " EXISTS (SELECT ck.fk_socpeople FROM ".MAIN_DB_PREFIX."categorie_contact as ck WHERE p.rowid = ck.fk_socpeople AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))";
628 }
629 if ($searchCategoryContactOperator == 1) {
630 if (!empty($searchCategoryContactSqlList)) {
631 $sql .= " AND (".implode(' OR ', $searchCategoryContactSqlList).")";
632 }
633 } else {
634 if (!empty($searchCategoryContactSqlList)) {
635 $sql .= " AND (".implode(' AND ', $searchCategoryContactSqlList).")";
636 }
637 }
638}
639
640// Search Customer Categories
641$searchCategoryCustomerList = $search_categ_thirdparty ? array($search_categ_thirdparty) : array();
642$searchCategoryCustomerOperator = 0;
643// Search for tag/category ($searchCategoryCustomerList is an array of ID)
644if (!empty($searchCategoryCustomerList)) {
645 $searchCategoryCustomerSqlList = array();
646 $listofcategoryid = '';
647 foreach ($searchCategoryCustomerList as $searchCategoryCustomer) {
648 if (intval($searchCategoryCustomer) == -2) {
649 $searchCategoryCustomerSqlList[] = "NOT EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe as ck WHERE s.rowid = ck.fk_soc)";
650 } elseif (intval($searchCategoryCustomer) > 0) {
651 if ($searchCategoryCustomerOperator == 0) {
652 $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).")";
653 } else {
654 $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryCustomer);
655 }
656 }
657 }
658 if ($listofcategoryid) {
659 $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)."))";
660 }
661 if ($searchCategoryCustomerOperator == 1) {
662 if (!empty($searchCategoryCustomerSqlList)) {
663 $sql .= " AND (".implode(' OR ', $searchCategoryCustomerSqlList).")";
664 }
665 } else {
666 if (!empty($searchCategoryCustomerSqlList)) {
667 $sql .= " AND (".implode(' AND ', $searchCategoryCustomerSqlList).")";
668 }
669 }
670}
671
672// Search Supplier Categories
673$searchCategorySupplierList = $search_categ_supplier ? array($search_categ_supplier) : array();
674$searchCategorySupplierOperator = 0;
675// Search for tag/category ($searchCategorySupplierList is an array of ID)
676if (!empty($searchCategorySupplierList)) {
677 $searchCategorySupplierSqlList = array();
678 $listofcategoryid = '';
679 foreach ($searchCategorySupplierList as $searchCategorySupplier) {
680 if (intval($searchCategorySupplier) == -2) {
681 $searchCategorySupplierSqlList[] = "NOT EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_fournisseur as ck WHERE s.rowid = ck.fk_soc)";
682 } elseif (intval($searchCategorySupplier) > 0) {
683 if ($searchCategorySupplierOperator == 0) {
684 $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).")";
685 } else {
686 $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategorySupplier);
687 }
688 }
689 }
690 if ($listofcategoryid) {
691 $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)."))";
692 }
693 if ($searchCategorySupplierOperator == 1) {
694 if (!empty($searchCategorySupplierSqlList)) {
695 $sql .= " AND (".implode(' OR ', $searchCategorySupplierSqlList).")";
696 }
697 } else {
698 if (!empty($searchCategorySupplierSqlList)) {
699 $sql .= " AND (".implode(' AND ', $searchCategorySupplierSqlList).")";
700 }
701 }
702}
703
704if ($search_all) {
705 $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
706}
707if (strlen($search_phone)) {
708 $sql .= natural_search(array('p.phone', 'p.phone_perso', 'p.phone_mobile'), $search_phone);
709}
710if (strlen($search_cti)) {
711 $sql .= natural_search(array('p.phone', 'p.phone_perso', 'p.phone_mobile'), $search_cti);
712}
713if (strlen($search_firstlast_only)) {
714 $sql .= natural_search(array('p.lastname', 'p.firstname'), $search_firstlast_only);
715}
716
717if ($search_id > 0) {
718 $sql .= natural_search('p.rowid', $search_id, 1);
719}
720if ($search_ref_ext) {
721 $sql .= natural_search('p.ref_ext', $search_ref_ext);
722}
723if ($search_lastname) {
724 $sql .= natural_search('p.lastname', $search_lastname);
725}
726if ($search_firstname) {
727 $sql .= natural_search('p.firstname', $search_firstname);
728}
729if (empty($arrayfields['s.name_alias']['checked']) && $search_societe) {
730 $sql .= natural_search(array("s.nom", "s.name_alias"), $search_societe);
731} else {
732 if ($search_societe) {
733 $sql .= natural_search('s.nom', $search_societe);
734 }
735 if ($search_societe_alias) {
736 $sql .= natural_search('s.name_alias', $search_societe_alias);
737 }
738}
739if ($search_country) {
740 $sql .= " AND p.fk_pays IN (".$db->sanitize($search_country).')';
741}
742if (strlen($search_poste)) {
743 $sql .= natural_search('p.poste', $search_poste);
744}
745if (strlen($search_phone_perso)) {
746 $sql .= natural_search('p.phone_perso', $search_phone_perso);
747}
748if (strlen($search_phone_pro)) {
749 $sql .= natural_search('p.phone', $search_phone_pro);
750}
751if (strlen($search_phone_mobile)) {
752 $sql .= natural_search('p.phone_mobile', $search_phone_mobile);
753}
754if (strlen($search_fax)) {
755 $sql .= natural_search('p.fax', $search_fax);
756}
757if (isModEnabled('socialnetworks')) {
758 foreach ($socialnetworks as $key => $value) {
759 if ($value['active'] && strlen($search_[$key])) {
760 $searchkeyinjsonformat = preg_replace('/"$/', '', preg_replace('/^"/', '', json_encode($search_[$key])));
761 if (in_array($db->type, array('mysql', 'mysqli'))) {
762 $sql .= " AND p.socialnetworks REGEXP '".$db->escape("\"".$db->escapeforlike($key)."\":\"[^\"]*".$db->escapeforlike($searchkeyinjsonformat))."'";
763 } elseif ($db->type == 'pgsql') {
764 $sql .= " AND p.socialnetworks ~ '".$db->escape("\"".$db->escapeforlike($key)."\":\"[^\"]*".$db->escapeforlike($searchkeyinjsonformat))."'";
765 } else {
766 // Works with all database but not reliable because search only for social network code starting with searched value
767 $sql .= " AND p.socialnetworks LIKE '".$db->escape("%\"".$db->escapeforlike($key."\":\"".$searchkeyinjsonformat)."%")."'";
768 }
769 }
770 }
771}
772//print $sql;
773
774if (strlen($search_email)) {
775 $sql .= natural_search('p.email', $search_email);
776}
777if (strlen($search_address)) {
778 $sql .= natural_search("p.address", $search_address);
779}
780if (strlen($search_zip)) {
781 $sql .= natural_search("p.zip", $search_zip);
782}
783if (strlen($search_town)) {
784 $sql .= natural_search("p.town", $search_town);
785}
786if ($search_state) {
787 $sql .= natural_search("state.nom", $search_state);
788}
789if ($search_region) {
790 $sql .= natural_search("region.nom", $search_region);
791}
792if (count($search_roles) > 0) {
793 $sql .= " AND EXISTS (SELECT sc.rowid FROM ".MAIN_DB_PREFIX."societe_contacts as sc WHERE p.rowid = sc.fk_socpeople AND sc.fk_c_type_contact IN (".$db->sanitize(implode(',', $search_roles))."))";
794}
795if ($search_no_email != -1 && $search_no_email > 0) {
796 $sql .= " AND (SELECT count(*) FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = p.email) > 0";
797}
798if ($search_no_email != -1 && $search_no_email == 0) {
799 $sql .= " AND (SELECT count(*) FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = p.email) = 0 AND p.email IS NOT NULL AND p.email <> ''";
800}
801if ($search_note_public != '') {
802 $sql .= natural_search('p.note_public', $search_note_public);
803}
804if ($search_note_private != '') {
805 $sql .= natural_search('p.note_private', $search_note_private);
806}
807if ($search_date_creation_start) {
808 $sql .= " AND p.datec >= '".$db->idate($search_date_creation_start)."'";
809}
810if ($search_date_creation_end) {
811 $sql .= " AND p.datec <= '".$db->idate($search_date_creation_end)."'";
812}
813
814if ($search_date_modif_start) {
815 $sql .= " AND p.tms >= '".$db->idate($search_date_modif_start)."'";
816}
817if ($search_date_modif_end) {
818 $sql .= " AND p.tms <= '".$db->idate($search_date_modif_end)."'";
819}
820if ($search_status != '' && $search_status >= 0) {
821 $sql .= " AND p.statut = ".((int) $search_status);
822}
823if ($search_import_key) {
824 $sql .= natural_search("p.import_key", $search_import_key);
825}
826if ($type == "o") { // filter on type
827 $sql .= " AND p.fk_soc IS NULL";
828} elseif ($type == "f") { // filter on type
829 $sql .= " AND s.fournisseur = 1";
830} elseif ($type == "c") { // filter on type
831 $sql .= " AND s.client IN (1, 3)";
832} elseif ($type == "p") { // filter on type
833 $sql .= " AND s.client IN (2, 3)";
834}
835if (!empty($socid)) {
836 $sql .= " AND s.rowid = ".((int) $socid);
837}
838if ($search_birthday_start) {
839 $sql .= " AND p.birthday >= '".$db->idate($search_birthday_start)."'";
840}
841if ($search_birthday_end) {
842 $sql .= " AND p.birthday <= '".$db->idate($search_birthday_end)."'";
843}
844
845// Add where from extra fields
846include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
847
848// Add where from hooks
849$parameters = array();
850$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
851$sql .= $hookmanager->resPrint;
852//print $sql;
853
854// Add GroupBy from hooks
855$parameters = array('fieldstosearchall' => $fieldstosearchall);
856$reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
857$sql .= $hookmanager->resPrint;
858//print $sql;
859
860// Count total nb of records
861$nbtotalofrecords = '';
862if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
863 /* The fast and low memory method to get and count full list converts the sql into a sql count */
864 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
865 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
866 $resql = $db->query($sqlforcount);
867 if ($resql) {
868 $objforcount = $db->fetch_object($resql);
869 $nbtotalofrecords = $objforcount->nbtotalofrecords;
870 } else {
872 }
873
874 if (($page * $limit) > (int) $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
875 $page = 0;
876 $offset = 0;
877 }
878 $db->free($resql);
879}
880
881// Complete request and execute it with limit
882if ($view == "recent") {
883 $sql .= $db->order("p.datec", "DESC");
884} else {
885 $sql .= $db->order($sortfield, $sortorder);
886}
887if ($limit) {
888 $sql .= $db->plimit($limit + 1, $offset);
889}
890
891$resql = $db->query($sql);
892if (!$resql) {
894 exit;
895}
896
897$num = $db->num_rows($resql);
898
899// Direct jump if only one record found
900if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && ($search_all != '' || $search_cti != '') && !$page) {
901 $obj = $db->fetch_object($resql);
902 $id = $obj->rowid;
903 header("Location: ".DOL_URL_ROOT.'/contact/card.php?id='.$id);
904 exit;
905}
906
907
908// Output page
909// --------------------------------------------------------------------
910
911llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'mod-societe page-contact-list bodyforlist');
912
913$arrayofselected = is_array($toselect) ? $toselect : array();
914
915$param = '';
916if (!empty($mode)) {
917 $param .= '&mode='.urlencode($mode);
918}
919if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
920 $param .= '&contextpage='.urlencode($contextpage);
921}
922if ($limit > 0 && $limit != $conf->liste_limit) {
923 $param .= '&limit='.((int) $limit);
924}
925if ($optioncss != '') {
926 $param .= '&optioncss='.urlencode($optioncss);
927}
928$param .= '&userid='.urlencode((string) $userid).'&contactname='.urlencode((string) $search_all);
929$param .= '&type='.urlencode($type).'&view='.urlencode($view);
930if (!empty($search_sale) && $search_sale != '-1') {
931 $param .= '&search_sale='.urlencode($search_sale);
932}
933if (!empty($search_categ) && $search_categ != '-1') {
934 $param .= '&search_categ='.urlencode((string) ($search_categ));
935}
936if (!empty($search_categ_thirdparty) && $search_categ_thirdparty != '-1') {
937 $param .= '&search_categ_thirdparty='.urlencode((string) ($search_categ_thirdparty));
938}
939if (!empty($search_categ_supplier) && $search_categ_supplier != '-1') {
940 $param .= '&search_categ_supplier='.urlencode((string) ($search_categ_supplier));
941}
942if ($search_all != '') {
943 $param .= '&search_all='.urlencode($search_all);
944}
945if ($search_id > 0) {
946 $param .= "&search_id=".((int) $search_id);
947}
948if ($search_ref_ext) {
949 $param .= "&search_ref_ext=".urlencode($search_ref_ext);
950}
951if ($search_lastname != '') {
952 $param .= '&search_lastname='.urlencode($search_lastname);
953}
954if ($search_firstname != '') {
955 $param .= '&search_firstname='.urlencode($search_firstname);
956}
957if ($search_societe != '') {
958 $param .= '&search_societe='.urlencode($search_societe);
959}
960if ($search_societe_alias != '') {
961 $param .= '&search_societe_alias='.urlencode($search_societe_alias);
962}
963if ($search_address != '') {
964 $param .= '&search_address='.urlencode($search_address);
965}
966if ($search_zip != '') {
967 $param .= '&search_zip='.urlencode($search_zip);
968}
969if ($search_town != '') {
970 $param .= '&search_town='.urlencode($search_town);
971}
972if ($search_state != '') {
973 $param .= "&search_state=".urlencode($search_state);
974}
975if ($search_region != '') {
976 $param .= "&search_region=".urlencode($search_region);
977}
978if ($search_country != '') {
979 $param .= "&search_country=".urlencode($search_country);
980}
981if ($search_poste != '') {
982 $param .= '&search_poste='.urlencode($search_poste);
983}
984if ($search_phone_pro != '') {
985 $param .= '&search_phone_pro='.urlencode($search_phone_pro);
986}
987if ($search_phone_perso != '') {
988 $param .= '&search_phone_perso='.urlencode($search_phone_perso);
989}
990if ($search_phone_mobile != '') {
991 $param .= '&search_phone_mobile='.urlencode($search_phone_mobile);
992}
993if ($search_fax != '') {
994 $param .= '&search_fax='.urlencode($search_fax);
995}
996if ($search_email != '') {
997 $param .= '&search_email='.urlencode($search_email);
998}
999if ($search_no_email != '') {
1000 $param .= '&search_no_email='.urlencode((string) ($search_no_email));
1001}
1002if ($search_note_private != '') {
1003 $param .= '&search_note_private='.urlencode((string) ($search_note_private));
1004}
1005if ($search_note_public != '') {
1006 $param .= '&search_note_public='.urlencode((string) ($search_note_public));
1007}
1008if ($search_date_creation_startmonth) {
1009 $param .= '&search_date_creation_startmonth='.urlencode((string) ($search_date_creation_startmonth));
1010}
1011if ($search_date_creation_startyear) {
1012 $param .= '&search_date_creation_startyear='.urlencode((string) ($search_date_creation_startyear));
1013}
1014if ($search_date_creation_startday) {
1015 $param .= '&search_date_creation_startday='.urlencode((string) ($search_date_creation_startday));
1016}
1017if ($search_date_creation_start) {
1018 $param .= '&search_date_creation_start='.urlencode((string) $search_date_creation_start);
1019}
1020if ($search_date_creation_endmonth) {
1021 $param .= '&search_date_creation_endmonth='.urlencode((string) ($search_date_creation_endmonth));
1022}
1023if ($search_date_creation_endyear) {
1024 $param .= '&search_date_creation_endyear='.urlencode((string) ($search_date_creation_endyear));
1025}
1026if ($search_date_creation_endday) {
1027 $param .= '&search_date_creation_endday='.urlencode((string) ($search_date_creation_endday));
1028}
1029if ($search_date_creation_end) {
1030 $param .= '&search_date_creation_end='.urlencode((string) $search_date_creation_end);
1031}
1032if ($search_date_modif_startmonth) {
1033 $param .= '&search_date_modif_startmonth='.urlencode((string) ($search_date_modif_startmonth));
1034}
1035if ($search_date_modif_startyear) {
1036 $param .= '&search_date_modif_startyear='.urlencode((string) ($search_date_modif_startyear));
1037}
1038if ($search_date_modif_startday) {
1039 $param .= '&search_date_modif_startday='.urlencode((string) ($search_date_modif_startday));
1040}
1041if ($search_date_modif_start) {
1042 $param .= '&search_date_modif_start='.urlencode((string) $search_date_modif_start);
1043}
1044if ($search_date_modif_endmonth) {
1045 $param .= '&search_date_modif_endmonth='.urlencode((string) ($search_date_modif_endmonth));
1046}
1047if ($search_date_modif_endyear) {
1048 $param .= '&search_date_modif_endyear='.urlencode((string) ($search_date_modif_endyear));
1049}
1050if ($search_date_modif_endday) {
1051 $param .= '&search_date_modif_endday='.urlencode((string) ($search_date_modif_endday));
1052}
1053if ($search_date_modif_end) {
1054 $param .= '&search_date_modif_end=' . urlencode((string) $search_date_modif_end);
1055}
1056if ($search_stcomm != '') {
1057 $param .= '&search_stcomm='.urlencode((string) ($search_stcomm));
1058}
1059if ($search_status != '') {
1060 $param .= '&search_status='.urlencode((string) ($search_status));
1061}
1062if ($search_priv == '0' || $search_priv == '1') {
1063 $param .= "&search_priv=".urlencode($search_priv);
1064}
1065if ($search_stcomm != '') {
1066 $param .= '&search_stcomm='.urlencode((string) ($search_stcomm));
1067}
1068if (is_array($search_level) && count($search_level)) {
1069 foreach ($search_level as $slevel) {
1070 $param .= '&search_level[]='.urlencode($slevel);
1071 }
1072}
1073if ($search_import_key != '') {
1074 $param .= '&search_import_key='.urlencode($search_import_key);
1075}
1076if (count($search_roles) > 0) {
1077 $param .= implode('&search_roles[]=', $search_roles);
1078}
1079if ($search_birthday_start) {
1080 $param .= '&search_birthday_start='.urlencode(dol_print_date($search_birthday_start, '%d')).'&search_birthday_startmonth='.urlencode(dol_print_date($search_birthday_start, '%m')).'&search_birthday_startyear='.urlencode(dol_print_date($search_birthday_start, '%Y'));
1081}
1082if ($search_birthday_end) {
1083 $param .= '&search_birthday_end='.urlencode(dol_print_date($search_birthday_end, '%d')).'&search_birthday_endmonth='.urlencode(dol_print_date($search_birthday_end, '%m')).'&search_birthday_endyear='.urlencode(dol_print_date($search_birthday_end, '%Y'));
1084}
1085// Add $param from extra fields
1086include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
1087
1088// List of mass actions available
1089$arrayofmassactions = array(
1090 'presend' => img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
1091// 'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
1092);
1093//if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer");
1094if (!empty($permissiontodelete)) {
1095 $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
1096}
1097if (isModEnabled('category') && $user->hasRight('societe', 'creer')) {
1098 $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag");
1099}
1100if (GETPOSTINT('nomassaction') || in_array($massaction, array('presend', 'predelete','preaffecttag'))) {
1101 $arrayofmassactions = array();
1102}
1103
1104$massactionbutton = '';
1105if ($contextpage != 'poslist') {
1106 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
1107}
1108
1109print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'" name="formfilter">';
1110if ($optioncss != '') {
1111 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
1112}
1113print '<input type="hidden" name="token" value="'.newToken().'">';
1114print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1115print '<input type="hidden" name="view" value="'.dolPrintHTMLForAttribute($view).'">';
1116print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
1117print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
1118//print '<input type="hidden" name="page" value="'.$page.'">';
1119print '<input type="hidden" name="type" value="'.$type.'">';
1120print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
1121print '<input type="hidden" name="page_y" value="">';
1122print '<input type="hidden" name="mode" value="'.$mode.'">';
1123
1124
1125$newcardbutton = '';
1126$parameters = array();
1127$reshook = $hookmanager->executeHooks('printNewCardButton', $parameters, $object);
1128if (empty($reshook)) {
1129 $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'));
1130 $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'));
1131 $newcardbutton .= dolGetButtonTitleSeparator();
1132 if ($contextpage != 'poslist') {
1133 $newcardbutton .= dolGetButtonTitle($langs->trans('NewContactAddress'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/contact/card.php?action=create', '', $permissiontoadd);
1134 } elseif ($user->hasRight('societe', 'contact', 'creer')) {
1135 $url = DOL_URL_ROOT . '/contact/card.php?action=create&type=t&contextpage=poslist&optioncss=print&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '?token=' . newToken() . 'type=t&contextpage=poslist&nomassaction=1&optioncss=print&place='.$place);
1136 $label = 'MenuNewCustomer';
1137 $newcardbutton .= dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', $url);
1138 }
1139} else {
1140 $newcardbutton = $hookmanager->resPrint;
1141}
1142
1143print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, (string) $massactionbutton, $num, $nbtotalofrecords, 'address', 0, $newcardbutton, '', $limit, 0, 0, 1);
1144
1145$topicmail = "Information";
1146$modelmail = "contact";
1147$objecttmp = new Contact($db);
1148$trackid = 'ctc'.$object->id;
1149include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
1150
1151if ($search_all) {
1152 $setupstring = '';
1153 foreach ($fieldstosearchall as $key => $val) {
1154 $fieldstosearchall[$key] = $langs->trans($val);
1155 $setupstring .= $key."=".$val.";";
1156 }
1157 print '<!-- Search done like if CONTACT_QUICKSEARCH_ON_FIELDS = '.$setupstring.' -->'."\n";
1158 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'</div>';
1159}
1160if ($search_firstlast_only) {
1161 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_firstlast_only).$langs->trans("Lastname").", ".$langs->trans("Firstname").'</div>';
1162}
1163
1164$moreforfilter = '';
1165
1166// If the user can view third-party other than their own
1167if ($user->hasRight('societe', 'client', 'voir')) {
1168 $langs->load('commercial');
1169 $moreforfilter .= '<div class="divsearchfield">';
1170 $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative');
1171 $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'maxwidth250 widthcentpercentminusx', 1);
1172 $moreforfilter .= '</div>';
1173}
1174
1175if (isModEnabled('category') && $user->hasRight('categorie', 'lire')) {
1176 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
1177 $moreforfilter .= '<div class="divsearchfield">';
1178 $tmptitle = $langs->trans('ContactCategoriesShort');
1179 $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"');
1180 $moreforfilter .= $formother->select_categories(Categorie::TYPE_CONTACT, (int) $search_categ, 'search_categ', 1, $tmptitle);
1181 $moreforfilter .= '</div>';
1182 if (empty($type) || $type == 'c' || $type == 'p') {
1183 $moreforfilter .= '<div class="divsearchfield">';
1184 $tmptitle = '';
1185 if ($type == 'c') {
1186 $tmptitle .= $langs->trans('CustomersCategoriesShort');
1187 } elseif ($type == 'p') {
1188 $tmptitle .= $langs->trans('ProspectsCategoriesShort');
1189 } else {
1190 $tmptitle .= $langs->trans('CustomersProspectsCategoriesShort');
1191 }
1192 $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"');
1193 $moreforfilter .= $formother->select_categories(Categorie::TYPE_CUSTOMER, (int) $search_categ_thirdparty, 'search_categ_thirdparty', 1, $tmptitle);
1194 $moreforfilter .= '</div>';
1195 }
1196
1197 if (isModEnabled("fournisseur") && (empty($type) || $type == 'f')) {
1198 $moreforfilter .= '<div class="divsearchfield">';
1199 $tmptitle = $langs->trans('SuppliersCategoriesShort');
1200 $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"');
1201 $moreforfilter .= $formother->select_categories(Categorie::TYPE_SUPPLIER, (int) $search_categ_supplier, 'search_categ_supplier', 1, $tmptitle);
1202 $moreforfilter .= '</div>';
1203 }
1204}
1205
1206$moreforfilter .= '<div class="divsearchfield">';
1207$moreforfilter .= $formcompany->showRoles("search_roles", $objecttmp, 'edit', $search_roles, 'minwidth500', $langs->transnoentitiesnoconv('ContactRoles'));
1208$moreforfilter .= '</div>';
1209
1210print '<div class="liste_titre liste_titre_bydiv centpercent">';
1211print $moreforfilter;
1212$parameters = array('type' => $type);
1213$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1214print $hookmanager->resPrint;
1215print '</div>';
1216
1217$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
1218$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, $conf->main_checkbox_left_column); // This also change content of $arrayfields
1219$selectedfields .= ((count($arrayofmassactions) && $contextpage != 'poslist') ? $form->showCheckAddButtons('checkforselect', 1) : '');
1220
1221print '<div class="div-table-responsive">';
1222print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
1223
1224// Fields title search
1225// --------------------------------------------------------------------
1226print '<tr class="liste_titre_filter">';
1227// Action column
1228if ($conf->main_checkbox_left_column) {
1229 print '<td class="liste_titre center maxwidthsearch actioncolumn">';
1230 $searchpicto = $form->showFilterButtons('left');
1231 print $searchpicto;
1232 print '</td>';
1233}
1234if (!empty($arrayfields['p.rowid']['checked'])) {
1235 print '<td class="liste_titre">';
1236 print '<input class="flat searchstring" type="text" name="search_id" size="1" value="'.dolPrintHTMLForAttribute($search_id).'">';
1237 print '</td>';
1238}
1239if (!empty($arrayfields['p.lastname']['checked'])) {
1240 print '<td class="liste_titre">';
1241 print '<input class="flat searchstring maxwidth75imp" type="text" name="search_lastname" value="'.dolPrintHTMLForAttribute($search_lastname).'">';
1242 print '</td>';
1243}
1244if (!empty($arrayfields['p.firstname']['checked'])) {
1245 print '<td class="liste_titre">';
1246 print '<input class="flat searchstring maxwidth75imp" type="text" name="search_firstname" value="'.dolPrintHTMLForAttribute($search_firstname).'">';
1247 print '</td>';
1248}
1249if (!empty($arrayfields['p.ref_ext']['checked'])) {
1250 print '<td class="liste_titre">';
1251 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_ref_ext" value="'.dolPrintHTMLForAttribute($search_ref_ext).'">';
1252 print '</td>';
1253}
1254if (!empty($arrayfields['p.poste']['checked'])) {
1255 print '<td class="liste_titre">';
1256 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_poste" value="'.dolPrintHTMLForAttribute($search_poste).'">';
1257 print '</td>';
1258}
1259if (!empty($arrayfields['p.address']['checked'])) {
1260 print '<td class="liste_titre">';
1261 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_address" value="'.dolPrintHTMLForAttribute($search_address).'">';
1262 print '</td>';
1263}
1264if (!empty($arrayfields['p.zip']['checked'])) {
1265 print '<td class="liste_titre">';
1266 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_zip" value="'.dolPrintHTMLForAttribute($search_zip).'">';
1267 print '</td>';
1268}
1269if (!empty($arrayfields['p.town']['checked'])) {
1270 print '<td class="liste_titre">';
1271 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_town" value="'.dolPrintHTMLForAttribute($search_town).'">';
1272 print '</td>';
1273}
1274// State
1275if (!empty($arrayfields['state.nom']['checked'])) {
1276 print '<td class="liste_titre">';
1277 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_state" value="'.dolPrintHTMLForAttribute($search_state).'">';
1278 print '</td>';
1279}
1280// Region
1281if (!empty($arrayfields['region.nom']['checked'])) {
1282 print '<td class="liste_titre">';
1283 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_region" value="'.dolPrintHTMLForAttribute($search_region).'">';
1284 print '</td>';
1285}
1286// Country
1287if (!empty($arrayfields['country.code_iso']['checked'])) {
1288 print '<td class="liste_titre center">';
1289 print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100');
1290 print '</td>';
1291}
1292if (!empty($arrayfields['p.phone']['checked'])) {
1293 print '<td class="liste_titre">';
1294 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_phone_pro" size="6" value="'.dolPrintHTMLForAttribute($search_phone_pro).'">';
1295 print '</td>';
1296}
1297if (!empty($arrayfields['p.phone_perso']['checked'])) {
1298 print '<td class="liste_titre">';
1299 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_phone_perso" size="6" value="'.dolPrintHTMLForAttribute($search_phone_perso).'">';
1300 print '</td>';
1301}
1302if (!empty($arrayfields['p.phone_mobile']['checked'])) {
1303 print '<td class="liste_titre">';
1304 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_phone_mobile" size="6" value="'.dolPrintHTMLForAttribute($search_phone_mobile).'">';
1305 print '</td>';
1306}
1307if (!empty($arrayfields['p.fax']['checked'])) {
1308 print '<td class="liste_titre">';
1309 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_fax" size="6" value="'.dolPrintHTMLForAttribute($search_fax).'">';
1310 print '</td>';
1311}
1312if (!empty($arrayfields['p.email']['checked'])) {
1313 print '<td class="liste_titre">';
1314 print '<input class="flat searchemail maxwidth50imp" type="text" name="search_email" size="6" value="'.dolPrintHTMLForAttribute($search_email).'">';
1315 print '</td>';
1316}
1317if (!empty($arrayfields['unsubscribed']['checked'])) {
1318 print '<td class="liste_titre center">';
1319 print $form->selectarray('search_no_email', array('-1' => '', '0' => $langs->trans('No'), '1' => $langs->trans('Yes')), $search_no_email);
1320 print '</td>';
1321}
1322if (isModEnabled('socialnetworks')) {
1323 foreach ($socialnetworks as $key => $value) {
1324 if ($value['active']) {
1325 if (!empty($arrayfields['p.'.$key]['checked'])) {
1326 print '<td class="liste_titre">';
1327 print '<input class="flat" type="text" name="search_'.$key.'" size="6" value="'.dolPrintHTMLForAttribute($search_[$key]).'">';
1328 print '</td>';
1329 }
1330 }
1331 }
1332}
1333if (!empty($arrayfields['p.fk_soc']['checked']) || !empty($arrayfields['s.nom']['checked'])) {
1334 print '<td class="liste_titre">';
1335 print '<input class="flat searchstring maxwidth75imp" type="text" name="search_societe" size="8" value="'.dolPrintHTMLForAttribute($search_societe).'">';
1336 print '</td>';
1337}
1338// Alias of ThirdParty
1339if (!empty($arrayfields['s.name_alias']['checked'])) {
1340 print '<td class="liste_titre left">';
1341 print '<input class="flat searchstring maxwidth75imp" type="text" name="search_societe_alias" value="'.dolPrintHTMLForAttribute($search_societe_alias).'">';
1342 print '</td>';
1343}
1344if (!empty($arrayfields['p.priv']['checked'])) {
1345 print '<td class="liste_titre center">';
1346 $selectarray = array('0' => $langs->trans("ContactPublic"), '1' => $langs->trans("ContactPrivate"));
1347 print $form->selectarray('search_priv', $selectarray, $search_priv, 1);
1348 print '</td>';
1349}
1350// Prospect level
1351if (!empty($arrayfields['p.fk_prospectlevel']['checked'])) {
1352 print '<td class="liste_titre center">';
1353 print $form->multiselectarray('search_level', $tab_level, $search_level, 0, 0, 'width75', 0, 0, '', '', '', 2);
1354 print '</td>';
1355}
1356// Prospect status
1357if (!empty($arrayfields['p.fk_stcommcontact']['checked'])) {
1358 print '<td class="liste_titre maxwidthonsmartphone center">';
1359 $arraystcomm = array();
1360 foreach ($contactstatic->cacheprospectstatus as $key => $val) {
1361 $arraystcomm[$val['id']] = ($langs->trans("StatusProspect".$val['id']) != "StatusProspect".$val['id'] ? $langs->trans("StatusProspect".$val['id']) : $val['label']);
1362 }
1363 print $form->selectarray('search_stcomm', $arraystcomm, $search_stcomm, -2, 0, 0, '', 0, 0, 0, '', 'nowrap ');
1364 print '</td>';
1365}
1366if (!empty($arrayfields['p.birthday']['checked'])) {
1367 print '<td class="liste_titre center">';
1368 print '<div class="nowrap">';
1369 print $form->selectDate($search_birthday_start ? $search_birthday_start : -1, 'search_birthday_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
1370 print '</div>';
1371 print '<div class="nowrap">';
1372 print $form->selectDate($search_birthday_end ? $search_birthday_end : -1, 'search_birthday_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
1373 print '</div>';
1374 print '</td>';
1375}
1376
1377// Extra fields
1378include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
1379
1380// Fields from hook
1381$parameters = array('arrayfields' => $arrayfields);
1382$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1383print $hookmanager->resPrint;
1384// IP
1385if (!empty($arrayfields['p.ip']['checked'])) {
1386 print '<td class="liste_titre center nowraponall">';
1387 print '</td>';
1388}
1389// Date creation
1390if (!empty($arrayfields['p.datec']['checked'])) {
1391 print '<td class="liste_titre center nowraponall">';
1392 print '<div class="nowrapfordate">';
1393 print $form->selectDate($search_date_creation_start ? $search_date_creation_start : -1, 'search_date_creation_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
1394 print '</div>';
1395 print '<div class="nowrapfordate">';
1396 print $form->selectDate($search_date_creation_end ? $search_date_creation_end : -1, 'search_date_creation_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
1397 print '</div>';
1398 print '</td>';
1399}
1400// Date modification
1401if (!empty($arrayfields['p.tms']['checked'])) {
1402 print '<td class="liste_titre center nowraponall">';
1403 print '<div class="nowrapfordate">';
1404 print $form->selectDate($search_date_modif_start ? $search_date_modif_start : -1, 'search_date_modif_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
1405 print '</div>';
1406 print '<div class="nowrapfordate">';
1407 print $form->selectDate($search_date_modif_end ? $search_date_modif_end : -1, 'search_date_modif_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
1408 print '</div>';
1409 print '</td>';
1410}
1411// Status
1412if (!empty($arrayfields['p.statut']['checked'])) {
1413 print '<td class="liste_titre center minwidth75imp parentonrightofpage">';
1414 print $form->selectarray('search_status', array('-1' => '', '0' => $langs->trans('ActivityCeased'), '1' => $langs->trans('InActivity')), $search_status, 0, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage');
1415 print '</td>';
1416}
1417if (!empty($arrayfields['p.import_key']['checked'])) {
1418 print '<td class="liste_titre center">';
1419 print '<input class="flat searchstring maxwidth50" type="text" name="search_import_key" size="3" value="'.dolPrintHTMLForAttribute($search_import_key).'">';
1420 print '</td>';
1421}
1422// Action column
1423if (!$conf->main_checkbox_left_column) {
1424 print '<td class="liste_titre center maxwidthsearch">';
1425 $searchpicto = $form->showFilterButtons();
1426 print $searchpicto;
1427 print '</td>';
1428}
1429print '</tr>'."\n";
1430
1431$totalarray = array();
1432$totalarray['nbfield'] = 0;
1433
1434// Fields title label
1435// --------------------------------------------------------------------
1436print '<tr class="liste_titre">';
1437if ($conf->main_checkbox_left_column) {
1438 print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
1439 $totalarray['nbfield']++;
1440}
1441if (!empty($arrayfields['p.rowid']['checked'])) {
1442 print_liste_field_titre($arrayfields['p.rowid']['label'], $_SERVER["PHP_SELF"], "p.rowid", "", $param, "", $sortfield, $sortorder);
1443 $totalarray['nbfield']++;
1444}
1445if (!empty($arrayfields['p.lastname']['checked'])) {
1446 print_liste_field_titre($arrayfields['p.lastname']['label'], $_SERVER["PHP_SELF"], "p.lastname", $begin, $param, '', $sortfield, $sortorder);
1447 $totalarray['nbfield']++;
1448}
1449if (!empty($arrayfields['p.firstname']['checked'])) {
1450 print_liste_field_titre($arrayfields['p.firstname']['label'], $_SERVER["PHP_SELF"], "p.firstname", $begin, $param, '', $sortfield, $sortorder);
1451 $totalarray['nbfield']++;
1452}
1453if (!empty($arrayfields['p.ref_ext']['checked'])) {
1454 print_liste_field_titre($arrayfields['p.ref_ext']['label'], $_SERVER["PHP_SELF"], "p.ref_ext", $begin, $param, '', $sortfield, $sortorder);
1455 $totalarray['nbfield']++;
1456}
1457if (!empty($arrayfields['p.poste']['checked'])) {
1458 print_liste_field_titre($arrayfields['p.poste']['label'], $_SERVER["PHP_SELF"], "p.poste", $begin, $param, '', $sortfield, $sortorder);
1459 $totalarray['nbfield']++;
1460}
1461if (!empty($arrayfields['p.address']['checked'])) {
1462 print_liste_field_titre($arrayfields['p.address']['label'], $_SERVER["PHP_SELF"], "p.address", $begin, $param, '', $sortfield, $sortorder);
1463 $totalarray['nbfield']++;
1464}
1465if (!empty($arrayfields['p.zip']['checked'])) {
1466 print_liste_field_titre($arrayfields['p.zip']['label'], $_SERVER["PHP_SELF"], "p.zip", $begin, $param, '', $sortfield, $sortorder);
1467 $totalarray['nbfield']++;
1468}
1469if (!empty($arrayfields['p.town']['checked'])) {
1470 print_liste_field_titre($arrayfields['p.town']['label'], $_SERVER["PHP_SELF"], "p.town", $begin, $param, '', $sortfield, $sortorder);
1471 $totalarray['nbfield']++;
1472}
1473if (!empty($arrayfields['state.nom']['checked'])) {
1474 print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder);
1475 $totalarray['nbfield']++;
1476}
1477if (!empty($arrayfields['region.nom']['checked'])) {
1478 print_liste_field_titre($arrayfields['region.nom']['label'], $_SERVER["PHP_SELF"], "region.nom", "", $param, '', $sortfield, $sortorder);
1479 $totalarray['nbfield']++;
1480}
1481if (!empty($arrayfields['country.code_iso']['checked'])) {
1482 print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "co.code_iso", "", $param, '', $sortfield, $sortorder, 'center ');
1483 $totalarray['nbfield']++;
1484}
1485if (!empty($arrayfields['p.phone']['checked'])) {
1486 print_liste_field_titre($arrayfields['p.phone']['label'], $_SERVER["PHP_SELF"], "p.phone", $begin, $param, '', $sortfield, $sortorder);
1487 $totalarray['nbfield']++;
1488}
1489if (!empty($arrayfields['p.phone_perso']['checked'])) {
1490 print_liste_field_titre($arrayfields['p.phone_perso']['label'], $_SERVER["PHP_SELF"], "p.phone_perso", $begin, $param, '', $sortfield, $sortorder);
1491 $totalarray['nbfield']++;
1492}
1493if (!empty($arrayfields['p.phone_mobile']['checked'])) {
1494 print_liste_field_titre($arrayfields['p.phone_mobile']['label'], $_SERVER["PHP_SELF"], "p.phone_mobile", $begin, $param, '', $sortfield, $sortorder);
1495 $totalarray['nbfield']++;
1496}
1497if (!empty($arrayfields['p.fax']['checked'])) {
1498 print_liste_field_titre($arrayfields['p.fax']['label'], $_SERVER["PHP_SELF"], "p.fax", $begin, $param, '', $sortfield, $sortorder);
1499 $totalarray['nbfield']++;
1500}
1501if (!empty($arrayfields['p.email']['checked'])) {
1502 print_liste_field_titre($arrayfields['p.email']['label'], $_SERVER["PHP_SELF"], "p.email", $begin, $param, '', $sortfield, $sortorder);
1503 $totalarray['nbfield']++;
1504}
1505if (!empty($arrayfields['unsubscribed']['checked'])) {
1506 print_liste_field_titre($arrayfields['unsubscribed']['label'], $_SERVER["PHP_SELF"], "unsubscribed", $begin, $param, '', $sortfield, $sortorder, 'center ');
1507 $totalarray['nbfield']++;
1508}
1509if (isModEnabled('socialnetworks')) {
1510 foreach ($socialnetworks as $key => $value) {
1511 if ($value['active'] && !empty($arrayfields['p.'.$key]['checked'])) {
1512 print_liste_field_titre($arrayfields['p.'.$key]['label'], $_SERVER["PHP_SELF"], "p.".$key, $begin, $param, '', $sortfield, $sortorder);
1513 $totalarray['nbfield']++;
1514 }
1515 }
1516}
1517if (!empty($arrayfields['p.fk_soc']['checked'])) {
1518 print_liste_field_titre($arrayfields['p.fk_soc']['label'], $_SERVER["PHP_SELF"], "p.fk_soc", $begin, $param, '', $sortfield, $sortorder);
1519 $totalarray['nbfield']++;
1520}
1521if (!empty($arrayfields['s.nom']['checked'])) {
1522 print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", $begin, $param, '', $sortfield, $sortorder);
1523 $totalarray['nbfield']++;
1524}
1525if (!empty($arrayfields['s.name_alias']['checked'])) {
1526 // False positive @phan-suppress-next-line PhanTypeInvalidDimOffset
1527 print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"], "s.name_alias", $begin, $param, '', $sortfield, $sortorder);
1528 $totalarray['nbfield']++;
1529}
1530if (!empty($arrayfields['p.priv']['checked'])) {
1531 print_liste_field_titre($arrayfields['p.priv']['label'], $_SERVER["PHP_SELF"], "p.priv", $begin, $param, '', $sortfield, $sortorder, 'center ');
1532 $totalarray['nbfield']++;
1533}
1534if (!empty($arrayfields['p.fk_prospectlevel']['checked'])) {
1535 print_liste_field_titre($arrayfields['p.fk_prospectlevel']['label'], $_SERVER["PHP_SELF"], "p.fk_prospectlevel", "", $param, '', $sortfield, $sortorder, 'center ');
1536 $totalarray['nbfield']++;
1537}
1538if (!empty($arrayfields['p.fk_stcommcontact']['checked'])) {
1539 print_liste_field_titre($arrayfields['p.fk_stcommcontact']['label'], $_SERVER["PHP_SELF"], "p.fk_stcommcontact", "", $param, '', $sortfield, $sortorder, 'center ');
1540 $totalarray['nbfield']++;
1541}
1542if (!empty($arrayfields['p.birthday']['checked'])) {
1543 print_liste_field_titre($arrayfields['p.birthday']['label'], $_SERVER["PHP_SELF"], "p.birthday", "", $param, '', $sortfield, $sortorder, 'center ');
1544 $totalarray['nbfield']++;
1545}
1546// Extra fields
1547include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
1548// Hook fields
1549$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'totalarray' => &$totalarray);
1550$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1551print $hookmanager->resPrint;
1552// IP
1553if (!empty($arrayfields['p.ip']['checked'])) {
1554 print_liste_field_titre($arrayfields['p.ip']['label'], $_SERVER["PHP_SELF"], "p.ip", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1555 $totalarray['nbfield']++;
1556}
1557// Date creation
1558if (!empty($arrayfields['p.datec']['checked'])) {
1559 print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1560 $totalarray['nbfield']++;
1561}
1562if (!empty($arrayfields['p.tms']['checked'])) {
1563 print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1564 $totalarray['nbfield']++;
1565}
1566if (!empty($arrayfields['p.note_public']['checked'])) {
1567 print_liste_field_titre($arrayfields['p.note_public']['label'], $_SERVER["PHP_SELF"], "p.note_public", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1568 $totalarray['nbfield']++;
1569}
1570if (!empty($arrayfields['p.note_private']['checked'])) {
1571 print_liste_field_titre($arrayfields['p.note_private']['label'], $_SERVER["PHP_SELF"], "p.note_private", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1572 $totalarray['nbfield']++;
1573}
1574if (!empty($arrayfields['p.statut']['checked'])) {
1575 print_liste_field_titre($arrayfields['p.statut']['label'], $_SERVER["PHP_SELF"], "p.statut", "", $param, '', $sortfield, $sortorder, 'center ');
1576 $totalarray['nbfield']++;
1577}
1578if (!empty($arrayfields['p.import_key']['checked'])) {
1579 print_liste_field_titre($arrayfields['p.import_key']['label'], $_SERVER["PHP_SELF"], "p.import_key", "", $param, '', $sortfield, $sortorder, 'center ');
1580 $totalarray['nbfield']++;
1581}
1582if (!$conf->main_checkbox_left_column) {
1583 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
1584 $totalarray['nbfield']++;
1585}
1586print "</tr>\n";
1587
1588
1589// Loop on record
1590// --------------------------------------------------------------------
1591$i = 0;
1592$savnbfield = $totalarray['nbfield'];
1593$totalarray = array();
1594$totalarray['nbfield'] = 0;
1595$imaxinloop = ($limit ? min($num, $limit) : $num);
1596while ($i < $imaxinloop) {
1597 $obj = $db->fetch_object($resql);
1598 if (empty($obj)) {
1599 break; // Should not happen
1600 }
1601
1602 $arraysocialnetworks = (array) json_decode($obj->socialnetworks, true);
1603 $contactstatic->id = $obj->rowid;
1604 $contactstatic->ref_ext = $obj->ref_ext;
1605 $contactstatic->lastname = $obj->lastname;
1606 $contactstatic->firstname = $obj->firstname;
1607 $contactstatic->status = $obj->statut;
1608 $contactstatic->statut = $obj->statut;
1609 $contactstatic->poste = $obj->poste;
1610 $contactstatic->email = $obj->email;
1611 $contactstatic->phone_pro = $obj->phone_pro;
1612 $contactstatic->phone_perso = $obj->phone_perso;
1613 $contactstatic->phone_mobile = $obj->phone_mobile;
1614 $contactstatic->address = $obj->address;
1615 $contactstatic->zip = $obj->zip;
1616 $contactstatic->town = $obj->town;
1617 $contactstatic->state = $obj->state_name;
1618 $contactstatic->region = $obj->region_name;
1619 $contactstatic->socialnetworks = $arraysocialnetworks;
1620 $contactstatic->country = $obj->country;
1621 $contactstatic->country_code = $obj->country_code;
1622 $contactstatic->photo = $obj->photo;
1623 $contactstatic->import_key = $obj->import_key;
1624 $contactstatic->photo = $obj->photo;
1625 $contactstatic->fk_prospectlevel = $obj->fk_prospectlevel;
1626
1627 $object = $contactstatic;
1628
1629 if ($mode == 'kanban') {
1630 if ($i == 0) {
1631 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
1632 print '<div class="box-flex-container kanban">';
1633 }
1634 // Output Kanban
1635 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1636 $selected = 0;
1637 if (in_array($object->id, $arrayofselected)) {
1638 $selected = 1;
1639 }
1640 }
1641 if ($obj->socid > 0) {
1642 $contactstatic->fetch_thirdparty($obj->socid);
1643 }
1644 print $contactstatic->getKanbanView('', array('selected' => in_array($contactstatic->id, $arrayofselected)));
1645 if ($i == ($imaxinloop - 1)) {
1646 print '</div>';
1647 print '</td></tr>';
1648 }
1649 } else {
1650 // Show here line of result
1651 print '<tr data-rowid="'.$object->id.'" class="oddeven row-with-select"';
1652 if ($contextpage == 'poslist') {
1653 print ' onclick="location.href=\'list.php?action=change&token='.newToken().'&contextpage=poslist&idcustomer='.$obj->socid.'&idcontact='.$obj->rowid.'&place='.urlencode($place).'\'"';
1654 }
1655 print '>';
1656
1657 // Action column
1658 if ($conf->main_checkbox_left_column) {
1659 print '<td class="nowrap center">';
1660 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1661 $selected = 0;
1662 if (in_array($obj->rowid, $arrayofselected)) {
1663 $selected = 1;
1664 }
1665 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
1666 }
1667 print '</td>';
1668 if (!$i) {
1669 $totalarray['nbfield']++;
1670 }
1671 }
1672
1673 // ID
1674 if (!empty($arrayfields['p.rowid']['checked'])) {
1675 print '<td class="tdoverflowmax50">';
1676 print dolPrintHTML($obj->rowid);
1677 print "</td>\n";
1678 if (!$i) {
1679 $totalarray['nbfield']++;
1680 }
1681 }
1682
1683 // (Last) Name
1684 if (!empty($arrayfields['p.lastname']['checked'])) {
1685 print '<td class="middle tdoverflowmax150" title="'.dolPrintHTMLForAttribute($contactstatic->lastname).'">';
1686 if ($contextpage == 'poslist') {
1687 print $contactstatic->lastname;
1688 } else {
1689 print $contactstatic->getNomUrl(1);
1690 }
1691 print '</td>';
1692 if (!$i) {
1693 $totalarray['nbfield']++;
1694 }
1695 }
1696
1697 // Firstname
1698 if (!empty($arrayfields['p.firstname']['checked'])) {
1699 print '<td class="tdoverflowmax150" title="'.dolPrintHTMLForAttribute($obj->firstname).'">';
1700 print dolPrintHTML($obj->firstname);
1701 print '</td>';
1702 if (!$i) {
1703 $totalarray['nbfield']++;
1704 }
1705 }
1706
1707 // Ref ext
1708 if (!empty($arrayfields['p.ref_ext']['checked'])) {
1709 print '<td class="middle tdoverflowmax100" title="'.dolPrintHTMLForAttribute($contactstatic->ref_ext).'">';
1710 print dolPrintHTML($contactstatic->ref_ext);
1711 print '</td>';
1712 if (!$i) {
1713 $totalarray['nbfield']++;
1714 }
1715 }
1716
1717 // Job position
1718 if (!empty($arrayfields['p.poste']['checked'])) {
1719 print '<td class="tdoverflowmax100">'.dolPrintHTML($obj->poste).'</td>';
1720 if (!$i) {
1721 $totalarray['nbfield']++;
1722 }
1723 }
1724
1725 // Address
1726 if (!empty($arrayfields['p.address']['checked'])) {
1727 print '<td>'.dolPrintHTML($obj->address).'</td>';
1728 if (!$i) {
1729 $totalarray['nbfield']++;
1730 }
1731 }
1732
1733 // Zip
1734 if (!empty($arrayfields['p.zip']['checked'])) {
1735 print '<td>'.dolPrintHTML($obj->zip).'</td>';
1736 if (!$i) {
1737 $totalarray['nbfield']++;
1738 }
1739 }
1740
1741 // Town
1742 if (!empty($arrayfields['p.town']['checked'])) {
1743 print '<td class="tdoverflowmax100" title="'.dolPrintHTMLForAttribute($obj->town).'">'.dolPrintHTML($obj->town).'</td>';
1744 if (!$i) {
1745 $totalarray['nbfield']++;
1746 }
1747 }
1748 // State
1749 if (!empty($arrayfields['state.nom']['checked'])) {
1750 print "<td>".dolPrintHTML($obj->state_name)."</td>\n";
1751 if (!$i) {
1752 $totalarray['nbfield']++;
1753 }
1754 }
1755 // Region
1756 if (!empty($arrayfields['region.nom']['checked'])) {
1757 print "<td>".dolPrintHTML($obj->region_name)."</td>\n";
1758 if (!$i) {
1759 $totalarray['nbfield']++;
1760 }
1761 }
1762 // Country
1763 if (!empty($arrayfields['country.code_iso']['checked'])) {
1764 print '<td class="center">';
1765 $tmparray = getCountry($obj->fk_pays, 'all');
1766 print dolPrintHTML($tmparray['label']);
1767 print '</td>';
1768 if (!$i) {
1769 $totalarray['nbfield']++;
1770 }
1771 }
1772
1773 // Phone pro
1774 if (!empty($arrayfields['p.phone']['checked'])) {
1775 print '<td class="nowraponall tdoverflowmax150">'.dol_print_phone($obj->phone_pro, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL', ' ', 'phone').'</td>';
1776 if (!$i) {
1777 $totalarray['nbfield']++;
1778 }
1779 }
1780
1781 // Phone perso
1782 if (!empty($arrayfields['p.phone_perso']['checked'])) {
1783 print '<td class="nowraponall tdoverflowmax150">'.dol_print_phone($obj->phone_perso, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL', ' ', 'phone').'</td>';
1784 if (!$i) {
1785 $totalarray['nbfield']++;
1786 }
1787 }
1788
1789 // Phone mobile
1790 if (!empty($arrayfields['p.phone_mobile']['checked'])) {
1791 print '<td class="nowraponall tdoverflowmax150">'.dol_print_phone($obj->phone_mobile, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL', ' ', 'mobile').'</td>';
1792 if (!$i) {
1793 $totalarray['nbfield']++;
1794 }
1795 }
1796
1797 // Fax
1798 if (!empty($arrayfields['p.fax']['checked'])) {
1799 print '<td class="nowraponall tdoverflowmax150">'.dol_print_phone($obj->fax, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL', ' ', 'fax').'</td>';
1800 if (!$i) {
1801 $totalarray['nbfield']++;
1802 }
1803 }
1804
1805 // EMail
1806 if (!empty($arrayfields['p.email']['checked'])) {
1807 print '<td class="nowraponall tdoverflowmax200" title="'.dolPrintHTMLForAttribute($obj->email).'">';
1808 if ($contextpage == 'poslist') {
1809 print $obj->email;
1810 } else {
1811 $showinvalidemail = getDolGlobalInt('MAIN_SHOW_INVALID_EMAIL_IN_LIST', 1); // in list, we check only syntax of emails
1812 print dol_print_email($obj->email, $obj->rowid, $obj->socid, 1, 18, $showinvalidemail, 1);
1813 }
1814 print '</td>';
1815 if (!$i) {
1816 $totalarray['nbfield']++;
1817 }
1818 }
1819
1820 // No EMail Subscription
1821 if (!empty($arrayfields['unsubscribed']['checked'])) {
1822 print '<td class="center">';
1823 if (empty($obj->email)) {
1824 //print '<span class="opacitymedium">'.$langs->trans("NoEmail").'</span>';
1825 } else {
1826 print yn(($obj->unsubscribed > 0) ? 1 : 0);
1827 }
1828 print '</td>';
1829 if (!$i) {
1830 $totalarray['nbfield']++;
1831 }
1832 }
1833
1834 // Social Networks
1835 if (isModEnabled('socialnetworks')) {
1836 foreach ($socialnetworks as $key => $value) {
1837 if ($value['active'] && !empty($arrayfields['p.'.$key]['checked'])) {
1838 print '<td class="tdoverflowmax100">'.(empty($arraysocialnetworks[$key]) ? '' : dol_print_socialnetworks($arraysocialnetworks[$key], $obj->rowid, $obj->socid, $key, $socialnetworks)).'</td>';
1839 if (!$i) {
1840 $totalarray['nbfield']++;
1841 }
1842 }
1843 }
1844 }
1845
1846 // Company / Third Party
1847 if (!empty($arrayfields['p.fk_soc']['checked']) || !empty($arrayfields['s.nom']['checked'])) {
1848 print '<td class="tdoverflowmax125">';
1849 if ($obj->socid) {
1850 $objsoc = new Societe($db);
1851 $objsoc->fetch($obj->socid);
1852 $option_link = 'customer';
1853 if ($objsoc->client == 0 && $objsoc->fournisseur > 0) {
1854 $option_link = 'supplier';
1855 } elseif ($objsoc->client == 0 && $objsoc->fournisseur == 0) {
1856 $option_link = '';
1857 }
1858 if ($contextpage == 'poslist') {
1859 print $objsoc->name;
1860 } else {
1861 print $objsoc->getNomUrl(1, $option_link, 100, 0, 1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1);
1862 }
1863 } else {
1864 print '&nbsp;';
1865 }
1866 print '</td>';
1867 if (!$i) {
1868 $totalarray['nbfield']++;
1869 }
1870 }
1871
1872 // Alias name
1873 if (!empty($arrayfields['s.name_alias']['checked'])) {
1874 print '<td class="tdoverflowmax100" title="'.dolPrintHTMLForAttribute($obj->alias).'">';
1875 print dolPrintHTML($obj->alias);
1876 print '</td>';
1877 if (!$i) {
1878 $totalarray['nbfield']++;
1879 }
1880 }
1881
1882 // Private/Public
1883 if (!empty($arrayfields['p.priv']['checked'])) {
1884 print '<td class="center">';
1885 print $contactstatic->LibPubPriv($obj->priv, 2);
1886 print '</td>';
1887 if (!$i) {
1888 $totalarray['nbfield']++;
1889 }
1890 }
1891
1892 // Prospect Level
1893 if (!empty($arrayfields['p.fk_prospectlevel']['checked'])) {
1894 print '<td class="center">';
1895 print $contactstatic->getLibProspLevel();
1896 print "</td>";
1897 if (!$i) {
1898 $totalarray['nbfield']++;
1899 }
1900 }
1901
1902 // Prospect status
1903 if (!empty($arrayfields['p.fk_stcommcontact']['checked'])) {
1904 print '<td class="center nowrap"><div class="nowrap">';
1905 print '<div class="inline-block">'.$contactstatic->libProspCommStatut($obj->stcomm_id, 2, $contactstatic->cacheprospectstatus[$obj->stcomm_id]['label'], $obj->stcomm_picto);
1906 print '</div> - <div class="inline-block">';
1907 foreach ($contactstatic->cacheprospectstatus as $key => $val) {
1908 $titlealt = 'default';
1909 if (!empty($val['code']) && !in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) {
1910 $titlealt = $val['label'];
1911 }
1912 if ($obj->stcomm_id != $val['id']) {
1913 print '<a class="pictosubstatus" href="'.$_SERVER["PHP_SELF"].'?stcommcontactid='.$obj->rowid.'&stcomm='.urlencode((string) ($val['code'])).'&action=setstcomm&token='.newToken().$param.($page ? '&page='.urlencode((string) ($page)) : '').'">'.img_action($titlealt, $val['code'], $val['picto']).'</a>';
1914 }
1915 }
1916 print '</div></div></td>';
1917 if (!$i) {
1918 $totalarray['nbfield']++;
1919 }
1920 }
1921
1922 // Birthday
1923 if (!empty($arrayfields['p.birthday']['checked'])) {
1924 print '<td class="center nowraponall">';
1925 print dol_print_date($db->jdate($obj->birthday), 'day', 'tzuser');
1926 print '</td>';
1927 if (!$i) {
1928 $totalarray['nbfield']++;
1929 }
1930 }
1931
1932 // Extra fields
1933 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1934
1935 // Fields from hook
1936 $parameters = array('arrayfields' => $arrayfields, 'object' => $object, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray);
1937 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1938 print $hookmanager->resPrint;
1939
1940 // IP creation
1941 if (!empty($arrayfields['p.ip']['checked'])) {
1942 print '<td class="center nowraponall">';
1943 print dol_print_ip($obj->ip);
1944 print '</td>';
1945 if (!$i) {
1946 $totalarray['nbfield']++;
1947 }
1948 }
1949
1950 // Date creation
1951 if (!empty($arrayfields['p.datec']['checked'])) {
1952 print '<td class="center nowraponall">';
1953 print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
1954 print '</td>';
1955 if (!$i) {
1956 $totalarray['nbfield']++;
1957 }
1958 }
1959
1960 // Date modification
1961 if (!empty($arrayfields['p.tms']['checked'])) {
1962 print '<td class="center nowraponall">';
1963 print dol_print_date($db->jdate($obj->date_modification), 'dayhour', 'tzuser');
1964 print '</td>';
1965 if (!$i) {
1966 $totalarray['nbfield']++;
1967 }
1968 }
1969
1970 // Note public
1971 if (!empty($arrayfields['p.note_public']['checked'])) {
1972 print '<td class="flat maxwidth250imp">';
1973 print '<div class="small lineheightsmall twolinesmax-normallineheight">'.dolPrintHTML(dolGetFirstLineOfText($obj->note_public, 5)).'</div>';
1974 print '</td>';
1975 if (!$i) {
1976 $totalarray['nbfield']++;
1977 }
1978 }
1979 // Note private
1980 if (!empty($arrayfields['p.note_private']['checked'])) {
1981 print '<td class="flat maxwidth250imp">';
1982 print '<div class="small lineheightsmall twolinesmax-normallineheight">'.dolPrintHTML(dolGetFirstLineOfText($obj->note_private, 5)).'</div>';
1983 print '</td>';
1984 if (!$i) {
1985 $totalarray['nbfield']++;
1986 }
1987 }
1988
1989 // Status
1990 if (!empty($arrayfields['p.statut']['checked'])) {
1991 print '<td class="center">'.$contactstatic->getLibStatut(5).'</td>';
1992 if (!$i) {
1993 $totalarray['nbfield']++;
1994 }
1995 }
1996
1997 // Import key
1998 if (!empty($arrayfields['p.import_key']['checked'])) {
1999 print '<td class="tdoverflowmax100">';
2000 print dolPrintHTML($obj->import_key);
2001 print "</td>\n";
2002 if (!$i) {
2003 $totalarray['nbfield']++;
2004 }
2005 }
2006
2007 // Action column
2008 if (!$conf->main_checkbox_left_column) {
2009 print '<td class="nowrap center">';
2010 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
2011 $selected = 0;
2012 if (in_array($obj->rowid, $arrayofselected)) {
2013 $selected = 1;
2014 }
2015 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
2016 }
2017 print '</td>';
2018 if (!$i) {
2019 $totalarray['nbfield']++;
2020 }
2021 }
2022
2023 print '</tr>'."\n";
2024 }
2025 $i++;
2026}
2027
2028// Show total line
2029include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
2030
2031// If no record found
2032if ($num == 0) {
2033 $colspan = 1;
2034 foreach ($arrayfields as $key => $val) {
2035 if (!empty($val['checked'])) {
2036 $colspan++;
2037 }
2038 }
2039 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
2040}
2041
2042$db->free($resql);
2043
2044$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
2045$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
2046print $hookmanager->resPrint;
2047
2048print '</table>'."\n";
2049print '</div>'."\n";
2050
2051print '</form>'."\n";
2052
2053// End of page
2054llxFooter();
2055$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
$totalarray
Definition list.php:501
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
Class to manage contact/addresses.
Class to manage standard extra fields.
Class to manage invoices.
Class to build HTML component for third parties management Only common components are here.
Class to manage generation of HTML components Only common components must be here.
Class to help generate other html components Only common components are here.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
dol_now($mode='gmt')
Return date for now.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='', $useCache=true)
Return an id or code from a code or id.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
natural_search($fields, $value, $mode=0, $nofirstand=0, $sqltoadd='')
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
getArrayOfSocialNetworks()
Get array of social network dictionary.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
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.
dolPrintHTMLForAttribute($s, $escapeonlyhtmltags=0, $allowothertags=array())
Return a string ready to be output into an HTML attribute (alt, title, data-html, ....
Definition html.lib.php:99
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
dolGetButtonTitleSeparator($moreClass="")
Add space between dolGetButtonTitle.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
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.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.