voici le code /
<?
include("config_stock13.php");
if ($action ==1) {
// Nom du fichier, tx de compression, Taille hauteur max, Taille largeur Max, rep source, rep de destination, prefixe a mettre
function reduit_fichier($fichier_image,$scale,$max_v,$max_h,$source,$destination,$prefixe)
{
// MAX_V = HAUTEUR -- MAX_H = LARGEUR
// le nom de l'image "scalÈe" commencera par ti_ et le nom du fichier original
$ti_fichier_image=$prefixe.$fichier_image;
global $nomfichier;
$im = ImageCreateFromjpeg("$source"."$fichier_image");
$v=ImageSY($im); // $v prend la hauteur
$h=ImageSX($im); // $h prend la largeur
//Floor Arrondi ‡ l'entier infÈrieur
//ON GERE LA HAUTEUR
if ($v > $max_v) // Si la hauteur Img, est plus grand que le max, on reduit
{
$taux_hauteur=$v/$max_v; // On recupere le taux necessaire pour retrecir
$ti_v=(int)floor($max_v); // ti_v = taille final de la hauteur
$ti_h=(int)floor($h/$taux_hauteur); // ti_h = taille final de la largeur
}
else $ti_v=$v; // Sinon on fixe la hauteur
// Si il n'a pas deja subbit une modification de la taille
if ($ti_h!="") $h_comp = $ti_h; else $h_comp = $h;
if ($ti_v!="") $v_comp = $ti_v; else $v_comp = $v;
//ON GERE LA LARGEUR
if ($h_comp > $max_h)
{
$taux_largeur=$h_comp/$max_h;
$ti_h=(int)floor($max_h);
$ti_v=(int)floor($v_comp/$taux_largeur);
}
else $ti_h=$h_comp;
$ti_im = ImageCreateTrueColor($ti_h,$ti_v);
ImageCopyResampled($ti_im,$im,0,0,0,0,$ti_h,$ti_v,$h,$v);
imagejpeg($ti_im,"$destination"."$ti_fichier_image",$scale);
$nomfichier = $destination.$ti_fichier_image;
}
if ($photoproduit != "") {
$split = explode(".", $photoproduit_name);
$ext = strtolower($split[1]);
if ($ext == "jpg" || $ext == "gif" || $ext == "jpeg") {
$largefile = "produits/$id.$ext";
///////
$fichier = $_FILES['photoproduit']['name'];
$size = $_FILES['photoproduit']['size'];
$max = $_POST['max'];
$photo_ext = strtolower($photoproduit_name);
eregi("\.(.*)$",$photo_ext,$regs);
if (file_exists("produits/petit_$id.jpeg")) {
unlink("produits/petit_$id.jpeg");
}
if (file_exists("produits/$id.jpeg")) {
unlink("produits/$id.jpeg");
}
if (file_exists("produits/petit_$id.jpg")) {
unlink("produits/petit_$id.jpg");
}
if (file_exists("produits/$id.jpg")) {
unlink("produits/$id.jpg");
}
move_uploaded_file($photoproduit, "produits/$id.$ext");
$name_image="produits/$id.$ext";
reduit_fichier("$id.$ext",150,100,130,"produits/","produits/","petit_");
$queryphot = mysql_query("UPDATE produit SET photo='$largefile' WHERE id_produit=$id");
}
}
else {
}
//////////////////
$query = mysql_query("UPDATE produit SET nom='$nom', reference='$reference', type='$type', description='$description', stock='$stock', prix_vente='$prix_vente', commentaire='$commentaire' WHERE id_produit=$id");
///DISPO PRODUIT /////
$querydispo = mysql_query("UPDATE dispo SET dispo=$dispo, info='$dispo_prod' WHERE id_produit=$id");
//////////////////////
//////MISE A JOUR PRIX FOURNISSEURS//////////
$query6=mysql_query("SELECT id_fournisseur FROM fournisseur WHERE 1");
while ($nbrow6 = mysql_fetch_array($query6)) {
$id_fournisseur = $nbrow6["id_fournisseur"];
$queryfour = mysql_query("UPDATE prod_four SET prix='$four[$id_fournisseur]' WHERE id_produit=$id AND id_fournisseur=$id_fournisseur");
}
///////////////////////////////////////////
echo "<SCRIPT LANGUAGE=\"JavaScript\">
<!-- Debut script
alert(\"Le Produit a ÈtÈ modifiÈ avec succËs\");
// Fin script -->
</SCRIPT>";
}
if ($action ==2) {
$reqsup = mysql_query("DELETE FROM produit WHERE id_produit=$id");
if (file_exists("produits/petit_$id.jpeg")) {
unlink("produits/petit_$id.jpeg");
}
if (file_exists("produits/$id.jpeg")) {
unlink("produits/$id.jpeg");
}
if (file_exists("produits/petit_$id.jpg")) {
unlink("produits/petit_$id.jpg");
}
if (file_exists("produits/$id.jpg")) {
unlink("produits/$id.jpg");
}
echo "<SCRIPT LANGUAGE=\"JavaScript\">
<!-- Debut script
alert(\"Le Produit a ÈtÈ supprimÈ avec succËs\");
// Fin script -->
</SCRIPT>";
echo "<script>window.location=\"debut.php\";</script>";
}
$query=@mysql_query("SELECT * FROM produit WHERE id_produit=$id");
$nbrow = mysql_fetch_array($query);
$reference = $nbrow["reference"];
$nom = $nbrow["nom"];
$type = $nbrow["type"];
$description = $nbrow["description"];
$photo = $nbrow["photo"];
$stock = $nbrow["stock"];
$prix_vente = $nbrow["prix_vente"];
$commentaire = $nbrow["commentaire"];
$photo_p2 = str_replace("produits/","produits/petit_",$photo);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>XIII JAPAN - GESTION | Fiche Produit |</title>
<style type="text/css">
<!--
.Style1 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 14px;
font-weight: bold;
color: #FFFFFF;
}
.Style2 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
color: #FFFFFF;
font-weight: bold;
}
.Style13 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; font-weight: bold; }
.Style16 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; }
.Style14 {color: #FFFFFF}
.Style17 {font-size: 11px; font-family: Verdana, Arial, Helvetica, sans-serif;}
.Style18 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; color: #333333; font-weight: bold; }
-->
</style>
<SCRIPT LANGUAGE="JavaScript">
function PopupCentrer(page)
{
imagePOP = new Image();
imagePOP.src = page;
nbf = 0;
affiche();
}
function affiche()
{
if (imagePOP.width != 0) {setTimeout("pop()",0);return;}
nbf++
if (nbf<200) {setTimeout("affiche()",20);return;}
}
function pop()
{
largeur = imagePOP.width;
hauteur = imagePOP.height;
ttop=(screen.height-hauteur)/2;
tleft=(screen.width-largeur)/2;
POPUP = window.open("","affiche","top="+ttop+",left="+tleft+",width="+largeur+",height="+hauteur+",menubar=no,scrollbars=no,statusbar=no");
POPUP.document.write("<body MARGINWIDTH=0 MARGINHEIGHT=0><img name='img' style='position:absolute;top:0;left:0;' src='"+imagePOP.src+"' border=0 alt=''></body>");
POPUP.document.close();
POPUP.focus();
}
</SCRIPT>
</head>
<body>
<table width="93%" border="0" align="center">
<tr>
<td bgcolor="#333333"><span class="Style1">FICHE PRODUIT</span></td>
</tr>
</table>
<FORM name="formulaire" action="fiche_produit.php?action=1&id=<? echo "$id"; ?>" method="post" enctype="multipart/form-data">
<table width="92%" border="0" align="center" cellspacing="1">
<tr>
<td width="4%" bgcolor="#FFFFFF"><div align="center"><a href="#" onclick="window.print();"><img src="images/imprimer_off.gif" alt="Imprimer la Page" name="btnPrint" border="0" id="btnPrint"></a></div></td>
<td colspan="2" bgcolor="#3887E7"> <span class="Style2">Identification</span></td>
</tr>
<tr>
<td bgcolor="#FFFFFF"> </td>
<td width="19%" bgcolor="#BDD8F6"> </td>
<td width="77%" bgcolor="#BDD8F6"> </td>
</tr>
<tr>
<td bgcolor="#FFFFFF"> </td>
<td bgcolor="#BDD8F6"><span class="Style13"> Référence</span></td>
<td bgcolor="#BDD8F6">
<input name="reference" type="text" class="Style16" id="reference" value="<? echo "$reference"; ?>" size="35"></td>
</tr>
<tr>
<td bgcolor="#FFFFFF"> </td>
<td bgcolor="#BDD8F6"><span class="Style13"> Nom</span></td>
<td bgcolor="#BDD8F6">
<input name="nom" type="text" class="Style16" id="nom" value="<? echo "$nom"; ?>" size="35"></td>
</tr>
<tr>
<td bgcolor="#FFFFFF"> </td>
<td bgcolor="#BDD8F6"><span class="Style13"> Type</span></td>
<td bgcolor="#BDD8F6">
<select name="type" class="Style16">
<option value="0"> </option>
<?
$query=mysql_query("SELECT id_type,nom FROM type_fournisseur WHERE 1");
while ($nbrow = mysql_fetch_array($query)) {
$id_type = $nbrow["id_type"];
$nom = $nbrow["nom"];
if ($type == $id_type) {
echo "<option value=\"$id_type\" selected>$nom</option>";
}
else {
echo "<option value=\"$id_type\">$nom</option>";
}
}
?>
</select></td>
</tr>
<tr>
<td bgcolor="#FFFFFF"> </td>
<td bgcolor="#BDD8F6"><span class="Style13"> Description</span></td>
<td bgcolor="#BDD8F6">
<textarea name="description" cols="85" rows="13" class="Style16" id="description"><? echo "$description"; ?></textarea></td>
</tr>
<tr>
<td bgcolor="#FFFFFF"> </td>
<td bgcolor="#BDD8F6"><span class="Style13"> Photo</span></td>
<td bgcolor="#BDD8F6"><? echo "<a href=\"javascript:PopupCentrer('$photo')\"><img src=\"./$photo_p2\" border=\"0\"></A>"; ?> <input type="hidden" name="MAX_FILE_SIZE" value="1000000" class="textblue11">
<input type="file" name="photoproduit" size="15" class="Style16"></td>
</tr>
<tr>
<td bgcolor="#FFFFFF"> </td>
<td bgcolor="#993333"><span class="Style13"> <span class="Style14">Stock</span></span></td>
<td bgcolor="#993333">
<input name="stock" type="text" class="Style16" value="<? echo "$stock"; ?>" id="stock" size="10"></td>
</tr>
<tr>
<td bgcolor="#FFFFFF"> </td>
<td bgcolor="#BDD8F6"><span class="Style13"> Prix d'achat HT </span></td>
<td bgcolor="#BDD8F6"><span class="Style13">
<table width="59%" border="0" cellspacing="1" bgcolor="#FFFFCC">
<?
$query5=mysql_query("SELECT id_fournisseur,prix FROM prod_four WHERE id_produit=$id");
while ($nbrow5 = mysql_fetch_array($query5)) {
$id_fournisseur = $nbrow5["id_fournisseur"];
$prix = $nbrow5["prix"];
$query6=mysql_query("SELECT nom FROM fournisseur WHERE id_fournisseur=$id_fournisseur");
$nbrow6 = mysql_fetch_array($query6);
$nom = $nbrow6["nom"];
echo "<tr>
<td width=\"50%\"><span class=\"Style13\"> $nom</span></td>
<td width=\"50%\"><input name=\"four[$id_fournisseur]\" type=\"text\" class=\"Style16\" id=\"four[$id_fournisseur]\" value=\"$prix\" size=\"15\">
<span class=\"Style13\">€ </span></td>
</tr>";
}
?>
</table></span></td>
</tr>
<tr>
<td bgcolor="#FFFFFF"> </td>
<td bgcolor="#BDD8F6"><span class="Style13"> Prix de Vente TTC </span></td>
<td bgcolor="#BDD8F6">
<input name="prix_vente" type="text" class="Style16" value="<? echo "$prix_vente"; ?>" id="prix_achat" size="15">
<span class="Style13">€</span></td>
</tr>
<tr>
<td bgcolor="#FFFFFF"> </td>
<td bgcolor="#BDD8F6"><span class="Style13"> Commentaires</span></td>
<td bgcolor="#BDD8F6">
<textarea name="commentaire" cols="50" rows="5" class="Style16" id="commentaire"><? echo "$commentaire"; ?></textarea></td>
</tr>
<tr>
<td bgcolor="#FFFFFF"> </td>
<td bgcolor="#BDD8F6"><span class="Style13"> Disponible</span></td>
<?
$querydis=mysql_query("SELECT dispo,info FROM dispo WHERE id_produit=$id");
$nbrowdis = mysql_fetch_array($querydis);
$dispoaff = $nbrowdis["dispo"];
$infoaff = $nbrowdis["info"];
?>
<td bgcolor="#BDD8F6">
<?
if ($dispoaff == 1) {
echo "<input type=\"radio\" name=\"dispo\" value=\"1\" checked>
<span class=\"Style13\">OUI
<input type=\"radio\" name=\"dispo\" value=\"0\">NON";
}
else {
echo "<input type=\"radio\" name=\"dispo\" value=\"1\">
<span class=\"Style13\">OUI
<input type=\"radio\" name=\"dispo\" value=\"0\" checked>NON";
}
?>
<span class="Style18"> Info Dispo:
<input type="text" name="dispo_prod" size="60" class="Style16" value="<? echo "$infoaff"; ?>">
</span></td>
</tr>
<tr>
<td bgcolor="#FFFFFF"> </td>
<td colspan="2" bgcolor="#BDD8F6"> </td>
<INPUT type="hidden" name="id" value="<? echo "$id"; ?>">
</tr>
<tr>
<td bgcolor="#FFFFFF"> </td>
<td colspan="2" bgcolor="#BDD8F6"><div align="center">
<input name="image" type="image" src="images/b_modifier.jpg">
<a href="fiche_produit.php?action=2&&id=<? echo "$id"; ?>"><img src="images/b_supprimer.jpg" border="0"></a></div></td>
</tr>
</table>
</FORM>
</body>
</html>