38 require
'../main.inc.php';
39 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
40 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
41 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
42 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
45 $langs->loadLangs(array(
"companies",
"suppliers",
"categories"));
50 $action =
GETPOST(
'action',
'aZ09');
51 $massaction =
GETPOST(
'massaction',
'alpha');
52 $show_files =
GETPOST(
'show_files',
'int');
53 $confirm =
GETPOST(
'confirm',
'alpha');
54 $toselect =
GETPOST(
'toselect',
'array');
55 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'contactlist';
56 $mode =
GETPOST(
'mode',
'alpha');
60 $contactid =
GETPOST(
'id',
'int');
63 $socid = $user->socid;
67 $search_all = trim((
GETPOST(
'search_all',
'alphanohtml') !=
'') ?
GETPOST(
'search_all',
'alphanohtml') :
GETPOST(
'sall',
'alphanohtml'));
68 $search_cti = preg_replace(
'/^0+/',
'', preg_replace(
'/[^0-9]/',
'',
GETPOST(
'search_cti',
'alphanohtml')));
69 $search_phone =
GETPOST(
"search_phone",
'alpha');
71 $search_id =
GETPOST(
"search_id",
"int");
72 $search_firstlast_only =
GETPOST(
"search_firstlast_only",
'alpha');
73 $search_lastname =
GETPOST(
"search_lastname",
'alpha');
74 $search_firstname =
GETPOST(
"search_firstname",
'alpha');
75 $search_societe =
GETPOST(
"search_societe",
'alpha');
76 $search_societe_alias =
GETPOST(
"search_societe_alias",
'alpha');
77 $search_poste =
GETPOST(
"search_poste",
'alpha');
78 $search_phone_perso =
GETPOST(
"search_phone_perso",
'alpha');
79 $search_phone_pro =
GETPOST(
"search_phone_pro",
'alpha');
80 $search_phone_mobile =
GETPOST(
"search_phone_mobile",
'alpha');
81 $search_fax =
GETPOST(
"search_fax",
'alpha');
82 $search_email =
GETPOST(
"search_email",
'alpha');
84 $search_no_email =
GETPOSTISSET(
"search_no_email") ?
GETPOST(
"search_no_email",
'int') : -1;
86 $search_no_email = -1;
89 foreach ($socialnetworks as $key => $value) {
90 if ($value[
'active']) {
91 $search_[$key] =
GETPOST(
"search_".$key,
'alpha');
95 $search_priv =
GETPOST(
"search_priv",
'alpha');
96 $search_categ =
GETPOST(
"search_categ",
'int');
97 $search_categ_thirdparty =
GETPOST(
"search_categ_thirdparty",
'int');
98 $search_categ_supplier =
GETPOST(
"search_categ_supplier",
'int');
99 $search_status =
GETPOST(
"search_status",
'int');
100 $search_type =
GETPOST(
'search_type',
'alpha');
101 $search_address =
GETPOST(
'search_address',
'alpha');
102 $search_zip =
GETPOST(
'search_zip',
'alpha');
103 $search_town =
GETPOST(
'search_town',
'alpha');
104 $search_import_key =
GETPOST(
"search_import_key",
'alpha');
105 $search_country =
GETPOST(
"search_country",
'intcomma');
106 $search_roles =
GETPOST(
"search_roles",
'array');
107 $search_level =
GETPOST(
"search_level",
'array');
108 $search_stcomm =
GETPOST(
'search_stcomm',
'int');
110 if ($search_status ===
'') {
113 if ($search_no_email ===
'') {
114 $search_no_email = -1;
117 $optioncss =
GETPOST(
'optioncss',
'alpha');
121 $view =
GETPOST(
"view",
'alpha');
123 $userid =
GETPOST(
'userid',
'int');
127 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
128 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
129 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
135 $sortfield =
"p.lastname";
137 if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
141 $offset = $limit * $page;
142 $pageprev = $page - 1;
143 $pagenext = $page + 1;
146 $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans(
"Contacts") : $langs->trans(
"ContactsAddresses"));
148 if (empty($contextpage) || $contextpage ==
'contactlist') {
149 $contextpage =
'contactprospectlist';
151 $title .=
' ('.$langs->trans(
"ThirdPartyProspects").
')';
152 $urlfiche =
"card.php";
155 if (empty($contextpage) || $contextpage ==
'contactlist') {
156 $contextpage =
'contactcustomerlist';
158 $title .=
' ('.$langs->trans(
"ThirdPartyCustomers").
')';
159 $urlfiche =
"card.php";
160 } elseif ($type ==
"f") {
161 if (empty($contextpage) || $contextpage ==
'contactlist') {
162 $contextpage =
'contactsupplierlist';
164 $title .=
' ('.$langs->trans(
"ThirdPartySuppliers").
')';
165 $urlfiche =
"card.php";
166 } elseif ($type ==
"o") {
167 if (empty($contextpage) || $contextpage ==
'contactlist') {
168 $contextpage =
'contactotherlist';
170 $title .=
' ('.$langs->trans(
"OthersNotLinkedToThirdParty").
')';
177 $hookmanager->initHooks(array($contextpage));
180 $extrafields->fetch_name_optionals_label($object->table_element);
182 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
185 $fieldstosearchall = array();
186 foreach ($object->fields as $key => $val) {
188 if (!empty($user->socid) && $key ==
"note_private") {
192 if (empty($val[
'searchall'])) {
196 $fieldstosearchall[
'p.'.$key] = $val[
'label'];
200 if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) {
201 $fieldstosearchall[
's.nom'] =
"ThirdParty";
202 $fieldstosearchall[
's.name_alias'] =
"AliasNames";
205 $parameters = array(
'fieldstosearchall'=>$fieldstosearchall);
206 $reshook = $hookmanager->executeHooks(
'completeFieldsToSearchAll', $parameters, $object, $action);
208 $fieldstosearchall = empty($hookmanager->resArray[
'fieldstosearchall']) ? array() : $hookmanager->resArray[
'fieldstosearchall'];
209 } elseif ($reshook == 0) {
210 $fieldstosearchall = array_merge($fieldstosearchall, empty($hookmanager->resArray[
'fieldstosearchall']) ? array() : $hookmanager->resArray[
'fieldstosearchall']);
214 $arrayfields = array();
215 foreach ($object->fields as $key => $val) {
217 if (!empty($val[
'visible'])) {
218 $visible = (int)
dol_eval($val[
'visible'], 1);
219 $arrayfields[
'p.'.$key] = array(
220 'label'=>$val[
'label'],
221 'checked'=>(($visible < 0) ? 0 : 1),
222 'enabled'=>(abs($visible) != 3 &&
dol_eval($val[
'enabled'], 1)),
223 'position'=>$val[
'position'],
224 'help'=> isset($val[
'help']) ? $val[
'help'] :
''
230 $arrayfields[
'country.code_iso'] = array(
'label'=>
"Country",
'position'=>66,
'checked'=>0);
231 if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) {
232 $arrayfields[
's.nom'] = array(
'label'=>
"ThirdParty",
'position'=>113,
'checked'=> 1);
233 $arrayfields[
's.name_alias'] = array(
'label'=>
"AliasNameShort",
'position'=>114,
'checked'=> 1);
236 $arrayfields[
'unsubscribed'] = array(
243 foreach ($socialnetworks as $key => $value) {
244 if ($value[
'active']) {
245 $arrayfields[
'p.'.$key] = array(
246 'label' => $value[
'label'],
255 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
262 if (($id > 0 || !empty($ref)) && $action !=
'add') {
263 $result = $object->fetch($id, $ref);
269 $permissiontoread = $user->hasRight(
'societe',
'lire');
270 $permissiontodelete = $user->hasRight(
'societe',
'supprimer');
271 $permissiontoadd = $user->hasRight(
'societe',
'creer');
280 if (
GETPOST(
'cancel',
'alpha')) {
284 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
288 $parameters = array();
289 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
294 if (empty($reshook)) {
296 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
299 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
302 $search_firstlast_only =
"";
303 $search_lastname =
"";
304 $search_firstname =
"";
305 $search_societe =
"";
306 $search_societe_alias =
"";
308 $search_address =
"";
310 $search_country =
"";
313 $search_phone_perso =
"";
314 $search_phone_pro =
"";
315 $search_phone_mobile =
"";
318 $search_no_email = -1;
320 foreach ($socialnetworks as $key => $value) {
321 if ($value[
'active']) {
331 $search_categ_thirdparty =
'';
332 $search_categ_supplier =
'';
333 $search_import_key =
'';
335 $search_array_options = array();
336 $search_roles = array();
340 $objectclass =
'Contact';
341 $objectlabel =
'Contact';
342 $uploaddir = $conf->societe->dir_output;
343 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
345 if ($action ==
'setstcomm') {
347 $result = $object->fetch(
GETPOST(
'stcommcontactid'));
349 $result = $object->update($object->id, $user);
358 if ($search_priv < 0) {
370 $contactstatic =
new Contact($db);
374 $title = $langs->trans(
"Contacts").
" - ".$langs->trans(
"List");
375 $help_url =
'EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Empresas';
379 if (!empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES)) {
380 $contactstatic->loadCacheOfProspStatus();
383 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
384 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
387 $tab_level = array();
388 $sql =
"SELECT code, label, sortorder";
389 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_prospectcontactlevel";
390 $sql .=
" WHERE active > 0";
391 $sql .=
" ORDER BY sortorder";
392 $resql = $db->query(
$sql);
394 while ($obj = $db->fetch_object($resql)) {
396 $level = $langs->trans($obj->code);
397 if ($level == $obj->code) {
398 $level = $langs->trans($obj->label);
400 $tab_level[$obj->code] = $level;
408 $sql =
"SELECT s.rowid as socid, s.nom as name, s.name_alias as alias,";
409 $sql .=
" p.rowid, p.lastname as lastname, p.statut, p.firstname, p.address, p.zip, p.town, p.poste, p.email,";
410 $sql .=
" p.socialnetworks, p.photo,";
411 $sql .=
" p.phone as phone_pro, p.phone_mobile, p.phone_perso, p.fax, p.fk_pays, p.priv, p.datec as date_creation, p.tms as date_update,";
412 $sql .=
" p.import_key, p.fk_stcommcontact as stcomm_id, p.fk_prospectlevel,";
413 $sql .=
" st.libelle as stcomm, st.picto as stcomm_picto,";
414 $sql .=
" co.label as country, co.code as country_code";
416 if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
417 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
418 $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
422 $sql .=
", (SELECT count(*) FROM ".MAIN_DB_PREFIX.
"mailing_unsubscribe WHERE email = p.email) as unsubscribed";
426 $parameters = array();
427 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
428 $sql .= $hookmanager->resPrint;
429 $sql = preg_replace(
'/,\s*$/',
'',
$sql);
433 $sql .=
" FROM ".MAIN_DB_PREFIX.
"socpeople as p";
434 if (isset($extrafields->attributes[$object->table_element][
'label']) && is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label'])) {
435 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (p.rowid = ef.fk_object)";
437 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as co ON co.rowid = p.fk_pays";
438 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid = p.fk_soc";
439 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_stcommcontact as st ON st.id = p.fk_stcommcontact";
440 if (empty($user->rights->societe->client->voir) && !$socid) {
441 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON s.rowid = sc.fk_soc";
445 $parameters = array();
446 $reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object, $action);
447 $sql .= $hookmanager->resPrint;
448 $sql .=
' WHERE p.entity IN ('.getEntity(
'contact').
')';
449 if (empty($user->rights->societe->client->voir) && !$socid) {
450 $sql .=
" AND (sc.fk_user = ".((int) $user->id).
" OR p.fk_soc IS NULL)";
452 if (!empty($userid)) {
453 $sql .=
" AND p.fk_user_creat=".((int) $userid);
458 if ($search_stcomm !=
'' && $search_stcomm != -2) {
463 if ($search_priv !=
'0' && $search_priv !=
'1') {
464 $sql .=
" AND (p.priv='0' OR (p.priv='1' AND p.fk_user_creat=".((int) $user->id).
"))";
466 if ($search_priv ==
'0') {
467 $sql .=
" AND p.priv='0'";
469 if ($search_priv ==
'1') {
470 $sql .=
" AND (p.priv='1' AND p.fk_user_creat=".((int) $user->id).
")";
476 $searchCategoryContactList = $search_categ ? array($search_categ) : array();
477 $searchCategoryContactOperator = 0;
479 if (!empty($searchCategoryContactList)) {
480 $searchCategoryContactSqlList = array();
481 $listofcategoryid =
'';
482 foreach ($searchCategoryContactList as $searchCategoryContact) {
483 if (intval($searchCategoryContact) == -2) {
484 $searchCategoryContactSqlList[] =
"NOT EXISTS (SELECT ck.fk_socpeople FROM ".MAIN_DB_PREFIX.
"categorie_contact as ck WHERE p.rowid = ck.fk_socpeople)";
485 } elseif (intval($searchCategoryContact) > 0) {
486 if ($searchCategoryContactOperator == 0) {
487 $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).
")";
489 $listofcategoryid .= ($listofcategoryid ?
', ' :
'') .((
int) $searchCategoryContact);
493 if ($listofcategoryid) {
494 $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).
"))";
496 if ($searchCategoryContactOperator == 1) {
497 if (!empty($searchCategoryContactSqlList)) {
498 $sql .=
" AND (".implode(
' OR ', $searchCategoryContactSqlList).
")";
501 if (!empty($searchCategoryContactSqlList)) {
502 $sql .=
" AND (".implode(
' AND ', $searchCategoryContactSqlList).
")";
508 $searchCategoryCustomerList = $search_categ_thirdparty ? array($search_categ_thirdparty) : array();
509 $searchCategoryCustomerOperator = 0;
511 if (!empty($searchCategoryCustomerList)) {
512 $searchCategoryCustomerSqlList = array();
513 $listofcategoryid =
'';
514 foreach ($searchCategoryCustomerList as $searchCategoryCustomer) {
515 if (intval($searchCategoryCustomer) == -2) {
516 $searchCategoryCustomerSqlList[] =
"NOT EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX.
"categorie_societe as ck WHERE s.rowid = ck.fk_soc)";
517 } elseif (intval($searchCategoryCustomer) > 0) {
518 if ($searchCategoryCustomerOperator == 0) {
519 $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).
")";
521 $listofcategoryid .= ($listofcategoryid ?
', ' :
'') .((
int) $searchCategoryCustomer);
525 if ($listofcategoryid) {
526 $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).
"))";
528 if ($searchCategoryCustomerOperator == 1) {
529 if (!empty($searchCategoryCustomerSqlList)) {
530 $sql .=
" AND (".implode(
' OR ', $searchCategoryCustomerSqlList).
")";
533 if (!empty($searchCategoryCustomerSqlList)) {
534 $sql .=
" AND (".implode(
' AND ', $searchCategoryCustomerSqlList).
")";
540 $searchCategorySupplierList = $search_categ_supplier ? array($search_categ_supplier) : array();
541 $searchCategorySupplierOperator = 0;
543 if (!empty($searchCategorySupplierList)) {
544 $searchCategorySupplierSqlList = array();
545 $listofcategoryid =
'';
546 foreach ($searchCategorySupplierList as $searchCategorySupplier) {
547 if (intval($searchCategorySupplier) == -2) {
548 $searchCategorySupplierSqlList[] =
"NOT EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX.
"categorie_fournisseur as ck WHERE s.rowid = ck.fk_soc)";
549 } elseif (intval($searchCategorySupplier) > 0) {
550 if ($searchCategorySupplierOperator == 0) {
551 $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).
")";
553 $listofcategoryid .= ($listofcategoryid ?
', ' :
'') .((
int) $searchCategorySupplier);
557 if ($listofcategoryid) {
558 $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).
"))";
560 if ($searchCategorySupplierOperator == 1) {
561 if (!empty($searchCategorySupplierSqlList)) {
562 $sql .=
" AND (".implode(
' OR ', $searchCategorySupplierSqlList).
")";
565 if (!empty($searchCategorySupplierSqlList)) {
566 $sql .=
" AND (".implode(
' AND ', $searchCategorySupplierSqlList).
")";
574 if (strlen($search_phone)) {
575 $sql .=
natural_search(array(
'p.phone',
'p.phone_perso',
'p.phone_mobile'), $search_phone);
577 if (strlen($search_cti)) {
578 $sql .=
natural_search(array(
'p.phone',
'p.phone_perso',
'p.phone_mobile'), $search_cti);
580 if (strlen($search_firstlast_only)) {
584 if ($search_id > 0) {
587 if ($search_lastname) {
590 if ($search_firstname) {
593 if (empty($arrayfields[
's.name_alias'][
'checked']) && $search_societe) {
596 if ($search_societe) {
599 if ($search_societe_alias) {
603 if ($search_country) {
604 $sql .=
" AND p.fk_pays IN (".$db->sanitize($search_country).
')';
606 if (strlen($search_poste)) {
609 if (strlen($search_phone_perso)) {
612 if (strlen($search_phone_pro)) {
615 if (strlen($search_phone_mobile)) {
618 if (strlen($search_fax)) {
622 foreach ($socialnetworks as $key => $value) {
623 if ($value[
'active'] && strlen($search_[$key])) {
624 $searchkeyinjsonformat = preg_replace(
'/"$/',
'', preg_replace(
'/^"/',
'', json_encode($search_[$key])));
625 if (in_array($db->type, array(
'mysql',
'mysqli'))) {
626 $sql .=
" AND p.socialnetworks REGEXP '\"".$db->escape($db->escapeforlike($key)).
"\":\"[^\"]*".$db->escape($db->escapeforlike($searchkeyinjsonformat)).
"'";
627 } elseif ($db->type ==
'pgsql') {
628 $sql .=
" AND p.socialnetworks ~ '\"".$db->escape($db->escapeforlike($key)).
"\":\"[^\"]*".$db->escape($db->escapeforlike($searchkeyinjsonformat)).
"'";
631 $sql .=
" AND p.socialnetworks LIKE '%\"".$db->escape($db->escapeforlike($key)).
"\":\"".$db->escape($db->escapeforlike($searchkeyinjsonformat)).
"%'";
638 if (strlen($search_email)) {
641 if (strlen($search_address)) {
644 if (strlen($search_zip)) {
647 if (strlen($search_town)) {
650 if (count($search_roles) > 0) {
651 $sql .=
" AND p.rowid IN (SELECT sc.fk_socpeople FROM ".MAIN_DB_PREFIX.
"societe_contacts as sc WHERE sc.fk_c_type_contact IN (".$db->sanitize(implode(
',', $search_roles)).
"))";
653 if ($search_no_email != -1 && $search_no_email > 0) {
654 $sql .=
" AND (SELECT count(*) FROM ".MAIN_DB_PREFIX.
"mailing_unsubscribe WHERE email = p.email) > 0";
656 if ($search_no_email != -1 && $search_no_email == 0) {
657 $sql .=
" AND (SELECT count(*) FROM ".MAIN_DB_PREFIX.
"mailing_unsubscribe WHERE email = p.email) = 0 AND p.email IS NOT NULL AND p.email <> ''";
659 if ($search_status !=
'' && $search_status >= 0) {
660 $sql .=
" AND p.statut = ".((int) $search_status);
662 if ($search_import_key) {
666 $sql .=
" AND p.fk_soc IS NULL";
667 } elseif ($type ==
"f") {
668 $sql .=
" AND s.fournisseur = 1";
669 } elseif ($type ==
"c") {
670 $sql .=
" AND s.client IN (1, 3)";
671 } elseif ($type ==
"p") {
672 $sql .=
" AND s.client IN (2, 3)";
674 if (!empty($socid)) {
675 $sql .=
" AND s.rowid = ".((int) $socid);
679 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
682 $parameters = array();
683 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
684 $sql .= $hookmanager->resPrint;
688 $nbtotalofrecords =
'';
691 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords',
$sql);
692 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
693 $resql = $db->query($sqlforcount);
695 $objforcount = $db->fetch_object($resql);
696 $nbtotalofrecords = $objforcount->nbtotalofrecords;
701 if (($page * $limit) > $nbtotalofrecords) {
709 if ($view ==
"recent") {
710 $sql .= $db->order(
"p.datec",
"DESC");
712 $sql .= $db->order($sortfield, $sortorder);
715 $sql .= $db->plimit($limit + 1, $offset);
718 $resql = $db->query(
$sql);
724 $num = $db->num_rows($resql);
727 if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && ($search_all !=
'' || $search_cti !=
'') && !$page) {
728 $obj = $db->fetch_object($resql);
730 header(
"Location: ".DOL_URL_ROOT.
'/contact/card.php?id='.$id);
740 $arrayofselected = is_array($toselect) ? $toselect : array();
744 $param .=
'&mode='.urlencode($mode);
746 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
747 $param .=
'&contextpage='.urlencode($contextpage);
749 if ($limit > 0 && $limit != $conf->liste_limit) {
750 $param .=
'&limit='.((int) $limit);
752 $param .=
'&begin='.urlencode($begin).
'&userid='.urlencode($userid).
'&contactname='.urlencode($search_all);
753 $param .=
'&type='.urlencode($type).
'&view='.urlencode($view);
754 if (!empty($search_categ) && $search_categ !=
'-1') {
755 $param .=
'&search_categ='.urlencode($search_categ);
757 if (!empty($search_categ_thirdparty) && $search_categ_thirdparty !=
'-1') {
758 $param .=
'&search_categ_thirdparty='.urlencode($search_categ_thirdparty);
760 if (!empty($search_categ_supplier) && $search_categ_supplier !=
'-1') {
761 $param .=
'&search_categ_supplier='.urlencode($search_categ_supplier);
763 if ($search_all !=
'') {
764 $param .=
'&search_all='.urlencode($search_all);
766 if ($search_id > 0) {
767 $param .=
"&search_id=".urlencode($search_id);
769 if ($search_lastname !=
'') {
770 $param .=
'&search_lastname='.urlencode($search_lastname);
772 if ($search_firstname !=
'') {
773 $param .=
'&search_firstname='.urlencode($search_firstname);
775 if ($search_societe !=
'') {
776 $param .=
'&search_societe='.urlencode($search_societe);
778 if ($search_societe_alias !=
'') {
779 $param .=
'&search_societe_alias='.urlencode($search_societe_alias);
781 if ($search_address !=
'') {
782 $param .=
'&search_address='.urlencode($search_address);
784 if ($search_zip !=
'') {
785 $param .=
'&search_zip='.urlencode($search_zip);
787 if ($search_town !=
'') {
788 $param .=
'&search_town='.urlencode($search_town);
790 if ($search_country !=
'') {
791 $param .=
"&search_country=".urlencode($search_country);
793 if ($search_poste !=
'') {
794 $param .=
'&search_poste='.urlencode($search_poste);
796 if ($search_phone_pro !=
'') {
797 $param .=
'&search_phone_pro='.urlencode($search_phone_pro);
799 if ($search_phone_perso !=
'') {
800 $param .=
'&search_phone_perso='.urlencode($search_phone_perso);
802 if ($search_phone_mobile !=
'') {
803 $param .=
'&search_phone_mobile='.urlencode($search_phone_mobile);
805 if ($search_fax !=
'') {
806 $param .=
'&search_fax='.urlencode($search_fax);
808 if ($search_email !=
'') {
809 $param .=
'&search_email='.urlencode($search_email);
811 if ($search_no_email !=
'') {
812 $param .=
'&search_no_email='.urlencode($search_no_email);
814 if ($search_status !=
'') {
815 $param .=
'&search_status='.urlencode($search_status);
817 if ($search_priv ==
'0' || $search_priv ==
'1') {
818 $param .=
"&search_priv=".urlencode($search_priv);
820 if ($search_stcomm !=
'') {
821 $param .=
'&search_stcomm='.urlencode($search_stcomm);
823 if (is_array($search_level) && count($search_level)) {
824 foreach ($search_level as $slevel) {
825 $param .=
'&search_level[]='.urlencode($slevel);
828 if ($search_import_key !=
'') {
829 $param .=
'&search_import_key='.urlencode($search_import_key);
831 if ($optioncss !=
'') {
832 $param .=
'&optioncss='.urlencode($optioncss);
834 if (count($search_roles) > 0) {
835 $param .= implode(
'&search_roles[]=', $search_roles);
839 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
842 $arrayofmassactions = array(
843 'presend' =>
img_picto(
'',
'email',
'class="pictofixedwidth"').$langs->trans(
"SendByMail"),
847 if (!empty($permissiontodelete)) {
848 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
850 if (
isModEnabled(
'category') && $user->hasRight(
'societe',
'creer')) {
851 $arrayofmassactions[
'preaffecttag'] =
img_picto(
'',
'category',
'class="pictofixedwidth"').$langs->trans(
"AffectTag");
853 if (in_array($massaction, array(
'presend',
'predelete',
'preaffecttag'))) {
854 $arrayofmassactions = array();
856 $massactionbutton =
$form->selectMassAction(
'', $arrayofmassactions);
858 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'" name="formfilter">';
859 if ($optioncss !=
'') {
860 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
862 print
'<input type="hidden" name="token" value="'.newToken().
'">';
863 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
864 print
'<input type="hidden" name="view" value="'.dol_escape_htmltag($view).
'">';
865 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
866 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
868 print
'<input type="hidden" name="type" value="'.$type.
'">';
869 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
870 print
'<input type="hidden" name="page_y" value="">';
871 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
875 $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'));
876 $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'));
878 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewContactAddress'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/contact/card.php?action=create',
'', $permissiontoadd);
880 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'address', 0, $newcardbutton,
'', $limit, 0, 0, 1);
882 $topicmail =
"Information";
883 $modelmail =
"contact";
885 $trackid =
'ctc'.$object->id;
886 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
890 foreach ($fieldstosearchall as $key => $val) {
891 $fieldstosearchall[$key] = $langs->trans($val);
892 $setupstring .= $key.
"=".$val.
";";
894 print
'<!-- Search done like if CONTACT_QUICKSEARCH_ON_FIELDS = '.$setupstring.
' -->'.
"\n";
895 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).join(
', ', $fieldstosearchall).
'</div>';
897 if ($search_firstlast_only) {
898 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_firstlast_only).$langs->trans(
"Lastname").
", ".$langs->trans(
"Firstname").
'</div>';
902 if (
isModEnabled(
'categorie') && $user->hasRight(
'categorie',
'lire')) {
903 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
904 $moreforfilter .=
'<div class="divsearchfield">';
905 $tmptitle = $langs->trans(
'ContactCategoriesShort');
906 $moreforfilter .=
img_picto($tmptitle,
'category',
'class="pictofixedwidth"');
907 $moreforfilter .= $formother->select_categories(Categorie::TYPE_CONTACT, $search_categ,
'search_categ', 1, $tmptitle);
908 $moreforfilter .=
'</div>';
909 if (empty($type) || $type ==
'c' || $type ==
'p') {
910 $moreforfilter .=
'<div class="divsearchfield">';
913 $tmptitle .= $langs->trans(
'CustomersCategoriesShort');
914 } elseif ($type ==
'p') {
915 $tmptitle .= $langs->trans(
'ProspectsCategoriesShort');
917 $tmptitle .= $langs->trans(
'CustomersProspectsCategoriesShort');
919 $moreforfilter .=
img_picto($tmptitle,
'category',
'class="pictofixedwidth"');
920 $moreforfilter .= $formother->select_categories(Categorie::TYPE_CUSTOMER, $search_categ_thirdparty,
'search_categ_thirdparty', 1, $tmptitle);
921 $moreforfilter .=
'</div>';
924 if (
isModEnabled(
"fournisseur") && (empty($type) || $type ==
'f')) {
925 $moreforfilter .=
'<div class="divsearchfield">';
926 $tmptitle = $langs->trans(
'SuppliersCategoriesShort');
927 $moreforfilter .=
img_picto($tmptitle,
'category',
'class="pictofixedwidth"');
928 $moreforfilter .= $formother->select_categories(Categorie::TYPE_SUPPLIER, $search_categ_supplier,
'search_categ_supplier', 1, $tmptitle);
929 $moreforfilter .=
'</div>';
933 $moreforfilter .=
'<div class="divsearchfield">';
934 $moreforfilter .= $langs->trans(
'Roles').
': ';
935 $moreforfilter .= $formcompany->showRoles(
"search_roles", $objecttmp,
'edit', $search_roles);
936 $moreforfilter .=
'</div>';
938 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
939 print $moreforfilter;
940 $parameters = array(
'type'=>$type);
941 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
942 print $hookmanager->resPrint;
945 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
946 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN',
''));
947 $selectedfields .= (count($arrayofmassactions) ?
$form->showCheckAddButtons(
'checkforselect', 1) :
'');
949 print
'<div class="div-table-responsive">';
950 print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
954 print
'<tr class="liste_titre_filter">';
957 print
'<td class="liste_titre center maxwidthsearch">';
958 $searchpicto =
$form->showFilterButtons(
'left');
962 if (!empty($arrayfields[
'p.rowid'][
'checked'])) {
963 print
'<td class="liste_titre">';
964 print
'<input class="flat searchstring" type="text" name="search_id" size="1" value="'.dol_escape_htmltag($search_id).
'">';
967 if (!empty($arrayfields[
'p.lastname'][
'checked'])) {
968 print
'<td class="liste_titre">';
969 print
'<input class="flat" type="text" name="search_lastname" size="6" value="'.dol_escape_htmltag($search_lastname).
'">';
972 if (!empty($arrayfields[
'p.firstname'][
'checked'])) {
973 print
'<td class="liste_titre">';
974 print
'<input class="flat" type="text" name="search_firstname" size="6" value="'.dol_escape_htmltag($search_firstname).
'">';
977 if (!empty($arrayfields[
'p.poste'][
'checked'])) {
978 print
'<td class="liste_titre">';
979 print
'<input class="flat" type="text" name="search_poste" size="5" value="'.dol_escape_htmltag($search_poste).
'">';
982 if (!empty($arrayfields[
'p.address'][
'checked'])) {
983 print
'<td class="liste_titre">';
984 print
'<input class="flat" type="text" name="search_address" size="6" value="'.dol_escape_htmltag($search_address).
'">';
987 if (!empty($arrayfields[
'p.zip'][
'checked'])) {
988 print
'<td class="liste_titre">';
989 print
'<input class="flat" type="text" name="search_zip" size="3" value="'.dol_escape_htmltag($search_zip).
'">';
992 if (!empty($arrayfields[
'p.town'][
'checked'])) {
993 print
'<td class="liste_titre">';
994 print
'<input class="flat" type="text" name="search_town" size="5" value="'.dol_escape_htmltag($search_town).
'">';
1017 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1018 print
'<td class="liste_titre center">';
1019 print
$form->select_country($search_country,
'search_country',
'', 0,
'minwidth100imp maxwidth100');
1022 if (!empty($arrayfields[
'p.phone'][
'checked'])) {
1023 print
'<td class="liste_titre">';
1024 print
'<input class="flat" type="text" name="search_phone_pro" size="6" value="'.dol_escape_htmltag($search_phone_pro).
'">';
1027 if (!empty($arrayfields[
'p.phone_perso'][
'checked'])) {
1028 print
'<td class="liste_titre">';
1029 print
'<input class="flat" type="text" name="search_phone_perso" size="6" value="'.dol_escape_htmltag($search_phone_perso).
'">';
1032 if (!empty($arrayfields[
'p.phone_mobile'][
'checked'])) {
1033 print
'<td class="liste_titre">';
1034 print
'<input class="flat" type="text" name="search_phone_mobile" size="6" value="'.dol_escape_htmltag($search_phone_mobile).
'">';
1037 if (!empty($arrayfields[
'p.fax'][
'checked'])) {
1038 print
'<td class="liste_titre">';
1039 print
'<input class="flat" type="text" name="search_fax" size="6" value="'.dol_escape_htmltag($search_fax).
'">';
1042 if (!empty($arrayfields[
'p.email'][
'checked'])) {
1043 print
'<td class="liste_titre">';
1044 print
'<input class="flat" type="text" name="search_email" size="6" value="'.dol_escape_htmltag($search_email).
'">';
1047 if (!empty($arrayfields[
'unsubscribed'][
'checked'])) {
1048 print
'<td class="liste_titre center">';
1049 print
$form->selectarray(
'search_no_email', array(
'-1'=>
'',
'0'=>$langs->trans(
'No'),
'1'=>$langs->trans(
'Yes')), $search_no_email);
1053 foreach ($socialnetworks as $key => $value) {
1054 if ($value[
'active']) {
1055 if (!empty($arrayfields[
'p.'.$key][
'checked'])) {
1056 print
'<td class="liste_titre">';
1057 print
'<input class="flat" type="text" name="search_'.$key.
'" size="6" value="'.
dol_escape_htmltag($search_[$key]).
'">';
1063 if (!empty($arrayfields[
'p.fk_soc'][
'checked']) || !empty($arrayfields[
's.nom'][
'checked'])) {
1064 print
'<td class="liste_titre">';
1065 print
'<input class="flat" type="text" name="search_societe" size="8" value="'.dol_escape_htmltag($search_societe).
'">';
1069 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1070 print
'<td class="liste_titre" align="left">';
1071 print
'<input class="flat maxwidth100" type="text" name="search_societe_alias" value="'.dol_escape_htmltag($search_societe_alias).
'">';
1074 if (!empty($arrayfields[
'p.priv'][
'checked'])) {
1075 print
'<td class="liste_titre center">';
1076 $selectarray = array(
'0'=>$langs->trans(
"ContactPublic"),
'1'=>$langs->trans(
"ContactPrivate"));
1077 print
$form->selectarray(
'search_priv', $selectarray, $search_priv, 1);
1081 if (!empty($arrayfields[
'p.fk_prospectlevel'][
'checked'])) {
1082 print
'<td class="liste_titre center">';
1083 print
$form->multiselectarray(
'search_level', $tab_level, $search_level, 0, 0,
'width75', 0, 0,
'',
'',
'', 2);
1087 if (!empty($arrayfields[
'p.fk_stcommcontact'][
'checked'])) {
1088 print
'<td class="liste_titre maxwidthonsmartphone center">';
1089 $arraystcomm = array();
1090 foreach ($contactstatic->cacheprospectstatus as $key => $val) {
1091 $arraystcomm[$val[
'id']] = ($langs->trans(
"StatusProspect".$val[
'id']) !=
"StatusProspect".$val[
'id'] ? $langs->trans(
"StatusProspect".$val[
'id']) : $val[
'label']);
1093 print
$form->selectarray(
'search_stcomm', $arraystcomm, $search_stcomm, -2, 0, 0,
'', 0, 0, 0,
'',
'nowrap ');
1097 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
1100 $parameters = array(
'arrayfields'=>$arrayfields);
1101 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
1102 print $hookmanager->resPrint;
1104 if (!empty($arrayfields[
'p.datec'][
'checked'])) {
1105 print
'<td class="liste_titre">';
1109 if (!empty($arrayfields[
'p.tms'][
'checked'])) {
1110 print
'<td class="liste_titre">';
1114 if (!empty($arrayfields[
'p.statut'][
'checked'])) {
1115 print
'<td class="liste_titre center parentonrightofpage">';
1116 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');
1119 if (!empty($arrayfields[
'p.import_key'][
'checked'])) {
1120 print
'<td class="liste_titre center">';
1121 print
'<input class="flat searchstring" type="text" name="search_import_key" size="3" value="'.dol_escape_htmltag($search_import_key).
'">';
1126 print
'<td class="liste_titre center maxwidthsearch">';
1127 $searchpicto =
$form->showFilterButtons();
1133 $totalarray = array();
1134 $totalarray[
'nbfield'] = 0;
1138 print
'<tr class="liste_titre">';
1140 print
getTitleFieldOfList(($mode !=
'kanban' ? $selectedfields :
''), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
1141 $totalarray[
'nbfield']++;
1143 if (!empty($arrayfields[
'p.rowid'][
'checked'])) {
1144 print_liste_field_titre($arrayfields[
'p.rowid'][
'label'], $_SERVER[
"PHP_SELF"],
"p.rowid",
"", $param,
"", $sortfield, $sortorder);
1145 $totalarray[
'nbfield']++;
1147 if (!empty($arrayfields[
'p.lastname'][
'checked'])) {
1148 print_liste_field_titre($arrayfields[
'p.lastname'][
'label'], $_SERVER[
"PHP_SELF"],
"p.lastname", $begin, $param,
'', $sortfield, $sortorder);
1149 $totalarray[
'nbfield']++;
1151 if (!empty($arrayfields[
'p.firstname'][
'checked'])) {
1152 print_liste_field_titre($arrayfields[
'p.firstname'][
'label'], $_SERVER[
"PHP_SELF"],
"p.firstname", $begin, $param,
'', $sortfield, $sortorder);
1153 $totalarray[
'nbfield']++;
1155 if (!empty($arrayfields[
'p.poste'][
'checked'])) {
1156 print_liste_field_titre($arrayfields[
'p.poste'][
'label'], $_SERVER[
"PHP_SELF"],
"p.poste", $begin, $param,
'', $sortfield, $sortorder);
1157 $totalarray[
'nbfield']++;
1159 if (!empty($arrayfields[
'p.address'][
'checked'])) {
1160 print_liste_field_titre($arrayfields[
'p.address'][
'label'], $_SERVER[
"PHP_SELF"],
"p.address", $begin, $param,
'', $sortfield, $sortorder);
1161 $totalarray[
'nbfield']++;
1163 if (!empty($arrayfields[
'p.zip'][
'checked'])) {
1164 print_liste_field_titre($arrayfields[
'p.zip'][
'label'], $_SERVER[
"PHP_SELF"],
"p.zip", $begin, $param,
'', $sortfield, $sortorder);
1165 $totalarray[
'nbfield']++;
1167 if (!empty($arrayfields[
'p.town'][
'checked'])) {
1168 print_liste_field_titre($arrayfields[
'p.town'][
'label'], $_SERVER[
"PHP_SELF"],
"p.town", $begin, $param,
'', $sortfield, $sortorder);
1169 $totalarray[
'nbfield']++;
1173 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1174 print_liste_field_titre($arrayfields[
'country.code_iso'][
'label'], $_SERVER[
"PHP_SELF"],
"co.code_iso",
"", $param,
'', $sortfield, $sortorder,
'center ');
1175 $totalarray[
'nbfield']++;
1177 if (!empty($arrayfields[
'p.phone'][
'checked'])) {
1178 print_liste_field_titre($arrayfields[
'p.phone'][
'label'], $_SERVER[
"PHP_SELF"],
"p.phone", $begin, $param,
'', $sortfield, $sortorder);
1179 $totalarray[
'nbfield']++;
1181 if (!empty($arrayfields[
'p.phone_perso'][
'checked'])) {
1182 print_liste_field_titre($arrayfields[
'p.phone_perso'][
'label'], $_SERVER[
"PHP_SELF"],
"p.phone_perso", $begin, $param,
'', $sortfield, $sortorder);
1183 $totalarray[
'nbfield']++;
1185 if (!empty($arrayfields[
'p.phone_mobile'][
'checked'])) {
1186 print_liste_field_titre($arrayfields[
'p.phone_mobile'][
'label'], $_SERVER[
"PHP_SELF"],
"p.phone_mobile", $begin, $param,
'', $sortfield, $sortorder);
1187 $totalarray[
'nbfield']++;
1189 if (!empty($arrayfields[
'p.fax'][
'checked'])) {
1190 print_liste_field_titre($arrayfields[
'p.fax'][
'label'], $_SERVER[
"PHP_SELF"],
"p.fax", $begin, $param,
'', $sortfield, $sortorder);
1191 $totalarray[
'nbfield']++;
1193 if (!empty($arrayfields[
'p.email'][
'checked'])) {
1194 print_liste_field_titre($arrayfields[
'p.email'][
'label'], $_SERVER[
"PHP_SELF"],
"p.email", $begin, $param,
'', $sortfield, $sortorder);
1195 $totalarray[
'nbfield']++;
1197 if (!empty($arrayfields[
'unsubscribed'][
'checked'])) {
1198 print_liste_field_titre($arrayfields[
'unsubscribed'][
'label'], $_SERVER[
"PHP_SELF"],
"unsubscribed", $begin, $param,
'', $sortfield, $sortorder,
'center ');
1199 $totalarray[
'nbfield']++;
1202 foreach ($socialnetworks as $key => $value) {
1203 if ($value[
'active'] && !empty($arrayfields[
'p.'.$key][
'checked'])) {
1204 print_liste_field_titre($arrayfields[
'p.'.$key][
'label'], $_SERVER[
"PHP_SELF"],
"p.".$key, $begin, $param,
'', $sortfield, $sortorder);
1205 $totalarray[
'nbfield']++;
1209 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
1210 print_liste_field_titre($arrayfields[
'p.fk_soc'][
'label'], $_SERVER[
"PHP_SELF"],
"p.fk_soc", $begin, $param,
'', $sortfield, $sortorder);
1211 $totalarray[
'nbfield']++;
1213 if (!empty($arrayfields[
's.nom'][
'checked'])) {
1214 print_liste_field_titre($arrayfields[
's.nom'][
'label'], $_SERVER[
"PHP_SELF"],
"s.nom", $begin, $param,
'', $sortfield, $sortorder);
1215 $totalarray[
'nbfield']++;
1217 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1218 print_liste_field_titre($arrayfields[
's.name_alias'][
'label'], $_SERVER[
"PHP_SELF"],
"s.name_alias", $begin, $param,
'', $sortfield, $sortorder);
1219 $totalarray[
'nbfield']++;
1221 if (!empty($arrayfields[
'p.priv'][
'checked'])) {
1222 print_liste_field_titre($arrayfields[
'p.priv'][
'label'], $_SERVER[
"PHP_SELF"],
"p.priv", $begin, $param,
'', $sortfield, $sortorder,
'center ');
1223 $totalarray[
'nbfield']++;
1225 if (!empty($arrayfields[
'p.fk_prospectlevel'][
'checked'])) {
1226 print_liste_field_titre($arrayfields[
'p.fk_prospectlevel'][
'label'], $_SERVER[
"PHP_SELF"],
"p.fk_prospectlevel",
"", $param,
'', $sortfield, $sortorder,
'center ');
1227 $totalarray[
'nbfield']++;
1229 if (!empty($arrayfields[
'p.fk_stcommcontact'][
'checked'])) {
1230 print_liste_field_titre($arrayfields[
'p.fk_stcommcontact'][
'label'], $_SERVER[
"PHP_SELF"],
"p.fk_stcommcontact",
"", $param,
'', $sortfield, $sortorder,
'center ');
1231 $totalarray[
'nbfield']++;
1234 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
1236 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder,
'totalarray'=>&$totalarray);
1237 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
1238 print $hookmanager->resPrint;
1239 if (!empty($arrayfields[
'p.datec'][
'checked'])) {
1240 print_liste_field_titre($arrayfields[
'p.datec'][
'label'], $_SERVER[
"PHP_SELF"],
"p.datec",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1241 $totalarray[
'nbfield']++;
1243 if (!empty($arrayfields[
'p.tms'][
'checked'])) {
1244 print_liste_field_titre($arrayfields[
'p.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"p.tms",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1245 $totalarray[
'nbfield']++;
1247 if (!empty($arrayfields[
'p.statut'][
'checked'])) {
1248 print_liste_field_titre($arrayfields[
'p.statut'][
'label'], $_SERVER[
"PHP_SELF"],
"p.statut",
"", $param,
'', $sortfield, $sortorder,
'center ');
1249 $totalarray[
'nbfield']++;
1251 if (!empty($arrayfields[
'p.import_key'][
'checked'])) {
1252 print_liste_field_titre($arrayfields[
'p.import_key'][
'label'], $_SERVER[
"PHP_SELF"],
"p.import_key",
"", $param,
'', $sortfield, $sortorder,
'center ');
1253 $totalarray[
'nbfield']++;
1255 if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
1256 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
1257 $totalarray[
'nbfield']++;
1265 $savnbfield = $totalarray[
'nbfield'];
1266 $totalarray = array();
1267 $totalarray[
'nbfield'] = 0;
1268 $imaxinloop = ($limit ? min($num, $limit) : $num);
1269 while ($i < $imaxinloop) {
1270 $obj = $db->fetch_object($resql);
1275 $arraysocialnetworks = (array) json_decode($obj->socialnetworks,
true);
1276 $contactstatic->lastname = $obj->lastname;
1277 $contactstatic->firstname =
'';
1278 $contactstatic->id = $obj->rowid;
1279 $contactstatic->statut = $obj->statut;
1280 $contactstatic->poste = $obj->poste;
1281 $contactstatic->email = $obj->email;
1282 $contactstatic->phone_pro = $obj->phone_pro;
1283 $contactstatic->phone_perso = $obj->phone_perso;
1284 $contactstatic->phone_mobile = $obj->phone_mobile;
1285 $contactstatic->address = $obj->address;
1286 $contactstatic->zip = $obj->zip;
1287 $contactstatic->town = $obj->town;
1288 $contactstatic->socialnetworks = $arraysocialnetworks;
1289 $contactstatic->country = $obj->country;
1290 $contactstatic->country_code = $obj->country_code;
1291 $contactstatic->photo = $obj->photo;
1292 $contactstatic->import_key = $obj->import_key;
1293 $contactstatic->photo = $obj->photo;
1294 $contactstatic->fk_prospectlevel = $obj->fk_prospectlevel;
1296 if ($mode ==
'kanban') {
1298 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
1299 print
'<div class="box-flex-container kanban">';
1302 if ($massactionbutton || $massaction) {
1304 if (in_array($object->id, $arrayofselected)) {
1308 if ($obj->socid > 0) {
1309 $contactstatic->fetch_thirdparty($obj->socid);
1311 print $contactstatic->getKanbanView(
'', array(
'selected' => in_array($contactstatic->id, $arrayofselected)));
1312 if ($i == ($imaxinloop - 1)) {
1319 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
1323 print
'<td class="nowrap center">';
1324 if ($massactionbutton || $massaction) {
1326 if (in_array($obj->rowid, $arrayofselected)) {
1329 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1333 $totalarray[
'nbfield']++;
1338 if (!empty($arrayfields[
'p.rowid'][
'checked'])) {
1339 print
'<td class="tdoverflowmax50">';
1343 $totalarray[
'nbfield']++;
1348 if (!empty($arrayfields[
'p.lastname'][
'checked'])) {
1349 print
'<td class="middle tdoverflowmax150">';
1350 print $contactstatic->getNomUrl(-1);
1353 $totalarray[
'nbfield']++;
1358 if (!empty($arrayfields[
'p.firstname'][
'checked'])) {
1359 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($obj->firstname).
'">'.
dol_escape_htmltag($obj->firstname).
'</td>';
1361 $totalarray[
'nbfield']++;
1366 if (!empty($arrayfields[
'p.poste'][
'checked'])) {
1367 print
'<td class="tdoverflowmax100">'.dol_escape_htmltag($obj->poste).
'</td>';
1369 $totalarray[
'nbfield']++;
1374 if (!empty($arrayfields[
'p.address'][
'checked'])) {
1375 print
'<td>'.dol_escape_htmltag($obj->address).
'</td>';
1377 $totalarray[
'nbfield']++;
1382 if (!empty($arrayfields[
'p.zip'][
'checked'])) {
1383 print
'<td>'.dol_escape_htmltag($obj->zip).
'</td>';
1385 $totalarray[
'nbfield']++;
1390 if (!empty($arrayfields[
'p.town'][
'checked'])) {
1391 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->town).
'">'.
dol_escape_htmltag($obj->town).
'</td>';
1393 $totalarray[
'nbfield']++;
1413 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1414 print
'<td class="center">';
1415 $tmparray =
getCountry($obj->fk_pays,
'all');
1419 $totalarray[
'nbfield']++;
1424 if (!empty($arrayfields[
'p.phone'][
'checked'])) {
1425 print
'<td class="nowraponall tdoverflowmax150">'.dol_print_phone($obj->phone_pro, $obj->country_code, $obj->rowid, $obj->socid,
'AC_TEL',
' ',
'phone').
'</td>';
1427 $totalarray[
'nbfield']++;
1432 if (!empty($arrayfields[
'p.phone_perso'][
'checked'])) {
1433 print
'<td class="nowraponall tdoverflowmax150">'.dol_print_phone($obj->phone_perso, $obj->country_code, $obj->rowid, $obj->socid,
'AC_TEL',
' ',
'phone').
'</td>';
1435 $totalarray[
'nbfield']++;
1440 if (!empty($arrayfields[
'p.phone_mobile'][
'checked'])) {
1441 print
'<td class="nowraponall tdoverflowmax150">'.dol_print_phone($obj->phone_mobile, $obj->country_code, $obj->rowid, $obj->socid,
'AC_TEL',
' ',
'mobile').
'</td>';
1443 $totalarray[
'nbfield']++;
1448 if (!empty($arrayfields[
'p.fax'][
'checked'])) {
1449 print
'<td class="nowraponall tdoverflowmax150">'.dol_print_phone($obj->fax, $obj->country_code, $obj->rowid, $obj->socid,
'AC_TEL',
' ',
'fax').
'</td>';
1451 $totalarray[
'nbfield']++;
1456 if (!empty($arrayfields[
'p.email'][
'checked'])) {
1457 print
'<td class="nowraponall tdoverflowmax300">'.dol_print_email($obj->email, $obj->rowid, $obj->socid,
'AC_EMAIL', 18, 0, 1).
'</td>';
1459 $totalarray[
'nbfield']++;
1464 if (!empty($arrayfields[
'unsubscribed'][
'checked'])) {
1465 print
'<td class="center">';
1466 if (empty($obj->email)) {
1469 print
yn(($obj->unsubscribed > 0) ? 1 : 0);
1473 $totalarray[
'nbfield']++;
1479 foreach ($socialnetworks as $key => $value) {
1480 if ($value[
'active'] && !empty($arrayfields[
'p.'.$key][
'checked'])) {
1481 print
'<td class="tdoverflowmax100">'.(empty($arraysocialnetworks[$key]) ?
'' :
dol_print_socialnetworks($arraysocialnetworks[$key], $obj->rowid, $obj->socid, $key, $socialnetworks)).
'</td>';
1483 $totalarray[
'nbfield']++;
1490 if (!empty($arrayfields[
'p.fk_soc'][
'checked']) || !empty($arrayfields[
's.nom'][
'checked'])) {
1491 print
'<td class="tdoverflowmax200">';
1494 $objsoc->fetch($obj->socid);
1495 print $objsoc->getNomUrl(1,
'', 100, 0, 1, empty($arrayfields[
's.name_alias'][
'checked']) ? 0 : 1);
1501 $totalarray[
'nbfield']++;
1506 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1507 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->alias).
'">';
1511 $totalarray[
'nbfield']++;
1516 if (!empty($arrayfields[
'p.priv'][
'checked'])) {
1517 print
'<td class="center">'.$contactstatic->LibPubPriv($obj->priv).
'</td>';
1519 $totalarray[
'nbfield']++;
1524 if (!empty($arrayfields[
'p.fk_prospectlevel'][
'checked'])) {
1525 print
'<td class="center">';
1526 print $contactstatic->getLibProspLevel();
1529 $totalarray[
'nbfield']++;
1534 if (!empty($arrayfields[
'p.fk_stcommcontact'][
'checked'])) {
1535 print
'<td class="center nowrap"><div class="nowrap">';
1536 print
'<div class="inline-block">'.$contactstatic->libProspCommStatut($obj->stcomm_id, 2, $contactstatic->cacheprospectstatus[$obj->stcomm_id][
'label'], $obj->stcomm_picto);
1537 print
'</div> - <div class="inline-block">';
1538 foreach ($contactstatic->cacheprospectstatus as $key => $val) {
1539 $titlealt =
'default';
1540 if (!empty($val[
'code']) && !in_array($val[
'code'], array(
'ST_NO',
'ST_NEVER',
'ST_TODO',
'ST_PEND',
'ST_DONE'))) {
1541 $titlealt = $val[
'label'];
1543 if ($obj->stcomm_id != $val[
'id']) {
1544 print
'<a class="pictosubstatus" href="'.$_SERVER[
"PHP_SELF"].
'?stcommcontactid='.$obj->rowid.
'&stcomm='.urlencode($val[
'code']).
'&action=setstcomm&token='.
newToken().$param.($page ?
'&page='.urlencode($page) :
'').
'">'.
img_action($titlealt, $val[
'code'], $val[
'picto']).
'</a>';
1547 print
'</div></div></td>';
1549 $totalarray[
'nbfield']++;
1554 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
1557 $parameters = array(
'arrayfields'=>$arrayfields,
'object'=>$object,
'obj'=>$obj,
'i'=>$i,
'totalarray'=>&$totalarray);
1558 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
1559 print $hookmanager->resPrint;
1561 if (!empty($arrayfields[
'p.datec'][
'checked'])) {
1562 print
'<td class="center nowraponall">';
1563 print
dol_print_date($db->jdate($obj->date_creation),
'dayhour',
'tzuser');
1566 $totalarray[
'nbfield']++;
1571 if (!empty($arrayfields[
'p.tms'][
'checked'])) {
1572 print
'<td class="center nowraponall">';
1573 print
dol_print_date($db->jdate($obj->date_update),
'dayhour',
'tzuser');
1576 $totalarray[
'nbfield']++;
1581 if (!empty($arrayfields[
'p.statut'][
'checked'])) {
1582 print
'<td class="center">'.$contactstatic->getLibStatut(5).
'</td>';
1584 $totalarray[
'nbfield']++;
1589 if (!empty($arrayfields[
'p.import_key'][
'checked'])) {
1590 print
'<td class="tdoverflowmax100">';
1594 $totalarray[
'nbfield']++;
1600 print
'<td class="nowrap center">';
1601 if ($massactionbutton || $massaction) {
1603 if (in_array($obj->rowid, $arrayofselected)) {
1606 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1610 $totalarray[
'nbfield']++;
1620 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
1625 foreach ($arrayfields as $key => $val) {
1626 if (!empty($val[
'checked'])) {
1630 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
1635 $parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>
$sql);
1636 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
1637 print $hookmanager->resPrint;
1639 print
'</table>'.
"\n";
1640 print
'</div>'.
"\n";
1642 print
'</form>'.
"\n";