qual: better phpdoc and use of isProduct(), isService() and isStockManaged() (#30405)
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
parent
7a57b704cc
commit
df1f9bc0bc
1 changed files with 24 additions and 24 deletions
|
|
@ -1525,7 +1525,7 @@ class Product extends CommonObject
|
|||
$this->error = "Object must be fetched before calling delete";
|
||||
return -1;
|
||||
}
|
||||
if (($this->type == Product::TYPE_PRODUCT && !$user->hasRight('produit', 'supprimer')) || ($this->type == Product::TYPE_SERVICE && !$user->hasRight('service', 'supprimer'))) {
|
||||
if (($this->isProduct() && !$user->hasRight('produit', 'supprimer')) || ($this->isService() && !$user->hasRight('service', 'supprimer'))) {
|
||||
$this->error = "ErrorForbidden";
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -5335,9 +5335,9 @@ class Product extends CommonObject
|
|||
}
|
||||
}
|
||||
|
||||
if ($this->type == Product::TYPE_PRODUCT) {
|
||||
if ($this->isProduct()) {
|
||||
$datas['picto'] = img_picto('', 'product').' <u class="paddingrightonly">'.$langs->trans("Product").'</u>';
|
||||
} elseif ($this->type == Product::TYPE_SERVICE) {
|
||||
} elseif ($this->isService()) {
|
||||
$datas['picto'] = img_picto('', 'service').' <u class="paddingrightonly">'.$langs->trans("Service").'</u>';
|
||||
}
|
||||
if (isset($this->status) && isset($this->status_buy)) {
|
||||
|
|
@ -5353,7 +5353,7 @@ class Product extends CommonObject
|
|||
if (!empty($this->description)) {
|
||||
$datas['description'] = '<br><b>'.$langs->trans('ProductDescription').':</b> '.dolGetFirstLineOfText($this->description, 5);
|
||||
}
|
||||
if ($this->type == Product::TYPE_PRODUCT || getDolGlobalString('STOCK_SUPPORTS_SERVICES')) {
|
||||
if ($this->isStockManaged()) {
|
||||
if (isModEnabled('productbatch')) {
|
||||
$langs->load("productbatch");
|
||||
$datas['batchstatus'] = "<br><b>".$langs->trans("ManageLotSerial").'</b>: '.$this->getLibStatut(0, 2);
|
||||
|
|
@ -5363,7 +5363,7 @@ class Product extends CommonObject
|
|||
$datas['barcode'] = '<br><b>'.$langs->trans('BarCode').':</b> '.$this->barcode;
|
||||
}
|
||||
|
||||
if ($this->type == Product::TYPE_PRODUCT) {
|
||||
if ($this->isProduct()) {
|
||||
if ($this->weight) {
|
||||
$datas['weight'] = "<br><b>".$langs->trans("Weight").'</b>: '.$this->weight.' '.measuringUnitString(0, "weight", $this->weight_units);
|
||||
}
|
||||
|
|
@ -5392,7 +5392,7 @@ class Product extends CommonObject
|
|||
$datas['surface'] = "<br>" . $labelsurfacevolume;
|
||||
}
|
||||
}
|
||||
if ($this->type == Product::TYPE_SERVICE && !empty($this->duration_value)) {
|
||||
if ($this->isService() && !empty($this->duration_value)) {
|
||||
// Duration
|
||||
$datas['duration'] = '<br><b>'.$langs->trans("Duration").':</b> '.$this->duration_value;
|
||||
if ($this->duration_value > 1) {
|
||||
|
|
@ -5518,10 +5518,10 @@ class Product extends CommonObject
|
|||
|
||||
$result .= $linkstart;
|
||||
if ($withpicto) {
|
||||
if ($this->type == Product::TYPE_PRODUCT) {
|
||||
if ($this->isProduct()) {
|
||||
$result .= (img_object(($notooltip ? '' : $label), 'product', 'class="paddingright"', 0, 0, $notooltip ? 0 : 1));
|
||||
}
|
||||
if ($this->type == Product::TYPE_SERVICE) {
|
||||
if ($this->isService()) {
|
||||
$result .= (img_object(($notooltip ? '' : $label), 'service', 'class="paddingright"', 0, 0, $notooltip ? 0 : 1));
|
||||
}
|
||||
}
|
||||
|
|
@ -6318,29 +6318,29 @@ class Product extends CommonObject
|
|||
}
|
||||
|
||||
/**
|
||||
* Return if object is a product.
|
||||
* Return if the object is a product.
|
||||
*
|
||||
* @return boolean True if it's a product
|
||||
* @return boolean True if the object is a product, false otherwise.
|
||||
*/
|
||||
public function isProduct()
|
||||
{
|
||||
return ($this->type == Product::TYPE_PRODUCT ? true : false);
|
||||
return $this->type == Product::TYPE_PRODUCT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return if object is a product
|
||||
* Return if the object is a service.
|
||||
*
|
||||
* @return boolean True if it's a service
|
||||
* @return boolean True if the object is a service, false otherwise.
|
||||
*/
|
||||
public function isService()
|
||||
{
|
||||
return ($this->type == Product::TYPE_SERVICE ? true : false);
|
||||
return $this->type == Product::TYPE_SERVICE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return if object need to have its stock managed
|
||||
* Return if the object is managed in stock.
|
||||
*
|
||||
* @return boolean True if it's a service
|
||||
* @return boolean True if the object is managed in stock, false otherwise.
|
||||
*/
|
||||
public function isStockManaged()
|
||||
{
|
||||
|
|
@ -6348,23 +6348,23 @@ class Product extends CommonObject
|
|||
}
|
||||
|
||||
/**
|
||||
* Return if object have a constraint on mandatory_period
|
||||
* Return if the object has a constraint on mandatory_period
|
||||
*
|
||||
* @return boolean True if mandatory_period set to 1
|
||||
* @return boolean True if mandatory_period is set to 1, false otherwise.
|
||||
*/
|
||||
public function isMandatoryPeriod()
|
||||
{
|
||||
return ($this->mandatory_period == 1 ? true : false);
|
||||
return $this->mandatory_period == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return if object has a sell-by date or eat-by date
|
||||
* Return if the object has a sell-by or eat-by date.
|
||||
*
|
||||
* @return boolean True if it's has
|
||||
* @return boolean True if the object has a sell-by or eat-by date, false otherwise.
|
||||
*/
|
||||
public function hasbatch()
|
||||
{
|
||||
return ($this->status_batch > 0 ? true : false);
|
||||
return $this->status_batch > 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -6726,9 +6726,9 @@ class Product extends CommonObject
|
|||
$label .= $this->show_photos('product', $conf->product->multidir_output[$this->entity], 1, 1, 0, 0, 0, 120, 160, 0, 0, 0, '', 'photoref photokanban');
|
||||
$return .= $label;
|
||||
} else {
|
||||
if ($this->type == Product::TYPE_PRODUCT) {
|
||||
if ($this->isProduct()) {
|
||||
$label .= img_picto('', 'product');
|
||||
} elseif ($this->type == Product::TYPE_SERVICE) {
|
||||
} elseif ($this->isService()) {
|
||||
$label .= img_picto('', 'service');
|
||||
}
|
||||
$return .= $label;
|
||||
|
|
|
|||
Loading…
Reference in a new issue