Check if dynamic price is enabled

This commit is contained in:
Ion Agorria 2016-02-14 14:26:04 +01:00
parent d6227fd981
commit 99efbd3464
7 changed files with 17 additions and 14 deletions

View File

@ -116,11 +116,11 @@ class box_produits extends ModeleBoxes
'text' => $objp->label,
);
if (empty($objp->fk_price_expression)) {
if (empty($conf->dynamicprices->enabled) || empty($objp->fk_price_expression)) {
$price_base_type=$langs->trans($objp->price_base_type);
$price=($objp->price_base_type == 'HT')?price($objp->price):$price=price($objp->price_ttc);
}
else //Parse the dinamic price
else //Parse the dynamic price
{
$productstatic->fetch($objp->rowid, '', '', 1);
$priceparser = new PriceParser($this->db);

View File

@ -123,12 +123,12 @@ class box_produits_alerte_stock extends ModeleBoxes
'text' => $objp->label,
);
if (empty($objp->fk_price_expression))
if (empty($conf->dynamicprices->enabled) || empty($objp->fk_price_expression))
{
$price_base_type=$langs->trans($objp->price_base_type);
$price=($objp->price_base_type == 'HT')?price($objp->price):$price=price($objp->price_ttc);
}
else //Parse the dinamic price
else //Parse the dynamic price
{
$productstatic->fetch($objp->rowid, '', '', 1);
$priceparser = new PriceParser($this->db);

View File

@ -1790,7 +1790,7 @@ class Form
}
else
{
if (!empty($objp->fk_price_expression)) {
if (!empty($conf->dynamicprices->enabled) && !empty($objp->fk_price_expression)) {
$price_product = new Product($this->db);
$price_product->fetch($objp->rowid, '', '', 1);
$priceparser = new PriceParser($this->db);
@ -2168,7 +2168,7 @@ class Form
{
$outqty=$objp->quantity;
$outdiscount=$objp->remise_percent;
if (!empty($objp->fk_supplier_price_expression)) {
if (!empty($conf->dynamicprices->enabled) && !empty($objp->fk_supplier_price_expression)) {
$priceparser = new PriceParser($this->db);
$price_result = $priceparser->parseProductSupplier($objp->fk_product, $objp->fk_supplier_price_expression, $objp->quantity, $objp->tva_tx);
if ($price_result >= 0) {
@ -2307,7 +2307,7 @@ class Form
}
$opt.= '>'.$objp->name.' - '.$objp->ref_fourn.' - ';
if (!empty($objp->fk_supplier_price_expression)) {
if (!empty($conf->dynamicprices->enabled) && !empty($objp->fk_supplier_price_expression)) {
$priceparser = new PriceParser($this->db);
$price_result = $priceparser->parseProductSupplier($objp->fk_product, $objp->fk_supplier_price_expression, $objp->quantity, $objp->tva_tx);
if ($price_result >= 0) {

View File

@ -355,6 +355,7 @@ class ProductFournisseur extends Product
*/
function fetch_product_fournisseur_price($rowid, $ignore_expression = 0)
{
global $conf;
$sql = "SELECT pfp.rowid, pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.fk_availability,";
$sql.= " pfp.fk_soc, pfp.ref_fourn, pfp.fk_product, pfp.charges, pfp.unitcharges, pfp.fk_supplier_price_expression, pfp.delivery_time_days"; // , pfp.recuperableonly as fourn_tva_npr"; FIXME this field not exist in llx_product_fournisseur_price
$sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
@ -473,7 +474,7 @@ class ProductFournisseur extends Product
$prodfourn->fourn_tva_npr = $record["info_bits"];
$prodfourn->fk_supplier_price_expression = $record["fk_supplier_price_expression"];
if (!empty($prodfourn->fk_supplier_price_expression)) {
if (!empty($conf->dynamicprices->enabled) && !empty($prodfourn->fk_supplier_price_expression)) {
$priceparser = new PriceParser($this->db);
$price_result = $priceparser->parseProductSupplier($prodid, $prodfourn->fk_supplier_price_expression, $prodfourn->fourn_qty, $prodfourn->fourn_tva_tx);
if ($price_result >= 0) {
@ -572,7 +573,7 @@ class ProductFournisseur extends Product
{
$fourn_price = $record["price"];
$fourn_unitprice = $record["unitprice"];
if (!empty($record["fk_supplier_price_expression"])) {
if (!empty($conf->dynamicprices->enabled) && !empty($record["fk_supplier_price_expression"])) {
$priceparser = new PriceParser($this->db);
$price_result = $priceparser->parseProductSupplier($prodid, $record["fk_supplier_price_expression"], $record["quantity"], $record["tva_tx"]);
if ($price_result >= 0) {

View File

@ -1278,6 +1278,7 @@ class Product extends CommonObject
*/
function get_buyprice($prodfournprice,$qty,$product_id=0,$fourn_ref=0)
{
global $conf;
$result = 0;
// We do select by searching with qty and prodfournprice
@ -1294,7 +1295,7 @@ class Product extends CommonObject
$obj = $this->db->fetch_object($resql);
if ($obj && $obj->quantity > 0) // If found
{
if (!empty($obj->fk_supplier_price_expression))
if (!empty($conf->dynamicprices->enabled) && !empty($obj->fk_supplier_price_expression))
{
require_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_parser.class.php';
$priceparser = new PriceParser($this->db);
@ -1329,7 +1330,7 @@ class Product extends CommonObject
$obj = $this->db->fetch_object($resql);
if ($obj && $obj->quantity > 0) // If found
{
if (!empty($obj->fk_supplier_price_expression))
if (!empty($conf->dynamicprices->enabled) && !empty($obj->fk_supplier_price_expression))
{
require_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_parser.class.php';
$priceparser = new PriceParser($this->db);
@ -1785,7 +1786,7 @@ class Product extends CommonObject
}
}
if (!empty($this->fk_price_expression) && empty($ignore_expression))
if (!empty($conf->dynamicprices->enabled) && !empty($this->fk_price_expression) && empty($ignore_expression))
{
require_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_parser.class.php';
$priceparser = new PriceParser($this->db);

View File

@ -225,7 +225,7 @@ if (empty($reshook))
}
else
{
if ($price_expression !== '')
if (!empty($conf->dynamicprices->enabled) && $price_expression !== '')
{
//Check the expression validity by parsing it
$priceparser = new PriceParser($db);

View File

@ -307,7 +307,8 @@ if ($result)
// Sell price
if (empty($conf->global->PRODUIT_MULTIPRICES))
{
if (!empty($objp->fk_price_expression)) {
if (!empty($conf->dynamicprices->enabled) && !empty($objp->fk_price_expression))
{
$product = new Product($db);
$product->fetch($objp->rowid);
$priceparser = new PriceParser($db);