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