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 1/2] 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 '
';
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 '';
From 35300b3dfc0b84910959113e74b2555f14804ca7 Mon Sep 17 00:00:00 2001
From: stickler-ci
Date: Sat, 14 Jan 2023 16:42:30 +0000
Subject: [PATCH 2/2] Fixing style errors.
---
htdocs/contact/list.php | 50 ++++++++++++++++++++---------------------
1 file changed, 25 insertions(+), 25 deletions(-)
diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php
index 1cc2d67cf93..f34c477ff71 100644
--- a/htdocs/contact/list.php
+++ b/htdocs/contact/list.php
@@ -455,7 +455,7 @@ if ($search_priv != '0' && $search_priv != '1') {
// Search Categories
- // Search Contact Categories
+ // Search Contact Categories
$searchCategoryContactList = $search_categ ? array($search_categ) : array();
$searchCategoryContactOperator = 0;
// Search for tag/category ($searchCategoryContactList is an array of ID)
@@ -487,7 +487,7 @@ if (!empty($searchCategoryContactList)) {
}
}
- // Search Customer Categories
+ // Search Customer Categories
$searchCategoryCustomerList = $search_categ_thirdparty ? array($search_categ_thirdparty) : array();
$searchCategoryCustomerOperator = 0;
// Search for tag/category ($searchCategoryCustomerList is an array of ID)
@@ -976,7 +976,7 @@ if (!empty($arrayfields['p.town']['checked'])) {
print '';
print ' | ';
}
-
+
// Region
if (!empty($arrayfields['region.nom']['checked']))
{
@@ -1262,7 +1262,7 @@ while ($i < min($num, $limit)) {
}
print ' | ';
}
-
+
// ID
if (!empty($arrayfields['p.rowid']['checked'])) {
print '';
@@ -1272,7 +1272,7 @@ while ($i < min($num, $limit)) {
$totalarray['nbfield']++;
}
}
-
+
// (Last) Name
if (!empty($arrayfields['p.lastname']['checked'])) {
print ' | ';
@@ -1282,7 +1282,7 @@ while ($i < min($num, $limit)) {
$totalarray['nbfield']++;
}
}
-
+
// Firstname
if (!empty($arrayfields['p.firstname']['checked'])) {
print ' | '.dol_escape_htmltag($obj->firstname).' | ';
@@ -1290,7 +1290,7 @@ while ($i < min($num, $limit)) {
$totalarray['nbfield']++;
}
}
-
+
// Job position
if (!empty($arrayfields['p.poste']['checked'])) {
print ''.dol_escape_htmltag($obj->poste).' | ';
@@ -1298,7 +1298,7 @@ while ($i < min($num, $limit)) {
$totalarray['nbfield']++;
}
}
-
+
// Address
if (!empty($arrayfields['p.address']['checked'])) {
print ''.dol_escape_htmltag($obj->address).' | ';
@@ -1306,7 +1306,7 @@ while ($i < min($num, $limit)) {
$totalarray['nbfield']++;
}
}
-
+
// Zip
if (!empty($arrayfields['p.zip']['checked'])) {
print ''.dol_escape_htmltag($obj->zip).' | ';
@@ -1314,7 +1314,7 @@ while ($i < min($num, $limit)) {
$totalarray['nbfield']++;
}
}
-
+
// Town
if (!empty($arrayfields['p.town']['checked'])) {
print ''.dol_escape_htmltag($obj->town).' | ';
@@ -1322,7 +1322,7 @@ while ($i < min($num, $limit)) {
$totalarray['nbfield']++;
}
}
-
+
/*
// State
if (!empty($arrayfields['state.nom']['checked']))
@@ -1330,14 +1330,14 @@ while ($i < min($num, $limit)) {
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 '';
@@ -1348,7 +1348,7 @@ while ($i < min($num, $limit)) {
$totalarray['nbfield']++;
}
}
-
+
// 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').' | ';
@@ -1356,7 +1356,7 @@ while ($i < min($num, $limit)) {
$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').' | ';
@@ -1364,7 +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').' | ';
@@ -1372,7 +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').' | ';
@@ -1380,7 +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).' | ';
@@ -1388,7 +1388,7 @@ while ($i < min($num, $limit)) {
$totalarray['nbfield']++;
}
}
-
+
// No EMail Subscription
if (!empty($arrayfields['unsubscribed']['checked'])) {
print '';
@@ -1402,7 +1402,7 @@ while ($i < min($num, $limit)) {
$totalarray['nbfield']++;
}
}
-
+
// Social Networks
if (isModEnabled('socialnetworks')) {
foreach ($socialnetworks as $key => $value) {
@@ -1448,7 +1448,7 @@ while ($i < min($num, $limit)) {
$totalarray['nbfield']++;
}
}
-
+
// Prospect Level
if (!empty($arrayfields['p.fk_prospectlevel']['checked'])) {
print ' | ';
@@ -1481,7 +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
@@ -1495,7 +1495,7 @@ while ($i < min($num, $limit)) {
$totalarray['nbfield']++;
}
}
-
+
// Date modification
if (!empty($arrayfields['p.tms']['checked'])) {
print ' | ';
@@ -1505,7 +1505,7 @@ while ($i < min($num, $limit)) {
$totalarray['nbfield']++;
}
}
-
+
// Status
if (!empty($arrayfields['p.statut']['checked'])) {
print ' | '.$contactstatic->getLibStatut(5).' | ';
@@ -1513,7 +1513,7 @@ while ($i < min($num, $limit)) {
$totalarray['nbfield']++;
}
}
-
+
// Import key
if (!empty($arrayfields['p.import_key']['checked'])) {
print '';
|