PageRenderTime 34ms CodeModel.GetById 10ms RepoModel.GetById 1ms app.codeStats 0ms

/views/SEIP136058/Summary/index.php

https://gitlab.com/ranjoy/Atomic_Project
PHP | 142 lines | 121 code | 18 blank | 3 comment | 5 complexity | 5796d38a0bf92b06bc0a4f6875ef9418 MD5 | raw file
  1. <?php
  2. session_start();
  3. include_once('../../../vendor/autoload.php');
  4. use App\BITM\SEIP136058\Summary\Summary;
  5. use App\BITM\SEIP136058\Utility\Utility;
  6. use App\BITM\SEIP136058\Message\Message;
  7. $object= new Summary();
  8. //Utility::d($allBook);
  9. if(array_key_exists('itemPerPage',$_SESSION)) {
  10. if (array_key_exists('itemPerPage', $_GET)) {
  11. $_SESSION['itemPerPage'] = $_GET['itemPerPage'];
  12. }
  13. }
  14. else{
  15. $_SESSION['itemPerPage']=5;
  16. }
  17. //Utility::dd($_SESSION['itemPerPage']);
  18. $itemPerPage=$_SESSION['itemPerPage'];
  19. $totalItem=$object->count();
  20. $totalPage=ceil($totalItem/$itemPerPage);
  21. //Utility::dd($itemPerPage);
  22. $pagination="";
  23. if(array_key_exists('pageNumber',$_GET)){
  24. $pageNumber=$_GET['pageNumber'];
  25. }else{
  26. $pageNumber=1;
  27. }
  28. for($i=1;$i<=$totalPage;$i++){
  29. $class=($pageNumber==$i)?"active":"";
  30. $pagination.="<li class='$class'><a href='index.php?pageNumber=$i'>$i</a></li>";
  31. }
  32. $pageStartFrom=$itemPerPage*($pageNumber-1);
  33. $allS=$object->paginator($pageStartFrom,$itemPerPage);
  34. ?>
  35. <!DOCTYPE html>
  36. <html>
  37. <head>
  38. <meta name="viewport" content="width=device-width, initial-scale=1">
  39. <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
  40. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
  41. <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
  42. </head>
  43. <body>
  44. <br/>
  45. <div align="right">
  46. <a href="../../../index.php" class="btn btn-success btn-lg" role="button">Atomic Project</a>
  47. </div>
  48. <div class="container">
  49. <h2>All User's City List</h2>
  50. <a href="create.php" class="btn btn-primary" role="button">Create again</a> <a href="trashed.php" class="btn btn-primary" role="button">View Trashed list</a>
  51. <div id="message">
  52. <?php if((array_key_exists('message',$_SESSION)&& (!empty($_SESSION['message'])))) {
  53. echo Message::message();
  54. }
  55. ?>
  56. </div>
  57. <form role="form">
  58. <div class="form-group">
  59. <label for="sel1">Select how many items you want to show (select one):</label>
  60. <select class="form-control" id="sel1" name="itemPerPage">
  61. <option <?php if($itemPerPage==5):?>selected<?php endif ?>>5</option>
  62. <option <?php if($itemPerPage==10):?>selected<?php endif?>>10</option>
  63. <option <?php if($itemPerPage==15):?>selected<?php endif ?>>15</option>
  64. <option <?php if($itemPerPage==20):?>selected<?php endif ?>>20</option>
  65. <option <?php if($itemPerPage==25):?>selected<?php endif ?>>25</option>
  66. </select>
  67. <button type="submit">Go!</button>
  68. </div>
  69. </form>
  70. <div class="table-responsive">
  71. <table class="table">
  72. <thead>
  73. <tr>
  74. <th>SL</th>
  75. <th>ID</th>
  76. <th>Organization Name</th>
  77. <th>Action</th>
  78. </tr>
  79. </thead>
  80. <tbody>
  81. <tr>
  82. <?php
  83. $sl=0;
  84. foreach($allS as $Osummary){
  85. $sl++; ?>
  86. <td><?php echo $sl+$pageStartFrom?></td>
  87. <td><?php echo $Osummary-> id?></td>
  88. <td><?php echo $Osummary->organization?></td>
  89. <td><a href="view.php?id=<?php echo $Osummary-> id ?>" class="btn btn-primary" role="button">View</a>
  90. <a href="edit.php?id=<?php echo $Osummary-> id ?>" class="btn btn-info" role="button">Edit</a>
  91. <a href="delete.php?id=<?php echo $Osummary->id?>" class="btn btn-danger" role="button" id="delete" Onclick="return ConfirmDelete()">Delete</a>
  92. <a href="trash.php?id=<?php echo $Osummary->id ?>" class="btn btn-info" role="button">Trash</a>
  93. </td>
  94. </tr>
  95. <?php }?>
  96. </tbody>
  97. </table>
  98. </div>
  99. <ul class="pagination">
  100. <?php if($pageNumber>1):?>
  101. <li><a href="index.php?pageNumber=<?php echo $pageNumber-1 ?>">Previous</a></li><?php endif;?>
  102. <?php echo $pagination?>
  103. <?php if($pageNumber<$totalPage):?>
  104. <li><a href="index.php?pageNumber=<?php echo $pageNumber+1 ?>">Next</a></li><?php endif;?>
  105. </ul>
  106. </div>
  107. <script>
  108. $('#message').show().delay(2000).fadeOut();
  109. function ConfirmDelete()
  110. {
  111. var x = confirm("Are you sure you want to delete?");
  112. if (x)
  113. return true;
  114. else
  115. return false;
  116. }
  117. </script>
  118. </body>
  119. </html>