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';
59 $contactid =
GETPOST(
'id',
'int');
62 $socid = $user->socid;
66 $sall = trim((
GETPOST(
'search_all',
'alphanohtml') !=
'') ?
GETPOST(
'search_all',
'alphanohtml') :
GETPOST(
'sall',
'alphanohtml'));
67 $search_cti = preg_replace(
'/^0+/',
'', preg_replace(
'/[^0-9]/',
'',
GETPOST(
'search_cti',
'alphanohtml')));
68 $search_phone =
GETPOST(
"search_phone",
'alpha');
70 $search_id =
GETPOST(
"search_id",
"int");
71 $search_firstlast_only =
GETPOST(
"search_firstlast_only",
'alpha');
72 $search_lastname =
GETPOST(
"search_lastname",
'alpha');
73 $search_firstname =
GETPOST(
"search_firstname",
'alpha');
74 $search_societe =
GETPOST(
"search_societe",
'alpha');
75 $search_societe_alias =
GETPOST(
"search_societe_alias",
'alpha');
76 $search_poste =
GETPOST(
"search_poste",
'alpha');
77 $search_phone_perso =
GETPOST(
"search_phone_perso",
'alpha');
78 $search_phone_pro =
GETPOST(
"search_phone_pro",
'alpha');
79 $search_phone_mobile =
GETPOST(
"search_phone_mobile",
'alpha');
80 $search_fax =
GETPOST(
"search_fax",
'alpha');
81 $search_email =
GETPOST(
"search_email",
'alpha');
83 $search_no_email =
GETPOSTISSET(
"search_no_email") ?
GETPOST(
"search_no_email",
'int') : -1;
85 $search_no_email = -1;
88 foreach ($socialnetworks as $key => $value) {
89 if ($value[
'active']) {
90 $search_[$key] =
GETPOST(
"search_".$key,
'alpha');
94 $search_priv =
GETPOST(
"search_priv",
'alpha');
95 $search_categ =
GETPOST(
"search_categ",
'int');
96 $search_categ_thirdparty =
GETPOST(
"search_categ_thirdparty",
'int');
97 $search_categ_supplier =
GETPOST(
"search_categ_supplier",
'int');
98 $search_status =
GETPOST(
"search_status",
'int');
99 $search_type =
GETPOST(
'search_type',
'alpha');
100 $search_address =
GETPOST(
'search_address',
'alpha');
101 $search_zip =
GETPOST(
'search_zip',
'alpha');
102 $search_town =
GETPOST(
'search_town',
'alpha');
103 $search_import_key =
GETPOST(
"search_import_key",
"alpha");
104 $search_country =
GETPOST(
"search_country",
'intcomma');
105 $search_roles =
GETPOST(
"search_roles",
'array');
106 $search_level =
GETPOST(
"search_level",
"array");
107 $search_stcomm =
GETPOST(
'search_stcomm',
'int');
109 if ($search_status ===
'') {
112 if ($search_no_email ===
'') {
113 $search_no_email = -1;
116 $optioncss =
GETPOST(
'optioncss',
'alpha');
120 $view =
GETPOST(
"view",
'alpha');
122 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
123 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
124 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
126 $userid =
GETPOST(
'userid',
'int');
132 $sortfield =
"p.lastname";
134 if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
137 $offset = $limit * $page;
140 $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans(
"Contacts") : $langs->trans(
"ContactsAddresses"));
142 if (empty($contextpage) || $contextpage ==
'contactlist') {
143 $contextpage =
'contactprospectlist';
145 $title .=
' ('.$langs->trans(
"ThirdPartyProspects").
')';
146 $urlfiche =
"card.php";
149 if (empty($contextpage) || $contextpage ==
'contactlist') {
150 $contextpage =
'contactcustomerlist';
152 $title .=
' ('.$langs->trans(
"ThirdPartyCustomers").
')';
153 $urlfiche =
"card.php";
154 } elseif ($type ==
"f") {
155 if (empty($contextpage) || $contextpage ==
'contactlist') {
156 $contextpage =
'contactsupplierlist';
158 $title .=
' ('.$langs->trans(
"ThirdPartySuppliers").
')';
159 $urlfiche =
"card.php";
160 } elseif ($type ==
"o") {
161 if (empty($contextpage) || $contextpage ==
'contactlist') {
162 $contextpage =
'contactotherlist';
164 $title .=
' ('.$langs->trans(
"OthersNotLinkedToThirdParty").
')';
170 $hookmanager->initHooks(array(
'contactlist'));
174 $extrafields->fetch_name_optionals_label($object->table_element);
176 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
179 $fieldstosearchall = array();
180 foreach ($object->fields as $key => $val) {
182 if (!empty($user->socid) && $key ==
"note_private") {
186 if (empty($val[
'searchall'])) {
190 $fieldstosearchall[
'p.'.$key] = $val[
'label'];
194 if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) {
195 $fieldstosearchall[
's.nom'] =
"ThirdParty";
196 $fieldstosearchall[
's.name_alias'] =
"AliasNames";
200 $arrayfields = array();
201 foreach ($object->fields as $key => $val) {
203 if (empty($val[
'visible'])) {
207 $arrayfields[
'p.'.$key] = array(
208 'label'=>$val[
'label'],
209 'checked'=>(($val[
'visible'] < 0) ? 0 : 1),
210 'enabled'=>($val[
'enabled'] && ($val[
'visible'] != 3)),
211 'position'=>$val[
'position']);
215 $arrayfields[
'country.code_iso'] = array(
'label'=>
"Country",
'position'=>66,
'checked'=>0);
216 if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) {
217 $arrayfields[
's.nom'] = array(
'label'=>
"ThirdParty",
'position'=>113,
'checked'=> 1);
218 $arrayfields[
's.name_alias'] = array(
'label'=>
"AliasNameShort",
'position'=>114,
'checked'=> 1);
221 $arrayfields[
'unsubscribed'] = array(
228 foreach ($socialnetworks as $key => $value) {
229 if ($value[
'active']) {
230 $arrayfields[
'p.'.$key] = array(
231 'label' => $value[
'label'],
240 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
246 if (($id > 0 || !empty($ref)) && $action !=
'add') {
247 $result = $object->fetch($id, $ref);
258 if (
GETPOST(
'cancel',
'alpha')) {
259 $action =
'list'; $massaction =
'';
261 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
265 $parameters = array();
266 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
271 if (empty($reshook)) {
273 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
276 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
279 $search_firstlast_only =
"";
280 $search_lastname =
"";
281 $search_firstname =
"";
282 $search_societe =
"";
283 $search_societe_alias =
"";
285 $search_address =
"";
287 $search_country =
"";
290 $search_phone_perso =
"";
291 $search_phone_pro =
"";
292 $search_phone_mobile =
"";
295 $search_no_email = -1;
297 foreach ($socialnetworks as $key => $value) {
298 if ($value[
'active']) {
308 $search_categ_thirdparty =
'';
309 $search_categ_supplier =
'';
310 $search_import_key =
'';
312 $search_array_options = array();
313 $search_roles = array();
317 $objectclass =
'Contact';
318 $objectlabel =
'Contact';
319 $permissiontoread = $user->hasRight(
'societe',
'lire');
320 $permissiontodelete = $user->hasRight(
'societe',
'supprimer');
321 $permissiontoadd = $user->rights->societe->creer;
322 $uploaddir = $conf->societe->dir_output;
323 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
325 if ($action ==
'setstcomm') {
327 $result = $object->fetch(
GETPOST(
'stcommcontactid'));
329 $result = $object->update($object->id, $user);
338 if ($search_priv < 0) {
350 $contactstatic =
new Contact($db);
355 if (!empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES)) {
356 $contactstatic->loadCacheOfProspStatus();
360 $tab_level = array();
361 $sql =
"SELECT code, label, sortorder";
362 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_prospectcontactlevel";
363 $sql .=
" WHERE active > 0";
364 $sql .=
" ORDER BY sortorder";
365 $resql = $db->query($sql);
367 while ($obj = $db->fetch_object(
$resql)) {
369 $level = $langs->trans($obj->code);
370 if ($level == $obj->code) {
371 $level = $langs->trans($obj->label);
373 $tab_level[$obj->code] = $level;
379 $sql =
"SELECT s.rowid as socid, s.nom as name, s.name_alias as alias,";
380 $sql .=
" p.rowid, p.lastname as lastname, p.statut, p.firstname, p.address, p.zip, p.town, p.poste, p.email,";
381 $sql .=
" p.socialnetworks, p.photo,";
382 $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,";
383 $sql .=
" p.import_key,";
384 $sql .=
" st.libelle as stcomm, st.picto as stcomm_picto, p.fk_stcommcontact as stcomm_id, p.fk_prospectcontactlevel,";
385 $sql .=
" co.label as country, co.code as country_code";
387 if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
388 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
389 $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
393 $sql .=
", (SELECT count(*) FROM ".MAIN_DB_PREFIX.
"mailing_unsubscribe WHERE email = p.email) as unsubscribed";
396 $parameters = array();
397 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
398 $sql .= $hookmanager->resPrint;
402 $sql .=
" FROM ".MAIN_DB_PREFIX.
"socpeople as p";
403 if (isset($extrafields->attributes[$object->table_element][
'label']) && is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label'])) {
404 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (p.rowid = ef.fk_object)";
406 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as co ON co.rowid = p.fk_pays";
407 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid = p.fk_soc";
408 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_stcommcontact as st ON st.id = p.fk_stcommcontact";
409 if (empty($user->rights->societe->client->voir) && !$socid) {
410 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON s.rowid = sc.fk_soc";
412 $sql .=
' WHERE p.entity IN ('.getEntity(
'contact').
')';
413 if (empty($user->rights->societe->client->voir) && !$socid) {
414 $sql .=
" AND (sc.fk_user = ".((int) $user->id).
" OR p.fk_soc IS NULL)";
416 if (!empty($userid)) {
417 $sql .=
" AND p.fk_user_creat=".((int) $userid);
420 $sql .=
natural_search(
"p.fk_prospectcontactlevel", join(
',', $search_level), 3);
422 if ($search_stcomm !=
'' && $search_stcomm != -2) {
427 if ($search_priv !=
'0' && $search_priv !=
'1') {
428 $sql .=
" AND (p.priv='0' OR (p.priv='1' AND p.fk_user_creat=".((int) $user->id).
"))";
430 if ($search_priv ==
'0') {
431 $sql .=
" AND p.priv='0'";
433 if ($search_priv ==
'1') {
434 $sql .=
" AND (p.priv='1' AND p.fk_user_creat=".((int) $user->id).
")";
437 $searchCategoryContactList = $search_categ ? array($search_categ) : array();
438 $searchCategoryContactOperator = 0;
440 if (!empty($searchCategoryContactList)) {
441 $searchCategoryContactSqlList = array();
442 $listofcategoryid =
'';
443 foreach ($searchCategoryContactList as $searchCategoryContact) {
444 if (intval($searchCategoryContact) == -2) {
445 $searchCategoryContactSqlList[] =
"NOT EXISTS (SELECT ck.fk_socpeople FROM ".MAIN_DB_PREFIX.
"categorie_contact as ck WHERE p.rowid = ck.fk_socpeople)";
446 } elseif (intval($searchCategoryContact) > 0) {
447 if ($searchCategoryContactOperator == 0) {
448 $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).
")";
450 $listofcategoryid .= ($listofcategoryid ?
', ' :
'') .((
int) $searchCategoryContact);
454 if ($listofcategoryid) {
455 $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).
"))";
457 if ($searchCategoryContactOperator == 1) {
458 if (!empty($searchCategoryContactSqlList)) {
459 $sql .=
" AND (".implode(
' OR ', $searchCategoryContactSqlList).
")";
462 if (!empty($searchCategoryContactSqlList)) {
463 $sql .=
" AND (".implode(
' AND ', $searchCategoryContactSqlList).
")";
467 $searchCategoryCustomerList = $search_categ_thirdparty ? array($search_categ_thirdparty) : array();
468 $searchCategoryCustomerOperator = 0;
470 if (!empty($searchCategoryCustomerList)) {
471 $searchCategoryCustomerSqlList = array();
472 $listofcategoryid =
'';
473 foreach ($searchCategoryCustomerList as $searchCategoryCustomer) {
474 if (intval($searchCategoryCustomer) == -2) {
475 $searchCategoryCustomerSqlList[] =
"NOT EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX.
"categorie_societe as ck WHERE s.rowid = ck.fk_soc)";
476 } elseif (intval($searchCategoryCustomer) > 0) {
477 if ($searchCategoryCustomerOperator == 0) {
478 $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).
")";
480 $listofcategoryid .= ($listofcategoryid ?
', ' :
'') .((
int) $searchCategoryCustomer);
484 if ($listofcategoryid) {
485 $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).
"))";
487 if ($searchCategoryCustomerOperator == 1) {
488 if (!empty($searchCategoryCustomerSqlList)) {
489 $sql .=
" AND (".implode(
' OR ', $searchCategoryCustomerSqlList).
")";
492 if (!empty($searchCategoryCustomerSqlList)) {
493 $sql .=
" AND (".implode(
' AND ', $searchCategoryCustomerSqlList).
")";
497 $searchCategorySupplierList = $search_categ_supplier ? array($search_categ_supplier) : array();
498 $searchCategorySupplierOperator = 0;
500 if (!empty($searchCategorySupplierList)) {
501 $searchCategorySupplierSqlList = array();
502 $listofcategoryid =
'';
503 foreach ($searchCategorySupplierList as $searchCategorySupplier) {
504 if (intval($searchCategorySupplier) == -2) {
505 $searchCategorySupplierSqlList[] =
"NOT EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX.
"categorie_fournisseur as ck WHERE s.rowid = ck.fk_soc)";
506 } elseif (intval($searchCategorySupplier) > 0) {
507 if ($searchCategorySupplierOperator == 0) {
508 $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).
")";
510 $listofcategoryid .= ($listofcategoryid ?
', ' :
'') .((
int) $searchCategorySupplier);
514 if ($listofcategoryid) {
515 $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).
"))";
517 if ($searchCategorySupplierOperator == 1) {
518 if (!empty($searchCategorySupplierSqlList)) {
519 $sql .=
" AND (".implode(
' OR ', $searchCategorySupplierSqlList).
")";
522 if (!empty($searchCategorySupplierSqlList)) {
523 $sql .=
" AND (".implode(
' AND ', $searchCategorySupplierSqlList).
")";
531 if (strlen($search_phone)) {
532 $sql .=
natural_search(array(
'p.phone',
'p.phone_perso',
'p.phone_mobile'), $search_phone);
534 if (strlen($search_cti)) {
535 $sql .=
natural_search(array(
'p.phone',
'p.phone_perso',
'p.phone_mobile'), $search_cti);
537 if (strlen($search_firstlast_only)) {
538 $sql .=
natural_search(array(
'p.lastname',
'p.firstname'), $search_firstlast_only);
541 if ($search_id > 0) {
544 if ($search_lastname) {
547 if ($search_firstname) {
550 if (empty($arrayfields[
's.name_alias'][
'checked']) && $search_societe) {
551 $sql .=
natural_search(array(
"s.nom",
"s.name_alias"), $search_societe);
553 if ($search_societe) {
556 if ($search_societe_alias) {
560 if ($search_country) {
561 $sql .=
" AND p.fk_pays IN (".$db->sanitize($search_country).
')';
563 if (strlen($search_poste)) {
566 if (strlen($search_phone_perso)) {
569 if (strlen($search_phone_pro)) {
572 if (strlen($search_phone_mobile)) {
575 if (strlen($search_fax)) {
579 foreach ($socialnetworks as $key => $value) {
580 if ($value[
'active'] && strlen($search_[$key])) {
581 $searchkeyinjsonformat = preg_replace(
'/"$/',
'', preg_replace(
'/^"/',
'', json_encode($search_[$key])));
582 if (in_array($db->type, array(
'mysql',
'mysqli'))) {
583 $sql .=
" AND p.socialnetworks REGEXP '\"".$db->escape($db->escapeforlike($key)).
"\":\"[^\"]*".$db->escape($db->escapeforlike($searchkeyinjsonformat)).
"'";
584 } elseif ($db->type ==
'pgsql') {
585 $sql .=
" AND p.socialnetworks ~ '\"".$db->escape($db->escapeforlike($key)).
"\":\"[^\"]*".$db->escape($db->escapeforlike($searchkeyinjsonformat)).
"'";
588 $sql .=
" AND p.socialnetworks LIKE '%\"".$db->escape($db->escapeforlike($key)).
"\":\"".$db->escape($db->escapeforlike($searchkeyinjsonformat)).
"%'";
594 if (strlen($search_email)) {
597 if (strlen($search_address)) {
600 if (strlen($search_zip)) {
603 if (strlen($search_town)) {
606 if (count($search_roles) > 0) {
607 $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)).
"))";
609 if ($search_no_email != -1 && $search_no_email > 0) {
610 $sql .=
" AND (SELECT count(*) FROM ".MAIN_DB_PREFIX.
"mailing_unsubscribe WHERE email = p.email) > 0";
612 if ($search_no_email != -1 && $search_no_email == 0) {
613 $sql .=
" AND (SELECT count(*) FROM ".MAIN_DB_PREFIX.
"mailing_unsubscribe WHERE email = p.email) = 0 AND p.email IS NOT NULL AND p.email <> ''";
615 if ($search_status !=
'' && $search_status >= 0) {
616 $sql .=
" AND p.statut = ".((int) $search_status);
618 if ($search_import_key) {
622 $sql .=
" AND p.fk_soc IS NULL";
623 } elseif ($type ==
"f") {
624 $sql .=
" AND s.fournisseur = 1";
625 } elseif ($type ==
"c") {
626 $sql .=
" AND s.client IN (1, 3)";
627 } elseif ($type ==
"p") {
628 $sql .=
" AND s.client IN (2, 3)";
630 if (!empty($socid)) {
631 $sql .=
" AND s.rowid = ".((int) $socid);
634 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
636 $parameters = array();
637 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
638 $sql .= $hookmanager->resPrint;
643 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
645 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
646 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
647 $resql = $db->query($sqlforcount);
649 $objforcount = $db->fetch_object(
$resql);
663 if ($view ==
"recent") {
664 $sql .= $db->order(
"p.datec",
"DESC");
666 $sql .= $db->order($sortfield, $sortorder);
669 $sql .= $db->plimit($limit + 1, $offset);
672 $resql = $db->query($sql);
678 $num = $db->num_rows(
$resql);
680 $arrayofselected = is_array($toselect) ? $toselect : array();
682 if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && ($sall !=
'' || $search_cti !=
'')) {
683 $obj = $db->fetch_object(
$resql);
685 header(
"Location: ".DOL_URL_ROOT.
'/contact/card.php?id='.$id);
689 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
690 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
692 $help_url =
'EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Empresas';
696 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
697 $param .=
'&contextpage='.urlencode($contextpage);
699 if ($limit > 0 && $limit != $conf->liste_limit) {
700 $param .=
'&limit='.((int) $limit);
702 $param .=
'&begin='.urlencode($begin).
'&userid='.urlencode($userid).
'&contactname='.urlencode($sall);
703 $param .=
'&type='.urlencode($type).
'&view='.urlencode($view);
704 if (!empty($search_categ) && $search_categ !=
'-1') {
705 $param .=
'&search_categ='.urlencode($search_categ);
707 if (!empty($search_categ_thirdparty) && $search_categ_thirdparty !=
'-1') {
708 $param .=
'&search_categ_thirdparty='.urlencode($search_categ_thirdparty);
710 if (!empty($search_categ_supplier) && $search_categ_supplier !=
'-1') {
711 $param .=
'&search_categ_supplier='.urlencode($search_categ_supplier);
714 $param .=
'&sall='.urlencode($sall);
716 if ($search_id > 0) {
717 $param .=
"&search_id=".urlencode($search_id);
719 if ($search_lastname !=
'') {
720 $param .=
'&search_lastname='.urlencode($search_lastname);
722 if ($search_firstname !=
'') {
723 $param .=
'&search_firstname='.urlencode($search_firstname);
725 if ($search_societe !=
'') {
726 $param .=
'&search_societe='.urlencode($search_societe);
728 if ($search_societe_alias !=
'') {
729 $param .=
'&search_societe_alias='.urlencode($search_societe_alias);
731 if ($search_address !=
'') {
732 $param .=
'&search_address='.urlencode($search_address);
734 if ($search_zip !=
'') {
735 $param .=
'&search_zip='.urlencode($search_zip);
737 if ($search_town !=
'') {
738 $param .=
'&search_town='.urlencode($search_town);
740 if ($search_country !=
'') {
741 $param .=
"&search_country=".urlencode($search_country);
743 if ($search_poste !=
'') {
744 $param .=
'&search_poste='.urlencode($search_poste);
746 if ($search_phone_pro !=
'') {
747 $param .=
'&search_phone_pro='.urlencode($search_phone_pro);
749 if ($search_phone_perso !=
'') {
750 $param .=
'&search_phone_perso='.urlencode($search_phone_perso);
752 if ($search_phone_mobile !=
'') {
753 $param .=
'&search_phone_mobile='.urlencode($search_phone_mobile);
755 if ($search_fax !=
'') {
756 $param .=
'&search_fax='.urlencode($search_fax);
758 if ($search_email !=
'') {
759 $param .=
'&search_email='.urlencode($search_email);
761 if ($search_no_email !=
'') {
762 $param .=
'&search_no_email='.urlencode($search_no_email);
764 if ($search_status !=
'') {
765 $param .=
'&search_status='.urlencode($search_status);
767 if ($search_priv ==
'0' || $search_priv ==
'1') {
768 $param .=
"&search_priv=".urlencode($search_priv);
770 if ($search_stcomm !=
'') {
771 $param .=
'&search_stcomm='.urlencode($search_stcomm);
773 if (is_array($search_level) && count($search_level)) {
774 foreach ($search_level as $slevel) {
775 $param .=
'&search_level[]='.urlencode($slevel);
778 if ($search_import_key !=
'') {
779 $param .=
'&search_import_key='.urlencode($search_import_key);
781 if ($optioncss !=
'') {
782 $param .=
'&optioncss='.urlencode($optioncss);
784 if (count($search_roles) > 0) {
785 $param .= implode(
'&search_roles[]=', $search_roles);
789 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
792 $arrayofmassactions = array(
797 if ($user->hasRight(
'societe',
'supprimer')) {
798 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
800 if (
isModEnabled(
'category') && $user->rights->societe->creer) {
801 $arrayofmassactions[
'preaffecttag'] =
img_picto(
'',
'category',
'class="pictofixedwidth"').$langs->trans(
"AffectTag");
803 if (in_array($massaction, array(
'presend',
'predelete',
'preaffecttag'))) {
804 $arrayofmassactions = array();
806 $massactionbutton =
$form->selectMassAction(
'', $arrayofmassactions);
808 $newcardbutton =
dolGetButtonTitle($langs->trans(
'NewContactAddress'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/contact/card.php?action=create',
'', $user->rights->societe->contact->creer);
810 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'" name="formfilter">';
811 if ($optioncss !=
'') {
812 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
814 print
'<input type="hidden" name="token" value="'.newToken().
'">';
815 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
816 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
817 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
819 print
'<input type="hidden" name="type" value="'.$type.
'">';
820 print
'<input type="hidden" name="view" value="'.dol_escape_htmltag($view).
'">';
822 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num,
$nbtotalofrecords,
'address', 0, $newcardbutton,
'', $limit, 0, 0, 1);
824 $topicmail =
"Information";
825 $modelmail =
"contact";
827 $trackid =
'ctc'.$object->id;
828 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
831 foreach ($fieldstosearchall as $key => $val) {
832 $fieldstosearchall[$key] = $langs->trans($val);
834 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $sall).join(
', ', $fieldstosearchall).
'</div>';
836 if ($search_firstlast_only) {
837 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_firstlast_only).$langs->trans(
"Lastname").
", ".$langs->trans(
"Firstname").
'</div>';
841 if (
isModEnabled(
'categorie') && $user->rights->categorie->lire) {
842 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
843 $moreforfilter .=
'<div class="divsearchfield">';
844 $tmptitle = $langs->trans(
'ContactCategoriesShort');
845 $moreforfilter .=
img_picto($tmptitle,
'category',
'class="pictofixedwidth"');
846 $moreforfilter .= $formother->select_categories(Categorie::TYPE_CONTACT, $search_categ,
'search_categ', 1, $tmptitle);
847 $moreforfilter .=
'</div>';
848 if (empty($type) || $type ==
'c' || $type ==
'p') {
849 $moreforfilter .=
'<div class="divsearchfield">';
852 $tmptitle .= $langs->trans(
'CustomersCategoriesShort');
853 } elseif ($type ==
'p') {
854 $tmptitle .= $langs->trans(
'ProspectsCategoriesShort');
856 $tmptitle .= $langs->trans(
'CustomersProspectsCategoriesShort');
858 $moreforfilter .=
img_picto($tmptitle,
'category',
'class="pictofixedwidth"');
859 $moreforfilter .= $formother->select_categories(Categorie::TYPE_CUSTOMER, $search_categ_thirdparty,
'search_categ_thirdparty', 1, $tmptitle);
860 $moreforfilter .=
'</div>';
863 if (
isModEnabled(
"fournisseur") && (empty($type) || $type ==
'f')) {
864 $moreforfilter .=
'<div class="divsearchfield">';
865 $tmptitle = $langs->trans(
'SuppliersCategoriesShort');
866 $moreforfilter .=
img_picto($tmptitle,
'category',
'class="pictofixedwidth"');
867 $moreforfilter .= $formother->select_categories(Categorie::TYPE_SUPPLIER, $search_categ_supplier,
'search_categ_supplier', 1, $tmptitle);
868 $moreforfilter .=
'</div>';
872 $moreforfilter .=
'<div class="divsearchfield">';
873 $moreforfilter .= $langs->trans(
'Roles').
': ';
874 $moreforfilter .= $formcompany->showRoles(
"search_roles", $objecttmp,
'edit', $search_roles);
875 $moreforfilter .=
'</div>';
877 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
878 print $moreforfilter;
879 $parameters = array(
'type'=>$type);
880 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
881 print $hookmanager->resPrint;
884 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
885 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN',
''));
886 if ($massactionbutton) {
887 $selectedfields .=
$form->showCheckAddButtons(
'checkforselect', 1);
890 print
'<div class="div-table-responsive">';
891 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
894 print
'<tr class="liste_titre_filter">';
896 if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
897 print
'<td class="liste_titre maxwidthsearch">';
898 $searchpicto =
$form->showFilterButtons(
'left');
902 if (!empty($arrayfields[
'p.rowid'][
'checked'])) {
903 print
'<td class="liste_titre">';
904 print
'<input class="flat searchstring" type="text" name="search_id" size="1" value="'.dol_escape_htmltag($search_id).
'">';
907 if (!empty($arrayfields[
'p.lastname'][
'checked'])) {
908 print
'<td class="liste_titre">';
909 print
'<input class="flat" type="text" name="search_lastname" size="6" value="'.dol_escape_htmltag($search_lastname).
'">';
912 if (!empty($arrayfields[
'p.firstname'][
'checked'])) {
913 print
'<td class="liste_titre">';
914 print
'<input class="flat" type="text" name="search_firstname" size="6" value="'.dol_escape_htmltag($search_firstname).
'">';
917 if (!empty($arrayfields[
'p.poste'][
'checked'])) {
918 print
'<td class="liste_titre">';
919 print
'<input class="flat" type="text" name="search_poste" size="5" value="'.dol_escape_htmltag($search_poste).
'">';
922 if (!empty($arrayfields[
'p.address'][
'checked'])) {
923 print
'<td class="liste_titre">';
924 print
'<input class="flat" type="text" name="search_address" size="6" value="'.dol_escape_htmltag($search_address).
'">';
927 if (!empty($arrayfields[
'p.zip'][
'checked'])) {
928 print
'<td class="liste_titre">';
929 print
'<input class="flat" type="text" name="search_zip" size="3" value="'.dol_escape_htmltag($search_zip).
'">';
932 if (!empty($arrayfields[
'p.town'][
'checked'])) {
933 print
'<td class="liste_titre">';
934 print
'<input class="flat" type="text" name="search_town" size="5" value="'.dol_escape_htmltag($search_town).
'">';
952 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
953 print
'<td class="liste_titre center">';
954 print
$form->select_country($search_country,
'search_country',
'', 0,
'minwidth100imp maxwidth100');
957 if (!empty($arrayfields[
'p.phone'][
'checked'])) {
958 print
'<td class="liste_titre">';
959 print
'<input class="flat" type="text" name="search_phone_pro" size="6" value="'.dol_escape_htmltag($search_phone_pro).
'">';
962 if (!empty($arrayfields[
'p.phone_perso'][
'checked'])) {
963 print
'<td class="liste_titre">';
964 print
'<input class="flat" type="text" name="search_phone_perso" size="6" value="'.dol_escape_htmltag($search_phone_perso).
'">';
967 if (!empty($arrayfields[
'p.phone_mobile'][
'checked'])) {
968 print
'<td class="liste_titre">';
969 print
'<input class="flat" type="text" name="search_phone_mobile" size="6" value="'.dol_escape_htmltag($search_phone_mobile).
'">';
972 if (!empty($arrayfields[
'p.fax'][
'checked'])) {
973 print
'<td class="liste_titre">';
974 print
'<input class="flat" type="text" name="search_fax" size="6" value="'.dol_escape_htmltag($search_fax).
'">';
977 if (!empty($arrayfields[
'p.email'][
'checked'])) {
978 print
'<td class="liste_titre">';
979 print
'<input class="flat" type="text" name="search_email" size="6" value="'.dol_escape_htmltag($search_email).
'">';
982 if (!empty($arrayfields[
'unsubscribed'][
'checked'])) {
983 print
'<td class="liste_titre center">';
984 print
$form->selectarray(
'search_no_email', array(
'-1'=>
'',
'0'=>$langs->trans(
'No'),
'1'=>$langs->trans(
'Yes')), $search_no_email);
988 foreach ($socialnetworks as $key => $value) {
989 if ($value[
'active']) {
990 if (!empty($arrayfields[
'p.'.$key][
'checked'])) {
991 print
'<td class="liste_titre">';
992 print
'<input class="flat" type="text" name="search_'.$key.
'" size="6" value="'.
dol_escape_htmltag($search_[$key]).
'">';
998 if (!empty($arrayfields[
'p.fk_soc'][
'checked']) || !empty($arrayfields[
's.nom'][
'checked'])) {
999 print
'<td class="liste_titre">';
1000 print
'<input class="flat" type="text" name="search_societe" size="8" value="'.dol_escape_htmltag($search_societe).
'">';
1004 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1005 print
'<td class="liste_titre" align="left">';
1006 print
'<input class="flat maxwidth100" type="text" name="search_societe_alias" value="'.dol_escape_htmltag($search_societe_alias).
'">';
1009 if (!empty($arrayfields[
'p.priv'][
'checked'])) {
1010 print
'<td class="liste_titre center">';
1011 $selectarray = array(
'0'=>$langs->trans(
"ContactPublic"),
'1'=>$langs->trans(
"ContactPrivate"));
1012 print
$form->selectarray(
'search_priv', $selectarray, $search_priv, 1);
1016 if (!empty($arrayfields[
'p.fk_prospectcontactlevel'][
'checked'])) {
1017 print
'<td class="liste_titre center">';
1018 print
$form->multiselectarray(
'search_level', $tab_level, $search_level, 0, 0,
'width75', 0, 0,
'',
'',
'', 2);
1022 if (!empty($arrayfields[
'p.fk_stcommcontact'][
'checked'])) {
1023 print
'<td class="liste_titre maxwidthonsmartphone center">';
1024 $arraystcomm = array();
1025 foreach ($contactstatic->cacheprospectstatus as $key => $val) {
1026 $arraystcomm[$val[
'id']] = ($langs->trans(
"StatusProspect".$val[
'id']) !=
"StatusProspect".$val[
'id'] ? $langs->trans(
"StatusProspect".$val[
'id']) : $val[
'label']);
1028 print
$form->selectarray(
'search_stcomm', $arraystcomm, $search_stcomm, -2, 0, 0,
'', 0, 0, 0,
'',
'nowrap ');
1032 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
1035 $parameters = array(
'arrayfields'=>$arrayfields);
1036 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
1037 print $hookmanager->resPrint;
1039 if (!empty($arrayfields[
'p.datec'][
'checked'])) {
1040 print
'<td class="liste_titre">';
1044 if (!empty($arrayfields[
'p.tms'][
'checked'])) {
1045 print
'<td class="liste_titre">';
1049 if (!empty($arrayfields[
'p.statut'][
'checked'])) {
1050 print
'<td class="liste_titre center">';
1051 print
$form->selectarray(
'search_status', array(
'-1'=>
'',
'0'=>$langs->trans(
'ActivityCeased'),
'1'=>$langs->trans(
'InActivity')), $search_status, 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth75 onrightofpage');
1054 if (!empty($arrayfields[
'p.import_key'][
'checked'])) {
1055 print
'<td class="liste_titre center">';
1056 print
'<input class="flat searchstring" type="text" name="search_import_key" size="3" value="'.dol_escape_htmltag($search_import_key).
'">';
1060 if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
1061 print
'<td class="liste_titre maxwidthsearch">';
1062 $searchpicto =
$form->showFilterAndCheckAddButtons(0);
1069 print
'<tr class="liste_titre">';
1070 if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
1071 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
1073 if (!empty($arrayfields[
'p.rowid'][
'checked'])) {
1074 print_liste_field_titre($arrayfields[
'p.rowid'][
'label'], $_SERVER[
"PHP_SELF"],
"p.rowid",
"", $param,
"", $sortfield, $sortorder);
1076 if (!empty($arrayfields[
'p.lastname'][
'checked'])) {
1077 print_liste_field_titre($arrayfields[
'p.lastname'][
'label'], $_SERVER[
"PHP_SELF"],
"p.lastname", $begin, $param,
'', $sortfield, $sortorder);
1079 if (!empty($arrayfields[
'p.firstname'][
'checked'])) {
1080 print_liste_field_titre($arrayfields[
'p.firstname'][
'label'], $_SERVER[
"PHP_SELF"],
"p.firstname", $begin, $param,
'', $sortfield, $sortorder);
1082 if (!empty($arrayfields[
'p.poste'][
'checked'])) {
1083 print_liste_field_titre($arrayfields[
'p.poste'][
'label'], $_SERVER[
"PHP_SELF"],
"p.poste", $begin, $param,
'', $sortfield, $sortorder);
1085 if (!empty($arrayfields[
'p.address'][
'checked'])) {
1086 print_liste_field_titre($arrayfields[
'p.address'][
'label'], $_SERVER[
"PHP_SELF"],
"p.address", $begin, $param,
'', $sortfield, $sortorder);
1088 if (!empty($arrayfields[
'p.zip'][
'checked'])) {
1089 print_liste_field_titre($arrayfields[
'p.zip'][
'label'], $_SERVER[
"PHP_SELF"],
"p.zip", $begin, $param,
'', $sortfield, $sortorder);
1091 if (!empty($arrayfields[
'p.town'][
'checked'])) {
1092 print_liste_field_titre($arrayfields[
'p.town'][
'label'], $_SERVER[
"PHP_SELF"],
"p.town", $begin, $param,
'', $sortfield, $sortorder);
1096 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1097 print_liste_field_titre($arrayfields[
'country.code_iso'][
'label'], $_SERVER[
"PHP_SELF"],
"co.code_iso",
"", $param,
'', $sortfield, $sortorder,
'center ');
1099 if (!empty($arrayfields[
'p.phone'][
'checked'])) {
1100 print_liste_field_titre($arrayfields[
'p.phone'][
'label'], $_SERVER[
"PHP_SELF"],
"p.phone", $begin, $param,
'', $sortfield, $sortorder);
1102 if (!empty($arrayfields[
'p.phone_perso'][
'checked'])) {
1103 print_liste_field_titre($arrayfields[
'p.phone_perso'][
'label'], $_SERVER[
"PHP_SELF"],
"p.phone_perso", $begin, $param,
'', $sortfield, $sortorder);
1105 if (!empty($arrayfields[
'p.phone_mobile'][
'checked'])) {
1106 print_liste_field_titre($arrayfields[
'p.phone_mobile'][
'label'], $_SERVER[
"PHP_SELF"],
"p.phone_mobile", $begin, $param,
'', $sortfield, $sortorder);
1108 if (!empty($arrayfields[
'p.fax'][
'checked'])) {
1109 print_liste_field_titre($arrayfields[
'p.fax'][
'label'], $_SERVER[
"PHP_SELF"],
"p.fax", $begin, $param,
'', $sortfield, $sortorder);
1111 if (!empty($arrayfields[
'p.email'][
'checked'])) {
1112 print_liste_field_titre($arrayfields[
'p.email'][
'label'], $_SERVER[
"PHP_SELF"],
"p.email", $begin, $param,
'', $sortfield, $sortorder);
1114 if (!empty($arrayfields[
'unsubscribed'][
'checked'])) {
1115 print_liste_field_titre($arrayfields[
'unsubscribed'][
'label'], $_SERVER[
"PHP_SELF"],
"unsubscribed", $begin, $param,
'', $sortfield, $sortorder,
'center ');
1118 foreach ($socialnetworks as $key => $value) {
1119 if ($value[
'active'] && !empty($arrayfields[
'p.'.$key][
'checked'])) {
1120 print_liste_field_titre($arrayfields[
'p.'.$key][
'label'], $_SERVER[
"PHP_SELF"],
"p.".$key, $begin, $param,
'', $sortfield, $sortorder);
1124 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
1125 print_liste_field_titre($arrayfields[
'p.fk_soc'][
'label'], $_SERVER[
"PHP_SELF"],
"p.fk_soc", $begin, $param,
'', $sortfield, $sortorder);
1127 if (!empty($arrayfields[
's.nom'][
'checked'])) {
1128 print_liste_field_titre($arrayfields[
's.nom'][
'label'], $_SERVER[
"PHP_SELF"],
"s.nom", $begin, $param,
'', $sortfield, $sortorder);
1130 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1131 print_liste_field_titre($arrayfields[
's.name_alias'][
'label'], $_SERVER[
"PHP_SELF"],
"s.name_alias", $begin, $param,
'', $sortfield, $sortorder);
1133 if (!empty($arrayfields[
'p.priv'][
'checked'])) {
1134 print_liste_field_titre($arrayfields[
'p.priv'][
'label'], $_SERVER[
"PHP_SELF"],
"p.priv", $begin, $param,
'', $sortfield, $sortorder,
'center ');
1136 if (!empty($arrayfields[
'p.fk_prospectcontactlevel'][
'checked'])) {
1137 print_liste_field_titre($arrayfields[
'p.fk_prospectcontactlevel'][
'label'], $_SERVER[
"PHP_SELF"],
"p.fk_prospectcontactlevel",
"", $param,
'', $sortfield, $sortorder,
'center ');
1139 if (!empty($arrayfields[
'p.fk_stcommcontact'][
'checked'])) {
1140 print_liste_field_titre($arrayfields[
'p.fk_stcommcontact'][
'label'], $_SERVER[
"PHP_SELF"],
"p.fk_stcommcontact",
"", $param,
'', $sortfield, $sortorder,
'center ');
1143 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
1145 $parameters = array(
1146 'arrayfields'=>$arrayfields,
1148 'sortfield'=>$sortfield,
1149 'sortorder'=>$sortorder,
1151 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
1152 print $hookmanager->resPrint;
1153 if (!empty($arrayfields[
'p.datec'][
'checked'])) {
1154 print_liste_field_titre($arrayfields[
'p.datec'][
'label'], $_SERVER[
"PHP_SELF"],
"p.datec",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1156 if (!empty($arrayfields[
'p.tms'][
'checked'])) {
1157 print_liste_field_titre($arrayfields[
'p.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"p.tms",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1159 if (!empty($arrayfields[
'p.statut'][
'checked'])) {
1160 print_liste_field_titre($arrayfields[
'p.statut'][
'label'], $_SERVER[
"PHP_SELF"],
"p.statut",
"", $param,
'', $sortfield, $sortorder,
'center ');
1162 if (!empty($arrayfields[
'p.import_key'][
'checked'])) {
1163 print_liste_field_titre($arrayfields[
'p.import_key'][
'label'], $_SERVER[
"PHP_SELF"],
"p.import_key",
"", $param,
'', $sortfield, $sortorder,
'center ');
1165 if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
1166 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
1172 $totalarray = array();
1173 $totalarray[
'nbfield'] = 0;
1174 while ($i < min($num, $limit)) {
1175 $obj = $db->fetch_object(
$resql);
1177 $arraysocialnetworks = (array) json_decode($obj->socialnetworks,
true);
1178 $contactstatic->lastname = $obj->lastname;
1179 $contactstatic->firstname =
'';
1180 $contactstatic->id = $obj->rowid;
1181 $contactstatic->statut = $obj->statut;
1182 $contactstatic->poste = $obj->poste;
1183 $contactstatic->email = $obj->email;
1184 $contactstatic->phone_pro = $obj->phone_pro;
1185 $contactstatic->phone_perso = $obj->phone_perso;
1186 $contactstatic->phone_mobile = $obj->phone_mobile;
1187 $contactstatic->address = $obj->address;
1188 $contactstatic->zip = $obj->zip;
1189 $contactstatic->town = $obj->town;
1190 $contactstatic->socialnetworks = $arraysocialnetworks;
1191 $contactstatic->country = $obj->country;
1192 $contactstatic->country_code = $obj->country_code;
1193 $contactstatic->photo = $obj->photo;
1194 $contactstatic->import_key = $obj->import_key;
1196 $contactstatic->fk_prospectlevel = $obj->fk_prospectcontactlevel;
1198 print
'<tr class="oddeven">';
1201 if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
1202 print
'<td class="nowrap center">';
1203 if ($massactionbutton || $massaction) {
1205 if (in_array($obj->rowid, $arrayofselected)) {
1208 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1213 if (!empty($arrayfields[
'p.rowid'][
'checked'])) {
1214 print
'<td class="tdoverflowmax50">';
1218 $totalarray[
'nbfield']++;
1222 if (!empty($arrayfields[
'p.lastname'][
'checked'])) {
1223 print
'<td class="middle tdoverflowmax150">';
1224 print $contactstatic->getNomUrl(1);
1227 $totalarray[
'nbfield']++;
1231 if (!empty($arrayfields[
'p.firstname'][
'checked'])) {
1232 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($obj->firstname).
'">'.
dol_escape_htmltag($obj->firstname).
'</td>';
1234 $totalarray[
'nbfield']++;
1238 if (!empty($arrayfields[
'p.poste'][
'checked'])) {
1239 print
'<td class="tdoverflowmax100">'.dol_escape_htmltag($obj->poste).
'</td>';
1241 $totalarray[
'nbfield']++;
1245 if (!empty($arrayfields[
'p.address'][
'checked'])) {
1246 print
'<td>'.dol_escape_htmltag($obj->address).
'</td>';
1248 $totalarray[
'nbfield']++;
1252 if (!empty($arrayfields[
'p.zip'][
'checked'])) {
1253 print
'<td>'.dol_escape_htmltag($obj->zip).
'</td>';
1255 $totalarray[
'nbfield']++;
1259 if (!empty($arrayfields[
'p.town'][
'checked'])) {
1260 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->town).
'">'.
dol_escape_htmltag($obj->town).
'</td>';
1262 $totalarray[
'nbfield']++;
1278 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1279 print
'<td class="center">';
1280 $tmparray =
getCountry($obj->fk_pays,
'all');
1284 $totalarray[
'nbfield']++;
1288 if (!empty($arrayfields[
'p.phone'][
'checked'])) {
1289 print
'<td class="nowraponall tdoverflowmax150">'.dol_print_phone($obj->phone_pro, $obj->country_code, $obj->rowid, $obj->socid,
'AC_TEL',
' ',
'phone').
'</td>';
1291 $totalarray[
'nbfield']++;
1295 if (!empty($arrayfields[
'p.phone_perso'][
'checked'])) {
1296 print
'<td class="nowraponall tdoverflowmax150">'.dol_print_phone($obj->phone_perso, $obj->country_code, $obj->rowid, $obj->socid,
'AC_TEL',
' ',
'phone').
'</td>';
1298 $totalarray[
'nbfield']++;
1302 if (!empty($arrayfields[
'p.phone_mobile'][
'checked'])) {
1303 print
'<td class="nowraponall tdoverflowmax150">'.dol_print_phone($obj->phone_mobile, $obj->country_code, $obj->rowid, $obj->socid,
'AC_TEL',
' ',
'mobile').
'</td>';
1305 $totalarray[
'nbfield']++;
1309 if (!empty($arrayfields[
'p.fax'][
'checked'])) {
1310 print
'<td class="nowraponall tdoverflowmax150">'.dol_print_phone($obj->fax, $obj->country_code, $obj->rowid, $obj->socid,
'AC_TEL',
' ',
'fax').
'</td>';
1312 $totalarray[
'nbfield']++;
1316 if (!empty($arrayfields[
'p.email'][
'checked'])) {
1317 print
'<td class="nowraponall tdoverflowmax300">'.dol_print_email($obj->email, $obj->rowid, $obj->socid,
'AC_EMAIL', 18, 0, 1).
'</td>';
1319 $totalarray[
'nbfield']++;
1323 if (!empty($arrayfields[
'unsubscribed'][
'checked'])) {
1324 print
'<td class="center">';
1325 if (empty($obj->email)) {
1328 print
yn(($obj->unsubscribed > 0) ? 1 : 0);
1332 $totalarray[
'nbfield']++;
1336 foreach ($socialnetworks as $key => $value) {
1337 if ($value[
'active'] && !empty($arrayfields[
'p.'.$key][
'checked'])) {
1338 print
'<td class="tdoverflowmax100">'.(empty($arraysocialnetworks[$key]) ?
'' :
dol_print_socialnetworks($arraysocialnetworks[$key], $obj->rowid, $obj->socid, $key, $socialnetworks)).
'</td>';
1340 $totalarray[
'nbfield']++;
1346 if (!empty($arrayfields[
'p.fk_soc'][
'checked']) || !empty($arrayfields[
's.nom'][
'checked'])) {
1347 print
'<td class="tdoverflowmax200">';
1350 $objsoc->fetch($obj->socid);
1351 $option_link =
'customer';
1352 if ($objsoc->client == 0 && $objsoc->fournisseur > 0) {
1353 $option_link =
'supplier';
1355 print $objsoc->getNomUrl(1, $option_link, 100, 0, 1, empty($arrayfields[
's.name_alias'][
'checked']) ? 0 : 1);
1361 $totalarray[
'nbfield']++;
1366 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1367 print
'<td class="nocellnopadd">';
1371 $totalarray[
'nbfield']++;
1376 if (!empty($arrayfields[
'p.priv'][
'checked'])) {
1377 print
'<td class="center">'.$contactstatic->LibPubPriv($obj->priv).
'</td>';
1379 $totalarray[
'nbfield']++;
1383 if (!empty($arrayfields[
'p.fk_prospectcontactlevel'][
'checked'])) {
1385 print
'<td class="center">';
1386 print $contactstatic->getLibProspLevel();
1389 $totalarray[
'nbfield']++;
1393 if (!empty($arrayfields[
'p.fk_stcommcontact'][
'checked'])) {
1395 print
'<td class="center nowrap"><div class="nowrap">';
1396 print
'<div class="inline-block">'.$contactstatic->libProspCommStatut($obj->stcomm_id, 2, $contactstatic->cacheprospectstatus[$obj->stcomm_id][
'label'], $obj->stcomm_picto);
1397 print
'</div> - <div class="inline-block">';
1398 foreach ($contactstatic->cacheprospectstatus as $key => $val) {
1399 $titlealt =
'default';
1400 if (!empty($val[
'code']) && !in_array($val[
'code'], array(
'ST_NO',
'ST_NEVER',
'ST_TODO',
'ST_PEND',
'ST_DONE'))) {
1401 $titlealt = $val[
'label'];
1403 if ($obj->stcomm_id != $val[
'id']) {
1404 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>';
1407 print
'</div></div></td>';
1409 $totalarray[
'nbfield']++;
1414 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
1416 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$obj,
'i'=>$i,
'totalarray'=>&$totalarray);
1417 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
1418 print $hookmanager->resPrint;
1420 if (!empty($arrayfields[
'p.datec'][
'checked'])) {
1421 print
'<td class="center nowraponall">';
1422 print
dol_print_date($db->jdate($obj->date_creation),
'dayhour',
'tzuser');
1425 $totalarray[
'nbfield']++;
1429 if (!empty($arrayfields[
'p.tms'][
'checked'])) {
1430 print
'<td class="center nowraponall">';
1431 print
dol_print_date($db->jdate($obj->date_update),
'dayhour',
'tzuser');
1434 $totalarray[
'nbfield']++;
1438 if (!empty($arrayfields[
'p.statut'][
'checked'])) {
1439 print
'<td class="center">'.$contactstatic->getLibStatut(5).
'</td>';
1441 $totalarray[
'nbfield']++;
1445 if (!empty($arrayfields[
'p.import_key'][
'checked'])) {
1446 print
'<td class="tdoverflowmax100">';
1450 $totalarray[
'nbfield']++;
1455 if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
1456 print
'<td class="nowrap center">';
1457 if ($massactionbutton || $massaction) {
1459 if (in_array($obj->rowid, $arrayofselected)) {
1462 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1467 $totalarray[
'nbfield']++;
1475 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
1480 foreach ($arrayfields as $key => $val) {
1481 if (!empty($val[
'checked'])) {
1485 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
1490 $parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>$sql);
1491 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
1492 print $hookmanager->resPrint;
1494 print
'</table>'.
"\n";
1495 print
'</div>'.
"\n";
1497 print
'</form>'.
"\n";