Fix: limit view of price for external user with price level

This commit is contained in:
Regis Houssin 2009-08-06 14:25:03 +00:00
parent dddffb657a
commit 7574fea36b
2 changed files with 122 additions and 36 deletions

View File

@ -46,7 +46,7 @@ if (isset($_GET["id"]) || isset($_GET["ref"]))
$id = isset($_GET["id"])?$_GET["id"]:(isset($_GET["ref"])?$_GET["ref"]:''); $id = isset($_GET["id"])?$_GET["id"]:(isset($_GET["ref"])?$_GET["ref"]:'');
} }
$fieldid = isset($_GET["ref"])?'ref':'rowid'; $fieldid = isset($_GET["ref"])?'ref':'rowid';
if ($user->societe_id) $socid=$user->societe_id; $socid=$user->societe_id?$user->societe_id:0;
$result=restrictedArea($user,'produit|service',$id,'product','','',$fieldid); $result=restrictedArea($user,'produit|service',$id,'product','','',$fieldid);
$mesg = ''; $mesg = '';
@ -867,6 +867,47 @@ if ($_GET["id"] || $_GET["ref"])
// MultiPrix // MultiPrix
if($conf->global->PRODUIT_MULTIPRICES) if($conf->global->PRODUIT_MULTIPRICES)
{
if ($socid)
{
$soc = new Societe($db);
$soc->id = $socid;
$soc->fetch($socid);
print '<tr><td>'.$langs->trans("SellingPrice").'</td>';
if ($product->multiprices_base_type["$soc->price_level"] == 'TTC')
{
print '<td>'.price($product->multiprices_ttc["$soc->price_level"]);
}
else
{
print '<td>'.price($product->multiprices["$soc->price_level"]);
}
if ($product->multiprices_base_type["$soc->price_level"])
{
print ' '.$langs->trans($product->multiprices_base_type["$soc->price_level"]);
}
else
{
print ' '.$langs->trans($product->price_base_type);
}
print '</td></tr>';
// Prix mini
print '<tr><td>'.$langs->trans("MinPrice").'</td><td>';
if ($product->multiprices_base_type["$soc->price_level"] == 'TTC')
{
print price($product->multiprices_min_ttc["$soc->price_level"]).' '.$langs->trans($product->multiprices_base_type["$soc->price_level"]);
}
else
{
print price($product->multiprices_min["$soc->price_level"]).' '.$langs->trans($product->multiprices_base_type["$soc->price_level"]);
}
print '</td></tr>';
}
else
{ {
for ($i=1; $i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) for ($i=1; $i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++)
{ {
@ -904,6 +945,7 @@ if ($_GET["id"] || $_GET["ref"])
print '</td></tr>'; print '</td></tr>';
} }
} }
}
else else
{ {
// Prix // Prix

View File

@ -40,7 +40,7 @@ if (isset($_GET["id"]) || isset($_GET["ref"]))
$id = isset($_GET["id"])?$_GET["id"]:(isset($_GET["ref"])?$_GET["ref"]:''); $id = isset($_GET["id"])?$_GET["id"]:(isset($_GET["ref"])?$_GET["ref"]:'');
} }
$fieldid = isset($_GET["ref"])?'ref':'rowid'; $fieldid = isset($_GET["ref"])?'ref':'rowid';
if ($user->societe_id) $socid=$user->societe_id; $socid=$user->societe_id?$user->societe_id:0;
$result=restrictedArea($user,'produit|service',$id,'product','','',$fieldid); $result=restrictedArea($user,'produit|service',$id,'product','','',$fieldid);
@ -140,6 +140,47 @@ print '</tr>';
// MultiPrix // MultiPrix
if($conf->global->PRODUIT_MULTIPRICES) if($conf->global->PRODUIT_MULTIPRICES)
{
if ($socid)
{
$soc = new Societe($db);
$soc->id = $socid;
$soc->fetch($socid);
print '<tr><td>'.$langs->trans("SellingPrice").'</td>';
if ($product->multiprices_base_type["$soc->price_level"] == 'TTC')
{
print '<td>'.price($product->multiprices_ttc["$soc->price_level"]);
}
else
{
print '<td>'.price($product->multiprices["$soc->price_level"]);
}
if ($product->multiprices_base_type["$soc->price_level"])
{
print ' '.$langs->trans($product->multiprices_base_type["$soc->price_level"]);
}
else
{
print ' '.$langs->trans($product->price_base_type);
}
print '</td></tr>';
// Prix mini
print '<tr><td>'.$langs->trans("MinPrice").'</td><td>';
if ($product->multiprices_base_type["$soc->price_level"] == 'TTC')
{
print price($product->multiprices_min_ttc["$soc->price_level"]).' '.$langs->trans($product->multiprices_base_type["$soc->price_level"]);
}
else
{
print price($product->multiprices_min["$soc->price_level"]).' '.$langs->trans($product->multiprices_base_type["$soc->price_level"]);
}
print '</td></tr>';
}
else
{ {
for ($i=1; $i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) for ($i=1; $i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++)
{ {
@ -164,7 +205,7 @@ if ($conf->global->PRODUIT_MULTIPRICES)
} }
print '</td></tr>'; print '</td></tr>';
// Prix minimum // Prix mini
print '<tr><td>'.$langs->trans("MinPrice").' '.$i.'</td><td>'; print '<tr><td>'.$langs->trans("MinPrice").' '.$i.'</td><td>';
if ($product->multiprices_base_type["$i"] == 'TTC') if ($product->multiprices_base_type["$i"] == 'TTC')
{ {
@ -177,20 +218,22 @@ if ($conf->global->PRODUIT_MULTIPRICES)
print '</td></tr>'; print '</td></tr>';
} }
} }
}
else else
{ {
// Prix // Prix
print '<tr><td>'.$langs->trans("SellingPrice").'</td><td colspan="2">'; print '<tr><td>'.$langs->trans("SellingPrice").'</td><td>';
if ($product->price_base_type == 'TTC') if ($product->price_base_type == 'TTC')
{ {
print price($product->price_ttc).' '.$langs->trans($product->price_base_type).'</td></tr>'; print price($product->price_ttc).' '.$langs->trans($product->price_base_type);
} }
else else
{ {
print price($product->price).' '.$langs->trans($product->price_base_type).'</td></tr>'; print price($product->price).' '.$langs->trans($product->price_base_type);
} }
print '</td></tr>';
// Prix minimum // Prix mini
print '<tr><td>'.$langs->trans("MinPrice").'</td><td>'; print '<tr><td>'.$langs->trans("MinPrice").'</td><td>';
if ($product->price_base_type == 'TTC') if ($product->price_base_type == 'TTC')
{ {
@ -360,6 +403,7 @@ $sql.= " FROM ".MAIN_DB_PREFIX."product_price as p,";
$sql.= " ".MAIN_DB_PREFIX."user as u"; $sql.= " ".MAIN_DB_PREFIX."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";
if ($socid && $conf->global->PRODUIT_MULTIPRICES) $sql.= " AND p.price_level = ".$soc->price_level;
$sql.= " ORDER BY p.date_price DESC, p.price_level ASC"; $sql.= " ORDER BY p.date_price DESC, p.price_level ASC";
//$sql .= $db->plimit(); //$sql .= $db->plimit();