Qual: Simplify and fix multiprice management
This commit is contained in:
parent
a8af3d474e
commit
aa23471000
@ -397,10 +397,12 @@ class Product extends CommonObject
|
||||
{
|
||||
// Multilangs
|
||||
if($conf->global->MAIN_MULTILANGS)
|
||||
if ( $this->setMultiLangs() < 0)
|
||||
{
|
||||
$this->error=$langs->trans("Error")." : ".$this->db->error()." - ".$sql;
|
||||
return -2;
|
||||
if ( $this->setMultiLangs() < 0)
|
||||
{
|
||||
$this->error=$langs->trans("Error")." : ".$this->db->error()." - ".$sql;
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@ -648,86 +650,30 @@ class Product extends CommonObject
|
||||
|
||||
|
||||
/**
|
||||
* \brief Ajoute un changement de prix en base dans l'historique des prix
|
||||
* \param user Objet utilisateur qui modifie le prix
|
||||
* \return int <0 si KO, >0 si OK
|
||||
* \brief Ajoute un changement de prix en base dans l'historique des prix
|
||||
* \param user Objet utilisateur qui modifie le prix
|
||||
* \return int <0 si KO, >0 si OK
|
||||
*/
|
||||
function _log_price($user)
|
||||
function _log_price($user,$level=0)
|
||||
{
|
||||
// MultiPrix : si activ<69>, on g<>re tout ici, m<>me le prix standard
|
||||
global $conf;
|
||||
// Add new price
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product_price(price_level,date_price,fk_product,fk_user_author,price,price_ttc,price_base_type,envente,tva_tx,";
|
||||
$sql.= " price_min,price_min_ttc) ";
|
||||
$sql.= " VALUES(".($level?$level:1).", ".$this->db->idate(mktime()).",".$this->id.",".$user->id.",".$this->price.",".$this->price_ttc.",'".$this->price_base_type."',".$this->status.",".$this->tva_tx.",";
|
||||
$sql.= " ".$this->price_min.",".$this->price_min_ttc;
|
||||
$sql.= ")";
|
||||
|
||||
if ($conf->global->PRODUIT_MULTIPRICES)
|
||||
dolibarr_syslog("Product::_log_price sql=".$sql);
|
||||
$resql=$this->db->query($sql);
|
||||
if(! $resql)
|
||||
{
|
||||
$queryError = false;
|
||||
for($i=2;$i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT;$i++)
|
||||
{
|
||||
if($this->multiprices["$i"] != "")
|
||||
{
|
||||
// Prise en compte du type
|
||||
if ($this->multiprices_base_type["$i"] == 'TTC')
|
||||
{
|
||||
$multiprice_ttc = price2num($this->multiprices["$i"],'MU');
|
||||
$multiprice_ht = price2num($this->multiprices["$i"] / (1 + ($this->tva_tx / 100)),'MU');
|
||||
}
|
||||
else
|
||||
{
|
||||
$multiprice_ht = price2num($this->multiprices["$i"],'MU');
|
||||
$multiprice_ttc = price2num($this->multiprices["$i"] * (1 + ($this->tva_tx / 100)),'MU');
|
||||
}
|
||||
|
||||
// On ajoute nouveau tarif
|
||||
$sql_multiprix = "INSERT INTO ".MAIN_DB_PREFIX."product_price(date_price,fk_product,fk_user_author,price_level,price,price_ttc,price_base_type,tva_tx) ";
|
||||
$sql_multiprix.= " VALUES(".$this->db->idate(mktime()).",".$this->id.",".$user->id.",".$i.",".price2num($multiprice_ht).",'".price2num($multiprice_ttc)."','".$this->multiprices_base_type["$i"]."',".$this->tva_tx;
|
||||
$sql_multiprix.= ")";
|
||||
if (! $this->db->query($sql_multiprix) )
|
||||
{
|
||||
$queryError = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (strlen(trim($this->price)) > 0 )
|
||||
{
|
||||
// On ajoute nouveau tarif
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product_price(date_price,fk_product,fk_user_author,price,price_ttc,price_base_type,envente,tva_tx,price_min,price_min_ttc) ";
|
||||
$sql.= " VALUES(".$this->db->idate(mktime()).",".$this->id.",".$user->id.",".$this->price.",".$this->price_ttc.",'".$this->price_base_type."',".$this->status.",".$this->tva_tx;
|
||||
$sql.= ",".$this->price_min.",".$this->price_min_ttc;
|
||||
$sql.= ")";
|
||||
if (! $this->db->query($sql) )
|
||||
$queryError = true;
|
||||
}
|
||||
if($queryError)
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
return 1;
|
||||
$this->error=$this->db->error();
|
||||
dolibarr_print_error($this->db);
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$queryError = false;
|
||||
|
||||
// On ajoute nouveau tarif
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product_price(date_price,fk_product,fk_user_author,price,price_ttc,price_base_type,envente,tva_tx,price_min,price_min_ttc) ";
|
||||
$sql.= " VALUES(".$this->db->idate(mktime()).",".$this->id.",".$user->id.",".$this->price.",".$this->price_ttc.",'".$this->price_base_type."',".$this->status.",".$this->tva_tx;
|
||||
$sql.= ",".$this->price_min.",".$this->price_min_ttc;
|
||||
$sql.= ")";
|
||||
|
||||
dolibarr_syslog("Product::_log_price sql=".$sql);
|
||||
$resql=$this->db->query($sql);
|
||||
if (!$resql)
|
||||
$queryError = true;
|
||||
|
||||
if($queryError)
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -743,7 +689,7 @@ class Product extends CommonObject
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."product_price";
|
||||
$sql.= " WHERE rowid=".$rowid;
|
||||
|
||||
dolibarr_syslog("Product::log_price_delete sql=".$sql);
|
||||
dolibarr_syslog("Product::log_price_delete sql=".$sql, LOG_DEBUG);
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
@ -842,13 +788,15 @@ class Product extends CommonObject
|
||||
* \param newpricebase HT ou TTC
|
||||
* \param user Objet utilisateur qui modifie le prix
|
||||
* \param newvat New VAT Rate
|
||||
* \param newminprice New price min
|
||||
* \param level 0=standard, >0 = level if multilevel prices
|
||||
* \return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function update_price($id, $newprice, $newpricebase, $user, $newvat='',$newminprice='')
|
||||
function update_price($id, $newprice, $newpricebase, $user, $newvat='',$newminprice='', $level=0)
|
||||
{
|
||||
//multiprix
|
||||
global $conf,$langs;
|
||||
dolibarr_syslog("Product::update_price id=".$id." newprice=".$newprice." newpricebase=".$newpricebase, LOG_DEBUG);
|
||||
|
||||
dolibarr_syslog("Product::update_price id=".$id." newprice=".$newprice." newpricebase=".$newpricebase." newminprice=".$newminprice." level=".$level, LOG_DEBUG);
|
||||
|
||||
if ($newvat == '') $newvat=$this->tva_tx;
|
||||
|
||||
@ -860,7 +808,7 @@ class Product extends CommonObject
|
||||
$price = price2num($newprice) / (1 + ($newvat / 100));
|
||||
$price = price2num($price,'MU');
|
||||
|
||||
if($newminprice!='')
|
||||
if ($newminprice!='')
|
||||
{
|
||||
$price_min_ttc = price2num($newminprice,'MU');
|
||||
$price_min = price2num($newminprice) / (1 + ($newvat / 100));
|
||||
@ -914,25 +862,15 @@ class Product extends CommonObject
|
||||
$this->price_base_type = $newpricebase;
|
||||
$this->tva_tx = $newvat;
|
||||
|
||||
$this->_log_price($user);
|
||||
return 1;
|
||||
$this->_log_price($user,$level);
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else if(($conf->global->PRODUIT_MULTIPRICES) && (count($this->multiprices) > 0))
|
||||
{
|
||||
$this->_log_price($user);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error = $langs->trans("ErrorBadParameter");
|
||||
return -2;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@ -957,7 +895,8 @@ class Product extends CommonObject
|
||||
return -1;
|
||||
}
|
||||
|
||||
$sql = "SELECT rowid, ref, label, description, note, price, price_ttc, price_min, price_min_ttc, price_base_type, tva_tx, envente,";
|
||||
$sql = "SELECT rowid, ref, label, description, note, price, price_ttc,";
|
||||
$sql.= " price_min, price_min_ttc, price_base_type, tva_tx, envente,";
|
||||
$sql.= " fk_product_type, duration, seuil_stock_alerte,canvas,";
|
||||
$sql.= " stock_commande, stock_loc, weight, weight_units, volume, volume_units, barcode, fk_barcode_type, finished";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."product";
|
||||
@ -1002,6 +941,7 @@ class Product extends CommonObject
|
||||
$this->label_url = '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$this->id.'">'.$this->libelle.'</a>';
|
||||
|
||||
$this->db->free();
|
||||
|
||||
// multilangs
|
||||
if ($conf->global->MAIN_MULTILANGS) $this->getMultiLangs();
|
||||
|
||||
@ -1037,52 +977,25 @@ class Product extends CommonObject
|
||||
// multiprix
|
||||
if ($conf->global->PRODUIT_MULTIPRICES)
|
||||
{
|
||||
if ($ref)
|
||||
for ($i=1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++)
|
||||
{
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product ";
|
||||
$sql.= "WHERE ref = '".addslashes($ref)."'";
|
||||
$result = $this->db->query($sql) ;
|
||||
if ($result)
|
||||
{
|
||||
$result = $this->db->fetch_array();
|
||||
$prodid = $result["rowid"];
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
$this->multiprices[1] = $this->price;
|
||||
$this->multiprices_ttc[1] = $this->price_ttc;
|
||||
$this->multiprices_base_type[1] = $this->price_base_type;
|
||||
$sql = "SELECT price, price_ttc, price_min, price_min_ttc,";
|
||||
$sql.= " price_base_type, tva_tx, envente";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."product_price";
|
||||
$sql.= " where price_level=".$i." and";
|
||||
$sql.= " fk_product = '".$this->id."'";
|
||||
$sql.= " order by date_price DESC limit 1";
|
||||
|
||||
for($i=2;$i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT;$i++)
|
||||
{
|
||||
$sql= "SELECT price, price_ttc, price_base_type, tva_tx, envente ";
|
||||
$sql.= "FROM ".MAIN_DB_PREFIX."product_price ";
|
||||
$sql.= "where price_level=".$i." and ";
|
||||
if ($id) $sql.= "fk_product = '".$id."' ";
|
||||
if ($ref) $sql.= "fk_product = '".$prodid."' ";
|
||||
$sql.= "order by date_price DESC limit 1";
|
||||
$result = $this->db->query($sql) ;
|
||||
if ( $result )
|
||||
{
|
||||
$result = $this->db->fetch_array();
|
||||
|
||||
if ($result["price"] != "" && $result["price"] != "0.00")
|
||||
{
|
||||
$this->multiprices[$i]=$result["price"];
|
||||
$this->multiprices_ttc[$i]=$result["price_ttc"];
|
||||
$this->multiprices_base_type[$i] = $result["price_base_type"];
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->multiprices[$i]=$this->price;
|
||||
$this->multiprices_ttc[$i]=$this->price_ttc;
|
||||
$this->multiprices_base_type[$i] = $this->price_base_type;
|
||||
}
|
||||
$this->multiprices[$i]=$result["price"];
|
||||
$this->multiprices_ttc[$i]=$result["price_ttc"];
|
||||
$this->multiprices_min[$i]=$result["price_min"];
|
||||
$this->multiprices_min_ttc[$i]=$result["price_min_ttc"];
|
||||
$this->multiprices_base_type[$i]=$result["price_base_type"];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -53,47 +53,32 @@ if ($_POST["action"] == 'update_price' && ! $_POST["cancel"] && $user->rights->p
|
||||
if($conf->global->PRODUIT_MULTIPRICES)
|
||||
{
|
||||
$newprice='';
|
||||
$newprice_min='';
|
||||
$newpricebase='';
|
||||
$newvat='';
|
||||
|
||||
for($i=1;$i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT;$i++)
|
||||
for($i=1; $i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++)
|
||||
{
|
||||
if($_POST["price_".$i])
|
||||
if ($_POST["price_".$i])
|
||||
{
|
||||
// le prix 1 est considere comme le prix de base du produit
|
||||
if ($i == 1)
|
||||
{
|
||||
$newprice=price2num($_POST["price_".$i],'MU');
|
||||
$newpricebase=$_POST["multiprices_base_type_".$i];
|
||||
$newvat=$_POST["tva_tx_".$i];
|
||||
}
|
||||
else
|
||||
{
|
||||
$product->multiprices["$i"] = price2num($_POST["price_".$i],'MU');
|
||||
$product->multiprices_base_type["$i"] = $_POST["multiprices_base_type_".$i];
|
||||
$product->multiprices_vat_rate["$i"] = $_POST["tva_tx_".$i];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$product->multiprices["$i"] = "";
|
||||
$product->multiprices_ttc["$i"] = "";
|
||||
$product->multiprices_base_type["$i"] = "";
|
||||
$product->multiprices_vat_rate["$i"] = "";
|
||||
$level=$i;
|
||||
$newprice=price2num($_POST["price_".$i],'MU');
|
||||
$newprice_min=price2num($_POST["price_min_".$i],'MU');
|
||||
$newpricebase=$_POST["multiprices_base_type_".$i];
|
||||
$newvat=$_POST["tva_tx_".$i];
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$level=0;
|
||||
$newprice=price2num($_POST["price"],'MU');
|
||||
$newprice_min=price2num($_POST["price_min"],'MU');
|
||||
$newpricebase=$_POST["price_base_type"];
|
||||
$newvat=$_POST["tva_tx"];
|
||||
}
|
||||
|
||||
$newprice_min = '' ;
|
||||
$newprice_min = price2num($_POST["price_min"],'MU');
|
||||
|
||||
if ($product->update_price($product->id, $newprice, $newpricebase, $user, $newvat,$newprice_min) > 0)
|
||||
if ($product->update_price($product->id, $newprice, $newpricebase, $user, $newvat,$newprice_min, $level) > 0)
|
||||
{
|
||||
$_GET["action"] = '';
|
||||
$mesg = '<div class="ok">'.$langs->trans("RecordSaved").'</div>';
|
||||
@ -145,7 +130,7 @@ print '</tr>';
|
||||
|
||||
|
||||
// MultiPrix
|
||||
if($conf->global->PRODUIT_MULTIPRICES)
|
||||
if ($conf->global->PRODUIT_MULTIPRICES)
|
||||
{
|
||||
for($i=1;$i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT;$i++)
|
||||
{
|
||||
@ -169,11 +154,23 @@ if($conf->global->PRODUIT_MULTIPRICES)
|
||||
print ' '.$langs->trans($product->price_base_type);
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Prix minimum
|
||||
print '<tr><td>'.$langs->trans("MinPrice").'</td><td>';
|
||||
if ($product->multiprices_base_type["$i"] == 'TTC')
|
||||
{
|
||||
print price($product->multiprices_min_ttc["$i"]).' '.$langs->trans($product->multiprices_base_type["$i"]);
|
||||
}
|
||||
else
|
||||
{
|
||||
print price($product->multiprices_min["$i"]).' '.$langs->trans($product->multiprices_base_type["$i"]);
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
}
|
||||
// Prix
|
||||
else
|
||||
{
|
||||
// Prix
|
||||
print '<tr><td>'.$langs->trans("SellingPrice").'</td><td colspan="2">';
|
||||
if ($product->price_base_type == 'TTC')
|
||||
{
|
||||
@ -183,19 +180,19 @@ else
|
||||
{
|
||||
print price($product->price).' '.$langs->trans($product->price_base_type).'</td></tr>';
|
||||
}
|
||||
}
|
||||
|
||||
// Prix minimum
|
||||
print '<tr><td>'.$langs->trans("MinPrice").'</td><td>';
|
||||
if ($product->price_base_type == 'TTC')
|
||||
{
|
||||
print price($product->price_min_ttc).' '.$langs->trans($product->price_base_type);
|
||||
// Prix minimum
|
||||
print '<tr><td>'.$langs->trans("MinPrice").'</td><td>';
|
||||
if ($product->price_base_type == 'TTC')
|
||||
{
|
||||
print price($product->price_min_ttc).' '.$langs->trans($product->price_base_type);
|
||||
}
|
||||
else
|
||||
{
|
||||
print price($product->price_min).' '.$langs->trans($product->price_base_type);
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print price($product->price_min).' '.$langs->trans($product->price_base_type);
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// TVA
|
||||
print '<tr><td>'.$langs->trans("VATRate").'</td><td colspan="2">'.vatrate($product->tva_tx,true).'</td></tr>';
|
||||
@ -237,7 +234,7 @@ if (empty($_GET["action"]) || $_GET["action"]=='delete')
|
||||
*/
|
||||
if ($_GET["action"] == 'edit_price' && $user->rights->produit->creer)
|
||||
{
|
||||
print_fiche_titre($langs->trans("NewPrice"));
|
||||
print_fiche_titre($langs->trans("NewPrice"),'','');
|
||||
|
||||
if (! $conf->global->PRODUIT_MULTIPRICES)
|
||||
{
|
||||
@ -256,19 +253,20 @@ if ($_GET["action"] == 'edit_price' && $user->rights->produit->creer)
|
||||
print '</tr>';
|
||||
|
||||
// Price
|
||||
print '<tr><td width="15%">';
|
||||
print '<tr><td width="20%">';
|
||||
$text=$langs->trans('SellingPrice');
|
||||
print $html->textwithhelp($text,$langs->trans("PrecisionUnitIsLimitedToXDecimals",$conf->global->MAIN_MAX_DECIMALS_UNIT),$direction=1,$usehelpcursor=1);
|
||||
print '</td>';
|
||||
print '</td><td>';
|
||||
if ($product->price_base_type == 'TTC')
|
||||
{
|
||||
print '<td><input name="price" size="10" value="'.price($product->price_ttc).'">';
|
||||
print '<input name="price" size="10" value="'.price($product->price_ttc).'">';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td><input name="price" size="10" value="'.price($product->price).'">';
|
||||
print '<input name="price" size="10" value="'.price($product->price).'">';
|
||||
}
|
||||
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td>' ;
|
||||
$text=$langs->trans('MinPrice') ;
|
||||
print $html->textwithhelp($text,$langs->trans("PrecisionUnitIsLimitedToXDecimals",$conf->global->MAIN_MAX_DECIMALS_UNIT),$direction=1,$usehelpcursor=1);
|
||||
@ -283,7 +281,7 @@ if ($_GET["action"] == 'edit_price' && $user->rights->produit->creer)
|
||||
print '</td></tr>';
|
||||
|
||||
// VAT
|
||||
print '<tr><td width="20%">'.$langs->trans("VATRate").'</td><td>';
|
||||
print '<tr><td>'.$langs->trans("VATRate").'</td><td>';
|
||||
print $html->select_tva("tva_tx",$product->tva_tx,$mysoc,'');
|
||||
print '</td></tr>';
|
||||
|
||||
@ -294,44 +292,42 @@ if ($_GET["action"] == 'edit_price' && $user->rights->produit->creer)
|
||||
}
|
||||
else
|
||||
{
|
||||
for($i=1;$i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT;$i++)
|
||||
for($i=1; $i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++)
|
||||
{
|
||||
print '<form action="price.php?id='.$product->id.'" method="post">';
|
||||
print '<input type="hidden" name="action" value="update_price">';
|
||||
print '<input type="hidden" name="id" value="'.$product->id.'">';
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr><td width="15%">';
|
||||
print '<tr><td width="20%">';
|
||||
$text=$langs->trans('SellingPrice').' '.$i;
|
||||
print $html->textwithhelp($text,$langs->trans("PrecisionUnitIsLimitedToXDecimals",$conf->global->MAIN_MAX_DECIMALS_UNIT),$direction=1,$usehelpcursor=1);
|
||||
print '</td>';
|
||||
|
||||
print '</td><td>';
|
||||
if ($product->multiprices_base_type["$i"] == 'TTC')
|
||||
{
|
||||
print '<td><input name="price_'.$i.'" size="10" value="'.price($product->multiprices_ttc["$i"]).'">';
|
||||
print '<input name="price_'.$i.'" size="10" value="'.price($product->multiprices_ttc["$i"]).'">';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td><input name="price_'.$i.'" size="10" value="'.price($product->multiprices["$i"]).'">';
|
||||
print '<input name="price_'.$i.'" size="10" value="'.price($product->multiprices["$i"]).'">';
|
||||
}
|
||||
|
||||
print $html->select_PriceBaseType($product->multiprices_base_type["$i"], "multiprices_base_type_".$i);
|
||||
print '</td>';
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td>' ;
|
||||
print '<tr><td>';
|
||||
$text=$langs->trans('MinPrice') ;
|
||||
print $html->textwithhelp($text,$langs->trans("PrecisionUnitIsLimitedToXDecimals",$conf->global->MAIN_MAX_DECIMALS_UNIT),$direction=1,$usehelpcursor=1);
|
||||
if ($product->price_base_type == 'TTC')
|
||||
if ($product->multiprices_base_type["$i"] == 'TTC')
|
||||
{
|
||||
print '<td><input name="price_min" size="10" value="'.price($product->price_min_ttc).'">';
|
||||
print '<td><input name="price_min_'.$i.'" size="10" value="'.price($product->multiprices_min_ttc["$i"]).'">';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td><input name="price_min" size="10" value="'.price($product->price_min).'">';
|
||||
print '<td><input name="price_min_'.$i.'" size="10" value="'.price($product->multiprices_min["$i"]).'">';
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
print '</td></tr>';
|
||||
|
||||
// VAT
|
||||
print '<td width="20%">'.$langs->trans("VATRate").'</td><td>';
|
||||
print '<tr><td>'.$langs->trans("VATRate").'</td><td>';
|
||||
print $html->select_tva("tva_tx_".$i,$product->multiprices_tva_tx["$i"],$mysoc,'');
|
||||
print '</td></tr>';
|
||||
|
||||
@ -340,31 +336,24 @@ if ($_GET["action"] == 'edit_price' && $user->rights->produit->creer)
|
||||
print '</table>';
|
||||
print '</form>';
|
||||
}
|
||||
|
||||
print '<tr><td colspan="2" align="center"><input type="submit" class="button" value="'.$langs->trans("Save").'"> ';
|
||||
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>';
|
||||
print '</table>';
|
||||
print '</form>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Liste des evolutions du prix
|
||||
if($conf->global->PRODUIT_MULTIPRICES)
|
||||
{
|
||||
$sql = "SELECT p.rowid, p.price, p.price_ttc, p.price_base_type, p.tva_tx,";
|
||||
$sql.= " p.price_level,";
|
||||
$sql.= " ".$db->pdate("p.date_price")." as dp, u.rowid as user_id, u.login";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."product_price as p, ".MAIN_DB_PREFIX."user as u";
|
||||
$sql.= " WHERE fk_product = ".$product->id;
|
||||
$sql.= " AND p.fk_user_author = u.rowid ";
|
||||
$sql.= " ORDER BY p.price_level ASC, p.date_price DESC";
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = "SELECT p.rowid, p.price, p.price_ttc, p.price_base_type, p.tva_tx,";
|
||||
$sql.= " p.price_min, p.price_min_ttc,";
|
||||
$sql.= " ".$db->pdate("p.date_price")." as dp, u.rowid as user_id, u.login";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."product_price as p ";
|
||||
$sql.= " WHERE p.fk_product = ".$product->id;
|
||||
$sql.= " AND p.fk_user_author = u.rowid";
|
||||
$sql.= " ORDER BY p.date_price DESC";
|
||||
}
|
||||
$sql = "SELECT p.rowid, p.price, p.price_ttc, p.price_base_type, p.tva_tx,";
|
||||
$sql.= " p.price_level, p.price_min, p.price_min_ttc,";
|
||||
$sql.= " ".$db->pdate("p.date_price")." as dp, u.rowid as user_id, u.login";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."product_price as p, ".MAIN_DB_PREFIX."user as u";
|
||||
$sql.= " WHERE fk_product = ".$product->id;
|
||||
$sql.= " AND p.fk_user_author = u.rowid";
|
||||
if ($conf->global->PRODUIT_MULTIPRICES) $sql.= " ORDER BY p.price_level ASC, p.date_price DESC";
|
||||
else $sql.= " ORDER BY p.date_price DESC";
|
||||
//$sql .= $db->plimit();
|
||||
|
||||
$result = $db->query($sql) ;
|
||||
@ -421,7 +410,7 @@ if ($result)
|
||||
// Price level
|
||||
if ($conf->global->PRODUIT_MULTIPRICES)
|
||||
{
|
||||
print "<td>".$objp->price_level."</td>";
|
||||
print '<td align="center">'.$objp->price_level."</td>";
|
||||
}
|
||||
|
||||
print '<td align="center">'.$langs->trans($objp->price_base_type)."</td>";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user