@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | if ($search_sale == -2) { |
105 | 105 | $sql .= " AND NOT EXISTS (SELECT sc.fk_soc FROM " . MAIN_DB_PREFIX . "societe_commerciaux as sc WHERE sc.fk_soc = p.fk_soc)"; |
106 | 106 | } elseif ($search_sale > 0) { |
107 | - $sql .= " AND EXISTS (SELECT sc.fk_soc FROM " . MAIN_DB_PREFIX . "societe_commerciaux as sc WHERE sc.fk_soc = p.fk_soc AND sc.fk_user = " . ((int)$search_sale) . ")"; |
|
107 | + $sql .= " AND EXISTS (SELECT sc.fk_soc FROM " . MAIN_DB_PREFIX . "societe_commerciaux as sc WHERE sc.fk_soc = p.fk_soc AND sc.fk_user = " . ((int) $search_sale) . ")"; |
|
108 | 108 | } |
109 | 109 | } |
110 | 110 | // Add sql filters |
@@ -498,7 +498,7 @@ discard block |
||
498 | 498 | } |
499 | 499 | if ($field == 'array_options' && is_array($value)) { |
500 | 500 | foreach ($value as $index => $val) { |
501 | - $this->task->array_options[$index] = $this->_checkValForAPI($field, $val, $this->task);; |
|
501 | + $this->task->array_options[$index] = $this->_checkValForAPI($field, $val, $this->task); ; |
|
502 | 502 | } |
503 | 503 | continue; |
504 | 504 | } |
@@ -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 ProductCombination($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 ProductCombination($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 ProductCombination($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 ProductCombination($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"); |
@@ -99,9 +99,9 @@ discard block |
||
99 | 99 | */ |
100 | 100 | public $revenuestamp; |
101 | 101 | |
102 | - public $totalpaid; // duplicate with sumpayed |
|
103 | - public $totaldeposits; // duplicate with sumdeposit |
|
104 | - public $totalcreditnotes; // duplicate with sumcreditnote |
|
102 | + public $totalpaid; // duplicate with sumpayed |
|
103 | + public $totaldeposits; // duplicate with sumdeposit |
|
104 | + public $totalcreditnotes; // duplicate with sumcreditnote |
|
105 | 105 | |
106 | 106 | public $sumpayed; |
107 | 107 | public $sumpayed_multicurrency; |
@@ -1141,7 +1141,7 @@ discard block |
||
1141 | 1141 | |
1142 | 1142 | if ($this->status > self::STATUS_DRAFT && $this->paye == 0) { |
1143 | 1143 | // Get the default payment mode for BAN payment of the third party |
1144 | - $bac = new CompanyBankAccount($this->db); // Table societe_rib |
|
1144 | + $bac = new CompanyBankAccount($this->db); // Table societe_rib |
|
1145 | 1145 | $result = $bac->fetch(0, '', $this->socid, 1, 'ban'); |
1146 | 1146 | if ($result <= 0 || empty($bac->id)) { |
1147 | 1147 | $this->error = $langs->trans("ThirdpartyHasNoDefaultBanAccount"); |
@@ -1155,16 +1155,16 @@ discard block |
||
1155 | 1155 | $sql .= " FROM " . $this->db->prefix() . "prelevement_demande"; |
1156 | 1156 | $sql .= " WHERE rowid = " . ((int) $did); |
1157 | 1157 | if ($type != 'bank-transfer' && $type != 'credit-transfer') { |
1158 | - $sql .= " AND fk_facture = " . ((int) $this->id); // Add a protection to not pay another invoice than current one |
|
1158 | + $sql .= " AND fk_facture = " . ((int) $this->id); // Add a protection to not pay another invoice than current one |
|
1159 | 1159 | } |
1160 | 1160 | if ($type != 'direct-debit') { |
1161 | 1161 | if ($sourcetype == 'salary') { |
1162 | - $sql .= " AND fk_salary = " . ((int) $this->id); // Add a protection to not pay another salary than current one |
|
1162 | + $sql .= " AND fk_salary = " . ((int) $this->id); // Add a protection to not pay another salary than current one |
|
1163 | 1163 | } else { |
1164 | - $sql .= " AND fk_facture_fourn = " . ((int) $this->id); // Add a protection to not pay another invoice than current one |
|
1164 | + $sql .= " AND fk_facture_fourn = " . ((int) $this->id); // Add a protection to not pay another invoice than current one |
|
1165 | 1165 | } |
1166 | 1166 | } |
1167 | - $sql .= " AND traite = 0"; // To not process payment request that were already converted into a direct debit or credit transfer order (Note: fk_prelevement_bons is also empty when traite = 0) |
|
1167 | + $sql .= " AND traite = 0"; // To not process payment request that were already converted into a direct debit or credit transfer order (Note: fk_prelevement_bons is also empty when traite = 0) |
|
1168 | 1168 | |
1169 | 1169 | dol_syslog(get_class($this) . "::makeStripeSepaRequest load requests to process", LOG_DEBUG); |
1170 | 1170 | $resql = $this->db->query($sql); |
@@ -1180,7 +1180,7 @@ discard block |
||
1180 | 1180 | |
1181 | 1181 | if (is_numeric($amount) && $amount != 0) { |
1182 | 1182 | require_once constant('DOL_DOCUMENT_ROOT') . '/societe/class/companypaymentmode.class.php'; |
1183 | - $companypaymentmode = new CompanyPaymentMode($this->db); // table societe_rib |
|
1183 | + $companypaymentmode = new CompanyPaymentMode($this->db); // table societe_rib |
|
1184 | 1184 | $companypaymentmode->fetch($bac->id); |
1185 | 1185 | |
1186 | 1186 | $this->stripechargedone = 0; |
@@ -1190,7 +1190,7 @@ discard block |
||
1190 | 1190 | |
1191 | 1191 | $currency = $conf->currency; |
1192 | 1192 | |
1193 | - $errorforinvoice = 0; // We reset the $errorforinvoice at each invoice loop |
|
1193 | + $errorforinvoice = 0; // We reset the $errorforinvoice at each invoice loop |
|
1194 | 1194 | |
1195 | 1195 | $this->fetch_thirdparty(); |
1196 | 1196 | |
@@ -1209,7 +1209,7 @@ discard block |
||
1209 | 1209 | $amountstripe = $amountstripe * 100; |
1210 | 1210 | } |
1211 | 1211 | |
1212 | - $fk_bank_account = getDolGlobalInt('STRIPE_BANK_ACCOUNT_FOR_PAYMENTS'); // Bank account used for SEPA direct debit or credit transfer. Must be the Stripe account in Dolibarr. |
|
1212 | + $fk_bank_account = getDolGlobalInt('STRIPE_BANK_ACCOUNT_FOR_PAYMENTS'); // Bank account used for SEPA direct debit or credit transfer. Must be the Stripe account in Dolibarr. |
|
1213 | 1213 | if (!($fk_bank_account > 0)) { |
1214 | 1214 | $error++; |
1215 | 1215 | $errorforinvoice++; |
@@ -1270,7 +1270,7 @@ discard block |
||
1270 | 1270 | $thirdparty = new Societe($this->db); |
1271 | 1271 | $resultthirdparty = $thirdparty->fetch($this->socid); |
1272 | 1272 | |
1273 | - include_once DOL_DOCUMENT_ROOT . '/stripe/class/stripe.class.php'; // This include the include of htdocs/stripe/config.php |
|
1273 | + include_once DOL_DOCUMENT_ROOT . '/stripe/class/stripe.class.php'; // This include the include of htdocs/stripe/config.php |
|
1274 | 1274 | // So it inits or erases the $stripearrayofkeysbyenv |
1275 | 1275 | $stripe = new Stripe($this->db); |
1276 | 1276 | |
@@ -1283,26 +1283,26 @@ discard block |
||
1283 | 1283 | $foundalternativestripeaccount = ''; |
1284 | 1284 | |
1285 | 1285 | // Force stripe to another value (by default this value is empty) |
1286 | - if (! empty($forcestripe)) { |
|
1286 | + if (!empty($forcestripe)) { |
|
1287 | 1287 | dol_syslog("makeStripeSepaRequest A dedicated stripe account was forced, so we switch to it."); |
1288 | 1288 | |
1289 | 1289 | $tmparray = explode('@', $forcestripe); |
1290 | - if (! empty($tmparray[1])) { |
|
1290 | + if (!empty($tmparray[1])) { |
|
1291 | 1291 | $tmparray2 = explode(':', $tmparray[1]); |
1292 | - if (! empty($tmparray2[1])) { |
|
1292 | + if (!empty($tmparray2[1])) { |
|
1293 | 1293 | $stripearrayofkeysbyenv[$servicestatus]["publishable_key"] = $tmparray2[0]; |
1294 | 1294 | $stripearrayofkeysbyenv[$servicestatus]["secret_key"] = $tmparray2[1]; |
1295 | 1295 | |
1296 | 1296 | $stripearrayofkeys = $stripearrayofkeysbyenv[$servicestatus]; |
1297 | 1297 | \Stripe\Stripe::setApiKey($stripearrayofkeys['secret_key']); |
1298 | 1298 | |
1299 | - $foundalternativestripeaccount = $tmparray[0]; // Store the customer id |
|
1299 | + $foundalternativestripeaccount = $tmparray[0]; // Store the customer id |
|
1300 | 1300 | |
1301 | 1301 | dol_syslog("makeStripeSepaRequest We use now customer=" . $foundalternativestripeaccount . " publishable_key=" . $stripearrayofkeys['publishable_key'], LOG_DEBUG); |
1302 | 1302 | } |
1303 | 1303 | } |
1304 | 1304 | |
1305 | - if (! $foundalternativestripeaccount) { |
|
1305 | + if (!$foundalternativestripeaccount) { |
|
1306 | 1306 | $stripearrayofkeysbyenv = $savstripearrayofkeysbyenv; |
1307 | 1307 | |
1308 | 1308 | $stripearrayofkeys = $savstripearrayofkeysbyenv[$servicestatus]; |
@@ -1317,7 +1317,7 @@ discard block |
||
1317 | 1317 | dol_syslog("makeStripeSepaRequest No dedicated Stripe Account requested, so we use global one, so " . $stripearrayofkeys['publishable_key'], LOG_DEBUG); |
1318 | 1318 | } |
1319 | 1319 | |
1320 | - $stripeacc = $stripe->getStripeAccount($service, $this->socid); // Get Stripe OAuth connect account if it exists (no network access here) |
|
1320 | + $stripeacc = $stripe->getStripeAccount($service, $this->socid); // Get Stripe OAuth connect account if it exists (no network access here) |
|
1321 | 1321 | |
1322 | 1322 | if ($foundalternativestripeaccount) { |
1323 | 1323 | if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage |
@@ -1327,7 +1327,7 @@ discard block |
||
1327 | 1327 | } |
1328 | 1328 | } else { |
1329 | 1329 | $customer = $stripe->customerStripe($thirdparty, $stripeacc, $servicestatus, 0); |
1330 | - if (empty($customer) && ! empty($stripe->error)) { |
|
1330 | + if (empty($customer) && !empty($stripe->error)) { |
|
1331 | 1331 | $this->errors[] = $stripe->error; |
1332 | 1332 | } |
1333 | 1333 | /*if (!empty($customer) && empty($customer->sources)) { |
@@ -1383,7 +1383,7 @@ discard block |
||
1383 | 1383 | $charge->failure_message = $stripe->error; |
1384 | 1384 | $charge->failure_declinecode = $stripe->declinecode; |
1385 | 1385 | $stripefailurecode = $stripe->code; |
1386 | - $stripefailuremessage = 'Action required. Contact the support at ';// . $conf->global->SELLYOURSAAS_MAIN_EMAIL; |
|
1386 | + $stripefailuremessage = 'Action required. Contact the support at '; // . $conf->global->SELLYOURSAAS_MAIN_EMAIL; |
|
1387 | 1387 | $stripefailuredeclinecode = $stripe->declinecode; |
1388 | 1388 | } else { |
1389 | 1389 | dol_syslog(var_export($paymentintent, true), LOG_DEBUG); |
@@ -1523,18 +1523,18 @@ discard block |
||
1523 | 1523 | // Insert record of payment (success or error) |
1524 | 1524 | $actioncomm = new ActionComm($this->db); |
1525 | 1525 | |
1526 | - $actioncomm->type_code = 'AC_OTH_AUTO'; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...) |
|
1526 | + $actioncomm->type_code = 'AC_OTH_AUTO'; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...) |
|
1527 | 1527 | $actioncomm->code = 'AC_' . $actioncode; |
1528 | 1528 | $actioncomm->label = $description; |
1529 | 1529 | $actioncomm->note_private = implode(",\n", $postactionmessages); |
1530 | 1530 | $actioncomm->fk_project = $this->fk_project; |
1531 | 1531 | $actioncomm->datep = $now; |
1532 | 1532 | $actioncomm->datef = $now; |
1533 | - $actioncomm->percentage = -1; // Not applicable |
|
1533 | + $actioncomm->percentage = -1; // Not applicable |
|
1534 | 1534 | $actioncomm->socid = $thirdparty->id; |
1535 | 1535 | $actioncomm->contactid = 0; |
1536 | - $actioncomm->authorid = $user->id; // User saving action |
|
1537 | - $actioncomm->userownerid = $user->id; // Owner of action |
|
1536 | + $actioncomm->authorid = $user->id; // User saving action |
|
1537 | + $actioncomm->userownerid = $user->id; // Owner of action |
|
1538 | 1538 | // Fields when action is a real email (content is already into note) |
1539 | 1539 | /*$actioncomm->email_msgid = $object->email_msgid; |
1540 | 1540 | $actioncomm->email_from = $object->email_from; |
@@ -1670,10 +1670,10 @@ discard block |
||
1670 | 1670 | |
1671 | 1671 | // Add the standard elements to the QR code |
1672 | 1672 | $lines = [ |
1673 | - 'BCD', // Service Tag (optional) |
|
1674 | - '002', // Version (optional) |
|
1675 | - '1', // Character set (optional) |
|
1676 | - 'SCT', // Identification (optional) |
|
1673 | + 'BCD', // Service Tag (optional) |
|
1674 | + '002', // Version (optional) |
|
1675 | + '1', // Character set (optional) |
|
1676 | + 'SCT', // Identification (optional) |
|
1677 | 1677 | ]; |
1678 | 1678 | |
1679 | 1679 | // Add the bank account information |
@@ -1746,10 +1746,10 @@ discard block |
||
1746 | 1746 | $s .= pack('C1', 3) . pack('C1', strlen($datestring)) . $datestring; |
1747 | 1747 | $s .= pack('C1', 4) . pack('C1', strlen($pricewithtaxstring)) . $pricewithtaxstring; |
1748 | 1748 | $s .= pack('C1', 5) . pack('C1', strlen($pricetaxstring)) . $pricetaxstring; |
1749 | - $s .= ''; // Hash of xml invoice |
|
1750 | - $s .= ''; // ecda signature |
|
1751 | - $s .= ''; // ecda public key |
|
1752 | - $s .= ''; // ecda signature of public key stamp |
|
1749 | + $s .= ''; // Hash of xml invoice |
|
1750 | + $s .= ''; // ecda signature |
|
1751 | + $s .= ''; // ecda public key |
|
1752 | + $s .= ''; // ecda signature of public key stamp |
|
1753 | 1753 | |
1754 | 1754 | $s = base64_encode($s); |
1755 | 1755 | |
@@ -1816,8 +1816,8 @@ discard block |
||
1816 | 1816 | $s .= "S\n"; |
1817 | 1817 | $s .= dol_trunc($bankaccount->proprio, 70, 'right', 'UTF-8', 1) . "\n"; |
1818 | 1818 | $addresslinearray = explode("\n", $bankaccount->owner_address); |
1819 | - $s .= dol_trunc(empty($addresslinearray[1]) ? '' : $addresslinearray[1], 70, 'right', 'UTF-8', 1) . "\n"; // address line 1 |
|
1820 | - $s .= dol_trunc(empty($addresslinearray[2]) ? '' : $addresslinearray[2], 70, 'right', 'UTF-8', 1) . "\n"; // address line 2 |
|
1819 | + $s .= dol_trunc(empty($addresslinearray[1]) ? '' : $addresslinearray[1], 70, 'right', 'UTF-8', 1) . "\n"; // address line 1 |
|
1820 | + $s .= dol_trunc(empty($addresslinearray[2]) ? '' : $addresslinearray[2], 70, 'right', 'UTF-8', 1) . "\n"; // address line 2 |
|
1821 | 1821 | /*$s .= dol_trunc($mysoc->zip, 16, 'right', 'UTF-8', 1)."\n"; |
1822 | 1822 | $s .= dol_trunc($mysoc->town, 35, 'right', 'UTF-8', 1)."\n"; |
1823 | 1823 | $s .= dol_trunc($mysoc->country_code, 2, 'right', 'UTF-8', 1)."\n";*/ |
@@ -1825,8 +1825,8 @@ discard block |
||
1825 | 1825 | $s .= "S\n"; |
1826 | 1826 | $s .= dol_trunc($mysoc->name, 70, 'right', 'UTF-8', 1) . "\n"; |
1827 | 1827 | $addresslinearray = explode("\n", $mysoc->address); |
1828 | - $s .= dol_trunc(empty($addresslinearray[1]) ? '' : $addresslinearray[1], 70, 'right', 'UTF-8', 1) . "\n"; // address line 1 |
|
1829 | - $s .= dol_trunc(empty($addresslinearray[2]) ? '' : $addresslinearray[2], 70, 'right', 'UTF-8', 1) . "\n"; // address line 2 |
|
1828 | + $s .= dol_trunc(empty($addresslinearray[1]) ? '' : $addresslinearray[1], 70, 'right', 'UTF-8', 1) . "\n"; // address line 1 |
|
1829 | + $s .= dol_trunc(empty($addresslinearray[2]) ? '' : $addresslinearray[2], 70, 'right', 'UTF-8', 1) . "\n"; // address line 2 |
|
1830 | 1830 | $s .= dol_trunc($mysoc->zip, 16, 'right', 'UTF-8', 1) . "\n"; |
1831 | 1831 | $s .= dol_trunc($mysoc->town, 35, 'right', 'UTF-8', 1) . "\n"; |
1832 | 1832 | $s .= dol_trunc($mysoc->country_code, 2, 'right', 'UTF-8', 1) . "\n"; |
@@ -1846,14 +1846,14 @@ discard block |
||
1846 | 1846 | $s .= "S\n"; |
1847 | 1847 | $s .= dol_trunc($this->thirdparty->name, 70, 'right', 'UTF-8', 1) . "\n"; |
1848 | 1848 | $addresslinearray = explode("\n", $this->thirdparty->address); |
1849 | - $s .= dol_trunc(empty($addresslinearray[1]) ? '' : $addresslinearray[1], 70, 'right', 'UTF-8', 1) . "\n"; // address line 1 |
|
1850 | - $s .= dol_trunc(empty($addresslinearray[2]) ? '' : $addresslinearray[2], 70, 'right', 'UTF-8', 1) . "\n"; // address line 2 |
|
1849 | + $s .= dol_trunc(empty($addresslinearray[1]) ? '' : $addresslinearray[1], 70, 'right', 'UTF-8', 1) . "\n"; // address line 1 |
|
1850 | + $s .= dol_trunc(empty($addresslinearray[2]) ? '' : $addresslinearray[2], 70, 'right', 'UTF-8', 1) . "\n"; // address line 2 |
|
1851 | 1851 | $s .= dol_trunc($this->thirdparty->zip, 16, 'right', 'UTF-8', 1) . "\n"; |
1852 | 1852 | $s .= dol_trunc($this->thirdparty->town, 35, 'right', 'UTF-8', 1) . "\n"; |
1853 | 1853 | $s .= dol_trunc($this->thirdparty->country_code, 2, 'right', 'UTF-8', 1) . "\n"; |
1854 | 1854 | // ID of payment |
1855 | - $s .= "NON\n"; // NON or QRR |
|
1856 | - $s .= "\n"; // QR Code reference if previous field is QRR |
|
1855 | + $s .= "NON\n"; // NON or QRR |
|
1856 | + $s .= "\n"; // QR Code reference if previous field is QRR |
|
1857 | 1857 | // Free text |
1858 | 1858 | if ($complementaryinfo) { |
1859 | 1859 | $s .= $complementaryinfo . "\n"; |