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
|
<?php
include('../include/session.php');
include('../include/connexion.php');
$link = connexion();
//récupère tous les enregistrements
$description = '';
$keywords = '';
$subject = '';
$title = '';
$fakea = '';
$menu = true;
//-----------------------------------------------------
// Vérification 1 : est-ce qu'on veut poster une cartouche ?
//-----------------------------------------------------
if (!empty($_POST['ref_cartouche']) AND !empty($_POST['designation_cartouche']) AND !empty($_POST['couleur_cartouche']) AND !empty($_POST['qte_cartouche']) AND !empty($_POST['prixTTC_cartouche']))
{
$ref_cartouche = addslashes($_POST['ref_cartouche']);
$designation_cartouche =addslashes ($_POST['designation_cartouche']);
$couleur_cartouche = addslashes($_POST['couleur_cartouche']);
$qte_cartouche =addslashes($_POST['qte_cartouche']);
$prixTTC_cartouche = addslashes($_POST['prixTTC_cartouche']);
echo "UPDATE cartouche
SET designation_cartouche='" . $designation_cartouche . "'
, couleur_cartouche='" . $couleur_cartouche . "'
, qte_cartouche=" . $qte_cartouche . "
, prixTTC_cartouche=" . $prixTTC_cartouche . "
WHERE ref_cartouche='" . $_POST['id_cartouche'] . "'";
// On vérifie si c'est une modification de cartouche ou pas
if (empty($_GET['modification_cartouche']))
{
// Ce n'est pas une modification, on crée une nouvelle entrée dans la table
mysql_query("INSERT INTO cartouche VALUES('" . $ref_cartouche . "', '" . $designation_cartouche . "', '" . $couleur_cartouche . "',, '" . $qte_cartouche . "',, '" . $prixTTC_cartouche . "')");
}
else
{
// C'est une modification, on met juste à jour le titre et le contenu
echo "UPDATE cartouche
SET designation_cartouche='" . $designation_cartouche . "'
, couleur_cartouche='" . $couleur_cartouche . "'
, qte_cartouche='" . $qte_cartouche . "'
, prixTTC_cartouche='" . $prixTTC_cartouche . "'
WHERE ref_cartouche='" . $_POST['id_cartouche'] . "'";
}
}
//--------------------------------------------------------
// Vérification 2 : est-ce qu'on veut supprimer une cartouche ?
//--------------------------------------------------------
if (isset($_GET['supprimer_cartouche'])) // Si on demande de supprimer une cartouche
{
// Alors on supprime la cartouche correspondante
$_GET['supprimer_cartouche'] = htmlentities($_GET['supprimer_cartouche']);
mysql_query('DELETE FROM cartouche WHERE ref_cartouche=\'' . $_GET['supprimer_cartouche'] . '\'');
}
// Constuction du tableau
$body = '<table><thead><tr>
<th>Modifier</th>
<th>Supprimer</th>
<th>reference</th>
<th>Designation</th>
<th>couleur</th>
<th>quantité</th>
<th>prix TTC</th>
</tr></thead><tbody>';
$retour = mysql_query('SELECT * FROM cartouche ORDER BY ref_cartouche DESC');
while ($donnees = mysql_fetch_array($retour)) // On fait une boucle pour lister les cartouche
{
$body .= '<tr>';
$body .= '<td><a href="ajout_cartouche.php?modifier_cartouche=' . $donnees['ref_cartouche'] . '">Modifier</a></td>';
$body .= '<td><a href="interface.php?supprimer_cartouche=' . $donnees['ref_cartouche'] . '">Supprimer</a></td>';
$body .= '<td>' . $donnees['ref_cartouche'] . '</td>';
$body .= '<td>' . $donnees['designation_cartouche'] . '</td>';
$body .= '<td>' . $donnees['couleur_cartouche'] . '</td>';
$body .= '<td>' . $donnees['qte_cartouche'] . '</td>';
$body .= '<td>' . $donnees['prixTTC_cartouche'] . '</td>';
$body .= '</tr>';
}
$body .= '</tbody></table>';
?>
<html>
<head>
<title></title>
</head>
<body>
<h2><a href="index.php?page=ajout_cartouche.php" title="Admin">Ajouter des cartouches</a></h2>
<?php echo $table; ?>
</body>
</html>
<?php
include('../include/base.php');
?> |
Partager