diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index c21d3204e0c..14b7c78cc7d 100755
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -1990,7 +1990,7 @@ class Form
$outdiscount=$objp->remise_percent;
if (!empty($objp->fk_price_expression)) {
$priceparser = new PriceParser($this->db);
- $price_result = $priceparser->parse_product_supplier($objp->fk_product, $objp->fk_price_expression, $objp->quantity, $objp->tva_tx);
+ $price_result = $priceparser->parseProductSupplier($objp->fk_product, $objp->fk_price_expression, $objp->quantity, $objp->tva_tx);
if ($price_result >= 0) {
$objp->fprice = $price_result;
if ($objp->quantity >= 1)
@@ -2129,7 +2129,7 @@ class Form
if (!empty($objp->fk_price_expression)) {
$priceparser = new PriceParser($this->db);
- $price_result = $priceparser->parse_product_supplier($objp->fk_product, $objp->fk_price_expression, $objp->quantity, $objp->tva_tx);
+ $price_result = $priceparser->parseProductSupplier($objp->fk_product, $objp->fk_price_expression, $objp->quantity, $objp->tva_tx);
if ($price_result >= 0) {
$objp->fprice = $price_result;
if ($objp->quantity >= 1)
diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php
index d69de2f1fae..ee269646c84 100644
--- a/htdocs/filefunc.inc.php
+++ b/htdocs/filefunc.inc.php
@@ -29,7 +29,7 @@
* \brief File that include conf.php file and commons lib like functions.lib.php
*/
-if (! defined('DOL_VERSION')) define('DOL_VERSION','3.7.0-beta');
+if (! defined('DOL_VERSION')) define('DOL_VERSION','3.8.0-alpha');
if (! defined('EURO')) define('EURO',chr(128));
// Define syslog constants
diff --git a/htdocs/fourn/ajax/getSupplierPrices.php b/htdocs/fourn/ajax/getSupplierPrices.php
index 0424c74cb60..cdff85ccde0 100755
--- a/htdocs/fourn/ajax/getSupplierPrices.php
+++ b/htdocs/fourn/ajax/getSupplierPrices.php
@@ -74,7 +74,7 @@ if (! empty($idprod))
if (!empty($objp->fk_price_expression)) {
$priceparser = new PriceParser($db);
- $price_result = $priceparser->parse_product_supplier($idprod, $objp->fk_price_expression, $objp->quantity, $objp->tva_tx);
+ $price_result = $priceparser->parseProductSupplier($idprod, $objp->fk_price_expression, $objp->quantity, $objp->tva_tx);
if ($price_result >= 0) {
$objp->fprice = $price_result;
if ($objp->quantity >= 1)
diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php
index f5fbf96f0ea..ea193eb101a 100755
--- a/htdocs/fourn/class/fournisseur.product.class.php
+++ b/htdocs/fourn/class/fournisseur.product.class.php
@@ -359,7 +359,7 @@ class ProductFournisseur extends Product
if (empty($ignore_expression) && !empty($this->fk_price_expression)) {
$priceparser = new PriceParser($this->db);
- $price_result = $priceparser->parse_product_supplier($this->fk_product, $this->fk_price_expression, $this->fourn_qty, $this->fourn_tva_tx);
+ $price_result = $priceparser->parseProductSupplier($this->fk_product, $this->fk_price_expression, $this->fourn_qty, $this->fourn_tva_tx);
if ($price_result >= 0) {
$this->fourn_price = $price_result;
//recalculation of unitprice, as probably the price changed...
@@ -443,7 +443,7 @@ class ProductFournisseur extends Product
if (!empty($prodfourn->fk_price_expression)) {
$priceparser = new PriceParser($this->db);
- $price_result = $priceparser->parse_product_supplier($prodid, $prodfourn->fk_price_expression, $prodfourn->fourn_qty, $prodfourn->fourn_tva_tx);
+ $price_result = $priceparser->parseProductSupplier($prodid, $prodfourn->fk_price_expression, $prodfourn->fourn_qty, $prodfourn->fourn_tva_tx);
if ($price_result >= 0) {
$prodfourn->fourn_price = $price_result;
$prodfourn->fourn_unitprice = null; //force recalculation of unitprice, as probably the price changed...
diff --git a/htdocs/install/check.php b/htdocs/install/check.php
index dc4bcd0e557..2d3c3b6ec66 100644
--- a/htdocs/install/check.php
+++ b/htdocs/install/check.php
@@ -1,6 +1,6 @@
- * Copyright (C) 2004-2013 Laurent Destailleur
+ * Copyright (C) 2004-2014 Laurent Destailleur
* Copyright (C) 2005 Marc Barilley / Ocebo
* Copyright (C) 2005-2012 Regis Houssin
* Copyright (C) 2013-2014 Juanjo Menent
@@ -380,22 +380,14 @@ else
$allowupgrade=false;
}
if (defined("MAIN_NOT_INSTALLED")) $allowupgrade=false;
- $migrationscript=array( //array('from'=>'2.0.0', 'to'=>'2.1.0'),
- //array('from'=>'2.1.0', 'to'=>'2.2.0'),
- //array('from'=>'2.2.0', 'to'=>'2.4.0'),
- //array('from'=>'2.4.0', 'to'=>'2.5.0'),
- //array('from'=>'2.5.0', 'to'=>'2.6.0'),
- array('from'=>'2.6.0', 'to'=>'2.7.0'),
- array('from'=>'2.7.0', 'to'=>'2.8.0'),
- array('from'=>'2.8.0', 'to'=>'2.9.0'),
- array('from'=>'2.9.0', 'to'=>'3.0.0'),
- array('from'=>'3.0.0', 'to'=>'3.1.0'),
+ $migrationscript=array( array('from'=>'3.0.0', 'to'=>'3.1.0'),
array('from'=>'3.1.0', 'to'=>'3.2.0'),
array('from'=>'3.2.0', 'to'=>'3.3.0'),
array('from'=>'3.3.0', 'to'=>'3.4.0'),
array('from'=>'3.4.0', 'to'=>'3.5.0'),
array('from'=>'3.5.0', 'to'=>'3.6.0'),
- array('from'=>'3.6.0', 'to'=>'3.7.0')
+ array('from'=>'3.6.0', 'to'=>'3.7.0'),
+ array('from'=>'3.7.0', 'to'=>'3.8.0')
);
$count=0;
diff --git a/htdocs/install/default.css b/htdocs/install/default.css
index c3feead7a8f..c3d97cdaa74 100644
--- a/htdocs/install/default.css
+++ b/htdocs/install/default.css
@@ -296,3 +296,7 @@ background-color: #dfd;
background-repeat: repeat-x;
background-position: top left;
}
+
+.center {
+ text-align: center;
+}
diff --git a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql
index e324ac23c87..a190f102023 100755
--- a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql
+++ b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql
@@ -19,11 +19,11 @@
-- -- VMYSQL4.1 DELETE FROM llx_usergroup_user WHERE fk_usergroup NOT IN (SELECT rowid from llx_usergroup);
--create table for price expressions and add column in product supplier
-create table llx_price_expression
+create table llx_c_price_expression
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
title varchar(20) NOT NULL,
expression varchar(80) NOT NULL
)ENGINE=innodb;
-ALTER TABLE llx_product_fournisseur_price ADD fk_price_expression integer DEFAULT NULL;
\ No newline at end of file
+ALTER TABLE llx_product_fournisseur_price ADD fk_price_expression integer DEFAULT NULL;
diff --git a/htdocs/install/mysql/tables/llx_price_expression.sql b/htdocs/install/mysql/tables/llx_c_price_expression.sql
similarity index 96%
rename from htdocs/install/mysql/tables/llx_price_expression.sql
rename to htdocs/install/mysql/tables/llx_c_price_expression.sql
index 2180302a0d5..4c1788e4276 100755
--- a/htdocs/install/mysql/tables/llx_price_expression.sql
+++ b/htdocs/install/mysql/tables/llx_c_price_expression.sql
@@ -16,7 +16,7 @@
--
-- ============================================================================
-create table llx_price_expression
+create table llx_c_price_expression
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
title varchar(20) NOT NULL,
diff --git a/htdocs/install/mysql/tables/llx_product_fournisseur_price.sql b/htdocs/install/mysql/tables/llx_product_fournisseur_price.sql
index a31ac762fee..a0554d4345c 100755
--- a/htdocs/install/mysql/tables/llx_product_fournisseur_price.sql
+++ b/htdocs/install/mysql/tables/llx_product_fournisseur_price.sql
@@ -39,6 +39,6 @@ create table llx_product_fournisseur_price
tva_tx double(6,3) NOT NULL,
info_bits integer NOT NULL DEFAULT 0,
fk_user integer,
- fk_price_expression integer,
+ fk_price_expression integer, -- Link to the rule for dynamic amount calculation
import_key varchar(14) -- Import key
)ENGINE=innodb;
diff --git a/htdocs/product/class/priceexpression.class.php b/htdocs/product/class/priceexpression.class.php
index a32aadff1ff..45fd9f9fa30 100755
--- a/htdocs/product/class/priceexpression.class.php
+++ b/htdocs/product/class/priceexpression.class.php
@@ -1,7 +1,7 @@
* Copyright (C) 2014 Juanjo Menent
-/* Copyright (C) 2014 Ion Agorria
+/* Copyright (C) 2014 Ion Agorria
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -18,7 +18,7 @@
*/
/**
- * \file htdocs/product/class/priceexpresion.class.php
+ * \file htdocs/product/class/priceexpression.class.php
* \ingroup product
* \brief Class for accesing price expression table
*/
@@ -59,12 +59,12 @@ class PriceExpression
{
$error=0;
- // Clean parameters
+ // Clean parameters
if (isset($this->title)) $this->title=trim($this->title);
if (isset($this->expression)) $this->expression=trim($this->expression);
// Insert request
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."price_expression (";
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."c_price_expression (";
$sql.= "title, expression";
$sql.= ") VALUES (";
$sql.= " ".(isset($this->title)?"'".$this->db->escape($this->title)."'":"''").",";
@@ -121,7 +121,7 @@ class PriceExpression
function fetch($id)
{
$sql = "SELECT title, expression";
- $sql.= " FROM ".MAIN_DB_PREFIX."price_expression";
+ $sql.= " FROM ".MAIN_DB_PREFIX."c_price_expression";
$sql.= " WHERE rowid = ".$id;
dol_syslog(get_class($this)."::fetch");
@@ -156,7 +156,7 @@ class PriceExpression
function list_price_expression()
{
$sql = "SELECT rowid, title, expression";
- $sql.= " FROM ".MAIN_DB_PREFIX."price_expression";
+ $sql.= " FROM ".MAIN_DB_PREFIX."c_price_expression";
$sql.= " ORDER BY title";
dol_syslog(get_class($this)."::list_price_expression");
@@ -194,7 +194,7 @@ class PriceExpression
function find_title($title)
{
$sql = "SELECT rowid";
- $sql.= " FROM ".MAIN_DB_PREFIX."price_expression";
+ $sql.= " FROM ".MAIN_DB_PREFIX."c_price_expression";
$sql.= " WHERE title = '".$this->db->escape($title)."'";
dol_syslog(get_class($this)."::find_title");
@@ -230,12 +230,12 @@ class PriceExpression
{
$error=0;
- // Clean parameters
+ // Clean parameters
if (isset($this->title)) $this->title=trim($this->title);
if (isset($this->expression)) $this->expression=trim($this->expression);
// Update request
- $sql = "UPDATE ".MAIN_DB_PREFIX."price_expression SET";
+ $sql = "UPDATE ".MAIN_DB_PREFIX."c_price_expression SET";
$sql.= " title = ".(isset($this->title)?"'".$this->db->escape($this->title)."'":"''").",";
$sql.= " expression = ".(isset($this->expression)?"'".$this->db->escape($this->expression)."'":"''")."";
$sql.= " WHERE rowid = ".$this->id;
@@ -309,7 +309,7 @@ class PriceExpression
if (! $error)
{
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."price_expression";
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."c_price_expression";
$sql.= " WHERE rowid = ".$rowid;
dol_syslog(get_class($this)."::delete");
diff --git a/htdocs/product/class/priceparser.class.php b/htdocs/product/class/priceparser.class.php
index 5b66a74ae20..5e4fb949cbb 100755
--- a/htdocs/product/class/priceparser.class.php
+++ b/htdocs/product/class/priceparser.class.php
@@ -1,5 +1,5 @@
+/* Copyright (C) 2014 Ion Agorria
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -57,7 +57,7 @@ class PriceParser
*
* @return string Translated error
*/
- public function translated_error()
+ public function translatedError()
{
global $langs;
$langs->load("errors");
@@ -94,20 +94,20 @@ class PriceParser
*/
if (empty($this->error)) {
return $langs->trans("ErrorPriceExpressionUnknown", 0); //this is not supposed to happen
- }
+ }
list($code, $info) = $this->error;
if (in_array($code, array(9, 14, 19, 20))) //Errors which have 0 arg
{
return $langs->trans("ErrorPriceExpression".$code);
- }
+ }
else if (in_array($code, array(1, 2, 3, 4, 5, 8, 10, 11, 17, 21, 22))) //Errors which have 1 arg
{
return $langs->trans("ErrorPriceExpression".$code, $info);
- }
+ }
else if (in_array($code, array(6))) //Errors which have 2 args
{
return $langs->trans("ErrorPriceExpression".$code, $info[0], $info[1]);
- }
+ }
else if (in_array($code, array(7, 12, 13, 15, 16, 18))) //Internal errors
{
return $langs->trans("ErrorPriceExpressionInternal", $code);
@@ -125,11 +125,11 @@ class PriceParser
* @param String $expression The expression to parse
* @return int > 0 if OK, < 1 if KO
*/
- public function parse_expression($values, $expression)
+ public function parseExpression($values, $expression)
{
//Check if empty
$expression = trim($expression);
- if (empty($expression))
+ if (empty($expression))
{
$this->error = array(20, null);
return -1;
@@ -169,12 +169,12 @@ class PriceParser
if (empty($vars["price"])) {
$vars["price"] = $last_result;
}
- if ($vars["price"] === null)
+ if ($vars["price"] === null)
{
$this->error = array(21, $expression);
return -3;
}
- if ($vars["price"] < 0)
+ if ($vars["price"] < 0)
{
$this->error = array(22, $expression);
return -4;
@@ -185,14 +185,14 @@ class PriceParser
/**
* Calculates supplier product price based on product id and string expression
*
- * @param int $product The Product id to get information
+ * @param int $product_id The Product id to get information
* @param string $expression The expression to parse
* @param int $quantity Min quantity
* @param int $tva_tx VAT rate
* @param array $extra_values Any aditional values for expression
* @return int > 0 if OK, < 1 if KO
*/
- public function parse_product_supplier_expression($product_id, $expression, $quantity = null, $tva_tx = null, $extra_values = array())
+ public function parseProductSupplierExpression($product_id, $expression, $quantity = null, $tva_tx = null, $extra_values = array())
{
//Accessible values by expressions
$expression_values = array(
@@ -212,20 +212,20 @@ class PriceParser
}
//Parse the expression and return the price
- return $this->parse_expression($expression_values, $expression);
+ return $this->parseExpression($expression_values, $expression);
}
/**
* Calculates supplier product price based on product id and expression id
*
- * @param int $product The Product id to get information
+ * @param int $product_id The Product id to get information
* @param int $expression_id The expression to parse
* @param int $quantity Min quantity
* @param int $tva_tx VAT rate
* @param array $extra_values Any aditional values for expression
* @return int > 0 if OK, < 1 if KO
*/
- public function parse_product_supplier($product_id, $expression_id, $quantity = null, $tva_tx = null, $extra_values = array())
+ public function parseProductSupplier($product_id, $expression_id, $quantity = null, $tva_tx = null, $extra_values = array())
{
$price_expression = new PriceExpression($this->db);
$res = $price_expression->fetch($expression_id);
@@ -235,6 +235,6 @@ class PriceParser
}
//Parse the expression and return the price
- return $this->parse_product_supplier_expression($product_id, $price_expression->expression, $quantity, $tva_tx, $extra_values);
+ return $this->parseProductSupplierExpression($product_id, $price_expression->expression, $quantity, $tva_tx, $extra_values);
}
}
\ No newline at end of file
diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php
index 1eeea8a6b9e..4839549a9dc 100755
--- a/htdocs/product/class/product.class.php
+++ b/htdocs/product/class/product.class.php
@@ -1185,7 +1185,7 @@ class Product extends CommonObject
{
if (!empty($obj->fk_price_expression)) {
$priceparser = new PriceParser($this->db);
- $price_result = $priceparser->parse_product_supplier($obj->fk_product, $obj->fk_price_expression, $obj->quantity, $obj->tva_tx);
+ $price_result = $priceparser->parseProductSupplier($obj->fk_product, $obj->fk_price_expression, $obj->quantity, $obj->tva_tx);
if ($price_result >= 0) {
$obj->price = $price_result;
}
@@ -1218,7 +1218,7 @@ class Product extends CommonObject
{
if (!empty($obj->fk_price_expression)) {
$priceparser = new PriceParser($this->db);
- $price_result = $priceparser->parse_product_supplier($obj->fk_product, $obj->fk_price_expression, $obj->quantity, $obj->tva_tx);
+ $price_result = $priceparser->parseProductSupplier($obj->fk_product, $obj->fk_price_expression, $obj->quantity, $obj->tva_tx);
if ($result >= 0) {
$obj->price = $price_result;
}
diff --git a/htdocs/product/expression.php b/htdocs/product/expression.php
index bb622224d92..68c57489bfb 100755
--- a/htdocs/product/expression.php
+++ b/htdocs/product/expression.php
@@ -70,9 +70,9 @@ if ($action == 'add')
{
//Check the expression validity by parsing it
$priceparser = new PriceParser($db);
- $price_result = $priceparser->parse_product_supplier_expression($id, $expression, 0, 0);
+ $price_result = $priceparser->parseProductSupplierExpression($id, $expression, 0, 0);
if ($price_result < 0) { //Expression is not valid
- setEventMessage($priceparser->translated_error(), 'errors');
+ setEventMessage($priceparser->translatedError(), 'errors');
}
else
{
@@ -109,9 +109,9 @@ if ($action == 'update')
{
//Check the expression validity by parsing it
$priceparser = new PriceParser($db);
- $price_result = $priceparser->parse_product_supplier_expression($id, $expression, 0, 0);
+ $price_result = $priceparser->parseProductSupplierExpression($id, $expression, 0, 0);
if ($price_result < 0) { //Expression is not valid
- setEventMessage($priceparser->translated_error(), 'errors');
+ setEventMessage($priceparser->translatedError(), 'errors');
}
else
{
diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php
index 78116290b1f..18fe4bae9ec 100755
--- a/htdocs/product/fournisseurs.php
+++ b/htdocs/product/fournisseurs.php
@@ -189,10 +189,10 @@ if ($action == 'updateprice' && GETPOST('cancel') <> $langs->trans("Cancel"))
if ($price_expression != 'NULL') {
//Check the expression validity by parsing it
$priceparser = new PriceParser($db);
- $price_result = $priceparser->parse_product_supplier($id, $price_expression, $quantity, $tva_tx);
+ $price_result = $priceparser->parseProductSupplier($id, $price_expression, $quantity, $tva_tx);
if ($price_result < 0) { //Expression is not valid
$error++;
- setEventMessage($priceparser->translated_error(), 'errors');
+ setEventMessage($priceparser->translatedError(), 'errors');
}
}
if (! $error && ! empty($conf->dynamicprices->enabled)) {