PageRenderTime 54ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/views/SEIP149551/City/index.php

https://gitlab.com/avijit_kar/avijit_kar_149551_B35_atomic_project
PHP | 230 lines | 151 code | 71 blank | 8 comment | 31 complexity | c0bdbc84f598fc5b9f8e21cd3432a62a MD5 | raw file
  1. <head>
  2. <link rel="stylesheet" href="../../../resource/assets/bootstrap/css/bootstrap.min.css">
  3. <link rel="stylesheet" href="../../../resource/assets/font-awesome/css/font-awesome.min.css">
  4. <script src="../../../resource/assets/js/jquery-1.11.1.min.js"></script>
  5. <script src="../../../resource/assets/bootstrap/js/bootstrap.min.js"></script>
  6. <!-- required for search, block3 of 5 start -->
  7. <link rel="stylesheet" href="../../../resource/bootstrap/css/jquery-ui.css">
  8. <script src="../../../resource/assets/bootstrap/js/jquery-1.12.4.js"></script>
  9. <script src="../../../resource/assets/bootstrap/js/jquery-ui.js"></script>
  10. <!-- required for search, block3 of 5 end -->
  11. </head>
  12. <?php
  13. require_once("../../../vendor/autoload.php");
  14. use App\City\City;
  15. use App\Message\Message;
  16. $objcity = new City() ;
  17. $allData=$objcity->index("obj");
  18. ################## search block 1 of 5 start ##################
  19. if(isset($_REQUEST['search']) )$allData = $objcity->search($_REQUEST);
  20. $availableKeywords=$objcity->getAllKeywords();
  21. $comma_separated_keywords= '"'.implode('","',$availableKeywords).'"';
  22. ################## search block 1 of 5 end ##################
  23. ######################## pagination code block#1 of 2 start ######################################
  24. $recordCount= count($allData);
  25. if(isset($_REQUEST['Page'])) $page = $_REQUEST['Page'];
  26. else if(isset($_SESSION['Page'])) $page = $_SESSION['Page'];
  27. else $page = 1;
  28. $_SESSION['Page']= $page;
  29. if(isset($_REQUEST['ItemsPerPage'])) $itemsPerPage = $_REQUEST['ItemsPerPage'];
  30. else if(isset($_SESSION['ItemsPerPage'])) $itemsPerPage = $_SESSION['ItemsPerPage'];
  31. else $itemsPerPage = 3;
  32. $_SESSION['ItemsPerPage']= $itemsPerPage;
  33. $pages = ceil($recordCount/$itemsPerPage);
  34. $someData = $objcity->indexPaginator($page,$itemsPerPage);
  35. $serial = (($page-1) * $itemsPerPage) +1;
  36. ####################### pagination code block#1 of 2 end #########################################
  37. ################## search block 2 of 5 start ##################
  38. if(isset($_REQUEST['search']) ) {
  39. $someData = $objcity->search($_REQUEST);
  40. $serial = 1;
  41. }
  42. ################## search block 2 of 5 end ##################
  43. ?>
  44. <html>
  45. <body>
  46. <table>
  47. <tr>
  48. <td width="500">
  49. <h2>Active List of City</h2>
  50. </td>
  51. <td width="450">
  52. <a href="pdf.php" class="btn btn-primary" role="button">Download as PDF</a>
  53. <a href="xl.php" class="btn btn-primary" role="button">Download as XL</a>
  54. <a href="email.php?list=1" class="btn btn-primary" role="button">Email to friend</a>
  55. </td>
  56. <td width="150">
  57. <!-- required for search, block 4 of 5 start -->
  58. <form id="searchForm" action="index.php" method="get">
  59. <input type="text" value="" id="searchID" name="search" placeholder="Search" width="60" >
  60. <input type="checkbox" name="byName" checked >By Name
  61. <input type="checkbox" name="byCity" checked >By city
  62. <input hidden type="submit" class="btn-primary" value="search">
  63. </form>
  64. <!-- required for search, block 4 of 5 end -->
  65. </td>
  66. </tr>
  67. </table>
  68. <div id="TopMenuBar">
  69. <button type="button" onclick="window.location.href='../index.php'" class=" btn-primary btn-lg">Home</button>
  70. <button type="button" onclick="window.location.href='create.php'" class=" btn-primary btn-lg">Add new</button>
  71. <button type="button" onclick="window.location.href='trashed.php?Page=1'" class=" btn-success btn-lg">Trashed List</button>
  72. </div>
  73. <h1> Active List</h1>
  74. <?php
  75. $serial=1;
  76. echo "<table border='2px'>";
  77. echo"<th>serial</th><th>id</th><th>name</th><th>city</th><th colspan='2'>Action</th>";
  78. foreach($someData as $oneData)
  79. {
  80. echo "<tr>";
  81. echo"<td>$serial</td>";
  82. echo"<td>$oneData->id</td>";
  83. echo"<td>$oneData->name</td>";
  84. echo"<td>$oneData->city</td>";
  85. echo "
  86. <td>
  87. <a href='view.php?id=$oneData->id'><button class='btn-info'>view</button></a>
  88. <a href='edit.php?id=$oneData->id'><button class='btn-primary'>edit</button></a>
  89. <a href='trash.php?id=$oneData->id'><button class='btn-success'>trash</button></a>
  90. <a href='delete.php?id=$oneData->id'><button class='btn-danger'>delete</button></a>
  91. </a>
  92. ";
  93. echo"</tr>";
  94. $serial++;
  95. //$oneDate->book_title."".$oneData->author_name."<br>";
  96. }
  97. echo "</table>";
  98. ?>
  99. <!-- ######################## pagination code block#2 of 2 start ###################################### -->
  100. <div align="left" class="container">
  101. <ul class="pagination">
  102. <?php
  103. echo '<li><a href="">' . "Previous" . '</a></li>';
  104. for($i=1;$i<=$pages;$i++)
  105. {
  106. if($i==$page) echo '<li class="active"><a href="">'. $i . '</a></li>';
  107. else echo "<li><a href='?Page=$i'>". $i . '</a></li>';
  108. }
  109. echo '<li><a href="">' . "Next" . '</a></li>';
  110. ?>
  111. <select class="form-control" name="ItemsPerPage" id="ItemsPerPage" onchange="javascript:location.href = this.value;" >
  112. <?php
  113. if($itemsPerPage==3 ) echo '<option value="?ItemsPerPage=3" selected >Show 3 Items Per Page</option>';
  114. else echo '<option value="?ItemsPerPage=3">Show 3 Items Per Page</option>';
  115. if($itemsPerPage==4 ) echo '<option value="?ItemsPerPage=4" selected >Show 4 Items Per Page</option>';
  116. else echo '<option value="?ItemsPerPage=4">Show 4 Items Per Page</option>';
  117. if($itemsPerPage==5 ) echo '<option value="?ItemsPerPage=5" selected >Show 5 Items Per Page</option>';
  118. else echo '<option value="?ItemsPerPage=5">Show 5 Items Per Page</option>';
  119. if($itemsPerPage==6 ) echo '<option value="?ItemsPerPage=6"selected >Show 6 Items Per Page</option>';
  120. else echo '<option value="?ItemsPerPage=6">Show 6 Items Per Page</option>';
  121. if($itemsPerPage==10 ) echo '<option value="?ItemsPerPage=10"selected >Show 10 Items Per Page</option>';
  122. else echo '<option value="?ItemsPerPage=10">Show 10 Items Per Page</option>';
  123. if($itemsPerPage==15 ) echo '<option value="?ItemsPerPage=15"selected >Show 15 Items Per Page</option>';
  124. else echo '<option value="?ItemsPerPage=15">Show 15 Items Per Page</option>';
  125. ?>
  126. </select>
  127. </ul>
  128. </div>
  129. <!-- ######################## pagination code block#2 of 2 end ###################################### -->
  130. </body>
  131. </html>
  132. <!-- required for search, block 5 of 5 start -->
  133. <script>
  134. $(function() {
  135. var availableTags = [
  136. <?php
  137. echo $comma_separated_keywords;
  138. ?>
  139. ];
  140. // Filter function to search only from the beginning of the string
  141. $( "#searchID" ).autocomplete({
  142. source: function(request, response) {
  143. var results = $.ui.autocomplete.filter(availableTags, request.term);
  144. results = $.map(availableTags, function (tag) {
  145. if (tag.toUpperCase().indexOf(request.term.toUpperCase()) === 0) {
  146. return tag;
  147. }
  148. });
  149. response(results.slice(0, 15));
  150. }
  151. });
  152. $( "#searchID" ).autocomplete({
  153. select: function(event, ui) {
  154. $("#searchID").val(ui.item.label);
  155. $("#searchForm").submit();
  156. }
  157. });
  158. });
  159. </script>