liste_articles.inc.php 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. <?php
  2. // --------
  3. // Sécurité
  4. // --------
  5. if (isValidConstant() != 1) {
  6. fermeSessionUtilisateur();
  7. }
  8. // ----------------------
  9. // Droit de l'utilisateur
  10. // ----------------------
  11. if ($_SESSION['gestion_site'] < 'Oui') {
  12. exit;
  13. }
  14. // ------------------------------
  15. // Caractéristiques du module
  16. // ------------------------------
  17. unset($module);
  18. $module = array(
  19. "titre" => "Gestion des articles",
  20. "urldest" => $SCRIPT_NAME . "?page=liste_articles&jeton=" . $jeton,
  21. "recherche" => array("engin" => false),
  22. "jeton" => $jeton,
  23. "fenetre" => array(
  24. "nom" => "liste_articles",
  25. "titre" => "titre",
  26. "largeur" => "400",
  27. "hauteur" => "280",
  28. "champs" => array("lnoarticle", "larticle", "lcommentaire", "lexpression")
  29. ),
  30. "msgmodifbouton" => "Modification de la fiche de l'article",
  31. "actionmodifbouton" => "Modifier l'article",
  32. "taille" => "800px",
  33. "lientri" => true,
  34. "entete" => array(
  35. 1 => array("Article" => "refarticle", "largeur" => "85px"),
  36. 2 => array("Commentaire" => "commentaire", "largeur" => "662px"),
  37. 3 => array("Expression" => "expression", "largeur" => "170px"),
  38. 4 => array("Action" => "expression", "largeur" => "45px")
  39. ),
  40. "msg" => array(
  41. "maj_ok" => "Mise à jour de l'article effectuée avec succès.",
  42. "maj_echec" => "L'opération de mise à jour de l'article a échouée."
  43. )
  44. );
  45. // ------------------
  46. // Requête sur le tri
  47. // ------------------
  48. //Traitement spécial pour le tri concernant ce module
  49. //Le tri pour la colonne Article est différent de la norme.
  50. if (key($module["entete"][$tri])==="Article") {
  51. $rtri = antiInjection("length(refarticle) $dir, noarticle $dir");
  52. } else {
  53. $rtri = antiInjection($module["entete"][$tri][key($module["entete"][$tri])] . " " . $dir);
  54. }
  55. // -----------------------
  56. // Opération de sauvegarde
  57. // -----------------------
  58. if (isset($action)) {
  59. $msg = "";
  60. //Cueillette de données du module
  61. $action = stripslashes(antiInjection($action));
  62. if ($action == "Modifier l'article") {
  63. $error = false;
  64. if ($rlnoarticle === "" || intval($rlnoarticle) < 0) {
  65. $module["resultatSQL"] = false;
  66. $module["message"] = "Le numéro d'article de la convention est invalide ou inexistant.";
  67. $error = true;
  68. }
  69. if (!$error) {
  70. unset($sqlparam, $result);
  71. $lnoemployeur = antiInjection($lnoemployeur);
  72. $sqlparam["table"][] = "articles";
  73. $sqlparam["where"][] = sprintf("refarticle = %d", $rlnoarticle);
  74. $result = executerRequeteSql($sqlparam);
  75. if (!isset($result)) {
  76. $module["resultatSQL"] = false;
  77. $module["message"] = "Le numéro d'article de la convention est invalide ou inexistant.";
  78. } else {
  79. unset($sqlparam, $result);
  80. $rlnoarticle = antiInjection($lnoarticle);
  81. $rlcommentaire = antiInjection($lcommentaire);
  82. $rlexpression = antiInjection($lexpression);
  83. $sqlparam["type"] = "UPDATE";
  84. $sqlparam["table"][] = "articles";
  85. $sqlparam["where"][] = "refarticle = " . $rlnoarticle;
  86. $sqlparam["champs"]["commentaire"] = "'$rlcommentaire'";
  87. $sqlparam["champs"]["expression"] = "'$rlexpression'";
  88. $result = executerRequeteSql($sqlparam);
  89. if (isset($result)) {
  90. $module["resultatSQL"] = true;
  91. $module["message"] = $module["msg"]["maj_ok"];
  92. } else {
  93. $module["resultatSQL"] = false;
  94. $module["message"] = $module["msg"]["maj_echec"];
  95. }
  96. }
  97. }
  98. }
  99. }
  100. $i = 0;
  101. unset($sqlparam);
  102. $sqlparam["table"][] = "articles";
  103. $sqlparam["champs"][] = "refarticle";
  104. $sqlparam["champs"][] = "noarticle";
  105. $sqlparam["champs"][] = "commentaire";
  106. $sqlparam["champs"][] = "expression";
  107. $sqlparam["champs"][] = "(SELECT count(articles.refarticle) FROM articles) as compte";
  108. $sqlparam["ordre"][] = $rtri;
  109. $result = executerRequeteSql($sqlparam);
  110. $module["compte"] = $result[0]["compte"];
  111. print preparerModule($module);
  112. if (isset($result)) {
  113. // Style CSS pour les liste
  114. $i = ($nopage - 1) * $nombreaffiche + 1;
  115. unset($style);
  116. $style = "border:1px solid #cfcfcf; font-family:arial, helvetica, sans-serif; ";
  117. $style .= "font-size:9pt; margin-left:5px; margin-right:5px;";
  118. //Boucle de lecture
  119. foreach ($result as $clef => $champs) {
  120. $champs4 = ($champs["expression"] != "") ? $champs["expression"] : " ";
  121. print "<tr>\n";
  122. print "<td style='$style'>" . $i . "</td>\n";
  123. print "<td style='$style'>" . htmlentities($champs["noarticle"], ENT_SUBSTITUTE, "UTF-8") . "</td>\n";
  124. print "<td style='$style'>" . htmlentities($champs["commentaire"], ENT_SUBSTITUTE, "UTF-8") . "</td>\n";
  125. print "<td style='$style'>" . htmlentities($champs4, ENT_SUBSTITUTE, "UTF-8") . "</td>\n";
  126. print "<td style='$style'>\n";
  127. print "<form action='' name='sous_formulaire$i'>";
  128. print prepareBoutonModifier(array($champs["refarticle"], $champs["noarticle"], $champs["commentaire"], $champs4));
  129. print "</form>";
  130. print "\n</td>\n";
  131. print "</tr>\n";
  132. $i++;
  133. }
  134. print"</table>\n";
  135. // Pagination
  136. print "<table style='width:968px; margin:auto;'>\n";
  137. print "<tr><td style='vertical-align:bottom;'>\n";
  138. print $seqpage;
  139. print "</td>\n";
  140. print "<td style='width:320px; text-align:right;'>\n";
  141. //Haut de page
  142. if ($nombreaffiche > 15) {
  143. print "<a href='#hautpage' title='Aller en haut de la page'>Haut de page</a>\n";
  144. print "<a name='baspage'>\n";
  145. }
  146. print "</td></tr>\n";
  147. print "</table>\n";
  148. print fenetreModaleDebut($module["fenetre"], $SCRIPT_NAME, $jeton);
  149. print " <tr>\n";
  150. print " <td>Article : </td>\n";
  151. print " <td><input type='text' readonly='readonly' id='larticle' value=''>\n";
  152. print " <input type='hidden' id='lnoarticle' name='lnoarticle' value=''>\n";
  153. print " </td>\n";
  154. print " </tr>\n";
  155. print " <tr>\n";
  156. print " <td>Commentaire : </td>\n";
  157. print " <td><textarea rows='2' cols='24' id='lcommentaire' name='lcommentaire'></textarea></td>\n";
  158. print " </tr>\n";
  159. print " <tr>\n";
  160. print " <td>Expression : </td>\n";
  161. print " <td><INPUT TYPE='text' id='lexpression' name='lexpression' Value='' SIZE='20' MAXLENGTH='20'></td>\n";
  162. print " </tr>\n";
  163. print fenetreModaleFin($module["actionmodifbouton"]);
  164. }
  165. // Mise en place des masques de saisie
  166. print "
  167. <script type='text/javascript'>
  168. $(document).ready(function() {
  169. $(\"#frmModif\").validate();
  170. });
  171. </script>";