librapports.inc.php 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <?php
  2. require_once("libliberations.inc.php");
  3. $sqlWhereDateDemande = "";
  4. $sqlWhereEmploye = "";
  5. $sqlWhereEmployeur = "";
  6. $sqlWhereArticle = "";
  7. // ****************************************************
  8. // Sélection de date
  9. // Toujours déterminer la date de début et de fin de la période courante.
  10. // Pour celles des BER (si nécessaire)
  11. // ****************************************************
  12. $datetemp = getPeriodeCourante();
  13. $datedebut1 = $datetemp["datedebut"];
  14. $datefin1 = $datetemp["datefin"];
  15. //Date de début indiquée?
  16. $operation = "";
  17. if (filter_input(INPUT_GET, "datedebut") != "") {
  18. $datedebut = antiInjection(filter_input(INPUT_GET, "datedebut"));
  19. if (!strtotime($datedebut)) {
  20. $datedebut = date("Y-M-d");
  21. }
  22. //Date de fin indiquée?
  23. if (filter_input(INPUT_GET, "datefin") != "") {
  24. $datedebut1 = $datedebut;
  25. $datedebut2 = $datedebut;
  26. $datefin = antiInjection(filter_input(INPUT_GET, "datefin"));
  27. if (!strtotime($datefin)) {
  28. $datefin = date("Y-M-d");
  29. }
  30. $datefin1 = $datefin;
  31. $datefin2 = $datefin;
  32. } else {
  33. if (filter_input(INPUT_GET, "optiondate") !== "") {
  34. $optiondate = sprintf("%d", filter_input(INPUT_GET, "optiondate"));
  35. switch ($optiondate) {
  36. case "1":
  37. $operation = "=";
  38. $datedebut1 = $datedebut;
  39. $datedebut2 = $datedebut;
  40. break;
  41. case "2":
  42. $operation = "<";
  43. $datefin1 = $datedebut;
  44. $datefin2 = $datedebut;
  45. break;
  46. case "3":
  47. $operation = ">";
  48. $datedebut1 = $datedebut;
  49. $datedebut2 = $datedebut;
  50. break;
  51. default:
  52. $operation = "=";
  53. $datedebut1 = $datedebut;
  54. $datedebut2 = $datedebut;
  55. break;
  56. }
  57. } else {
  58. $operation = "=";
  59. $datedebut1 = $datedebut;
  60. $datedebut2 = $datedebut;
  61. }
  62. }
  63. }
  64. if (isset($rapport_source) && $rapport_source !== "rapport_employes_employeur") {
  65. if ($operation != "=") {
  66. $sqlWhereDateDemande = "DATE_FORMAT(ligneliberations.dateliberation,'%Y-%m-%d') BETWEEN '$datedebut1' And '$datefin1'";
  67. } else {
  68. $sqlWhereDateDemande = "DATE_FORMAT(ligneliberations.dateliberation,'%Y-%m-%d') = '$datedebut1' ";
  69. }
  70. $sqlparam["where"]["datedemande"] = $sqlWhereDateDemande;
  71. }
  72. // ****************************************************
  73. // Employeur ou employé
  74. // ****************************************************
  75. if (intval(filter_input(INPUT_GET, "ListeEmployes")) != -1) {
  76. if (filter_input(INPUT_GET, "ListeEmployes") != "") {
  77. $listeEmployes = antiInjection(sprintf("%d", filter_input(INPUT_GET, "ListeEmployes")));
  78. $sqlparam["where"]["employe"] = "(employes.refemploye = " . $listeEmployes . ")";
  79. $sqlGroupEmployeur = "";
  80. $bHavEmploye = True;
  81. }
  82. }
  83. if (intval(filter_input(INPUT_GET, "ListeEmployeurs")) != -1 || $_SESSION['gestion_site'] == "Non") {
  84. unset($listeEmployeurs);
  85. if ($_SESSION['gestion_site'] == "Non") {
  86. $listeEmployeurs = $_SESSION['employeur'];
  87. } else {
  88. $listeEmployeurs = intval(antiInjection(filter_input(INPUT_GET, "ListeEmployeurs")));
  89. }
  90. $sqlWhereEmployeur = sprintf("(employes.refemployeur = %d)", $listeEmployeurs);
  91. $sqlparam["where"]["employeur"] = sprintf("employes.refemployeur = %d", $listeEmployeurs);
  92. $bHavEmployeur = True;
  93. } else {
  94. $sqlWhereEmployeur = "";
  95. $sqlGroupEmployeur = "";
  96. }
  97. // ****************************************************
  98. // Articles de la convention
  99. // ****************************************************
  100. if (filter_input(INPUT_GET, "ListeArticles") != "") {
  101. $listeArticles = antiInjection(filter_input(INPUT_GET, "ListeArticles"));
  102. $listeArticles2 = explode(",", $listeArticles);
  103. $nombreligne = sizeof($listeArticles2) - 1;
  104. $listeArticles3 = "";
  105. for ($v = 0; $v < $nombreligne; $v++) {
  106. $listeArticles3 .= "\"" . sprintf("%d", $listeArticles2[$v]) . "\"";
  107. if ($v < $nombreligne - 1) {
  108. $listeArticles3 .= ",";
  109. }
  110. }
  111. $sqlparam["where"]["article"] = "articles.refarticle IN (" . $listeArticles3 . ")";
  112. }
  113. $sqlGroup = "";
  114. $sqlGroupEmployeur = "";
  115. // ****************************************************
  116. // Commentaire
  117. // ****************************************************
  118. $sqlWhereCommentaire = "";
  119. if (filter_input(INPUT_GET, "Commentaire") != "") {
  120. $sqlparam["where"]["commentaire"] = "ligneliberations.commentaire LIKE \"%" . antiInjection(sprintf("%s", filter_input(INPUT_GET, "Commentaire"))) . "%\" ";
  121. }
  122. // ****************************************************
  123. // Traitement par rapport
  124. // ****************************************************
  125. if (isset($mode)) {
  126. //Est-ce le rapport des employés par employeur?
  127. if ($mode == "Rapport des employés par employeur") {
  128. unset($sqlparam["where"]["datedemande"]);
  129. unset($sqlparam["where"]["employe"]);
  130. unset($sqlparam["where"]["article"]);
  131. unset($sqlparam["where"]["commentaire"]);
  132. }
  133. //Est-ce le rapport des libérations selon le paiement?
  134. elseif ($mode == "Rapport des libérations selon le paiement") {
  135. if (filter_input(INPUT_GET, "Assumerpar") != "") {
  136. if (filter_input(INPUT_GET, "Assumerpar") == "1") {
  137. $sqlparam["where"]["quipaye"] = "ligneliberations.quipaye = 'Syndicat' ";
  138. } elseif (filter_input(INPUT_GET, "Assumerpar") == "2") {
  139. $sqlparam["where"]["quipaye"] = "ligneliberations.quipaye = 'Employeur' ";
  140. }
  141. }
  142. if (filter_input(INPUT_GET, "Paiement") != "") {
  143. $var1 = antiInjection(filter_input(INPUT_GET, "Paiement"));
  144. $sqlparam["where"]["paiement"] = ($var1 == "1") ? "ligneliberations.paiement=2" : "ligneliberations.paiement<2";
  145. }
  146. }
  147. if (isset($sqlWhereEmployeur) && !empty($sqlWhereEmployeur)) {
  148. $sqlparam["where"]["employeur"] = $sqlWhereEmployeur;
  149. }
  150. }
  151. if (isset($sqlSelect) && isset($sqlselect2) && isset($sqlFrom) && isset($sqlGroup) && isset($sqlGroupEmployeur) && isset($sqlWhere) && isset($sqlOrder)) {
  152. $sqlprinc = $sqlSelect . $sqlselect2 . $sqlFrom . $sqlGroup . $sqlGroupEmployeur . $sqlWhere . $sqlOrder;
  153. print $sqlprinc;
  154. }