*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/**
* \file htdocs/fourn/product/fourn.php
* \ingroup product
* \brief Page de la fiche produit fournisseur
* \version $Id$
*/
require("../../main.inc.php");
require_once DOL_DOCUMENT_ROOT."/fourn/class/fournisseur.product.class.php";
if (!$user->rights->produit->lire && !$user->rights->service->lire) accessforbidden();
if ($_POST["action"] == 'update' && $_POST["cancel"] <> $langs->trans("Cancel"))
{
$product = new ProductFournisseur($db);
$result = $product->fetch($_GET["id"], $_GET["id_fourn"]);
if( $result == 0 )
{
$product->update($_POST["fourn_ref"], '1', $_POST["price"], $user);
}
Header('Location :fourn.php?id='.$product->id.'&id_fourn='.$_GET["id_fourn"]);
}
llxHeader("","",$langs->trans("CardProduct0"));
/*
* Fiche produit
*/
if ($_GET["id"])
{
if ($_GET["action"] <> 're-edit')
{
$product = new ProductFournisseur($db);
$result = $product->fetch($_GET["id"], $_GET["id_fourn"]);
$product->get_buyprice($_GET["id_fourn"],1);
}
if ( $result == 0)
{
/*
* En mode visu
*/
$h=0;
$head[$h][0] = DOL_URL_ROOT."/fourn/product/fiche.php?id=".$product->id;
$head[$h][1] = $langs->trans("ProductCard");
$h++;
$head[$h][0] = DOL_URL_ROOT."/fourn/product/fourn.php?id=".$product->id.'&id_fourn='.$_GET["id_fourn"];
$head[$h][1] = $langs->trans("SupplierCard");
$hselected = $h;
$h++;
dol_fiche_head($head, $hselected, $langs->trans("CardProduct".$product->type).' : '.$product->ref);
print '
';
if ($conf->categorie->enabled)
{
print '';
print '| ';
$cat = new Categorie ($db);
$way = $cat->print_primary_way($product->id," > ",'fourn/product/liste.php', 1);
if ($way == "")
{
print "Ce produit n'appartient a aucune categorie";
}
else
{
print $langs->trans("Category")." : ";
print $way;
}
print ' |
';
}
print '| '.$langs->trans("Label").' | '.$product->libelle.' |
';
print '| '.$langs->trans("InternalRef").' | '.$product->ref.' | ';
print '';
$product->show_photos($conf->produit->dir_output,1,1,0);
print ' |
';
print "";
print '| '.$langs->trans("Supplier").' | '.$product->fourn->getNomUrl(1).' | ';
print '
';
print '| '.$langs->trans("SupplierRef").' | '.$product->fourn_ref.' | ';
print '
';
print '| '.$langs->trans("BuiingPrice").' | '.price($product->buyprice).' | ';
print '
';
print '| '.$langs->trans("Description").' |
';
print '| '.nl2br($product->description).' |
';
print "
\n";
print '';
print '| ';
print $langs->trans("Date").' | ';
print ''.$langs->trans("Price").' | ';
print ''.$langs->trans("Quantity").' | ';
print '
';
/*
* Prix
*/
$sql = "SELECT p.price, p.quantity, tms as date_releve";
$sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as p";
$sql .=" WHERE p.fk_soc = ".$product->fourn->id;
$sql .= " AND p.fk_product = ".$product->id;
$sql .= " ORDER BY p.quantity ASC";
$resql= $db->query($sql) ;
if ($resql)
{
$num_fournisseur = $db->num_rows($resql);
$i = 0;
$var=True;
while ($i < $num_fournisseur)
{
$objp = $db->fetch_object($resql);
$var=!$var;
print "";
print '| '.dol_print_date($db->datej($objp->date_releve)).' | ';
print ''.price($objp->price).' | ';
print ''.$objp->quantity.' |
';
$i++;
}
$db->free($resql);
}
print '
';
/*
*
* Fiche en mode edition
*
*/
if (($_GET["action"] == 'edit' || $_GET["action"] == 're-edit') && ($user->rights->produit->creer || $user->rights->service->creer))
{
$action = 'fourn.php?id='.$product->id.'&id_fourn='.$product->fourn->id;
print '';
}
print "\n";
/* ************************************************************************** */
/* */
/* Barre d'action */
/* */
/* ************************************************************************** */
print "\n\n";
if ($_GET["action"] == '')
{
if ($user->rights->produit->creer || $user->rights->service->creer)
{
print '
'.$langs->trans("Modify").'';
}
}
print "\n
\n";
}
}
else
{
print $langs->trans("ErrorUnknown");
}
$db->close();
llxFooter("Dernière modification $Date$ révision $Revision$");
?>