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