diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index c21d3204e0c2e6950951016e032f7e3b5dd5f673..14b7c78cc7d0ce421baa1cf35050640dda3465ce 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 d69de2f1fae7ec061c687af5f70d4db8d6a96291..ee269646c84b6e2e9d40f5c5ae8b43464c0d0b76 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 0424c74cb6033dc49ead81d8f6f39c4fa087242c..cdff85ccde079d88f9e8f00762fdd4b02250038e 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 f5fbf96f0ea63705958a3e6260c6898ed9ce0e9c..ea193eb101a5ade6d4644dc978427c9de2bb3229 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 dc4bcd0e55731c965316347da0243c6c571105e2..2d3c3b6ec668382034fc32e217b7f57eba5f0ef5 100644 --- a/htdocs/install/check.php +++ b/htdocs/install/check.php @@ -1,6 +1,6 @@ <?php /* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> - * Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net> + * Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com> * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2013-2014 Juanjo Menent <jmenent@2byte.es> @@ -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 c3feead7a8fc68a67bbb488d93039c6856d6968f..c3d97cdaa7462f400e4a246525e60632f4df81e9 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 e324ac23c87c3b0c1f02c2ca57562dd108677747..a190f102023c284e543e74162ef8d462d9bc6a94 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 2180302a0d5661d6926c172b7b2714816600fd94..4c1788e42764f0b64fd0cb9700e1c12cb81a4eb2 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 a31ac762fee21861cb663fa3cd91078898c4b8e6..a0554d4345c05d03128e762dca1e7f0963e64082 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 a32aadff1ff7726df35d5459862ce02b983b898a..45fd9f9fa301167cd67f46d40d2ee7c902cf2461 100755 --- a/htdocs/product/class/priceexpression.class.php +++ b/htdocs/product/class/priceexpression.class.php @@ -1,7 +1,7 @@ <?php /* Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es> -/* Copyright (C) 2014 Ion Agorria <ion@agorria.com> +/* Copyright (C) 2014 Ion Agorria <ion@agorria.com> * * 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 5b66a74ae206597d3b9eb821ed587af4381f44bc..5e4fb949cbb5bb797300e3127be8247cfa765fd2 100755 --- a/htdocs/product/class/priceparser.class.php +++ b/htdocs/product/class/priceparser.class.php @@ -1,5 +1,5 @@ <?php -/* Copyright (C) 2014 Ion Agorria <ion@agorria.com> +/* Copyright (C) 2014 Ion Agorria <ion@agorria.com> * * 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 1eeea8a6b9e615b8058213c89ef9f5a165ec2b04..4839549a9dcead38ee4d9a99728763974fdb9843 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 bb622224d9230d46b8469cb598825e1c01094bcf..68c57489bfb4acdaeaccacd1b16e1a6231e0d59f 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 78116290b1fd7f43798175010539e9eeb92d809f..18fe4bae9ec05a4e51200ec2eef0189f6ff51b9e 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)) {