getvalues.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <?php
  2. $currentusr = $_SESSION["username"];
  3. $isadminqry = mysqli_query($link, "select * from users where username='".$currentusr."'");
  4. while($row = mysqli_fetch_array($isadminqry)){
  5. $admin = $row['admin'];
  6. }
  7. if(isset($_GET['a'])){
  8. $place = $_GET['a'];
  9. }
  10. if(isset($_GET['req'])){
  11. $req = trim($_GET['req']);
  12. }
  13. if(isset($_GET['acc'])){
  14. $acc = trim($_GET['acc']);
  15. }
  16. if(isset($_GET['clt'])){
  17. $cltid = trim($_GET['clt']);
  18. }
  19. if(isset($_GET['rep'])){
  20. $rep = trim($_GET['rep']);
  21. }
  22. if(isset($_GET['usr'])){
  23. $usr = trim($_GET['usr']);
  24. }
  25. if(isset($_GET['chk'])){
  26. $chk = trim($_GET['chk']);
  27. }
  28. if(isset($_GET['repid'])){
  29. $repportid = trim($_GET['repid']);
  30. }
  31. if(isset($_GET['searchstring'])){
  32. $searchstring = trim($_GET['searchstring']);
  33. }
  34. if(isset($_GET['dvctp'])){
  35. $dvctp = trim($_GET['dvctp']);
  36. }
  37. if(isset($_GET['stpdn'])){
  38. $stpdn = trim($_GET['stpdn']);
  39. }
  40. if(isset($_GET['repdn'])){
  41. $repdn = trim($_GET['repdn']);
  42. }
  43. if($place == "logout"){
  44. session_destroy();
  45. header("Refresh:0");
  46. exit;
  47. }
  48. if($_SERVER["REQUEST_METHOD"] == "POST"){
  49. require "place/postactions.php";
  50. }
  51. if(isset($acc)){
  52. if($acc == "yes"){
  53. $sql = "UPDATE request SET treated_by = ?, approved = 1 WHERE id = ?";
  54. if($stmt = mysqli_prepare($link, $sql)){
  55. mysqli_stmt_bind_param($stmt, "si", $currentusr, $req);
  56. if(mysqli_stmt_execute($stmt)){
  57. header("location: ?a=launch&req=$req");
  58. exit();
  59. } else{
  60. echo "Oops! Something went wrong. Please try again later.";
  61. }
  62. }
  63. }elseif($acc == "cltclass"){
  64. $sql = "UPDATE request SET clientid = ? WHERE id = ?";
  65. if($stmt = mysqli_prepare($link, $sql)){
  66. mysqli_stmt_bind_param($stmt, "ii", $cltid, $req);
  67. if(mysqli_stmt_execute($stmt)){
  68. header("location: ?a=launch&req=$req");
  69. exit();
  70. } else{
  71. echo "Oops! Something went wrong. Please try again later.";
  72. }
  73. }
  74. }elseif($acc == "reqend"){
  75. $sql = "UPDATE request SET approved = 3 WHERE id = ?";
  76. if($stmt = mysqli_prepare($link, $sql)){
  77. mysqli_stmt_bind_param($stmt, "i", $req);
  78. if(mysqli_stmt_execute($stmt)){
  79. header("location: ?a=launch");
  80. exit();
  81. } else{
  82. echo "Oops! Something went wrong. Please try again later.";
  83. }
  84. }
  85. }
  86. }
  87. if(isset($stpdn)){
  88. $stepqry = mysqli_query($link, "select * from repports where id='$rep'");
  89. while($row = mysqli_fetch_array($stepqry)){
  90. $stepsdone = $row['stepsdone'];
  91. }
  92. if(strpos("$stepsdone", "<$stpdn>")){
  93. $stepsdone = str_replace("<$stpdn>","",$stepsdone);
  94. $delstepqry = "UPDATE repports SET stepsdone = ? WHERE id = $rep";
  95. if($stmt = mysqli_prepare($link, $delstepqry)){
  96. mysqli_stmt_bind_param($stmt, "s", $stepsdone);
  97. if(mysqli_stmt_execute($stmt)){
  98. header("location: ?a=launch&acc=rapp&req=$req&rep=$rep");
  99. exit();
  100. }
  101. }
  102. }else{
  103. $stepsdone = $stepsdone."<$stpdn>";
  104. $addstepqry = "UPDATE repports SET stepsdone=? WHERE id=$rep";
  105. if($stmt = mysqli_prepare($link, $addstepqry)){
  106. mysqli_stmt_bind_param($stmt, "s", $stepsdone);
  107. if(mysqli_stmt_execute($stmt)){
  108. header("location: ?a=launch&acc=rapp&req=$req&rep=$rep");
  109. exit();
  110. }
  111. }
  112. }
  113. }
  114. if(isset($repdn)){
  115. $delrepqry = "UPDATE repports SET repstat = 1 WHERE id = ?";
  116. if($stmt = mysqli_prepare($link, $delrepqry)){
  117. mysqli_stmt_bind_param($stmt, "i", $rep);
  118. if(mysqli_stmt_execute($stmt)){
  119. header("location: ?a=launch&acc=rapp&req=$req");
  120. exit();
  121. }
  122. }
  123. }
  124. if($rep == "done"){
  125. $finreqqry = "UPDATE request SET approved = 3 WHERE id = ?";
  126. if($stmt = mysqli_prepare($link, $finreqqry)){
  127. mysqli_stmt_bind_param($stmt, "i", $req);
  128. if(mysqli_stmt_execute($stmt)){
  129. header("location: ?a=launch");
  130. exit();
  131. }
  132. }
  133. }
  134. require "place/theme.php";
  135. ?>