/gespac/gestion_utilisateurs/form_menu_portail.php

http://gespac.googlecode.com/ · PHP · 116 lines · 71 code · 36 blank · 9 comment · 2 complexity · 3f1992724f6330a5294e106d18a08ab8 MD5 · raw file

  1. <?PHP
  2. #formulaire de modification
  3. #des items du menu portail !
  4. // lib
  5. include ('../config/databases.php'); // fichiers de configuration des bases de données
  6. require_once ('../fonctions.php');
  7. include_once ('../../class/Sql.class.php');
  8. ?>
  9. <script type="text/javascript">
  10. window.addEvent('domready', function(){
  11. // MOTEUR AJAX
  12. $('post_form').addEvent('submit', function(e) { // Pour poster un formulaire
  13. new Event(e).stop();
  14. new Request({
  15. method: this.method,
  16. url: this.action,
  17. onSuccess: function(responseText, responseXML) {
  18. $('targetback').setStyle("display","block"); $('target').setStyle("display","block");
  19. $('target').set('html', responseText);
  20. SexyLightbox.close();
  21. window.setTimeout("document.location.href='index.php?page=grades&filter=" + $('filt').value + "'", 2500);
  22. }
  23. }).send(this.toQueryString());
  24. });
  25. });
  26. </script>
  27. <small>Pour ajouter un raccourci, allez dans les "MODULES" et choisissez "MENU PORTAIL"</small>
  28. <?PHP
  29. $grade_id = $_GET['id'];
  30. // cnx ŕ la base de données OCS
  31. $con_gespac = new Sql ($host, $user, $pass, $gespac);
  32. // Requete pour récupérer les données des champs pour le grade ŕ modifier
  33. $droits_menu_portail = $con_gespac->QueryOne ( "SELECT grade_menu_portail FROM grades WHERE grade_id=$grade_id");
  34. // stockage des lignes retournées par sql dans un tableau nommé avec originalité "array" (mais "tableau" peut aussi marcher)
  35. $liste_des_icones = $con_gespac->QueryAll ( "SELECT mp_id, mp_icone, mp_nom, mp_url FROM menu_portail ORDER BY mp_nom" );
  36. ?>
  37. <FORM action="gestion_utilisateurs/post_menu_portail.php?gradeid=<?PHP echo $grade_id; ?>" method="post" name="post_form" id="post_form">
  38. <center>
  39. </br>
  40. <table width=500 id='portail_table'>
  41. <th>&nbsp;</th>
  42. <th>Icone</th>
  43. <th>Nom</th>
  44. <th>Url</th>
  45. <th>&nbsp;</th>
  46. <th>&nbsp;</th>
  47. <?PHP
  48. $compteur = 0; // Pour alternance des couleurs
  49. // On parcourt le tableau
  50. foreach ($liste_des_icones as $record ) {
  51. // alternance des couleurs
  52. $tr_class = ($compteur % 2) == 0 ? "tr1" : "tr2";
  53. echo "<tr class=$tr_class>";
  54. $mp_id = $record['mp_id'];
  55. $mp_icone = "./img/" . $record['mp_icone'];
  56. $mp_nom = $record['mp_nom'];
  57. $mp_lien = $record['mp_url'];
  58. $menu_portail_exist = preg_match ("#item$mp_id#", $droits_menu_portail);
  59. $check = $menu_portail_exist == 1 ? "checked" : "" ;
  60. echo "<td><input type=checkbox id='item$mp_id' class='Lchk' name='item$mp_id' $check \"/></td>";
  61. echo "<td width=40><img height=30 src=$mp_icone></td>";
  62. echo "<td>" . $mp_nom . "</td>";
  63. echo "<td>" . $mp_lien . "</td>";
  64. echo "<td>&nbsp;</td>";
  65. echo "<td>&nbsp;</td>";
  66. echo "</tr>";
  67. $compteur++;
  68. }
  69. ?>
  70. </table>
  71. <br>
  72. <input type="submit" value='Modifier le menu du portail' />
  73. </center>
  74. </FORM>