NEW: Add new option for displaying Contact email (or phones if not defined) and town info list (select list or combobox)

Contacts will appear with a name format of "Dupond Durand - dupond.durand@email.com - Paris" or "Dupond Durand - 06 07 59 65 66 - Paris" instead of "Dupond Durand".
This commit is contained in:
kamel
2020-11-18 09:41:42 +01:00
parent 17f78f9cec
commit 73b35f334e
4 changed files with 61 additions and 4 deletions

View File

@@ -1464,9 +1464,10 @@ class Form
// We search third parties
$sql = "SELECT sp.rowid, sp.lastname, sp.statut, sp.firstname, sp.poste";
if (!empty($conf->global->CONTACT_SHOW_EMAIL_PHONE_TOWN_SELECTLIST)) $sql.= ", sp.email, sp.phone, sp.phone_perso, sp.phone_mobile, sp.town AS contact_town, s.town AS company_town";
if ($showsoc > 0) $sql .= " , s.nom as company";
$sql .= " FROM ".MAIN_DB_PREFIX."socpeople as sp";
if ($showsoc > 0) $sql .= " LEFT OUTER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid=sp.fk_soc";
if ($showsoc > 0 || !empty($conf->global->CONTACT_SHOW_EMAIL_PHONE_TOWN_SELECTLIST)) $sql .= " LEFT OUTER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid=sp.fk_soc";
$sql .= " WHERE sp.entity IN (".getEntity('socpeople').")";
if ($socid > 0 || $socid == -1) $sql .= " AND sp.fk_soc=".$socid;
if (!empty($conf->global->CONTACT_HIDE_INACTIVE_IN_COMBOBOX)) $sql .= " AND sp.statut <> 0";
@@ -1499,6 +1500,28 @@ class Form
{
$obj = $this->db->fetch_object($resql);
// Set email (or phones) and town extended infos
$extendedInfos = '';
if (!empty($conf->global->CONTACT_SHOW_EMAIL_PHONE_TOWN_SELECTLIST)) {
$extendedInfos = array();
$email = trim($obj->email);
if (!empty($email)) $extendedInfos[] = $email;
else {
$phone = trim($obj->phone);
$phone_perso = trim($obj->phone_perso);
$phone_mobile = trim($obj->phone_mobile);
if (!empty($phone)) $extendedInfos[] = $phone;
if (!empty($phone_perso)) $extendedInfos[] = $phone_perso;
if (!empty($phone_mobile)) $extendedInfos[] = $phone_mobile;
}
$contact_town = trim($obj->contact_town);
$company_town = trim($obj->company_town);
if (!empty($contact_town)) $extendedInfos[] = $contact_town;
elseif (!empty($company_town)) $extendedInfos[] = $company_town;
$extendedInfos = implode(' - ', $extendedInfos);
if (!empty($extendedInfos)) $extendedInfos = ' - ' . $extendedInfos;
}
$contactstatic->id = $obj->rowid;
$contactstatic->lastname = $obj->lastname;
$contactstatic->firstname = $obj->firstname;
@@ -1513,7 +1536,7 @@ class Form
$out .= '<option value="'.$obj->rowid.'"';
if ($disabled) $out .= ' disabled';
$out .= ' selected>';
$out .= $contactstatic->getFullName($langs);
$out .= $contactstatic->getFullName($langs) . $extendedInfos;
if ($showfunction && $obj->poste) $out .= ' ('.$obj->poste.')';
if (($showsoc > 0) && $obj->company) $out .= ' - ('.$obj->company.')';
$out .= '</option>';
@@ -1521,7 +1544,7 @@ class Form
$out .= '<option value="'.$obj->rowid.'"';
if ($disabled) $out .= ' disabled';
$out .= '>';
$out .= $contactstatic->getFullName($langs);
$out .= $contactstatic->getFullName($langs) . $extendedInfos;
if ($showfunction && $obj->poste) $out .= ' ('.$obj->poste.')';
if (($showsoc > 0) && $obj->company) $out .= ' - ('.$obj->company.')';
$out .= '</option>';
@@ -1529,7 +1552,7 @@ class Form
} else {
if (in_array($obj->rowid, $selected))
{
$out .= $contactstatic->getFullName($langs);
$out .= $contactstatic->getFullName($langs) . $extendedInfos;
if ($showfunction && $obj->poste) $out .= ' ('.$obj->poste.')';
if (($showsoc > 0) && $obj->company) $out .= ' - ('.$obj->company.')';
}

View File

@@ -1314,6 +1314,7 @@ PHPModuleLoaded=PHP component %s is loaded
PreloadOPCode=Preloaded OPCode is used
AddRefInList=Display Customer/Vendor ref. info list (select list or combobox) and most of hyperlink.<br>Third Parties will appear with a name format of "CC12345 - SC45678 - The Big Company corp." instead of "The Big Company corp".
AddAdressInList=Display Customer/Vendor adress info list (select list or combobox)<br>Third Parties will appear with a name format of "The Big Company corp. - 21 jump street 123456 Big town - USA" instead of "The Big Company corp".
AddEmailPhoneTownInContactList=Display Contact email (or phones if not defined) and town info list (select list or combobox)<br>Contacts will appear with a name format of "Dupond Durand - dupond.durand@email.com - Paris" or "Dupond Durand - 06 07 59 65 66 - Paris" instead of "Dupond Durand".
AskForPreferredShippingMethod=Ask for preferred shipping method for Third Parties.
FieldEdition=Edition of field %s
FillThisOnlyIfRequired=Example: +2 (fill only if timezone offset problems are experienced)

View File

@@ -1276,6 +1276,7 @@ PHPModuleLoaded=Le composant PHP %s est chargé
PreloadOPCode=Le code OP préchargé est utilisé
AddRefInList=Afficher les références client/fournisseur dans les listes (listes déroulantes ou à autocomplétion) et les libellés des liens clicables.<br>Les tiers apparaîtront alors sous la forme "CC12345 - SC45678 - La big company coorp", au lieu de "La big company coorp".
AddAdressInList=Affiche les informations sur ladresse du client/fournisseur (liste de sélection ou liste déroulante) <br> Les tiers apparaîtront avec le format de nom suivant: "The Big Company corp. - 21, rue du saut 123456 Big town - USA" au lieu de "The Big Company corp".
AddEmailPhoneTownInContactList=Affiche les informations sur lemail (ou les telephones si non définie) et la ville du contact (liste de sélection ou liste déroulante) <br> Les contacts apparaîtront avec le format de nom suivant: "Dupond Durand - dupond.durand@email.com - Paris" ou "Dupond Durand - 06 07 59 65 66 - Paris" au lieu de "Dupond Durand".
AskForPreferredShippingMethod=Demander la méthode d'expédition préférée pour les Tiers
FieldEdition=Édition du champ %s
FillThisOnlyIfRequired=Exemple: +2 (ne remplir que si un décalage d'heure est constaté dans l'export)

View File

@@ -198,6 +198,21 @@ if ($action == "setaddadressinlist") {
}
}
//Activate Set email phone town in contact list
if ($action=="setaddemailphonetownincontactlist") {
$val = GETPOST('value', 'int');
$res = dolibarr_set_const($db, "CONTACT_SHOW_EMAIL_PHONE_TOWN_SELECTLIST", $val, 'yesno', 0, '', $conf->entity);
if (! $res > 0) $error++;
if (! $error)
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
else
{
setEventMessages($langs->trans("Error"), null, 'errors');
}
}
//Activate Ask For Preferred Shipping Method
if ($action == "setaskforshippingmet") {
$setaskforshippingmet = GETPOST('value', 'int');
@@ -800,6 +815,23 @@ if (!empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST))
print '</a></td>';
print '</tr>';
print '<tr class="oddeven">';
print '<td width="80%">'.$langs->trans("AddEmailPhoneTownInContactList").'</td>';
print '<td>&nbsp</td>';
print '<td class="center">';
if (!empty($conf->global->CONTACT_SHOW_EMAIL_PHONE_TOWN_SELECTLIST))
{
print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setaddemailphonetownincontactlist&value=0">';
print img_picto($langs->trans("Activated"), 'switch_on');
}
else
{
print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setaddemailphonetownincontactlist&value=1">';
print img_picto($langs->trans("Disabled"), 'switch_off');
}
print '</a></td>';
print '</tr>';
if (!empty($conf->expedition->enabled)) {
if (!empty($conf->global->MAIN_FEATURES_LEVEL)) { // Visible on experimental only because seems to not be implemented everywhere (only on proposal)
print '<tr class="oddeven">';