DubStepMad

#1

Feb 11th, 2018
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.85 KB | None | 0 0
  1. <?php
  2. session_start();
  3. ob_start();
  4. if (!isset($_SESSION['logged'])) {
  5. header('Location: index.php');
  6. }
  7. $staffPerms = $_SESSION['perms'];
  8. $user = $_SESSION['user'];
  9.  
  10. if ($staffPerms['ccmember'] != '1' ) {
  11. if ($staffPerms['dev'] != '1') {
  12. header('Location: ../lvlError.php');
  13. }
  14. }
  15.  
  16. include '../verifyPanel.php';
  17. masterconnect();
  18.  
  19. $page1 = $_GET['page'];
  20. if ($page1 == '' || $page1 == '1') {
  21. $page = 0;
  22. } else {
  23. $page = ($page1 * 50) - 50;
  24. }
  25. $resultQ = 'SELECT uid FROM points';
  26. $result = mysqli_query($dbcon, $resultQ) or die('Connection could not be established');
  27. $count = mysqli_num_rows($result);
  28. $amount = $count / 50;
  29. $amount = ceil($amount) + 1;
  30. $currentpage = $page1;
  31. $minusPage = $currentpage - 1;
  32. if ($minusPage < 1) {
  33. $minusPage = 1;
  34. }
  35. $addPage = $currentpage + 1;
  36. if ($addPage > $amount) {
  37. $addPage = $amount;
  38. }
  39.  
  40. $sqlget = 'SELECT * FROM points ORDER BY uid ASC limit '.$page.',50';
  41. $search_result = filterTable($dbcon, $sqlget);
  42.  
  43. include '../header/convoyheader.php';
  44. ?>
  45. <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
  46. <h1 style = "margin-top: 70px">Convoy Points</h1>
  47. <p class="page-header">List of points for the current convoy and who the point is assigned to.</p>
  48. <div id="alert-area"></div>
  49. <div class="btn-group" role="group" aria-label="...">
  50. <FORM METHOD="LINK" ACTION="convoydetails">
  51. <INPUT class='btn btn-primary btn-outline' style="border-color:<?php echo $CCUSTOMCOLOR; ?>" TYPE="submit" VALUE="Back">
  52. </FORM>
  53. </div>
  54.  
  55. <br>
  56.  
  57.  
  58. <div class="table-responsive">
  59. <table class="table table-striped" style = "margin-top: 0px">
  60. <thead>
  61. <tr>
  62. <th></th>
  63. <th style="text-align: center !important;">Assinged To</th>
  64. <th style="text-align: center !important;">Message</th>
  65.  
  66. </tr>
  67. </thead>
  68. <tbody>
  69. <?php
  70. $pointno = 0;
  71. while ($row = mysqli_fetch_array($search_result, MYSQLI_ASSOC)) {
  72.  
  73. $pointno++;
  74.  
  75. echo '<tr>';
  76. echo '<td style="font-weight: bold;">Point: '.$pointno.'</td>';
  77. echo '<td>' ?>
  78. <input style="max-width: 50% !important;" class="form-control" onBlur="dbSave(this.value, '<?php echo $row['uid']; ?>', 'assigned', '<?php echo $row['assigned']; ?>')"; type=text value= "<?php echo $row['assigned']; ?>" >
  79. <?php
  80. echo '</td>';
  81. echo '<td>' ?>
  82. <input class="form-control" onBlur="dbSave(this.value, '<?php echo $row['uid']; ?>', 'message', '<?php echo $row['message']; ?>')"; type=text value= "<?php echo $row['message']; ?>" >
  83. <?php
  84. echo '</td>';
  85. echo '</tr>';
  86. }
  87. echo '</table></div>';
  88. ?>
  89.  
  90. <nav>
  91. <ul class="pagination">
  92. <?php if ($currentpage != 1) {
  93. ?>
  94. <li>
  95. <a href="convoypoints.php?search=<?php echo $search; ?>&page=<?php echo $minusPage; ?>" aria-label="Previous">
  96. <span aria-hidden="true">&laquo;</span>
  97. </a>
  98. </li>
  99. <?php
  100. } else {
  101. ?>
  102.  
  103. <li class = "disabled">
  104. <a href="convoypoints.php?search=<?php echo $search; ?>&page=<?php echo $minusPage; ?>" aria-label="Previous">
  105. <span aria-hidden="true">&laquo;</span>
  106. </a>
  107. </li>
  108.  
  109. <?php
  110. }
  111. $amountPage = $currentpage + 2;
  112. $pageBefore = $currentpage - 2;
  113. if ($pageBefore == 0) {
  114. $pageBefore = 1;
  115. $amountPage = $amountPage + 1;
  116. }
  117. if ($pageBefore < 1) {
  118. $pageBefore = 1;
  119. $amountPage = $amountPage + 2;
  120. }
  121. for ($b = $pageBefore; $b <= $amountPage; ++$b) {
  122. if ($b >= $amount) {
  123. ?><li class = "disabled"><a href = "convoypoints.php?search=<?php echo $search; ?>&page=<?php echo $b; ?>" style = "text-decoration:none"><?php echo $b.' '; ?></a><li><?php
  124. } else {
  125. if ($b == $currentpage) {
  126. ?><li class = "active"><a href = "convoypoints.php?search=<?php echo $search; ?>&page=<?php echo $b; ?>" style = "text-decoration:none"><?php echo $b.' '; ?></a><li><?php
  127. } else {
  128. ?><li><a href = "convoypoints.php?search=<?php echo $search; ?>&page=<?php echo $b; ?>" style = "text-decoration:none"><?php echo $b.' '; ?></a><li><?php
  129. }
  130. }
  131. }
  132. if ($currentpage != $amount) {
  133. ?>
  134. <li>
  135. <a href="convoypoints.php?search=<?php echo $search; ?>&page=<?php echo $addPage; ?>" aria-label="Next">
  136. <span aria-hidden="true">&raquo;</span>
  137. </a>
  138. </li>
  139. <?php
  140. } else {
  141. ?>
  142.  
  143. <li class = "disabled">
  144. <a href='convoypoints.php?search=<?php echo $search; ?>&page=<?php echo $minusPage; ?>' aria-label="Next">
  145. <span aria-hidden="true">&raquo;</span>
  146. </a>
  147. </li>
  148.  
  149. <?php
  150. }
  151. ?>
  152. </ul>
  153. </nav>
  154. <script>
  155. function newAlert (type, message) {
  156. $("#alert-area").append($("<div class='alert " + type + " fade in' data-alert><p> " + message + " </p></div>"));
  157. $(".alert").delay(2000).fadeOut("slow", function () { $(this).remove(); });
  158. }
  159. function dbSave(value, uid, column, original){
  160. if (value != original) {
  161. newAlert('alert-success', 'Value Updated!');
  162. $.post('Backend/updatePoints.php',{column:column, editval:value, uid:uid},
  163. function(){
  164. //alert("Sent values.");
  165. });
  166. };
  167. }
  168. </script>
  169. </tbody>
  170. </table>
  171. </div>
  172. </div>
  173. </div>
  174. </div>
  175. <script src="dist/js/bootstrap.min.js"></script>
  176. </body>
  177. </html>
Advertisement
Add Comment
Please, Sign In to add comment