@@ -339,7 +339,7 @@ discard block |
||
| 339 | 339 | |
| 340 | 340 | // Select products of given category |
| 341 | 341 | if ($category > 0) { |
| 342 | - $sql .= " AND c.fk_categorie = " . ((int)$category); |
|
| 342 | + $sql .= " AND c.fk_categorie = " . ((int) $category); |
|
| 343 | 343 | $sql .= " AND c.fk_product = t.rowid"; |
| 344 | 344 | } |
| 345 | 345 | if ($mode == 1) { |
@@ -418,9 +418,9 @@ discard block |
||
| 418 | 418 | |
| 419 | 419 | $obj_ret['data'] = $tmp; |
| 420 | 420 | $obj_ret['pagination'] = array( |
| 421 | - 'total' => (int)$total, |
|
| 421 | + 'total' => (int) $total, |
|
| 422 | 422 | 'page' => $page, //count starts from 0 |
| 423 | - 'page_count' => ceil((int)$total / $limit), |
|
| 423 | + 'page_count' => ceil((int) $total / $limit), |
|
| 424 | 424 | 'limit' => $limit |
| 425 | 425 | ); |
| 426 | 426 | } |
@@ -999,7 +999,7 @@ discard block |
||
| 999 | 999 | if ($result <= 0) { |
| 1000 | 1000 | throw new RestException(500, "Error updating buy price : " . $this->db->lasterror()); |
| 1001 | 1001 | } |
| 1002 | - return (int)$this->productsupplier->product_fourn_price_id; |
|
| 1002 | + return (int) $this->productsupplier->product_fourn_price_id; |
|
| 1003 | 1003 | } |
| 1004 | 1004 | |
| 1005 | 1005 | /** |
@@ -1082,15 +1082,15 @@ discard block |
||
| 1082 | 1082 | $sql .= ' WHERE t.entity IN (' . getEntity('product') . ')'; |
| 1083 | 1083 | |
| 1084 | 1084 | if ($supplier > 0) { |
| 1085 | - $sql .= " AND s.fk_soc = " . ((int)$supplier); |
|
| 1085 | + $sql .= " AND s.fk_soc = " . ((int) $supplier); |
|
| 1086 | 1086 | } |
| 1087 | 1087 | if ($socid > 0) { // if external user |
| 1088 | - $sql .= " AND s.fk_soc = " . ((int)$socid); |
|
| 1088 | + $sql .= " AND s.fk_soc = " . ((int) $socid); |
|
| 1089 | 1089 | } |
| 1090 | 1090 | $sql .= " AND s.fk_product = t.rowid"; |
| 1091 | 1091 | // Select products of given category |
| 1092 | 1092 | if ($category > 0) { |
| 1093 | - $sql .= " AND c.fk_categorie = " . ((int)$category); |
|
| 1093 | + $sql .= " AND c.fk_categorie = " . ((int) $category); |
|
| 1094 | 1094 | $sql .= " AND c.fk_product = t.rowid"; |
| 1095 | 1095 | } |
| 1096 | 1096 | if ($mode == 1) { |
@@ -1285,7 +1285,7 @@ discard block |
||
| 1285 | 1285 | } |
| 1286 | 1286 | |
| 1287 | 1287 | $prodattr = new ProductAttribute($this->db); |
| 1288 | - $result = $prodattr->fetch((int)$id); |
|
| 1288 | + $result = $prodattr->fetch((int) $id); |
|
| 1289 | 1289 | |
| 1290 | 1290 | if ($result < 0) { |
| 1291 | 1291 | throw new RestException(404, "Product attribute not found"); |
@@ -1301,11 +1301,11 @@ discard block |
||
| 1301 | 1301 | |
| 1302 | 1302 | $sql = "SELECT COUNT(*) as nb FROM " . $this->db->prefix() . "product_attribute_combination2val as pac2v"; |
| 1303 | 1303 | $sql .= " JOIN " . $this->db->prefix() . "product_attribute_combination as pac ON pac2v.fk_prod_combination = pac.rowid"; |
| 1304 | - $sql .= " WHERE pac2v.fk_prod_attr = " . ((int)$prodattr->id) . " AND pac.entity IN (" . getEntity('product') . ")"; |
|
| 1304 | + $sql .= " WHERE pac2v.fk_prod_attr = " . ((int) $prodattr->id) . " AND pac.entity IN (" . getEntity('product') . ")"; |
|
| 1305 | 1305 | |
| 1306 | 1306 | $resql = $this->db->query($sql); |
| 1307 | 1307 | $obj = $this->db->fetch_object($resql); |
| 1308 | - $prodattr->is_used_by_products = (int)$obj->nb; |
|
| 1308 | + $prodattr->is_used_by_products = (int) $obj->nb; |
|
| 1309 | 1309 | |
| 1310 | 1310 | return $this->_cleanObjectDatas($prodattr); |
| 1311 | 1311 | } |
@@ -1350,12 +1350,12 @@ discard block |
||
| 1350 | 1350 | |
| 1351 | 1351 | $sql = "SELECT COUNT(*) as nb FROM " . $this->db->prefix() . "product_attribute_combination2val as pac2v"; |
| 1352 | 1352 | $sql .= " JOIN " . $this->db->prefix() . "product_attribute_combination as pac ON pac2v.fk_prod_combination = pac.rowid"; |
| 1353 | - $sql .= " WHERE pac2v.fk_prod_attr = " . ((int)$result->rowid) . " AND pac.entity IN (" . getEntity('product') . ")"; |
|
| 1353 | + $sql .= " WHERE pac2v.fk_prod_attr = " . ((int) $result->rowid) . " AND pac.entity IN (" . getEntity('product') . ")"; |
|
| 1354 | 1354 | |
| 1355 | 1355 | $resql = $this->db->query($sql); |
| 1356 | 1356 | $obj = $this->db->fetch_object($resql); |
| 1357 | 1357 | |
| 1358 | - $attr["is_used_by_products"] = (int)$obj->nb; |
|
| 1358 | + $attr["is_used_by_products"] = (int) $obj->nb; |
|
| 1359 | 1359 | |
| 1360 | 1360 | return $attr; |
| 1361 | 1361 | } |
@@ -1400,12 +1400,12 @@ discard block |
||
| 1400 | 1400 | |
| 1401 | 1401 | $sql = "SELECT COUNT(*) as nb FROM " . $this->db->prefix() . "product_attribute_combination2val as pac2v"; |
| 1402 | 1402 | $sql .= " JOIN " . $this->db->prefix() . "product_attribute_combination as pac ON pac2v.fk_prod_combination = pac.rowid"; |
| 1403 | - $sql .= " WHERE pac2v.fk_prod_attr = " . ((int)$result->rowid) . " AND pac.entity IN (" . getEntity('product') . ")"; |
|
| 1403 | + $sql .= " WHERE pac2v.fk_prod_attr = " . ((int) $result->rowid) . " AND pac.entity IN (" . getEntity('product') . ")"; |
|
| 1404 | 1404 | |
| 1405 | 1405 | $resql = $this->db->query($sql); |
| 1406 | 1406 | $obj = $this->db->fetch_object($resql); |
| 1407 | 1407 | |
| 1408 | - $attr["is_used_by_products"] = (int)$obj->nb; |
|
| 1408 | + $attr["is_used_by_products"] = (int) $obj->nb; |
|
| 1409 | 1409 | |
| 1410 | 1410 | return $attr; |
| 1411 | 1411 | } |
@@ -1463,7 +1463,7 @@ discard block |
||
| 1463 | 1463 | |
| 1464 | 1464 | $prodattr = new ProductAttribute($this->db); |
| 1465 | 1465 | |
| 1466 | - $result = $prodattr->fetch((int)$id); |
|
| 1466 | + $result = $prodattr->fetch((int) $id); |
|
| 1467 | 1467 | if ($result == 0) { |
| 1468 | 1468 | throw new RestException(404, 'Attribute not found'); |
| 1469 | 1469 | } elseif ($result < 0) { |
@@ -1484,7 +1484,7 @@ discard block |
||
| 1484 | 1484 | } |
| 1485 | 1485 | |
| 1486 | 1486 | if ($prodattr->update(DolibarrApiAccess::$user) > 0) { |
| 1487 | - $result = $prodattr->fetch((int)$id); |
|
| 1487 | + $result = $prodattr->fetch((int) $id); |
|
| 1488 | 1488 | if ($result == 0) { |
| 1489 | 1489 | throw new RestException(404, 'Attribute not found'); |
| 1490 | 1490 | } elseif ($result < 0) { |
@@ -1514,7 +1514,7 @@ discard block |
||
| 1514 | 1514 | } |
| 1515 | 1515 | |
| 1516 | 1516 | $prodattr = new ProductAttribute($this->db); |
| 1517 | - $prodattr->id = (int)$id; |
|
| 1517 | + $prodattr->id = (int) $id; |
|
| 1518 | 1518 | $result = $prodattr->delete(DolibarrApiAccess::$user); |
| 1519 | 1519 | |
| 1520 | 1520 | if ($result <= 0) { |
@@ -1580,7 +1580,7 @@ discard block |
||
| 1580 | 1580 | throw new RestException(403); |
| 1581 | 1581 | } |
| 1582 | 1582 | |
| 1583 | - $sql = "SELECT rowid, fk_product_attribute, ref, value FROM " . $this->db->prefix() . "product_attribute_value WHERE rowid = " . (int)$id . " AND entity IN (" . getEntity('product') . ")"; |
|
| 1583 | + $sql = "SELECT rowid, fk_product_attribute, ref, value FROM " . $this->db->prefix() . "product_attribute_value WHERE rowid = " . (int) $id . " AND entity IN (" . getEntity('product') . ")"; |
|
| 1584 | 1584 | |
| 1585 | 1585 | $query = $this->db->query($sql); |
| 1586 | 1586 | |
@@ -1624,7 +1624,7 @@ discard block |
||
| 1624 | 1624 | $ref = trim($ref); |
| 1625 | 1625 | |
| 1626 | 1626 | $sql = "SELECT rowid, fk_product_attribute, ref, value FROM " . $this->db->prefix() . "product_attribute_value"; |
| 1627 | - $sql .= " WHERE ref LIKE '" . $this->db->escape($ref) . "' AND fk_product_attribute = " . ((int)$id) . " AND entity IN (" . getEntity('product') . ")"; |
|
| 1627 | + $sql .= " WHERE ref LIKE '" . $this->db->escape($ref) . "' AND fk_product_attribute = " . ((int) $id) . " AND entity IN (" . getEntity('product') . ")"; |
|
| 1628 | 1628 | |
| 1629 | 1629 | $query = $this->db->query($sql); |
| 1630 | 1630 | |
@@ -1667,7 +1667,7 @@ discard block |
||
| 1667 | 1667 | $ref = trim($ref); |
| 1668 | 1668 | |
| 1669 | 1669 | $sql = "SELECT rowid FROM " . $this->db->prefix() . "product_attribute_value"; |
| 1670 | - $sql .= " WHERE ref LIKE '" . $this->db->escape($ref) . "' AND fk_product_attribute = " . ((int)$id) . " AND entity IN (" . getEntity('product') . ")"; |
|
| 1670 | + $sql .= " WHERE ref LIKE '" . $this->db->escape($ref) . "' AND fk_product_attribute = " . ((int) $id) . " AND entity IN (" . getEntity('product') . ")"; |
|
| 1671 | 1671 | $query = $this->db->query($sql); |
| 1672 | 1672 | |
| 1673 | 1673 | if (!$query) { |
@@ -1709,7 +1709,7 @@ discard block |
||
| 1709 | 1709 | |
| 1710 | 1710 | $objectval = new ProductAttributeValue($this->db); |
| 1711 | 1711 | |
| 1712 | - $return = $objectval->fetchAllByProductAttribute((int)$id); |
|
| 1712 | + $return = $objectval->fetchAllByProductAttribute((int) $id); |
|
| 1713 | 1713 | |
| 1714 | 1714 | if (count($return) == 0) { |
| 1715 | 1715 | throw new RestException(404, 'Attribute values not found'); |
@@ -1785,7 +1785,7 @@ discard block |
||
| 1785 | 1785 | } |
| 1786 | 1786 | |
| 1787 | 1787 | $objectval = new ProductAttributeValue($this->db); |
| 1788 | - $objectval->fk_product_attribute = ((int)$id); |
|
| 1788 | + $objectval->fk_product_attribute = ((int) $id); |
|
| 1789 | 1789 | $objectval->ref = $ref; |
| 1790 | 1790 | $objectval->value = $value; |
| 1791 | 1791 | |
@@ -1814,7 +1814,7 @@ discard block |
||
| 1814 | 1814 | } |
| 1815 | 1815 | |
| 1816 | 1816 | $objectval = new ProductAttributeValue($this->db); |
| 1817 | - $result = $objectval->fetch((int)$id); |
|
| 1817 | + $result = $objectval->fetch((int) $id); |
|
| 1818 | 1818 | |
| 1819 | 1819 | if ($result == 0) { |
| 1820 | 1820 | throw new RestException(404, 'Attribute value not found'); |
@@ -1836,7 +1836,7 @@ discard block |
||
| 1836 | 1836 | } |
| 1837 | 1837 | |
| 1838 | 1838 | if ($objectval->update(DolibarrApiAccess::$user) > 0) { |
| 1839 | - $result = $objectval->fetch((int)$id); |
|
| 1839 | + $result = $objectval->fetch((int) $id); |
|
| 1840 | 1840 | if ($result == 0) { |
| 1841 | 1841 | throw new RestException(404, 'Attribute not found'); |
| 1842 | 1842 | } elseif ($result < 0) { |
@@ -1866,7 +1866,7 @@ discard block |
||
| 1866 | 1866 | } |
| 1867 | 1867 | |
| 1868 | 1868 | $objectval = new ProductAttributeValue($this->db); |
| 1869 | - $objectval->id = (int)$id; |
|
| 1869 | + $objectval->id = (int) $id; |
|
| 1870 | 1870 | |
| 1871 | 1871 | if ($objectval->delete(DolibarrApiAccess::$user) > 0) { |
| 1872 | 1872 | return 1; |
@@ -1893,16 +1893,16 @@ discard block |
||
| 1893 | 1893 | } |
| 1894 | 1894 | |
| 1895 | 1895 | $prodcomb = new ProductAttributeCombination($this->db); |
| 1896 | - $combinations = $prodcomb->fetchAllByFkProductParent((int)$id); |
|
| 1896 | + $combinations = $prodcomb->fetchAllByFkProductParent((int) $id); |
|
| 1897 | 1897 | |
| 1898 | 1898 | foreach ($combinations as $key => $combination) { |
| 1899 | 1899 | $prodc2vp = new ProductCombination2ValuePair($this->db); |
| 1900 | - $combinations[$key]->attributes = $prodc2vp->fetchByFkCombination((int)$combination->id); |
|
| 1900 | + $combinations[$key]->attributes = $prodc2vp->fetchByFkCombination((int) $combination->id); |
|
| 1901 | 1901 | $combinations[$key] = $this->_cleanObjectDatas($combinations[$key]); |
| 1902 | 1902 | |
| 1903 | 1903 | if (!empty($includestock) && DolibarrApiAccess::$user->hasRight('stock', 'lire')) { |
| 1904 | 1904 | $productModel = new Product($this->db); |
| 1905 | - $productModel->fetch((int)$combination->fk_product_child); |
|
| 1905 | + $productModel->fetch((int) $combination->fk_product_child); |
|
| 1906 | 1906 | $productModel->load_stock($includestock); |
| 1907 | 1907 | $combinations[$key]->stock_warehouse = $this->_cleanObjectDatas($productModel)->stock_warehouse; |
| 1908 | 1908 | } |
@@ -1934,11 +1934,11 @@ discard block |
||
| 1934 | 1934 | } |
| 1935 | 1935 | |
| 1936 | 1936 | $prodcomb = new ProductAttributeCombination($this->db); |
| 1937 | - $combinations = $prodcomb->fetchAllByFkProductParent((int)$this->product->id); |
|
| 1937 | + $combinations = $prodcomb->fetchAllByFkProductParent((int) $this->product->id); |
|
| 1938 | 1938 | |
| 1939 | 1939 | foreach ($combinations as $key => $combination) { |
| 1940 | 1940 | $prodc2vp = new ProductCombination2ValuePair($this->db); |
| 1941 | - $combinations[$key]->attributes = $prodc2vp->fetchByFkCombination((int)$combination->id); |
|
| 1941 | + $combinations[$key]->attributes = $prodc2vp->fetchByFkCombination((int) $combination->id); |
|
| 1942 | 1942 | $combinations[$key] = $this->_cleanObjectDatas($combinations[$key]); |
| 1943 | 1943 | } |
| 1944 | 1944 | |
@@ -1985,15 +1985,15 @@ discard block |
||
| 1985 | 1985 | $prodattr = new ProductAttribute($this->db); |
| 1986 | 1986 | $prodattr_val = new ProductAttributeValue($this->db); |
| 1987 | 1987 | foreach ($features as $id_attr => $id_value) { |
| 1988 | - if ($prodattr->fetch((int)$id_attr) < 0) { |
|
| 1988 | + if ($prodattr->fetch((int) $id_attr) < 0) { |
|
| 1989 | 1989 | throw new RestException(400, 'Invalid attribute ID: ' . $id_attr); |
| 1990 | 1990 | } |
| 1991 | - if ($prodattr_val->fetch((int)$id_value) < 0) { |
|
| 1991 | + if ($prodattr_val->fetch((int) $id_value) < 0) { |
|
| 1992 | 1992 | throw new RestException(400, 'Invalid attribute value ID: ' . $id_value); |
| 1993 | 1993 | } |
| 1994 | 1994 | } |
| 1995 | 1995 | |
| 1996 | - $result = $this->product->fetch((int)$id); |
|
| 1996 | + $result = $this->product->fetch((int) $id); |
|
| 1997 | 1997 | if (!$result) { |
| 1998 | 1998 | throw new RestException(404, 'Product not found'); |
| 1999 | 1999 | } |
@@ -2042,10 +2042,10 @@ discard block |
||
| 2042 | 2042 | $prodattr = new ProductAttribute($this->db); |
| 2043 | 2043 | $prodattr_val = new ProductAttributeValue($this->db); |
| 2044 | 2044 | foreach ($features as $id_attr => $id_value) { |
| 2045 | - if ($prodattr->fetch((int)$id_attr) < 0) { |
|
| 2045 | + if ($prodattr->fetch((int) $id_attr) < 0) { |
|
| 2046 | 2046 | throw new RestException(404); |
| 2047 | 2047 | } |
| 2048 | - if ($prodattr_val->fetch((int)$id_value) < 0) { |
|
| 2048 | + if ($prodattr_val->fetch((int) $id_value) < 0) { |
|
| 2049 | 2049 | throw new RestException(404); |
| 2050 | 2050 | } |
| 2051 | 2051 | } |
@@ -2089,7 +2089,7 @@ discard block |
||
| 2089 | 2089 | } |
| 2090 | 2090 | |
| 2091 | 2091 | $prodcomb = new ProductAttributeCombination($this->db); |
| 2092 | - $prodcomb->fetch((int)$id); |
|
| 2092 | + $prodcomb->fetch((int) $id); |
|
| 2093 | 2093 | |
| 2094 | 2094 | foreach ($request_data as $field => $value) { |
| 2095 | 2095 | if ($field == 'rowid') { |
@@ -2129,7 +2129,7 @@ discard block |
||
| 2129 | 2129 | } |
| 2130 | 2130 | |
| 2131 | 2131 | $prodcomb = new ProductAttributeCombination($this->db); |
| 2132 | - $prodcomb->id = (int)$id; |
|
| 2132 | + $prodcomb->id = (int) $id; |
|
| 2133 | 2133 | $result = $prodcomb->delete(DolibarrApiAccess::$user); |
| 2134 | 2134 | if ($result <= 0) { |
| 2135 | 2135 | throw new RestException(500, "Error deleting variant"); |