diff --git a/application/cmdbabstract.class.inc.php b/application/cmdbabstract.class.inc.php
index 2d8b79ac0..1f7f27b46 100644
--- a/application/cmdbabstract.class.inc.php
+++ b/application/cmdbabstract.class.inc.php
@@ -1244,6 +1244,10 @@ EOF
$oPage->add(self::GetSetAsHTMLSpreadsheet($oSet, $aParams));
}
+ /**
+ * Spreadsheet output: designed for end users doing some reporting
+ * Then the ids are excluded and replaced by the corresponding friendlyname
+ */
static function GetSetAsHTMLSpreadsheet(DBObjectSet $oSet, $aParams = array())
{
$aFields = null;
@@ -1289,18 +1293,27 @@ EOF
}
}
}
- $aHeader[] = 'id';
+ // Replace external key by the corresponding friendly name (if not already in the list)
+ foreach($aList[$sAlias] as $sAttCode => $oAttDef)
+ {
+ if ($oAttDef->IsExternalKey())
+ {
+ unset($aList[$sAlias][$sAttCode]);
+ $sFriendlyNameAttCode = $sAttCode.'_friendlyname';
+ if (!array_key_exists($sFriendlyNameAttCode, $aList[$sAlias]) && MetaModel::IsValidAttCode($sClassName, $sFriendlyNameAttCode))
+ {
+ $oFriendlyNameAtt = MetaModel::GetAttributeDef($sClassName, $sFriendlyNameAttCode);
+ $aList[$sAlias][$sFriendlyNameAttCode] = $oFriendlyNameAtt;
+ }
+ }
+ }
+
foreach($aList[$sAlias] as $sAttCode => $oAttDef)
{
- $sStar = '';
if ($oAttDef->IsExternalField())
{
$sExtKeyLabel = MetaModel::GetLabel($sClassName, $oAttDef->GetKeyAttCode());
$oExtKeyAttDef = MetaModel::GetAttributeDef($sClassName, $oAttDef->GetKeyAttCode());
- if (!$oExtKeyAttDef->IsNullAllowed() && isset($aParams['showMandatoryFields']))
- {
- $sStar = '*';
- }
$sRemoteAttLabel = MetaModel::GetLabel($oAttDef->GetTargetClass(), $oAttDef->GetExtAttCode());
$oTargetAttDef = MetaModel::GetAttributeDef($oAttDef->GetTargetClass(), $oAttDef->GetExtAttCode());
$sSuffix = '';
@@ -1308,15 +1321,11 @@ EOF
{
$sSuffix = '->id';
}
- $sColLabel = $sExtKeyLabel.'->'.$sRemoteAttLabel.$sSuffix.$sStar;
+ $sColLabel = $sExtKeyLabel.'->'.$sRemoteAttLabel.$sSuffix;
}
else
{
- if (!$oAttDef->IsNullAllowed() && isset($aParams['showMandatoryFields']))
- {
- $sStar = '*';
- }
- $sColLabel = MetaModel::GetLabel($sClassName, $sAttCode).$sStar;
+ $sColLabel = MetaModel::GetLabel($sClassName, $sAttCode);
}
$oFinalAttDef = $oAttDef->GetFinalAttDef();
if (get_class($oFinalAttDef) == 'AttributeDateTime')
@@ -1343,19 +1352,11 @@ EOF
foreach($aAuthorizedClasses as $sAlias => $sClassName)
{
$oObj = $aObjects[$sAlias];
- if (is_null($oObj))
- {
- $aRow[] = '';
- }
- else
- {
- $aRow[] = '
'.$oObj->GetKey().' | ';
- }
foreach($aList[$sAlias] as $sAttCode => $oAttDef)
{
if (is_null($oObj))
{
- $aRow[] = '';
+ $aRow[] = ' | ';
}
else
{
diff --git a/core/attributedef.class.inc.php b/core/attributedef.class.inc.php
index ab85c499e..a3d8761ab 100644
--- a/core/attributedef.class.inc.php
+++ b/core/attributedef.class.inc.php
@@ -3534,6 +3534,43 @@ class AttributeFriendlyName extends AttributeComputedFieldVoid
public function GetKeyAttCode() {return $this->Get("extkey_attcode");}
+ public function GetLabel($sDefault = null)
+ {
+ $sLabel = parent::GetLabel('');
+ if (strlen($sLabel) == 0)
+ {
+ $sKeyAttCode = $this->Get("extkey_attcode");
+ if ($sKeyAttCode == 'id')
+ {
+ return Dict::S('Core:FriendlyName-Label');
+ }
+ else
+ {
+ $oExtKeyAttDef = MetaModel::GetAttributeDef($this->GetHostClass(), $sKeyAttCode);
+ $sLabel = $oExtKeyAttDef->GetLabel($this->m_sCode);
+ }
+ }
+ return $sLabel;
+ }
+ public function GetDescription($sDefault = null)
+ {
+ $sLabel = parent::GetDescription('');
+ if (strlen($sLabel) == 0)
+ {
+ $sKeyAttCode = $this->Get("extkey_attcode");
+ if ($sKeyAttCode == 'id')
+ {
+ return Dict::S('Core:FriendlyName-Description');
+ }
+ else
+ {
+ $oExtKeyAttDef = MetaModel::GetAttributeDef($this->GetHostClass(), $sKeyAttCode);
+ $sLabel = $oExtKeyAttDef->GetDescription('');
+ }
+ }
+ return $sLabel;
+ }
+
// n/a, the friendly name is made of a complex expression (see GetNameSpec)
protected function GetSQLCol() {return "";}
diff --git a/dictionaries/dictionary.itop.core.php b/dictionaries/dictionary.itop.core.php
index 160eacdc6..fefc532ac 100644
--- a/dictionaries/dictionary.itop.core.php
+++ b/dictionaries/dictionary.itop.core.php
@@ -140,6 +140,12 @@ Operators:
'Core:AttributePropertySet' => 'Properties',
'Core:AttributePropertySet+' => 'List of untyped properties (name and value)',
+
+ 'Core:AttributeFriendlyName' => 'Friendly name',
+ 'Core:AttributeFriendlyName+' => 'Attribute created automatically ; the friendly name is computed after several attributes',
+
+ 'Core:FriendlyName-Label' => 'Name',
+ 'Core:FriendlyName-Description' => 'Friendly name',
));
diff --git a/dictionaries/fr.dictionary.itop.core.php b/dictionaries/fr.dictionary.itop.core.php
index 02e8e1668..2f61f04cc 100644
--- a/dictionaries/fr.dictionary.itop.core.php
+++ b/dictionaries/fr.dictionary.itop.core.php
@@ -485,6 +485,13 @@ Opérateurs :
'Core:AttributeTable+' => 'Tableau à deux dimensions',
'Core:AttributePropertySet' => 'Propriétés',
'Core:AttributePropertySet+' => 'Liste de propriétés (nom et valeur) non typées',
+
+ 'Core:AttributeFriendlyName' => 'Nom usuel (convivial)',
+ 'Core:AttributeFriendlyName+' => 'Attribut créé automatiquement ; sa valeur est calculée d\'après d\'autres attributs',
+
+ 'Core:FriendlyName-Label' => 'Nom',
+ 'Core:FriendlyName-Description' => 'Nom usuel',
+
'Change:ObjectCreated' => 'Elément créé',
'Change:ObjectDeleted' => 'Elément effacé',
'Change:ObjectModified' => 'Elément modifié',