PageRenderTime 25ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/view/SEIP143203/City/index.php

https://gitlab.com/sumonaliza12/ATOMIC_PROJECT_SEIP143203_SUMONA_SEIP143203
PHP | 339 lines | 212 code | 119 blank | 8 comment | 34 complexity | 87b84d7316d37a2b3ced19d3955dc87d MD5 | raw file
  1. <?php
  2. require_once("../../../vendor/autoload.php");
  3. use App\BITM\SEIP143203\Message\Message;
  4. if(!isset( $_SESSION)) session_start();
  5. $message1=Message::message();
  6. use App\BITM\SEIP143203\City\City;
  7. $obj= new City();
  8. $allData= $obj->index("obj");
  9. ######################## pagination code block#1 of 2 start ######################################
  10. $recordCount= count($allData);
  11. if(isset($_REQUEST['Page']))
  12. $page = $_REQUEST['Page'];
  13. else if(isset($_SESSION['Page']))
  14. $page = $_SESSION['Page'];
  15. else $page = 1;
  16. $_SESSION['Page']= $page;
  17. if(isset($_REQUEST['ItemsPerPage']))
  18. $itemsPerPage = $_REQUEST['ItemsPerPage'];
  19. else if(isset($_SESSION['ItemsPerPage']))
  20. $itemsPerPage = $_SESSION['ItemsPerPage'];
  21. else $itemsPerPage = 3;
  22. $_SESSION['ItemsPerPage']= $itemsPerPage;
  23. $pages = ceil($recordCount/$itemsPerPage);
  24. $someData = $obj->indexPaginator($page,$itemsPerPage);
  25. $serial = (($page-1) * $itemsPerPage) +1;
  26. ####################### pagination code block#1 of 2 end #########################################
  27. ################## search block 1 of 5 start ##################
  28. if(isset($_REQUEST['search']) )$allData = $obj->search($_REQUEST);
  29. $availableKeywords=$obj->getAllKeywords();
  30. $comma_separated_keywords= '"'.implode('","',$availableKeywords).'"';
  31. ################## search block 1 of 5 end ##################
  32. ################## search block 2 of 5 start ##################
  33. if(isset($_REQUEST['search']) ) {
  34. $someData = $obj->search($_REQUEST);
  35. $serial = 1;
  36. }
  37. ################## search block 2 of 5 end ##################
  38. ?>
  39. <!--table-->
  40. <!DOCTYPE html>
  41. <html lang="en">
  42. <head>
  43. <meta charset="utf-8">
  44. <title> </title>
  45. <!-- Latest compiled and minified CSS -->
  46. <!-- Latest compiled and minified CSS -->
  47. <link rel="stylesheet" href="../../../resource/Bootstrap/css/bootstrap.min.css">
  48. <!-- Optional theme -->
  49. <link rel="stylesheet" href="../../../resource/Bootstrap/css/bootstrap-theme.min.css">
  50. <!-- <link rel="stylesheet" href="../../../resource/Bootstrap/css/booktitle.css"> -->
  51. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
  52. <!-- required for search, block3 of 5 start -->
  53. <link rel="stylesheet" href="../../../resource/Bootstrap/css/jquery-ui.css">
  54. <script src="../../../resource/Bootstrap/js/jquery-1.12.4.js"></script>
  55. <script src="../../../resource/Bootstrap/js/jquery-ui.js"></script>
  56. <!-- required for search, block3 of 5 end -->
  57. </head>
  58. <style>
  59. .main{
  60. margin-top: 10%;
  61. margin-left: 15%;
  62. margin-right:15%;
  63. background-color:grey;
  64. }
  65. body{
  66. background-image:url("../../../resource/assets/images/general2.jpg");
  67. background-repeat:no-repeat;
  68. background-size: 100% 925px;
  69. }
  70. </style>
  71. <body >
  72. <table>
  73. <tr>
  74. <td width="500">
  75. </td>
  76. <td width="450">
  77. <a href="pdf.php" class="btn btn-primary" role="button">Download as PDF</a>
  78. <a href="xl.php" class="btn btn-primary" role="button">Download as XL</a>
  79. <a href="email.php?list=1" class="btn btn-primary" role="button">Email to friend</a>
  80. </td>
  81. <td width="150">
  82. <!-- required for search, block 4 of 5 start -->
  83. <form id="searchForm" action="index.php" method="get" style="color:darkblue">
  84. <input type="text" value="" id="searchID" name="search" placeholder="Search" width="60" >
  85. <input type="checkbox" name="byName" checked >By Name
  86. <input type="checkbox" name="byCity" checked >By City
  87. <input hidden type="submit" class="btn-primary" value="search">
  88. </form>
  89. <!-- required for search, block 4 of 5 end -->
  90. </td>
  91. </tr>
  92. </table>
  93. <div class="container ">
  94. <div style="margin-top: 40px ;float: right;"> <a href="../index.php" class="btn btn-danger custom btn-lg" role="button">Atomic Project List</a></br></br></div>
  95. <div class="main">
  96. <div class="panel panel-default" >
  97. <div class="panel-heading">
  98. <div class="panel-heading">
  99. <h1 style="text-align: center"> City List</h1>
  100. </div>
  101. </div>
  102. <div class="panel-body">
  103. <div class="table-responsive" >
  104. </br></br></br></br>
  105. <table class="table">
  106. <thead>
  107. <tr>
  108. <th>Serial</th>
  109. <th>ID</th>
  110. <th>Name</th>
  111. <th>City</th>
  112. <th>Action</th>
  113. </tr>
  114. </thead>
  115. <tbody>
  116. <tr>
  117. <?php
  118. $serial=0;
  119. foreach($someData as $oneData){ ########### Traversing $someData is Required for pagination #############
  120. $serial++; ?>
  121. <td><?php echo $serial?></td>
  122. <td><?php echo $oneData->id?></td>
  123. <td><?php echo $oneData->name?></td>
  124. <td><?php echo $oneData->city_name?></td>
  125. <td><a href="view.php?id=<?php echo $oneData->id ?>" class="btn btn-primary" role="button">View</a>
  126. <a href="edit.php?id=<?php echo$oneData->id ?>" class="btn btn-info" role="button">Edit</a>
  127. <a href="delete.php?id=<?php echo$oneData->id ?>" class="btn btn-danger" role="button" id="delete" Onclick="return ConfirmDelete()">Delete</a>
  128. <a href="trash.php?id=<?php echo $oneData->id ?>" class="btn btn-info" role="button">Trash</a>
  129. </td>
  130. </tr>
  131. <?php }?>
  132. <a href="create.php" class="btn btn-primary role="button"> Add new City</a> &nbsp;&nbsp;&nbsp;
  133. <a href="multipleTrash.php " class="btn btn-info role=" button">Multiple Trash </a>
  134. <a href="trashed.php " class="btn btn-primary role="button"> View Trash List </a>
  135. <a href="multipleDelete.php " class="btn btn-danger role="button"> Multiple Delete </a>
  136. </tbody>
  137. </table>
  138. <div id="confirmation_message" style="color:red;">
  139. <?php echo $message1 ?>
  140. </div>
  141. </div>
  142. </div>
  143. </div>
  144. </div>
  145. </div>
  146. <script>
  147. $(document).ready(function(){
  148. $(function() {
  149. $('#confirmation_message').delay(3000).fadeOut();
  150. });
  151. });
  152. </script>
  153. <script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
  154. <!-- Latest compiled and minified JavaScript -->
  155. <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
  156. <!-- ######################## pagination code block#2 of 2 start ###################################### -->
  157. <div align="left" class="container">
  158. <ul class="pagination">
  159. <?php
  160. $pageMinusOne = $page -1;
  161. if($page>1) echo "<li><a href='index.php?Page=$pageMinusOne'>" . "Previous" . '</a></li>';
  162. //echo '<li><a href="">' . "Previous" . '</a></li>';
  163. for($i=1;$i<=$pages;$i++)
  164. {
  165. if($i==$page) echo '<li class="active"><a href="">'. $i . '</a></li>';
  166. else echo "<li><a href='?Page=$i'>". $i . '</a></li>';
  167. }
  168. $pagePlusOne=$page+1;
  169. echo "<li><a href='index.php?Page=$pagePlusOne'>" . "Next" . '</a></li>';
  170. ?>
  171. <select class="form-control" name="ItemsPerPage" id="ItemsPerPage" onchange="javascript:location.href = this.value;" >
  172. <?php
  173. if($itemsPerPage==3 ) echo '<option value="?ItemsPerPage=3" selected >Show 3 Items Per Page</option>';
  174. else echo '<option value="?ItemsPerPage=3" style="float: right">Show 3 Items Per Page</option>';
  175. if($itemsPerPage==4 ) echo '<option value="?ItemsPerPage=4" selected >Show 4 Items Per Page</option>';
  176. else echo '<option value="?ItemsPerPage=4" style="float: right">Show 4 Items Per Page</option>';
  177. if($itemsPerPage==5 ) echo '<option value="?ItemsPerPage=5" selected >Show 5 Items Per Page</option>';
  178. else echo '<option value="?ItemsPerPage=5" style="float: right">Show 5 Items Per Page</option>';
  179. if($itemsPerPage==6 ) echo '<option value="?ItemsPerPage=6"selected >Show 6 Items Per Page</option>';
  180. else echo '<option value="?ItemsPerPage=6" style="float: right">Show 6 Items Per Page</option>';
  181. if($itemsPerPage==10 ) echo '<option value="?ItemsPerPage=10"selected >Show 10 Items Per Page</option>';
  182. else echo '<option value="?ItemsPerPage=10" style="float: right">Show 10 Items Per Page</option>';
  183. if($itemsPerPage==15 ) echo '<option value="?ItemsPerPage=15"selected >Show 15 Items Per Page</option>';
  184. else echo '<option value="?ItemsPerPage=15" style="float: right">Show 15 Items Per Page</option>';
  185. ?>
  186. </select>
  187. </ul>
  188. </div>
  189. <!-- ######################## pagination code block#2 of 2 end ###################################### -->
  190. </body>
  191. </html>
  192. <!-- required for search, block 5 of 5 start -->
  193. <script>
  194. $(function() {
  195. var availableTags = [
  196. <?php
  197. echo $comma_separated_keywords;
  198. ?>
  199. ];
  200. // Filter function to search only from the beginning of the string
  201. $( "#searchID" ).autocomplete({
  202. source: function(request, response) {
  203. var results = $.ui.autocomplete.filter(availableTags, request.term);
  204. results = $.map(availableTags, function (tag) {
  205. if (tag.toUpperCase().indexOf(request.term.toUpperCase()) === 0) {
  206. return tag;
  207. }
  208. });
  209. response(results.slice(0, 15));
  210. }
  211. });
  212. $( "#searchID" ).autocomplete({
  213. select: function(event, ui) {
  214. $("#searchID").val(ui.item.label);
  215. $("#searchForm").submit();
  216. }
  217. });
  218. });
  219. </script>
  220. <!-- required for search, block5 of 5 end -->