From 925a1475a126672daf934a9da06079c911f9621e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Fri, 4 Sep 2020 11:01:47 +0200 Subject: [PATCH 01/40] add ref_ext to ProductCombination.class.php --- .../class/ProductCombination.class.php | 105 ++++++++++++------ 1 file changed, 72 insertions(+), 33 deletions(-) diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index 4c25e32c9da..a4faa6121a0 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -76,6 +76,12 @@ class ProductCombination * @var ProductCombinationLevel[] */ public $combination_price_levels; + + /** + * External ref + * @var string + */ + public $variation_ref_ext = ''; /** * Constructor @@ -100,7 +106,7 @@ class ProductCombination { global $conf; - $sql = "SELECT rowid, fk_product_parent, fk_product_child, variation_price, variation_price_percentage, variation_weight FROM ".MAIN_DB_PREFIX."product_attribute_combination WHERE rowid = ".(int) $rowid." AND entity IN (".getEntity('product').")"; + $sql = "SELECT rowid, fk_product_parent, fk_product_child, variation_price, variation_price_percentage, variation_weight, variation_ref_ext FROM ".MAIN_DB_PREFIX."product_attribute_combination WHERE rowid = ".(int) $rowid." AND entity IN (".getEntity('product').")"; $query = $this->db->query($sql); @@ -120,6 +126,7 @@ class ProductCombination $this->variation_price = $obj->variation_price; $this->variation_price_percentage = $obj->variation_price_percentage; $this->variation_weight = $obj->variation_weight; + $this->variation_ref_ext = $obj->variation_ref_ext; if (!empty($conf->global->PRODUIT_MULTIPRICES)) { $this->fetchCombinationPriceLevels(); @@ -226,44 +233,72 @@ class ProductCombination } } + /** + * Get fk_product_parent by fk_product_child + * + * @param int $fk_child Product row id + * @return int >0 OK <0 KO + */ + public function getFkProductParentByFkProductChild($fk_child) + { + $sql = "SELECT fk_product_parent FROM ".MAIN_DB_PREFIX."product_attribute_combination"; + $sql .= " WHERE fk_product_child = ".(int) $fk_child." AND entity IN (".getEntity('product').") LIMIT 1"; - /** - * Retrieves a product combination by a child product row id - * - * @param int $fk_child Product row id - * @return int <0 KO, >0 OK - */ - public function fetchByFkProductChild($fk_child) - { - global $conf; + $query = $this->db->query($sql); - $sql = "SELECT rowid, fk_product_parent, fk_product_child, variation_price, variation_price_percentage, variation_weight FROM ".MAIN_DB_PREFIX."product_attribute_combination WHERE fk_product_child = ".(int) $fk_child." AND entity IN (".getEntity('product').")"; + if (!$query) { + return -1; + } - $query = $this->db->query($sql); + if (!$this->db->num_rows($query)) { + return -1; + } - if (!$query) { - return -1; - } + $row = $this->db->fetch_object($query); - if (!$this->db->num_rows($query)) { - return -1; - } + return (int) $row->fk_product_parent; + } - $result = $this->db->fetch_object($query); - $this->id = $result->rowid; - $this->fk_product_parent = $result->fk_product_parent; - $this->fk_product_child = $result->fk_product_child; - $this->variation_price = $result->variation_price; - $this->variation_price_percentage = $result->variation_price_percentage; - $this->variation_weight = $result->variation_weight; + /** + * Retrieves all product combinations by the child product row id + * + * @param int $fk_child Product row id + * @return int|ProductCombination[] <0 KO + */ + public function fetchAllByFkProductChild($fk_child) + { + global $conf; - if (!empty($conf->global->PRODUIT_MULTIPRICES)) { - $this->fetchCombinationPriceLevels(); - } + $sql = "SELECT rowid, fk_product_parent, fk_product_child, variation_price, variation_price_percentage, variation_weight, variation_ref_ext FROM ".MAIN_DB_PREFIX."product_attribute_combination WHERE fk_product_child = ".(int) $fk_child." AND entity IN (".getEntity('product').")"; - return 1; - } + $query = $this->db->query($sql); + + if (!$query) { + return -1; + } + + $return = array(); + + while ($result = $this->db->fetch_object($query)) { + $tmp = new ProductCombination($this->db); + $tmp->id = $result->rowid; + $tmp->fk_product_parent = $result->fk_product_parent; + $tmp->fk_product_child = $result->fk_product_child; + $tmp->variation_price = $result->variation_price; + $tmp->variation_price_percentage = $result->variation_price_percentage; + $tmp->variation_weight = $result->variation_weight; + $tmp->variation_ref_ext = $result->variation_ref_ext; + + if (!empty($conf->global->PRODUIT_MULTIPRICES)) { + $tmp->fetchCombinationPriceLevels(); + } + + $return[] = $tmp; + } + + return $return; + } /** * Retrieves all product combinations by the product parent row id @@ -293,6 +328,7 @@ class ProductCombination $tmp->variation_price = $result->variation_price; $tmp->variation_price_percentage = $result->variation_price_percentage; $tmp->variation_weight = $result->variation_weight; + $tmp->variation_ref_ext = $result->variation_ref_ext; if (!empty($conf->global->PRODUIT_MULTIPRICES)) { $tmp->fetchCombinationPriceLevels(); @@ -340,7 +376,7 @@ class ProductCombination $sql .= " (fk_product_parent, fk_product_child, variation_price, variation_price_percentage, variation_weight, entity)"; $sql .= " VALUES (".((int) $this->fk_product_parent).", ".((int) $this->fk_product_child).","; $sql .= (float) $this->variation_price.", ".(int) $this->variation_price_percentage.","; - $sql .= (float) $this->variation_weight.", ".(int) $this->entity.")"; + $sql .= (float) $this->variation_weight.", '".$this->db->escape($this->variation_ref_ext)."', ".(int) $this->entity.")"; $resql = $this->db->query($sql); if ($resql) { @@ -373,7 +409,8 @@ class ProductCombination $sql = "UPDATE ".MAIN_DB_PREFIX."product_attribute_combination"; $sql .= " SET fk_product_parent = ".(int) $this->fk_product_parent.", fk_product_child = ".(int) $this->fk_product_child.","; $sql .= " variation_price = ".(float) $this->variation_price.", variation_price_percentage = ".(int) $this->variation_price_percentage.","; - $sql .= " variation_weight = ".(float) $this->variation_weight." WHERE rowid = ".((int) $this->id); + $sql .= " variation_ref_ext = '".$this->db->escape($this->variation_ref_ext)."',"; + $sql .= " variation_weight = ".(float) $this->variation_weight." WHERE rowid = ".((int) $this->id); $resql = $this->db->query($sql); if (! $resql) { @@ -661,9 +698,10 @@ class ProductCombination * @param bool|float $forced_pricevar If the price variation is forced * @param bool|float $forced_weightvar If the weight variation is forced * @param bool|string $forced_refvar If the reference is forced + * @param string $ref_ext External reference * @return int <0 KO, >0 OK */ - public function createProductCombination(User $user, Product $product, array $combinations, array $variations, $price_var_percent = false, $forced_pricevar = false, $forced_weightvar = false, $forced_refvar = false) + public function createProductCombination(User $user, Product $product, array $combinations, array $variations, $price_var_percent = false, $forced_pricevar = false, $forced_weightvar = false, $forced_refvar = false, $ref_ext = '') { global $db, $conf; @@ -779,6 +817,7 @@ class ProductCombination $newcomb->variation_price_percentage = $price_var_percent; $newcomb->variation_price = $price_impact[1]; $newcomb->variation_weight = $weight_impact; + $newcomb->variation_ref_ext = $db->escape($ref_ext); // Init price level if ($conf->global->PRODUIT_MULTIPRICES){ From 0f1c3643d7db798fa9e38984ea596b68b84cf878 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Fri, 4 Sep 2020 11:21:29 +0200 Subject: [PATCH 02/40] Use function getFkProductParentByFkProductChild --- htdocs/core/lib/product.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index dfc57313add..686ff3af1f5 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -107,7 +107,7 @@ function product_prepare_head($object) $prodcomb = new ProductCombination($db); - if ($prodcomb->fetchByFkProductChild($object->id) == -1) + if ($prodcomb->getFkProductParentByFkProductChild($object->id) == -1) { $head[$h][0] = DOL_URL_ROOT."/variants/combinations.php?id=".$object->id; $head[$h][1] = $langs->trans('ProductCombinations'); From 3d926ff3a180b19c176dcdcfeced966891005374 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Fri, 4 Sep 2020 11:38:40 +0200 Subject: [PATCH 03/40] use function getFkProductParentByFkProductChild --- htdocs/product/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 32c50ccb661..bfb630f4eb9 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1912,9 +1912,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) if (!empty($conf->variants->enabled) && ($object->isProduct() || $object->isService())) { $combination = new ProductCombination($db); - if ($combination->fetchByFkProductChild($object->id) > 0) { + if (($fk_product_parent = $combination->getFkProductParentByFkProductChild($object->id)) > 0) { $prodstatic = new Product($db); - $prodstatic->fetch($combination->fk_product_parent); + $prodstatic->fetch($fk_product_parent); // Parent product print ''.$langs->trans("ParentProduct").''; From 3a232796d8878d35e71b6f9d0f8412254a260363 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Fri, 4 Sep 2020 11:43:56 +0200 Subject: [PATCH 04/40] Use new function fetchAllByFkProductChild --- htdocs/product/class/product.class.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 1fcb76a571d..7d91052ab87 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1194,9 +1194,13 @@ class Product extends CommonObject } //We also check if it is a child product - if (!$error && ($prodcomb->fetchByFkProductChild($this->id) > 0) && ($prodcomb->delete($user) < 0)) { - $error++; - $this->errors[] = 'Error deleting child combination'; + if (!$error) { + foreach ($prodcomb->fetchAllByFkProductChild($this->id) as $obj) { + if ($obj->delete($user) < 0) { + $error++; + $this->errors[] = 'Error deleting child combination'; + } + } } } From 93959d34c8f4020529bf98c4442a4afc658281e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Fri, 4 Sep 2020 12:01:01 +0200 Subject: [PATCH 05/40] NEW fields ref_ext for Attributes and Combinations --- htdocs/install/mysql/migration/12.0.0-13.0.0.sql | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql index 17b58f278cf..35f2e4e8a54 100644 --- a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql +++ b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql @@ -310,4 +310,8 @@ ALTER TABLE llx_actioncomm_reminder ADD INDEX idx_actioncomm_reminder_status (st ALTER TABLE llx_inventorydet ADD UNIQUE uk_inventorydet(fk_inventory, fk_warehouse, fk_product, batch); +ALTER TABLE llx_product_attribute ADD COLUMN ref_ext varchar(255) AFTER ref; +ALTER TABLE llx_product_attribute_combination ADD COLUMN variation_ref_ext varchar(255) AFTER variation_weight; +ALTER TABLE llx_product_attribute ADD COLUMN ref_ext varchar(255) AFTER ref; +ALTER TABLE llx_product_attribute_combination ADD COLUMN variation_ref_ext varchar(255) AFTER variation_weight; From b841a4354e04052040811c64599eba8e43784b59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Fri, 4 Sep 2020 12:06:09 +0200 Subject: [PATCH 06/40] NEW ref_ext for Attributes --- .../variants/class/ProductAttribute.class.php | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/htdocs/variants/class/ProductAttribute.class.php b/htdocs/variants/class/ProductAttribute.class.php index 6e2335c2f99..d7fbbfefa8b 100644 --- a/htdocs/variants/class/ProductAttribute.class.php +++ b/htdocs/variants/class/ProductAttribute.class.php @@ -40,6 +40,12 @@ class ProductAttribute extends CommonObject * @var string */ public $ref; + + /** + * External ref of the product attribute + * @var string + */ + public $ref_ext; /** * Label of the product attribute @@ -79,8 +85,8 @@ class ProductAttribute extends CommonObject return -1; } - $sql = "SELECT rowid, ref, label, rang FROM ".MAIN_DB_PREFIX."product_attribute WHERE rowid = ".(int) $id." AND entity IN (".getEntity('product').")"; - + $sql = "SELECT rowid, ref, ref_ext, label, rang FROM ".MAIN_DB_PREFIX."product_attribute WHERE rowid = ".(int) $id." AND entity IN (".getEntity('product').")"; + $query = $this->db->query($sql); if (!$this->db->num_rows($query)) { @@ -91,6 +97,7 @@ class ProductAttribute extends CommonObject $this->id = $obj->rowid; $this->ref = $obj->ref; + $this->ref_ext = $obj->ref_ext; $this->label = $obj->label; $this->rang = $obj->rang; @@ -106,7 +113,7 @@ class ProductAttribute extends CommonObject { $return = array(); - $sql = 'SELECT rowid, ref, label, rang FROM '.MAIN_DB_PREFIX."product_attribute WHERE entity IN (".getEntity('product').')'; + $sql = 'SELECT rowid, ref, ref_ext, label, rang FROM '.MAIN_DB_PREFIX."product_attribute WHERE entity IN (".getEntity('product').')'; $sql .= $this->db->order('rang', 'asc'); $query = $this->db->query($sql); if ($query) @@ -115,6 +122,7 @@ class ProductAttribute extends CommonObject $tmp = new ProductAttribute($this->db); $tmp->id = $result->rowid; $tmp->ref = $result->ref; + $tmp->ref_ext = $result->ref_ext; $tmp->label = $result->label; $tmp->rang = $result->rang; @@ -147,9 +155,9 @@ class ProductAttribute extends CommonObject //Ref must be uppercase $this->ref = strtoupper($this->ref); - $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_attribute (ref, label, entity, rang) - VALUES ('".$this->db->escape($this->ref)."', '".$this->db->escape($this->label)."', ".(int) $this->entity.", ".(int) $this->rang.")"; - + $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_attribute (ref, ref_ext, label, entity, rang) + VALUES ('".$this->db->escape($this->ref)."', '".$this->db->escape($this->ref_ext)."', '".$this->db->escape($this->label)."', ".(int) $this->entity.", ".(int) $this->rang.")"; + $query = $this->db->query($sql); if ($query) { @@ -183,8 +191,8 @@ class ProductAttribute extends CommonObject $this->ref = trim(strtoupper($this->ref)); $this->label = trim($this->label); - $sql = "UPDATE ".MAIN_DB_PREFIX."product_attribute SET ref = '".$this->db->escape($this->ref)."', label = '".$this->db->escape($this->label)."', rang = ".(int) $this->rang." WHERE rowid = ".(int) $this->id; - + $sql = "UPDATE ".MAIN_DB_PREFIX."product_attribute SET ref = '".$this->db->escape($this->ref)."', ref_ext = '".$this->db->escape($this->ref_ext)."', label = '".$this->db->escape($this->label)."', rang = ".(int) $this->rang." WHERE rowid = ".(int) $this->id; + if ($this->db->query($sql)) { return 1; } From 8d6c19a4328740ee99185fc65530122ec4e9cade Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 4 Sep 2020 10:10:37 +0000 Subject: [PATCH 07/40] Fixing style errors. --- htdocs/variants/class/ProductAttribute.class.php | 8 ++++---- htdocs/variants/class/ProductCombination.class.php | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/variants/class/ProductAttribute.class.php b/htdocs/variants/class/ProductAttribute.class.php index d7fbbfefa8b..8ae9879e6ca 100644 --- a/htdocs/variants/class/ProductAttribute.class.php +++ b/htdocs/variants/class/ProductAttribute.class.php @@ -40,7 +40,7 @@ class ProductAttribute extends CommonObject * @var string */ public $ref; - + /** * External ref of the product attribute * @var string @@ -86,7 +86,7 @@ class ProductAttribute extends CommonObject } $sql = "SELECT rowid, ref, ref_ext, label, rang FROM ".MAIN_DB_PREFIX."product_attribute WHERE rowid = ".(int) $id." AND entity IN (".getEntity('product').")"; - + $query = $this->db->query($sql); if (!$this->db->num_rows($query)) { @@ -157,7 +157,7 @@ class ProductAttribute extends CommonObject $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_attribute (ref, ref_ext, label, entity, rang) VALUES ('".$this->db->escape($this->ref)."', '".$this->db->escape($this->ref_ext)."', '".$this->db->escape($this->label)."', ".(int) $this->entity.", ".(int) $this->rang.")"; - + $query = $this->db->query($sql); if ($query) { @@ -192,7 +192,7 @@ class ProductAttribute extends CommonObject $this->label = trim($this->label); $sql = "UPDATE ".MAIN_DB_PREFIX."product_attribute SET ref = '".$this->db->escape($this->ref)."', ref_ext = '".$this->db->escape($this->ref_ext)."', label = '".$this->db->escape($this->label)."', rang = ".(int) $this->rang." WHERE rowid = ".(int) $this->id; - + if ($this->db->query($sql)) { return 1; } diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index a4faa6121a0..b65957d0a89 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -76,7 +76,7 @@ class ProductCombination * @var ProductCombinationLevel[] */ public $combination_price_levels; - + /** * External ref * @var string From 4383f1d00c0188f1eb53a2ae2a9183475e110400 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 4 Sep 2020 13:50:22 +0200 Subject: [PATCH 08/40] Update ProductCombination.class.php --- htdocs/variants/class/ProductCombination.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index b65957d0a89..a449ca5d237 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -234,10 +234,10 @@ class ProductCombination } /** - * Get fk_product_parent by fk_product_child + * Return the product id of the parent product of a variant product (Get fk_product_parent by fk_product_child) * - * @param int $fk_child Product row id - * @return int >0 OK <0 KO + * @param int $fk_child Product row id + * @return int >0 if OK, 0 if product is not a variant, <0 if KO */ public function getFkProductParentByFkProductChild($fk_child) { @@ -251,7 +251,7 @@ class ProductCombination } if (!$this->db->num_rows($query)) { - return -1; + return 0; } $row = $this->db->fetch_object($query); From 0a09284b8fbaa1c9608a485f1b497acdffedd582 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Fri, 4 Sep 2020 21:32:12 +0200 Subject: [PATCH 09/40] FIX one time is enough --- htdocs/install/mysql/migration/12.0.0-13.0.0.sql | 3 --- 1 file changed, 3 deletions(-) diff --git a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql index 35f2e4e8a54..7dfccac5beb 100644 --- a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql +++ b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql @@ -312,6 +312,3 @@ ALTER TABLE llx_inventorydet ADD UNIQUE uk_inventorydet(fk_inventory, fk_warehou ALTER TABLE llx_product_attribute ADD COLUMN ref_ext varchar(255) AFTER ref; ALTER TABLE llx_product_attribute_combination ADD COLUMN variation_ref_ext varchar(255) AFTER variation_weight; - -ALTER TABLE llx_product_attribute ADD COLUMN ref_ext varchar(255) AFTER ref; -ALTER TABLE llx_product_attribute_combination ADD COLUMN variation_ref_ext varchar(255) AFTER variation_weight; From 76a5a42191385172107d35b0c9ac9d79846093cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Fri, 4 Sep 2020 23:07:10 +0200 Subject: [PATCH 10/40] Update llx_product_attribute.sql --- htdocs/install/mysql/tables/llx_product_attribute.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/install/mysql/tables/llx_product_attribute.sql b/htdocs/install/mysql/tables/llx_product_attribute.sql index f7ebee3cc23..7e00b14d17a 100644 --- a/htdocs/install/mysql/tables/llx_product_attribute.sql +++ b/htdocs/install/mysql/tables/llx_product_attribute.sql @@ -20,6 +20,7 @@ CREATE TABLE llx_product_attribute ( rowid INT PRIMARY KEY NOT NULL AUTO_INCREMENT, ref VARCHAR(255) NOT NULL, + ref_ext varchar(255) DEFAULT NULL, label VARCHAR(255) NOT NULL, rang INT DEFAULT 0 NOT NULL, entity INT DEFAULT 1 NOT NULL From 806cfa84e258d509673140d36a05e66afad74084 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Fri, 4 Sep 2020 23:08:02 +0200 Subject: [PATCH 11/40] Update llx_product_attribute_combination.sql --- .../install/mysql/tables/llx_product_attribute_combination.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/install/mysql/tables/llx_product_attribute_combination.sql b/htdocs/install/mysql/tables/llx_product_attribute_combination.sql index a00b4009c72..afbb9bcec65 100644 --- a/htdocs/install/mysql/tables/llx_product_attribute_combination.sql +++ b/htdocs/install/mysql/tables/llx_product_attribute_combination.sql @@ -25,5 +25,6 @@ CREATE TABLE llx_product_attribute_combination variation_price DOUBLE(24,8) NOT NULL, variation_price_percentage INTEGER NULL, variation_weight REAL NOT NULL, + ref_ext varchar(255) DEFAULT NULL, entity INTEGER DEFAULT 1 NOT NULL )ENGINE=innodb; From af910135061136e0987a72fdde21d2aa67e04d45 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sun, 6 Sep 2020 15:52:02 +0000 Subject: [PATCH 12/40] Fixing style errors. --- .../class/ProductCombination.class.php | 104 +++++++++--------- 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index e9e71b41c4a..cdf8e470a00 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -233,72 +233,72 @@ class ProductCombination } } - /** - * Return the product id of the parent product of a variant product (Get fk_product_parent by fk_product_child) - * - * @param int $fk_child Product row id - * @return int >0 if OK, 0 if product is not a variant, <0 if KO - */ - public function getFkProductParentByFkProductChild($fk_child) - { - $sql = "SELECT fk_product_parent FROM ".MAIN_DB_PREFIX."product_attribute_combination"; - $sql .= " WHERE fk_product_child = ".(int) $fk_child." AND entity IN (".getEntity('product').") LIMIT 1"; + /** + * Return the product id of the parent product of a variant product (Get fk_product_parent by fk_product_child) + * + * @param int $fk_child Product row id + * @return int >0 if OK, 0 if product is not a variant, <0 if KO + */ + public function getFkProductParentByFkProductChild($fk_child) + { + $sql = "SELECT fk_product_parent FROM ".MAIN_DB_PREFIX."product_attribute_combination"; + $sql .= " WHERE fk_product_child = ".(int) $fk_child." AND entity IN (".getEntity('product').") LIMIT 1"; - $query = $this->db->query($sql); + $query = $this->db->query($sql); - if (!$query) { - return -1; - } + if (!$query) { + return -1; + } - if (!$this->db->num_rows($query)) { - return 0; - } + if (!$this->db->num_rows($query)) { + return 0; + } - $row = $this->db->fetch_object($query); + $row = $this->db->fetch_object($query); - return (int) $row->fk_product_parent; - } + return (int) $row->fk_product_parent; + } - /** - * Retrieves all product combinations by the child product row id - * - * @param int $fk_child Product row id - * @param int $donotloadpricelevel Avoid loading price impact for each level. If PRODUIT_MULTIPRICES is not set, this has no effect. - * @return int|ProductCombination[] <0 KO - */ - public function fetchAllByFkProductChild($fk_child, $donotloadpricelevel = 0) - { - global $conf; + /** + * Retrieves all product combinations by the child product row id + * + * @param int $fk_child Product row id + * @param int $donotloadpricelevel Avoid loading price impact for each level. If PRODUIT_MULTIPRICES is not set, this has no effect. + * @return int|ProductCombination[] <0 KO + */ + public function fetchAllByFkProductChild($fk_child, $donotloadpricelevel = 0) + { + global $conf; - $sql = "SELECT rowid, fk_product_parent, fk_product_child, variation_price, variation_price_percentage, variation_weight, variation_ref_ext FROM ".MAIN_DB_PREFIX."product_attribute_combination WHERE fk_product_child = ".(int) $fk_child." AND entity IN (".getEntity('product').")"; + $sql = "SELECT rowid, fk_product_parent, fk_product_child, variation_price, variation_price_percentage, variation_weight, variation_ref_ext FROM ".MAIN_DB_PREFIX."product_attribute_combination WHERE fk_product_child = ".(int) $fk_child." AND entity IN (".getEntity('product').")"; - $query = $this->db->query($sql); + $query = $this->db->query($sql); - if (!$query) { - return -1; - } + if (!$query) { + return -1; + } - $return = array(); + $return = array(); - while ($result = $this->db->fetch_object($query)) { - $tmp = new ProductCombination($this->db); - $tmp->id = $result->rowid; - $tmp->fk_product_parent = $result->fk_product_parent; - $tmp->fk_product_child = $result->fk_product_child; - $tmp->variation_price = $result->variation_price; - $tmp->variation_price_percentage = $result->variation_price_percentage; - $tmp->variation_weight = $result->variation_weight; - $tmp->variation_ref_ext = $result->variation_ref_ext; + while ($result = $this->db->fetch_object($query)) { + $tmp = new ProductCombination($this->db); + $tmp->id = $result->rowid; + $tmp->fk_product_parent = $result->fk_product_parent; + $tmp->fk_product_child = $result->fk_product_child; + $tmp->variation_price = $result->variation_price; + $tmp->variation_price_percentage = $result->variation_price_percentage; + $tmp->variation_weight = $result->variation_weight; + $tmp->variation_ref_ext = $result->variation_ref_ext; - if (empty($donotloadpricelevel) && !empty($conf->global->PRODUIT_MULTIPRICES)) { - $tmp->fetchCombinationPriceLevels(); - } + if (empty($donotloadpricelevel) && !empty($conf->global->PRODUIT_MULTIPRICES)) { + $tmp->fetchCombinationPriceLevels(); + } - $return[] = $tmp; - } + $return[] = $tmp; + } - return $return; - } + return $return; + } /** * Retrieves all product combinations by the product parent row id From 61903a10795279ec58dcc4f9d43bafbf42b968e2 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 7 Sep 2020 15:24:35 +0000 Subject: [PATCH 13/40] Fixing style errors. --- htdocs/product/card.php | 6 +++--- htdocs/product/class/product.class.php | 2 +- .../variants/class/ProductAttribute.class.php | 18 +++++++++--------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 7195c1476f3..073136e8807 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1912,9 +1912,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) if (!empty($conf->variants->enabled) && ($object->isProduct() || $object->isService())) { $combination = new ProductCombination($db); - if (($fk_product_parent = $combination->getFkProductParentByFkProductChild($object->id)) > 0) { - $prodstatic = new Product($db); - $prodstatic->fetch($fk_product_parent); + if (($fk_product_parent = $combination->getFkProductParentByFkProductChild($object->id)) > 0) { + $prodstatic = new Product($db); + $prodstatic->fetch($fk_product_parent); // Parent product print ''.$langs->trans("ParentProduct").''; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index fb27e140cc2..697c51f09c4 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -4482,7 +4482,7 @@ class Product extends CommonObject global $conf, $langs; $labelStatus = $labelStatusShort = ''; - + $langs->load('products'); if (!empty($conf->productbatch->enabled)) { $langs->load("productbatch"); } diff --git a/htdocs/variants/class/ProductAttribute.class.php b/htdocs/variants/class/ProductAttribute.class.php index 533fc7ea9f4..bbc3a188137 100644 --- a/htdocs/variants/class/ProductAttribute.class.php +++ b/htdocs/variants/class/ProductAttribute.class.php @@ -118,16 +118,16 @@ class ProductAttribute extends CommonObject $query = $this->db->query($sql); if ($query) { - while ($result = $this->db->fetch_object($query)) { - $tmp = new ProductAttribute($this->db); - $tmp->id = $result->rowid; - $tmp->ref = $result->ref; - $tmp->ref_ext = $result->ref_ext; - $tmp->label = $result->label; - $tmp->rang = $result->rang; + while ($result = $this->db->fetch_object($query)) { + $tmp = new ProductAttribute($this->db); + $tmp->id = $result->rowid; + $tmp->ref = $result->ref; + $tmp->ref_ext = $result->ref_ext; + $tmp->label = $result->label; + $tmp->rang = $result->rang; - $return[] = $tmp; - } + $return[] = $tmp; + } } else dol_print_error($this->db); From ccff18e2a564424d32ec921f3a183c942c86858e Mon Sep 17 00:00:00 2001 From: kamel Date: Tue, 8 Sep 2020 14:48:50 +0200 Subject: [PATCH 14/40] NEW : Email configuration - Allow auto signed certificat when ssl activated --- htdocs/admin/mails.php | 37 ++++++++++++++++++++-- htdocs/admin/mails_emailing.php | 40 ++++++++++++++++++++++-- htdocs/core/class/CMailFile.class.php | 14 +++++++++ htdocs/core/class/smtps.class.php | 44 ++++++++++++++++++++++++--- htdocs/langs/en_US/admin.lang | 1 + htdocs/langs/fr_FR/admin.lang | 1 + 6 files changed, 127 insertions(+), 10 deletions(-) diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index 476d782368e..c8c017c476e 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -77,6 +77,7 @@ if ($action == 'update' && empty($_POST["cancel"])) dolibarr_set_const($db, "MAIN_MAIL_SMTPS_PW", GETPOST("MAIN_MAIL_SMTPS_PW", 'none'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_MAIL_EMAIL_TLS", GETPOST("MAIN_MAIL_EMAIL_TLS", 'int'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_MAIL_EMAIL_STARTTLS", GETPOST("MAIN_MAIL_EMAIL_STARTTLS", 'int'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED", GETPOST("MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED", 'int'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_MAIL_EMAIL_DKIM_ENABLED", GETPOST("MAIN_MAIL_EMAIL_DKIM_ENABLED", 'int'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_MAIL_EMAIL_DKIM_DOMAIN", GETPOST("MAIN_MAIL_EMAIL_DKIM_DOMAIN", 'alphanohtml'), 'chaine', 0, '', $conf->entity); @@ -156,6 +157,8 @@ if ($action == 'edit') jQuery("#MAIN_MAIL_EMAIL_TLS").prop("disabled", true); jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val(0); jQuery("#MAIN_MAIL_EMAIL_STARTTLS").prop("disabled", true); + jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(0); + jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").prop("disabled", true); jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").val(0); jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").prop("disabled", true); jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").prop("disabled", true); @@ -187,6 +190,8 @@ if ($action == 'edit') jQuery("#MAIN_MAIL_EMAIL_TLS").removeAttr("disabled"); jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val('.$conf->global->MAIN_MAIL_EMAIL_STARTTLS.'); jQuery("#MAIN_MAIL_EMAIL_STARTTLS").removeAttr("disabled"); + jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val('.$conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED.'); + jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").removeAttr("disabled"); jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").val(0); jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").prop("disabled", true); jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").prop("disabled", true); @@ -211,6 +216,8 @@ if ($action == 'edit') jQuery("#MAIN_MAIL_EMAIL_TLS").removeAttr("disabled"); jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val('.$conf->global->MAIN_MAIL_EMAIL_STARTTLS.'); jQuery("#MAIN_MAIL_EMAIL_STARTTLS").removeAttr("disabled"); + jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val('.$conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED.'); + jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").removeAttr("disabled"); jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").val('.$conf->global->MAIN_MAIL_EMAIL_DKIM_ENABLED.'); jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").removeAttr("disabled"); jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").removeAttr("disabled"); @@ -233,12 +240,16 @@ if ($action == 'edit') initfields(); }); jQuery("#MAIN_MAIL_EMAIL_TLS").change(function() { - if (jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val() == 1) + if (jQuery("#MAIN_MAIL_EMAIL_TLS").val() == 1) jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val(0); + else + jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(0); }); jQuery("#MAIN_MAIL_EMAIL_STARTTLS").change(function() { - if (jQuery("#MAIN_MAIL_EMAIL_TLS").val() == 1) + if (jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val() == 1) jQuery("#MAIN_MAIL_EMAIL_TLS").val(0); + else + jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(0); }); })'; print ''."\n"; @@ -408,6 +419,17 @@ if ($action == 'edit') } else print yn(0).' ('.$langs->trans("NotSupported").')'; print ''; + // SMTP_ALLOW_SELF_SIGNED + print ''.$langs->trans("MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").''; + if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer')))) + { + if (function_exists('openssl_open')) + { + print $form->selectyesno('MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED', (!empty($conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED) ? $conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED : 0), 1); + } else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')'; + } else print yn(0).' ('.$langs->trans("NotSupported").')'; + print ''; + // DKIM print ''.$langs->trans("MAIN_MAIL_EMAIL_DKIM_ENABLED").''; if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('swiftmailer')))) @@ -561,6 +583,17 @@ if ($action == 'edit') } else print ''.yn(0).' ('.$langs->trans("NotSupported").')'; print ''; + // SMTP_ALLOW_SELF_SIGNED + print ''.$langs->trans("MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").''; + if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))) + { + if (function_exists('openssl_open')) + { + print yn($conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED); + } else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')'; + } else print ''.yn(0).' ('.$langs->trans("NotSupported").')'; + print ''; + if ($conf->global->MAIN_MAIL_SENDMODE == 'swiftmailer') { diff --git a/htdocs/admin/mails_emailing.php b/htdocs/admin/mails_emailing.php index f78ef0277bb..7e6f9acae93 100644 --- a/htdocs/admin/mails_emailing.php +++ b/htdocs/admin/mails_emailing.php @@ -68,6 +68,7 @@ if ($action == 'update' && empty($_POST["cancel"])) dolibarr_set_const($db, "MAIN_MAIL_SMTPS_PW_EMAILING", GETPOST("MAIN_MAIL_SMTPS_PW_EMAILING"), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_MAIL_EMAIL_TLS_EMAILING", GETPOST("MAIN_MAIL_EMAIL_TLS_EMAILING"), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_MAIL_EMAIL_STARTTLS_EMAILING", GETPOST("MAIN_MAIL_EMAIL_STARTTLS_EMAILING"), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING", GETPOST("MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING"), 'chaine', 0, '', $conf->entity); header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup"); exit; @@ -147,6 +148,8 @@ if ($action == 'edit') jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").prop("disabled", true); jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").val(0); jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").prop("disabled", true); + jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").val(0); + jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").prop("disabled", true); '; if ($linuxlike) { @@ -173,6 +176,8 @@ if ($action == 'edit') jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").removeAttr("disabled"); jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").val('.$conf->global->MAIN_MAIL_EMAIL_STARTTLS_EMAILING.'); jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").removeAttr("disabled"); + jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").val('.$conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING.'); + jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").removeAttr("disabled"); jQuery("#MAIN_MAIL_SMTP_SERVER_EMAILING").removeAttr("disabled"); jQuery("#MAIN_MAIL_SMTP_PORT_EMAILING").removeAttr("disabled"); jQuery("#MAIN_MAIL_SMTP_SERVER_EMAILING").show(); @@ -187,6 +192,8 @@ if ($action == 'edit') jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").removeAttr("disabled"); jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").val('.$conf->global->MAIN_MAIL_EMAIL_STARTTLS_EMAILING.'); jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").removeAttr("disabled"); + jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").val('.$conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING.'); + jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").removeAttr("disabled"); jQuery("#MAIN_MAIL_SMTP_SERVER_EMAILING").removeAttr("disabled"); jQuery("#MAIN_MAIL_SMTP_PORT_EMAILING").removeAttr("disabled"); jQuery("#MAIN_MAIL_SMTP_SERVER_EMAILING").show(); @@ -199,13 +206,17 @@ if ($action == 'edit') jQuery("#MAIN_MAIL_SENDMODE_EMAILING").change(function() { initfields(); }); - jQuery("#MAIN_MAIL_EMAIL_TLS").change(function() { - if (jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").val() == 1) + jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").change(function() { + if (jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").val() == 1) jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").val(0); + else + jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").val(0); }); jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").change(function() { - if (jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").val() == 1) + if (jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").val() == 1) jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").val(0); + else + jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").val(0); }); })'; print ''."\n"; @@ -359,6 +370,18 @@ if ($action == 'edit') } else print yn(0).' ('.$langs->trans("NotSupported").')'; print ''; + // SMTP_ALLOW_SELF_SIGNED_EMAILING + + print ''.$langs->trans("MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").''; + if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer')))) + { + if (function_exists('openssl_open')) + { + print $form->selectyesno('MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING', (!empty($conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING) ? $conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING : 0), 1); + } else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')'; + } else print yn(0).' ('.$langs->trans("NotSupported").')'; + print ''; + print ''; dol_fiche_end(); @@ -437,6 +460,17 @@ if ($action == 'edit') } else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')'; } else print yn(0).' ('.$langs->trans("NotSupported").')'; print ''; + + // SMTP_ALLOW_SELF_SIGNED_EMAILING + print ''.$langs->trans("MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").''; + if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer'))) + { + if (function_exists('openssl_open')) + { + print yn($conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING); + } else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')'; + } else print yn(0).' ('.$langs->trans("NotSupported").')'; + print ''; } print ''; diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 5048bcd31e8..4803a0da1ca 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -294,6 +294,16 @@ class CMailFile $addr_bcc .= ($addr_bcc ? ', ' : '').$conf->global->MAIN_MAIL_AUTOCOPY_TO; } + $keyforsslseflsigned ='MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED'; + if (!empty($this->sendcontext)) { + $smtpContextKey = strtoupper($this->sendcontext); + $keyForSMTPSendMode = 'MAIN_MAIL_SENDMODE_' . $smtpContextKey; + $smtpContextSendMode = $conf->global->{$keyForSMTPSendMode}; + if (!empty($smtpContextSendMode) && $smtpContextSendMode != 'default') { + $keyforsslseflsigned ='MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_' . $smtpContextKey; + } + } + // We set all data according to choosed sending method. // We also set a value for ->msgid if ($this->sendmode == 'mail') @@ -404,6 +414,7 @@ class CMailFile $smtps->setBCC($this->addr_bcc); $smtps->setErrorsTo($this->errors_to); $smtps->setDeliveryReceipt($this->deliveryreceipt); + if (!empty($conf->global->$keyforsslseflsigned)) $smtps->setOptions(array('ssl' => array('verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true))); $host = dol_getprefix('email'); $this->msgid = time().'.SMTPs-dolibarr-'.$this->trackid.'@'.$host; @@ -639,6 +650,7 @@ class CMailFile $keyforsmtppw = 'MAIN_MAIL_SMTPS_PW'; $keyfortls = 'MAIN_MAIL_EMAIL_TLS'; $keyforstarttls = 'MAIN_MAIL_EMAIL_STARTTLS'; + $keyforsslseflsigned ='MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED'; if (!empty($this->sendcontext)) { $smtpContextKey = strtoupper($this->sendcontext); $keyForSMTPSendMode = 'MAIN_MAIL_SENDMODE_' . $smtpContextKey; @@ -650,6 +662,7 @@ class CMailFile $keyforsmtppw = 'MAIN_MAIL_SMTPS_PW_' . $smtpContextKey; $keyfortls = 'MAIN_MAIL_EMAIL_TLS_' . $smtpContextKey; $keyforstarttls = 'MAIN_MAIL_EMAIL_STARTTLS_' . $smtpContextKey; + $keyforsslseflsigned ='MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_' . $smtpContextKey; } } @@ -846,6 +859,7 @@ class CMailFile if (!empty($conf->global->$keyforsmtpid)) $this->transport->setUsername($conf->global->$keyforsmtpid); if (!empty($conf->global->$keyforsmtppw)) $this->transport->setPassword($conf->global->$keyforsmtppw); + if (! empty($conf->global->$keyforsslseflsigned)) $this->transport->setStreamOptions(array('ssl' => array('allow_self_signed' => true, 'verify_peer' => false)));; //$smtps->_msgReplyTo = 'reply@web.com'; // Switch content encoding to base64 - avoid the doubledot issue with quoted-printable diff --git a/htdocs/core/class/smtps.class.php b/htdocs/core/class/smtps.class.php index 87ce3c22e80..5e3f35fbbc0 100644 --- a/htdocs/core/class/smtps.class.php +++ b/htdocs/core/class/smtps.class.php @@ -228,6 +228,21 @@ class SMTPs private $_trackId = ''; private $_moreInHeader = ''; + /** + * An array of options for stream_context_create() + */ + private $_options = []; + + /** + * Set delivery receipt + * + * @param array $_options An array of options for stream_context_create() + * @return void + */ + public function setOptions($_options = []) + { + $this->_options = $_options; + } /** * Set delivery receipt @@ -372,15 +387,34 @@ class SMTPs { $this->_setErr(99, $host.' is either offline or is an invalid host name.'); $_retVal = false; - } else { - //See if we can connect to the SMTP server - if ($this->socket = @fsockopen( - preg_replace('@tls://@i', '', $this->getHost()), // Host to 'hit', IP or domain + } + else + { + if (function_exists('stream_socket_client')) { + $socket_context = stream_context_create($this->_options); // An array of options for stream_context_create() + set_error_handler([$this, 'errorHandler']); + $this->socket = @stream_socket_client( + $this->getHost() . // Host to 'hit', IP or domain + ':' . $this->getPort(), // which Port number to use + $this->errno, // actual system level error + $this->errstr, // and any text that goes with the error + $this->_smtpTimeout, // timeout for reading/writing data over the socket + STREAM_CLIENT_CONNECT, + $socket_context // Options for connection + ); + } else { + $this->socket = @fsockopen( + $this->getHost(), // Host to 'hit', IP or domain $this->getPort(), // which Port number to use $this->errno, // actual system level error $this->errstr, // and any text that goes with the error $this->_smtpTimeout // timeout for reading/writing data over the socket - )) { + ); + } + + //See if we can connect to the SMTP server + if (is_resource($this->socket)) + { // Fix from PHP SMTP class by 'Chris Ryan' // Sometimes the SMTP server takes a little longer to respond // so we will give it a longer timeout for the first read diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 15627a7e88b..7bf73f8e458 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -289,6 +289,7 @@ MAIN_MAIL_SMTPS_ID=SMTP ID (if sending server requires authentication) MAIN_MAIL_SMTPS_PW=SMTP Password (if sending server requires authentication) MAIN_MAIL_EMAIL_TLS=Use TLS (SSL) encryption MAIN_MAIL_EMAIL_STARTTLS=Use TLS (STARTTLS) encryption +MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED=Authorise les certificats auto-signés MAIN_MAIL_EMAIL_DKIM_ENABLED=Use DKIM to generate email signature MAIN_MAIL_EMAIL_DKIM_DOMAIN=Email Domain for use with dkim MAIN_MAIL_EMAIL_DKIM_SELECTOR=Name of dkim selector diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index baf38869cab..6cace7f78fd 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -289,6 +289,7 @@ MAIN_MAIL_SMTPS_ID=ID SMTP (si le serveur d'envoi nécessite une authentificatio MAIN_MAIL_SMTPS_PW=Mot de passe SMTP (si le serveur d'envoi nécessite une authentification) MAIN_MAIL_EMAIL_TLS=Utilisation du chiffrement TLS (SSL) MAIN_MAIL_EMAIL_STARTTLS=Utiliser le cryptage TTS (STARTTLS) +MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED=Authorise les certificats auto-signés MAIN_MAIL_EMAIL_DKIM_ENABLED=Utiliser DKIM pour signer les emails MAIN_MAIL_EMAIL_DKIM_DOMAIN=Nom de domaine pour la signature DKIM MAIN_MAIL_EMAIL_DKIM_SELECTOR=Nom du sélecteur DKIM From ed13a9fce2958c9056f98aaf8c54296b1eb57bfd Mon Sep 17 00:00:00 2001 From: kamel Date: Tue, 8 Sep 2020 14:53:22 +0200 Subject: [PATCH 15/40] Correction stickler-ci --- htdocs/core/class/smtps.class.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/core/class/smtps.class.php b/htdocs/core/class/smtps.class.php index 5e3f35fbbc0..6d02d23ab6e 100644 --- a/htdocs/core/class/smtps.class.php +++ b/htdocs/core/class/smtps.class.php @@ -387,9 +387,7 @@ class SMTPs { $this->_setErr(99, $host.' is either offline or is an invalid host name.'); $_retVal = false; - } - else - { + } else { if (function_exists('stream_socket_client')) { $socket_context = stream_context_create($this->_options); // An array of options for stream_context_create() set_error_handler([$this, 'errorHandler']); From efb59754d72b62c586f51e1e802952d844e6bd03 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 9 Sep 2020 19:32:14 +0200 Subject: [PATCH 16/40] Update 12.0.0-13.0.0.sql --- htdocs/install/mysql/migration/12.0.0-13.0.0.sql | 3 --- 1 file changed, 3 deletions(-) diff --git a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql index 37fcf0d785f..a41b6825fa3 100644 --- a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql +++ b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql @@ -312,8 +312,5 @@ ALTER TABLE llx_actioncomm_reminder ADD INDEX idx_actioncomm_reminder_status (st ALTER TABLE llx_inventorydet ADD UNIQUE uk_inventorydet(fk_inventory, fk_warehouse, fk_product, batch); -ALTER TABLE llx_product_attribute ADD COLUMN ref_ext varchar(255) AFTER ref; -ALTER TABLE llx_product_attribute_combination ADD COLUMN variation_ref_ext varchar(255) AFTER variation_weight; - ALTER TABLE llx_commandedet ADD COLUMN ref_ext varchar(255) AFTER label; ALTER TABLE llx_facturedet ADD COLUMN ref_ext varchar(255) AFTER multicurrency_total_ttc; From 3209708e309d79bfa62c0e18dd136cbf7a415d71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Thu, 10 Sep 2020 13:56:58 +0200 Subject: [PATCH 17/40] Update ProductCombination.class.php --- htdocs/variants/class/ProductCombination.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index 6510ef3176e..bd593b2c568 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -373,7 +373,7 @@ class ProductCombination /* $this->fk_product_child may be empty and will be filled later after subproduct has been created */ $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_attribute_combination"; - $sql .= " (fk_product_parent, fk_product_child, variation_price, variation_price_percentage, variation_weight, entity)"; + $sql .= " (fk_product_parent, fk_product_child, variation_price, variation_price_percentage, variation_weight, variation_ref_ext, entity)"; $sql .= " VALUES (".((int) $this->fk_product_parent).", ".((int) $this->fk_product_child).","; $sql .= (float) $this->variation_price.", ".(int) $this->variation_price_percentage.","; $sql .= (float) $this->variation_weight.", '".$this->db->escape($this->variation_ref_ext)."', ".(int) $this->entity.")"; From 2ae91b131fa04ea0e2ba06ddb675496be2bd8361 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 13 Sep 2020 22:17:24 +0200 Subject: [PATCH 18/40] Fix display on quickadd dropdown menu --- htdocs/langs/en_US/supplier_proposal.lang | 1 + htdocs/theme/eldy/dropdown.inc.php | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/langs/en_US/supplier_proposal.lang b/htdocs/langs/en_US/supplier_proposal.lang index ce5bdf0425a..ca75eddb7df 100644 --- a/htdocs/langs/en_US/supplier_proposal.lang +++ b/htdocs/langs/en_US/supplier_proposal.lang @@ -13,6 +13,7 @@ SupplierProposalArea=Vendor proposals area SupplierProposalShort=Vendor proposal SupplierProposals=Vendor proposals SupplierProposalsShort=Vendor proposals +AskPrice=Price request NewAskPrice=New price request ShowSupplierProposal=Show price request AddSupplierProposal=Create a price request diff --git a/htdocs/theme/eldy/dropdown.inc.php b/htdocs/theme/eldy/dropdown.inc.php index 12f34ed50ac..ff1a4ff9fba 100644 --- a/htdocs/theme/eldy/dropdown.inc.php +++ b/htdocs/theme/eldy/dropdown.inc.php @@ -411,7 +411,7 @@ a.top-menu-dropdown-link { * QUICK ADD */ #topmenu-quickadd-dropdown .dropdown-menu { - width: 300px !important; + width: 340px !important; color: #444; } @@ -449,8 +449,8 @@ div.quickadd a:hover, div.quickadd a:active { } div.quickaddblock { - width: 80px; - display: block ruby; + width: 100px; + height: 70px; } div.quickaddblock:hover, From 2a5b31da2dca7e36ad2c1d4708342a806c5a976c Mon Sep 17 00:00:00 2001 From: kamel Date: Mon, 14 Sep 2020 10:22:05 +0200 Subject: [PATCH 19/40] CORE smtps: Corrections --- htdocs/core/class/smtps.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/smtps.class.php b/htdocs/core/class/smtps.class.php index 6d02d23ab6e..3adbf4af4d5 100644 --- a/htdocs/core/class/smtps.class.php +++ b/htdocs/core/class/smtps.class.php @@ -388,11 +388,11 @@ class SMTPs $this->_setErr(99, $host.' is either offline or is an invalid host name.'); $_retVal = false; } else { - if (function_exists('stream_socket_client')) { + if (function_exists('stream_socket_client') && !empty($this->_options)) { $socket_context = stream_context_create($this->_options); // An array of options for stream_context_create() set_error_handler([$this, 'errorHandler']); $this->socket = @stream_socket_client( - $this->getHost() . // Host to 'hit', IP or domain + preg_replace('@tls://@i', '', $this->getHost()) . // Host to 'hit', IP or domain ':' . $this->getPort(), // which Port number to use $this->errno, // actual system level error $this->errstr, // and any text that goes with the error @@ -402,7 +402,7 @@ class SMTPs ); } else { $this->socket = @fsockopen( - $this->getHost(), // Host to 'hit', IP or domain + preg_replace('@tls://@i', '', $this->getHost()), // Host to 'hit', IP or domain $this->getPort(), // which Port number to use $this->errno, // actual system level error $this->errstr, // and any text that goes with the error From a8c1b835db978350bf98ada2f5825e5687206156 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Tue, 15 Sep 2020 03:08:06 +0200 Subject: [PATCH 20/40] Fix display on quickadd dropdown menu --- htdocs/theme/eldy/dropdown.inc.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/htdocs/theme/eldy/dropdown.inc.php b/htdocs/theme/eldy/dropdown.inc.php index ff1a4ff9fba..1140589a2e2 100644 --- a/htdocs/theme/eldy/dropdown.inc.php +++ b/htdocs/theme/eldy/dropdown.inc.php @@ -411,10 +411,15 @@ a.top-menu-dropdown-link { * QUICK ADD */ #topmenu-quickadd-dropdown .dropdown-menu { - width: 340px !important; + width: 310px !important; color: #444; } +.quickadd-body.dropdown-body { + padding: unset; + padding-top: 15px; +} + .quickadd-header { color: #444 !important; } @@ -449,8 +454,8 @@ div.quickadd a:hover, div.quickadd a:active { } div.quickaddblock { - width: 100px; - height: 70px; + width: 95px; + height: 80px; } div.quickaddblock:hover, From 31eecae2a6044e12fe383d69df0de2e5f635279d Mon Sep 17 00:00:00 2001 From: "jove@bisquerra.com" Date: Wed, 16 Sep 2020 06:54:01 +0200 Subject: [PATCH 21/40] Show buttons on products when 'Hide Product Images' is enabled --- htdocs/takepos/css/pos.css.php | 21 +++++++++++++++++ htdocs/takepos/index.php | 43 +++++++++++++++++++++++++--------- 2 files changed, 53 insertions(+), 11 deletions(-) diff --git a/htdocs/takepos/css/pos.css.php b/htdocs/takepos/css/pos.css.php index f4c9cf3a88a..4666de59a8e 100644 --- a/htdocs/takepos/css/pos.css.php +++ b/htdocs/takepos/css/pos.css.php @@ -141,6 +141,27 @@ button.calcbutton3 { border-radius: 3px; } +button.productbutton { + display: inline-block; + position: relative; + padding: 0; + line-height: normal; + cursor: pointer; + vertical-align: middle; + text-align: center; + overflow: visible; /* removes extra width in IE */ + width: calc(100% - 2px); + height: calc(100% - 2px); + font-weight: bold; + background-color: #a3a6a3; + color: #fff; + /* border-color: unset; */ + border-width: 0; + margin: 1px; + font-size: 14pt; + border-radius: 3px; +} + button.actionbutton { background: #EABCA6; border: 2px solid #EEE; diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index 390f71491ba..76c71f5b755 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -291,12 +291,20 @@ function LoadProducts(position, issubcat) { //console.log("ishow"+ishow+" idata="+idata); console.log(data[idata]); if (typeof (data[idata]) == "undefined") { - $("#prodivdesc"+ishow).hide(); - $("#prodesc"+ishow).text(""); + global->TAKEPOS_HIDE_PRODUCT_IMAGES) + { + echo '$("#prodivdesc"+ishow).hide();'; + echo '$("#prodesc"+ishow).text("");'; + echo '$("#proimg"+ishow).attr("title","");'; + echo '$("#proimg"+ishow).attr("src","genimg/empty.png");'; + } + else + { + echo '$("#probutton"+ishow).hide();'; + echo '$("#probutton"+ishow).text("");'; + }?> $("#proprice"+ishow).attr("class", "hidden"); $("#proprice"+ishow).html(""); - $("#proimg"+ishow).attr("title",""); - $("#proimg"+ishow).attr("src","genimg/empty.png"); $("#prodiv"+ishow).data("rowid",""); $("#prodiv"+ishow).attr("class","wrapper2 divempty"); $("#prowatermark"+ishow).hide(); @@ -308,14 +316,23 @@ function LoadProducts(position, issubcat) { $titlestring .= " + ' - ".dol_escape_js($langs->trans("Barcode").': ')."' + data[idata]['barcode']"; ?> var titlestring = ; - $("#prodivdesc"+ishow).show(); - $("#prodesc"+ishow).text(data[parseInt(idata)]['label']); + global->TAKEPOS_HIDE_PRODUCT_IMAGES) + { + echo '$("#prodivdesc"+ishow).show();'; + echo '$("#prodesc"+ishow).text(data[parseInt(idata)][\'label\']);'; + echo '$("#proimg"+ishow).attr("title", titlestring);'; + echo '$("#proimg"+ishow).attr("src", "genimg/index.php?query=pro&id="+data[idata][\'id\']);'; + } + else + { + echo '$("#probutton"+ishow).show();'; + echo '$("#probutton"+ishow).text(data[parseInt(idata)][\'label\']);'; + } + ?> if (data[parseInt(idata)]['price_formated']) { $("#proprice"+ishow).attr("class", "productprice"); $("#proprice"+ishow).html(data[parseInt(idata)]['price_formated']); } - $("#proimg"+ishow).attr("title", titlestring); - $("#proimg"+ishow).attr("src", "genimg/index.php?query=pro&id="+data[idata]['id']); $("#prodiv"+ishow).data("rowid", data[idata]['id']); $("#prodiv"+ishow).data("iscat", 0); $("#prodiv"+ishow).attr("class","wrapper2"); @@ -1070,11 +1087,15 @@ if ($conf->global->TAKEPOS_WEIGHING_SCALE) //echo ''; print ''; } else { - print '
'; - if (!$conf->global->TAKEPOS_HIDE_PRODUCT_IMAGES) print ''; + if ($conf->global->TAKEPOS_HIDE_PRODUCT_IMAGES) echo ''; + else + { + print '
'; + print ''; + } } ?> - + global->TAKEPOS_HIDE_PRODUCT_IMAGES) { ?>
From 9bb41e949d420900fa28cffb6eb15e53afbbd515 Mon Sep 17 00:00:00 2001 From: andreubisquerra Date: Wed, 16 Sep 2020 07:39:48 +0200 Subject: [PATCH 22/40] Fix travis --- htdocs/takepos/index.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index 76c71f5b755..fac4f7a0083 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -297,8 +297,7 @@ function LoadProducts(position, issubcat) { echo '$("#prodesc"+ishow).text("");'; echo '$("#proimg"+ishow).attr("title","");'; echo '$("#proimg"+ishow).attr("src","genimg/empty.png");'; - } - else + } else { echo '$("#probutton"+ishow).hide();'; echo '$("#probutton"+ishow).text("");'; @@ -323,8 +322,7 @@ function LoadProducts(position, issubcat) { echo '$("#proimg"+ishow).attr("title", titlestring);'; echo '$("#proimg"+ishow).attr("src", "genimg/index.php?query=pro&id="+data[idata][\'id\']);'; } - else - { + else { echo '$("#probutton"+ishow).show();'; echo '$("#probutton"+ishow).text(data[parseInt(idata)][\'label\']);'; } @@ -1088,8 +1086,7 @@ if ($conf->global->TAKEPOS_WEIGHING_SCALE) print ''; } else { if ($conf->global->TAKEPOS_HIDE_PRODUCT_IMAGES) echo ''; - else - { + else { print '
'; print ''; } From ffb1b5c2ca3a07eb8f338cfcbecf5dedccfced50 Mon Sep 17 00:00:00 2001 From: andreubisquerra Date: Wed, 16 Sep 2020 07:59:36 +0200 Subject: [PATCH 23/40] Fix travis --- htdocs/takepos/index.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index fac4f7a0083..accd353de8d 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -297,8 +297,7 @@ function LoadProducts(position, issubcat) { echo '$("#prodesc"+ishow).text("");'; echo '$("#proimg"+ishow).attr("title","");'; echo '$("#proimg"+ishow).attr("src","genimg/empty.png");'; - } else - { + } else { echo '$("#probutton"+ishow).hide();'; echo '$("#probutton"+ishow).text("");'; }?> From 8284d0ee06a785c85f41598f7973aba11e120dd7 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Thu, 17 Sep 2020 11:41:53 +0200 Subject: [PATCH 24/40] FIx product list fix mistake if fk_state empty --- htdocs/product/list.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 2217d85ccfc..a6fb86f07b8 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -1445,7 +1445,9 @@ if ($resql) // State if (!empty($arrayfields['p.fk_state']['checked'])) { - print ''.getState($obj->fk_state, 0, $db).''; + print ''; + if (!empty($obj->fk_state)) print getState($obj->fk_state, 0, $db); + print ''; if (!$i) $totalarray['nbfield']++; } // Accountancy code sell From e711ab3aa398f5fad429b1f27ef9cb1b7b454bbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Thu, 17 Sep 2020 12:31:56 +0200 Subject: [PATCH 25/40] Update product.lib.php --- htdocs/core/lib/product.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index 686ff3af1f5..dfc57313add 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -107,7 +107,7 @@ function product_prepare_head($object) $prodcomb = new ProductCombination($db); - if ($prodcomb->getFkProductParentByFkProductChild($object->id) == -1) + if ($prodcomb->fetchByFkProductChild($object->id) == -1) { $head[$h][0] = DOL_URL_ROOT."/variants/combinations.php?id=".$object->id; $head[$h][1] = $langs->trans('ProductCombinations'); From 67b565df6ba5a0aa59a5302b43908827fd14712f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Thu, 17 Sep 2020 12:34:47 +0200 Subject: [PATCH 26/40] Update card.php --- htdocs/product/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 073136e8807..df3f21a453a 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1912,9 +1912,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) if (!empty($conf->variants->enabled) && ($object->isProduct() || $object->isService())) { $combination = new ProductCombination($db); - if (($fk_product_parent = $combination->getFkProductParentByFkProductChild($object->id)) > 0) { + if ($combination->fetchByFkProductChild($object->id) > 0) { $prodstatic = new Product($db); - $prodstatic->fetch($fk_product_parent); + $prodstatic->fetch($combination->fk_product_parent); // Parent product print ''.$langs->trans("ParentProduct").''; From 0d20b6645d95d726d815f399396cf6bb07c21bdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Thu, 17 Sep 2020 12:37:20 +0200 Subject: [PATCH 27/40] Update ProductCombination.class.php --- .../class/ProductCombination.class.php | 65 ++++++------------- 1 file changed, 19 insertions(+), 46 deletions(-) diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index bd593b2c568..a50256226f3 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -234,15 +234,18 @@ class ProductCombination } /** - * Return the product id of the parent product of a variant product (Get fk_product_parent by fk_product_child) + * Retrieves information of a variant product and ID of its parent product. * - * @param int $fk_child Product row id - * @return int >0 if OK, 0 if product is not a variant, <0 if KO + * @param int $productid Product ID of variant + * @param int $donotloadpricelevel Avoid loading price impact for each level. If PRODUIT_MULTIPRICES is not set, this has no effect. + * @return int <0 if KO, 0 if product ID is not ID of a variant product (so parent not found), >0 if OK (ID of parent) */ - public function getFkProductParentByFkProductChild($fk_child) + public function fetchByFkProductChild($productid, $donotloadpricelevel = 0) { - $sql = "SELECT fk_product_parent FROM ".MAIN_DB_PREFIX."product_attribute_combination"; - $sql .= " WHERE fk_product_child = ".(int) $fk_child." AND entity IN (".getEntity('product').") LIMIT 1"; + global $conf; + + $sql = "SELECT rowid, fk_product_parent, fk_product_child, variation_price, variation_price_percentage, variation_weight"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_attribute_combination WHERE fk_product_child = ".((int) $productid)." AND entity IN (".getEntity('product').")"; $query = $this->db->query($sql); @@ -254,50 +257,20 @@ class ProductCombination return 0; } - $row = $this->db->fetch_object($query); + $result = $this->db->fetch_object($query); - return (int) $row->fk_product_parent; - } + $this->id = $result->rowid; + $this->fk_product_parent = $result->fk_product_parent; + $this->fk_product_child = $result->fk_product_child; + $this->variation_price = $result->variation_price; + $this->variation_price_percentage = $result->variation_price_percentage; + $this->variation_weight = $result->variation_weight; - /** - * Retrieves all product combinations by the child product row id - * - * @param int $fk_child Product row id - * @param int $donotloadpricelevel Avoid loading price impact for each level. If PRODUIT_MULTIPRICES is not set, this has no effect. - * @return int|ProductCombination[] <0 KO - */ - public function fetchAllByFkProductChild($fk_child, $donotloadpricelevel = 0) - { - global $conf; - - $sql = "SELECT rowid, fk_product_parent, fk_product_child, variation_price, variation_price_percentage, variation_weight, variation_ref_ext FROM ".MAIN_DB_PREFIX."product_attribute_combination WHERE fk_product_child = ".(int) $fk_child." AND entity IN (".getEntity('product').")"; - - $query = $this->db->query($sql); - - if (!$query) { - return -1; + if (empty($donotloadpricelevel) && !empty($conf->global->PRODUIT_MULTIPRICES)) { + $this->fetchCombinationPriceLevels(); } - $return = array(); - - while ($result = $this->db->fetch_object($query)) { - $tmp = new ProductCombination($this->db); - $tmp->id = $result->rowid; - $tmp->fk_product_parent = $result->fk_product_parent; - $tmp->fk_product_child = $result->fk_product_child; - $tmp->variation_price = $result->variation_price; - $tmp->variation_price_percentage = $result->variation_price_percentage; - $tmp->variation_weight = $result->variation_weight; - $tmp->variation_ref_ext = $result->variation_ref_ext; - - if (empty($donotloadpricelevel) && !empty($conf->global->PRODUIT_MULTIPRICES)) { - $tmp->fetchCombinationPriceLevels(); - } - - $return[] = $tmp; - } - - return $return; + return (int) $this->fk_product_parent; } /** From cbd511fbb42a9db63834db677143568c0db09ae0 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Thu, 17 Sep 2020 16:16:35 +0200 Subject: [PATCH 28/40] Update list.php --- htdocs/product/list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/product/list.php b/htdocs/product/list.php index a6fb86f07b8..f3aab6091ef 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -210,8 +210,8 @@ $arrayfields = array( 'p.stock'=>array('label'=>$langs->trans("PhysicalStock"), 'checked'=>1, 'enabled'=>(!empty($conf->stock->enabled) && $user->rights->stock->lire && $contextpage != 'service'), 'position'=>52), 'stock_virtual'=>array('label'=>$langs->trans("VirtualStock"), 'checked'=>1, 'enabled'=>(!empty($conf->stock->enabled) && $user->rights->stock->lire && $contextpage != 'service' && $virtualdiffersfromphysical), 'position'=>53), 'p.tobatch'=>array('label'=>$langs->trans("ManageLotSerial"), 'checked'=>0, 'enabled'=>(!empty($conf->productbatch->enabled)), 'position'=>60), - 'p.fk_country'=>array('label'=>$langs->trans("Country").' ('.$langs->trans("Country").')', 'checked'=>0, 'position'=>100), - 'p.fk_state'=>array('label'=>$langs->trans("State").' ('.$langs->trans("State").')', 'checked'=>0, 'position'=>101), + 'p.fk_country'=>array('label'=>$langs->trans("Country").', 'checked'=>0, 'position'=>100), + 'p.fk_state'=>array('label'=>$langs->trans("State").', 'checked'=>0, 'position'=>101), 'p.accountancy_code_sell'=>array('label'=>$langs->trans("ProductAccountancySellCode"), 'checked'=>0, 'position'=>400), 'p.accountancy_code_sell_intra'=>array('label'=>$langs->trans("ProductAccountancySellIntraCode"), 'checked'=>0, 'enabled'=>$isInEEC, 'position'=>401), 'p.accountancy_code_sell_export'=>array('label'=>$langs->trans("ProductAccountancySellExportCode"), 'checked'=>0, 'position'=>402), From 03f37f3c1f65f37214b4a3a51ef3ec9165f61206 Mon Sep 17 00:00:00 2001 From: Got2be Date: Thu, 17 Sep 2020 17:00:58 +0200 Subject: [PATCH 29/40] NEW : add hooks on stats pages --- htdocs/compta/stats/cabyprodserv.php | 3 +++ htdocs/compta/stats/casoc.php | 3 +++ htdocs/compta/stats/supplier_turnover_by_prodserv.php | 3 +++ htdocs/compta/stats/supplier_turnover_by_thirdparty.php | 3 +++ 4 files changed, 12 insertions(+) diff --git a/htdocs/compta/stats/cabyprodserv.php b/htdocs/compta/stats/cabyprodserv.php index ab2c1dcadb1..fbecc1df335 100644 --- a/htdocs/compta/stats/cabyprodserv.php +++ b/htdocs/compta/stats/cabyprodserv.php @@ -60,6 +60,9 @@ if (GETPOST('subcat', 'alpha') === 'yes') { $selected_type = GETPOST('search_type', 'int'); if ($selected_type == '') $selected_type = -1; +// Hook +$hookmanager->initHooks(array('cabyprodservlist')); + // Date range $year = GETPOST("year"); $month = GETPOST("month"); diff --git a/htdocs/compta/stats/casoc.php b/htdocs/compta/stats/casoc.php index ab71b147b50..a02d87a8392 100644 --- a/htdocs/compta/stats/casoc.php +++ b/htdocs/compta/stats/casoc.php @@ -61,6 +61,9 @@ if ($user->socid > 0) $socid = $user->socid; if (!empty($conf->comptabilite->enabled)) $result = restrictedArea($user, 'compta', '', '', 'resultat'); if (!empty($conf->accounting->enabled)) $result = restrictedArea($user, 'accounting', '', '', 'comptarapport'); +// Hook +$hookmanager->initHooks(array('casoclist')); + // Date range $year = GETPOST("year", 'int'); $month = GETPOST("month", 'int'); diff --git a/htdocs/compta/stats/supplier_turnover_by_prodserv.php b/htdocs/compta/stats/supplier_turnover_by_prodserv.php index 5911daaba45..83a3cb70a00 100644 --- a/htdocs/compta/stats/supplier_turnover_by_prodserv.php +++ b/htdocs/compta/stats/supplier_turnover_by_prodserv.php @@ -57,6 +57,9 @@ if (GETPOST('subcat', 'alpha') === 'yes') { $selected_type = GETPOST('search_type', 'int'); if ($selected_type == '') $selected_type = -1; +// Hook +$hookmanager->initHooks(array('supplierturnoverbyprodservlist')); + // Date range $year = GETPOST("year"); $month = GETPOST("month"); diff --git a/htdocs/compta/stats/supplier_turnover_by_thirdparty.php b/htdocs/compta/stats/supplier_turnover_by_thirdparty.php index 60d65049800..7a624284cdf 100644 --- a/htdocs/compta/stats/supplier_turnover_by_thirdparty.php +++ b/htdocs/compta/stats/supplier_turnover_by_thirdparty.php @@ -50,6 +50,9 @@ if (GETPOST('subcat', 'alpha') === 'yes') { $subcat = true; } +// Hook +$hookmanager->initHooks(array('supplierturnoverbythirdpartylist')); + // Security check if ($user->socid > 0) $socid = $user->socid; if (!empty($conf->comptabilite->enabled)) $result = restrictedArea($user, 'compta', '', '', 'resultat'); From 08d7973b4a8e85e9a3f5c19a2e3e7aeec512a690 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Thu, 17 Sep 2020 22:10:22 +0200 Subject: [PATCH 30/40] Update list.php --- htdocs/product/list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/product/list.php b/htdocs/product/list.php index f3aab6091ef..f0d1a3ef4c0 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -210,8 +210,8 @@ $arrayfields = array( 'p.stock'=>array('label'=>$langs->trans("PhysicalStock"), 'checked'=>1, 'enabled'=>(!empty($conf->stock->enabled) && $user->rights->stock->lire && $contextpage != 'service'), 'position'=>52), 'stock_virtual'=>array('label'=>$langs->trans("VirtualStock"), 'checked'=>1, 'enabled'=>(!empty($conf->stock->enabled) && $user->rights->stock->lire && $contextpage != 'service' && $virtualdiffersfromphysical), 'position'=>53), 'p.tobatch'=>array('label'=>$langs->trans("ManageLotSerial"), 'checked'=>0, 'enabled'=>(!empty($conf->productbatch->enabled)), 'position'=>60), - 'p.fk_country'=>array('label'=>$langs->trans("Country").', 'checked'=>0, 'position'=>100), - 'p.fk_state'=>array('label'=>$langs->trans("State").', 'checked'=>0, 'position'=>101), + 'p.fk_country'=>array('label'=>$langs->trans("Country"), 'checked'=>0, 'position'=>100), + 'p.fk_state'=>array('label'=>$langs->trans("State"), 'checked'=>0, 'position'=>101), 'p.accountancy_code_sell'=>array('label'=>$langs->trans("ProductAccountancySellCode"), 'checked'=>0, 'position'=>400), 'p.accountancy_code_sell_intra'=>array('label'=>$langs->trans("ProductAccountancySellIntraCode"), 'checked'=>0, 'enabled'=>$isInEEC, 'position'=>401), 'p.accountancy_code_sell_export'=>array('label'=>$langs->trans("ProductAccountancySellExportCode"), 'checked'=>0, 'position'=>402), From c82992714b47796824a2582a8e0beba93e6b87ce Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Fri, 18 Sep 2020 08:00:43 +0200 Subject: [PATCH 31/40] Fix wrong visibility of commercial mein menu --- htdocs/core/menus/standard/eldy.lib.php | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index a76a4839242..b964548195d 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -223,26 +223,24 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'submenus' => array(), ); - // Commercial + // Commercial (propal, commande, supplier_proposal, supplier_order, contrat, ficheinter) $tmpentry = array( - 'enabled'=>(!empty($conf->propal->enabled) || + 'enabled'=>( + !empty($conf->propal->enabled) || !empty($conf->commande->enabled) || - !empty($conf->fournisseur->enabled) || !empty($conf->supplier_proposal->enabled) || !empty($conf->supplier_order->enabled) || !empty($conf->contrat->enabled) || !empty($conf->ficheinter->enabled) - ) ? 1 : 0, - 'perms'=>(!empty($user->rights->propal->lire) || + ) ? 1 : 0, + 'perms'=>( + !empty($user->rights->propal->lire) || !empty($user->rights->commande->lire) || - !empty($user->rights->fournisseur->lire) || !empty($user->rights->supplier_proposal->lire) || !empty($user->rights->supplier_order->lire) || !empty($user->rights->contrat->lire) || - !empty($user->rights->ficheinter->lire) || - !empty($user->rights->supplier_order->lire) || - !empty($user->rights->fournisseur->commande->lire) - ), + !empty($user->rights->ficheinter->lire) + ), 'module'=>'propal|commande|supplier_proposal|supplier_order|contrat|ficheinter' ); @@ -893,7 +891,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM } /* - * Menu COMMERCIAL + * Menu COMMERCIAL (propal, commande, supplier_proposal, supplier_order, contrat, ficheinter) */ if ($mainmenu == 'commercial') { From b879b365c318ba9e7fb3f2fe9ca05cfbdba88b2c Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Fri, 18 Sep 2020 08:30:28 +0200 Subject: [PATCH 32/40] bette code style --- htdocs/core/menus/standard/eldy.lib.php | 26 ++++++++++++------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index b964548195d..9ad83e503b7 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -225,21 +225,19 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = // Commercial (propal, commande, supplier_proposal, supplier_order, contrat, ficheinter) $tmpentry = array( - 'enabled'=>( - !empty($conf->propal->enabled) || - !empty($conf->commande->enabled) || - !empty($conf->supplier_proposal->enabled) || - !empty($conf->supplier_order->enabled) || - !empty($conf->contrat->enabled) || - !empty($conf->ficheinter->enabled) + 'enabled'=>(!empty($conf->propal->enabled) + || !empty($conf->commande->enabled) + || !empty($conf->supplier_proposal->enabled) + || !empty($conf->supplier_order->enabled) + || !empty($conf->contrat->enabled) + || !empty($conf->ficheinter->enabled) ) ? 1 : 0, - 'perms'=>( - !empty($user->rights->propal->lire) || - !empty($user->rights->commande->lire) || - !empty($user->rights->supplier_proposal->lire) || - !empty($user->rights->supplier_order->lire) || - !empty($user->rights->contrat->lire) || - !empty($user->rights->ficheinter->lire) + 'perms'=>(!empty($user->rights->propal->lire) + || !empty($user->rights->commande->lire) + || !empty($user->rights->supplier_proposal->lire) + || !empty($user->rights->supplier_order->lire) + || !empty($user->rights->contrat->lire) + || !empty($user->rights->ficheinter->lire) ), 'module'=>'propal|commande|supplier_proposal|supplier_order|contrat|ficheinter' ); From 1c65fa0c5dddffecd9dfbac5ec1bbde727aa7cec Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Fri, 18 Sep 2020 14:48:47 +0200 Subject: [PATCH 33/40] NEW create thirdparty customer from TAKEPOS avoid to switch to backend dolibarr then return to takepos (not really ergonomic and userfriendly) --- htdocs/societe/list.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 4cb6941dc74..cf4ebf6b2df 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -613,6 +613,12 @@ if ($user->rights->societe->creer && $contextpage != 'poslist') } $newcardbutton .= dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/societe/card.php?action=create'.$typefilter); +} elseif ($user->rights->societe->creer && $contextpage == 'poslist') +{ + + $label = 'MenuNewCustomer'; + + $newcardbutton .= dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/societe/card.php?action=create&type=c&contextpage=poslist&optioncss=print&backtopage='.$_SERVER["PHP_SELF"].'?contextpage=poslist&nomassaction=1&optioncss=print&place='.urlencode($place)); } print '
'; From b41bfd502a901f9d249d844d2bfbd4d6e808cc70 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 18 Sep 2020 12:50:53 +0000 Subject: [PATCH 34/40] Fixing style errors. --- htdocs/societe/list.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index cf4ebf6b2df..c7f9d7697b5 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -615,10 +615,9 @@ if ($user->rights->societe->creer && $contextpage != 'poslist') $newcardbutton .= dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/societe/card.php?action=create'.$typefilter); } elseif ($user->rights->societe->creer && $contextpage == 'poslist') { - $label = 'MenuNewCustomer'; - $newcardbutton .= dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/societe/card.php?action=create&type=c&contextpage=poslist&optioncss=print&backtopage='.$_SERVER["PHP_SELF"].'?contextpage=poslist&nomassaction=1&optioncss=print&place='.urlencode($place)); + $newcardbutton .= dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/societe/card.php?action=create&type=c&contextpage=poslist&optioncss=print&backtopage='.$_SERVER["PHP_SELF"].'?contextpage=poslist&nomassaction=1&optioncss=print&place='.urlencode($place)); } print ''; From 206b1189c90bbd73ef2749d9db11e7338abf29a9 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Fri, 18 Sep 2020 17:52:48 +0200 Subject: [PATCH 35/40] NEW fetch contact by email with REST API --- htdocs/societe/class/api_contacts.class.php | 42 +++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/htdocs/societe/class/api_contacts.class.php b/htdocs/societe/class/api_contacts.class.php index 37d9239265f..027cd124d36 100644 --- a/htdocs/societe/class/api_contacts.class.php +++ b/htdocs/societe/class/api_contacts.class.php @@ -97,6 +97,48 @@ class Contacts extends DolibarrApi return $this->_cleanObjectDatas($this->contact); } + + /** + * Get properties of a contact object by Email + * + * @param string $email Email of contact + * @param int $includecount Count and return also number of elements the contact is used as a link for + * @return array|mixed data without useless information + * + * @url GET email/{email} + * + * @throws RestException 401 Insufficient rights + * @throws RestException 404 User or group not found + */ + public function getByEmail($email, $includecount = 0) + { + if (!DolibarrApiAccess::$user->rights->societe->contact->lire) + { + throw new RestException(401, 'No permission to read contacts'); + } + if (empty($email)) { + $result = $this->contact->initAsSpecimen(); + } else { + $result = $this->contact->fetch('', '', '', $email); + } + + if (!$result) + { + throw new RestException(404, 'Contact not found'); + } + + if (!DolibarrApi::_checkAccessToResource('contact', $this->contact->id, 'socpeople&societe')) + { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + if ($includecount) + { + $this->contact->load_ref_elements(); + } + + return $this->_cleanObjectDatas($this->contact); + } /** * List contacts From f9b4a0f68ba7a03cfc86daacfe7bf0ec3b5ad711 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 18 Sep 2020 15:54:37 +0000 Subject: [PATCH 36/40] Fixing style errors. --- htdocs/societe/class/api_contacts.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/class/api_contacts.class.php b/htdocs/societe/class/api_contacts.class.php index 027cd124d36..4d9bd4a47f4 100644 --- a/htdocs/societe/class/api_contacts.class.php +++ b/htdocs/societe/class/api_contacts.class.php @@ -97,7 +97,7 @@ class Contacts extends DolibarrApi return $this->_cleanObjectDatas($this->contact); } - + /** * Get properties of a contact object by Email * From d86f541b358be57304f6fa9a9e1fa1ddb42c903c Mon Sep 17 00:00:00 2001 From: Bernard Saulme Date: Fri, 18 Sep 2020 18:29:52 +0200 Subject: [PATCH 37/40] FIX|members substitution variable not substituted if empty Members substitution variables not substituted if empty for the __MEMBER_ ... variables, the variable is showed instead. Change to display '' instead --- htdocs/core/lib/functions.lib.php | 34 +++++++++++++++---------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index a457aa5af17..d8b7c68c290 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -6072,25 +6072,25 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, if (is_object($object) && $object->element == 'adherent' && $object->id > 0) { - $substitutionarray['__MEMBER_ID__'] = $object->id; + $substitutionarray['__MEMBER_ID__'] = (isset($object->id) ? $object->id : ''); if (method_exists($object, 'getCivilityLabel')) $substitutionarray['__MEMBER_CIVILITY__'] = $object->getCivilityLabel(); - $substitutionarray['__MEMBER_FIRSTNAME__'] = $object->firstname; - $substitutionarray['__MEMBER_LASTNAME__'] = $object->lastname; + $substitutionarray['__MEMBER_FIRSTNAME__'] = (isset($object->firstname) ? $object->firstname : ''); + $substitutionarray['__MEMBER_LASTNAME__'] = (isset($object->lastname) ? $object->lastname : ''); if (method_exists($object, 'getFullName')) $substitutionarray['__MEMBER_FULLNAME__'] = $object->getFullName($outputlangs); - $substitutionarray['__MEMBER_COMPANY__'] = $object->societe; - $substitutionarray['__MEMBER_ADDRESS__'] = $object->address; - $substitutionarray['__MEMBER_ZIP__'] = $object->zip; - $substitutionarray['__MEMBER_TOWN__'] = $object->town; - $substitutionarray['__MEMBER_COUNTRY__'] = $object->country; - $substitutionarray['__MEMBER_EMAIL__'] = $object->email; - $substitutionarray['__MEMBER_BIRTH__'] = $birthday; - $substitutionarray['__MEMBER_PHOTO__'] = $object->photo; - $substitutionarray['__MEMBER_LOGIN__'] = $object->login; - $substitutionarray['__MEMBER_PASSWORD__'] = $object->pass; - $substitutionarray['__MEMBER_PHONE__'] = $object->phone; - $substitutionarray['__MEMBER_PHONEPRO__'] = $object->phone_perso; - $substitutionarray['__MEMBER_PHONEMOBILE__'] = $object->phone_mobile; - $substitutionarray['__MEMBER_TYPE__'] = $object->type; + $substitutionarray['__MEMBER_COMPANY__'] = (isset($object->societe) ? $object->societe : ''); + $substitutionarray['__MEMBER_ADDRESS__'] = (isset($object->address) ? $object->address : ''); + $substitutionarray['__MEMBER_ZIP__'] = (isset($object->zip) ? $object->zip : ''); + $substitutionarray['__MEMBER_TOWN__'] = (isset($object->town) ? $object->town : ''); + $substitutionarray['__MEMBER_COUNTRY__'] = (isset($object->country) ? $object->country : ''); + $substitutionarray['__MEMBER_EMAIL__'] = (isset($object->email) ? $object->email : ''); + $substitutionarray['__MEMBER_BIRTH__'] = (isset($birthday) ? $birthday : ''); + $substitutionarray['__MEMBER_PHOTO__'] = (isset($object->photo) ? $object->photo : ''); + $substitutionarray['__MEMBER_LOGIN__'] = (isset($object->login) ? $object->login : ''); + $substitutionarray['__MEMBER_PASSWORD__'] = (isset($object->pass) ? $object->pass : ''); + $substitutionarray['__MEMBER_PHONE__'] = (isset($object->phone) ? $object->phone : ''); + $substitutionarray['__MEMBER_PHONEPRO__'] = (isset($object->phone_perso) ? $object->phone_perso : ''); + $substitutionarray['__MEMBER_PHONEMOBILE__'] = (isset($object->phone_mobile) ? $object->phone_mobile : ''); + $substitutionarray['__MEMBER_TYPE__'] = (isset($object->type) ? $object->type : ''); $substitutionarray['__MEMBER_FIRST_SUBSCRIPTION_DATE__'] = dol_print_date($object->first_subscription_date, 'dayrfc'); $substitutionarray['__MEMBER_FIRST_SUBSCRIPTION_DATE_START__'] = dol_print_date($object->first_subscription_date_start, 'dayrfc'); $substitutionarray['__MEMBER_FIRST_SUBSCRIPTION_DATE_END__'] = dol_print_date($object->first_subscription_date_end, 'dayrfc'); From 09f23c1d8472a20cc7d6645004b80af2973bb82d Mon Sep 17 00:00:00 2001 From: bahfir abbes Date: Wed, 16 Sep 2020 10:48:06 +0100 Subject: [PATCH 38/40] fix:remove deleted user params --- htdocs/user/class/user.class.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 53a7abe5dac..8c3cdf4ac10 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -1038,6 +1038,14 @@ class User extends CommonObject $this->error = $this->db->lasterror(); } + // Remove params + $sql = "DELETE FROM ".MAIN_DB_PREFIX."user_param WHERE fk_user = ".$this->id; + if (!$error && !$this->db->query($sql)) + { + $error++; + $this->error = $this->db->lasterror(); + } + // If contact, remove link if ($this->contact_id > 0) { From 55a0e5f2e787aa26bf529acfe70f83572fdab297 Mon Sep 17 00:00:00 2001 From: andreubisquerra Date: Sat, 19 Sep 2020 17:12:41 +0200 Subject: [PATCH 39/40] Avoid errors when Weighing Scale from the cloud in TakePOS --- htdocs/takepos/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index 3376023b8b6..f2a37953cfa 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -751,7 +751,7 @@ function WeighingScale(){ console.log("Weighing Scale"); $.ajax({ type: "POST", - url: 'global->TAKEPOS_PRINT_SERVER; ?>/scale', + url: 'global->TAKEPOS_PRINT_SERVER; ?>/scale/index.php', }) .done(function( editnumber ) { $("#poslines").load("invoice.php?action=updateqty&place="+place+"&idline="+selectedline+"&number="+editnumber, function() { From b3d386fa54add55019e69a2737ede7eefa764bed Mon Sep 17 00:00:00 2001 From: daraelmin Date: Sun, 20 Sep 2020 08:42:25 +0200 Subject: [PATCH 40/40] Fix Category is lost on sorting member list When sorting member list filter by tag/category the criteria is lost because of one missing GET parameter Just adding a GET parameter to keep the category/tag parameter when sorting the list --- htdocs/adherents/list.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 1e550fb7f65..75c9c731810 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -370,6 +370,7 @@ if ($search_lastname) $param .= "&search_lastname=".urlencode($search_lastname) if ($search_gender) $param .= "&search_gender=".urlencode($search_gender); if ($search_login) $param .= "&search_login=".urlencode($search_login); if ($search_email) $param .= "&search_email=".urlencode($search_email); +if ($search_categ) $param .= "&search_categ=".urlencode($search_categ); if ($search_company) $param .= "&search_company=".urlencode($search_company); if ($search_address != '') $param .= "&search_address=".urlencode($search_address); if ($search_town != '') $param .= "&search_town=".urlencode($search_town); @@ -545,7 +546,7 @@ if (!empty($arrayfields['d.email']['checked'])) { print ''; print ''; } - +// End of subscription date if (!empty($arrayfields['d.datefin']['checked'])) { print ''; print '';