Fix: problem with price_min in mutli-price mode

This commit is contained in:
Regis Houssin 2011-01-29 16:30:41 +00:00
parent 80ed70d32e
commit 1761aca350
3 changed files with 21 additions and 11 deletions

View File

@ -672,12 +672,14 @@ if ($_POST['action'] == "addline" && $user->rights->propale->creer)
{ {
$pu_ht = $prod->multiprices[$object->client->price_level]; $pu_ht = $prod->multiprices[$object->client->price_level];
$pu_ttc = $prod->multiprices_ttc[$object->client->price_level]; $pu_ttc = $prod->multiprices_ttc[$object->client->price_level];
$price_min = $prod->multiprices_min[$object->client->price_level];
$price_base_type = $prod->multiprices_base_type[$object->client->price_level]; $price_base_type = $prod->multiprices_base_type[$object->client->price_level];
} }
else else
{ {
$pu_ht = $prod->price; $pu_ht = $prod->price;
$pu_ttc = $prod->price_ttc; $pu_ttc = $prod->price_ttc;
$price_min = $prod->price_min;
$price_base_type = $prod->price_base_type; $price_base_type = $prod->price_base_type;
} }
@ -714,9 +716,9 @@ if ($_POST['action'] == "addline" && $user->rights->propale->creer)
$info_bits=0; $info_bits=0;
if ($tva_npr) $info_bits |= 0x01; if ($tva_npr) $info_bits |= 0x01;
if ($prod->price_min && (price2num($pu_ht)*(1-price2num($_POST['remise_percent'])/100) < price2num($prod->price_min))) if ($price_min && (price2num($pu_ht)*(1-price2num($_POST['remise_percent'])/100) < price2num($price_min)))
{ {
$mesg = '<div class="error">'.$langs->trans("CantBeLessThanMinPrice",price2num($prod->price_min,'MU').' '.$langs->trans("Currency".$conf->monnaie)).'</div>' ; $mesg = '<div class="error">'.$langs->trans("CantBeLessThanMinPrice",price2num($price_min,'MU').' '.$langs->trans("Currency".$conf->monnaie)).'</div>' ;
} }
else else
{ {
@ -794,10 +796,12 @@ if ($_POST['action'] == 'updateligne' && $user->rights->propale->creer && $_POST
{ {
$product = new Product($db) ; $product = new Product($db) ;
$res=$product->fetch($productid) ; $res=$product->fetch($productid) ;
$price_min = $product->price_min;
if ($conf->global->PRODUIT_MULTIPRICES && $object->client->price_level) $price_min = $product->multiprices_min[$object->client->price_level];
} }
if ($productid && $product->price_min && (price2num($up_ht)*(1-price2num($_POST['remise_percent'])/100) < price2num($product->price_min))) if ($productid && $price_min && (price2num($up_ht)*(1-price2num($_POST['remise_percent'])/100) < price2num($price_min)))
{ {
$mesg = '<div class="error">'.$langs->trans("CantBeLessThanMinPrice",price2num($product->price_min,'MU').' '.$langs->trans("Currency".$conf->monnaie)).'</div>' ; $mesg = '<div class="error">'.$langs->trans("CantBeLessThanMinPrice",price2num($price_min,'MU').' '.$langs->trans("Currency".$conf->monnaie)).'</div>' ;
} }
else else
{ {

View File

@ -402,12 +402,14 @@ if ($_POST['action'] == 'addline' && $user->rights->commande->creer)
{ {
$pu_ht = $prod->multiprices[$object->client->price_level]; $pu_ht = $prod->multiprices[$object->client->price_level];
$pu_ttc = $prod->multiprices_ttc[$object->client->price_level]; $pu_ttc = $prod->multiprices_ttc[$object->client->price_level];
$price_min = $prod->multiprices_min[$object->client->price_level];
$price_base_type = $prod->multiprices_base_type[$object->client->price_level]; $price_base_type = $prod->multiprices_base_type[$object->client->price_level];
} }
else else
{ {
$pu_ht = $prod->price; $pu_ht = $prod->price;
$pu_ttc = $prod->price_ttc; $pu_ttc = $prod->price_ttc;
$price_min = $prod->price_min;
$price_base_type = $prod->price_base_type; $price_base_type = $prod->price_base_type;
} }
@ -450,10 +452,10 @@ if ($_POST['action'] == 'addline' && $user->rights->commande->creer)
if ($result >= 0) if ($result >= 0)
{ {
if($prod->price_min && (price2num($pu_ht)*(1-price2num($_POST['remise_percent'])/100) < price2num($prod->price_min))) if($price_min && (price2num($pu_ht)*(1-price2num($_POST['remise_percent'])/100) < price2num($price_min)))
{ {
//print "CantBeLessThanMinPrice ".$up_ht." - ".GETPOST('remise_percent')." - ".$product->price_min; //print "CantBeLessThanMinPrice ".$up_ht." - ".GETPOST('remise_percent')." - ".$product->price_min;
$mesg = '<div class="error">'.$langs->trans("CantBeLessThanMinPrice",price2num($prod->price_min,'MU').' '.$langs->trans("Currency".$conf->monnaie)).'</div>' ; $mesg = '<div class="error">'.$langs->trans("CantBeLessThanMinPrice",price2num($price_min,'MU').' '.$langs->trans("Currency".$conf->monnaie)).'</div>' ;
} }
else else
{ {
@ -548,10 +550,12 @@ if ($_POST['action'] == 'updateligne' && $user->rights->commande->creer && $_POS
$product = new Product($db); $product = new Product($db);
$product->fetch($productid); $product->fetch($productid);
$type=$product->type; $type=$product->type;
$price_min = $product->price_min;
if ($conf->global->PRODUIT_MULTIPRICES && $object->client->price_level) $price_min = $product->multiprices_min[$object->client->price_level];
} }
if ($product->price_min && GETPOST('productid') && (price2num($up_ht)*(1-price2num($_POST['elremise_percent'])/100) < price2num($product->price_min))) if ($price_min && GETPOST('productid') && (price2num($up_ht)*(1-price2num($_POST['elremise_percent'])/100) < price2num($price_min)))
{ {
$mesg = '<div class="error">'.$langs->trans("CantBeLessThanMinPrice",price2num($product->price_min,'MU').' '.$langs->trans("Currency".$conf->monnaie)).'</div>' ; $mesg = '<div class="error">'.$langs->trans("CantBeLessThanMinPrice",price2num($price_min,'MU').' '.$langs->trans("Currency".$conf->monnaie)).'</div>' ;
$result=-1; $result=-1;
} }

View File

@ -909,7 +909,7 @@ if (($_POST['action'] == 'addline' || $_POST['action'] == 'addline_predef') && $
{ {
if($price_min && (price2num($pu_ht)*(1-price2num($_POST['remise_percent'])/100) < price2num($price_min))) if($price_min && (price2num($pu_ht)*(1-price2num($_POST['remise_percent'])/100) < price2num($price_min)))
{ {
$object->error = $langs->trans("CantBeLessThanMinPrice",price2num($prod->price_min,'MU').' '.$langs->trans("Currency".$conf->monnaie)) ; $object->error = $langs->trans("CantBeLessThanMinPrice",price2num($price_min,'MU').' '.$langs->trans("Currency".$conf->monnaie)) ;
$result = -1 ; $result = -1 ;
} }
else else
@ -1005,11 +1005,13 @@ if ($_POST['action'] == 'updateligne' && $user->rights->facture->creer && $_POST
$product = new Product($db); $product = new Product($db);
$product->fetch($productid); $product->fetch($productid);
$type=$product->type; $type=$product->type;
$price_min = $product->price_min;
if ($conf->global->PRODUIT_MULTIPRICES && $object->client->price_level) $price_min = $product->multiprices_min[$object->client->price_level];
} }
if ($object->type!=2 && $product->price_min && GETPOST('productid') && (price2num($up_ht)*(1-price2num(GETPOST('remise_percent'))/100) < price2num($product->price_min))) if ($object->type!=2 && $price_min && GETPOST('productid') && (price2num($up_ht)*(1-price2num(GETPOST('remise_percent'))/100) < price2num($price_min)))
{ {
//print "CantBeLessThanMinPrice ".$up_ht." - ".GETPOST('remise_percent')." - ".$product->price_min; //print "CantBeLessThanMinPrice ".$up_ht." - ".GETPOST('remise_percent')." - ".$product->price_min;
$mesg = '<div class="error">'.$langs->trans("CantBeLessThanMinPrice",price2num($product->price_min,'MU').' '.$langs->trans("Currency".$conf->monnaie)).'</div>'; $mesg = '<div class="error">'.$langs->trans("CantBeLessThanMinPrice",price2num($price_min,'MU').' '.$langs->trans("Currency".$conf->monnaie)).'</div>';
$result=-1; $result=-1;
} }