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 ''; print ''; print ''; } + // Region if (!empty($arrayfields['region.nom']['checked'])) { print ''; print ''; print ''; - }*/ + } +*/ + // Country if (!empty($arrayfields['country.code_iso']['checked'])) { print ''; @@ -1014,7 +1038,7 @@ if (!empty($arrayfields['p.fk_soc']['checked']) || !empty($arrayfields['s.nom'][ print ''; print ''; } -// Alias +// Alias of ThirdParty if (!empty($arrayfields['s.name_alias']['checked'])) { print ''; print ''; @@ -1079,7 +1103,7 @@ if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { } print ''; -// Ligne des titres +// Title line print ''; if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); @@ -1238,6 +1262,7 @@ while ($i < min($num, $limit)) { } print ''; } + // ID if (!empty($arrayfields['p.rowid']['checked'])) { print ''; @@ -1247,7 +1272,8 @@ while ($i < min($num, $limit)) { $totalarray['nbfield']++; } } - // Name + + // (Last) Name if (!empty($arrayfields['p.lastname']['checked'])) { print ''; print $contactstatic->getNomUrl(1); @@ -1256,6 +1282,7 @@ while ($i < min($num, $limit)) { $totalarray['nbfield']++; } } + // Firstname if (!empty($arrayfields['p.firstname']['checked'])) { print ''.dol_escape_htmltag($obj->firstname).''; @@ -1263,6 +1290,7 @@ while ($i < min($num, $limit)) { $totalarray['nbfield']++; } } + // Job position if (!empty($arrayfields['p.poste']['checked'])) { print ''.dol_escape_htmltag($obj->poste).''; @@ -1270,6 +1298,7 @@ while ($i < min($num, $limit)) { $totalarray['nbfield']++; } } + // Address if (!empty($arrayfields['p.address']['checked'])) { print ''.dol_escape_htmltag($obj->address).''; @@ -1277,6 +1306,7 @@ while ($i < min($num, $limit)) { $totalarray['nbfield']++; } } + // Zip if (!empty($arrayfields['p.zip']['checked'])) { print ''.dol_escape_htmltag($obj->zip).''; @@ -1284,6 +1314,7 @@ while ($i < min($num, $limit)) { $totalarray['nbfield']++; } } + // Town if (!empty($arrayfields['p.town']['checked'])) { print ''.dol_escape_htmltag($obj->town).''; @@ -1291,18 +1322,22 @@ while ($i < min($num, $limit)) { $totalarray['nbfield']++; } } + + /* // State - /*if (!empty($arrayfields['state.nom']['checked'])) + if (!empty($arrayfields['state.nom']['checked'])) { print "".$obj->state_name."\n"; if (! $i) $totalarray['nbfield']++; } + // Region if (!empty($arrayfields['region.nom']['checked'])) { print "".$obj->region_name."\n"; if (! $i) $totalarray['nbfield']++; }*/ + // Country if (!empty($arrayfields['country.code_iso']['checked'])) { print ''; @@ -1313,13 +1348,15 @@ while ($i < min($num, $limit)) { $totalarray['nbfield']++; } } - // Phone + + // Phone pro if (!empty($arrayfields['p.phone']['checked'])) { print ''.dol_print_phone($obj->phone_pro, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL', ' ', 'phone').''; if (!$i) { $totalarray['nbfield']++; } } + // Phone perso if (!empty($arrayfields['p.phone_perso']['checked'])) { print ''.dol_print_phone($obj->phone_perso, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL', ' ', 'phone').''; @@ -1327,6 +1364,7 @@ while ($i < min($num, $limit)) { $totalarray['nbfield']++; } } + // Phone mobile if (!empty($arrayfields['p.phone_mobile']['checked'])) { print ''.dol_print_phone($obj->phone_mobile, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL', ' ', 'mobile').''; @@ -1334,6 +1372,7 @@ while ($i < min($num, $limit)) { $totalarray['nbfield']++; } } + // Fax if (!empty($arrayfields['p.fax']['checked'])) { print ''.dol_print_phone($obj->fax, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL', ' ', 'fax').''; @@ -1341,6 +1380,7 @@ while ($i < min($num, $limit)) { $totalarray['nbfield']++; } } + // EMail if (!empty($arrayfields['p.email']['checked'])) { print ''.dol_print_email($obj->email, $obj->rowid, $obj->socid, 'AC_EMAIL', 18, 0, 1).''; @@ -1348,7 +1388,8 @@ while ($i < min($num, $limit)) { $totalarray['nbfield']++; } } - // No EMail + + // No EMail Subscription if (!empty($arrayfields['unsubscribed']['checked'])) { print ''; if (empty($obj->email)) { @@ -1361,6 +1402,8 @@ while ($i < min($num, $limit)) { $totalarray['nbfield']++; } } + + // Social Networks if (isModEnabled('socialnetworks')) { foreach ($socialnetworks as $key => $value) { if ($value['active'] && !empty($arrayfields['p.'.$key]['checked'])) { @@ -1371,7 +1414,8 @@ while ($i < min($num, $limit)) { } } } - // Company + + // Company / Third Party if (!empty($arrayfields['p.fk_soc']['checked']) || !empty($arrayfields['s.nom']['checked'])) { print ''; if ($obj->socid) { @@ -1404,9 +1448,9 @@ while ($i < min($num, $limit)) { $totalarray['nbfield']++; } } - + + // Prospect Level if (!empty($arrayfields['p.fk_prospectlevel']['checked'])) { - // Prospect level print ''; print $contactstatic->getLibProspLevel(); print ""; @@ -1415,8 +1459,8 @@ while ($i < min($num, $limit)) { } } + // Prospect status if (!empty($arrayfields['p.fk_stcommcontact']['checked'])) { - // Prospect status print '
'; print '
'.$contactstatic->libProspCommStatut($obj->stcomm_id, 2, $contactstatic->cacheprospectstatus[$obj->stcomm_id]['label'], $obj->stcomm_picto); print '
-
'; @@ -1437,6 +1481,7 @@ while ($i < min($num, $limit)) { // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook @@ -1450,6 +1495,7 @@ while ($i < min($num, $limit)) { $totalarray['nbfield']++; } } + // Date modification if (!empty($arrayfields['p.tms']['checked'])) { print ''; @@ -1459,6 +1505,7 @@ while ($i < min($num, $limit)) { $totalarray['nbfield']++; } } + // Status if (!empty($arrayfields['p.statut']['checked'])) { print ''.$contactstatic->getLibStatut(5).''; @@ -1466,6 +1513,7 @@ while ($i < min($num, $limit)) { $totalarray['nbfield']++; } } + // Import key if (!empty($arrayfields['p.import_key']['checked'])) { print '';