From 7dea799a9e158bbf5bf739b3d565c763158c2bdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Tue, 3 Feb 2015 15:24:15 +0100 Subject: [PATCH 1/4] FIXED Allowed 0 to be used as an account mask 0 is used by some accounting systems and software. --- htdocs/core/modules/societe/mod_codecompta_aquarium.php | 4 ++-- htdocs/societe/admin/societe.php | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/htdocs/core/modules/societe/mod_codecompta_aquarium.php b/htdocs/core/modules/societe/mod_codecompta_aquarium.php index 1cc70aa009e..65a1f6192b5 100644 --- a/htdocs/core/modules/societe/mod_codecompta_aquarium.php +++ b/htdocs/core/modules/societe/mod_codecompta_aquarium.php @@ -44,8 +44,8 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode function __construct() { global $conf; - if (empty($conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER)) $conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER='411'; - if (empty($conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER)) $conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER='401'; + if (is_null($conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER)) $conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER='411'; + if (is_null($conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER)) $conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER='401'; $this->prefixcustomeraccountancycode=$conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER; $this->prefixsupplieraccountancycode=$conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER; } diff --git a/htdocs/societe/admin/societe.php b/htdocs/societe/admin/societe.php index 9834959273c..65728435910 100644 --- a/htdocs/societe/admin/societe.php +++ b/htdocs/societe/admin/societe.php @@ -114,7 +114,11 @@ if ($action == 'setModuleOptions') { $param=GETPOST("param".$i,'alpha'); $value=GETPOST("value".$i,'alpha'); - if ($param) $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity); + // Use the default values if the field is not set + if ($param == '') { + $param = null; + } + $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity); if (! $res > 0) $error++; } } From 7cab558ed2f9076dddebfc616591b90f8f72cfb0 Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Sat, 14 Mar 2015 09:44:58 +0100 Subject: [PATCH 2/4] Fix: Showing system error if not enough stock of product into orders creation with lines --- ChangeLog | 1 + htdocs/commande/class/commande.class.php | 20 +++++++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0664bda856d..2bcf02febf8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -30,6 +30,7 @@ English Dolibarr ChangeLog - Fix: [ bug #1790 ] Email form behaves in an unexpected way when pressing Enter key - Fix: Bad SEPA xml file creation - Fix: [ bug #1892 ] PHP Fatal error when using USER_UPDATE_SESSION trigger and adding a supplier invoice payment +- Fix: Showing system error if not enough stock of product into orders creation with lines ***** ChangeLog for 3.6.2 compared to 3.6.1 ***** - Fix: fix ErrorBadValueForParamNotAString error message in price customer multiprice. diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 573778e808c..cac43ced746 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -3,7 +3,7 @@ * Copyright (C) 2004-2012 Laurent Destailleur * Copyright (C) 2005-2014 Regis Houssin * Copyright (C) 2006 Andre Cianfarani - * Copyright (C) 2010-2013 Juanjo Menent + * Copyright (C) 2010-2015 Juanjo Menent * Copyright (C) 2011 Jean Heimburger * Copyright (C) 2012-2014 Christophe Battarel * Copyright (C) 2013 Florian Henry @@ -100,6 +100,11 @@ class Commande extends CommonOrder // Pour board var $nbtodo; var $nbtodolate; + + /** + * ERR Not engouch stock + */ + const STOCK_NOT_ENOUGH_FOR_ORDER = -3; /** @@ -734,8 +739,11 @@ class Commande extends CommonOrder ); if ($result < 0) { - $this->error=$this->db->lasterror(); - dol_print_error($this->db); + if ($result != self::STOCK_NOT_ENOUGH_FOR_ORDER) + { + $this->error=$this->db->lasterror(); + dol_print_error($this->db); + } $this->db->rollback(); return -1; } @@ -1169,10 +1177,12 @@ class Commande extends CommonOrder $result=$product->fetch($fk_product); $product_type=$product->type; - if($conf->global->STOCK_MUST_BE_ENOUGH_FOR_ORDER && $product_type == 0 && $product->stock_reel < $qty) { + if($conf->global->STOCK_MUST_BE_ENOUGH_FOR_ORDER && $product_type == 0 && $product->stock_reel < $qty) + { $this->error=$langs->trans('ErrorStockIsNotEnough'); + dol_syslog(get_class($this)."::addline error=Product ".$product->ref.": ".$this->error, LOG_ERR); $this->db->rollback(); - return -3; + return self::STOCK_NOT_ENOUGH_FOR_ORDER; } } From 4a9a3ab04ba396128ed392a83fb9b9916186781b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 14 Mar 2015 13:42:58 +0100 Subject: [PATCH 3/4] Revert "FIXED Allowed 0 to be used as an account mask" --- htdocs/core/modules/societe/mod_codecompta_aquarium.php | 4 ++-- htdocs/societe/admin/societe.php | 6 +----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/htdocs/core/modules/societe/mod_codecompta_aquarium.php b/htdocs/core/modules/societe/mod_codecompta_aquarium.php index 65a1f6192b5..1cc70aa009e 100644 --- a/htdocs/core/modules/societe/mod_codecompta_aquarium.php +++ b/htdocs/core/modules/societe/mod_codecompta_aquarium.php @@ -44,8 +44,8 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode function __construct() { global $conf; - if (is_null($conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER)) $conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER='411'; - if (is_null($conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER)) $conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER='401'; + if (empty($conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER)) $conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER='411'; + if (empty($conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER)) $conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER='401'; $this->prefixcustomeraccountancycode=$conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER; $this->prefixsupplieraccountancycode=$conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER; } diff --git a/htdocs/societe/admin/societe.php b/htdocs/societe/admin/societe.php index 65728435910..9834959273c 100644 --- a/htdocs/societe/admin/societe.php +++ b/htdocs/societe/admin/societe.php @@ -114,11 +114,7 @@ if ($action == 'setModuleOptions') { $param=GETPOST("param".$i,'alpha'); $value=GETPOST("value".$i,'alpha'); - // Use the default values if the field is not set - if ($param == '') { - $param = null; - } - $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity); + if ($param) $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity); if (! $res > 0) $error++; } } From 89b22be063b2c1f2b032e3e9a7b416cfa3c11859 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 14 Mar 2015 13:44:26 +0100 Subject: [PATCH 4/4] FIXED: Allowed 0 to be used as an account mask. Required by CEGID. --- htdocs/core/modules/societe/mod_codecompta_aquarium.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/societe/mod_codecompta_aquarium.php b/htdocs/core/modules/societe/mod_codecompta_aquarium.php index 1cc70aa009e..a4514efbce4 100644 --- a/htdocs/core/modules/societe/mod_codecompta_aquarium.php +++ b/htdocs/core/modules/societe/mod_codecompta_aquarium.php @@ -44,8 +44,8 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode function __construct() { global $conf; - if (empty($conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER)) $conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER='411'; - if (empty($conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER)) $conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER='401'; + if (! isset($conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER) || trim($conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER) == '') $conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER='411'; + if (! isset($conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER) || trim($conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER) == '') $conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER='401'; $this->prefixcustomeraccountancycode=$conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER; $this->prefixsupplieraccountancycode=$conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER; }