obtdatelib.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. //Librairie de fonctions
  3. //require("lib/libsession.inc.php");
  4. //require("lib/libfonctions.inc.php");
  5. require("lib/libencode.inc.php");
  6. require("lib/libmysql.inc.php");
  7. session_start();
  8. setConnectionSql();
  9. if (isset($_POST['prm1']) && isset($_POST['prm2'])) {
  10. $rsearch1 = antiInjection($_POST['prm1']);
  11. $rsearch2 = antiInjection($_POST['prm2']);
  12. if (isset($_POST['prm3']) && !empty($_POST['prm3'])) {
  13. $rsearch3 = antiInjection($_POST['prm3']);
  14. if ($rsearch3 != "--------") {
  15. $prm3vide = false;
  16. } else {
  17. unset($rsearch3);
  18. $prm3vide = true;
  19. }
  20. } else {
  21. $prm3vide = true;
  22. }
  23. if (isset($_POST['prm4']) && !empty($_POST['prm4'])) {
  24. $rsearch4 = antiInjection($_POST['prm4']);
  25. if ($rsearch4 == "1" || $rsearch4 == "2") {
  26. $prm4vide = false;
  27. } else {
  28. unset($rsearch4);
  29. $prm4vide = true;
  30. }
  31. } else {
  32. $prm4vide = true;
  33. }
  34. if ($rsearch1 != "" && $rsearch2 != "") {
  35. unset($sqlparam);
  36. $sqlparam["table"][] = "liberations";
  37. $sqlparam["table"][] = "ligneliberations";
  38. $sqlparam["table"][] = "articles";
  39. $sqlparam["table"][] = "duree";
  40. $sqlparam["join"][] = "ligneliberations.refliberation = liberations.refliberation";
  41. $sqlparam["join"][] = "articles.refarticle=ligneliberations.refarticle";
  42. $sqlparam["join"][] = "duree.refduree=ligneliberations.duree";
  43. $sqlparam["champs"][] = "liberations.refemploye";
  44. $sqlparam["champs"][] = "articles.refarticle";
  45. $sqlparam["champs"][] = "unix_timestamp(ligneliberations.dateliberation) as dateliberation";
  46. $sqlparam["champs"][] = "SUM(If(liberations.typeoperation=1,duree.dureeNombre,0-dureeNombre)) AS calculduree";
  47. $sqlparam["groupe"][] = "liberations.refemploye";
  48. $sqlparam["groupe"][] = "ligneliberations.dateliberation";
  49. if (!$prm3vide) {
  50. $sqlparam["where"][] = sprintf("ligneliberations.refarticle=%d", $rsearch3);
  51. $sqlparam["groupe"][] = "articles.refarticle";
  52. }
  53. $sqlparam["where"][] = "DATE_FORMAT(ligneliberations.dateliberation,'%Y-%m-%d')='$rsearch2'";
  54. $sqlparam["where"][] = "liberations.refemploye=$rsearch1";
  55. $resultat = executerRequeteSql($sqlparam);
  56. if (is_array($resultat) && count($resultat) > 0) {
  57. unset($tablovide);
  58. $tablovide = true;
  59. unset($somme_temps);
  60. $somme_temps = 0;
  61. foreach ($resultat as $clef => $valeur) {
  62. $somme_temps += floatval($valeur["calculduree"]);
  63. }
  64. if ($somme_temps <= 0) {
  65. if ($rsearch4 == "2") {
  66. if (!$prm3vide) {
  67. print "occupedatearticle_annulation";
  68. } else {
  69. print "occupedate_annulation";
  70. }
  71. } else {
  72. print "accepte";
  73. }
  74. } elseif ($somme_temps > 0) {
  75. if ($rsearch4 == "1") {
  76. if (!$prm3vide) {
  77. print "occupedatearticle_demande";
  78. } else {
  79. print "occupedate_demande";
  80. }
  81. } else {
  82. print "accepte";
  83. }
  84. }
  85. } else {
  86. if ($rsearch4 == "2") {
  87. print "refus_annulation";
  88. } else {
  89. print "accepte";
  90. }
  91. }
  92. }
  93. }
  94. mysql_close();