0byt3m1n1
Path:
/
home
/
kassiope
/
www
/
administrer
/
[
Home
]
File: paiement.php
<? include("../configuration.inc.php"); necessite_identification(); necessite_priv("admin"); $DOC_TITLE = "Gestion des types de paiement"; include("modeles/haut.php"); $start = vn($_REQUEST['start']);// Détermine la variable start (début de page) switch (vb($_REQUEST['mode'])) { case "ajout" : affiche_formulaire_ajout_paiement(); break; case "modif" : affiche_formulaire_modif_paiement($_GET['id']); break; case "suppr" : supprime_paiement($_GET['id']); affiche_liste_paiement($start); break; case "insere" : insere_paiement($_POST['id'], $_POST); affiche_liste_paiement($start); break; case "maj" : maj_paiement($_POST['id'], $_POST); affiche_liste_paiement($start); break; default : affiche_liste_paiement($start); break; } include("modeles/bas.php"); /****************************************************************************** * FONCTIONS *****************************************************************************/ function affiche_formulaire_ajout_paiement() { /* Affiche un formulaire vierge pour ajouter un paiement */ global $frm; /* Valeurs par défaut */ $frm['nouveau_mode'] = "insere"; $frm['id'] = ""; foreach ($_SESSION['lng'] as $lng) { $frm['nom_'.$lng.''] = ""; } $frm['position'] = ""; $frm['tarif'] = ""; $frm['titre_bouton'] = "Ajouter un type de paiement"; affiche_formulaire_paiement(); } function affiche_formulaire_modif_paiement($id) { /* Affiche le formulaire de modification pour le paiement sélectionné */ global $frm; /* Charge les informations du produit */ $qid = mysql_query_override(" SELECT * FROM gaia_paiement WHERE id = $id "); $frm = mysql_fetch_array_override($qid); $frm["nouveau_mode"] = "maj"; $frm["titre_bouton"] = "Sauvegarder changements"; affiche_formulaire_paiement(); } function affiche_formulaire_paiement() { GLOBAL $frm,$wwwroot; ?> <form name="entryform" method="post" action="<?=$_SERVER['PHP_SELF']?>?start=0"> <input type="hidden" name="mode" value="<?=$frm["nouveau_mode"]?>"> <input type="hidden" name="id" value="<?=$frm['id']?>"> <table class="tablespace" border=0"" width="100%" cellpadding="0" cellspacing="0"> <tr> <th class="entete" colspan="2">Ajouter ou modifier un type de paiement</th> </tr> <?php foreach ($_SESSION['lng'] as $lng) { ?> <tr><td colspan="2" class="menu">BLOC DE LANGUE <?echo strtoupper($lng) ?></td><tr> <tr> <td class="">Nom <?echo $lng ?>:</td> <td class=""><input style="width:460px" class="" type="text" name="nom_<?echo $lng ?>" value="<?=$frm['nom_'.$lng.''] ?>"></td> </tr> <? } ?> <tr> <td class="">Ordre de proposition :</td> <td><input class="form-control" type="text" name="position" value="<?=$frm["position"] ?>"></td> </tr> <tr> <td colspan="2" class="bouton" align="center"><input class="bouton" type="submit" value="<?=$frm["titre_bouton"] ?>"></td> </tr> </table> </form> <? } function supprime_paiement($id) { /* Supprime le paiement spécificié par $id. Il faut supprimer le paiement * puis les entrées correspondantes de la table paiement_categories. */ $qid = mysql_query_override(" SELECT * FROM gaia_paiement WHERE id = $id "); $p = mysql_fetch_array_override($qid); /* Efface le paiement */ $qid = mysql_query_override("DELETE FROM gaia_paiement WHERE id = $id"); /* Efface ce paiement de la table produits_paiement */ $qid = mysql_query_override(" DELETE FROM gaia_produits_paiements WHERE paiement_id = $id"); ?> <p class=normal> Le paiement <b><? echo stripslashes($p['nom_'.$_SESSION['langue'].'']) ?></b> a été effacé. <? } function insere_paiement($id, $frm) { /*ajoute le paiement dans la table paiement */ $sql = "INSERT INTO gaia_paiement (position, priv"; foreach ($_SESSION['lng'] as $lng) { $sql .= ", nom_".$lng.""; } $sql .= ") VALUES ( '".intval($frm['position'])."', 'reve'"; foreach ($_SESSION['lng'] as $lng) { $sql .= ", '".htmlspecialchars($frm['nom_'.$lng.''], ENT_QUOTES)."'"; } $sql .= ")"; mysql_query_override($sql) or DIE('Une erreur de connexion à la base s est produite ' . __LINE__ . '.<p>' . MYSQL_ERROR()); } function maj_paiement($id, $frm) { /* Met à jour le paiement $id avec de nouvelles valeurs. Les champs sont dans $frm */ /* Met à jour la table paiement */ $sql =" UPDATE gaia_paiement SET position = '".intval($frm['position'])."', priv = 'reve'"; foreach ($_SESSION['lng'] as $lng) { $sql .= ", nom_".$lng." = '".htmlspecialchars($frm['nom_'.$lng.''], ENT_QUOTES)."'"; } $sql .= " WHERE id = '$id'"; mysql_query_override($sql) or DIE('Une erreur de connexion à la base s est produite ' . __LINE__ . '.<p>' . MYSQL_ERROR()); } function affiche_liste_paiement($start) { ?> <table class="tablespace" border=0"" width="100%" cellpadding="0" cellspacing="0"> <tr> <th class="entete" colspan="5">Gérer les types de paiement</th> </tr> <tr> <td colspan="5"> <a class="normal" href="<?=$_SERVER['PHP_SELF']?>?mode=ajout"> Ajouter un type de paiement</a></td> </tr> <? $result=mysql_query_override("SELECT * FROM gaia_paiement where priv = 'reve' ORDER BY position"); if (mysql_num_rows_override($result) == 0) {echo "<tr><td class=normal><b>Aucun type de paiement enregistré dans la base.</b></td></tr>"; } else { ?> <tr bgcolor="#6699ff"> <td class="menu">Action</td> <td class="menu">Type de paiement</td> <td class="menu">Ordre de proposition</td> </tr> <? $i = 0; while ($ligne = mysql_fetch_array_override($result)) { ?> <tr bgcolor="<?echo ($i % 2 == 0 ? '#F4F4F4' : '#ffffff' );?>"> <td class=petit><a class="petit" onClick="Javascript:return confirm('êtes-vous sûr de vouloir supprimer ce type de paiement ?');" title="Supprimer <?=$ligne['nom_'.$_SESSION['langue'].''] ?>" href="<?=$_SERVER['PHP_SELF']?>?mode=suppr&id=<?=$ligne['id'] ?>"><i class="ti-close"></i></a></td> <td class=petit><a class="petit" title="Modifier ce paiement" href="<?=$_SERVER['PHP_SELF']?>?mode=modif&id=<?=$ligne['id'] ?>"><?=$ligne['nom_'.$_SESSION['langue'].''] ?></a></td> <td class=petit align="center"><?=$ligne['position'] ?></td> </tr> <? $i++; } } echo "</table>"; } ?>