Finalisation de l'ajout de la gestion du HT et TTC avec l'option multiprix

This commit is contained in:
Regis Houssin 2006-12-19 18:15:40 +00:00
parent a585f33dc9
commit 6c286ab6f8
2 changed files with 75 additions and 73 deletions

View File

@ -152,6 +152,20 @@ class Product
if ($this->status=='') $this->status = 0; if ($this->status=='') $this->status = 0;
$this->price = price2num($this->price); $this->price = price2num($this->price);
if (strlen(trim($this->price)) > 0 )
{
if ($this->price_base_type == 'TTC')
{
$price_ttc = $this->price;
$price = $this->price / (1 + ($this->tva_tx / 100));
}
else
{
$price = $this->price;
$price_ttc = $this->price * (1 + ($this->tva_tx / 100));
}
}
dolibarr_syslog("Product::Create ref=".$this->ref." Categorie : ".$this->catid); dolibarr_syslog("Product::Create ref=".$this->ref." Categorie : ".$this->catid);
if (strlen($this->ref) > 0) if (strlen($this->ref) > 0)
@ -171,10 +185,10 @@ class Product
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product "; $sql = "INSERT INTO ".MAIN_DB_PREFIX."product ";
$sql.= " (datec, "; $sql.= " (datec, ";
if ($this->ref) $sql.= "ref, "; if ($this->ref) $sql.= "ref, ";
$sql.= "fk_user_author, fk_product_type, price, canvas)"; $sql.= "fk_user_author, fk_product_type, price, price_ttc, price_base_type, canvas)";
$sql.= " VALUES (now(), "; $sql.= " VALUES (now(), ";
if ($this->ref) $sql.= "'".$this->ref."', "; if ($this->ref) $sql.= "'".$this->ref."', ";
$sql.= $user->id.", ".$this->type.", '" . $this->price . "','".$this->canvas."')"; $sql.= $user->id.", ".$this->type.", '" . $price . "', '".$price_ttc."', '" . $this->price_base_type . "','".$this->canvas."')";
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ( $result ) if ( $result )
{ {
@ -194,7 +208,8 @@ class Product
$this->db->commit(); $this->db->commit();
return $id; return $id;
} }
else { else
{
$this->db->rollback(); $this->db->rollback();
return -5; return -5;
} }
@ -889,7 +904,6 @@ class Product
// multilangs // multilangs
if( $conf->global->MAIN_MULTILANGS) $this->getMultiLangs(); if( $conf->global->MAIN_MULTILANGS) $this->getMultiLangs();
// multiprix // multiprix
if($conf->global->PRODUIT_MULTIPRICES == 1) if($conf->global->PRODUIT_MULTIPRICES == 1)
{ {
@ -923,29 +937,17 @@ class Product
{ {
$result = $this->db->fetch_array(); $result = $this->db->fetch_array();
$this->multiprices_base_type[$i] = $result["price_base_type"];
if($result["price"] != "" && $result["price"] != "0.00") if($result["price"] != "" && $result["price"] != "0.00")
{
if ($result["price_base_type"] == 'TTC')
{
$this->multiprices_ttc[$i]=$result["price_ttc"];
}
else
{ {
$this->multiprices[$i]=$result["price"]; $this->multiprices[$i]=$result["price"];
} $this->multiprices_ttc[$i]=$result["price_ttc"];
} $this->multiprices_base_type[$i] = $result["price_base_type"];
else
{
if ($result["price_base_type"] == 'TTC')
{
$this->multiprices_ttc[$i]=$this->price_ttc;
} }
else else
{ {
$this->multiprices[$i]=$this->price; $this->multiprices[$i]=$this->price;
} $this->multiprices_ttc[$i]=$this->price_ttc;
$this->multiprices_base_type[$i] = $this->price_base_type;
} }
} }
else else

View File

@ -280,10 +280,10 @@ if ($_GET["action"] == 'edit_price' && $user->rights->produit->creer)
// Liste des evolutions du prix // Liste des evolutions du prix
$sql = "SELECT p.rowid, p.price, p.price_ttc, p.price_base_type"; $sql = "SELECT p.rowid, p.price, p.price_ttc, p.price_base_type, ";
if($conf->global->PRODUIT_MULTIPRICES == 1) if($conf->global->PRODUIT_MULTIPRICES == 1)
{ {
$sql .= ", p.price_level, "; $sql .= "p.price_level, ";
$sql .= $db->pdate("p.date_price")." as dp, u.rowid as user_id, u.login"; $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 .= " FROM ".MAIN_DB_PREFIX."product_price as p, ".MAIN_DB_PREFIX."user as u";
$sql .= " WHERE fk_product = ".$product->id; $sql .= " WHERE fk_product = ".$product->id;
@ -352,6 +352,7 @@ if ($result)
if($conf->global->PRODUIT_MULTIPRICES == 1) if($conf->global->PRODUIT_MULTIPRICES == 1)
{ {
print "<td>".$objp->price_level."</td>"; print "<td>".$objp->price_level."</td>";
}
if ($objp->price_base_type == 'TTC') if ($objp->price_base_type == 'TTC')
{ {
@ -362,7 +363,6 @@ if ($result)
print "<td>".price($objp->price); print "<td>".price($objp->price);
} }
print " ".$langs->trans($objp->price_base_type)."</td>"; print " ".$langs->trans($objp->price_base_type)."</td>";
}
// User // User
print '<td><a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$objp->user_id.'">'.img_object($langs->trans("ShowUser"),'user').' '.$objp->login.'</a></td>'; print '<td><a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$objp->user_id.'">'.img_object($langs->trans("ShowUser"),'user').' '.$objp->login.'</a></td>';