Gestion du prix TTC
This commit is contained in:
parent
56f967f6dc
commit
ad75950faa
@ -46,6 +46,9 @@ class Product
|
|||||||
var $description;
|
var $description;
|
||||||
//! Prix de vente
|
//! Prix de vente
|
||||||
var $price;
|
var $price;
|
||||||
|
//! Base de prix (ttc ou ht)
|
||||||
|
var $price_base_type;
|
||||||
|
//! Tableau des prix multiples
|
||||||
var $multiprices=array();
|
var $multiprices=array();
|
||||||
//! Taux de TVA
|
//! Taux de TVA
|
||||||
var $tva_tx;
|
var $tva_tx;
|
||||||
@ -707,9 +710,9 @@ class Product
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Modifie le prix d'un produit/service
|
\brief Modifie le prix d'un produit/service
|
||||||
* \param id id du produit/service à modifier
|
\param id id du produit/service à modifier
|
||||||
* \param user utilisateur qui modifie le prix
|
\param user utilisateur qui modifie le prix
|
||||||
*/
|
*/
|
||||||
function update_price($id, $user)
|
function update_price($id, $user)
|
||||||
{
|
{
|
||||||
@ -749,10 +752,24 @@ class Product
|
|||||||
{
|
{
|
||||||
if (strlen(trim($this->price)) > 0 )
|
if (strlen(trim($this->price)) > 0 )
|
||||||
{
|
{
|
||||||
|
if ($this->price_base_type == 'TTC')
|
||||||
|
{
|
||||||
|
$price_ttc = $this->price;
|
||||||
|
$this->price = $this->price / (1 + ($this->tva_tx / 100));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$price_ttc = $this->price * (1 + ($this->tva_tx / 100));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."product ";
|
$sql = "UPDATE ".MAIN_DB_PREFIX."product ";
|
||||||
$sql .= " SET price = " . price2num($this->price);
|
$sql .= " SET price = " . price2num($this->price);
|
||||||
$sql .= " WHERE rowid = " . $id;
|
$sql .= " , price_base_type='".$this->price_base_type."'";
|
||||||
|
$sql .= " , price_ttc='".$price_ttc."'";
|
||||||
|
|
||||||
|
$sql .= " WHERE rowid = " . $id;
|
||||||
|
|
||||||
if ( $this->db->query($sql) )
|
if ( $this->db->query($sql) )
|
||||||
{
|
{
|
||||||
$this->_log_price($user);
|
$this->_log_price($user);
|
||||||
@ -794,7 +811,7 @@ class Product
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "SELECT rowid, ref, label, description, note, price, tva_tx, envente,";
|
$sql = "SELECT rowid, ref, label, description, note, price, price_ttc, price_base_type, tva_tx, envente,";
|
||||||
$sql.= " nbvente, fk_product_type, duration, seuil_stock_alerte,canvas,";
|
$sql.= " nbvente, fk_product_type, duration, seuil_stock_alerte,canvas,";
|
||||||
$sql.= " stock_commande, stock_loc, weight, weight_units";
|
$sql.= " stock_commande, stock_loc, weight, weight_units";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."product";
|
$sql.= " FROM ".MAIN_DB_PREFIX."product";
|
||||||
@ -812,6 +829,8 @@ class Product
|
|||||||
$this->description = stripslashes($result["description"]);
|
$this->description = stripslashes($result["description"]);
|
||||||
$this->note = stripslashes($result["note"]);
|
$this->note = stripslashes($result["note"]);
|
||||||
$this->price = $result["price"];
|
$this->price = $result["price"];
|
||||||
|
$this->price_ttc = $result["price_ttc"];
|
||||||
|
$this->price_base_type = $result["price_base_type"];
|
||||||
$this->tva_tx = $result["tva_tx"];
|
$this->tva_tx = $result["tva_tx"];
|
||||||
$this->type = $result["fk_product_type"];
|
$this->type = $result["fk_product_type"];
|
||||||
$this->nbvente = $result["nbvente"];
|
$this->nbvente = $result["nbvente"];
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -24,10 +24,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\file htdocs/product/price.php
|
\file htdocs/product/price.php
|
||||||
\ingroup product
|
\ingroup product
|
||||||
\brief Page de la fiche produit
|
\brief Page de la fiche produit
|
||||||
\version $Revision$
|
\version $Revision$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require("./pre.inc.php");
|
require("./pre.inc.php");
|
||||||
@ -55,22 +55,23 @@ if ($_POST["action"] == 'update_price' &&
|
|||||||
$_POST["cancel"] <> $langs->trans("Cancel") && $user->rights->produit->creer)
|
$_POST["cancel"] <> $langs->trans("Cancel") && $user->rights->produit->creer)
|
||||||
{
|
{
|
||||||
$product = new Product($db);
|
$product = new Product($db);
|
||||||
|
|
||||||
$result = $product->fetch($_GET["id"]);
|
$result = $product->fetch($_GET["id"]);
|
||||||
|
|
||||||
$product->price = ereg_replace(" ","",$_POST["price"]);
|
$product->price = ereg_replace(" ","",$_POST["price"]);
|
||||||
// MultiPrix
|
$product->price_base_type = $_POST["price_base_type"];
|
||||||
if($conf->global->PRODUIT_MULTIPRICES == 1)
|
// MultiPrix
|
||||||
|
if($conf->global->PRODUIT_MULTIPRICES == 1)
|
||||||
|
{
|
||||||
|
for($i=2;$i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT;$i++)
|
||||||
{
|
{
|
||||||
for($i=2;$i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT;$i++)
|
if($_POST["price_".$i])
|
||||||
{
|
$product->multiprices["$i"]=ereg_replace(" ","",$_POST["price_".$i]);
|
||||||
if($_POST["price_".$i])
|
else
|
||||||
$product->multiprices["$i"]=ereg_replace(" ","",$_POST["price_".$i]);
|
$product->multiprices["$i"] = "";
|
||||||
else
|
|
||||||
$product->multiprices["$i"] = "";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( $product->update_price($product->id, $user) > 0 )
|
if ( $product->update_price($product->id, $user) > 0 )
|
||||||
{
|
{
|
||||||
$_GET["action"] = '';
|
$_GET["action"] = '';
|
||||||
@ -122,16 +123,27 @@ print '</tr>';
|
|||||||
// MultiPrix
|
// MultiPrix
|
||||||
if($conf->global->PRODUIT_MULTIPRICES == 1)
|
if($conf->global->PRODUIT_MULTIPRICES == 1)
|
||||||
{
|
{
|
||||||
print '<tr><td>'.$langs->trans("SellingPrice").' 1</td><td colspan="2">'.price($product->price).'</td></tr>';
|
print '<tr><td>'.$langs->trans("SellingPrice").' 1</td><td colspan="2">'.price($product->price).'</td></tr>';
|
||||||
for($i=2;$i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT;$i++)
|
for($i=2;$i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT;$i++)
|
||||||
{
|
{
|
||||||
print '<tr><td>'.$langs->trans("SellingPrice").' '.$i.'</td><td>'.price($product->multiprices["$i"]).'</td>';
|
print '<tr><td>'.$langs->trans("SellingPrice").' '.$i.'</td><td>'.price($product->multiprices["$i"]).'</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Prix
|
// Prix
|
||||||
else
|
else
|
||||||
print '<tr><td>'.$langs->trans("SellingPrice").'</td><td colspan="2">'.price($product->price).'</td></tr>';
|
{
|
||||||
|
print '<tr><td>'.$langs->trans("SellingPrice").'</td><td colspan="2">';
|
||||||
|
if ($product->price_base_type == 'TTC')
|
||||||
|
{
|
||||||
|
print price($product->price_ttc).' '.$langs->trans($product->price_base_type).'</td></tr>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print price($product->price).' '.$langs->trans($product->price_base_type).'</td></tr>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Statut
|
// Statut
|
||||||
print '<tr><td>'.$langs->trans("Status").'</td><td colspan="2">';
|
print '<tr><td>'.$langs->trans("Status").'</td><td colspan="2">';
|
||||||
print $product->getLibStatut(2);
|
print $product->getLibStatut(2);
|
||||||
@ -174,30 +186,46 @@ if ($_GET["action"] == 'edit_price' && $user->rights->produit->creer)
|
|||||||
print '<input type="hidden" name="id" value="'.$product->id.'">';
|
print '<input type="hidden" name="id" value="'.$product->id.'">';
|
||||||
print '<table class="border" width="100%">';
|
print '<table class="border" width="100%">';
|
||||||
if($conf->global->PRODUIT_MULTIPRICES == 1)
|
if($conf->global->PRODUIT_MULTIPRICES == 1)
|
||||||
print '<tr><td width="15%">'.$langs->trans('SellingPrice').' 1</td><td><input name="price" size="10" value="'.price($product->price).'"></td></tr>';
|
{
|
||||||
|
print '<tr><td width="15%">'.$langs->trans('SellingPrice').' 1</td><td><input name="price" size="10" value="'.price($product->price).'"></td></tr>';
|
||||||
|
}
|
||||||
else
|
else
|
||||||
print '<tr><td width="15%">'.$langs->trans('SellingPrice').'</td><td><input name="price" size="10" value="'.price($product->price).'"></td></tr>';
|
{
|
||||||
|
print '<tr><td width="15%">'.$langs->trans('SellingPrice').'</td>';
|
||||||
|
if ($product->price_base_type == 'TTC')
|
||||||
|
{
|
||||||
|
print '<td><input name="price" size="10" value="'.price($product->price_ttc).'">';
|
||||||
|
print '<select class="flat" name="price_base_type"><option value="HT">HT</option><option value="TTC" SELECTED>TTC</option></select>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print '<td><input name="price" size="10" value="'.price($product->price).'">';
|
||||||
|
print '<select class="flat" name="price_base_type"><option value="HT" SELECTED>HT</option><option value="TTC">TTC</option></select>';
|
||||||
|
}
|
||||||
|
print '</td></tr>';
|
||||||
|
}
|
||||||
print '<tr><td colspan="2" align="center"><input type="submit" class="button" value="'.$langs->trans("Save").'"> ';
|
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 '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>';
|
||||||
print '</table>';
|
print '</table>';
|
||||||
print '</form>';
|
print '</form>';
|
||||||
// MultiPrix
|
// MultiPrix
|
||||||
if($conf->global->PRODUIT_MULTIPRICES == 1)
|
if($conf->global->PRODUIT_MULTIPRICES == 1)
|
||||||
|
{
|
||||||
|
for($i=2;$i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT;$i++)
|
||||||
{
|
{
|
||||||
for($i=2;$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 '<form action="price.php?id='.$product->id.'" method="post">';
|
print '<input type="hidden" name="id" value="'.$product->id.'">';
|
||||||
print '<input type="hidden" name="action" value="update_price">';
|
print '<table class="border" width="100%">';
|
||||||
print '<input type="hidden" name="id" value="'.$product->id.'">';
|
print '<tr><td width="15%">'.$langs->trans("SellingPrice").' '.$i.'</td><td><input name="price_'.$i.'" size="10" value="'.price($product->multiprices["$i"]).'"></td>';
|
||||||
print '<table class="border" width="100%">';
|
print '</tr>';
|
||||||
print '<tr><td width="15%">'.$langs->trans("SellingPrice").' '.$i.'</td><td><input name="price_'.$i.'" size="10" value="'.price($product->multiprices["$i"]).'"></td>';
|
print '<tr><td colspan="2" align="center"><input type="submit" class="button" value="'.$langs->trans("Save").'"> ';
|
||||||
print '</tr>';
|
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>';
|
||||||
print '<tr><td colspan="2" align="center"><input type="submit" class="button" value="'.$langs->trans("Save").'"> ';
|
print '</table>';
|
||||||
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>';
|
print '</form>';
|
||||||
print '</table>';
|
|
||||||
print '</form>';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -205,27 +233,23 @@ if ($_GET["action"] == 'edit_price' && $user->rights->produit->creer)
|
|||||||
$sql = "SELECT p.rowid, p.price, ";
|
$sql = "SELECT p.rowid, p.price, ";
|
||||||
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, llx_user as u";
|
$sql .= " FROM ".MAIN_DB_PREFIX."product_price as p, llx_user as u";
|
||||||
$sql .= " WHERE fk_product = ".$product->id;
|
$sql .= " WHERE fk_product = ".$product->id;
|
||||||
$sql .= " AND p.fk_user_author = u.rowid ";
|
$sql .= " AND p.fk_user_author = u.rowid ";
|
||||||
$sql .= " ORDER BY p.price_level ASC ";
|
$sql .= " ORDER BY p.price_level ASC ";
|
||||||
$sql .= ",p.date_price DESC ";
|
$sql .= ",p.date_price DESC ";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$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, llx_user as u";
|
$sql .= " FROM ".MAIN_DB_PREFIX."product_price as p, llx_user as u";
|
||||||
$sql .= " WHERE fk_product = ".$product->id;
|
$sql .= " WHERE fk_product = ".$product->id;
|
||||||
$sql .= " AND p.fk_user_author = u.rowid ";
|
$sql .= " AND p.fk_user_author = u.rowid ";
|
||||||
$sql .= " ORDER BY p.date_price DESC ";
|
$sql .= " ORDER BY p.date_price DESC ";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$sql .= $db->plimit();
|
$sql .= $db->plimit();
|
||||||
$result = $db->query($sql) ;
|
$result = $db->query($sql) ;
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user