PageRenderTime 26ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/views/SEIP128330/SummeryOfOrganizations/index.php

https://gitlab.com/shaon2016/day13
PHP | 208 lines | 164 code | 41 blank | 3 comment | 20 complexity | 96568c83d44777f1da16401f5e609584 MD5 | raw file
  1. <?php
  2. session_start();
  3. include_once("../../../vendor/autoload.php");
  4. use App\BITM\SEIP128330\Utility;
  5. use App\BITM\SEIP128330\Message;
  6. $summery= new \App\BITM\SEIP128330\SummeryOfOrganizations\SummeryOfOrganizations();
  7. //Utility::d($allBook);
  8. if(array_key_exists('itemPerPage',$_SESSION)) {
  9. if (array_key_exists('itemPerPage', $_GET)) {
  10. $_SESSION['itemPerPage'] = $_GET['itemPerPage'];
  11. }
  12. }
  13. else{
  14. $_SESSION['itemPerPage']=5;
  15. }
  16. //Utility::dd($_SESSION['itemPerPage']);
  17. $itemPerPage=$_SESSION['itemPerPage'];
  18. $totalItem=$summery->count();
  19. $totalPage=ceil($totalItem/$itemPerPage);
  20. //Utility::dd($itemPerPage);
  21. $pagination="";
  22. if(array_key_exists('pageNumber',$_GET)){
  23. $pageNumber=$_GET['pageNumber'];
  24. }else{
  25. $pageNumber=1;
  26. }
  27. for($i=1;$i<=$totalPage;$i++){
  28. $class=($pageNumber==$i)?"active":"";
  29. $pagination.="<li class='$class'><a href='index.php?pageNumber=$i'>$i</a></li>";
  30. }
  31. $pageStartFrom=$itemPerPage*($pageNumber-1);
  32. $getAllSummeryData=$summery->paginator($pageStartFrom,$itemPerPage);
  33. ?>
  34. <!DOCTYPE html>
  35. <html lang="en">
  36. <head>
  37. <title>Summery of organizations</title>
  38. <meta charset="utf-8">
  39. <meta name="viewport" content="width=device-width, initial-scale=1">
  40. <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
  41. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
  42. <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
  43. </head>
  44. <body>
  45. <div class="container">
  46. <h2>organizations List</h2>
  47. <a href="create.php" class="btn btn-info" role="button">Create Again</a>
  48. <a href="trashed.php" class="btn btn-info" role="button">Go to trashed</a>
  49. <div id = 'message'>
  50. <?php
  51. if (array_key_exists('message', $_SESSION) && (!empty($_SESSION['message'])))
  52. echo Message::examineMessage();
  53. ?>
  54. </div>
  55. <form role="form">
  56. <div class="form-group">
  57. <label for="sel1">Select homw many items you want to show (select one):</label>
  58. <select class="form-control" id="sel1" name="itemPerPage">
  59. <option
  60. <?php
  61. if ($itemPerPage == 5) {
  62. ?>
  63. selected
  64. <?php
  65. }
  66. ?>
  67. >5</option>
  68. <option
  69. <?php
  70. if ($itemPerPage == 10) {
  71. ?>
  72. selected
  73. <?php
  74. }
  75. ?>
  76. >10</option>
  77. <option
  78. <?php
  79. if ($itemPerPage == 15) {
  80. ?>
  81. selected
  82. <?php
  83. }
  84. ?>
  85. >15</option>
  86. <option
  87. <?php
  88. if ($itemPerPage == 20) {
  89. ?>
  90. selected
  91. <?php
  92. }
  93. ?>
  94. >20</option>
  95. <option
  96. <?php
  97. if ($itemPerPage == 25) {
  98. ?>
  99. selected
  100. <?php
  101. }
  102. ?>
  103. >25</option>
  104. </select>
  105. <button type="submit">Go!</button>
  106. </div>
  107. </form>
  108. <table class="table table-hover">
  109. <thead>
  110. <tr>
  111. <th>SL</th>
  112. <th>ID</th>
  113. <th>organzation</th>
  114. <th>Summery</th>
  115. <th>Action</th>
  116. </tr>
  117. </thead>
  118. <tbody>
  119. <!-- Here getAllBookData is a object -->
  120. <?php
  121. $serialNumber = 1;
  122. foreach ($getAllSummeryData as $summery) {
  123. ?>
  124. <tr>
  125. <td><?php echo $serialNumber++ + $pageStartFrom ?></td>
  126. <td><?php echo $summery['id'] ?></td>
  127. <td><?php echo $summery['organization'] ?></td>
  128. <td><?php echo $summery['summery'] ?></td>
  129. <td>
  130. <a href="view.php?id=<?php echo $summery['id']?>" class="btn btn-info" role="button">View</a>
  131. <a href="edit.php?id=<?php echo $summery['id']?>" class="btn btn-primary" role="button">Edit</a>
  132. <a href="delete.php?id=<?php echo $summery['id']?>" class="btn btn-danger" role="button">Delete</a>
  133. <a href="trash.php?id=<?php echo $summery['id']?>" class="btn btn-warning" role="button">Trash</a>
  134. </td>
  135. </tr>
  136. <?php
  137. }
  138. ?>
  139. </tbody>
  140. </table>
  141. <ul class="pagination">
  142. <li
  143. <?php
  144. if ($pageNumber == 1) {
  145. ?>
  146. class="hidden"
  147. <?php
  148. }
  149. ?>
  150. ><a href="index.php?pageNumber= <?php echo($pageNumber - 1) ?>>">Prev</a></li>
  151. <?php echo $pagination ?>
  152. <li
  153. <?php
  154. if ($pageNumber == $totalPage) {
  155. ?>
  156. class="hidden"
  157. <?php
  158. }
  159. ?>
  160. ><a href="index.php?pageNumber= <?php echo($pageNumber + 1) ?>>">Next</a></li>
  161. </ul>
  162. </div>
  163. <script>
  164. $('#message').show().delay(2000).fadeOut();
  165. </script>
  166. </body>
  167. </html>