PageRenderTime 31ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 0ms

/view/SEIP143467/Birthday/index.php

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