Can delete a price line log
This commit is contained in:
parent
def9892548
commit
51160ac2e0
@ -717,15 +717,41 @@ class Product extends CommonObject
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Lit le prix pratiqu<EFBFBD> par un fournisseur
|
* \brief Delete a price line
|
||||||
|
* \param user Object user
|
||||||
|
* \param rowid Line id to delete
|
||||||
|
* \return int <0 if KO, >0 if OK
|
||||||
|
*/
|
||||||
|
function log_price_delete($user,$rowid)
|
||||||
|
{
|
||||||
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."product_price";
|
||||||
|
$sql.= " WHERE rowid=".$rowid;
|
||||||
|
|
||||||
|
dolibarr_syslog("Product::log_price_delete sql=".$sql);
|
||||||
|
$resql=$this->db->query($sql);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->error=$this->db->lasterror();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Lit le prix pratique par un fournisseur
|
||||||
* On renseigne le couple prodfournprice/qty ou le triplet qty/product_id/fourn_ref)
|
* On renseigne le couple prodfournprice/qty ou le triplet qty/product_id/fourn_ref)
|
||||||
* \param prodfournprice Id du tarif = rowid table product_fournisseur_price
|
* \param prodfournprice Id du tarif = rowid table product_fournisseur_price
|
||||||
* \param qty Quantit<EFBFBD> du produit
|
* \param qty Quantit<EFBFBD> du produit
|
||||||
|
|||||||
@ -25,7 +25,7 @@
|
|||||||
\ingroup product
|
\ingroup product
|
||||||
\brief Page de la fiche produit
|
\brief Page de la fiche produit
|
||||||
\version $Id$
|
\version $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require("./pre.inc.php");
|
require("./pre.inc.php");
|
||||||
require_once(DOL_DOCUMENT_ROOT."/lib/product.lib.php");
|
require_once(DOL_DOCUMENT_ROOT."/lib/product.lib.php");
|
||||||
@ -43,8 +43,7 @@ accessforbidden();
|
|||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ($_POST["action"] == 'update_price' &&
|
if ($_POST["action"] == 'update_price' && ! $_POST["cancel"] && $user->rights->produit->creer)
|
||||||
! $_POST["cancel"] && $user->rights->produit->creer)
|
|
||||||
{
|
{
|
||||||
$product = new Product($db);
|
$product = new Product($db);
|
||||||
|
|
||||||
@ -61,7 +60,7 @@ if ($_POST["action"] == 'update_price' &&
|
|||||||
{
|
{
|
||||||
if($_POST["price_".$i])
|
if($_POST["price_".$i])
|
||||||
{
|
{
|
||||||
// le prix 1 est considéré comme le prix de base du produit
|
// le prix 1 est considere comme le prix de base du produit
|
||||||
if ($i == 1)
|
if ($i == 1)
|
||||||
{
|
{
|
||||||
$newprice=price2num($_POST["price_".$i],'MU');
|
$newprice=price2num($_POST["price_".$i],'MU');
|
||||||
@ -106,10 +105,18 @@ if ($_POST["action"] == 'update_price' &&
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($_GET["action"] == 'delete' && $user->rights->produit->creer)
|
||||||
|
{
|
||||||
|
$productstatic = new Product($db);
|
||||||
|
$result=$productstatic->log_price_delete($user,$_GET["lineid"]);
|
||||||
|
if ($result < 0) $mesg='<div class="error">'.$productstatic->error.'</div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Affiche historique prix
|
* View
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$html = new Form($db);
|
$html = new Form($db);
|
||||||
|
|
||||||
$product = new Product($db);
|
$product = new Product($db);
|
||||||
@ -118,6 +125,8 @@ if ($_GET["id"]) $result = $product->fetch($_GET["id"]);
|
|||||||
|
|
||||||
llxHeader("","",$langs->trans("CardProduct".$product->type));
|
llxHeader("","",$langs->trans("CardProduct".$product->type));
|
||||||
|
|
||||||
|
if ($mesg) print $mesg;
|
||||||
|
|
||||||
$head=product_prepare_head($product, $user);
|
$head=product_prepare_head($product, $user);
|
||||||
$titre=$langs->trans("CardProduct".$product->type);
|
$titre=$langs->trans("CardProduct".$product->type);
|
||||||
dolibarr_fiche_head($head, 'price', $titre);
|
dolibarr_fiche_head($head, 'price', $titre);
|
||||||
@ -210,7 +219,7 @@ print "</div>\n";
|
|||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
if (! $_GET["action"])
|
if (empty($_GET["action"]) || $_GET["action"]=='delete')
|
||||||
{
|
{
|
||||||
print "\n<div class=\"tabsAction\">\n";
|
print "\n<div class=\"tabsAction\">\n";
|
||||||
|
|
||||||
@ -238,12 +247,20 @@ 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%">';
|
||||||
|
|
||||||
|
// Price base
|
||||||
|
print '<tr><td width="15%">';
|
||||||
|
print $langs->trans('PriceBase');
|
||||||
|
print '</td>';
|
||||||
|
print '<td>';
|
||||||
|
print $html->select_PriceBaseType($product->price_base_type, "price_base_type");
|
||||||
|
print '</td>';
|
||||||
|
print '</tr>';
|
||||||
|
|
||||||
// Price
|
// Price
|
||||||
print '<tr><td width="15%">';
|
print '<tr><td width="15%">';
|
||||||
$text=$langs->trans('SellingPrice');
|
$text=$langs->trans('SellingPrice');
|
||||||
print $html->textwithhelp($text,$langs->trans("PrecisionUnitIsLimitedToXDecimals",$conf->global->MAIN_MAX_DECIMALS_UNIT),$direction=1,$usehelpcursor=1);
|
print $html->textwithhelp($text,$langs->trans("PrecisionUnitIsLimitedToXDecimals",$conf->global->MAIN_MAX_DECIMALS_UNIT),$direction=1,$usehelpcursor=1);
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
if ($product->price_base_type == 'TTC')
|
if ($product->price_base_type == 'TTC')
|
||||||
{
|
{
|
||||||
print '<td><input name="price" size="10" value="'.price($product->price_ttc).'">';
|
print '<td><input name="price" size="10" value="'.price($product->price_ttc).'">';
|
||||||
@ -264,9 +281,6 @@ if ($_GET["action"] == 'edit_price' && $user->rights->produit->creer)
|
|||||||
{
|
{
|
||||||
print '<td><input name="price_min" size="10" value="'.price($product->price_min).'">';
|
print '<td><input name="price_min" size="10" value="'.price($product->price_min).'">';
|
||||||
}
|
}
|
||||||
print '</td>';
|
|
||||||
|
|
||||||
print $html->select_PriceBaseType($product->price_base_type, "price_base_type");
|
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
// VAT
|
// VAT
|
||||||
@ -364,8 +378,8 @@ if ($result)
|
|||||||
$db->free($result) ;
|
$db->free($result) ;
|
||||||
|
|
||||||
// Il doit au moins y avoir la ligne de prix initial.
|
// Il doit au moins y avoir la ligne de prix initial.
|
||||||
// On l'ajoute donc pour remettre à niveau (pb vieilles versions)
|
// On l'ajoute donc pour remettre a niveau (pb vieilles versions)
|
||||||
$product->update_price($product->id, $product->price, 'HT' ,$user,$newprice_min);
|
$product->update_price($product->id, $product->price, 'HT', $user, $newprice_min);
|
||||||
|
|
||||||
$result = $db->query($sql) ;
|
$result = $db->query($sql) ;
|
||||||
$num = $db->num_rows($result);
|
$num = $db->num_rows($result);
|
||||||
@ -392,6 +406,7 @@ if ($result)
|
|||||||
print '<td align="right">'.$langs->trans("MinPrice").' '.$langs->trans("HT").'</td>';
|
print '<td align="right">'.$langs->trans("MinPrice").' '.$langs->trans("HT").'</td>';
|
||||||
print '<td align="right">'.$langs->trans("MinPrice").' '.$langs->trans("TTC").'</td>';
|
print '<td align="right">'.$langs->trans("MinPrice").' '.$langs->trans("TTC").'</td>';
|
||||||
print '<td align="right">'.$langs->trans("ChangedBy").'</td>';
|
print '<td align="right">'.$langs->trans("ChangedBy").'</td>';
|
||||||
|
if ($user->rights->produit->creer) print '<td align="right"> </td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
$var=True;
|
$var=True;
|
||||||
@ -404,7 +419,7 @@ if ($result)
|
|||||||
// Date
|
// Date
|
||||||
print "<td>".dolibarr_print_date($objp->dp,"dayhour")."</td>";
|
print "<td>".dolibarr_print_date($objp->dp,"dayhour")."</td>";
|
||||||
|
|
||||||
// catégorie de Prix
|
// Price level
|
||||||
if ($conf->global->PRODUIT_MULTIPRICES)
|
if ($conf->global->PRODUIT_MULTIPRICES)
|
||||||
{
|
{
|
||||||
print "<td>".$objp->price_level."</td>";
|
print "<td>".$objp->price_level."</td>";
|
||||||
@ -419,6 +434,21 @@ if ($result)
|
|||||||
|
|
||||||
// User
|
// User
|
||||||
print '<td align="right"><a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$objp->user_id.'">'.img_object($langs->trans("ShowUser"),'user').' '.$objp->login.'</a></td>';
|
print '<td align="right"><a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$objp->user_id.'">'.img_object($langs->trans("ShowUser"),'user').' '.$objp->login.'</a></td>';
|
||||||
|
|
||||||
|
// Action
|
||||||
|
if ($user->rights->produit->creer)
|
||||||
|
{
|
||||||
|
print '<td align="right">';
|
||||||
|
if ($i > 0)
|
||||||
|
{
|
||||||
|
print '<a href="'.$_SERVER["PHP_SELF"].'?action=delete&id='.$product->id.'&lineid='.$objp->rowid.'">';
|
||||||
|
print img_delete();
|
||||||
|
print '</a>';
|
||||||
|
}
|
||||||
|
else print ' '; // Can not delete last price (it's current price)
|
||||||
|
print '</td>';
|
||||||
|
}
|
||||||
|
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user