Nouveau fichier
This commit is contained in:
parent
6fde7b4592
commit
59c5166ec5
620
htdocs/fourn/product/fiche.php
Normal file
620
htdocs/fourn/product/fiche.php
Normal file
@ -0,0 +1,620 @@
|
||||
<?php
|
||||
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004 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
|
||||
* 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.
|
||||
*
|
||||
* $Id$
|
||||
* $Source$
|
||||
*
|
||||
*/
|
||||
|
||||
/*!
|
||||
\file htdocs/product/fiche.php
|
||||
\ingroup product
|
||||
\brief Page de la fiche produit
|
||||
\version $Revision$
|
||||
*/
|
||||
|
||||
require("./pre.inc.php");
|
||||
|
||||
$langs->load("products");
|
||||
|
||||
$user->getrights('produit');
|
||||
$user->getrights('propale');
|
||||
$user->getrights('facture');
|
||||
$mesg = '';
|
||||
|
||||
if (!$user->rights->produit->lire) accessforbidden();
|
||||
|
||||
|
||||
$types[0] = $langs->trans("Product");
|
||||
$types[1] = $langs->trans("Service");
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
|
||||
if ( $_POST["sendit"] && defined('MAIN_UPLOAD_DOC') && MAIN_UPLOAD_DOC == 1)
|
||||
{
|
||||
if ($_GET["id"])
|
||||
{
|
||||
$product = new Product($db);
|
||||
$result = $product->fetch($_GET["id"]);
|
||||
|
||||
// if (doliMoveFileUpload($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name']))
|
||||
|
||||
// var_dump($_FILES);
|
||||
|
||||
$product->add_photo($conf->produit->dir_output, $_FILES['photofile']);
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
if ($_GET["action"] == 'fastappro')
|
||||
{
|
||||
$product = new Product($db);
|
||||
$product->fetch($_GET["id"]);
|
||||
$result = $product->fastappro($user);
|
||||
Header("Location: fiche.php?id=".$_GET["id"]);
|
||||
}
|
||||
|
||||
|
||||
// Action ajout d'un produit ou service
|
||||
if ($_POST["action"] == 'add' && $user->rights->produit->creer)
|
||||
{
|
||||
$product = new Product($db);
|
||||
|
||||
$product->ref = $_POST["ref"];
|
||||
$product->libelle = $_POST["libelle"];
|
||||
$product->price = $_POST["price"];
|
||||
$product->tva_tx = $_POST["tva_tx"];
|
||||
$product->type = $_POST["type"];
|
||||
$product->envente = $_POST["statut"];
|
||||
$product->description = $_POST["desc"];
|
||||
$product->duration_value = $_POST["duration_value"];
|
||||
$product->duration_unit = $_POST["duration_unit"];
|
||||
$product->seuil_stock_alerte = $_POST["seuil_stock_alerte"];
|
||||
|
||||
$e_product = $product;
|
||||
|
||||
$id = $product->create($user);
|
||||
|
||||
if ($id > 0)
|
||||
{
|
||||
Header("Location: fiche.php?id=$id");
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($id == -3)
|
||||
{
|
||||
$_error = 1;
|
||||
$_GET["action"] = "create";
|
||||
$_GET["type"] = $_POST["type"];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Action mise a jour d'un produit ou service
|
||||
if ($_POST["action"] == 'update' &&
|
||||
$_POST["cancel"] <> $langs->trans("Cancel") &&
|
||||
$user->rights->produit->creer)
|
||||
{
|
||||
$product = new Product($db);
|
||||
if ($product->fetch($_POST["id"]))
|
||||
{
|
||||
$product->ref = $_POST["ref"];
|
||||
$product->libelle = $_POST["libelle"];
|
||||
$product->price = $_POST["price"];
|
||||
$product->description = $_POST["desc"];
|
||||
$product->seuil_stock_alerte = $_POST["seuil_stock_alerte"];
|
||||
$product->duration_value = $_POST["duration_value"];
|
||||
$product->duration_unit = $_POST["duration_unit"];
|
||||
|
||||
if ($product->check())
|
||||
{
|
||||
if ($product->update($product->id, $user) > 0)
|
||||
{
|
||||
$_GET["action"] = '';
|
||||
$_GET["id"] = $_POST["id"];
|
||||
|
||||
Header("Location: fiche.php?id=".$_POST["id"]);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$_GET["action"] = 're-edit';
|
||||
$_GET["id"] = $_POST["id"];
|
||||
$mesg = $product->mesg_error;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$_GET["action"] = 're-edit';
|
||||
$_GET["id"] = $_POST["id"];
|
||||
$mesg = $langs->trans("ErrorProductBadRefOrLabel");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($_POST["action"] == 'add_fourn' && $_POST["cancel"] <> $langs->trans("Cancel"))
|
||||
{
|
||||
|
||||
$product = new Product($db);
|
||||
if( $product->fetch($_GET["id"]) )
|
||||
{
|
||||
if ($product->add_fournisseur($user, $_POST["id_fourn"], $_POST["ref_fourn"]) > 0)
|
||||
{
|
||||
$action = '';
|
||||
$mesg = $langs->trans("SupplierAdded");
|
||||
}
|
||||
else
|
||||
{
|
||||
$action = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($_GET["action"] == 'remove_fourn')
|
||||
{
|
||||
$product = new Product($db);
|
||||
if( $product->fetch($_GET["id"]) )
|
||||
{
|
||||
if ($product->remove_fournisseur($user, $_GET["id_fourn"]) > 0)
|
||||
{
|
||||
$_GET["action"] = '';
|
||||
$mesg = $langs->trans("SupplierRemoved");
|
||||
}
|
||||
else
|
||||
{
|
||||
$_GET["action"] = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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 = '';
|
||||
Header("Location: fiche.php?id=".$_POST["id"]);
|
||||
}
|
||||
|
||||
// Le produit n'est pas encore chargé a ce stade
|
||||
//llxHeader("","",$langs->trans("CardProduct".$product->type));
|
||||
llxHeader("","",$langs->trans("CardProduct0"));
|
||||
|
||||
|
||||
/*
|
||||
* Création du produit
|
||||
*
|
||||
*/
|
||||
if ($_GET["action"] == 'create' && $user->rights->produit->creer)
|
||||
{
|
||||
$html = new Form($db);
|
||||
$nbligne=0;
|
||||
$product = new Product($db);
|
||||
if ($_error == 1)
|
||||
{
|
||||
$product = $e_product;
|
||||
}
|
||||
|
||||
print '<form action="fiche.php" method="post">';
|
||||
print '<input type="hidden" name="action" value="add">';
|
||||
print '<input type="hidden" name="type" value="'.$_GET["type"].'">'."\n";
|
||||
print '<div class="titre">';
|
||||
if ($_GET["type"]==0) { print $langs->trans("NewProduct"); }
|
||||
if ($_GET["type"]==1) { print $langs->trans("NewService"); }
|
||||
print '</div><br>'."\n";
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr>';
|
||||
print '<td>'.$langs->trans("Ref").'</td><td><input name="ref" size="20" value="'.$product->ref.'">';
|
||||
if ($_error == 1)
|
||||
{
|
||||
print $langs->trans("RefAlreadyExists");
|
||||
}
|
||||
print '</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("Label").'</td><td><input name="libelle" size="40" value="'.$product->libelle.'"></td></tr>';
|
||||
print '<tr><td>'.$langs->trans("SellingPrice").'</td><td><input name="price" size="10" value="'.$product->price.'"></td></tr>';
|
||||
|
||||
$langs->load("bills");
|
||||
print '<tr><td>'.$langs->trans("VATRate").'</td><td>';
|
||||
print $html->select_tva("tva_tx",$conf->defaulttx);
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans("Status").'</td><td>';
|
||||
print '<select name="statut">';
|
||||
print '<option value="1">'.$langs->trans("OnSell").'</option>';
|
||||
print '<option value="0" selected>'.$langs->trans("NotOnSell").'</option>';
|
||||
print '</td></tr>';
|
||||
|
||||
if ($_GET["type"] == 0 && $conf->stick->enabled)
|
||||
{
|
||||
print "<tr>".'<td>Seuil stock</td><td colspan="2">';
|
||||
print '<input name="seuil_stock_alerte" size="4" value="0">';
|
||||
print '</td></tr>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input name="seuil_stock_alerte" type="hidden" value="0">';
|
||||
}
|
||||
print '<tr><td valign="top">'.$langs->trans("Description").'</td><td>';
|
||||
print '<textarea name="desc" rows="8" cols="50">';
|
||||
print "</textarea></td></tr>";
|
||||
if ($_GET["type"] == 1)
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("Duration").'</td><td><input name="duration_value" size="6" maxlength="5" value="'.$product->duree.'"> ';
|
||||
print '<input name="duration_unit" type="radio" value="d">'.$langs->trans("Day").' ';
|
||||
print '<input name="duration_unit" type="radio" value="w">'.$langs->trans("Week").' ';
|
||||
print '<input name="duration_unit" type="radio" value="m">'.$langs->trans("Month").' ';
|
||||
print '<input name="duration_unit" type="radio" value="y">'.$langs->trans("Year").' ';
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
print '<tr><td> </td><td><input type="submit" value="'.$langs->trans("Create").'"></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."/fourn/product/fiche.php?id=".$product->id;
|
||||
$head[$h][1] = $langs->trans("Card");
|
||||
$hselected = $h;
|
||||
$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="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>';
|
||||
|
||||
$nblignefour=3;
|
||||
|
||||
print '<td valign="top" rowspan="'.$nblignefour.'">';
|
||||
|
||||
print '</td></tr>';
|
||||
|
||||
|
||||
if ($product->type == 0 && defined("MAIN_MODULE_STOCK"))
|
||||
{
|
||||
print '<tr><td><a href="'.DOL_URL_ROOT.'/product/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 '<table class="border" width="100%">';
|
||||
print '<tr class="liste_titre"><td>';
|
||||
print $langs->trans("Suppliers").'</td>';
|
||||
print '<td>'.$langs->trans("Ref").'</td>';
|
||||
print '</tr>';
|
||||
|
||||
$sql = "SELECT s.nom, s.idp, pf.ref_fourn";
|
||||
$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)";
|
||||
|
||||
if ( $db->query($sql) )
|
||||
{
|
||||
$num_fournisseur = $db->num_rows();
|
||||
$i = 0;
|
||||
$var=True;
|
||||
while ($i < $num_fournisseur)
|
||||
{
|
||||
$objp = $db->fetch_object($i);
|
||||
$var=!$var;
|
||||
print "<tr $bc[$var]>";
|
||||
print '<td><a href="'.DOL_URL_ROOT.'/fourn/fiche.php?socid='.$objp->idp.'">'.$objp->nom.'</a></td>';
|
||||
print '<td>';
|
||||
print '<a href="fourn.php?id='.$product->id.'&id_fourn='.$objp->idp.'">';
|
||||
print img_edit($langs->trans("Edit"));
|
||||
print ' <a href="fourn.php?id='.$product->id.'&id_fourn='.$objp->idp.'">';
|
||||
print $objp->ref_fourn.'</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++;
|
||||
}
|
||||
$db->free();
|
||||
}
|
||||
print '</table>';
|
||||
|
||||
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><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)";
|
||||
|
||||
if ($db->query($sql))
|
||||
{
|
||||
$num = $db->num_rows();
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $db->fetch_object($i);
|
||||
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" value="'.$langs->trans("Save").'"> ';
|
||||
print '<input type="submit" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>';
|
||||
print '</table>';
|
||||
print '</form>';
|
||||
}
|
||||
|
||||
/*
|
||||
* Ajouter une photo
|
||||
*
|
||||
*/
|
||||
if ($_GET["action"] == 'ajout_photo' && $user->rights->produit->creer && $product->isproduct)
|
||||
{
|
||||
print_titre($langs->trans("AddPhoto"));
|
||||
|
||||
print '<form name="userfile" action="fiche.php?id='.$product->id.'" enctype="multipart/form-data" METHOD="POST">';
|
||||
print '<input type="hidden" name="max_file_size" value="2000000">';
|
||||
|
||||
print '<table class="border" width="100%"><tr>';
|
||||
print '<td>'.$langs->trans("File").'</td>';
|
||||
print '<td><input type="file" name="photofile"></td></tr>';
|
||||
|
||||
print '<tr><td colspan="4" align="center">';
|
||||
print '<input type="submit" name="sendit" value="'.$langs->trans("Save").'"> ';
|
||||
|
||||
|
||||
print '<input type="submit" 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>';
|
||||
|
||||
|
||||
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" value="'.$langs->trans("Save").'"> ';
|
||||
print '<input type="submit" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>';
|
||||
print '</table>';
|
||||
print '</form>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print $langs->trans("ErrorUnknown");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* Barre d'action */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
print "\n<div class=\"tabsAction\">\n";
|
||||
|
||||
if ($_GET["action"] == '')
|
||||
{
|
||||
|
||||
print '<a class="butAction" href="fiche.php?id='.$product->id.'&action=ajout_fourn">'.$langs->trans("AddSupplier").'</a>';
|
||||
|
||||
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>';
|
||||
}
|
||||
|
||||
if ( $user->rights->produit->creer)
|
||||
{
|
||||
print '<a class="tabAction" href="fiche.php?action=edit&id='.$product->id.'">'.$langs->trans("Edit").'</a>';
|
||||
}
|
||||
|
||||
if ($product->type == 0 && $conf->stock->enabled)
|
||||
{
|
||||
print '<a class="tabAction" href="'.DOL_URL_ROOT.'/stock/product.php?id='.$product->id.'&action=correction">'.$langs->trans("CorrectStock").'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
print "\n</div>\n";
|
||||
|
||||
$db->close();
|
||||
|
||||
llxFooter("<em>Dernière modification $Date$ révision $Revision$</em>");
|
||||
?>
|
||||
251
htdocs/fourn/product/fourn.php
Normal file
251
htdocs/fourn/product/fourn.php
Normal file
@ -0,0 +1,251 @@
|
||||
<?php
|
||||
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* $Id$
|
||||
* $Source$
|
||||
*
|
||||
*/
|
||||
|
||||
/*!
|
||||
\file htdocs/fourn/product/fourn.php
|
||||
\ingroup product
|
||||
\brief Page de la fiche produit fournisseur
|
||||
\version $Revision$
|
||||
*/
|
||||
|
||||
require("./pre.inc.php");
|
||||
|
||||
$langs->load("products");
|
||||
$user->getrights('produit');
|
||||
|
||||
if (!$user->rights->produit->lire) accessforbidden();
|
||||
|
||||
llxHeader("","",$langs->trans("CardProduct0"));
|
||||
|
||||
/*
|
||||
* Fiche produit
|
||||
*/
|
||||
if ($_GET["id"])
|
||||
{
|
||||
if ($_GET["action"] <> 're-edit')
|
||||
{
|
||||
$product = new Product($db);
|
||||
$result = $product->fetch($_GET["id"]);
|
||||
|
||||
$fourn = new Fournisseur($db);
|
||||
$result = $fourn->fetch($_GET["id_fourn"]);
|
||||
}
|
||||
|
||||
if ( $result )
|
||||
{
|
||||
|
||||
if ($_GET["action"] <> 'edit' && $_GET["action"] <> 're-edit')
|
||||
{
|
||||
/*
|
||||
* 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++;
|
||||
|
||||
dolibarr_fiche_head($head, $hselected, $langs->trans("CardProduct".$product->type).' : '.$product->ref);
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
print "<tr>";
|
||||
print '<td width="20%">'.$langs->trans("InternalRef").'</td><td width="40%">'.$product->ref.'</td>';
|
||||
print '</tr>';
|
||||
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="2">'.$product->libelle.'</td></tr>';
|
||||
|
||||
print "<tr>";
|
||||
print '<td width="20%">'.$langs->trans("Supplier").'</td><td width="40%">'.$fourn->nom_url.'</td>';
|
||||
print '</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 '<table class="border" width="100%">';
|
||||
print '<tr class="liste_titre"><td>';
|
||||
print $langs->trans("Date").'</td>';
|
||||
print '<td align="right">'.$langs->trans("Price").'</td>';
|
||||
print '<td align="center">'.$langs->trans("Quantity").'</td>';
|
||||
print '</tr>';
|
||||
|
||||
/*
|
||||
* Prix
|
||||
*/
|
||||
|
||||
$sql = "SELECT p.price, p.quantity,".$db->pdate("tms") ." as date_releve";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as p";
|
||||
$sql .=" WHERE p.fk_soc = ".$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 "<tr $bc[$var]>";
|
||||
print '<td>'.dolibarr_print_date($objp->date_releve).'</td>';
|
||||
print '<td align="right">'.price($objp->price).'</td>';
|
||||
print '<td align="center">'.$objp->quantity.'</td></tr>';
|
||||
|
||||
$i++;
|
||||
}
|
||||
$db->free($resql);
|
||||
}
|
||||
print '</table>';
|
||||
print "</div>\n";
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* 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" value="'.$langs->trans("Save").'"> ';
|
||||
print '<input type="submit" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>';
|
||||
print '</table>';
|
||||
print '</form>';
|
||||
}
|
||||
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* Barre d'action */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
print "\n<div class=\"tabsAction\">\n";
|
||||
|
||||
if ($_GET["action"] == '')
|
||||
{
|
||||
|
||||
if ( $user->rights->produit->creer)
|
||||
{
|
||||
print '<a class="tabAction" href="fiche.php?action=edit&id='.$product->id.'">'.$langs->trans("Edit").'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
print "\n</div>\n";
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print $langs->trans("ErrorUnknown");
|
||||
}
|
||||
$db->close();
|
||||
|
||||
llxFooter("<em>Dernière modification $Date$ révision $Revision$</em>");
|
||||
?>
|
||||
|
||||
172
htdocs/fourn/product/photos.php
Normal file
172
htdocs/fourn/product/photos.php
Normal file
@ -0,0 +1,172 @@
|
||||
<?php
|
||||
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004 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
|
||||
* 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.
|
||||
*
|
||||
* $Id$
|
||||
* $Source$
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/product/fiche.php
|
||||
\ingroup product
|
||||
\brief Page de la fiche produit
|
||||
\version $Revision$
|
||||
*/
|
||||
|
||||
require("./pre.inc.php");
|
||||
require("../propal.class.php");
|
||||
require("../facture.class.php");
|
||||
|
||||
$langs->load("products");
|
||||
|
||||
$user->getrights('produit');
|
||||
$user->getrights('propale');
|
||||
$user->getrights('facture');
|
||||
$mesg = '';
|
||||
|
||||
if (!$user->rights->produit->lire) accessforbidden();
|
||||
|
||||
|
||||
$types[0] = $langs->trans("Product");
|
||||
$types[1] = $langs->trans("Service");
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
|
||||
if ( $_POST["sendit"] && defined('MAIN_UPLOAD_DOC') && MAIN_UPLOAD_DOC == 1)
|
||||
{
|
||||
if ($_GET["id"])
|
||||
{
|
||||
$product = new Product($db);
|
||||
$result = $product->fetch($_GET["id"]);
|
||||
|
||||
// if (doliMoveFileUpload($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name']))
|
||||
|
||||
// var_dump($_FILES);
|
||||
|
||||
$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 )
|
||||
{
|
||||
|
||||
|
||||
/*
|
||||
* 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++;
|
||||
|
||||
dolibarr_fiche_head($head, $hselected, $langs->trans("CardProduct".$product->type).' : '.$product->ref);
|
||||
|
||||
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>'.$product->libelle.'</td>';
|
||||
print '<td>'.$langs->trans("SellingPrice").'</td><td>'.price($product->price).'</td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans("Description").'</td><td colspan="3">'.nl2br($product->description).'</td></tr>';
|
||||
|
||||
print "</table><br>\n";
|
||||
|
||||
/*
|
||||
* Photo
|
||||
*
|
||||
*/
|
||||
if ($_GET["id"] && $_GET["action"]=='')
|
||||
{
|
||||
print $product->show_photos($conf->produit->dir_output);
|
||||
}
|
||||
|
||||
print "</div>\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print $langs->trans("ErrorUnknown");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$db->close();
|
||||
|
||||
llxFooter("<em>Dernière modification $Date$ révision $Revision$</em>");
|
||||
?>
|
||||
Loading…
Reference in New Issue
Block a user