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