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->rights->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);
356 if (!empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES)) {
357 $contactstatic->loadCacheOfProspStatus();
361 $tab_level = array();
362 $sql =
"SELECT code, label, sortorder";
363 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_prospectcontactlevel";
364 $sql .=
" WHERE active > 0";
365 $sql .=
" ORDER BY sortorder";
366 $resql = $db->query($sql);
368 while ($obj = $db->fetch_object(
$resql)) {
370 $level = $langs->trans($obj->code);
371 if ($level == $obj->code) {
372 $level = $langs->trans($obj->label);
374 $tab_level[$obj->code] = $level;
380 $sql =
"SELECT s.rowid as socid, s.nom as name, s.name_alias as alias,";
381 $sql .=
" p.rowid, p.lastname as lastname, p.statut, p.firstname, p.address, p.zip, p.town, p.poste, p.email,";
382 $sql .=
" p.socialnetworks, p.photo,";
383 $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,";
384 $sql .=
" p.import_key,";
385 $sql .=
" st.libelle as stcomm, st.picto as stcomm_picto, p.fk_stcommcontact as stcomm_id, p.fk_prospectlevel,";
386 $sql .=
" co.label as country, co.code as country_code";
388 if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
389 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
390 $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
394 $sql .=
", (SELECT count(*) FROM ".MAIN_DB_PREFIX.
"mailing_unsubscribe WHERE email = p.email) as unsubscribed";
397 $parameters = array();
398 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
399 $sql .= $hookmanager->resPrint;
403 $sql .=
" FROM ".MAIN_DB_PREFIX.
"socpeople as p";
404 if (isset($extrafields->attributes[$object->table_element][
'label']) && is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label'])) {
405 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (p.rowid = ef.fk_object)";
407 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as co ON co.rowid = p.fk_pays";
408 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid = p.fk_soc";
409 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_stcommcontact as st ON st.id = p.fk_stcommcontact";
410 if (empty($user->rights->societe->client->voir) && !$socid) {
411 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON s.rowid = sc.fk_soc";
413 $sql .=
' WHERE p.entity IN ('.getEntity(
'contact').
')';
414 if (empty($user->rights->societe->client->voir) && !$socid) {
415 $sql .=
" AND (sc.fk_user = ".((int) $user->id).
" OR p.fk_soc IS NULL)";
417 if (!empty($userid)) {
418 $sql .=
" AND p.fk_user_creat=".((int) $userid);
421 $sql .=
natural_search(
"p.fk_prospectlevel", join(
',', $search_level), 3);
423 if ($search_stcomm !=
'' && $search_stcomm != -2) {
428 if ($search_priv !=
'0' && $search_priv !=
'1') {
429 $sql .=
" AND (p.priv='0' OR (p.priv='1' AND p.fk_user_creat=".((int) $user->id).
"))";
431 if ($search_priv ==
'0') {
432 $sql .=
" AND p.priv='0'";
434 if ($search_priv ==
'1') {
435 $sql .=
" AND (p.priv='1' AND p.fk_user_creat=".((int) $user->id).
")";
439 $searchCategoryContactList = $search_categ ? array($search_categ) : array();
440 $searchCategoryContactOperator = 0;
442 if (!empty($searchCategoryContactList)) {
443 $searchCategoryContactSqlList = array();
444 $listofcategoryid =
'';
445 foreach ($searchCategoryContactList as $searchCategoryContact) {
446 if (intval($searchCategoryContact) == -2) {
447 $searchCategoryContactSqlList[] =
"NOT EXISTS (SELECT ck.fk_socpeople FROM ".MAIN_DB_PREFIX.
"categorie_contact as ck WHERE s.rowid = ck.fk_socpeople)";
448 } elseif (intval($searchCategoryContact) > 0) {
449 if ($searchCategoryContactOperator == 0) {
450 $searchCategoryContactSqlList[] =
" EXISTS (SELECT ck.fk_socpeople FROM ".MAIN_DB_PREFIX.
"categorie_contact as ck WHERE s.rowid = ck.fk_socpeople AND ck.fk_categorie = ".((int) $searchCategoryContact).
")";
452 $listofcategoryid .= ($listofcategoryid ?
', ' :
'') .((
int) $searchCategoryContact);
456 if ($listofcategoryid) {
457 $searchCategoryContactSqlList[] =
" EXISTS (SELECT ck.fk_socpeople FROM ".MAIN_DB_PREFIX.
"categorie_contact as ck WHERE s.rowid = ck.fk_socpeople AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid).
"))";
459 if ($searchCategoryContactOperator == 1) {
460 if (!empty($searchCategoryContactSqlList)) {
461 $sql .=
" AND (".implode(
' OR ', $searchCategoryContactSqlList).
")";
464 if (!empty($searchCategoryContactSqlList)) {
465 $sql .=
" AND (".implode(
' AND ', $searchCategoryContactSqlList).
")";
469 $searchCategoryCustomerList = $search_categ_thirdparty ? array($search_categ_thirdparty) : array();
470 $searchCategoryCustomerOperator = 0;
472 if (!empty($searchCategoryCustomerList)) {
473 $searchCategoryCustomerSqlList = array();
474 $listofcategoryid =
'';
475 foreach ($searchCategoryCustomerList as $searchCategoryCustomer) {
476 if (intval($searchCategoryCustomer) == -2) {
477 $searchCategoryCustomerSqlList[] =
"NOT EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX.
"categorie_societe as ck WHERE s.rowid = ck.fk_soc)";
478 } elseif (intval($searchCategoryCustomer) > 0) {
479 if ($searchCategoryCustomerOperator == 0) {
480 $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).
")";
482 $listofcategoryid .= ($listofcategoryid ?
', ' :
'') .((
int) $searchCategoryCustomer);
486 if ($listofcategoryid) {
487 $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).
"))";
489 if ($searchCategoryCustomerOperator == 1) {
490 if (!empty($searchCategoryCustomerSqlList)) {
491 $sql .=
" AND (".implode(
' OR ', $searchCategoryCustomerSqlList).
")";
494 if (!empty($searchCategoryCustomerSqlList)) {
495 $sql .=
" AND (".implode(
' AND ', $searchCategoryCustomerSqlList).
")";
499 $searchCategorySupplierList = $search_categ_supplier ? array($search_categ_supplier) : array();
500 $searchCategorySupplierOperator = 0;
502 if (!empty($searchCategorySupplierList)) {
503 $searchCategorySupplierSqlList = array();
504 $listofcategoryid =
'';
505 foreach ($searchCategorySupplierList as $searchCategorySupplier) {
506 if (intval($searchCategorySupplier) == -2) {
507 $searchCategorySupplierSqlList[] =
"NOT EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX.
"categorie_fournisseur as ck WHERE s.rowid = ck.fk_soc)";
508 } elseif (intval($searchCategorySupplier) > 0) {
509 if ($searchCategorySupplierOperator == 0) {
510 $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).
")";
512 $listofcategoryid .= ($listofcategoryid ?
', ' :
'') .((
int) $searchCategorySupplier);
516 if ($listofcategoryid) {
517 $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).
"))";
519 if ($searchCategorySupplierOperator == 1) {
520 if (!empty($searchCategorySupplierSqlList)) {
521 $sql .=
" AND (".implode(
' OR ', $searchCategorySupplierSqlList).
")";
524 if (!empty($searchCategorySupplierSqlList)) {
525 $sql .=
" AND (".implode(
' AND ', $searchCategorySupplierSqlList).
")";
533 if (strlen($search_phone)) {
534 $sql .=
natural_search(array(
'p.phone',
'p.phone_perso',
'p.phone_mobile'), $search_phone);
536 if (strlen($search_cti)) {
537 $sql .=
natural_search(array(
'p.phone',
'p.phone_perso',
'p.phone_mobile'), $search_cti);
539 if (strlen($search_firstlast_only)) {
540 $sql .=
natural_search(array(
'p.lastname',
'p.firstname'), $search_firstlast_only);
543 if ($search_id > 0) {
546 if ($search_lastname) {
549 if ($search_firstname) {
552 if (empty($arrayfields[
's.name_alias'][
'checked']) && $search_societe) {
553 $sql .=
natural_search(array(
"s.nom",
"s.name_alias"), $search_societe);
555 if ($search_societe) {
558 if ($search_societe_alias) {
562 if ($search_country) {
563 $sql .=
" AND p.fk_pays IN (".$db->sanitize($search_country).
')';
565 if (strlen($search_poste)) {
568 if (strlen($search_phone_perso)) {
571 if (strlen($search_phone_pro)) {
574 if (strlen($search_phone_mobile)) {
577 if (strlen($search_fax)) {
581 foreach ($socialnetworks as $key => $value) {
582 if ($value[
'active'] && strlen($search_[$key])) {
583 $searchkeyinjsonformat = preg_replace(
'/"$/',
'', preg_replace(
'/^"/',
'', json_encode($search_[$key])));
584 if (in_array($db->type, array(
'mysql',
'mysqli'))) {
585 $sql .=
" AND p.socialnetworks REGEXP '\"".$db->escape($db->escapeforlike($key)).
"\":\"[^\"]*".$db->escape($db->escapeforlike($searchkeyinjsonformat)).
"'";
586 } elseif ($db->type ==
'pgsql') {
587 $sql .=
" AND p.socialnetworks ~ '\"".$db->escape($db->escapeforlike($key)).
"\":\"[^\"]*".$db->escape($db->escapeforlike($searchkeyinjsonformat)).
"'";
590 $sql .=
" AND p.socialnetworks LIKE '%\"".$db->escape($db->escapeforlike($key)).
"\":\"".$db->escape($db->escapeforlike($searchkeyinjsonformat)).
"%'";
596 if (strlen($search_email)) {
599 if (strlen($search_address)) {
602 if (strlen($search_zip)) {
605 if (strlen($search_town)) {
608 if (count($search_roles) > 0) {
609 $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)).
"))";
611 if ($search_no_email != -1 && $search_no_email > 0) {
612 $sql .=
" AND (SELECT count(*) FROM ".MAIN_DB_PREFIX.
"mailing_unsubscribe WHERE email = p.email) > 0";
614 if ($search_no_email != -1 && $search_no_email == 0) {
615 $sql .=
" AND (SELECT count(*) FROM ".MAIN_DB_PREFIX.
"mailing_unsubscribe WHERE email = p.email) = 0 AND p.email IS NOT NULL AND p.email <> ''";
617 if ($search_status !=
'' && $search_status >= 0) {
618 $sql .=
" AND p.statut = ".((int) $search_status);
620 if ($search_import_key) {
624 $sql .=
" AND p.fk_soc IS NULL";
625 } elseif ($type ==
"f") {
626 $sql .=
" AND s.fournisseur = 1";
627 } elseif ($type ==
"c") {
628 $sql .=
" AND s.client IN (1, 3)";
629 } elseif ($type ==
"p") {
630 $sql .=
" AND s.client IN (2, 3)";
632 if (!empty($socid)) {
633 $sql .=
" AND s.rowid = ".((int) $socid);
636 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
638 $parameters = array();
639 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
640 $sql .= $hookmanager->resPrint;
645 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
647 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
648 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
649 $resql = $db->query($sqlforcount);
651 $objforcount = $db->fetch_object(
$resql);
665 if ($view ==
"recent") {
666 $sql .= $db->order(
"p.datec",
"DESC");
668 $sql .= $db->order($sortfield, $sortorder);
671 $sql .= $db->plimit($limit + 1, $offset);
674 $resql = $db->query($sql);
680 $num = $db->num_rows(
$resql);
682 $arrayofselected = is_array($toselect) ? $toselect : array();
684 if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && ($sall !=
'' || $search_cti !=
'')) {
685 $obj = $db->fetch_object(
$resql);
687 header(
"Location: ".DOL_URL_ROOT.
'/contact/card.php?id='.$id);
691 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
692 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
694 $help_url =
'EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Empresas';
699 $param .=
'&mode='.urlencode($mode);
701 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
702 $param .=
'&contextpage='.urlencode($contextpage);
704 if ($limit > 0 && $limit != $conf->liste_limit) {
705 $param .=
'&limit='.((int) $limit);
707 $param .=
'&begin='.urlencode($begin).
'&userid='.urlencode($userid).
'&contactname='.urlencode($sall);
708 $param .=
'&type='.urlencode($type).
'&view='.urlencode($view);
709 if (!empty($search_categ) && $search_categ !=
'-1') {
710 $param .=
'&search_categ='.urlencode($search_categ);
712 if (!empty($search_categ_thirdparty) && $search_categ_thirdparty !=
'-1') {
713 $param .=
'&search_categ_thirdparty='.urlencode($search_categ_thirdparty);
715 if (!empty($search_categ_supplier) && $search_categ_supplier !=
'-1') {
716 $param .=
'&search_categ_supplier='.urlencode($search_categ_supplier);
719 $param .=
'&sall='.urlencode($sall);
721 if ($search_id > 0) {
722 $param .=
"&search_id=".urlencode($search_id);
724 if ($search_lastname !=
'') {
725 $param .=
'&search_lastname='.urlencode($search_lastname);
727 if ($search_firstname !=
'') {
728 $param .=
'&search_firstname='.urlencode($search_firstname);
730 if ($search_societe !=
'') {
731 $param .=
'&search_societe='.urlencode($search_societe);
733 if ($search_societe_alias !=
'') {
734 $param .=
'&search_societe_alias='.urlencode($search_societe_alias);
736 if ($search_address !=
'') {
737 $param .=
'&search_address='.urlencode($search_address);
739 if ($search_zip !=
'') {
740 $param .=
'&search_zip='.urlencode($search_zip);
742 if ($search_town !=
'') {
743 $param .=
'&search_town='.urlencode($search_town);
745 if ($search_country !=
'') {
746 $param .=
"&search_country=".urlencode($search_country);
748 if ($search_poste !=
'') {
749 $param .=
'&search_poste='.urlencode($search_poste);
751 if ($search_phone_pro !=
'') {
752 $param .=
'&search_phone_pro='.urlencode($search_phone_pro);
754 if ($search_phone_perso !=
'') {
755 $param .=
'&search_phone_perso='.urlencode($search_phone_perso);
757 if ($search_phone_mobile !=
'') {
758 $param .=
'&search_phone_mobile='.urlencode($search_phone_mobile);
760 if ($search_fax !=
'') {
761 $param .=
'&search_fax='.urlencode($search_fax);
763 if ($search_email !=
'') {
764 $param .=
'&search_email='.urlencode($search_email);
766 if ($search_no_email !=
'') {
767 $param .=
'&search_no_email='.urlencode($search_no_email);
769 if ($search_status !=
'') {
770 $param .=
'&search_status='.urlencode($search_status);
772 if ($search_priv ==
'0' || $search_priv ==
'1') {
773 $param .=
"&search_priv=".urlencode($search_priv);
775 if ($search_stcomm !=
'') {
776 $param .=
'&search_stcomm='.urlencode($search_stcomm);
778 if (is_array($search_level) && count($search_level)) {
779 foreach ($search_level as $slevel) {
780 $param .=
'&search_level[]='.urlencode($slevel);
783 if ($search_import_key !=
'') {
784 $param .=
'&search_import_key='.urlencode($search_import_key);
786 if ($optioncss !=
'') {
787 $param .=
'&optioncss='.urlencode($optioncss);
789 if (count($search_roles) > 0) {
790 $param .= implode(
'&search_roles[]=', $search_roles);
794 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
797 $arrayofmassactions = array(
798 'presend' =>
img_picto(
'',
'email',
'class="pictofixedwidth"').$langs->trans(
"SendByMail"),
802 if ($user->hasRight(
'societe',
'supprimer')) {
803 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
805 if (
isModEnabled(
'category') && $user->rights->societe->creer) {
806 $arrayofmassactions[
'preaffecttag'] =
img_picto(
'',
'category',
'class="pictofixedwidth"').$langs->trans(
"AffectTag");
808 if (in_array($massaction, array(
'presend',
'predelete',
'preaffecttag'))) {
809 $arrayofmassactions = array();
811 $massactionbutton =
$form->selectMassAction(
'', $arrayofmassactions);
814 $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'));
815 $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'));
816 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewContactAddress'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/contact/card.php?action=create',
'', $user->rights->societe->contact->creer);
818 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'" name="formfilter">';
819 if ($optioncss !=
'') {
820 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
822 print
'<input type="hidden" name="token" value="'.newToken().
'">';
823 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
824 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
825 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
827 print
'<input type="hidden" name="type" value="'.$type.
'">';
828 print
'<input type="hidden" name="view" value="'.dol_escape_htmltag($view).
'">';
829 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
832 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num,
$nbtotalofrecords,
'address', 0, $newcardbutton,
'', $limit, 0, 0, 1);
834 $topicmail =
"Information";
835 $modelmail =
"contact";
837 $trackid =
'ctc'.$object->id;
838 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
841 foreach ($fieldstosearchall as $key => $val) {
842 $fieldstosearchall[$key] = $langs->trans($val);
844 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $sall).join(
', ', $fieldstosearchall).
'</div>';
846 if ($search_firstlast_only) {
847 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_firstlast_only).$langs->trans(
"Lastname").
", ".$langs->trans(
"Firstname").
'</div>';
851 if (
isModEnabled(
'categorie') && $user->rights->categorie->lire) {
852 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
853 $moreforfilter .=
'<div class="divsearchfield">';
854 $tmptitle = $langs->trans(
'ContactCategoriesShort');
855 $moreforfilter .=
img_picto($tmptitle,
'category',
'class="pictofixedwidth"');
856 $moreforfilter .= $formother->select_categories(Categorie::TYPE_CONTACT, $search_categ,
'search_categ', 1, $tmptitle);
857 $moreforfilter .=
'</div>';
858 if (empty($type) || $type ==
'c' || $type ==
'p') {
859 $moreforfilter .=
'<div class="divsearchfield">';
862 $tmptitle .= $langs->trans(
'CustomersCategoriesShort');
863 } elseif ($type ==
'p') {
864 $tmptitle .= $langs->trans(
'ProspectsCategoriesShort');
866 $tmptitle .= $langs->trans(
'CustomersProspectsCategoriesShort');
868 $moreforfilter .=
img_picto($tmptitle,
'category',
'class="pictofixedwidth"');
869 $moreforfilter .= $formother->select_categories(Categorie::TYPE_CUSTOMER, $search_categ_thirdparty,
'search_categ_thirdparty', 1, $tmptitle);
870 $moreforfilter .=
'</div>';
873 if (
isModEnabled(
"fournisseur") && (empty($type) || $type ==
'f')) {
874 $moreforfilter .=
'<div class="divsearchfield">';
875 $tmptitle = $langs->trans(
'SuppliersCategoriesShort');
876 $moreforfilter .=
img_picto($tmptitle,
'category',
'class="pictofixedwidth"');
877 $moreforfilter .= $formother->select_categories(Categorie::TYPE_SUPPLIER, $search_categ_supplier,
'search_categ_supplier', 1, $tmptitle);
878 $moreforfilter .=
'</div>';
882 $moreforfilter .=
'<div class="divsearchfield">';
883 $moreforfilter .= $langs->trans(
'Roles').
': ';
884 $moreforfilter .= $formcompany->showRoles(
"search_roles", $objecttmp,
'edit', $search_roles);
885 $moreforfilter .=
'</div>';
887 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
888 print $moreforfilter;
889 $parameters = array(
'type'=>$type);
890 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
891 print $hookmanager->resPrint;
894 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
895 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN',
''));
896 if ($massactionbutton) {
897 $selectedfields .=
$form->showCheckAddButtons(
'checkforselect', 1);
900 print
'<div class="div-table-responsive">';
901 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
904 print
'<tr class="liste_titre_filter">';
906 if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
907 print
'<td class="liste_titre maxwidthsearch">';
908 $searchpicto =
$form->showFilterButtons(
'left');
912 if (!empty($arrayfields[
'p.rowid'][
'checked'])) {
913 print
'<td class="liste_titre">';
914 print
'<input class="flat searchstring" type="text" name="search_id" size="1" value="'.dol_escape_htmltag($search_id).
'">';
917 if (!empty($arrayfields[
'p.lastname'][
'checked'])) {
918 print
'<td class="liste_titre">';
919 print
'<input class="flat" type="text" name="search_lastname" size="6" value="'.dol_escape_htmltag($search_lastname).
'">';
922 if (!empty($arrayfields[
'p.firstname'][
'checked'])) {
923 print
'<td class="liste_titre">';
924 print
'<input class="flat" type="text" name="search_firstname" size="6" value="'.dol_escape_htmltag($search_firstname).
'">';
927 if (!empty($arrayfields[
'p.poste'][
'checked'])) {
928 print
'<td class="liste_titre">';
929 print
'<input class="flat" type="text" name="search_poste" size="5" value="'.dol_escape_htmltag($search_poste).
'">';
932 if (!empty($arrayfields[
'p.address'][
'checked'])) {
933 print
'<td class="liste_titre">';
934 print
'<input class="flat" type="text" name="search_address" size="6" value="'.dol_escape_htmltag($search_address).
'">';
937 if (!empty($arrayfields[
'p.zip'][
'checked'])) {
938 print
'<td class="liste_titre">';
939 print
'<input class="flat" type="text" name="search_zip" size="3" value="'.dol_escape_htmltag($search_zip).
'">';
942 if (!empty($arrayfields[
'p.town'][
'checked'])) {
943 print
'<td class="liste_titre">';
944 print
'<input class="flat" type="text" name="search_town" size="5" value="'.dol_escape_htmltag($search_town).
'">';
962 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
963 print
'<td class="liste_titre center">';
964 print
$form->select_country($search_country,
'search_country',
'', 0,
'minwidth100imp maxwidth100');
967 if (!empty($arrayfields[
'p.phone'][
'checked'])) {
968 print
'<td class="liste_titre">';
969 print
'<input class="flat" type="text" name="search_phone_pro" size="6" value="'.dol_escape_htmltag($search_phone_pro).
'">';
972 if (!empty($arrayfields[
'p.phone_perso'][
'checked'])) {
973 print
'<td class="liste_titre">';
974 print
'<input class="flat" type="text" name="search_phone_perso" size="6" value="'.dol_escape_htmltag($search_phone_perso).
'">';
977 if (!empty($arrayfields[
'p.phone_mobile'][
'checked'])) {
978 print
'<td class="liste_titre">';
979 print
'<input class="flat" type="text" name="search_phone_mobile" size="6" value="'.dol_escape_htmltag($search_phone_mobile).
'">';
982 if (!empty($arrayfields[
'p.fax'][
'checked'])) {
983 print
'<td class="liste_titre">';
984 print
'<input class="flat" type="text" name="search_fax" size="6" value="'.dol_escape_htmltag($search_fax).
'">';
987 if (!empty($arrayfields[
'p.email'][
'checked'])) {
988 print
'<td class="liste_titre">';
989 print
'<input class="flat" type="text" name="search_email" size="6" value="'.dol_escape_htmltag($search_email).
'">';
992 if (!empty($arrayfields[
'unsubscribed'][
'checked'])) {
993 print
'<td class="liste_titre center">';
994 print
$form->selectarray(
'search_no_email', array(
'-1'=>
'',
'0'=>$langs->trans(
'No'),
'1'=>$langs->trans(
'Yes')), $search_no_email);
998 foreach ($socialnetworks as $key => $value) {
999 if ($value[
'active']) {
1000 if (!empty($arrayfields[
'p.'.$key][
'checked'])) {
1001 print
'<td class="liste_titre">';
1002 print
'<input class="flat" type="text" name="search_'.$key.
'" size="6" value="'.
dol_escape_htmltag($search_[$key]).
'">';
1008 if (!empty($arrayfields[
'p.fk_soc'][
'checked']) || !empty($arrayfields[
's.nom'][
'checked'])) {
1009 print
'<td class="liste_titre">';
1010 print
'<input class="flat" type="text" name="search_societe" size="8" value="'.dol_escape_htmltag($search_societe).
'">';
1014 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1015 print
'<td class="liste_titre" align="left">';
1016 print
'<input class="flat maxwidth100" type="text" name="search_societe_alias" value="'.dol_escape_htmltag($search_societe_alias).
'">';
1019 if (!empty($arrayfields[
'p.priv'][
'checked'])) {
1020 print
'<td class="liste_titre center">';
1021 $selectarray = array(
'0'=>$langs->trans(
"ContactPublic"),
'1'=>$langs->trans(
"ContactPrivate"));
1022 print
$form->selectarray(
'search_priv', $selectarray, $search_priv, 1);
1026 if (!empty($arrayfields[
'p.fk_prospectlevel'][
'checked'])) {
1027 print
'<td class="liste_titre center">';
1028 print
$form->multiselectarray(
'search_level', $tab_level, $search_level, 0, 0,
'width75', 0, 0,
'',
'',
'', 2);
1032 if (!empty($arrayfields[
'p.fk_stcommcontact'][
'checked'])) {
1033 print
'<td class="liste_titre maxwidthonsmartphone center">';
1034 $arraystcomm = array();
1035 foreach ($contactstatic->cacheprospectstatus as $key => $val) {
1036 $arraystcomm[$val[
'id']] = ($langs->trans(
"StatusProspect".$val[
'id']) !=
"StatusProspect".$val[
'id'] ? $langs->trans(
"StatusProspect".$val[
'id']) : $val[
'label']);
1038 print
$form->selectarray(
'search_stcomm', $arraystcomm, $search_stcomm, -2, 0, 0,
'', 0, 0, 0,
'',
'nowrap ');
1042 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
1045 $parameters = array(
'arrayfields'=>$arrayfields);
1046 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
1047 print $hookmanager->resPrint;
1049 if (!empty($arrayfields[
'p.datec'][
'checked'])) {
1050 print
'<td class="liste_titre">';
1054 if (!empty($arrayfields[
'p.tms'][
'checked'])) {
1055 print
'<td class="liste_titre">';
1059 if (!empty($arrayfields[
'p.statut'][
'checked'])) {
1060 print
'<td class="liste_titre center">';
1061 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');
1064 if (!empty($arrayfields[
'p.import_key'][
'checked'])) {
1065 print
'<td class="liste_titre center">';
1066 print
'<input class="flat searchstring" type="text" name="search_import_key" size="3" value="'.dol_escape_htmltag($search_import_key).
'">';
1070 if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
1071 print
'<td class="liste_titre maxwidthsearch">';
1072 $searchpicto =
$form->showFilterAndCheckAddButtons(0);
1079 print
'<tr class="liste_titre">';
1080 if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
1081 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
1083 if (!empty($arrayfields[
'p.rowid'][
'checked'])) {
1084 print_liste_field_titre($arrayfields[
'p.rowid'][
'label'], $_SERVER[
"PHP_SELF"],
"p.rowid",
"", $param,
"", $sortfield, $sortorder);
1086 if (!empty($arrayfields[
'p.lastname'][
'checked'])) {
1087 print_liste_field_titre($arrayfields[
'p.lastname'][
'label'], $_SERVER[
"PHP_SELF"],
"p.lastname", $begin, $param,
'', $sortfield, $sortorder);
1089 if (!empty($arrayfields[
'p.firstname'][
'checked'])) {
1090 print_liste_field_titre($arrayfields[
'p.firstname'][
'label'], $_SERVER[
"PHP_SELF"],
"p.firstname", $begin, $param,
'', $sortfield, $sortorder);
1092 if (!empty($arrayfields[
'p.poste'][
'checked'])) {
1093 print_liste_field_titre($arrayfields[
'p.poste'][
'label'], $_SERVER[
"PHP_SELF"],
"p.poste", $begin, $param,
'', $sortfield, $sortorder);
1095 if (!empty($arrayfields[
'p.address'][
'checked'])) {
1096 print_liste_field_titre($arrayfields[
'p.address'][
'label'], $_SERVER[
"PHP_SELF"],
"p.address", $begin, $param,
'', $sortfield, $sortorder);
1098 if (!empty($arrayfields[
'p.zip'][
'checked'])) {
1099 print_liste_field_titre($arrayfields[
'p.zip'][
'label'], $_SERVER[
"PHP_SELF"],
"p.zip", $begin, $param,
'', $sortfield, $sortorder);
1101 if (!empty($arrayfields[
'p.town'][
'checked'])) {
1102 print_liste_field_titre($arrayfields[
'p.town'][
'label'], $_SERVER[
"PHP_SELF"],
"p.town", $begin, $param,
'', $sortfield, $sortorder);
1106 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1107 print_liste_field_titre($arrayfields[
'country.code_iso'][
'label'], $_SERVER[
"PHP_SELF"],
"co.code_iso",
"", $param,
'', $sortfield, $sortorder,
'center ');
1109 if (!empty($arrayfields[
'p.phone'][
'checked'])) {
1110 print_liste_field_titre($arrayfields[
'p.phone'][
'label'], $_SERVER[
"PHP_SELF"],
"p.phone", $begin, $param,
'', $sortfield, $sortorder);
1112 if (!empty($arrayfields[
'p.phone_perso'][
'checked'])) {
1113 print_liste_field_titre($arrayfields[
'p.phone_perso'][
'label'], $_SERVER[
"PHP_SELF"],
"p.phone_perso", $begin, $param,
'', $sortfield, $sortorder);
1115 if (!empty($arrayfields[
'p.phone_mobile'][
'checked'])) {
1116 print_liste_field_titre($arrayfields[
'p.phone_mobile'][
'label'], $_SERVER[
"PHP_SELF"],
"p.phone_mobile", $begin, $param,
'', $sortfield, $sortorder);
1118 if (!empty($arrayfields[
'p.fax'][
'checked'])) {
1119 print_liste_field_titre($arrayfields[
'p.fax'][
'label'], $_SERVER[
"PHP_SELF"],
"p.fax", $begin, $param,
'', $sortfield, $sortorder);
1121 if (!empty($arrayfields[
'p.email'][
'checked'])) {
1122 print_liste_field_titre($arrayfields[
'p.email'][
'label'], $_SERVER[
"PHP_SELF"],
"p.email", $begin, $param,
'', $sortfield, $sortorder);
1124 if (!empty($arrayfields[
'unsubscribed'][
'checked'])) {
1125 print_liste_field_titre($arrayfields[
'unsubscribed'][
'label'], $_SERVER[
"PHP_SELF"],
"unsubscribed", $begin, $param,
'', $sortfield, $sortorder,
'center ');
1128 foreach ($socialnetworks as $key => $value) {
1129 if ($value[
'active'] && !empty($arrayfields[
'p.'.$key][
'checked'])) {
1130 print_liste_field_titre($arrayfields[
'p.'.$key][
'label'], $_SERVER[
"PHP_SELF"],
"p.".$key, $begin, $param,
'', $sortfield, $sortorder);
1134 if (!empty($arrayfields[
'p.fk_soc'][
'checked'])) {
1135 print_liste_field_titre($arrayfields[
'p.fk_soc'][
'label'], $_SERVER[
"PHP_SELF"],
"p.fk_soc", $begin, $param,
'', $sortfield, $sortorder);
1137 if (!empty($arrayfields[
's.nom'][
'checked'])) {
1138 print_liste_field_titre($arrayfields[
's.nom'][
'label'], $_SERVER[
"PHP_SELF"],
"s.nom", $begin, $param,
'', $sortfield, $sortorder);
1140 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1141 print_liste_field_titre($arrayfields[
's.name_alias'][
'label'], $_SERVER[
"PHP_SELF"],
"s.name_alias", $begin, $param,
'', $sortfield, $sortorder);
1143 if (!empty($arrayfields[
'p.priv'][
'checked'])) {
1144 print_liste_field_titre($arrayfields[
'p.priv'][
'label'], $_SERVER[
"PHP_SELF"],
"p.priv", $begin, $param,
'', $sortfield, $sortorder,
'center ');
1146 if (!empty($arrayfields[
'p.fk_prospectlevel'][
'checked'])) {
1147 print_liste_field_titre($arrayfields[
'p.fk_prospectlevel'][
'label'], $_SERVER[
"PHP_SELF"],
"p.fk_prospectlevel",
"", $param,
'', $sortfield, $sortorder,
'center ');
1149 if (!empty($arrayfields[
'p.fk_stcommcontact'][
'checked'])) {
1150 print_liste_field_titre($arrayfields[
'p.fk_stcommcontact'][
'label'], $_SERVER[
"PHP_SELF"],
"p.fk_stcommcontact",
"", $param,
'', $sortfield, $sortorder,
'center ');
1153 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
1155 $parameters = array(
1156 'arrayfields'=>$arrayfields,
1158 'sortfield'=>$sortfield,
1159 'sortorder'=>$sortorder,
1161 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
1162 print $hookmanager->resPrint;
1163 if (!empty($arrayfields[
'p.datec'][
'checked'])) {
1164 print_liste_field_titre($arrayfields[
'p.datec'][
'label'], $_SERVER[
"PHP_SELF"],
"p.datec",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1166 if (!empty($arrayfields[
'p.tms'][
'checked'])) {
1167 print_liste_field_titre($arrayfields[
'p.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"p.tms",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1169 if (!empty($arrayfields[
'p.statut'][
'checked'])) {
1170 print_liste_field_titre($arrayfields[
'p.statut'][
'label'], $_SERVER[
"PHP_SELF"],
"p.statut",
"", $param,
'', $sortfield, $sortorder,
'center ');
1172 if (!empty($arrayfields[
'p.import_key'][
'checked'])) {
1173 print_liste_field_titre($arrayfields[
'p.import_key'][
'label'], $_SERVER[
"PHP_SELF"],
"p.import_key",
"", $param,
'', $sortfield, $sortorder,
'center ');
1175 if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
1176 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
1182 $totalarray = array();
1183 $totalarray[
'nbfield'] = 0;
1184 while ($i < min($num, $limit)) {
1185 $obj = $db->fetch_object(
$resql);
1187 $arraysocialnetworks = (array) json_decode($obj->socialnetworks,
true);
1188 $contactstatic->lastname = $obj->lastname;
1189 $contactstatic->firstname =
'';
1190 $contactstatic->id = $obj->rowid;
1191 $contactstatic->statut = $obj->statut;
1192 $contactstatic->poste = $obj->poste;
1193 $contactstatic->email = $obj->email;
1194 $contactstatic->phone_pro = $obj->phone_pro;
1195 $contactstatic->phone_perso = $obj->phone_perso;
1196 $contactstatic->phone_mobile = $obj->phone_mobile;
1197 $contactstatic->address = $obj->address;
1198 $contactstatic->zip = $obj->zip;
1199 $contactstatic->town = $obj->town;
1200 $contactstatic->socialnetworks = $arraysocialnetworks;
1201 $contactstatic->country = $obj->country;
1202 $contactstatic->country_code = $obj->country_code;
1203 $contactstatic->photo = $obj->photo;
1204 $contactstatic->import_key = $obj->import_key;
1206 $contactstatic->fk_prospectlevel = $obj->fk_prospectlevel;
1208 if ($mode ==
'kanban') {
1210 print
'<tr><td colspan="12">';
1211 print
'<div class="box-flex-container">';
1213 $contactstatic->photo = $obj->photo;
1214 if ($obj->socid > 0) {
1215 $contactstatic->fetch_thirdparty($obj->socid);
1217 print $contactstatic->getKanbanView(
'');
1218 if ($i == min($num, $limit) - 1) {
1223 print
'<tr class="oddeven" id="rowid-'.((int) $obj->rowid).
'">';
1226 if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
1227 print
'<td class="nowrap center">';
1228 if ($massactionbutton || $massaction) {
1230 if (in_array($obj->rowid, $arrayofselected)) {
1233 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1238 if (!empty($arrayfields[
'p.rowid'][
'checked'])) {
1239 print
'<td class="tdoverflowmax50">';
1243 $totalarray[
'nbfield']++;
1247 if (!empty($arrayfields[
'p.lastname'][
'checked'])) {
1248 print
'<td class="middle tdoverflowmax150">';
1249 print $contactstatic->getNomUrl(1);
1252 $totalarray[
'nbfield']++;
1256 if (!empty($arrayfields[
'p.firstname'][
'checked'])) {
1257 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($obj->firstname).
'">'.
dol_escape_htmltag($obj->firstname).
'</td>';
1259 $totalarray[
'nbfield']++;
1263 if (!empty($arrayfields[
'p.poste'][
'checked'])) {
1264 print
'<td class="tdoverflowmax100">'.dol_escape_htmltag($obj->poste).
'</td>';
1266 $totalarray[
'nbfield']++;
1270 if (!empty($arrayfields[
'p.address'][
'checked'])) {
1271 print
'<td>'.dol_escape_htmltag($obj->address).
'</td>';
1273 $totalarray[
'nbfield']++;
1277 if (!empty($arrayfields[
'p.zip'][
'checked'])) {
1278 print
'<td>'.dol_escape_htmltag($obj->zip).
'</td>';
1280 $totalarray[
'nbfield']++;
1284 if (!empty($arrayfields[
'p.town'][
'checked'])) {
1285 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->town).
'">'.
dol_escape_htmltag($obj->town).
'</td>';
1287 $totalarray[
'nbfield']++;
1303 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1304 print
'<td class="center">';
1305 $tmparray =
getCountry($obj->fk_pays,
'all');
1309 $totalarray[
'nbfield']++;
1313 if (!empty($arrayfields[
'p.phone'][
'checked'])) {
1314 print
'<td class="nowraponall tdoverflowmax150">'.dol_print_phone($obj->phone_pro, $obj->country_code, $obj->rowid, $obj->socid,
'AC_TEL',
' ',
'phone').
'</td>';
1316 $totalarray[
'nbfield']++;
1320 if (!empty($arrayfields[
'p.phone_perso'][
'checked'])) {
1321 print
'<td class="nowraponall tdoverflowmax150">'.dol_print_phone($obj->phone_perso, $obj->country_code, $obj->rowid, $obj->socid,
'AC_TEL',
' ',
'phone').
'</td>';
1323 $totalarray[
'nbfield']++;
1327 if (!empty($arrayfields[
'p.phone_mobile'][
'checked'])) {
1328 print
'<td class="nowraponall tdoverflowmax150">'.dol_print_phone($obj->phone_mobile, $obj->country_code, $obj->rowid, $obj->socid,
'AC_TEL',
' ',
'mobile').
'</td>';
1330 $totalarray[
'nbfield']++;
1334 if (!empty($arrayfields[
'p.fax'][
'checked'])) {
1335 print
'<td class="nowraponall tdoverflowmax150">'.dol_print_phone($obj->fax, $obj->country_code, $obj->rowid, $obj->socid,
'AC_TEL',
' ',
'fax').
'</td>';
1337 $totalarray[
'nbfield']++;
1341 if (!empty($arrayfields[
'p.email'][
'checked'])) {
1342 print
'<td class="nowraponall tdoverflowmax300">'.dol_print_email($obj->email, $obj->rowid, $obj->socid,
'AC_EMAIL', 18, 0, 1).
'</td>';
1344 $totalarray[
'nbfield']++;
1348 if (!empty($arrayfields[
'unsubscribed'][
'checked'])) {
1349 print
'<td class="center">';
1350 if (empty($obj->email)) {
1353 print
yn(($obj->unsubscribed > 0) ? 1 : 0);
1357 $totalarray[
'nbfield']++;
1361 foreach ($socialnetworks as $key => $value) {
1362 if ($value[
'active'] && !empty($arrayfields[
'p.'.$key][
'checked'])) {
1363 print
'<td class="tdoverflowmax100">'.(empty($arraysocialnetworks[$key]) ?
'' :
dol_print_socialnetworks($arraysocialnetworks[$key], $obj->rowid, $obj->socid, $key, $socialnetworks)).
'</td>';
1365 $totalarray[
'nbfield']++;
1371 if (!empty($arrayfields[
'p.fk_soc'][
'checked']) || !empty($arrayfields[
's.nom'][
'checked'])) {
1372 print
'<td class="tdoverflowmax200">';
1375 $objsoc->fetch($obj->socid);
1376 print $objsoc->getNomUrl(1);
1382 $totalarray[
'nbfield']++;
1387 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1388 print
'<td class="nocellnopadd">';
1392 $totalarray[
'nbfield']++;
1397 if (!empty($arrayfields[
'p.priv'][
'checked'])) {
1398 print
'<td class="center">'.$contactstatic->LibPubPriv($obj->priv).
'</td>';
1400 $totalarray[
'nbfield']++;
1404 if (!empty($arrayfields[
'p.fk_prospectlevel'][
'checked'])) {
1406 print
'<td class="center">';
1407 print $contactstatic->getLibProspLevel();
1410 $totalarray[
'nbfield']++;
1414 if (!empty($arrayfields[
'p.fk_stcommcontact'][
'checked'])) {
1416 print
'<td class="center nowrap"><div class="nowrap">';
1417 print
'<div class="inline-block">'.$contactstatic->libProspCommStatut($obj->stcomm_id, 2, $contactstatic->cacheprospectstatus[$obj->stcomm_id][
'label'], $obj->stcomm_picto);
1418 print
'</div> - <div class="inline-block">';
1419 foreach ($contactstatic->cacheprospectstatus as $key => $val) {
1420 $titlealt =
'default';
1421 if (!empty($val[
'code']) && !in_array($val[
'code'], array(
'ST_NO',
'ST_NEVER',
'ST_TODO',
'ST_PEND',
'ST_DONE'))) {
1422 $titlealt = $val[
'label'];
1424 if ($obj->stcomm_id != $val[
'id']) {
1425 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>';
1428 print
'</div></div></td>';
1430 $totalarray[
'nbfield']++;
1435 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
1437 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$obj,
'i'=>$i,
'totalarray'=>&$totalarray);
1438 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
1439 print $hookmanager->resPrint;
1441 if (!empty($arrayfields[
'p.datec'][
'checked'])) {
1442 print
'<td class="center nowraponall">';
1443 print
dol_print_date($db->jdate($obj->date_creation),
'dayhour',
'tzuser');
1446 $totalarray[
'nbfield']++;
1450 if (!empty($arrayfields[
'p.tms'][
'checked'])) {
1451 print
'<td class="center nowraponall">';
1452 print
dol_print_date($db->jdate($obj->date_update),
'dayhour',
'tzuser');
1455 $totalarray[
'nbfield']++;
1459 if (!empty($arrayfields[
'p.statut'][
'checked'])) {
1460 print
'<td class="center">'.$contactstatic->getLibStatut(5).
'</td>';
1462 $totalarray[
'nbfield']++;
1466 if (!empty($arrayfields[
'p.import_key'][
'checked'])) {
1467 print
'<td class="tdoverflowmax100">';
1471 $totalarray[
'nbfield']++;
1476 if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
1477 print
'<td class="nowrap center">';
1478 if ($massactionbutton || $massaction) {
1480 if (in_array($obj->rowid, $arrayofselected)) {
1483 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1488 $totalarray[
'nbfield']++;
1497 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
1502 foreach ($arrayfields as $key => $val) {
1503 if (!empty($val[
'checked'])) {
1507 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
1512 $parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>$sql);
1513 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
1514 print $hookmanager->resPrint;
1516 print
'</table>'.
"\n";
1517 print
'</div>'.
"\n";
1519 print
'</form>'.
"\n";
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage third parties objects (customers, suppliers, prospects...)
getCountry($searchkey, $withcode='', $dbtouse=0, $outputlangs='', $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
dol_print_socialnetworks($value, $cid, $socid, $type, $dictsocialnetworks=array())
Show social network link.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
img_action($titlealt, $numaction, $picto='')
Show logo action.
getArrayOfSocialNetworks()
Get array of social network dictionary.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isModEnabled($module)
Is Dolibarr module enabled.
$nbtotalofrecords
Count total nb of records.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.