clean code

This commit is contained in:
Frédéric FRANCE 2023-02-06 23:08:34 +01:00
parent ff94600d8f
commit 769e28e3c0
2 changed files with 42 additions and 8 deletions

View File

@ -593,6 +593,11 @@ abstract class CommonObject
protected $labelStatus;
protected $labelStatusShort;
/**
* @var int showphoto_on_popup
*/
public $showphoto_on_popup;
/**
* @var array nb used in load_stateboard
*/

View File

@ -683,6 +683,29 @@ class Workstation extends CommonObject
return $this->setStatusCommon($user, self::STATUS_DISABLED, $notrigger, 'WORKSTATION_DISABLED');
}
/**
* getTooltipContentArray
*
* @param array $params ex option, infologin
* @since v18
* @return array
*/
public function getTooltipContentArray($params)
{
global $conf, $langs;
$langs->load('holiday');
$datas = [];
$datas['picto'] = img_picto('', $this->picto).' <u>'.$langs->trans("Workstation").'</u>';
$datas['ref'] = '<br><b>'.$langs->trans('Ref').':</b> '.$this->ref;
if (isset($this->status)) {
$datas['status'] = '<br><b>'.$langs->trans("Status").":</b> ".$this->getLibStatut(5);
}
return $datas;
}
/**
* Return a link to the object card (with optionaly the picto)
*
@ -703,12 +726,18 @@ class Workstation extends CommonObject
$result = '';
$label = img_picto('', $this->picto).' <u>'.$langs->trans("Workstation").'</u>';
$label .= '<br>';
$label .= '<b>'.$langs->trans('Ref').':</b> '.$this->ref;
if (isset($this->status)) {
$label .= '<br><b>'.$langs->trans("Status").":</b> ".$this->getLibStatut(5);
$params = [
'id' => $this->id,
'objecttype' => $this->element,
];
$classfortooltip = 'classfortooltip';
$dataparams = '';
if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) {
$classfortooltip = 'classforajaxtooltip';
$dataparams = ' data-params='.json_encode($params);
// $label = $langs->trans('Loading');
}
$label = implode($this->getTooltipContentArray($params));
$url = dol_buildpath('/workstation/workstation_card.php', 1).'?id='.$this->id;
@ -729,8 +758,8 @@ class Workstation extends CommonObject
$label = $langs->trans("ShowWorkstation");
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
}
$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
$linkclose .= $dataparams.' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose .= ' class="'.$classfortooltip.($morecss ? ' '.$morecss : '').'"';
} else {
$linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
}
@ -743,7 +772,7 @@ class Workstation extends CommonObject
if (empty($this->showphoto_on_popup)) {
if ($withpicto) {
$result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'mrp'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
$result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'mrp'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1);
}
} else {
if ($withpicto) {