340 lines
8.9 KiB
PHP
Executable File
340 lines
8.9 KiB
PHP
Executable File
<?php
|
|
session_start();
|
|
$loguer=$HTTP_GET_VARS["loguer"];
|
|
$idfamille=$HTTP_GET_VARS["idfamille"];
|
|
$retour=$idfamille;
|
|
$idcateg=$HTTP_GET_VARS["idcateg"];
|
|
$idprod=$HTTP_GET_VARS["idprod"];
|
|
$nomcateg=$HTTP_GET_VARS["nomcateg"];
|
|
$action=$HTTP_GET_VARS["action"];
|
|
$nomfamille=$HTTP_GET_VARS["nomfamille"];
|
|
print "idfamille : $idfamille";
|
|
$retour=$idfamille;
|
|
?>
|
|
<html>
|
|
<head>
|
|
<title>Partie Administrateur</title>
|
|
</head>
|
|
<body>
|
|
<?php
|
|
if (isset($_SESSION['idadm']))
|
|
{
|
|
?>
|
|
<div align="center">
|
|
<table border=0>
|
|
<tr>
|
|
<td colspan=2 align="center">
|
|
<br><br><h1>Gestion des produits</h1>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<?php
|
|
require("../connexion.php");
|
|
$conn = mysql_connect($host, $user, $password);
|
|
mysql_select_db($bdd) or die("Impossible d'ouvrir la base de donnee $bdd");
|
|
|
|
if ($loguer)
|
|
{
|
|
|
|
$requete1 = "select idprod,refprod,denomination,description,location,delailivraison,prixht1,pathpdfdocument,pathphotobassedef,pathphotohautedef,idfamille,qteprod1,poidsprod1,qteprod2,prixht2,poidsprod2,qteprod3,prixht3,poidsprod3,coef from produit where idprod='$idprod'";
|
|
$result1=mysql_query($requete1) or die ("Erreur SQL :$requete<br>".mysql_error()."...");
|
|
|
|
while ($ligne=mysql_fetch_row($result1))
|
|
{
|
|
$refprod=$ligne[1];
|
|
$denomination=$ligne[2];
|
|
$description=$ligne[3];
|
|
$location=$ligne[4];
|
|
$delailivraison=$ligne[5];
|
|
$prixht1=$ligne[6];
|
|
$pathpdfdocument=$ligne[7];
|
|
$pathphotobassedef=$ligne[8];
|
|
$pathphotohautedef=$ligne[9];
|
|
$idfamille=$ligne[10];
|
|
$qteprod1=$ligne[11];
|
|
$poidsprod1=$ligne[12];
|
|
$qteprod2=$ligne[13];
|
|
$prixht2=$ligne[14];
|
|
$poidsprod2=$ligne[15];
|
|
$qteprod3=$ligne[16];
|
|
$prixht3=$ligne[17];
|
|
$poidsprod3=$ligne[18];
|
|
$coef=$ligne[19];
|
|
}
|
|
$idfamille=$oldid;
|
|
|
|
// requete de récupéaration des prix du produit + incrémentation d'un compteur pour savoir le nombre de prix
|
|
$requete2 = "select idprix,prix,marge,qteprod from prix where idprod='$idprod'";
|
|
$result2=mysql_query($requete2) or die ("Erreur SQL :$requete2<br>".mysql_error()."...");
|
|
$i=0;
|
|
while ($ligne1 = mysql_fetch_row($result2))
|
|
{
|
|
$idprix[$i]=$ligne1[0];
|
|
$testprix[$i]=$ligne1[1];
|
|
$marge[$i]=$ligne1[2];
|
|
$qteprod[$i]=$ligne1[3];
|
|
print "qteprod : $qteprod[$i]";
|
|
//ici on teste marge : si le champsr est renseigné alors le prix est u ne URL
|
|
if ($marge[$i])
|
|
{
|
|
$prix[$i]="http://crossover.codeweavers.com/vendor_price_query.php?user=tallagrand@airtria.fr;sku=".$testprix[$i];
|
|
$hwnd=fopen($prix[$i],"r");
|
|
$prix[$i] = fread($hwnd, 100);
|
|
fclose($hwnd);
|
|
$prix[$i] = ($prix[$i] + ($prix[$i] * $marge[$i] / 100));
|
|
} else {
|
|
$prix[$i] = $testprix[$i];
|
|
}
|
|
$i++;
|
|
}
|
|
$i--;
|
|
$nbprix=$i;
|
|
?>
|
|
<form name="f1" action="modifprod.php" method="POST">
|
|
<table>
|
|
<tr align='left'>
|
|
<td>
|
|
<input type="hidden" name="nbprix" value="<?php print $nbprix?>"/>
|
|
Denomination :
|
|
</td>
|
|
<td>
|
|
<input type="text" name="denomination" value="<?php print $denomination?>"/>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
Description :
|
|
</td>
|
|
<td>
|
|
<textarea name="description" cols=25 rows=5><?php print $description?></textarea>
|
|
</td>
|
|
</tr>
|
|
<tr align='left'>
|
|
<td>
|
|
Location :
|
|
</td>
|
|
<td>
|
|
<input type="text" name="location" value="<?php print $location?>"/>
|
|
</td>
|
|
</tr>
|
|
<tr align='left'>
|
|
<td>
|
|
Refprod :
|
|
</td>
|
|
<td>
|
|
<input type="text" name="refprod" value="<?php print $refprod?>"/>
|
|
</td>
|
|
</tr>
|
|
<tr align='left'>
|
|
<td>
|
|
delailivraison :
|
|
</td>
|
|
<td>
|
|
<input type="text" name="delailivraison" value="<?php print $delailivraison?>"/>
|
|
</td>
|
|
</tr>
|
|
<tr align='left'>
|
|
<td>
|
|
Coef :
|
|
</td>
|
|
<td>
|
|
<input type="text" name="coef" value="<?php print $coef?>"/>
|
|
</td>
|
|
</tr>
|
|
<tr align='left'>
|
|
<td>
|
|
pathpdfdocument :
|
|
</td>
|
|
<td>
|
|
<input type="text" name="pathpdfdocument" value="<?php print $pathpdfdocument?>"/>
|
|
</td>
|
|
</tr>
|
|
<tr align='left'>
|
|
<td>
|
|
pathphotobassedef :
|
|
</td>
|
|
<td>
|
|
<input type="text" name="pathphotobassedef" value="<?php print $pathphotobassedef?>"/>
|
|
</td>
|
|
</tr>
|
|
<tr align='left'>
|
|
<td>
|
|
pathphotohautedef :
|
|
</td>
|
|
<td>
|
|
<input type="text" name="pathphotohautedef" value="<?php print $pathphotohautedef?>"/>
|
|
</td>
|
|
</tr>
|
|
<tr align='center'>
|
|
<td colspan=2>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td align=right>
|
|
Famille
|
|
</td>
|
|
<td>
|
|
<select name="idfamille">
|
|
<?php
|
|
$requete2 = "select idfamille,nomfamille from famille";
|
|
$result2=mysql_query($requete2) or die ("Erreur SQL :$requete<br>".mysql_error()."...");
|
|
|
|
while ($ligne=mysql_fetch_row($result2))
|
|
{
|
|
$idf=$ligne[0];
|
|
$nomfamille=$ligne[1];
|
|
|
|
if ($idf==$oldid)
|
|
{
|
|
?>
|
|
<option value="<?php print $idfamille?>" selected="selected"><?php print $nomfamille?></option>
|
|
<?php
|
|
} else {
|
|
?>
|
|
<option value="<?php print $idf?>"><?php print $nomfamille?></option>
|
|
<?php
|
|
}
|
|
}
|
|
?>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan=2>
|
|
<?php print "idfamille : $retour";?>
|
|
<input type="hidden" name="<?php print session_name()?>" value="<?php print session_id()?>"/>
|
|
<input type="hidden" name="idcateg" value="<?php print $idcateg?>"/>
|
|
<input type="hidden" name="idfamille" value="<?php print $retour?>"/>
|
|
<input type="hidden" name="idprod" value="<?php print $idprod?>"/>
|
|
<input type="hidden" name="action" value="modif"/>
|
|
<input type="hidden" name="loguer" value="oui"/>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan=2 align=center>
|
|
<input type="submit" value="Modifier"/>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</form>
|
|
<?php
|
|
// Affichage des prix
|
|
for ($j=0;$j<=$nbprix;$j++)
|
|
{
|
|
?>
|
|
<br>
|
|
<form name="modifprix" action="updateprix.php" method="post">
|
|
<table border=1>
|
|
<tr align=center>
|
|
<td>
|
|
Prix pour <?php print $qteprod[$j] ?> produit(s) : <?php print $prix[$j]?>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan=2>
|
|
Qte prod
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan=2>
|
|
<input type="text" name="qteprod" size=5 value="<?php print $qteprod[$j]?>"/>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan=2>
|
|
prix
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan=2>
|
|
<input type="text" name="prix" size=100 value="<?php print $testprix[$j]?>"/>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan=2>
|
|
Marge (si prix = URL (dynamique))
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan=2>
|
|
<input type="text" name="marge" value="<?php print $marge[$j]?>"/>
|
|
</td>
|
|
</tr>
|
|
<tr><td align="center">
|
|
<input type="hidden" name="loguer" value="oui"/>
|
|
<input type="hidden" name="idcateg" value="<?php print $idcateg?>"/>
|
|
<input type="hidden" name="idfamille" value="<?php print $retour?>"/>
|
|
<input type="hidden" name="idprix" value="<?php print $idprix[$j]?>"/>
|
|
<input type="hidden" name="idprod" value="<?php print $idprod?>"/>
|
|
<input type="hidden" name="loguer" value="ok"/>
|
|
<input type="submit" value="modifier"/>
|
|
</form>
|
|
|
|
<form name="modifprix" action="updateprix.php" method="post">
|
|
<input type="hidden" name="loguer" value="oui"/>
|
|
<input type="hidden" name="idcateg" value="<?php print $idcateg?>"/>
|
|
<input type="hidden" name="idfamille" value="<?php print $retour?>"/>
|
|
<input type="hidden" name="idprix" value="<?php print $idprix[$j]?>"/>
|
|
<input type="hidden" name="idprod" value="<?php print $idprod?>"/>
|
|
<input type="hidden" name="action" value="supprimer"/>
|
|
<input type="hidden" name="loguer" value="ok"/>
|
|
<input type="submit" value="Supprimer"/>
|
|
</form>
|
|
<td>
|
|
</tr>
|
|
</table>
|
|
<?php
|
|
}
|
|
?>
|
|
<table align="center">
|
|
<form name="ajoutprix" action="ajoutprix.php" method="post">
|
|
<tr>
|
|
<td>
|
|
Ajouter un prix a ce produit
|
|
<input type="hidden" name="idprod" value="<?php print $idprod ?>"/>
|
|
<input type="hidden" name="idcateg" value="<?php print $idcateg?>"/>
|
|
<input type="hidden" name="idfamille" value="<?php print $retour?>"/>
|
|
<input type="hidden" name="action" value="modif"/>
|
|
<input type="hidden" name="loguer" value="oui"/>
|
|
<br>
|
|
</td>
|
|
<td>
|
|
<input type="submit" value="ok"/>
|
|
</td>
|
|
</tr>
|
|
</form>
|
|
</table>
|
|
|
|
<?php
|
|
} else {
|
|
?>
|
|
<tr><td colspan=4><a href="login.php">Une erreure s'est produite veuillez vous reconnecter</a></td></tr>
|
|
<?php
|
|
session_destroy("loguer");
|
|
}
|
|
?>
|
|
<?php
|
|
if ($loguer)
|
|
{
|
|
?>
|
|
<br><a href="famille.php?loguer=oui&idfamille=<?php print $retour?>&idcateg=<?php print $idcateg ?>&<?php print session_name();?>=<?php print session_id();?>">Retour</a>
|
|
|
|
<?php
|
|
} else {
|
|
?>
|
|
<br><a href="../index.php?<?php print session_name();?>=<?php print session_id();?>">Retour</a>
|
|
<?php
|
|
}
|
|
?>
|
|
</div>
|
|
<?php
|
|
}
|
|
else
|
|
{
|
|
print "Erreur de connection";
|
|
}
|
|
?>
|
|
|
|
</body>
|
|
</html>
|