Fixing style errors.

This commit is contained in:
stickler-ci 2019-11-21 16:24:25 +00:00
parent 1068d9a623
commit 0074589b6f

View File

@ -980,7 +980,7 @@ class Products extends DolibarrApi
} }
throw new RestException(500, "Error deleting attribute"); throw new RestException(500, "Error deleting attribute");
} }
/** /**
* Get attribute value by id. * Get attribute value by id.
* *
@ -998,30 +998,30 @@ class Products extends DolibarrApi
if(! DolibarrApiAccess::$user->rights->produit->lire) { if(! DolibarrApiAccess::$user->rights->produit->lire) {
throw new RestException(401); throw new RestException(401);
} }
$sql = "SELECT rowid, fk_product_attribute, ref, value FROM ".MAIN_DB_PREFIX."product_attribute_value WHERE rowid = ".(int) $id." AND entity IN (".getEntity('product').")"; $sql = "SELECT rowid, fk_product_attribute, ref, value FROM ".MAIN_DB_PREFIX."product_attribute_value WHERE rowid = ".(int) $id." AND entity IN (".getEntity('product').")";
$query = $this->db->query($sql); $query = $this->db->query($sql);
if (!$query) { if (!$query) {
throw new RestException(401); throw new RestException(401);
} }
if (!$this->db->num_rows($query)) { if (!$this->db->num_rows($query)) {
throw new RestException(404, 'Attribute value not found'); throw new RestException(404, 'Attribute value not found');
} }
$result = $this->db->fetch_object($query); $result = $this->db->fetch_object($query);
$attrval = []; $attrval = [];
$attrval['id'] = $result->rowid; $attrval['id'] = $result->rowid;
$attrval['fk_product_attribute'] = $result->fk_product_attribute; $attrval['fk_product_attribute'] = $result->fk_product_attribute;
$attrval['ref'] = $result->ref; $attrval['ref'] = $result->ref;
$attrval['value'] = $result->value; $attrval['value'] = $result->value;
return $attrval; return $attrval;
} }
/** /**
* Get attribute value by ref. * Get attribute value by ref.
* *
@ -1039,30 +1039,30 @@ class Products extends DolibarrApi
if(! DolibarrApiAccess::$user->rights->produit->lire) { if(! DolibarrApiAccess::$user->rights->produit->lire) {
throw new RestException(401); throw new RestException(401);
} }
$sql = "SELECT rowid, fk_product_attribute, ref, value FROM ".MAIN_DB_PREFIX."product_attribute_value WHERE ref LIKE '". trim($ref) ."' AND fk_product_attribute = ". (int) $id ." AND entity IN (".getEntity('product').")"; $sql = "SELECT rowid, fk_product_attribute, ref, value FROM ".MAIN_DB_PREFIX."product_attribute_value WHERE ref LIKE '". trim($ref) ."' AND fk_product_attribute = ". (int) $id ." AND entity IN (".getEntity('product').")";
$query = $this->db->query($sql); $query = $this->db->query($sql);
if (!$query) { if (!$query) {
throw new RestException(401); throw new RestException(401);
} }
if (!$this->db->num_rows($query)) { if (!$this->db->num_rows($query)) {
throw new RestException(404, 'Attribute value not found'); throw new RestException(404, 'Attribute value not found');
} }
$result = $this->db->fetch_object($query); $result = $this->db->fetch_object($query);
$attrval = []; $attrval = [];
$attrval['id'] = $result->rowid; $attrval['id'] = $result->rowid;
$attrval['fk_product_attribute'] = $result->fk_product_attribute; $attrval['fk_product_attribute'] = $result->fk_product_attribute;
$attrval['ref'] = $result->ref; $attrval['ref'] = $result->ref;
$attrval['value'] = $result->value; $attrval['value'] = $result->value;
return $attrval; return $attrval;
} }
/** /**
* Delete attribute value by ref. * Delete attribute value by ref.
* *
@ -1080,13 +1080,13 @@ class Products extends DolibarrApi
if(! DolibarrApiAccess::$user->rights->produit->supprimer) { if(! DolibarrApiAccess::$user->rights->produit->supprimer) {
throw new RestException(401); throw new RestException(401);
} }
$sql = "DELETE FROM ".MAIN_DB_PREFIX."product_attribute_value WHERE ref LIKE '". trim($ref) ."' AND fk_product_attribute = ". (int) $id; $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_attribute_value WHERE ref LIKE '". trim($ref) ."' AND fk_product_attribute = ". (int) $id;
if ($this->db->query($sql)) { if ($this->db->query($sql)) {
return 1; return 1;
} }
throw new RestException(500, "Error deleting attribute value"); throw new RestException(500, "Error deleting attribute value");
} }