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,8 +752,22 @@ 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 .= " , price_base_type='".$this->price_base_type."'";
|
||||||
|
$sql .= " , price_ttc='".$price_ttc."'";
|
||||||
|
|
||||||
$sql .= " WHERE rowid = " . $id;
|
$sql .= " WHERE rowid = " . $id;
|
||||||
|
|
||||||
if ( $this->db->query($sql) )
|
if ( $this->db->query($sql) )
|
||||||
@ -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"];
|
||||||
|
|||||||
@ -4,6 +4,7 @@
|
|||||||
* Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
|
* Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
|
||||||
* Copyright (C) 2005-2006 Régis Houssin <regis.houssin@cap-networks.com>
|
* Copyright (C) 2005-2006 Régis Houssin <regis.houssin@cap-networks.com>
|
||||||
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
||||||
|
* Copyright (C) 2006 Auguria SARL <info@auguria.org>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -651,8 +652,15 @@ if ($_GET["id"] || $_GET["ref"])
|
|||||||
// Prix
|
// Prix
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print '<tr><td>'.$langs->trans("SellingPrice").'</td><td>'.price($product->price).'</td>';
|
print '<tr><td>'.$langs->trans("SellingPrice").'</td><td>';
|
||||||
print '</tr>';
|
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>';
|
print '<tr><td>'.$langs->trans("Status").'</td><td>';
|
||||||
|
|||||||
@ -59,6 +59,7 @@ if ($_POST["action"] == 'update_price' &&
|
|||||||
$result = $product->fetch($_GET["id"]);
|
$result = $product->fetch($_GET["id"]);
|
||||||
|
|
||||||
$product->price = ereg_replace(" ","",$_POST["price"]);
|
$product->price = ereg_replace(" ","",$_POST["price"]);
|
||||||
|
$product->price_base_type = $_POST["price_base_type"];
|
||||||
// MultiPrix
|
// MultiPrix
|
||||||
if($conf->global->PRODUIT_MULTIPRICES == 1)
|
if($conf->global->PRODUIT_MULTIPRICES == 1)
|
||||||
{
|
{
|
||||||
@ -131,7 +132,18 @@ if($conf->global->PRODUIT_MULTIPRICES == 1)
|
|||||||
}
|
}
|
||||||
// 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,9 +186,24 @@ 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>';
|
||||||
@ -198,6 +225,7 @@ if ($_GET["action"] == 'edit_price' && $user->rights->produit->creer)
|
|||||||
print '</form>';
|
print '</form>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -222,10 +250,6 @@ else
|
|||||||
$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