Merge branch '12.0' of git@github.com:Dolibarr/dolibarr.git into 12.0
This commit is contained in:
commit
c40ec37b60
@ -51,10 +51,10 @@ abstract class CommonObjectLine extends CommonObject
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the translation key from units dictionary.
|
* Returns the label, shot_label or code found in units dictionary from ->fk_unit.
|
||||||
* A langs->trans() must be called on result to get translated value.
|
* A langs->trans() must be called on result to get translated value.
|
||||||
*
|
*
|
||||||
* @param string $type Label type (long or short). This can be a translation key.
|
* @param string $type Label type (long, short or code). This can be a translation key.
|
||||||
* @return string|int <0 if ko, label if ok
|
* @return string|int <0 if ko, label if ok
|
||||||
*/
|
*/
|
||||||
public function getLabelOfUnit($type = 'long')
|
public function getLabelOfUnit($type = 'long')
|
||||||
@ -69,17 +69,16 @@ abstract class CommonObjectLine extends CommonObject
|
|||||||
|
|
||||||
$label_type = 'label';
|
$label_type = 'label';
|
||||||
|
|
||||||
if ($type == 'short')
|
$label_type = 'label';
|
||||||
{
|
if ($type == 'short') $label_type = 'short_label';
|
||||||
$label_type = 'short_label';
|
elseif ($type == 'code') $label_type = 'code';
|
||||||
}
|
|
||||||
|
|
||||||
$sql = 'select '.$label_type.',code from '.MAIN_DB_PREFIX.'c_units where rowid='.$this->fk_unit;
|
$sql = 'select '.$label_type.', code from '.MAIN_DB_PREFIX.'c_units where rowid='.$this->fk_unit;
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql && $this->db->num_rows($resql) > 0)
|
if ($resql && $this->db->num_rows($resql) > 0) {
|
||||||
{
|
|
||||||
$res = $this->db->fetch_array($resql);
|
$res = $this->db->fetch_array($resql);
|
||||||
$label = ($label_type == 'short' ? $res[$label_type] : 'unit'.$res['code']);
|
if ($label_type == 'code') $label = 'unit'.$res['code'];
|
||||||
|
else $label = $res[$label_type];
|
||||||
$this->db->free($resql);
|
$this->db->free($resql);
|
||||||
return $label;
|
return $label;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5367,10 +5367,12 @@ class Product extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the text label from units dictionary
|
* Returns the label, shot_label or code found in units dictionary from ->fk_unit.
|
||||||
|
* A langs->trans() must be called on result to get translated value.
|
||||||
*
|
*
|
||||||
* @param string $type Label type (long or short)
|
* @param string $type Label type (long, short or code)
|
||||||
* @return string|int <0 if ko, label if ok
|
* @return string|int <0 if ko, label if ok
|
||||||
|
* @see getLabelOfUnit() in CommonObjectLine
|
||||||
*/
|
*/
|
||||||
public function getLabelOfUnit($type = 'long')
|
public function getLabelOfUnit($type = 'long')
|
||||||
{
|
{
|
||||||
@ -5383,16 +5385,15 @@ class Product extends CommonObject
|
|||||||
$langs->load('products');
|
$langs->load('products');
|
||||||
|
|
||||||
$label_type = 'label';
|
$label_type = 'label';
|
||||||
|
if ($type == 'short') $label_type = 'short_label';
|
||||||
if ($type == 'short') {
|
elseif ($type == 'code') $label_type = 'code';
|
||||||
$label_type = 'short_label';
|
|
||||||
}
|
|
||||||
|
|
||||||
$sql = 'select '.$label_type.', code from '.MAIN_DB_PREFIX.'c_units where rowid='.$this->fk_unit;
|
$sql = 'select '.$label_type.', code from '.MAIN_DB_PREFIX.'c_units where rowid='.$this->fk_unit;
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql && $this->db->num_rows($resql) > 0) {
|
if ($resql && $this->db->num_rows($resql) > 0) {
|
||||||
$res = $this->db->fetch_array($resql);
|
$res = $this->db->fetch_array($resql);
|
||||||
$label = ($label_type == 'short_label' ? $res[$label_type] : 'unit'.$res['code']);
|
if ($label_type == 'code') $label = 'unit'.$res['code'];
|
||||||
|
else $label = $res[$label_type];
|
||||||
$this->db->free($resql);
|
$this->db->free($resql);
|
||||||
return $label;
|
return $label;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user