par
castelli » 05 déc. 2006, 15:20
Bon aprés plusieurs tentavives , je n'ai pas trop avancer
En effet , j'arrive seulement a ajouter un produit dans ma base historique
que , si j'ai selectionner "effectué "a un seul produit dans la liste deroulante "effectué" (en effet si j'en
selectionne plusieurs , les premiers produits seront oublié et seulement le
dernier sera copié dans la base de donnée)
de meme ce produit sera copié autant de fois que j'ai de produit dans ma base de données...
Je suis complemtent perdus pourriez vous m'aidez : /
Voici mon code:
$qryCmde = "SELECT * FROM commande2 WHERE groupe = '" . $rangGroupe['groupe'] . "'";
$resQryCmde = mysql_query($qryCmde,$link) or die ('Erreur : ' . mysql_error() );
$groupee = $rangGroupe['groupe'];
?>
<BR><div id="<?php echo $groupee; ?>">
<FORM method="POST" action="commande3.php">
<table border=1>
<TR bgcolor= "#CCFFCC">
<th>Nom</th><th>Référence</th><th>Quantité</th><th>Nombre d'unité</th><th>Fournisseur</th><th>Reference fournisseur</th>
<th>Prix à l'unité</th><th>Prix total</th><th>Prix avec reduction</th><th>Numero de cas</th><th>Date</th><th>initiale</th>
<th>Localisation</th><th>Commande</th>
</tr>
<?php
while($rangCmde = mysql_fetch_array($resQryCmde)){
if(isset($_POST['commande'])){
$list=$_POST['commande'];
$listnom=$_POST['tabnom'];
$listnom_cass=$_POST['tabnom_cass'];
$listref=$_POST['tabref'];
for($i=0;$i<count($list);$i++)
{
if ($list[$i]=="effectuee")
{
echo"$listnom[$i] $list[$i] <br>";
$selecta= "SELECT * from commande2 where nom like '".$listnom[$i]."'";
$resulta2 = mysql_query($selecta,$link) or die ('Erreur : '.mysql_error() );
$rangCmde2 = mysql_fetch_assoc($resulta2);
if (($rangCmde2['numero_cass'] !="") || ($rangCmde2['nom'] !="")|| ($rangCmde2['fournisseur'] !="")) {
$insertion="INSERT INTO historique VALUES ('".$rangCmde2['numero_cass']."','".$rangCmde2['fournisseur']."','".$rangCmde2['prix']."',
'".$rangCmde2['quantite']."','".$rangCmde2['nombre_quantite']."','".$rangCmde2['nom']."','".$rangCmde2['date']."','".$rangCmde2['prix_total']."',
'".$rangCmde2['initiale']."','".$rangCmde2['reference']."','".$rangCmde2['reference_fournisseur']."',
'".$rangCmde2['equipe']."','".$rangCmde2['groupe']."')";
}
$result_insertion=mysql_query($insertion,$link) or die ('Erreur : '.mysql_error() );
}
elseif ($list[$i]=="annulee")
{
$query="UPDATE produit2 SET disponibilite='annulé' where nom like '$listnom[$i]' AND reference = '".$listref[$i]."'";
$result=mysql_query($query,$link) or die ('Erreur : '.mysql_error() );
echo"$listnom[$i] $list[$i] <br>";
}
if (($list[$i]=="effectuee")||($list[$i]=="annulee"))
{
$rqSql= "DELETE FROM commande2 WHERE nom='".$listnom[$i]."' AND numero_cass = '".$listnom_cass[$i]."'";
$result3 = mysql_query( $rqSql, $link) or die( "Suppression impossible.");
echo $rqSql;
}
}
}
?>
<tr>
<td><font face='Verdana' size='2'><?php echo $rangCmde['nom']; ?></font></td>
<td><font face='Verdana' size='2'><?php echo $rangCmde['reference']; ?></font></td>
<td><font face='Verdana' size='2'><?php echo $rangCmde['quantite']; ?></font></td>
<td><font face='Verdana' size='2'><?php echo $rangCmde['nombre_quantite']; ?></font></td>
<td><font face='Verdana' size='2'><?php echo $rangCmde['fournisseur']; ?></font></td>
<td><font face='Verdana' size='2'><?php echo $rangCmde['reference_fournisseur']; ?></font></td>
<td><font face='Verdana' size='2'><?php echo $prix2; ?></font></td>
<td><font face='Verdana' size='2'><?php echo $prix_total2; ?></font></td>
<td><font face='Verdana' size='2'><?php echo $reduction2; ?> </font></td>
<td><font face='Verdana' size='2'><?php echo $rangCmde['numero_cass']; ?></font></td>
<td><font face='Verdana' size='2'><?php echo $rangCmde['date']; ?></font></td>
<td><font face='Verdana' size='2'><?php echo $rangCmde['initiale']; ?></font></td>
<td><font face='Verdana' size='2'><?php echo $voirreqloc['localisation']; ?></font></td>
<td class="truc"><font face='Verdana' size='2'>
<div style="text-align:left;">
<select name="commande[]">
<option value="rien"></option>
<option value="effectuee">Effectuée</option>
<option value="annulee">Annulée</option>
</select>
<input type="hidden" name="tabnom[]" value="<?php echo $rangCmde['nom']; ?>" />
<input type="hidden" name="tabnom_cass[]" value="<?php echo $rangCmde['numero_cass']; ?>" />
<input type="hidden" name="tabref[]" value="<?php echo $rangCmde['reference']; ?>" />
</div>
</font>
</td>
</tr>
<?php
}
?>
<tr>
<td colspan=14>
<center>
<input type="submit" value="Valider" />
<input type="button" value="Imprimer" onclick="imprime_zone('commande','<?php echo $groupee; ?>');">
<input type="submit" value="Fermer" onClick="window.close()" />
<center>
</td>
</tr>
</table>
</form></div id="<?php echo $groupee; ?>">
ps: pour rappel cette page contient un tableau ou sont stocké toute les commandes , a droite de chaque ligne il y a une liste deroulante
ou on peut selectionner "","effectué","annuler"
puis a la fin on valide , si on a selectionner effectué sur plusieur produit , c'est dernier sont effacer
de la table commande est ajouter a la table historique , si on met annuler , ils sont totalement effacer de la table commande ,
si on ne fais rien les produit restent comme tels
evidement on peut avoir des produit ou on a selectionner annuler , d'autre effectué etc...
Bon aprés plusieurs tentavives , je n'ai pas trop avancer
En effet , j'arrive seulement a ajouter un produit dans ma base historique
que , si j'ai selectionner "effectué "a un seul produit dans la liste deroulante "effectué" (en effet si j'en
selectionne plusieurs , les premiers produits seront oublié et seulement le
dernier sera copié dans la base de donnée)
de meme ce produit sera copié autant de fois que j'ai de produit dans ma base de données...
Je suis complemtent perdus pourriez vous m'aidez : /
Voici mon code:
[php] $qryCmde = "SELECT * FROM commande2 WHERE groupe = '" . $rangGroupe['groupe'] . "'";
$resQryCmde = mysql_query($qryCmde,$link) or die ('Erreur : ' . mysql_error() );
$groupee = $rangGroupe['groupe'];
?>
<BR><div id="<?php echo $groupee; ?>">
<FORM method="POST" action="commande3.php">
<table border=1>
<TR bgcolor= "#CCFFCC">
<th>Nom</th><th>Référence</th><th>Quantité</th><th>Nombre d'unité</th><th>Fournisseur</th><th>Reference fournisseur</th>
<th>Prix à l'unité</th><th>Prix total</th><th>Prix avec reduction</th><th>Numero de cas</th><th>Date</th><th>initiale</th>
<th>Localisation</th><th>Commande</th>
</tr>
<?php
while($rangCmde = mysql_fetch_array($resQryCmde)){
if(isset($_POST['commande'])){
$list=$_POST['commande'];
$listnom=$_POST['tabnom'];
$listnom_cass=$_POST['tabnom_cass'];
$listref=$_POST['tabref'];
for($i=0;$i<count($list);$i++)
{
if ($list[$i]=="effectuee")
{
echo"$listnom[$i] $list[$i] <br>";
$selecta= "SELECT * from commande2 where nom like '".$listnom[$i]."'";
$resulta2 = mysql_query($selecta,$link) or die ('Erreur : '.mysql_error() );
$rangCmde2 = mysql_fetch_assoc($resulta2);
if (($rangCmde2['numero_cass'] !="") || ($rangCmde2['nom'] !="")|| ($rangCmde2['fournisseur'] !="")) {
$insertion="INSERT INTO historique VALUES ('".$rangCmde2['numero_cass']."','".$rangCmde2['fournisseur']."','".$rangCmde2['prix']."',
'".$rangCmde2['quantite']."','".$rangCmde2['nombre_quantite']."','".$rangCmde2['nom']."','".$rangCmde2['date']."','".$rangCmde2['prix_total']."',
'".$rangCmde2['initiale']."','".$rangCmde2['reference']."','".$rangCmde2['reference_fournisseur']."',
'".$rangCmde2['equipe']."','".$rangCmde2['groupe']."')";
}
$result_insertion=mysql_query($insertion,$link) or die ('Erreur : '.mysql_error() );
}
elseif ($list[$i]=="annulee")
{
$query="UPDATE produit2 SET disponibilite='annulé' where nom like '$listnom[$i]' AND reference = '".$listref[$i]."'";
$result=mysql_query($query,$link) or die ('Erreur : '.mysql_error() );
echo"$listnom[$i] $list[$i] <br>";
}
if (($list[$i]=="effectuee")||($list[$i]=="annulee"))
{
$rqSql= "DELETE FROM commande2 WHERE nom='".$listnom[$i]."' AND numero_cass = '".$listnom_cass[$i]."'";
$result3 = mysql_query( $rqSql, $link) or die( "Suppression impossible.");
echo $rqSql;
}
}
}
?>
<tr>
<td><font face='Verdana' size='2'><?php echo $rangCmde['nom']; ?></font></td>
<td><font face='Verdana' size='2'><?php echo $rangCmde['reference']; ?></font></td>
<td><font face='Verdana' size='2'><?php echo $rangCmde['quantite']; ?></font></td>
<td><font face='Verdana' size='2'><?php echo $rangCmde['nombre_quantite']; ?></font></td>
<td><font face='Verdana' size='2'><?php echo $rangCmde['fournisseur']; ?></font></td>
<td><font face='Verdana' size='2'><?php echo $rangCmde['reference_fournisseur']; ?></font></td>
<td><font face='Verdana' size='2'><?php echo $prix2; ?></font></td>
<td><font face='Verdana' size='2'><?php echo $prix_total2; ?></font></td>
<td><font face='Verdana' size='2'><?php echo $reduction2; ?> </font></td>
<td><font face='Verdana' size='2'><?php echo $rangCmde['numero_cass']; ?></font></td>
<td><font face='Verdana' size='2'><?php echo $rangCmde['date']; ?></font></td>
<td><font face='Verdana' size='2'><?php echo $rangCmde['initiale']; ?></font></td>
<td><font face='Verdana' size='2'><?php echo $voirreqloc['localisation']; ?></font></td>
<td class="truc"><font face='Verdana' size='2'>
<div style="text-align:left;">
<select name="commande[]">
<option value="rien"></option>
<option value="effectuee">Effectuée</option>
<option value="annulee">Annulée</option>
</select>
<input type="hidden" name="tabnom[]" value="<?php echo $rangCmde['nom']; ?>" />
<input type="hidden" name="tabnom_cass[]" value="<?php echo $rangCmde['numero_cass']; ?>" />
<input type="hidden" name="tabref[]" value="<?php echo $rangCmde['reference']; ?>" />
</div>
</font>
</td>
</tr>
<?php
}
?>
<tr>
<td colspan=14>
<center>
<input type="submit" value="Valider" />
<input type="button" value="Imprimer" onclick="imprime_zone('commande','<?php echo $groupee; ?>');">
<input type="submit" value="Fermer" onClick="window.close()" />
<center>
</td>
</tr>
</table>
</form></div id="<?php echo $groupee; ?>">[/php]
ps: pour rappel cette page contient un tableau ou sont stocké toute les commandes , a droite de chaque ligne il y a une liste deroulante
ou on peut selectionner "","effectué","annuler"
puis a la fin on valide , si on a selectionner effectué sur plusieur produit , c'est dernier sont effacer
de la table commande est ajouter a la table historique , si on met annuler , ils sont totalement effacer de la table commande ,
si on ne fais rien les produit restent comme tels
evidement on peut avoir des produit ou on a selectionner annuler , d'autre effectué etc...