compilation_documents.inc.php 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <?PHP
  2. // ------------------------------
  3. // Caractéristiques du module
  4. // ------------------------------
  5. unset($module);
  6. $module = array(
  7. "titre" => "Compilation de documents",
  8. "urldest" => $SCRIPT_NAME . "?page=compilation_documents&jeton=" . $jeton,
  9. "autre" => 1,
  10. "jeton" => $jeton,
  11. "tailleentete" => "1000",
  12. "nombre_a_afficher" => array(
  13. 0 => array("refid" => 15, "valeur" => 15),
  14. 1 => array("refid" => 30, "valeur" => 30),
  15. 2 => array("refid" => 45, "valeur" => 45),
  16. 3 => array("refid" => 60, "valeur" => 60),
  17. 4 => array("refid" => 120, "valeur" => 120),
  18. 5 => array("refid" => 240, "valeur" => 240)
  19. ),
  20. "boutonfermeraction" => "fermerfenetre",
  21. "colonneaction" => false,
  22. "lientri" => true,
  23. "entete" => array(
  24. 1 => array("Employé" => "CONCAT(employes.nomfamille,employes.prenom)", "largeur" => "200px"),
  25. 2 => array("Type" => "typeoperation", "largeur" => "170px"),
  26. 3 => array("Date de libération" => "dateliberation", "largeur" => "170px"),
  27. 4 => array("Article" => "noarticle", "largeur" => "55px"),
  28. 5 => array("Employeur" => "nomemployeur", "largeur" => "170px"),
  29. 6 => array("<img alt=\"Pdf\" src=\"images/pdficon_small.gif\">" => "-1", "largeur" => "22px")
  30. ),
  31. );
  32. // ------------------
  33. // Requête sur le tri
  34. // ------------------
  35. $rtri = antiInjection($module["entete"][$tri][key($module["entete"][$tri])] . " " . $dir);
  36. // ****************************************************
  37. // Requête SQL principale
  38. // ****************************************************
  39. unset($sqlparam);
  40. $sqlparam["table"][] = "employes";
  41. $sqlparam["table"][] = "employeurs";
  42. $sqlparam["table"][] = "liberations";
  43. $sqlparam["table"][] = "ligneliberations";
  44. $sqlparam["table"][] = "articles";
  45. $sqlparam["table"][] = "duree";
  46. $sqlparam["join"][] = "employes.refemployeur=employeurs.refemployeur";
  47. $sqlparam["join"][] = "employes.refemploye = liberations.refemploye";
  48. $sqlparam["join"][] = "liberations.refliberation = ligneliberations.refliberation";
  49. $sqlparam["join"][] = "ligneliberations.refarticle = articles.refarticle";
  50. $sqlparam["join"][] = "duree.refduree=ligneliberations.duree";
  51. $sqlparam["champs"][] = "liberations.refliberation";
  52. $sqlparam["champs"][] = "CONCAT(employes.nomfamille,', ',employes.prenom) as nomemploye";
  53. $sqlparam["champs"][] = "employes.numemploye";
  54. $sqlparam["champs"][] = "employeurs.nomemployeur";
  55. $sqlparam["champs"][] = "unix_timestamp(liberations.datedemande) as nombre";
  56. $sqlparam["champs"][] = "If(liberations.typeoperation=2,'Annulation','Demande') AS toperation";
  57. $sqlparam["champs"][] = "articles.noarticle";
  58. $sqlparam["champs"][] = "unix_timestamp(ligneliberations.dateliberation) as dateliberation";
  59. $sqlparam["champs"][] = "If(liberations.typeoperation=1,duree.dureeNombre,0-dureeNombre) AS calculduree";
  60. $sqlparam["champs"][] = "employes.refemploye";
  61. $sqlparam["champs"][] = "ligneliberations.commentaire";
  62. $compte = "(SELECT count(ligneliberations.refliberation) FROM employes, employeurs,liberations,"
  63. . "ligneliberations,articles "
  64. . "WHERE employes.refemployeur=employeurs.refemployeur AND ";
  65. $compte .= "employes.refemploye=liberations.refemploye AND liberations.refliberation=ligneliberations.refliberation "
  66. . "AND ligneliberations.refarticle=articles.refarticle";
  67. $compte .= ") as compte";
  68. $sqlparam["champs"][] = $compte;
  69. $sqlparam["limite"] = ($nombreaffiche * ($nopage - 1)) . "," . $nombreaffiche;
  70. if ($_SESSION['gestion_site'] == 'Non') {
  71. $sqlparam["where"] = sprintf("employes.refemployeur=%d", $_SESSION['employeur']);
  72. }
  73. $sqlparam["ordre"][] = $rtri;
  74. require("lib/librapports.inc.php");
  75. $result = executerRequeteSql($sqlparam);
  76. // ****************************************************
  77. // Vérification de la présence de détails dans la liste
  78. // ****************************************************
  79. if (!($result && is_array($result) && !empty($result))) {
  80. print"<center>Aucune libération trouvée!";
  81. print "<br>";
  82. print "<input type='button' onclick='javascript:window.close();' value='Fermer'></center>";
  83. die();
  84. }
  85. $module["compte"] = $result[0]["compte"];
  86. $i = 1;
  87. print preparerModule($module);
  88. //Liste principale;
  89. if (isset($result) && is_array($result)) {
  90. if (!empty($result)) {
  91. $i = ($nopage - 1) * $nombreaffiche + 1;
  92. unset($style);
  93. $style = "border:1px solid #cfcfcf; font-family:arial, helvetica, sans-serif; font-size:9pt; margin-left:5px; margin-right:5px;";
  94. foreach ($result as $clef => $champs) {
  95. $couleur = ($champs["toperation"] == "Demande") ? "style='background-color:#f2f6f7;'" : "style='background-color:#f2f6f7; color:#ff0000; font-weight:700;'";
  96. print "<tr $couleur>\n";
  97. print "<td style='$style'>$i</td>\n";
  98. print "<td style='$style' title=\"" . $champs["nomemploye"] . "\">" . $champs["nomemploye"] . "</td>\n"; //0
  99. print "<td style='$style' title=\"" . $champs["toperation"] . "\">" . $champs["toperation"] . "</td>"; //2
  100. print "<td style='$style' title=\"" . date("Y-m-d", $champs["dateliberation"]) . "\">" . date("Y-m-d", $champs["dateliberation"]) . "</td>\n"; //4
  101. print "<td style='$style' title=\"" . $champs["noarticle"] . "\">" . $champs["noarticle"] . "</td>"; //3
  102. print "<td style='$style' title=\"\">" . ecrireTexteLimite($champs["nomemployeur"], 170) . "</td>"; //1
  103. print "<td style='$style'>";
  104. print "<a href=\"creation_liberation.php?lib=" . $champs["refliberation"] . "&sortie=ecran\"><img alt=\"pdf\" src=\"images/pdficon_small.gif\"></a>"; //5
  105. print "</td></tr>\n";
  106. $i++;
  107. }
  108. }
  109. }
  110. print"</table>";
  111. // Pagination
  112. print "<table style='width:968px; margin:auto;'>";
  113. print "<tr><td style='vertical-align:bottom;'>";
  114. print $seqpage;
  115. print "</td>";
  116. print "<td style='width:320px; text-align:right;'>";
  117. //Haut de page
  118. if ($nombreaffiche > 15) {
  119. print "<a href='#hautpage' title='Aller en haut de la page'>Haut de page</a>";
  120. print "<a name='baspage'>";
  121. }
  122. print "</td></tr>";
  123. print "</table>";