clean code

This commit is contained in:
Frédéric FRANCE 2023-02-06 21:43:50 +01:00
parent 1b9f8d46b0
commit dc15349e83
3 changed files with 71 additions and 97 deletions

View File

@ -1121,24 +1121,20 @@ class BOM extends CommonObject
}
$result = '';
$params = [
'id' => $this->id,
'objecttype' => $this->element,
'option' => $option,
];
$classfortooltip = 'classfortooltip';
$dataparams = '';
if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) {
$classfortooltip = 'classforajaxtooltip';
$dataparams = ' data-params='.json_encode($params);
// $label = $langs->trans('Loading');
}
$label = img_picto('', $this->picto).' <u class="paddingrightonly">'.$langs->trans("BillOfMaterials").'</u>';
if (isset($this->status)) {
$label .= ' '.$this->getLibStatut(5);
}
$label .= '<br>';
$label .= '<b>'.$langs->trans('Ref').':</b> '.$this->ref;
if (isset($this->label)) {
$label .= '<br><b>'.$langs->trans('Label').':</b> '.$this->label;
}
if (!empty($this->fk_product) && $this->fk_product > 0) {
include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
$product = new Product($db);
$resultFetch = $product->fetch($this->fk_product);
if ($resultFetch > 0) {
$label .= "<br><b>".$langs->trans("Product").'</b>: '.$product->ref.' - '.$product->label;
}
}
$label = implode($this->getTooltipContentArray($params));
$url = DOL_URL_ROOT.'/bom/bom_card.php?id='.$this->id;
@ -1155,18 +1151,6 @@ class BOM extends CommonObject
}
$linkclose = '';
$classfortooltip = 'classfortooltip';
$dataparams = '';
if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) {
$params = [
'id' => $this->id,
'objecttype' => $this->element,
'option' => $option,
];
$classfortooltip = 'classforajaxtooltip';
$dataparams = ' data-params='.json_encode($params);
// $label = $langs->trans('Loading');
}
if (empty($notooltip)) {
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
$label = $langs->trans("ShowBillOfMaterials");

View File

@ -1605,7 +1605,7 @@ class Categorie extends CommonObject
*/
public function getTooltipContentArray($params)
{
global $conf, $langs, $user;
global $langs;
$datas = [];
@ -1629,7 +1629,19 @@ class Categorie extends CommonObject
global $langs, $hookmanager;
$result = '';
$label = $langs->trans("ShowCategory").': '.($this->ref ? $this->ref : $this->label);
$params = [
'id' => $this->id,
'objecttype' => $this->element,
'option' => $option,
];
$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));
// Check contrast with background and correct text color
$forced_color = 'categtextwhite';
@ -1638,18 +1650,6 @@ class Categorie extends CommonObject
$forced_color = 'categtextblack';
}
}
$classfortooltip = 'classfortooltip';
$dataparams = '';
if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) {
$params = [
'id' => $this->id,
'objecttype' => $this->element,
'option' => $option,
];
$classfortooltip = 'classforajaxtooltip';
$dataparams = ' data-params='.json_encode($params);
// $label = $langs->trans('Loading');
}
$link = '<a href="'.DOL_URL_ROOT.'/categories/viewcat.php?id='.$this->id.'&type='.$this->type.$moreparam.'&backtopage='.urlencode($_SERVER['PHP_SELF'].($moreparam ? '?'.$moreparam : ''));
$link .= '"'.$dataparams.' title="'.dol_escape_htmltag($label, 1).'" class="'.$classfortooltip.' '.$forced_color.'">';
$linkend = '</a>';

View File

@ -133,6 +133,11 @@ class Contact extends CommonObject
public $civility_code;
public $civility;
/**
* @var string gender
*/
public $gender;
/**
* @var int egroupware_id
*/
@ -193,6 +198,11 @@ class Contact extends CommonObject
public $socid; // both socid and fk_soc are used
public $fk_soc; // both socid and fk_soc are used
/**
* @var string thirdparty name
*/
public $socname;
/**
* @var int 0=inactive, 1=active
*/
@ -206,6 +216,14 @@ class Contact extends CommonObject
*/
public $email;
/**
* Email
* @var string
* @deprecated
* @see $email
*/
public $mail;
/**
* URL
* @var string
@ -1045,12 +1063,12 @@ class Contact extends CommonObject
$this->country_id = $obj->country_id;
$this->country_code = $obj->country_id ? $obj->country_code : '';
$this->country = $obj->country_id ? ($langs->trans('Country'.$obj->country_code) != 'Country'.$obj->country_code ? $langs->transnoentities('Country'.$obj->country_code) : $obj->country) : '';
$this->country = $obj->country_id ? ($langs->trans('Country'.$obj->country_code) != 'Country'.$obj->country_code ? $langs->transnoentities('Country'.$obj->country_code) : $obj->country) : '';
$this->fk_soc = $obj->fk_soc; // Both fk_soc and socid are used
$this->socid = $obj->fk_soc; // Both fk_soc and socid are used
$this->socname = $obj->socname;
$this->poste = $obj->poste;
$this->fk_soc = $obj->fk_soc; // Both fk_soc and socid are used
$this->socid = $obj->fk_soc; // Both fk_soc and socid are used
$this->socname = $obj->socname;
$this->poste = $obj->poste;
$this->statut = $obj->statut;
$this->fk_prospectlevel = $obj->fk_prospectlevel;
@ -1066,22 +1084,22 @@ class Contact extends CommonObject
$this->phone_perso = trim($obj->phone_perso);
$this->phone_mobile = trim($obj->phone_mobile);
$this->email = $obj->email;
$this->email = $obj->email;
$this->socialnetworks = ($obj->socialnetworks ? (array) json_decode($obj->socialnetworks, true) : array());
$this->photo = $obj->photo;
$this->priv = $obj->priv;
$this->mail = $obj->email;
$this->photo = $obj->photo;
$this->priv = $obj->priv;
$this->mail = $obj->email;
$this->birthday = $this->db->jdate($obj->birthday);
$this->note = $obj->note_private; // deprecated
$this->note_private = $obj->note_private;
$this->note = $obj->note_private; // deprecated
$this->note_private = $obj->note_private;
$this->note_public = $obj->note_public;
$this->default_lang = $obj->default_lang;
$this->default_lang = $obj->default_lang;
$this->user_id = $obj->user_id;
$this->user_login = $obj->user_login;
$this->user_login = $obj->user_login;
$this->canvas = $obj->canvas;
$this->import_key = $obj->import_key;
$this->import_key = $obj->import_key;
// Define gender according to civility
$this->setGenderFromCivility();
@ -1468,35 +1486,19 @@ class Contact extends CommonObject
global $conf, $langs, $hookmanager;
$result = '';
$label = '';
if (!empty($this->photo) && class_exists('Form')) {
$label .= '<div class="photointooltip floatright">';
$label .= Form::showphoto('contact', $this, 0, 40, 0, 'photoref', 'mini', 0); // Important, we must force height so image will have height tags and if image is inside a tooltip, the tooltip manager can calculate height and position correctly the tooltip.
$label .= '</div>';
//$label .= '<div style="clear: both;"></div>';
$params = [
'id' => $this->id,
'objecttype' => $this->element,
'option' => $option,
];
$classfortooltip = 'classfortooltip';
$dataparams = '';
if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) {
$classfortooltip = 'classforajaxtooltip';
$dataparams = ' data-params='.json_encode($params);
// $label = $langs->trans('Loading');
}
$label .= img_picto('', $this->picto).' <u class="paddingrightonly">'.$langs->trans("Contact").'</u>';
$label .= ' '.$this->getLibStatut(4);
$label .= '<br><b>'.$langs->trans("Name").':</b> '.$this->getFullName($langs);
//if ($this->civility_id) $label.= '<br><b>' . $langs->trans("Civility") . ':</b> '.$this->civility_id; // TODO Translate cibilty_id code
if (!empty($this->poste)) {
$label .= '<br><b>'.$langs->trans("Poste").':</b> '.$this->poste;
}
$label .= '<br><b>'.$langs->trans("EMail").':</b> '.$this->email;
$phonelist = array();
$country_code = empty($this->country_code) ? '': $this->country_code;
if ($this->phone_pro) {
$phonelist[] = dol_print_phone($this->phone_pro, $country_code, $this->id, 0, '', '&nbsp;', 'phone');
}
if ($this->phone_mobile) {
$phonelist[] = dol_print_phone($this->phone_mobile, $country_code, $this->id, 0, '', '&nbsp;', 'mobile');
}
if ($this->phone_perso) {
$phonelist[] = dol_print_phone($this->phone_perso, $country_code, $this->id, 0, '', '&nbsp;', 'phone');
}
$label .= '<br><b>'.$langs->trans("Phone").':</b> '.implode('&nbsp;', $phonelist);
$label .= '<br><b>'.$langs->trans("Address").':</b> '.dol_format_address($this, 1, ' ', $langs);
$label = implode($this->getTooltipContentArray($params));
$url = DOL_URL_ROOT.'/contact/card.php?id='.$this->id;
@ -1514,18 +1516,6 @@ class Contact extends CommonObject
$url .= $moreparam;
$linkclose = "";
$classfortooltip = 'classfortooltip';
$dataparams = '';
if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) {
$params = [
'id' => $this->id,
'objecttype' => $this->element,
'option' => $option,
];
$classfortooltip = 'classforajaxtooltip';
$dataparams = ' data-params='.json_encode($params);
// $label = $langs->trans('Loading');
}
if (empty($notooltip)) {
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
$label = $langs->trans("ShowContact");