Fix: Dbuggage de la gestion des fournisseurs, photos et prix sur les produits
This commit is contained in:
parent
dffa43b161
commit
4644cd7d09
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* 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
|
||||
@ -22,10 +22,10 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/product/fiche.php
|
||||
\ingroup product
|
||||
\brief Page de la fiche produit
|
||||
\version $Revision$
|
||||
\file htdocs/product/fiche.php
|
||||
\ingroup product
|
||||
\brief Page de la fiche produit
|
||||
\version $Revision$
|
||||
*/
|
||||
|
||||
require("./pre.inc.php");
|
||||
@ -216,30 +216,6 @@ if ($_GET["action"] == 'remove_fourn')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($_POST["action"] == 'update_price' &&
|
||||
$_POST["cancel"] <> $langs->trans("Cancel") && $user->rights->produit->creer)
|
||||
{
|
||||
$product = new Product($db);
|
||||
|
||||
$result = $product->fetch($_GET["id"]);
|
||||
|
||||
$product->price = ereg_replace(" ","",$_POST["price"]);
|
||||
|
||||
if ( $product->update_price($product->id, $user) > 0 )
|
||||
|
||||
{
|
||||
$_GET["action"] = '';
|
||||
$mesg = 'Fiche mise à jour';
|
||||
}
|
||||
else
|
||||
{
|
||||
$_GET["action"] = 'edit_price';
|
||||
$mesg = 'Fiche non mise à jour !' . "<br>" . $product->mesg_error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($_POST["cancel"] == $langs->trans("Cancel"))
|
||||
{
|
||||
$action = '';
|
||||
@ -252,8 +228,7 @@ llxHeader("","",$langs->trans("CardProduct0"));
|
||||
|
||||
|
||||
/*
|
||||
* Création du produit
|
||||
*
|
||||
* Action création du produit
|
||||
*/
|
||||
if ($_GET["action"] == 'create' && $user->rights->produit->creer)
|
||||
{
|
||||
@ -322,335 +297,265 @@ if ($_GET["action"] == 'create' && $user->rights->produit->creer)
|
||||
print '</table>';
|
||||
print '</form>';
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Fiche produit
|
||||
*/
|
||||
if ($_GET["id"])
|
||||
{
|
||||
|
||||
if ($_GET["action"] <> 're-edit')
|
||||
{
|
||||
$product = new Product($db);
|
||||
$result = $product->fetch($_GET["id"]);
|
||||
}
|
||||
|
||||
if ( $result )
|
||||
{
|
||||
|
||||
if ($_GET["action"] <> 'edit' && $_GET["action"] <> 're-edit')
|
||||
{
|
||||
/*
|
||||
* En mode visu
|
||||
*/
|
||||
|
||||
$h=0;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT."/product/fiche.php?id=".$product->id;
|
||||
$head[$h][1] = $langs->trans("Card");
|
||||
$hselected = $h;
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT."/product/price.php?id=".$product->id;
|
||||
$head[$h][1] = $langs->trans("Price");
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT."/product/photos.php?id=".$product->id;
|
||||
$head[$h][1] = $langs->trans("Photos");
|
||||
$h++;
|
||||
|
||||
if($product->type == 0)
|
||||
{
|
||||
if ($conf->stock->enabled)
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT."/product/stock/product.php?id=".$product->id;
|
||||
$head[$h][1] = $langs->trans("Stock");
|
||||
$h++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($conf->fournisseur->enabled)
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT."/product/fournisseurs.php?id=".$product->id;
|
||||
$head[$h][1] = $langs->trans("Suppliers");
|
||||
$h++;
|
||||
}
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT."/product/stats/fiche.php?id=".$product->id;
|
||||
$head[$h][1] = $langs->trans('Statistics');
|
||||
$h++;
|
||||
|
||||
|
||||
dolibarr_fiche_head($head, $hselected, $langs->trans("CardProduct".$product->type).' : '.$product->ref);
|
||||
|
||||
|
||||
print($mesg);
|
||||
print '<table class="border" width="100%">';
|
||||
print "<tr>";
|
||||
print '<td width="10%">'.$langs->trans("Ref").'</td><td colspan="2" width="40%">'.$product->ref.'</td>';
|
||||
print '</tr>';
|
||||
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="2">'.$product->libelle.'</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Prix
|
||||
print '<tr><td>'.$langs->trans("SellingPrice").'</td><td>'.price($product->price).'</td>';
|
||||
if ($product->type == 0) $nbligne=5;
|
||||
else $nbligne=5;
|
||||
print '<td valign="top" rowspan="'.$nbligne.'">';
|
||||
|
||||
$sql = "SELECT s.nom, s.idp";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."product_fournisseur as pf";
|
||||
$sql .=" WHERE pf.fk_soc = s.idp AND pf.fk_product = ".$product->id;
|
||||
$sql .= " ORDER BY lower(s.nom)";
|
||||
|
||||
$result=$db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$num_fournisseur = $db->num_rows($result);
|
||||
$i = 0;
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Suppliers").'</td></tr>';
|
||||
$var=True;
|
||||
while ($i < $num_fournisseur)
|
||||
{
|
||||
$objp = $db->fetch_object($result);
|
||||
$var=!$var;
|
||||
print "<tr $bc[$var]>";
|
||||
print '<td><a href="../fourn/fiche.php?socid='.$objp->idp.'">'.$objp->nom.'</a></td>';
|
||||
print '<td align="right">';
|
||||
print '<a href="fiche.php?id='.$product->id.'&action=remove_fourn&id_fourn='.$objp->idp.'">';
|
||||
print img_disable($langs->trans("Remove")).'</a></td></tr>';
|
||||
$i++;
|
||||
}
|
||||
print '</table>';
|
||||
$db->free($result);
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Statut
|
||||
print '<tr><td>'.$langs->trans("Status").'</td><td>';
|
||||
if ($product->envente) print $langs->trans("OnSell");
|
||||
else print $langs->trans("NotOnSell");
|
||||
print '</td></tr>';
|
||||
|
||||
$langs->load("bills");
|
||||
print '<tr><td>'.$langs->trans("VATRate").'</td><td>'.$product->tva_tx.' %</td></tr>';
|
||||
if ($product->type == 0 && defined("MAIN_MODULE_STOCK"))
|
||||
{
|
||||
print '<tr><td><a href="stock/product.php?id='.$product->id.'">'.$langs->trans("Stock").'</a></td>';
|
||||
if ($product->no_stock)
|
||||
{
|
||||
print "<td>Pas de définition de stock pour ce produit";
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($product->stock_reel <= $product->seuil_stock_alerte)
|
||||
{
|
||||
print '<td class="alerte">'.$product->stock_reel.' Seuil : '.$product->seuil_stock_alerte;
|
||||
}
|
||||
else
|
||||
{
|
||||
print "<td>".$product->stock_reel;
|
||||
}
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
print '<tr><td valign="top">'.$langs->trans("Description").'</td><td>'.nl2br($product->description).'</td></tr>';
|
||||
|
||||
if ($product->type == 1)
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("Duration").'</td><td>'.$product->duration_value.' ';
|
||||
|
||||
if ($product->duration_value > 1)
|
||||
{
|
||||
$dur=array("d"=>$langs->trans("Days"),"w"=>$langs->trans("Weeks"),"m"=>$langs->trans("Months"),"y"=>$langs->trans("Years"));
|
||||
}
|
||||
else {
|
||||
$dur=array("d"=>$langs->trans("Day"),"w"=>$langs->trans("Week"),"m"=>$langs->trans("Month"),"y"=>$langs->trans("Year"));
|
||||
}
|
||||
print $langs->trans($dur[$product->duration_unit])." ";
|
||||
|
||||
print '</td></tr>';
|
||||
}
|
||||
print "</table><br>\n";
|
||||
|
||||
print "</div>\n";
|
||||
}
|
||||
|
||||
/*
|
||||
* Ajouter un fournisseur
|
||||
*/
|
||||
if ($_GET["action"] == 'ajout_fourn' && $user->rights->produit->creer)
|
||||
{
|
||||
$langs->load("suppliers");
|
||||
|
||||
print_titre($langs->trans("AddSupplier"));
|
||||
print '<form action="fiche.php?id='.$product->id.'" method="post">';
|
||||
print '<input type="hidden" name="action" value="add_fourn">';
|
||||
print '<input type="hidden" name="id" value="'.$product->id.'">';
|
||||
print '<table class="border" width="100%"><tr>';
|
||||
print '<td>'.$langs->trans("Suppliers").'</td><td>';
|
||||
|
||||
$html=new Form($db);
|
||||
$html->select_societes('','id_fourn','fournisseur=1');
|
||||
|
||||
print '</td><td>'.$langs->trans("Ref").'</td>';
|
||||
print '<td><input name="ref_fourn" size="25" value=""></td></tr>';
|
||||
print '<tr><td colspan="4" align="center">';
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Save").'"> ';
|
||||
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>';
|
||||
print '</table>';
|
||||
print '</form>';
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Fiche en mode edition
|
||||
*/
|
||||
if (($_GET["action"] == 'edit' || $_GET["action"] == 're-edit') && $user->rights->produit->creer)
|
||||
{
|
||||
|
||||
print_fiche_titre('Edition de la fiche '.$types[$product->type].' : '.$product->ref, "");
|
||||
|
||||
if ($mesg) {
|
||||
print '<br><div class="error">'.$mesg.'</div><br>';
|
||||
}
|
||||
|
||||
print "<form action=\"fiche.php\" method=\"post\">\n";
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
print '<input type="hidden" name="id" value="'.$product->id.'">';
|
||||
print '<table class="border" width="100%">';
|
||||
print "<tr>".'<td width="20%">'.$langs->trans("Ref").'</td><td colspan="2"><input name="ref" size="20" value="'.$product->ref.'"></td></tr>';
|
||||
print '<td>'.$langs->trans("Label").'</td><td><input name="libelle" size="40" value="'.$product->libelle.'"></td></tr>';
|
||||
|
||||
$langs->load("bills");
|
||||
print '<tr><td>'.$langs->trans("VATRate").'</td><td colspan="2">';
|
||||
$html = new Form($db);
|
||||
print $html->select_tva("tva_tx", $product->tva_tx);
|
||||
print '</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("Status").'</td><td colspan="2">';
|
||||
print '<select name="statut">';
|
||||
if ($product->envente)
|
||||
{
|
||||
print '<option value="1" selected>'.$langs->trans("OnSell").'</option>';
|
||||
print '<option value="0">'.$langs->trans("NotOnSell").'</option>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<option value="1">'.$langs->trans("OnSell").'</option>';
|
||||
print '<option value="0" selected>'.$langs->trans("NotOnSell").'</option>';
|
||||
}
|
||||
print '</td></tr>';
|
||||
if ($product->type == 0 && defined("MAIN_MODULE_STOCK"))
|
||||
{
|
||||
print "<tr>".'<td>Seuil stock</td><td colspan="2">';
|
||||
print '<input name="seuil_stock_alerte" size="4" value="'.$product->seuil_stock_alerte.'">';
|
||||
print '</td></tr>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input name="seuil_stock_alerte" type="hidden" value="0">';
|
||||
}
|
||||
print '<tr><td valign="top">'.$langs->trans("Description").'</td><td colspan="2">';
|
||||
print '<textarea name="desc" rows="8" cols="50">';
|
||||
print $product->description;
|
||||
print "</textarea></td></tr>";
|
||||
|
||||
if ($product->type == 1)
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("Duration").'</td><td colspan="2"><input name="duration_value" size="3" maxlength="5" value="'.$product->duration_value.'">';
|
||||
print ' ';
|
||||
print '<input name="duration_unit" type="radio" value="d"'.($product->duration_unit=='d'?' checked':'').'>'.$langs->trans("Day");
|
||||
print ' ';
|
||||
print '<input name="duration_unit" type="radio" value="w"'.($product->duration_unit=='w'?' checked':'').'>'.$langs->trans("Week");
|
||||
print ' ';
|
||||
print '<input name="duration_unit" type="radio" value="m"'.($product->duration_unit=='m'?' checked':'').'>'.$langs->trans("Month");
|
||||
print ' ';
|
||||
print '<input name="duration_unit" type="radio" value="y"'.($product->duration_unit=='y'?' checked':'').'>'.$langs->trans("Year");
|
||||
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
print '<tr><td colspan="3" 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 '</table>';
|
||||
print '</form>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* Fiche produit
|
||||
*/
|
||||
if ($_GET["id"])
|
||||
{
|
||||
|
||||
if ($_GET["action"] <> 're-edit')
|
||||
{
|
||||
$product = new Product($db);
|
||||
$result = $product->fetch($_GET["id"]);
|
||||
}
|
||||
|
||||
if ( $result )
|
||||
{
|
||||
|
||||
if ($_GET["action"] <> 'edit' && $_GET["action"] <> 're-edit')
|
||||
{
|
||||
/*
|
||||
* En mode visu
|
||||
*/
|
||||
|
||||
$h=0;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT."/product/fiche.php?id=".$product->id;
|
||||
$head[$h][1] = $langs->trans("Card");
|
||||
$hselected = $h;
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT."/product/price.php?id=".$product->id;
|
||||
$head[$h][1] = $langs->trans("Price");
|
||||
$h++;
|
||||
|
||||
if($product->type == 0)
|
||||
{
|
||||
if ($conf->stock->enabled)
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT."/product/stock/product.php?id=".$product->id;
|
||||
$head[$h][1] = $langs->trans("Stock");
|
||||
$h++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($conf->fournisseur->enabled)
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT."/product/fournisseurs.php?id=".$product->id;
|
||||
$head[$h][1] = $langs->trans("Suppliers");
|
||||
$h++;
|
||||
}
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT."/product/photos.php?id=".$product->id;
|
||||
$head[$h][1] = $langs->trans("Photos");
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT."/product/stats/fiche.php?id=".$product->id;
|
||||
$head[$h][1] = $langs->trans('Statistics');
|
||||
$h++;
|
||||
|
||||
|
||||
dolibarr_fiche_head($head, $hselected, $langs->trans("CardProduct".$product->type).' : '.$product->ref);
|
||||
|
||||
|
||||
print($mesg);
|
||||
print '<table class="border" width="100%">';
|
||||
print "<tr>";
|
||||
print '<td width="20%">'.$langs->trans("Ref").'</td><td width="40%">'.$product->ref.'</td>';
|
||||
print '<td width="40%">';
|
||||
if ($product->envente)
|
||||
{
|
||||
print $langs->trans("OnSell");
|
||||
}
|
||||
else
|
||||
{
|
||||
print $langs->trans("NotOnSell");
|
||||
}
|
||||
print '</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="2">'.$product->libelle.'</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("SellingPrice").'</td><td>'.price($product->price).'</td>';
|
||||
if ($product->type == 0)
|
||||
{
|
||||
$nblignefour=4;
|
||||
}
|
||||
else
|
||||
{
|
||||
$nblignefour=4;
|
||||
}
|
||||
|
||||
print '<td valign="top" rowspan="'.$nblignefour.'">';
|
||||
print $langs->trans("Suppliers").' [<a href="fiche.php?id='.$product->id.'&action=ajout_fourn">'.$langs->trans("Add").'</a>]';
|
||||
|
||||
$sql = "SELECT s.nom, s.idp";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."product_fournisseur as pf";
|
||||
$sql .=" WHERE pf.fk_soc = s.idp AND pf.fk_product = ".$product->id;
|
||||
$sql .= " ORDER BY lower(s.nom)";
|
||||
|
||||
$result=$db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$num_fournisseur = $db->num_rows($result);
|
||||
$i = 0;
|
||||
print '<table class="noborder" width="100%">';
|
||||
$var=True;
|
||||
while ($i < $num_fournisseur)
|
||||
{
|
||||
$objp = $db->fetch_object($result);
|
||||
$var=!$var;
|
||||
print "<tr $bc[$var]>";
|
||||
print '<td><a href="../fourn/fiche.php?socid='.$objp->idp.'">'.$objp->nom.'</a></td>';
|
||||
print '<td align="right">';
|
||||
print '<a href="fiche.php?id='.$product->id.'&action=remove_fourn&id_fourn='.$objp->idp.'">';
|
||||
print img_disable($langs->trans("Remove")).'</a></td></tr>';
|
||||
$i++;
|
||||
}
|
||||
print '</table>';
|
||||
$db->free($result);
|
||||
}
|
||||
|
||||
print '</td></tr>';
|
||||
|
||||
$langs->load("bills");
|
||||
print '<tr><td>'.$langs->trans("VATRate").'</td><td>'.$product->tva_tx.' %</td></tr>';
|
||||
if ($product->type == 0 && defined("MAIN_MODULE_STOCK"))
|
||||
{
|
||||
print '<tr><td><a href="stock/product.php?id='.$product->id.'">'.$langs->trans("Stock").'</a></td>';
|
||||
if ($product->no_stock)
|
||||
{
|
||||
print "<td>Pas de définition de stock pour ce produit";
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($product->stock_reel <= $product->seuil_stock_alerte)
|
||||
{
|
||||
print '<td class="alerte">'.$product->stock_reel.' Seuil : '.$product->seuil_stock_alerte;
|
||||
}
|
||||
else
|
||||
{
|
||||
print "<td>".$product->stock_reel;
|
||||
}
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
print '<tr><td valign="top">'.$langs->trans("Description").'</td><td>'.nl2br($product->description).'</td></tr>';
|
||||
|
||||
if ($product->type == 1)
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("Duration").'</td><td>'.$product->duration_value.' ';
|
||||
|
||||
if ($product->duration_value > 1)
|
||||
{
|
||||
$dur=array("d"=>$langs->trans("Days"),"w"=>$langs->trans("Weeks"),"m"=>$langs->trans("Months"),"y"=>$langs->trans("Years"));
|
||||
}
|
||||
else {
|
||||
$dur=array("d"=>$langs->trans("Day"),"w"=>$langs->trans("Week"),"m"=>$langs->trans("Month"),"y"=>$langs->trans("Year"));
|
||||
}
|
||||
print $langs->trans($dur[$product->duration_unit])." ";
|
||||
|
||||
print '</td></tr>';
|
||||
}
|
||||
print "</table><br>\n";
|
||||
|
||||
print "</div>\n";
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Edition du prix
|
||||
*
|
||||
*/
|
||||
if ($_GET["action"] == 'edit_price' && $user->rights->produit->creer)
|
||||
{
|
||||
print '<div class="titre">'.$langs->trans("NewPrice").'</div>';
|
||||
print '<form action="fiche.php?id='.$product->id.'" method="post">';
|
||||
print '<input type="hidden" name="action" value="update_price">';
|
||||
print '<input type="hidden" name="id" value="'.$product->id.'">';
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr><td width="20%">'.$langs->trans('SellingPrice').'</td><td><input name="price" size="10" value="'.price($product->price).'"></td></tr>';
|
||||
print '<tr><td colspan="3" 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 '</table>';
|
||||
print '</form>';
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Ajouter un fournisseur
|
||||
*
|
||||
*/
|
||||
if ($_GET["action"] == 'ajout_fourn' && $user->rights->produit->creer)
|
||||
{
|
||||
$langs->load("suppliers");
|
||||
|
||||
print_titre($langs->trans("AddSupplier"));
|
||||
print '<form action="fiche.php?id='.$product->id.'" method="post">';
|
||||
print '<input type="hidden" name="action" value="add_fourn">';
|
||||
print '<input type="hidden" name="id" value="'.$product->id.'">';
|
||||
print '<table class="border" width="100%"><tr>';
|
||||
print '<td>'.$langs->trans("Suppliers").'</td><td><select name="id_fourn">';
|
||||
|
||||
$sql = "SELECT s.idp, s.nom, s.ville FROM ".MAIN_DB_PREFIX."societe as s WHERE s.fournisseur=1";
|
||||
$sql .= " ORDER BY lower(s.nom)";
|
||||
|
||||
$result=$db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$num = $db->num_rows($result);
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $db->fetch_object($result);
|
||||
print '<option value="'.$obj->idp.'">'.$obj->nom . ($obj->ville?" ($obj->ville)":"");
|
||||
$i++;
|
||||
}
|
||||
|
||||
}
|
||||
print '</select></td><td>'.$langs->trans("Ref").'</td>';
|
||||
print '<td><input name="ref_fourn" size="25" value=""></td></tr>';
|
||||
print '<tr><td colspan="4" align="center">';
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Save").'"> ';
|
||||
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>';
|
||||
print '</table>';
|
||||
print '</form>';
|
||||
}
|
||||
|
||||
/*
|
||||
* Ajouter une photo
|
||||
*
|
||||
*/
|
||||
if ($_GET["action"] == 'ajout_photo' && $conf->upload && $user->rights->produit->creer && $product->isproduct)
|
||||
{
|
||||
print_titre($langs->trans("AddPhoto"));
|
||||
|
||||
print '<form name="userfile" action="fiche.php" enctype="multipart/form-data" METHOD="POST">';
|
||||
print '<input type="hidden" name="max_file_size" value="'.$conf->maxfilesize.'">';
|
||||
print '<input type="hidden" name="id" value="'.$product->id.'">';
|
||||
|
||||
print '<table class="border" width="100%"><tr>';
|
||||
print '<td>'.$langs->trans("File").' ('.$langs->trans("Size").' <= '.$conf->maxfilesize.')</td>';
|
||||
print '<td><input type="file" class="flat" name="photofile"></td></tr>';
|
||||
|
||||
print '<tr><td colspan="4" align="center">';
|
||||
print '<input type="submit" class="button" name="sendit" value="'.$langs->trans("Upload").'"> ';
|
||||
|
||||
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>';
|
||||
print '</table>';
|
||||
print '</form>';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* Fiche en mode edition
|
||||
*
|
||||
*/
|
||||
if (($_GET["action"] == 'edit' || $_GET["action"] == 're-edit') && $user->rights->produit->creer)
|
||||
{
|
||||
|
||||
print_fiche_titre('Edition de la fiche '.$types[$product->type].' : '.$product->ref, "");
|
||||
|
||||
if ($mesg) {
|
||||
print '<br><div class="error">'.$mesg.'</div><br>';
|
||||
}
|
||||
|
||||
print "<form action=\"fiche.php\" method=\"post\">\n";
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
print '<input type="hidden" name="id" value="'.$product->id.'">';
|
||||
print '<table class="border" width="100%">';
|
||||
print "<tr>".'<td width="20%">'.$langs->trans("Ref").'</td><td colspan="2"><input name="ref" size="20" value="'.$product->ref.'"></td></tr>';
|
||||
print '<td>'.$langs->trans("Label").'</td><td colspan="2"><input name="libelle" size="40" value="'.$product->libelle.'"></td></tr>';
|
||||
|
||||
$langs->load("bills");
|
||||
print '<tr><td>'.$langs->trans("VATRate").'</td><td colspan="2">';
|
||||
$html = new Form($db);
|
||||
print $html->select_tva("tva_tx", $product->tva_tx);
|
||||
print '</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("Status").'</td><td colspan="2">';
|
||||
print '<select name="statut">';
|
||||
if ($product->envente)
|
||||
{
|
||||
print '<option value="1" selected>'.$langs->trans("OnSell").'</option>';
|
||||
print '<option value="0">'.$langs->trans("NotOnSell").'</option>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<option value="1">'.$langs->trans("OnSell").'</option>';
|
||||
print '<option value="0" selected>'.$langs->trans("NotOnSell").'</option>';
|
||||
}
|
||||
print '</td></tr>';
|
||||
if ($product->type == 0 && defined("MAIN_MODULE_STOCK"))
|
||||
{
|
||||
print "<tr>".'<td>Seuil stock</td><td colspan="2">';
|
||||
print '<input name="seuil_stock_alerte" size="4" value="'.$product->seuil_stock_alerte.'">';
|
||||
print '</td></tr>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input name="seuil_stock_alerte" type="hidden" value="0">';
|
||||
}
|
||||
print '<tr><td valign="top">'.$langs->trans("Description").'</td><td colspan="2">';
|
||||
print '<textarea name="desc" rows="8" cols="50">';
|
||||
print $product->description;
|
||||
print "</textarea></td></tr>";
|
||||
|
||||
if ($product->type == 1)
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("Duration").'</td><td colspan="2"><input name="duration_value" size="3" maxlength="5" value="'.$product->duration_value.'">';
|
||||
print ' ';
|
||||
print '<input name="duration_unit" type="radio" value="d"'.($product->duration_unit=='d'?' checked':'').'>'.$langs->trans("Day");
|
||||
print ' ';
|
||||
print '<input name="duration_unit" type="radio" value="w"'.($product->duration_unit=='w'?' checked':'').'>'.$langs->trans("Week");
|
||||
print ' ';
|
||||
print '<input name="duration_unit" type="radio" value="m"'.($product->duration_unit=='m'?' checked':'').'>'.$langs->trans("Month");
|
||||
print ' ';
|
||||
print '<input name="duration_unit" type="radio" value="y"'.($product->duration_unit=='y'?' checked':'').'>'.$langs->trans("Year");
|
||||
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
print '<tr><td colspan="3" 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 '</table>';
|
||||
print '</form>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print $langs->trans("ErrorUnknown");
|
||||
}
|
||||
print $langs->trans("ErrorUnknown");
|
||||
}
|
||||
|
||||
|
||||
@ -664,37 +569,40 @@ print "\n<div class=\"tabsAction\">\n";
|
||||
|
||||
if ($_GET["action"] == '')
|
||||
{
|
||||
if ($product->type == 0 && $user->rights->produit->commander && $num_fournisseur == 1)
|
||||
if ($product->type == 0 && $user->rights->produit->commander && $num_fournisseur == 1)
|
||||
{
|
||||
print '<a class="tabAction" href="fiche.php?action=fastappro&id='.$product->id.'">';
|
||||
print $langs->trans("Order").'</a>';
|
||||
print '<a class="tabAction" href="fiche.php?action=fastappro&id='.$product->id.'">';
|
||||
print $langs->trans("Order").'</a>';
|
||||
}
|
||||
|
||||
if ( $user->rights->produit->creer)
|
||||
{
|
||||
print '<a class="tabAction" href="fiche.php?action=edit&id='.$product->id.'">'.$langs->trans("Edit").'</a>';
|
||||
}
|
||||
|
||||
if ( $user->rights->produit->creer && $product->isproduct && $conf->upload)
|
||||
if ($user->rights->produit->modifier || $user->rights->produit->creer)
|
||||
{
|
||||
print '<a class="tabAction" href="fiche.php?action=ajout_photo&id='.$product->id.'">';
|
||||
print $langs->trans("AddPhoto").'</a>';
|
||||
print '<a class="tabAction" href="'.DOL_URL_ROOT.'/product/price.php?action=edit_price&id='.$product->id.'">'.$langs->trans("UpdatePrice").'</a>';
|
||||
}
|
||||
|
||||
if ( $user->rights->produit->creer)
|
||||
if ( $user->rights->produit->creer && $conf->upload)
|
||||
{
|
||||
print '<a class="tabAction" href="fiche.php?action=edit_price&id='.$product->id.'">';
|
||||
print $langs->trans("UpdatePrice").'</a>';
|
||||
print '<a class="tabAction" href="'.DOL_URL_ROOT.'/product/photos.php?action=ajout_photo&id='.$product->id.'">';
|
||||
print $langs->trans("AddPhoto").'</a>';
|
||||
}
|
||||
|
||||
if ( $user->rights->produit->creer)
|
||||
if ($user->rights->produit->modifier || $user->rights->produit->creer)
|
||||
{
|
||||
print '<a class="tabAction" href="fiche.php?action=edit&id='.$product->id.'">'.$langs->trans("Edit").'</a>';
|
||||
print '<a class="tabAction" href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$product->id.'&action=ajout_fourn">';
|
||||
print $langs->trans("AddSupplier").'</a>';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
print "\n</div>\n";
|
||||
print "\n</div><br>\n";
|
||||
|
||||
|
||||
/*
|
||||
* Photo
|
||||
*
|
||||
*/
|
||||
if ($_GET["id"] && $_GET["action"]=='')
|
||||
{
|
||||
@ -914,5 +822,5 @@ if ($_GET["id"] && $_GET["action"] == '' && $product->envente)
|
||||
|
||||
$db->close();
|
||||
|
||||
llxFooter("<em>Dernière modification $Date$ révision $Revision$</em>");
|
||||
llxFooter('$Date$ - $Revision$');
|
||||
?>
|
||||
|
||||
@ -33,34 +33,64 @@ require("../propal.class.php");
|
||||
require("../facture.class.php");
|
||||
|
||||
$langs->load("products");
|
||||
$langs->load("suppliers");
|
||||
|
||||
$user->getrights('produit');
|
||||
$user->getrights('propale');
|
||||
$user->getrights('facture');
|
||||
$mesg = '';
|
||||
|
||||
if (!$user->rights->produit->lire)
|
||||
{
|
||||
accessforbidden();
|
||||
}
|
||||
if (! $user->rights->produit->lire) accessforbidden();
|
||||
|
||||
$types[0] = $langs->trans("Product");
|
||||
$types[1] = $langs->trans("Service");
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if ($_POST["action"] == 'updateprice' && $_POST["cancel"] <> $langs->trans("Cancel"))
|
||||
{
|
||||
|
||||
$product = new Product($db);
|
||||
if( $product->fetch($_GET["id"]) )
|
||||
$product = new Product($db);
|
||||
if( $product->fetch($_GET["id"]) )
|
||||
{
|
||||
$product->update_buyprice($_POST["id_fourn"], $_POST["qty"], $_POST["price"], $user);
|
||||
$db->begin();
|
||||
|
||||
$error=0;
|
||||
|
||||
if ($_POST["ref_fourn"]) {
|
||||
$ret=$product->add_fournisseur($user, $_POST["id_fourn"], $_POST["ref_fourn"]);
|
||||
if ($ret < 0) {
|
||||
$error++;
|
||||
$mesg='<div class="error">'.$product->error.'</div>';
|
||||
}
|
||||
}
|
||||
|
||||
if ($_POST["qty"]) {
|
||||
$ret=$product->update_buyprice($_POST["id_fourn"], $_POST["qty"], $_POST["price"], $user);
|
||||
if ($ret < 0) {
|
||||
$error++;
|
||||
$mesg='<div class="error">'.$product->error.'</div>';
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$db->commit();
|
||||
}
|
||||
else {
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($_POST["cancel"] == $langs->trans("Cancel"))
|
||||
{
|
||||
$action = '';
|
||||
Header("Location: fournisseurs.php?id=".$_GET["id"]);
|
||||
$action = '';
|
||||
Header("Location: fournisseurs.php?id=".$_GET["id"]);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
@ -87,13 +117,16 @@ if ($_GET["id"])
|
||||
/*
|
||||
* En mode visu
|
||||
*/
|
||||
|
||||
// Zone recherche
|
||||
/* Deja présent dans menu gauche
|
||||
print '<div class="formsearch">';
|
||||
print '<form action="liste.php" method="post">';
|
||||
print '<input type="hidden" name="type" value="'.$product->type.'">';
|
||||
print $langs->trans("Ref").': <input class="flat" type="text" size="10" name="sref"> <input class="flat" type="submit" value="'.$langs->trans("Go").'"> ';
|
||||
print $langs->trans("Label").': <input class="flat" type="text" size="20" name="snom"> <input class="flat" type="submit" value="'.$langs->trans("Go").'">';
|
||||
print '</form></div>';
|
||||
*/
|
||||
|
||||
$h=0;
|
||||
|
||||
@ -105,6 +138,10 @@ if ($_GET["id"])
|
||||
$head[$h][1] = $langs->trans("Price");
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT."/product/photos.php?id=".$product->id;
|
||||
$head[$h][1] = $langs->trans("Photos");
|
||||
$h++;
|
||||
|
||||
if($product->type == 0)
|
||||
{
|
||||
if ($conf->stock->enabled)
|
||||
@ -123,10 +160,6 @@ if ($_GET["id"])
|
||||
$h++;
|
||||
}
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT."/product/photos.php?id=".$product->id;
|
||||
$head[$h][1] = $langs->trans("Photos");
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT."/product/stats/fiche.php?id=".$product->id;
|
||||
$head[$h][1] = $langs->trans('Statistics');
|
||||
$h++;
|
||||
@ -135,99 +168,147 @@ if ($_GET["id"])
|
||||
dolibarr_fiche_head($head, $hselected, $langs->trans("CardProduct".$product->type).' : '.$product->ref);
|
||||
|
||||
print($mesg);
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr><td width="20%">'.$langs->trans("Ref").'</td><td>'.$product->ref.'</td>';
|
||||
print '<td align="right">'.$langs->trans("Status").' : ';
|
||||
if ($product->envente)
|
||||
{
|
||||
print $langs->trans("OnSell");
|
||||
}
|
||||
else
|
||||
{
|
||||
print $langs->trans("NotOnSell");
|
||||
}
|
||||
print '</td></tr>';
|
||||
print '<tr><td width="20%">'.$langs->trans("Ref").'</td><td colspan="2">'.$product->ref.'</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="2">'.$product->libelle.'</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("SellingPrice").'</td><td colspan="2">'.price($product->price).'</td></tr>';
|
||||
|
||||
// Statut
|
||||
print '<tr><td>'.$langs->trans("Status").'</td><td colspan="2">';
|
||||
if ($product->envente) print $langs->trans("OnSell");
|
||||
else print $langs->trans("NotOnSell");
|
||||
print '</td></tr>';
|
||||
|
||||
print '</table><br />';
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
print "</div>\n";
|
||||
|
||||
if ($product->type == 0)
|
||||
{
|
||||
$nblignefour=4;
|
||||
}
|
||||
else
|
||||
{
|
||||
$nblignefour=4;
|
||||
}
|
||||
|
||||
// Formulaire ajout prix
|
||||
if ($_GET["action"] == 'add_price' && $user->rights->produit->creer)
|
||||
{
|
||||
$langs->load("suppliers");
|
||||
|
||||
print '<div class="titre">'.$langs->trans("ChangeSupplierPrice").'</div>';
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
print '<form action="fournisseurs.php?id='.$product->id.'" method="post">';
|
||||
print '<input type="hidden" name="action" value="updateprice">';
|
||||
|
||||
if ($_GET["id_fourn"]) {
|
||||
print '<input type="hidden" name="id_fourn" value="'.$_GET["id_fourn"].'">';
|
||||
} else {
|
||||
print '<tr><td>'.$langs->trans("Supplier").'</td><td colspan="3">';
|
||||
$html=new Form($db);
|
||||
$html->select_societes('','id_fourn','fournisseur=1');
|
||||
print '</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("Ref").'</td><td colspan="3">';
|
||||
print '<input name="ref_fourn" size="25" value="">';
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
print '<tr><td>'.$langs->trans("Qty").'</td>';
|
||||
print '<td><input name="qty" size="5" value="'.$_GET["qty"].'"></td>';
|
||||
print '<td>'.$langs->trans("Price").'</td><td><input name="price" size="8" value="'.price($objp->price).'"></td></tr>';
|
||||
|
||||
print '<tr><td colspan="4" align="center"><input type="submit" value="'.$langs->trans("Save").'"> ';
|
||||
print '<input type="submit" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>';
|
||||
print '</form>';
|
||||
print '</table>';
|
||||
}
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* Barre d'action */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
print "\n<div class=\"tabsAction\">\n";
|
||||
|
||||
if ($_GET["action"] != 'add_price') {
|
||||
|
||||
print '<a class="tabAction" href="'.DOL_URL_ROOT.'/product/fournisseurs.php?id='.$product->id.'&action=add_price">';
|
||||
print $langs->trans("AddSupplierPrice").'</a>';
|
||||
|
||||
}
|
||||
|
||||
print "\n</div>\n";
|
||||
print '<br>';
|
||||
|
||||
|
||||
// Titre liste des fournisseurs
|
||||
print '<table class="noborder" width="100%">';
|
||||
if ($product->type == 0) $nblignefour=4;
|
||||
else $nblignefour=4;
|
||||
print '<tr class="liste_titre"><td valign="top">';
|
||||
print $langs->trans("Suppliers").'</td>';
|
||||
print '<td>'.$langs->trans("Ref").'</td>';
|
||||
print '<td align="center">'.$langs->trans("Qty").'</td>';
|
||||
print '<td align="right">'.$langs->trans("BuiingPrice").'</td>';
|
||||
print '<td align="right">'.$langs->trans("BuyingPrice").'</td>';
|
||||
print '<td align="right">'.$langs->trans("UnitPrice").'</td>';
|
||||
print '<td> </td>';
|
||||
print '</tr>';
|
||||
|
||||
$sql = "SELECT s.nom, s.idp, pf.ref_fourn, pfp.price, pfp.quantity";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||
$sql .= " , ".MAIN_DB_PREFIX."product_fournisseur as pf";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
|
||||
$sql .=" ON pf.fk_soc = pfp.fk_soc AND pf.fk_product = pfp.fk_product";
|
||||
$sql .=" WHERE pf.fk_soc = s.idp AND pf.fk_product = ".$product->id;
|
||||
$sql .= " ORDER BY lower(s.nom), pfp.quantity";
|
||||
|
||||
if ( $db->query($sql) )
|
||||
// Liste des fournisseurs
|
||||
$sql = "SELECT s.nom, s.idp, pf.ref_fourn, pfp.price, pfp.quantity";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."product_fournisseur as pf";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
|
||||
$sql.= " ON pf.fk_soc = pfp.fk_soc AND pf.fk_product = pfp.fk_product";
|
||||
$sql.= " WHERE pf.fk_soc = s.idp AND pf.fk_product = ".$product->id;
|
||||
$sql.= " ORDER BY lower(s.nom), pfp.quantity";
|
||||
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $db->num_rows();
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
|
||||
$var=True;
|
||||
while ($i < $num)
|
||||
{
|
||||
$objp = $db->fetch_object();
|
||||
$objp = $db->fetch_object($resql);
|
||||
$var=!$var;
|
||||
|
||||
print "<tr $bc[$var]>";
|
||||
print '<td><a href="../fourn/fiche.php?socid='.$objp->idp.'">'.$objp->nom.'</a></td>';
|
||||
|
||||
// Fournisseur
|
||||
print '<td align="left">'.$objp->ref_fourn.'</td>';
|
||||
|
||||
// Quantité
|
||||
print '<td align="center">';
|
||||
print $objp->quantity;
|
||||
print '</td>';
|
||||
|
||||
// Prix quantité
|
||||
print '<td align="right">';
|
||||
print price($objp->price);
|
||||
print '<a href="fournisseurs.php?id='.$product->id.'&action=add_price&id_fourn='.$objp->idp.'&qty='.$objp->quantity.'">';
|
||||
print img_edit(). "</a></td>";
|
||||
print $objp->price?price($objp->price):"";
|
||||
print '</td>';
|
||||
|
||||
// Prix unitaire
|
||||
print '<td align="right">';
|
||||
print $objp->quantity?price($objp->price / $objp->quantity):" ";
|
||||
print '</td>';
|
||||
|
||||
print '<td>';
|
||||
if ($user->rights->produit->modifier) {
|
||||
print '<a href="fournisseurs.php?id='.$product->id.'&action=add_price&id_fourn='.$objp->idp.'&qty='.$objp->quantity.'">'.img_edit()."</a>";
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
print '</tr>';
|
||||
|
||||
if ($_GET["action"] == 'add_price'
|
||||
&& $user->rights->produit->creer
|
||||
&& $_GET["qty"] == $objp->quantity
|
||||
&& $_GET["id_fourn"] == $objp->idp)
|
||||
{
|
||||
$langs->load("suppliers");
|
||||
|
||||
|
||||
print '<form action="fournisseurs.php?id='.$product->id.'" method="post">';
|
||||
print '<input type="hidden" name="action" value="updateprice">';
|
||||
print '<input type="hidden" name="id_fourn" value="'.$objp->idp.'">';
|
||||
|
||||
print '<tr><td colspan="2" align="right">Modifier le prix</td>';
|
||||
|
||||
print '<td align="center"><input name="qty" size="5" value="'.$objp->quantity.'"></td>';
|
||||
print '<td><input name="price" size="8" value="'.price($objp->price).'"></td></tr>';
|
||||
print '<tr><td colspan="2"> </td><td colspan="2" align="center"><input type="submit" value="'.$langs->trans("Save").'"> ';
|
||||
print '<input type="submit" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>';
|
||||
print '</form>';
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
|
||||
$db->free();
|
||||
$db->free($resql);
|
||||
}
|
||||
|
||||
print '</td></tr>';
|
||||
print "</table><br>\n";
|
||||
print "</div>\n";
|
||||
else {
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -237,17 +318,7 @@ else
|
||||
}
|
||||
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* Barre d'action */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
print "\n<div class=\"tabsAction\">\n";
|
||||
|
||||
print "\n</div>\n";
|
||||
|
||||
$db->close();
|
||||
|
||||
llxFooter("<em>Dernière modification $Date$ révision $Revision$</em>");
|
||||
llxFooter('$Date$ - $Revision$');
|
||||
?>
|
||||
|
||||
@ -18,7 +18,6 @@
|
||||
*
|
||||
* $Id$
|
||||
* $Source$
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -41,118 +40,164 @@ $mesg = '';
|
||||
|
||||
if (!$user->rights->produit->lire) accessforbidden();
|
||||
|
||||
|
||||
$types[0] = $langs->trans("Product");
|
||||
$types[1] = $langs->trans("Service");
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if ( $_POST["sendit"] && defined('MAIN_UPLOAD_DOC') && MAIN_UPLOAD_DOC == 1)
|
||||
{
|
||||
if ($_GET["id"])
|
||||
{
|
||||
$product = new Product($db);
|
||||
$result = $product->fetch($_GET["id"]);
|
||||
if ($_GET["id"])
|
||||
{
|
||||
$product = new Product($db);
|
||||
$result = $product->fetch($_GET["id"]);
|
||||
|
||||
// if (doliMoveFileUpload($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name']))
|
||||
// if (doliMoveFileUpload($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name']))
|
||||
|
||||
// var_dump($_FILES);
|
||||
// var_dump($_FILES);
|
||||
|
||||
$product->add_photo($conf->produit->dir_output, $_FILES['photofile']);
|
||||
$product->add_photo($conf->produit->dir_output, $_FILES['photofile']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
llxHeader("","",$langs->trans("CardProduct0"));
|
||||
|
||||
/*
|
||||
* Fiche produit
|
||||
*/
|
||||
|
||||
if ($_GET["id"])
|
||||
{
|
||||
|
||||
|
||||
$product = new Product($db);
|
||||
$result = $product->fetch($_GET["id"]);
|
||||
|
||||
if ( $result )
|
||||
{
|
||||
$product = new Product($db);
|
||||
$result = $product->fetch($_GET["id"]);
|
||||
|
||||
/*
|
||||
* En mode visu
|
||||
*/
|
||||
|
||||
$h=0;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT."/product/fiche.php?id=".$product->id;
|
||||
$head[$h][1] = $langs->trans("Card");
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT."/product/price.php?id=".$product->id;
|
||||
$head[$h][1] = $langs->trans("Price");
|
||||
$h++;
|
||||
|
||||
if ($conf->stock->enabled)
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT."/product/stock/product.php?id=".$product->id;
|
||||
$head[$h][1] = $langs->trans("Stock");
|
||||
$h++;
|
||||
}
|
||||
|
||||
if ($conf->fournisseur->enabled)
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT."/product/fournisseurs.php?id=".$product->id;
|
||||
$head[$h][1] = $langs->trans("Suppliers");
|
||||
$h++;
|
||||
}
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT."/product/photos.php?id=".$product->id;
|
||||
$head[$h][1] = $langs->trans("Photos");
|
||||
$hselected = $h;
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT."/product/stats/fiche.php?id=".$product->id;
|
||||
$head[$h][1] = $langs->trans('Statistics');
|
||||
$h++;
|
||||
if ($result)
|
||||
{
|
||||
/*
|
||||
* En mode visu
|
||||
*/
|
||||
|
||||
dolibarr_fiche_head($head, $hselected, $langs->trans("CardProduct".$product->type).' : '.$product->ref);
|
||||
$h=0;
|
||||
|
||||
print($mesg);
|
||||
print '<table class="border" width="100%">';
|
||||
print "<tr>";
|
||||
print '<td>'.$langs->trans("Ref").'</td><td>'.$product->ref.'</td>';
|
||||
print '<td colspan="2">';
|
||||
if ($product->envente)
|
||||
{
|
||||
print $langs->trans("OnSell");
|
||||
}
|
||||
else
|
||||
{
|
||||
print $langs->trans("NotOnSell");
|
||||
}
|
||||
print '</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="3">'.$product->libelle.'</td>';
|
||||
print '</tr>';
|
||||
$head[$h][0] = DOL_URL_ROOT."/product/fiche.php?id=".$product->id;
|
||||
$head[$h][1] = $langs->trans("Card");
|
||||
$h++;
|
||||
|
||||
print "</table><br>\n";
|
||||
$head[$h][0] = DOL_URL_ROOT."/product/price.php?id=".$product->id;
|
||||
$head[$h][1] = $langs->trans("Price");
|
||||
$h++;
|
||||
|
||||
// Affiche photos
|
||||
$nbphoto=$product->show_photos($conf->produit->dir_output,1);
|
||||
if ($nbphoto < 1) print $langs->trans("NoPhotoYet")."<br><br>";
|
||||
print "</div>\n";
|
||||
}
|
||||
$head[$h][0] = DOL_URL_ROOT."/product/photos.php?id=".$product->id;
|
||||
$head[$h][1] = $langs->trans("Photos");
|
||||
$hselected = $h;
|
||||
$h++;
|
||||
|
||||
if ($conf->stock->enabled)
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT."/product/stock/product.php?id=".$product->id;
|
||||
$head[$h][1] = $langs->trans("Stock");
|
||||
$h++;
|
||||
}
|
||||
|
||||
if ($conf->fournisseur->enabled)
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT."/product/fournisseurs.php?id=".$product->id;
|
||||
$head[$h][1] = $langs->trans("Suppliers");
|
||||
$h++;
|
||||
}
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT."/product/stats/fiche.php?id=".$product->id;
|
||||
$head[$h][1] = $langs->trans('Statistics');
|
||||
$h++;
|
||||
|
||||
dolibarr_fiche_head($head, $hselected, $langs->trans("CardProduct".$product->type).' : '.$product->ref);
|
||||
|
||||
print($mesg);
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr>';
|
||||
print '<td width="10%">'.$langs->trans("Ref").'</td><td colspan="2" width="40%">'.$product->ref.'</td>';
|
||||
print '</tr>';
|
||||
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="2">'.$product->libelle.'</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Prix
|
||||
print '<tr><td>'.$langs->trans("SellingPrice").'</td><td colspan="2">'.price($product->price).'</td></tr>';
|
||||
|
||||
// Statut
|
||||
print '<tr><td>'.$langs->trans("Status").'</td><td colspan="2">';
|
||||
if ($product->envente) print $langs->trans("OnSell");
|
||||
else print $langs->trans("NotOnSell");
|
||||
print '</td></tr>';
|
||||
|
||||
print "</table><br>\n";
|
||||
|
||||
print "</div>\n";
|
||||
|
||||
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* Barre d'action */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
print "\n<div class=\"tabsAction\">\n";
|
||||
|
||||
if ($_GET["action"] != 'ajout_photo' && $user->rights->produit->creer && $conf->upload)
|
||||
{
|
||||
print '<a class="tabAction" href="'.DOL_URL_ROOT.'/product/photos.php?action=ajout_photo&id='.$product->id.'">';
|
||||
print $langs->trans("AddPhoto").'</a>';
|
||||
}
|
||||
|
||||
print "\n</div>\n";
|
||||
|
||||
/*
|
||||
* Ajouter une photo
|
||||
*/
|
||||
if ($_GET["action"] == 'ajout_photo' && $conf->upload && $user->rights->produit->creer)
|
||||
{
|
||||
print_titre($langs->trans("AddPhoto"));
|
||||
|
||||
print '<form name="userfile" action="'.DOL_URL_ROOT.'/product/photos.php?id='.$product->id.'" enctype="multipart/form-data" METHOD="POST">';
|
||||
print '<input type="hidden" name="max_file_size" value="'.$conf->maxfilesize.'">';
|
||||
print '<input type="hidden" name="id" value="'.$product->id.'">';
|
||||
|
||||
print '<table class="border" width="100%"><tr>';
|
||||
print '<td>'.$langs->trans("File").' ('.$langs->trans("Size").' <= '.$conf->maxfilesize.')</td>';
|
||||
print '<td><input type="file" class="flat" name="photofile"></td></tr>';
|
||||
|
||||
print '<tr><td colspan="2" align="center">';
|
||||
print '<input type="submit" class="button" name="sendit" value="'.$langs->trans("Upload").'"> ';
|
||||
|
||||
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>';
|
||||
print '</table>';
|
||||
print '</form>';
|
||||
}
|
||||
|
||||
|
||||
// Affiche photos
|
||||
if ($_GET["action"] != 'ajout_photo') {
|
||||
print '<div class="photo">';
|
||||
$nbphoto=$product->show_photos($conf->produit->dir_output,1);
|
||||
if ($nbphoto < 1) print $langs->trans("NoPhotoYet")."<br><br>";
|
||||
print '</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print $langs->trans("ErrorUnknown");
|
||||
print $langs->trans("ErrorUnknown");
|
||||
}
|
||||
|
||||
|
||||
|
||||
$db->close();
|
||||
|
||||
llxFooter("<em>Dernière modification $Date$ révision $Revision$</em>");
|
||||
llxFooter('$Date$ - $Revision$');
|
||||
?>
|
||||
|
||||
@ -42,11 +42,36 @@ $types[0] = $langs->trans("Product");
|
||||
$types[1] = $langs->trans("Service");
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if ($_POST["action"] == 'update_price' &&
|
||||
$_POST["cancel"] <> $langs->trans("Cancel") && $user->rights->produit->creer)
|
||||
{
|
||||
$product = new Product($db);
|
||||
|
||||
$result = $product->fetch($_GET["id"]);
|
||||
|
||||
$product->price = ereg_replace(" ","",$_POST["price"]);
|
||||
|
||||
if ( $product->update_price($product->id, $user) > 0 )
|
||||
|
||||
{
|
||||
$_GET["action"] = '';
|
||||
$mesg = 'Fiche mise à jour';
|
||||
}
|
||||
else
|
||||
{
|
||||
$_GET["action"] = 'edit_price';
|
||||
$mesg = 'Fiche non mise à jour !' . "<br>" . $product->mesg_error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
* Affiche historique prix
|
||||
*/
|
||||
|
||||
llxHeader("","",$langs->trans("Price"));
|
||||
@ -66,6 +91,10 @@ $head[$h][1] = $langs->trans("Price");
|
||||
$hselected=$h;
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT."/product/photos.php?id=".$product->id;
|
||||
$head[$h][1] = $langs->trans("Photos");
|
||||
$h++;
|
||||
|
||||
if($product->type == 0)
|
||||
{
|
||||
if ($conf->stock->enabled)
|
||||
@ -82,10 +111,6 @@ if ($conf->fournisseur->enabled) {
|
||||
$h++;
|
||||
}
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT."/product/photos.php?id=".$product->id;
|
||||
$head[$h][1] = $langs->trans("Photos");
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT."/product/stats/fiche.php?id=".$product->id;
|
||||
$head[$h][1] = $langs->trans("Statistics");
|
||||
$h++;
|
||||
@ -93,7 +118,66 @@ $h++;
|
||||
|
||||
dolibarr_fiche_head($head, $hselected, $langs->trans("CardProduct".$product->type).' : '.$product->ref);
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr>';
|
||||
print '<td width="10%">'.$langs->trans("Ref").'</td><td colspan="2" width="40%">'.$product->ref.'</td>';
|
||||
print '</tr>';
|
||||
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="2">'.$product->libelle.'</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Prix
|
||||
print '<tr><td>'.$langs->trans("SellingPrice").'</td><td colspan="2">'.price($product->price).'</td></tr>';
|
||||
|
||||
// Statut
|
||||
print '<tr><td>'.$langs->trans("Status").'</td><td colspan="2">';
|
||||
if ($product->envente) print $langs->trans("OnSell");
|
||||
else print $langs->trans("NotOnSell");
|
||||
print '</td></tr>';
|
||||
|
||||
print "</table><br>\n";
|
||||
|
||||
print "</div>\n";
|
||||
|
||||
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* Barre d'action */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
print "\n<div class=\"tabsAction\">\n";
|
||||
|
||||
if ($_GET["action"] == '')
|
||||
{
|
||||
if ($user->rights->produit->modifier || $user->rights->produit->creer)
|
||||
{
|
||||
print '<a class="tabAction" href="'.DOL_URL_ROOT.'/product/price.php?action=edit_price&id='.$product->id.'">'.$langs->trans("UpdatePrice").'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
print "\n</div>\n";
|
||||
|
||||
|
||||
/*
|
||||
* Edition du prix
|
||||
*/
|
||||
if ($_GET["action"] == 'edit_price' && $user->rights->produit->creer)
|
||||
{
|
||||
print '<div class="titre">'.$langs->trans("NewPrice").'</div>';
|
||||
print '<form action="price.php?id='.$product->id.'" method="post">';
|
||||
print '<input type="hidden" name="action" value="update_price">';
|
||||
print '<input type="hidden" name="id" value="'.$product->id.'">';
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr><td width="20%">'.$langs->trans('SellingPrice').'</td><td><input name="price" size="10" value="'.price($product->price).'"></td></tr>';
|
||||
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 '</table>';
|
||||
print '</form>';
|
||||
}
|
||||
|
||||
|
||||
// Liste des evolutions du prix
|
||||
$sql = "SELECT p.rowid, p.price, ".$db->pdate("p.date_price")." as dp, u.login";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."product_price as p, llx_user as u";
|
||||
$sql .= " WHERE fk_product = ".$product->id;
|
||||
@ -111,7 +195,7 @@ if ($result)
|
||||
$db->free($result) ;
|
||||
|
||||
// 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 à niveau (pb vieilles versions)
|
||||
$product->update_price($product->id, $user);
|
||||
|
||||
$result = $db->query($sql) ;
|
||||
@ -120,6 +204,8 @@ if ($result)
|
||||
|
||||
if ($num > 0)
|
||||
{
|
||||
print '<br>';
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
@ -135,7 +221,7 @@ if ($result)
|
||||
$objp = $db->fetch_object($result);
|
||||
$var=!$var;
|
||||
print "<tr $bc[$var]>";
|
||||
print "<td>".dolibarr_print_date($objp->dp,"%d %B %Y %H:%M:%S")."</td>";
|
||||
print "<td>".dolibarr_print_date($objp->dp,"%d %b %Y %H:%M:%S")."</td>";
|
||||
print "<td>".price($objp->price)."</td>";
|
||||
print "<td>".$objp->login."</td>";
|
||||
|
||||
@ -152,30 +238,8 @@ else
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
|
||||
print "</div>\n";
|
||||
|
||||
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* Barre d'action */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
print "\n<div class=\"tabsAction\">\n";
|
||||
|
||||
if ($_GET["action"] == '')
|
||||
{
|
||||
if ($user->rights->produit->modifier || $user->rights->produit->creer)
|
||||
{
|
||||
print '<a class="tabAction" href="fiche.php?action=edit_price&id='.$product->id.'">'.$langs->trans("UpdatePrice").'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
print "\n</div>\n";
|
||||
|
||||
|
||||
$db->close();
|
||||
|
||||
llxFooter("<em>Dernière modification $Date$ révision $Revision$</em>");
|
||||
llxFooter('$Date$ - $Revision$');
|
||||
?>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (c) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (c) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* 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
|
||||
@ -21,11 +21,11 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/*!
|
||||
\file htdocs/product/stats/fiche.php
|
||||
\ingroup product
|
||||
\brief Page des stats produits
|
||||
\version $Revision$
|
||||
/**
|
||||
\file htdocs/product/stats/fiche.php
|
||||
\ingroup product
|
||||
\brief Page des stats produits
|
||||
\version $Revision$
|
||||
*/
|
||||
|
||||
require("./pre.inc.php");
|
||||
@ -48,12 +48,12 @@ else
|
||||
}
|
||||
|
||||
|
||||
llxHeader('','Statistiques produits');
|
||||
llxHeader('',$langs->trans("Statistics"));
|
||||
|
||||
$mesg = '';
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
@ -62,11 +62,11 @@ if ($_GET["id"])
|
||||
$product = new Product($db);
|
||||
$result = $product->fetch($_GET["id"]);
|
||||
|
||||
if ( $result )
|
||||
if ($result)
|
||||
{
|
||||
// Efface rep obsolete
|
||||
if(is_dir(DOL_DOCUMENT_ROOT."/document/produits"))
|
||||
rmdir(DOL_DOCUMENT_ROOT."/document/produits");
|
||||
rmdir(DOL_DOCUMENT_ROOT."/document/produits");
|
||||
|
||||
// Création répertoire pour images générées
|
||||
// $conf->produit->dir_images définit dans master.inc.php
|
||||
@ -119,6 +119,10 @@ if ($_GET["id"])
|
||||
$head[$h][1] = $langs->trans("Price");
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT."/product/photos.php?id=".$product->id;
|
||||
$head[$h][1] = $langs->trans("Photos");
|
||||
$h++;
|
||||
|
||||
if($product->type == 0)
|
||||
{
|
||||
if ($conf->stock->enabled)
|
||||
@ -136,10 +140,6 @@ if ($_GET["id"])
|
||||
$h++;
|
||||
}
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT."/product/photos.php?id=".$product->id;
|
||||
$head[$h][1] = $langs->trans("Photos");
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT."/product/stats/fiche.php?id=".$product->id;
|
||||
$head[$h][1] = $langs->trans("Statistics");
|
||||
$hselected=$h;
|
||||
@ -149,11 +149,13 @@ if ($_GET["id"])
|
||||
dolibarr_fiche_head($head, $hselected, $langs->trans("CardProduct".$product->type).' : '.$product->ref);
|
||||
|
||||
|
||||
print '<table class="border" width="100%"><tr>';
|
||||
print '<td width="20%">'.$langs->trans("Ref").'</td>';
|
||||
print '<td width="40%">'.$product->ref.'</td>';
|
||||
print '<td>'.$langs->trans("Statistics").'</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$product->libelle.'</td>';
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr>';
|
||||
print '<td width="10%">'.$langs->trans("Ref").'</td><td colspan="2" width="40%">'.$product->ref.'</td>';
|
||||
print '</tr>';
|
||||
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="2">'.$product->libelle.'</td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans("SellingPrice").'</td><td>'.price($product->price).'</td>';
|
||||
print '<td valign="top" rowspan="2">';
|
||||
// Propals
|
||||
if ($conf->propal->enabled)
|
||||
@ -175,7 +177,13 @@ if ($_GET["id"])
|
||||
print '<a href="facture.php?id='.$product->id.'">'.$langs->trans("Bills").'</a> : '.$product->count_facture($socid);
|
||||
}
|
||||
print '</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("CurrentPrice").'</td><td>'.price($product->price).'</td></tr>';
|
||||
|
||||
// Statut
|
||||
print '<tr><td>'.$langs->trans("Status").'</td><td>';
|
||||
if ($product->envente) print $langs->trans("OnSell");
|
||||
else print $langs->trans("NotOnSell");
|
||||
print '</td></tr>';
|
||||
|
||||
print "</table>";
|
||||
|
||||
print '<br><table class="border" width="100%">';
|
||||
@ -249,7 +257,9 @@ else
|
||||
dolibarr_print_error();
|
||||
}
|
||||
|
||||
|
||||
$db->close();
|
||||
|
||||
llxFooter("<em>Dernière modification $Date$ révision $Revision$</em>");
|
||||
llxFooter('$Date$ - $Revision$');
|
||||
|
||||
?>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user