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 $sall = 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 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
124 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
125 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
127 $userid =
GETPOST(
'userid',
'int');
133 $sortfield =
"p.lastname";
135 if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
138 $offset = $limit * $page;
141 $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans(
"Contacts") : $langs->trans(
"ContactsAddresses"));
143 if (empty($contextpage) || $contextpage ==
'contactlist') {
144 $contextpage =
'contactprospectlist';
146 $title .=
' ('.$langs->trans(
"ThirdPartyProspects").
')';
147 $urlfiche =
"card.php";
150 if (empty($contextpage) || $contextpage ==
'contactlist') {
151 $contextpage =
'contactcustomerlist';
153 $title .=
' ('.$langs->trans(
"ThirdPartyCustomers").
')';
154 $urlfiche =
"card.php";
155 } elseif ($type ==
"f") {
156 if (empty($contextpage) || $contextpage ==
'contactlist') {
157 $contextpage =
'contactsupplierlist';
159 $title .=
' ('.$langs->trans(
"ThirdPartySuppliers").
')';
160 $urlfiche =
"card.php";
161 } elseif ($type ==
"o") {
162 if (empty($contextpage) || $contextpage ==
'contactlist') {
163 $contextpage =
'contactotherlist';
165 $title .=
' ('.$langs->trans(
"OthersNotLinkedToThirdParty").
')';
171 $hookmanager->initHooks(array(
'contactlist'));
175 $extrafields->fetch_name_optionals_label($object->table_element);
177 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
180 $fieldstosearchall = array();
181 foreach ($object->fields as $key => $val) {
183 if (!empty($user->socid) && $key ==
"note_private") {
187 if (empty($val[
'searchall'])) {
191 $fieldstosearchall[
'p.'.$key] = $val[
'label'];
195 if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) {
196 $fieldstosearchall[
's.nom'] =
"ThirdParty";
197 $fieldstosearchall[
's.name_alias'] =
"AliasNames";
201 $arrayfields = array();
202 foreach ($object->fields as $key => $val) {
204 if (empty($val[
'visible'])) {
208 $arrayfields[
'p.'.$key] = array(
209 'label'=>$val[
'label'],
210 'checked'=>(($val[
'visible'] < 0) ? 0 : 1),
211 'enabled'=>($val[
'enabled'] && ($val[
'visible'] != 3)),
212 'position'=>$val[
'position']);
216 $arrayfields[
'country.code_iso'] = array(
'label'=>
"Country",
'position'=>66,
'checked'=>0);
217 if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) {
218 $arrayfields[
's.nom'] = array(
'label'=>
"ThirdParty",
'position'=>113,
'checked'=> 1);
219 $arrayfields[
's.name_alias'] = array(
'label'=>
"AliasNameShort",
'position'=>114,
'checked'=> 1);
222 $arrayfields[
'unsubscribed'] = array(
229 foreach ($socialnetworks as $key => $value) {
230 if ($value[
'active']) {
231 $arrayfields[
'p.'.$key] = array(
232 'label' => $value[
'label'],
241 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
247 if (($id > 0 || !empty($ref)) && $action !=
'add') {
248 $result = $object->fetch($id, $ref);
259 if (
GETPOST(
'cancel',
'alpha')) {
260 $action =
'list'; $massaction =
'';
262 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
266 $parameters = array();
267 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
272 if (empty($reshook)) {
274 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
277 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
280 $search_firstlast_only =
"";
281 $search_lastname =
"";
282 $search_firstname =
"";
283 $search_societe =
"";
284 $search_societe_alias =
"";
286 $search_address =
"";
288 $search_country =
"";
291 $search_phone_perso =
"";
292 $search_phone_pro =
"";
293 $search_phone_mobile =
"";
296 $search_no_email = -1;
298 foreach ($socialnetworks as $key => $value) {
299 if ($value[
'active']) {
309 $search_categ_thirdparty =
'';
310 $search_categ_supplier =
'';
311 $search_import_key =
'';
313 $search_array_options = array();
314 $search_roles = array();
318 $objectclass =
'Contact';
319 $objectlabel =
'Contact';
320 $permissiontoread = $user->hasRight(
'societe',
'lire');
321 $permissiontodelete = $user->hasRight(
'societe',
'supprimer');
322 $permissiontoadd = $user->hasRight(
'societe',
'creer');
323 $uploaddir = $conf->societe->dir_output;
324 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
326 if ($action ==
'setstcomm') {
328 $result = $object->fetch(
GETPOST(
'stcommcontactid'));
330 $result = $object->update($object->id, $user);
339 if ($search_priv < 0) {
351 $contactstatic =
new Contact($db);
357 $title = $langs->trans(
"Contacts").
" - ".$langs->trans(
"List");
358 $help_url =
'EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Empresas';
361 if (!empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES)) {
362 $contactstatic->loadCacheOfProspStatus();
365 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
366 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
369 $tab_level = array();
370 $sql =
"SELECT code, label, sortorder";
371 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_prospectcontactlevel";
372 $sql .=
" WHERE active > 0";
373 $sql .=
" ORDER BY sortorder";
374 $resql = $db->query(
$sql);
376 while ($obj = $db->fetch_object($resql)) {
378 $level = $langs->trans($obj->code);
379 if ($level == $obj->code) {
380 $level = $langs->trans($obj->label);
382 $tab_level[$obj->code] = $level;
388 $sql =
"SELECT s.rowid as socid, s.nom as name, s.name_alias as alias,";
389 $sql .=
" p.rowid, p.lastname as lastname, p.statut, p.firstname, p.address, p.zip, p.town, p.poste, p.email,";
390 $sql .=
" p.socialnetworks, p.photo,";
391 $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,";
392 $sql .=
" p.import_key,";
393 $sql .=
" st.libelle as stcomm, st.picto as stcomm_picto, p.fk_stcommcontact as stcomm_id, p.fk_prospectlevel,";
394 $sql .=
" co.label as country, co.code as country_code";
397 if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
398 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
399 $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
403 $sql .=
", (SELECT count(*) FROM ".MAIN_DB_PREFIX.
"mailing_unsubscribe WHERE email = p.email) as unsubscribed";
407 $parameters = array();
408 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
409 $sql .= $hookmanager->resPrint;
414 $sql .=
" FROM ".MAIN_DB_PREFIX.
"socpeople as p";
415 if (isset($extrafields->attributes[$object->table_element][
'label']) && is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label'])) {
416 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (p.rowid = ef.fk_object)";
418 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as co ON co.rowid = p.fk_pays";
419 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid = p.fk_soc";
420 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_stcommcontact as st ON st.id = p.fk_stcommcontact";
421 if (empty($user->rights->societe->client->voir) && !$socid) {
422 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON s.rowid = sc.fk_soc";
426 $parameters = array();
427 $reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object, $action);
428 $sql .= $hookmanager->resPrint;
429 $sql .=
' WHERE p.entity IN ('.getEntity(
'contact').
')';
430 if (empty($user->rights->societe->client->voir) && !$socid) {
431 $sql .=
" AND (sc.fk_user = ".((int) $user->id).
" OR p.fk_soc IS NULL)";
433 if (!empty($userid)) {
434 $sql .=
" AND p.fk_user_creat=".((int) $userid);
439 if ($search_stcomm !=
'' && $search_stcomm != -2) {
444 if ($search_priv !=
'0' && $search_priv !=
'1') {
445 $sql .=
" AND (p.priv='0' OR (p.priv='1' AND p.fk_user_creat=".((int) $user->id).
"))";
447 if ($search_priv ==
'0') {
448 $sql .=
" AND p.priv='0'";
450 if ($search_priv ==
'1') {
451 $sql .=
" AND (p.priv='1' AND p.fk_user_creat=".((int) $user->id).
")";
457 $searchCategoryContactList = $search_categ ? array($search_categ) : array();
458 $searchCategoryContactOperator = 0;
460 if (!empty($searchCategoryContactList)) {
461 $searchCategoryContactSqlList = array();
462 $listofcategoryid =
'';
463 foreach ($searchCategoryContactList as $searchCategoryContact) {
464 if (intval($searchCategoryContact) == -2) {
465 $searchCategoryContactSqlList[] =
"NOT EXISTS (SELECT ck.fk_socpeople FROM ".MAIN_DB_PREFIX.
"categorie_contact as ck WHERE p.rowid = ck.fk_socpeople)";
466 } elseif (intval($searchCategoryContact) > 0) {
467 if ($searchCategoryContactOperator == 0) {
468 $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).
")";
470 $listofcategoryid .= ($listofcategoryid ?
', ' :
'') .((
int) $searchCategoryContact);
474 if ($listofcategoryid) {
475 $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).
"))";
477 if ($searchCategoryContactOperator == 1) {
478 if (!empty($searchCategoryContactSqlList)) {
479 $sql .=
" AND (".implode(
' OR ', $searchCategoryContactSqlList).
")";
482 if (!empty($searchCategoryContactSqlList)) {
483 $sql .=
" AND (".implode(
' AND ', $searchCategoryContactSqlList).
")";
489 $searchCategoryCustomerList = $search_categ_thirdparty ? array($search_categ_thirdparty) : array();
490 $searchCategoryCustomerOperator = 0;
492 if (!empty($searchCategoryCustomerList)) {
493 $searchCategoryCustomerSqlList = array();
494 $listofcategoryid =
'';
495 foreach ($searchCategoryCustomerList as $searchCategoryCustomer) {
496 if (intval($searchCategoryCustomer) == -2) {
497 $searchCategoryCustomerSqlList[] =
"NOT EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX.
"categorie_societe as ck WHERE s.rowid = ck.fk_soc)";
498 } elseif (intval($searchCategoryCustomer) > 0) {
499 if ($searchCategoryCustomerOperator == 0) {
500 $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).
")";
502 $listofcategoryid .= ($listofcategoryid ?
', ' :
'') .((
int) $searchCategoryCustomer);
506 if ($listofcategoryid) {
507 $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).
"))";
509 if ($searchCategoryCustomerOperator == 1) {
510 if (!empty($searchCategoryCustomerSqlList)) {
511 $sql .=
" AND (".implode(
' OR ', $searchCategoryCustomerSqlList).
")";
514 if (!empty($searchCategoryCustomerSqlList)) {
515 $sql .=
" AND (".implode(
' AND ', $searchCategoryCustomerSqlList).
")";
521 $searchCategorySupplierList = $search_categ_supplier ? array($search_categ_supplier) : array();
522 $searchCategorySupplierOperator = 0;
524 if (!empty($searchCategorySupplierList)) {
525 $searchCategorySupplierSqlList = array();
526 $listofcategoryid =
'';
527 foreach ($searchCategorySupplierList as $searchCategorySupplier) {
528 if (intval($searchCategorySupplier) == -2) {
529 $searchCategorySupplierSqlList[] =
"NOT EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX.
"categorie_fournisseur as ck WHERE s.rowid = ck.fk_soc)";
530 } elseif (intval($searchCategorySupplier) > 0) {
531 if ($searchCategorySupplierOperator == 0) {
532 $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).
")";
534 $listofcategoryid .= ($listofcategoryid ?
', ' :
'') .((
int) $searchCategorySupplier);
538 if ($listofcategoryid) {
539 $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).
"))";
541 if ($searchCategorySupplierOperator == 1) {
542 if (!empty($searchCategorySupplierSqlList)) {
543 $sql .=
" AND (".implode(
' OR ', $searchCategorySupplierSqlList).
")";
546 if (!empty($searchCategorySupplierSqlList)) {
547 $sql .=
" AND (".implode(
' AND ', $searchCategorySupplierSqlList).
")";
555 if (strlen($search_phone)) {
556 $sql .=
natural_search(array(
'p.phone',
'p.phone_perso',
'p.phone_mobile'), $search_phone);
558 if (strlen($search_cti)) {
559 $sql .=
natural_search(array(
'p.phone',
'p.phone_perso',
'p.phone_mobile'), $search_cti);
561 if (strlen($search_firstlast_only)) {
565 if ($search_id > 0) {
568 if ($search_lastname) {
571 if ($search_firstname) {
574 if (empty($arrayfields[
's.name_alias'][
'checked']) && $search_societe) {
577 if ($search_societe) {
580 if ($search_societe_alias) {
584 if ($search_country) {
585 $sql .=
" AND p.fk_pays IN (".$db->sanitize($search_country).
')';
587 if (strlen($search_poste)) {
590 if (strlen($search_phone_perso)) {
593 if (strlen($search_phone_pro)) {
596 if (strlen($search_phone_mobile)) {
599 if (strlen($search_fax)) {
603 foreach ($socialnetworks as $key => $value) {
604 if ($value[
'active'] && strlen($search_[$key])) {
605 $searchkeyinjsonformat = preg_replace(
'/"$/',
'', preg_replace(
'/^"/',
'', json_encode($search_[$key])));
606 if (in_array($db->type, array(
'mysql',
'mysqli'))) {
607 $sql .=
" AND p.socialnetworks REGEXP '\"".$db->escape($db->escapeforlike($key)).
"\":\"[^\"]*".$db->escape($db->escapeforlike($searchkeyinjsonformat)).
"'";
608 } elseif ($db->type ==
'pgsql') {
609 $sql .=
" AND p.socialnetworks ~ '\"".$db->escape($db->escapeforlike($key)).
"\":\"[^\"]*".$db->escape($db->escapeforlike($searchkeyinjsonformat)).
"'";
612 $sql .=
" AND p.socialnetworks LIKE '%\"".$db->escape($db->escapeforlike($key)).
"\":\"".$db->escape($db->escapeforlike($searchkeyinjsonformat)).
"%'";
619 if (strlen($search_email)) {
622 if (strlen($search_address)) {
625 if (strlen($search_zip)) {
628 if (strlen($search_town)) {
631 if (count($search_roles) > 0) {
632 $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)).
"))";
634 if ($search_no_email != -1 && $search_no_email > 0) {
635 $sql .=
" AND (SELECT count(*) FROM ".MAIN_DB_PREFIX.
"mailing_unsubscribe WHERE email = p.email) > 0";
637 if ($search_no_email != -1 && $search_no_email == 0) {
638 $sql .=
" AND (SELECT count(*) FROM ".MAIN_DB_PREFIX.
"mailing_unsubscribe WHERE email = p.email) = 0 AND p.email IS NOT NULL AND p.email <> ''";
640 if ($search_status !=
'' && $search_status >= 0) {
641 $sql .=
" AND p.statut = ".((int) $search_status);
643 if ($search_import_key) {
647 $sql .=
" AND p.fk_soc IS NULL";
648 } elseif ($type ==
"f") {
649 $sql .=
" AND s.fournisseur = 1";
650 } elseif ($type ==
"c") {
651 $sql .=
" AND s.client IN (1, 3)";
652 } elseif ($type ==
"p") {
653 $sql .=
" AND s.client IN (2, 3)";
655 if (!empty($socid)) {
656 $sql .=
" AND s.rowid = ".((int) $socid);
660 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
663 $parameters = array();
664 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
665 $sql .= $hookmanager->resPrint;
670 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
672 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords',
$sql);
673 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
674 $resql = $db->query($sqlforcount);
676 $objforcount = $db->fetch_object($resql);
690 if ($view ==
"recent") {
691 $sql .= $db->order(
"p.datec",
"DESC");
693 $sql .= $db->order($sortfield, $sortorder);
696 $sql .= $db->plimit($limit + 1, $offset);
699 $resql = $db->query(
$sql);
705 $num = $db->num_rows($resql);
707 $arrayofselected = is_array($toselect) ? $toselect : array();
709 if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && ($sall !=
'' || $search_cti !=
'')) {
710 $obj = $db->fetch_object($resql);
712 header(
"Location: ".DOL_URL_ROOT.
'/contact/card.php?id='.$id);
720 $param .=
'&mode='.urlencode($mode);
722 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
723 $param .=
'&contextpage='.urlencode($contextpage);
725 if ($limit > 0 && $limit != $conf->liste_limit) {
726 $param .=
'&limit='.((int) $limit);
728 $param .=
'&begin='.urlencode($begin).
'&userid='.urlencode($userid).
'&contactname='.urlencode($sall);
729 $param .=
'&type='.urlencode($type).
'&view='.urlencode($view);
730 if (!empty($search_categ) && $search_categ !=
'-1') {
731 $param .=
'&search_categ='.urlencode($search_categ);
733 if (!empty($search_categ_thirdparty) && $search_categ_thirdparty !=
'-1') {
734 $param .=
'&search_categ_thirdparty='.urlencode($search_categ_thirdparty);
736 if (!empty($search_categ_supplier) && $search_categ_supplier !=
'-1') {
737 $param .=
'&search_categ_supplier='.urlencode($search_categ_supplier);
740 $param .=
'&sall='.urlencode($sall);
742 if ($search_id > 0) {
743 $param .=
"&search_id=".urlencode($search_id);
745 if ($search_lastname !=
'') {
746 $param .=
'&search_lastname='.urlencode($search_lastname);
748 if ($search_firstname !=
'') {
749 $param .=
'&search_firstname='.urlencode($search_firstname);
751 if ($search_societe !=
'') {
752 $param .=
'&search_societe='.urlencode($search_societe);
754 if ($search_societe_alias !=
'') {
755 $param .=
'&search_societe_alias='.urlencode($search_societe_alias);
757 if ($search_address !=
'') {
758 $param .=
'&search_address='.urlencode($search_address);
760 if ($search_zip !=
'') {
761 $param .=
'&search_zip='.urlencode($search_zip);
763 if ($search_town !=
'') {
764 $param .=
'&search_town='.urlencode($search_town);
766 if ($search_country !=
'') {
767 $param .=
"&search_country=".urlencode($search_country);
769 if ($search_poste !=
'') {
770 $param .=
'&search_poste='.urlencode($search_poste);
772 if ($search_phone_pro !=
'') {
773 $param .=
'&search_phone_pro='.urlencode($search_phone_pro);
775 if ($search_phone_perso !=
'') {
776 $param .=
'&search_phone_perso='.urlencode($search_phone_perso);
778 if ($search_phone_mobile !=
'') {
779 $param .=
'&search_phone_mobile='.urlencode($search_phone_mobile);
781 if ($search_fax !=
'') {
782 $param .=
'&search_fax='.urlencode($search_fax);
784 if ($search_email !=
'') {
785 $param .=
'&search_email='.urlencode($search_email);
787 if ($search_no_email !=
'') {
788 $param .=
'&search_no_email='.urlencode($search_no_email);
790 if ($search_status !=
'') {
791 $param .=
'&search_status='.urlencode($search_status);
793 if ($search_priv ==
'0' || $search_priv ==
'1') {
794 $param .=
"&search_priv=".urlencode($search_priv);
796 if ($search_stcomm !=
'') {
797 $param .=
'&search_stcomm='.urlencode($search_stcomm);
799 if (is_array($search_level) && count($search_level)) {
800 foreach ($search_level as $slevel) {
801 $param .=
'&search_level[]='.urlencode($slevel);
804 if ($search_import_key !=
'') {
805 $param .=
'&search_import_key='.urlencode($search_import_key);
807 if ($optioncss !=
'') {
808 $param .=
'&optioncss='.urlencode($optioncss);
810 if (count($search_roles) > 0) {
811 $param .= implode(
'&search_roles[]=', $search_roles);
815 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
818 $arrayofmassactions = array(
819 'presend' =>
img_picto(
'',
'email',
'class="pictofixedwidth"').$langs->trans(
"SendByMail"),
823 if ($user->hasRight(
'societe',
'supprimer')) {
824 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
826 if (
isModEnabled(
'category') && $user->rights->societe->creer) {
827 $arrayofmassactions[
'preaffecttag'] =
img_picto(
'',
'category',
'class="pictofixedwidth"').$langs->trans(
"AffectTag");
829 if (in_array($massaction, array(
'presend',
'predelete',
'preaffecttag'))) {
830 $arrayofmassactions = array();
832 $massactionbutton =
$form->selectMassAction(
'', $arrayofmassactions);
835 $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'));
836 $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'));
837 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewContactAddress'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/contact/card.php?action=create',
'', $user->rights->societe->contact->creer);
839 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'" name="formfilter">';
840 if ($optioncss !=
'') {
841 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
843 print
'<input type="hidden" name="token" value="'.newToken().
'">';
844 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
845 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
846 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
848 print
'<input type="hidden" name="type" value="'.$type.
'">';
849 print
'<input type="hidden" name="view" value="'.dol_escape_htmltag($view).
'">';
850 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
853 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num,
$nbtotalofrecords,
'address', 0, $newcardbutton,
'', $limit, 0, 0, 1);
855 $topicmail =
"Information";
856 $modelmail =
"contact";
858 $trackid =
'ctc'.$object->id;
859 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
862 foreach ($fieldstosearchall as $key => $val) {
863 $fieldstosearchall[$key] = $langs->trans($val);
865 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $sall).join(
', ', $fieldstosearchall).
'</div>';
867 if ($search_firstlast_only) {
868 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_firstlast_only).$langs->trans(
"Lastname").
", ".$langs->trans(
"Firstname").
'</div>';
872 if (
isModEnabled(
'categorie') && $user->rights->categorie->lire) {
873 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
874 $moreforfilter .=
'<div class="divsearchfield">';
875 $tmptitle = $langs->trans(
'ContactCategoriesShort');
876 $moreforfilter .=
img_picto($tmptitle,
'category',
'class="pictofixedwidth"');
877 $moreforfilter .= $formother->select_categories(Categorie::TYPE_CONTACT, $search_categ,
'search_categ', 1, $tmptitle);
878 $moreforfilter .=
'</div>';
879 if (empty($type) || $type ==
'c' || $type ==
'p') {
880 $moreforfilter .=
'<div class="divsearchfield">';
883 $tmptitle .= $langs->trans(
'CustomersCategoriesShort');
884 } elseif ($type ==
'p') {
885 $tmptitle .= $langs->trans(
'ProspectsCategoriesShort');
887 $tmptitle .= $langs->trans(
'CustomersProspectsCategoriesShort');
889 $moreforfilter .=
img_picto($tmptitle,
'category',
'class="pictofixedwidth"');
890 $moreforfilter .= $formother->select_categories(Categorie::TYPE_CUSTOMER, $search_categ_thirdparty,
'search_categ_thirdparty', 1, $tmptitle);
891 $moreforfilter .=
'</div>';
894 if (
isModEnabled(
"fournisseur") && (empty($type) || $type ==
'f')) {
895 $moreforfilter .=
'<div class="divsearchfield">';
896 $tmptitle = $langs->trans(
'SuppliersCategoriesShort');
897 $moreforfilter .=
img_picto($tmptitle,
'category',
'class="pictofixedwidth"');
898 $moreforfilter .= $formother->select_categories(Categorie::TYPE_SUPPLIER, $search_categ_supplier,
'search_categ_supplier', 1, $tmptitle);
899 $moreforfilter .=
'</div>';
903 $moreforfilter .=
'<div class="divsearchfield">';
904 $moreforfilter .= $langs->trans(
'Roles').
': ';
905 $moreforfilter .= $formcompany->showRoles(
"search_roles", $objecttmp,
'edit', $search_roles);
906 $moreforfilter .=
'</div>';
908 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
909 print $moreforfilter;
910 $parameters = array(
'type'=>$type);
911 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
912 print $hookmanager->resPrint;
915 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
916 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN',
''));
917 if ($massactionbutton) {
918 $selectedfields .=
$form->showCheckAddButtons(
'checkforselect', 1);
921 print
'<div class="div-table-responsive">';
922 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
925 print
'<tr class="liste_titre_filter">';
927 if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
928 print
'<td class="liste_titre maxwidthsearch">';
929 $searchpicto =
$form->showFilterButtons(
'left');
933 if (!empty($arrayfields[
'p.rowid'][
'checked'])) {
934 print
'<td class="liste_titre">';
935 print
'<input class="flat searchstring" type="text" name="search_id" size="1" value="'.dol_escape_htmltag($search_id).
'">';
938 if (!empty($arrayfields[
'p.lastname'][
'checked'])) {
939 print
'<td class="liste_titre">';
940 print
'<input class="flat" type="text" name="search_lastname" size="6" value="'.dol_escape_htmltag($search_lastname).
'">';
943 if (!empty($arrayfields[
'p.firstname'][
'checked'])) {
944 print
'<td class="liste_titre">';
945 print
'<input class="flat" type="text" name="search_firstname" size="6" value="'.dol_escape_htmltag($search_firstname).
'">';
948 if (!empty($arrayfields[
'p.poste'][
'checked'])) {
949 print
'<td class="liste_titre">';
950 print
'<input class="flat" type="text" name="search_poste" size="5" value="'.dol_escape_htmltag($search_poste).
'">';
953 if (!empty($arrayfields[
'p.address'][
'checked'])) {
954 print
'<td class="liste_titre">';
955 print
'<input class="flat" type="text" name="search_address" size="6" value="'.dol_escape_htmltag($search_address).
'">';
958 if (!empty($arrayfields[
'p.zip'][
'checked'])) {
959 print
'<td class="liste_titre">';
960 print
'<input class="flat" type="text" name="search_zip" size="3" value="'.dol_escape_htmltag($search_zip).
'">';
963 if (!empty($arrayfields[
'p.town'][
'checked'])) {
964 print
'<td class="liste_titre">';
965 print
'<input class="flat" type="text" name="search_town" size="5" value="'.dol_escape_htmltag($search_town).
'">';
988 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
989 print
'<td class="liste_titre center">';
990 print
$form->select_country($search_country,
'search_country',
'', 0,
'minwidth100imp maxwidth100');
993 if (!empty($arrayfields[
'p.phone'][
'checked'])) {
994 print
'<td class="liste_titre">';
995 print
'<input class="flat" type="text" name="search_phone_pro" size="6" value="'.dol_escape_htmltag($search_phone_pro).
'">';
998 if (!empty($arrayfields[
'p.phone_perso'][
'checked'])) {
999 print
'<td class="liste_titre">';
1000 print
'<input class="flat" type="text" name="search_phone_perso" size="6" value="'.dol_escape_htmltag($search_phone_perso).
'">';
1003 if (!empty($arrayfields[
'p.phone_mobile'][
'checked'])) {
1004 print
'<td class="liste_titre">';
1005 print
'<input class="flat" type="text" name="search_phone_mobile" size="6" value="'.dol_escape_htmltag($search_phone_mobile).
'">';
1008 if (!empty($arrayfields[
'p.fax'][
'checked'])) {
1009 print
'<td class="liste_titre">';
1010 print
'<input class="flat" type="text" name="search_fax" size="6" value="'.dol_escape_htmltag($search_fax).
'">';
1013 if (!empty($arrayfields[
'p.email'][
'checked'])) {
1014 print
'<td class="liste_titre">';
1015 print
'<input class="flat" type="text" name="search_email" size="6" value="'.dol_escape_htmltag($search_email).
'">';
1018 if (!empty($arrayfields[
'unsubscribed'][
'checked'])) {
1019 print
'<td class="liste_titre center">';
1020 print
$form->selectarray(
'search_no_email', array(
'-1'=>
'',
'0'=>$langs->trans(
'No'),
'1'=>$langs->trans(
'Yes')), $search_no_email);
1024 foreach ($socialnetworks as $key => $value) {
1025 if ($value[
'active']) {
1026 if (!empty($arrayfields[
'p.'.$key][
'checked'])) {
1027 print
'<td class="liste_titre">';
1028 print
'<input class="flat" type="text" name="search_'.$key.
'" size="6" value="'.
dol_escape_htmltag($search_[$key]).
'">';
1034 if (!empty($arrayfields[
'p.fk_soc'][
'checked']) || !empty($arrayfields[
's.nom'][
'checked'])) {
1035 print
'<td class="liste_titre">';
1036 print
'<input class="flat" type="text" name="search_societe" size="8" value="'.dol_escape_htmltag($search_societe).
'">';
1040 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1041 print
'<td class="liste_titre" align="left">';
1042 print
'<input class="flat maxwidth100" type="text" name="search_societe_alias" value="'.dol_escape_htmltag($search_societe_alias).
'">';
1045 if (!empty($arrayfields[
'p.priv'][
'checked'])) {
1046 print
'<td class="liste_titre center">';
1047 $selectarray = array(
'0'=>$langs->trans(
"ContactPublic"),
'1'=>$langs->trans(
"ContactPrivate"));
1048 print
$form->selectarray(
'search_priv', $selectarray, $search_priv, 1);
1052 if (!empty($arrayfields[
'p.fk_prospectlevel'][
'checked'])) {
1053 print
'<td class="liste_titre center">';
1054 print
$form->multiselectarray(
'search_level', $tab_level, $search_level, 0, 0,
'width75', 0, 0,
'',
'',
'', 2);
1058 if (!empty($arrayfields[
'p.fk_stcommcontact'][
'checked'])) {
1059 print
'<td class="liste_titre maxwidthonsmartphone center">';
1060 $arraystcomm = array();
1061 foreach ($contactstatic->cacheprospectstatus as $key => $val) {
1062 $arraystcomm[$val[
'id']] = ($langs->trans(
"StatusProspect".$val[
'id']) !=
"StatusProspect".$val[
'id'] ? $langs->trans(
"StatusProspect".$val[
'id']) : $val[
'label']);
1064 print
$form->selectarray(
'search_stcomm', $arraystcomm, $search_stcomm, -2, 0, 0,
'', 0, 0, 0,
'',
'nowrap ');
1068 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
1071 $parameters = array(
'arrayfields'=>$arrayfields);
1072 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
1073 print $hookmanager->resPrint;
1075 if (!empty($arrayfields[
'p.datec'][
'checked'])) {
1076 print
'<td class="liste_titre">';
1080 if (!empty($arrayfields[
'p.tms'][
'checked'])) {
1081 print
'<td class="liste_titre">';
1085 if (!empty($arrayfields[
'p.statut'][
'checked'])) {
1086 print
'<td class="liste_titre center parentonrightofpage">';
1087 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');
1090 if (!empty($arrayfields[
'p.import_key'][
'checked'])) {
1091 print
'<td class="liste_titre center">';
1092 print
'<input class="flat searchstring" type="text" name="search_import_key" size="3" value="'.dol_escape_htmltag($search_import_key).
'">';
1096 if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
1097 print
'<td class="liste_titre maxwidthsearch">';
1098 $searchpicto =
$form->showFilterAndCheckAddButtons(0);
1105 print
'<tr class="liste_titre">';
1106 if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
1107 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
1109 if (!empty($arrayfields[
'p.rowid'][
'checked'])) {
1110 print_liste_field_titre($arrayfields[
'p.rowid'][
'label'], $_SERVER[
"PHP_SELF"],
"p.rowid",
"", $param,
"", $sortfield, $sortorder);
1112 if (!empty($arrayfields[
'p.lastname'][
'checked'])) {
1113 print_liste_field_titre($arrayfields[
'p.lastname'][
'label'], $_SERVER[
"PHP_SELF"],
"p.lastname", $begin, $param,
'', $sortfield, $sortorder);
1115 if (!empty($arrayfields[
'p.firstname'][
'checked'])) {
1116 print_liste_field_titre($arrayfields[
'p.firstname'][
'label'], $_SERVER[
"PHP_SELF"],
"p.firstname", $begin, $param,
'', $sortfield, $sortorder);
1118 if (!empty($arrayfields[
'p.poste'][
'checked'])) {
1119 print_liste_field_titre($arrayfields[
'p.poste'][
'label'], $_SERVER[
"PHP_SELF"],
"p.poste", $begin, $param,
'', $sortfield, $sortorder);
1121 if (!empty($arrayfields[
'p.address'][
'checked'])) {
1122 print_liste_field_titre($arrayfields[
'p.address'][
'label'], $_SERVER[
"PHP_SELF"],
"p.address", $begin, $param,
'', $sortfield, $sortorder);
1124 if (!empty($arrayfields[
'p.zip'][
'checked'])) {
1125 print_liste_field_titre($arrayfields[
'p.zip'][
'label'], $_SERVER[
"PHP_SELF"],
"p.zip", $begin, $param,
'', $sortfield, $sortorder);
1127 if (!empty($arrayfields[
'p.town'][
'checked'])) {
1128 print_liste_field_titre($arrayfields[
'p.town'][
'label'], $_SERVER[
"PHP_SELF"],
"p.town", $begin, $param,
'', $sortfield, $sortorder);
1132 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1133 print_liste_field_titre($arrayfields[
'country.code_iso'][
'label'], $_SERVER[
"PHP_SELF"],
"co.code_iso",
"", $param,
'', $sortfield, $sortorder,
'center ');
1135 if (!empty($arrayfields[
'p.phone'][
'checked'])) {
1136 print_liste_field_titre($arrayfields[
'p.phone'][
'label'], $_SERVER[
"PHP_SELF"],
"p.phone", $begin, $param,
'', $sortfield, $sortorder);
1138 if (!empty($arrayfields[
'p.phone_perso'][
'checked'])) {
1139 print_liste_field_titre($arrayfields[
'p.phone_perso'][
'label'], $_SERVER[
"PHP_SELF"],
"p.phone_perso", $begin, $param,
'', $sortfield, $sortorder);
1141 if (!empty($arrayfields[
'p.phone_mobile'][
'checked'])) {
1142 print_liste_field_titre($arrayfields[
'p.phone_mobile'][
'label'], $_SERVER[
"PHP_SELF"],
"p.phone_mobile", $begin, $param,
'', $sortfield, $sortorder);
1144 if (!empty($arrayfields[
'p.fax'][
'checked'])) {
1145 print_liste_field_titre($arrayfields[
'p.fax'][
'label'], $_SERVER[
"PHP_SELF"],
"p.fax", $begin, $param,
'', $sortfield, $sortorder);
1147 if (!empty($arrayfields[
'p.email'][
'checked'])) {
1148 print_liste_field_titre($arrayfields[
'p.email'][
'label'], $_SERVER[
"PHP_SELF"],
"p.email", $begin, $param,
'', $sortfield, $sortorder);
1150 if (!empty($arrayfields[
'unsubscribed'][
'checked'])) {
1151 print_liste_field_titre($arrayfields[
'unsubscribed'][
'label'], $_SERVER[
"PHP_SELF"],
"unsubscribed", $begin, $param,
'', $sortfield, $sortorder,
'center ');
1154 foreach ($socialnetworks as $key => $value) {
1155 if ($value[
'active'] && !empty($arrayfields[
'p.'.$key][
'checked'])) {
1156 print_liste_field_titre($arrayfields[
'p.'.$key][
'label'], $_SERVER[
"PHP_SELF"],
"p.".$key, $begin, $param,
'', $sortfield, $sortorder);
1160 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
1161 print_liste_field_titre($arrayfields[
'p.fk_soc'][
'label'], $_SERVER[
"PHP_SELF"],
"p.fk_soc", $begin, $param,
'', $sortfield, $sortorder);
1163 if (!empty($arrayfields[
's.nom'][
'checked'])) {
1164 print_liste_field_titre($arrayfields[
's.nom'][
'label'], $_SERVER[
"PHP_SELF"],
"s.nom", $begin, $param,
'', $sortfield, $sortorder);
1166 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1167 print_liste_field_titre($arrayfields[
's.name_alias'][
'label'], $_SERVER[
"PHP_SELF"],
"s.name_alias", $begin, $param,
'', $sortfield, $sortorder);
1169 if (!empty($arrayfields[
'p.priv'][
'checked'])) {
1170 print_liste_field_titre($arrayfields[
'p.priv'][
'label'], $_SERVER[
"PHP_SELF"],
"p.priv", $begin, $param,
'', $sortfield, $sortorder,
'center ');
1172 if (!empty($arrayfields[
'p.fk_prospectlevel'][
'checked'])) {
1173 print_liste_field_titre($arrayfields[
'p.fk_prospectlevel'][
'label'], $_SERVER[
"PHP_SELF"],
"p.fk_prospectlevel",
"", $param,
'', $sortfield, $sortorder,
'center ');
1175 if (!empty($arrayfields[
'p.fk_stcommcontact'][
'checked'])) {
1176 print_liste_field_titre($arrayfields[
'p.fk_stcommcontact'][
'label'], $_SERVER[
"PHP_SELF"],
"p.fk_stcommcontact",
"", $param,
'', $sortfield, $sortorder,
'center ');
1179 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
1181 $parameters = array(
1182 'arrayfields'=>$arrayfields,
1184 'sortfield'=>$sortfield,
1185 'sortorder'=>$sortorder,
1187 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
1188 print $hookmanager->resPrint;
1189 if (!empty($arrayfields[
'p.datec'][
'checked'])) {
1190 print_liste_field_titre($arrayfields[
'p.datec'][
'label'], $_SERVER[
"PHP_SELF"],
"p.datec",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1192 if (!empty($arrayfields[
'p.tms'][
'checked'])) {
1193 print_liste_field_titre($arrayfields[
'p.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"p.tms",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1195 if (!empty($arrayfields[
'p.statut'][
'checked'])) {
1196 print_liste_field_titre($arrayfields[
'p.statut'][
'label'], $_SERVER[
"PHP_SELF"],
"p.statut",
"", $param,
'', $sortfield, $sortorder,
'center ');
1198 if (!empty($arrayfields[
'p.import_key'][
'checked'])) {
1199 print_liste_field_titre($arrayfields[
'p.import_key'][
'label'], $_SERVER[
"PHP_SELF"],
"p.import_key",
"", $param,
'', $sortfield, $sortorder,
'center ');
1201 if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
1202 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
1208 $totalarray = array();
1209 $totalarray[
'nbfield'] = 0;
1210 while ($i < min($num, $limit)) {
1211 $obj = $db->fetch_object($resql);
1213 $arraysocialnetworks = (array) json_decode($obj->socialnetworks,
true);
1214 $contactstatic->lastname = $obj->lastname;
1215 $contactstatic->firstname =
'';
1216 $contactstatic->id = $obj->rowid;
1217 $contactstatic->statut = $obj->statut;
1218 $contactstatic->poste = $obj->poste;
1219 $contactstatic->email = $obj->email;
1220 $contactstatic->phone_pro = $obj->phone_pro;
1221 $contactstatic->phone_perso = $obj->phone_perso;
1222 $contactstatic->phone_mobile = $obj->phone_mobile;
1223 $contactstatic->address = $obj->address;
1224 $contactstatic->zip = $obj->zip;
1225 $contactstatic->town = $obj->town;
1226 $contactstatic->socialnetworks = $arraysocialnetworks;
1227 $contactstatic->country = $obj->country;
1228 $contactstatic->country_code = $obj->country_code;
1229 $contactstatic->photo = $obj->photo;
1230 $contactstatic->import_key = $obj->import_key;
1232 $contactstatic->fk_prospectlevel = $obj->fk_prospectlevel;
1234 if ($mode ==
'kanban') {
1236 print
'<tr><td colspan="12">';
1237 print
'<div class="box-flex-container kanban">';
1239 $contactstatic->photo = $obj->photo;
1240 if ($obj->socid > 0) {
1241 $contactstatic->fetch_thirdparty($obj->socid);
1243 print $contactstatic->getKanbanView(
'');
1244 if ($i == min($num, $limit) - 1) {
1249 print
'<tr class="oddeven" id="rowid-'.((int) $obj->rowid).
'">';
1252 if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
1253 print
'<td class="nowrap center">';
1254 if ($massactionbutton || $massaction) {
1256 if (in_array($obj->rowid, $arrayofselected)) {
1259 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1265 if (!empty($arrayfields[
'p.rowid'][
'checked'])) {
1266 print
'<td class="tdoverflowmax50">';
1270 $totalarray[
'nbfield']++;
1275 if (!empty($arrayfields[
'p.lastname'][
'checked'])) {
1276 print
'<td class="middle tdoverflowmax150">';
1277 print $contactstatic->getNomUrl(1);
1280 $totalarray[
'nbfield']++;
1285 if (!empty($arrayfields[
'p.firstname'][
'checked'])) {
1286 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($obj->firstname).
'">'.
dol_escape_htmltag($obj->firstname).
'</td>';
1288 $totalarray[
'nbfield']++;
1293 if (!empty($arrayfields[
'p.poste'][
'checked'])) {
1294 print
'<td class="tdoverflowmax100">'.dol_escape_htmltag($obj->poste).
'</td>';
1296 $totalarray[
'nbfield']++;
1301 if (!empty($arrayfields[
'p.address'][
'checked'])) {
1302 print
'<td>'.dol_escape_htmltag($obj->address).
'</td>';
1304 $totalarray[
'nbfield']++;
1309 if (!empty($arrayfields[
'p.zip'][
'checked'])) {
1310 print
'<td>'.dol_escape_htmltag($obj->zip).
'</td>';
1312 $totalarray[
'nbfield']++;
1317 if (!empty($arrayfields[
'p.town'][
'checked'])) {
1318 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->town).
'">'.
dol_escape_htmltag($obj->town).
'</td>';
1320 $totalarray[
'nbfield']++;
1340 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1341 print
'<td class="center">';
1342 $tmparray =
getCountry($obj->fk_pays,
'all');
1346 $totalarray[
'nbfield']++;
1351 if (!empty($arrayfields[
'p.phone'][
'checked'])) {
1352 print
'<td class="nowraponall tdoverflowmax150">'.dol_print_phone($obj->phone_pro, $obj->country_code, $obj->rowid, $obj->socid,
'AC_TEL',
' ',
'phone').
'</td>';
1354 $totalarray[
'nbfield']++;
1359 if (!empty($arrayfields[
'p.phone_perso'][
'checked'])) {
1360 print
'<td class="nowraponall tdoverflowmax150">'.dol_print_phone($obj->phone_perso, $obj->country_code, $obj->rowid, $obj->socid,
'AC_TEL',
' ',
'phone').
'</td>';
1362 $totalarray[
'nbfield']++;
1367 if (!empty($arrayfields[
'p.phone_mobile'][
'checked'])) {
1368 print
'<td class="nowraponall tdoverflowmax150">'.dol_print_phone($obj->phone_mobile, $obj->country_code, $obj->rowid, $obj->socid,
'AC_TEL',
' ',
'mobile').
'</td>';
1370 $totalarray[
'nbfield']++;
1375 if (!empty($arrayfields[
'p.fax'][
'checked'])) {
1376 print
'<td class="nowraponall tdoverflowmax150">'.dol_print_phone($obj->fax, $obj->country_code, $obj->rowid, $obj->socid,
'AC_TEL',
' ',
'fax').
'</td>';
1378 $totalarray[
'nbfield']++;
1383 if (!empty($arrayfields[
'p.email'][
'checked'])) {
1384 print
'<td class="nowraponall tdoverflowmax300">'.dol_print_email($obj->email, $obj->rowid, $obj->socid,
'AC_EMAIL', 18, 0, 1).
'</td>';
1386 $totalarray[
'nbfield']++;
1391 if (!empty($arrayfields[
'unsubscribed'][
'checked'])) {
1392 print
'<td class="center">';
1393 if (empty($obj->email)) {
1396 print
yn(($obj->unsubscribed > 0) ? 1 : 0);
1400 $totalarray[
'nbfield']++;
1406 foreach ($socialnetworks as $key => $value) {
1407 if ($value[
'active'] && !empty($arrayfields[
'p.'.$key][
'checked'])) {
1408 print
'<td class="tdoverflowmax100">'.(empty($arraysocialnetworks[$key]) ?
'' :
dol_print_socialnetworks($arraysocialnetworks[$key], $obj->rowid, $obj->socid, $key, $socialnetworks)).
'</td>';
1410 $totalarray[
'nbfield']++;
1417 if (!empty($arrayfields[
'p.fk_soc'][
'checked']) || !empty($arrayfields[
's.nom'][
'checked'])) {
1418 print
'<td class="tdoverflowmax200">';
1421 $objsoc->fetch($obj->socid);
1422 print $objsoc->getNomUrl(1,
'', 100, 0, 1, empty($arrayfields[
's.name_alias'][
'checked']) ? 0 : 1);
1428 $totalarray[
'nbfield']++;
1433 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1434 print
'<td class="nocellnopadd">';
1438 $totalarray[
'nbfield']++;
1443 if (!empty($arrayfields[
'p.priv'][
'checked'])) {
1444 print
'<td class="center">'.$contactstatic->LibPubPriv($obj->priv).
'</td>';
1446 $totalarray[
'nbfield']++;
1451 if (!empty($arrayfields[
'p.fk_prospectlevel'][
'checked'])) {
1452 print
'<td class="center">';
1453 print $contactstatic->getLibProspLevel();
1456 $totalarray[
'nbfield']++;
1461 if (!empty($arrayfields[
'p.fk_stcommcontact'][
'checked'])) {
1462 print
'<td class="center nowrap"><div class="nowrap">';
1463 print
'<div class="inline-block">'.$contactstatic->libProspCommStatut($obj->stcomm_id, 2, $contactstatic->cacheprospectstatus[$obj->stcomm_id][
'label'], $obj->stcomm_picto);
1464 print
'</div> - <div class="inline-block">';
1465 foreach ($contactstatic->cacheprospectstatus as $key => $val) {
1466 $titlealt =
'default';
1467 if (!empty($val[
'code']) && !in_array($val[
'code'], array(
'ST_NO',
'ST_NEVER',
'ST_TODO',
'ST_PEND',
'ST_DONE'))) {
1468 $titlealt = $val[
'label'];
1470 if ($obj->stcomm_id != $val[
'id']) {
1471 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>';
1474 print
'</div></div></td>';
1476 $totalarray[
'nbfield']++;
1481 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
1484 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$obj,
'i'=>$i,
'totalarray'=>&$totalarray);
1485 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
1486 print $hookmanager->resPrint;
1488 if (!empty($arrayfields[
'p.datec'][
'checked'])) {
1489 print
'<td class="center nowraponall">';
1490 print
dol_print_date($db->jdate($obj->date_creation),
'dayhour',
'tzuser');
1493 $totalarray[
'nbfield']++;
1498 if (!empty($arrayfields[
'p.tms'][
'checked'])) {
1499 print
'<td class="center nowraponall">';
1500 print
dol_print_date($db->jdate($obj->date_update),
'dayhour',
'tzuser');
1503 $totalarray[
'nbfield']++;
1508 if (!empty($arrayfields[
'p.statut'][
'checked'])) {
1509 print
'<td class="center">'.$contactstatic->getLibStatut(5).
'</td>';
1511 $totalarray[
'nbfield']++;
1516 if (!empty($arrayfields[
'p.import_key'][
'checked'])) {
1517 print
'<td class="tdoverflowmax100">';
1521 $totalarray[
'nbfield']++;
1526 if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
1527 print
'<td class="nowrap center">';
1528 if ($massactionbutton || $massaction) {
1530 if (in_array($obj->rowid, $arrayofselected)) {
1533 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1538 $totalarray[
'nbfield']++;
1547 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
1552 foreach ($arrayfields as $key => $val) {
1553 if (!empty($val[
'checked'])) {
1557 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
1562 $parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>
$sql);
1563 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
1564 print $hookmanager->resPrint;
1566 print
'</table>'.
"\n";
1567 print
'</div>'.
"\n";
1569 print
'</form>'.
"\n";