clean code

This commit is contained in:
Frédéric FRANCE 2023-02-06 22:21:54 +01:00
parent 4a74e7d875
commit 8a5e983d7e
6 changed files with 72 additions and 231 deletions

View File

@ -3756,36 +3756,22 @@ class Propal extends CommonObject
}
$result = '';
$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));
$url = '';
if ($user->rights->propal->lire) {
$label = img_picto('', $this->picto).' <u class="paddingrightonly">'.$langs->trans("Proposal").'</u>';
if (isset($this->statut)) {
$label .= ' '.$this->getLibStatut(5);
}
if (!empty($this->ref)) {
$label .= '<br><b>'.$langs->trans('Ref').':</b> '.$this->ref;
}
if (!empty($this->ref_client)) {
$label .= '<br><b>'.$langs->trans('RefCustomer').':</b> '.$this->ref_client;
}
if (!empty($this->total_ht)) {
$label .= '<br><b>'.$langs->trans('AmountHT').':</b> '.price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency);
}
if (!empty($this->total_tva)) {
$label .= '<br><b>'.$langs->trans('VAT').':</b> '.price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency);
}
if (!empty($this->total_ttc)) {
$label .= '<br><b>'.$langs->trans('AmountTTC').':</b> '.price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency);
}
if (!empty($this->date)) {
$label .= '<br><b>'.$langs->trans('Date').':</b> '.dol_print_date($this->date, 'day');
}
if (!empty($this->delivery_date)) {
$label .= '<br><b>'.$langs->trans('DeliveryDate').':</b> '.dol_print_date($this->delivery_date, 'dayhour');
}
if ($option == '') {
$url = DOL_URL_ROOT.'/comm/propal/card.php?id='.$this->id.$get_params;
} elseif ($option == 'compta') { // deprecated
@ -3809,18 +3795,6 @@ class Propal 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) && $user->rights->propal->lire) {
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
$label = $langs->trans("Proposal");

View File

@ -3804,46 +3804,22 @@ class Commande extends CommonOrder
if ($short) {
return $url;
}
$label = '';
if ($user->hasRight('commande', 'lire')) {
$label = img_picto('', $this->picto).' <u class="paddingrightonly">'.$langs->trans("Order").'</u>';
if (isset($this->statut)) {
$label .= ' '.$this->getLibStatut(5);
}
$label .= '<br><b>'.$langs->trans('Ref').':</b> '.$this->ref;
$label .= '<br><b>'.$langs->trans('RefCustomer').':</b> '.(empty($this->ref_customer) ? (empty($this->ref_client) ? '' : $this->ref_client) : $this->ref_customer);
if (!empty($this->total_ht)) {
$label .= '<br><b>'.$langs->trans('AmountHT').':</b> '.price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency);
}
if (!empty($this->total_tva)) {
$label .= '<br><b>'.$langs->trans('VAT').':</b> '.price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency);
}
if (!empty($this->total_ttc)) {
$label .= '<br><b>'.$langs->trans('AmountTTC').':</b> '.price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency);
}
if (!empty($this->date)) {
$label .= '<br><b>'.$langs->trans('Date').':</b> '.dol_print_date($this->date, 'day');
}
if (!empty($this->delivery_date)) {
$label .= '<br><b>'.$langs->trans('DeliveryDate').':</b> '.dol_print_date($this->delivery_date, 'dayhour');
}
}
$linkclose = '';
$params = [
'id' => $this->id,
'objecttype' => $this->element,
'option' => $option,
];
$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');
}
$label = implode($this->getTooltipContentArray($params));
$linkclose = '';
if (empty($notooltip) && $user->rights->commande->lire) {
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
$label = $langs->trans("Order");

View File

@ -1123,16 +1123,20 @@ class Mo 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("ManufacturingOrder").'</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;
}
$label = implode($this->getTooltipContentArray($params));
$url = DOL_URL_ROOT.'/mrp/mo_card.php?id='.$this->id;
if ($option == 'production') {
@ -1151,18 +1155,6 @@ class Mo 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("ShowMo");

View File

@ -5125,114 +5125,28 @@ class Product extends CommonObject
global $conf, $langs, $hookmanager;
include_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
$result = ''; $label = '';
$result = '';
$newref = $this->ref;
if ($maxlength) {
$newref = dol_trunc($newref, $maxlength, 'middle');
}
if (!empty($this->entity)) {
$tmpphoto = $this->show_photos('product', $conf->product->multidir_output[$this->entity], 1, 1, 0, 0, 0, 80);
if ($this->nbphoto > 0) {
$label .= '<div class="photointooltip floatright">';
$label .= $tmpphoto;
$label .= '</div>';
//$label .= '<div style="clear: both;"></div>';
}
}
if ($this->type == Product::TYPE_PRODUCT) {
$label .= img_picto('', 'product').' <u class="paddingrightonly">'.$langs->trans("Product").'</u>';
} elseif ($this->type == Product::TYPE_SERVICE) {
$label .= img_picto('', 'service').' <u class="paddingrightonly">'.$langs->trans("Service").'</u>';
}
if (isset($this->status) && isset($this->status_buy)) {
$label .= ' '.$this->getLibStatut(5, 0);
$label .= ' '.$this->getLibStatut(5, 1);
}
if (!empty($this->ref)) {
$label .= '<br><b>'.$langs->trans('ProductRef').':</b> '.$this->ref;
}
if (!empty($this->label)) {
$label .= '<br><b>'.$langs->trans('ProductLabel').':</b> '.$this->label;
}
if ($this->type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
if (isModEnabled('productbatch')) {
$langs->load("productbatch");
$label .= "<br><b>".$langs->trans("ManageLotSerial").'</b>: '.$this->getLibStatut(0, 2);
}
}
if (isModEnabled('barcode')) {
$label .= '<br><b>'.$langs->trans('BarCode').':</b> '.$this->barcode;
}
if ($this->type == Product::TYPE_PRODUCT) {
if ($this->weight) {
$label .= "<br><b>".$langs->trans("Weight").'</b>: '.$this->weight.' '.measuringUnitString(0, "weight", $this->weight_units);
}
$labelsize = "";
if ($this->length) {
$labelsize .= ($labelsize ? " - " : "")."<b>".$langs->trans("Length").'</b>: '.$this->length.' '.measuringUnitString(0, 'size', $this->length_units);
}
if ($this->width) {
$labelsize .= ($labelsize ? " - " : "")."<b>".$langs->trans("Width").'</b>: '.$this->width.' '.measuringUnitString(0, 'size', $this->width_units);
}
if ($this->height) {
$labelsize .= ($labelsize ? " - " : "")."<b>".$langs->trans("Height").'</b>: '.$this->height.' '.measuringUnitString(0, 'size', $this->height_units);
}
if ($labelsize) {
$label .= "<br>".$labelsize;
}
$labelsurfacevolume = "";
if ($this->surface) {
$labelsurfacevolume .= ($labelsurfacevolume ? " - " : "")."<b>".$langs->trans("Surface").'</b>: '.$this->surface.' '.measuringUnitString(0, 'surface', $this->surface_units);
}
if ($this->volume) {
$labelsurfacevolume .= ($labelsurfacevolume ? " - " : "")."<b>".$langs->trans("Volume").'</b>: '.$this->volume.' '.measuringUnitString(0, 'volume', $this->volume_units);
}
if ($labelsurfacevolume) {
$label .= "<br>".$labelsurfacevolume;
}
}
if (!empty($this->pmp) && $this->pmp) {
$label .= "<br><b>".$langs->trans("PMPValue").'</b>: '.price($this->pmp, 0, '', 1, -1, -1, $conf->currency);
}
if (isModEnabled('accounting')) {
if ($this->status && isset($this->accountancy_code_sell)) {
include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
$label .= '<br>';
$label .= '<br><b>'.$langs->trans('ProductAccountancySellCode').':</b> '.length_accountg($this->accountancy_code_sell);
$label .= '<br><b>'.$langs->trans('ProductAccountancySellIntraCode').':</b> '.length_accountg($this->accountancy_code_sell_intra);
$label .= '<br><b>'.$langs->trans('ProductAccountancySellExportCode').':</b> '.length_accountg($this->accountancy_code_sell_export);
}
if ($this->status_buy && isset($this->accountancy_code_buy)) {
include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
if (empty($this->status)) {
$label .= '<br>';
}
$label .= '<br><b>'.$langs->trans('ProductAccountancyBuyCode').':</b> '.length_accountg($this->accountancy_code_buy);
$label .= '<br><b>'.$langs->trans('ProductAccountancyBuyIntraCode').':</b> '.length_accountg($this->accountancy_code_buy_intra);
$label .= '<br><b>'.$langs->trans('ProductAccountancyBuyExportCode').':</b> '.length_accountg($this->accountancy_code_buy_export);
}
}
$linkclose = '';
$params = [
'id' => $this->id,
'objecttype' => $this->element,
'option' => $option,
];
$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');
}
$label = implode($this->getTooltipContentArray($params));
$linkclose = '';
if (empty($notooltip)) {
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
$label = $langs->trans("ShowProduct");

View File

@ -739,15 +739,20 @@ class Entrepot 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("Warehouse").'</u>';
if (isset($this->statut)) {
$label .= ' '.$this->getLibStatut(5);
}
$label .= '<br><b>'.$langs->trans('Ref').':</b> '.(empty($this->ref) ? $this->label : $this->ref);
if (!empty($this->lieu)) {
$label .= '<br><b>'.$langs->trans('LocationSummary').':</b> '.$this->lieu;
}
$label = implode($this->getTooltipContentArray($params));
$url = DOL_URL_ROOT.'/product/stock/card.php?id='.$this->id;
@ -763,18 +768,6 @@ class Entrepot 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("Warehouse");

View File

@ -632,16 +632,20 @@ class Productlot extends CommonObject
global $menumanager;
$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>'.$langs->trans("Batch").'</u>';
$label .= '<div width="100%">';
$label .= '<b>'.$langs->trans('Batch').':</b> '.$this->batch;
if ($this->eatby && empty($conf->global->PRODUCT_DISABLE_EATBY)) {
$label .= '<br><b>'.$langs->trans('EatByDate').':</b> '.dol_print_date($this->eatby, 'day');
}
if ($this->sellby && empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
$label .= '<br><b>'.$langs->trans('SellByDate').':</b> '.dol_print_date($this->sellby, 'day');
}
$label = implode($this->getTooltipContentArray($params));
$url = DOL_URL_ROOT.'/product/stock/productlot_card.php?id='.$this->id;
@ -657,18 +661,6 @@ class Productlot 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("ShowMyObject");