Bonjour,
Il y a quelques années, à la demande de mon mari, j'ai fait une base de donnée pour lui permettre de gérer sa cave à vin. Il avait essayé plusieurs logiciels mais aucun ne correspondait exactement à ce qu'il voulait.
Actuellement, j'ai quelques idées d'améliorations, mais il y a une chose que je ne sais pas comment faire.
J'ai un tableau répertoriant les achats et sur chaque ligne il faut cliquer sur un bouton pour afficher un formulaire permettant de modifier le stock restant. Cela fonctionne très bien mais il me semble qu'il serait plus simple de modifier le champs "sortie" directement dans le tableau. Mais je ne sais pas commeng m'y prendre.
Si quelqu'un a une idée, elle est la bienvenue.
Voici le code de ce formulaire contenant le tableau :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<?php
include("include/variables.inc.php");
include("menu.php");
$liendb  =  mysql_connect($bddserver,  $bddlogin,  $bddpassword);
mysql_select_db  ($bdd);
?>
<link rel="stylesheet" href="menu/dropdown_three.css" type="text/css">
<link rel="stylesheet" href="style.css" type="text/css">
<table border="1" align="center">
        <tr>
            <th  class="intitule" style="background-color: #FF0000; color:white"><big><b>&nbsp;&nbsp;Les vin rouges&nbsp;&nbsp;</b></big></th>
            <th  class="intitule" style="background-color: #ffffff"><big><b>&nbsp;&nbsp;Les vin blancs&nbsp;&nbsp;</b></big></th>
            <th  class="intitule" style="background-color: #ffcccc"><big><b>&nbsp;&nbsp;Les vin rosés&nbsp;&nbsp;</b></big></th>
            <th  class="intitule" style="background-color: #ffff99"><big><b>&nbsp;&nbsp;Les vin mousseux&nbsp;&nbsp;</b></big></th>
	</tr>
</table>
<table border="1" align="center">
        <tr>
            <th  class="intitule" style="background-color: #ADFF2F"><big><b>&nbsp;&nbsp;Les vin de 10 à 20 ans&nbsp;&nbsp;</b></big></th>
            <th  class="intitule" style="background-color: #ff33cc; color:white"><big><b>&nbsp;&nbsp;Les vin de plus de 20 ans&nbsp;&nbsp;</b></big></th>
        </tr>
</table>
<table border="1" align="center">
        <tr>
            <th  class="intitule"><big><b>&nbsp;&nbsp;Bouteilles en stock&nbsp;&nbsp;</b></big></th>
	</tr>
<tr>
                <td><center>
<big><b>
<?php
$requete = mysql_query("SELECT SUM((entree)-(sortie)) FROM mouvements");
$somme = number_format(mysql_result($requete, 0));
echo $somme;
?>
</b></big></center>
</td>
 
</tr>	
    </table>	
<p  align="left">  ::  Stock</p>
<table class="bicolor" border="1" width="90%"  align="center">
  <tr>
    <th  class="intitule">Vin</th>
    <th  class="intitule">Producteur</th>
    <th  class="intitule"><center>Couleur</center></th>
    <th  class="intitule"><center>Mousseux</center></th>
    <th  class="intitule">Date achat</th>
    <th  class="intitule">Qté achetée</th>
    <th  class="intitule">Entrée</th>
    <th  class="intitule">Sortie</th>
    <th  class="intitule">Année</th>
    <th  class="intitule">Début optimum</th>
    <th  class="intitule">Fin optimum</th>
    <th  class="intitule">Age</th>
    <th  class="intitule">Taille bouteille</th>
    <th  class="intitule">Prix d'achat</th>
    <th  class="intitule">Notes</th>
    <th  class="intitule">Quantité en stock</th>
    <th  class="intitule">Valeur stock</th>
    <th  class="intitule">&nbsp;</th>		
  </tr>
<?php
$sql  =  "SELECT idmvt, date_mvt, mouvements.idvin, date_mvt, quantite_mvt, YEAR(NOW()) - annee_vin as AGE, entree, sortie, annee_vin, debut_optimum, fin_optimum, taille_btl, vins.nom_vin, vins.mousseux, couleurs.couleur, prix_achat, notes, (mouvements.entree-mouvements.sortie) as STOCK, (quantite_mvt*prix_achat) as PT, ((quantite_mvt-sortie)*prix_achat) as PSTOCK, vins.idproducteur, producteurs.nom_producteur
FROM mouvements
INNER JOIN vins
ON mouvements.idvin = vins.idvin
INNER JOIN couleurs
ON vins.idcouleur = couleurs.idcouleur
INNER JOIN producteurs
ON vins.idproducteur = producteurs.idproducteur

ORDER BY producteurs.nom_producteur ASC, nom_vin, annee_vin ASC";
 
$resultat  =  mysql_query  ($sql);
$resultat = mysql_query($sql) or die(mysql_error()); 
 
while  ($mouvements = mysql_fetch_array  ($resultat)){
    $id  =  $mouvements['idmvt'];
    $nom_vin  =  $mouvements['nom_vin'];
    $nom_producteur  =  $mouvements['nom_producteur'];
    $couleur = $mouvements['couleur'];		
    $mousseux  =  $mouvements['mousseux'];		
    $date_mvt  =  $mouvements['date_mvt'];
    $quantite_mvt  =  $mouvements['quantite_mvt'];
    $entree  =  $mouvements['entree'];
    $sortie  =  $mouvements['sortie'];
    $annee_vin  =  $mouvements['annee_vin'];
    $debut_optimum  =  $mouvements['debut_optimum'];		
    $fin_optimum  =  $mouvements['fin_optimum'];
    $AGE  =  $mouvements['AGE'];
    $taille_btl  =  $mouvements['taille_btl'];
    $prix_achat  =  $mouvements['prix_achat'];
    $notes  =  $mouvements['notes'];
    $STOCK  =  $mouvements['STOCK'];
    $PSTOCK  =  $mouvements['PSTOCK'];
    echo  "<tr>";
    echo  "<td><div align='left'>$nom_vin</div></td>";
    echo  "<td><div align='left'>$nom_producteur</div></td>";
if ($mouvements['couleur'] == 'Rouge'){
echo '<td style="background-color: #FF0000; color:white">';
echo $mouvements['couleur'];
 
} else if ($mouvements['couleur'] == 'Rosé'){
echo '<td style="background-color: #ffcccc">';
echo $mouvements['couleur'];
 
} else if ($mouvements['couleur'] == 'Blanc'){
echo '<td style="background-color: #ffffff">';
echo $mouvements['couleur'];
 
} else {
echo '<td>';
echo $mouvements['couleur'];
}
 
if ($mouvements['mousseux'] == 'oui'){
echo '<td style="background-color: #ffff99">';
echo $mouvements['mousseux'];
 
} else if ($mouvements['mousseux'] == 'non'){
echo '<td style="background-color: #ffffff">';
echo $mouvements['mousseux'];
 
} else {
echo '<td>';
echo $mouvements['mousseux'];
}
 
    echo  "<td>$date_mvt</td>";		
    echo  "<td>$quantite_mvt</td>";
    echo  "<td>$entree</td>";
    echo  "<td>$sortie</td>";
    echo  "<td>$annee_vin</td>";
    echo  "<td>$debut_optimum</td>";
    echo  "<td>$fin_optimum</td>";
 
if ($mouvements['AGE'] >= '10' && $mouvements['AGE'] <'20'){
echo '<td style="background-color: #ADFF2F">';
echo $mouvements['AGE'];
 
} else if ($mouvements['AGE'] >= '20'){
echo '<td style="background-color: #ff33cc; color:white">';
echo $mouvements['AGE'];
 
} else {
echo '<td>';
echo $mouvements['AGE'];
}
		echo  "<td>$taille_btl</td>";
		echo  "<td>$prix_achat</td>";
		echo  "<td>$notes</td>";
 
if ($mouvements['STOCK'] == '0'){
echo '<td style="background-color: #ff0000; color:white">';
echo $mouvements['STOCK'];
 
} else if ($mouvements['STOCK'] >= '1'){
echo '<td style="background-color: #ffffff">';
echo $mouvements['STOCK'];
 
} else {
echo '<td>';
echo $mouvements['STOCK'];
}
    echo  "<td>$PSTOCK</td>";
    echo  "<td>";
    echo  "<a  href=mvt_edite.php?id=$id>Editer</a>";
    echo  "</td>";
    echo  "</tr>";
}
echo  "</table>";
?>
<?php
mysql_close($liendb);
?>
c'est le champs 'sortie' ci-dessous que j'aimerais pouvoir modifier, en ajoutant un champs temporaire permettant d'entrer le nombre de bouteilles sorties

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
$sql  =  "SELECT idmvt, date_mvt, mouvements.idvin, date_mvt, quantite_mvt, YEAR(NOW()) - annee_vin as AGE, entree, sortie, annee_vin, debut_optimum, fin_optimum, taille_btl, vins.nom_vin, vins.mousseux, couleurs.couleur, prix_achat, notes, (mouvements.entree-mouvements.sortie) as STOCK, (quantite_mvt*prix_achat) as PT, ((quantite_mvt-sortie)*prix_achat) as PSTOCK, vins.idproducteur, producteurs.nom_producteur
FROM mouvements
INNER JOIN vins
ON mouvements.idvin = vins.idvin
INNER JOIN couleurs
ON vins.idcouleur = couleurs.idcouleur
INNER JOIN producteurs
ON vins.idproducteur = producteurs.idproducteur
 
ORDER BY producteurs.nom_producteur ASC, nom_vin, annee_vin ASC";
 
$resultat  =  mysql_query  ($sql);
Merci à tous pour votre aide et bonne journée