From bff128a061735948435045d55893a5bcc6a0fd2a Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Sat, 14 Jan 2023 17:41:29 +0100 Subject: [PATCH] Update list.php --- htdocs/contact/list.php | 100 +++++++++++++++++++++++++++++----------- 1 file changed, 74 insertions(+), 26 deletions(-) diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index a025ef81b97..1cc2d67cf93 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -101,10 +101,10 @@ $search_type = GETPOST('search_type', 'alpha'); $search_address = GETPOST('search_address', 'alpha'); $search_zip = GETPOST('search_zip', 'alpha'); $search_town = GETPOST('search_town', 'alpha'); -$search_import_key = GETPOST("search_import_key", "alpha"); +$search_import_key = GETPOST("search_import_key", 'alpha'); $search_country = GETPOST("search_country", 'intcomma'); $search_roles = GETPOST("search_roles", 'array'); -$search_level = GETPOST("search_level", "array"); +$search_level = GETPOST("search_level", 'array'); $search_stcomm = GETPOST('search_stcomm', 'int'); if ($search_status === '') { @@ -350,9 +350,14 @@ $formother = new FormOther($db); $formcompany = new FormCompany($db); $contactstatic = new Contact($db); -$morejs=array(); +$morejs = array(); $morecss = array(); +// Page Header +$title = $langs->trans("Contacts")." - ".$langs->trans("List"); +$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Empresas'; +llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'bodyforlist'); + if (!empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES)) { $contactstatic->loadCacheOfProspStatus(); } @@ -387,6 +392,7 @@ $sql .= " p.phone as phone_pro, p.phone_mobile, p.phone_perso, p.fax, p.fk_pays, $sql .= " p.import_key,"; $sql .= " st.libelle as stcomm, st.picto as stcomm_picto, p.fk_stcommcontact as stcomm_id, p.fk_prospectlevel,"; $sql .= " co.label as country, co.code as country_code"; + // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { @@ -396,13 +402,15 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) { if (isModEnabled('mailing')) { $sql .= ", (SELECT count(*) FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = p.email) as unsubscribed"; } -// Add fields from hooks + +// Add fields from hooks - ListSelect $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; $sqlfields = $sql; // $sql fields to remove for count total +// SQL Table Aliase $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as p"; if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (p.rowid = ef.fk_object)"; @@ -413,7 +421,8 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_stcommcontact as st ON st.id = p.fk_stco if (empty($user->rights->societe->client->voir) && !$socid) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; } -// Add fields from hooks + +// Add fields from hooks - ListFrom $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; @@ -443,9 +452,13 @@ if ($search_priv != '0' && $search_priv != '1') { } } + +// Search Categories + + // Search Contact Categories $searchCategoryContactList = $search_categ ? array($search_categ) : array(); $searchCategoryContactOperator = 0; -// Search for tag/category ($searchCategoryContactList is an array of ID) + // Search for tag/category ($searchCategoryContactList is an array of ID) if (!empty($searchCategoryContactList)) { $searchCategoryContactSqlList = array(); $listofcategoryid = ''; @@ -473,9 +486,11 @@ if (!empty($searchCategoryContactList)) { } } } + + // Search Customer Categories $searchCategoryCustomerList = $search_categ_thirdparty ? array($search_categ_thirdparty) : array(); $searchCategoryCustomerOperator = 0; -// Search for tag/category ($searchCategoryCustomerList is an array of ID) + // Search for tag/category ($searchCategoryCustomerList is an array of ID) if (!empty($searchCategoryCustomerList)) { $searchCategoryCustomerSqlList = array(); $listofcategoryid = ''; @@ -503,9 +518,11 @@ if (!empty($searchCategoryCustomerList)) { } } } + + // Search Supplier Categories $searchCategorySupplierList = $search_categ_supplier ? array($search_categ_supplier) : array(); $searchCategorySupplierOperator = 0; -// Search for tag/category ($searchCategorySupplierList is an array of ID) + // Search for tag/category ($searchCategorySupplierList is an array of ID) if (!empty($searchCategorySupplierList)) { $searchCategorySupplierSqlList = array(); $listofcategoryid = ''; @@ -600,6 +617,7 @@ if (isModEnabled('socialnetworks')) { } } //print $sql; + if (strlen($search_email)) { $sql .= natural_search('p.email', $search_email); } @@ -627,20 +645,22 @@ if ($search_status != '' && $search_status >= 0) { if ($search_import_key) { $sql .= natural_search("p.import_key", $search_import_key); } -if ($type == "o") { // filtre sur type +if ($type == "o") { // filter on type $sql .= " AND p.fk_soc IS NULL"; -} elseif ($type == "f") { // filtre sur type +} elseif ($type == "f") { // filter on type $sql .= " AND s.fournisseur = 1"; -} elseif ($type == "c") { // filtre sur type +} elseif ($type == "c") { // filter on type $sql .= " AND s.client IN (1, 3)"; -} elseif ($type == "p") { // filtre sur type +} elseif ($type == "p") { // filter on type $sql .= " AND s.client IN (2, 3)"; } if (!empty($socid)) { $sql .= " AND s.rowid = ".((int) $socid); } + // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; + // Add where from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook @@ -695,8 +715,7 @@ if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && ( exit; } -$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Empresas'; -llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'bodyforlist'); + $param = ''; if (!empty($mode)) { @@ -948,20 +967,25 @@ if (!empty($arrayfields['p.town']['checked'])) { print ''; print ''; } + +/* // State -/*if (!empty($arrayfields['state.nom']['checked'])) + if (!empty($arrayfields['state.nom']['checked'])) { print '