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