Fix asset module

This commit is contained in:
Laurent Destailleur 2020-09-24 17:37:57 +02:00
parent 9a831e3249
commit 72e9e1b387
3 changed files with 15 additions and 27 deletions

View File

@ -55,6 +55,10 @@ class Asset extends CommonObject
public $picto = 'asset'; public $picto = 'asset';
const STATUS_DRAFT = 0;
const STATUS_VALIDATED = 1;
/** /**
* 'type' if the field format. * 'type' if the field format.
* 'label' the translation key. * 'label' the translation key.
@ -390,31 +394,16 @@ class Asset extends CommonObject
// phpcs:enable // phpcs:enable
global $langs; global $langs;
if ($mode == 0 || $mode == 1) $langs->load("contracts");
{ $labelStatus[self::STATUS_DRAFT] = $langs->trans('Disabled');
if ($status == 1) return $langs->trans('Enabled'); $labelStatus[self::STATUS_VALIDATED] = $langs->trans('Enabled');
elseif ($status == 0) return $langs->trans('Disabled'); $labelStatusShort[self::STATUS_DRAFT] = $langs->trans('Disabled');
} elseif ($mode == 2) $labelStatusShort[self::STATUS_VALIDATED] = $langs->trans('Enabled');
{
if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled'); $statusType = 'status0';
elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); if ($status == self::STATUS_VALIDATED) $statusType = 'status4';
} elseif ($mode == 3)
{ return dolGetStatus($labelStatus[$status], $labelStatusShort[$status], '', $statusType, $mode);
if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4');
elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5');
} elseif ($mode == 4)
{
if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled');
elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled');
} elseif ($mode == 5)
{
if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4');
elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5');
} elseif ($mode == 6)
{
if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4');
elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5');
}
} }
/** /**

View File

@ -80,7 +80,7 @@ if ($user->socid > 0) // Protection if external user
accessforbidden(); accessforbidden();
} }
// Security check // Security check
$result = restrictedArea($user, 'asset', $id, ''); $result = restrictedArea($user, 'asset', $id);
// Initialize array of search criterias // Initialize array of search criterias

View File

@ -1911,7 +1911,6 @@ class Contrat extends CommonObject
} }
$statusType = 'status'.$status; $statusType = 'status'.$status;
if ($status == self::STATUS_VALIDATED) $statusType = 'status4';
if ($status == self::STATUS_VALIDATED) $statusType = 'status6'; if ($status == self::STATUS_VALIDATED) $statusType = 'status6';
if ($mode == 4 || $mode == 6 || $mode == 7) if ($mode == 4 || $mode == 6 || $mode == 7)