PageRenderTime 40ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/views/SEIP142691/BookTitle/index.php

https://gitlab.com/istiyakaminsanto/Atomic_project_IstiyakAmin_142691_B35
PHP | 368 lines | 322 code | 40 blank | 6 comment | 15 complexity | 9425bfd571a91d793e4ed0dcbfadb9ae MD5 | raw file
  1. <?php
  2. require_once("../../../vendor/autoload.php");
  3. use App\Utility\Utility;
  4. use App\BookTitle\BookTitle;
  5. use App\Message\Message;
  6. if(!isset($_SESSION) )session_start();
  7. use App\User\User;
  8. use App\User\Auth;
  9. $obj= new User();
  10. $obj->prepare($_SESSION);
  11. $singleUser = $obj->view();
  12. $auth= new Auth();
  13. $status = $auth->prepare($_SESSION)->logged_in();
  14. if(!$status) {
  15. Utility::redirect('../login.php');
  16. return;
  17. }
  18. $objBookTitle = new BookTitle();
  19. $allData = $objBookTitle->index("obj");
  20. $serial = 1;
  21. ################## search block 1 of 5 start ##################
  22. if(isset($_REQUEST['search']) )$allData = $objBookTitle->search($_REQUEST);
  23. $availableKeywords=$objBookTitle->getAllKeywords();
  24. $comma_separated_keywords= '"'.implode('","',$availableKeywords).'"';
  25. ################## search block 1 of 5 end ##################
  26. ######################## pagination code block#1 of 2 start ######################################
  27. $recordCount= count($allData);
  28. if(isset($_REQUEST['Page'])) $page = $_REQUEST['Page'];
  29. else if(isset($_SESSION['Page'])) $page = $_SESSION['Page'];
  30. else $page = 1;
  31. $_SESSION['Page']= $page;
  32. if(isset($_REQUEST['ItemsPerPage'])) $itemsPerPage = $_REQUEST['ItemsPerPage'];
  33. else if(isset($_SESSION['ItemsPerPage'])) $itemsPerPage = $_SESSION['ItemsPerPage'];
  34. else $itemsPerPage = 5;
  35. $_SESSION['ItemsPerPage']= $itemsPerPage;
  36. $pages = ceil($recordCount/$itemsPerPage);
  37. $someData = $objBookTitle->indexPaginator($page,$itemsPerPage);
  38. $serial = (($page-1) * $itemsPerPage) +1;
  39. ####################### pagination code block#1 of 2 end #########################################
  40. ################## search block 2 of 5 start ##################
  41. if(isset($_REQUEST['search']) ) {
  42. $someData = $objBookTitle->search($_REQUEST);
  43. $serial = 1;
  44. }
  45. ################## search block 2 of 5 end ##################
  46. ?>
  47. <!DOCTYPE html>
  48. <html lang="en" xmlns="http://www.w3.org/1999/html" xmlns="http://www.w3.org/1999/html">
  49. <head>
  50. <meta charset="UTF-8">
  51. <title>Book Title</title>
  52. <link rel="icon"
  53. type="image/png"
  54. href="../../../resource/assets/icon/book/book-24-179933.png">
  55. <link rel="stylesheet" href="../../../font-awesome/css/font-awesome.min.css">
  56. <link href="https://fonts.googleapis.com/css?family=Yellowtail" rel="stylesheet">
  57. <link rel="stylesheet" href="../../../resource/assets/css/bootstrap.css">
  58. <link rel="stylesheet" href="../../../resource/assets/css/bootstrap-responsive.css">
  59. <link rel="stylesheet" href="../../../resource/assets/css/cssanimation.css">
  60. <link rel="stylesheet" href="../../../resource/assets/style.css">
  61. <style>
  62. </style>
  63. <!-- required for search, block3 of 5 start -->
  64. <link rel="stylesheet" href="../../../resource/assets/css/jquery-ui.css">
  65. <script src="../../../resource/assets/js/jquery-1.12.4.js"></script>
  66. <script src="../../../resource/assets/js/jquery-ui.js"></script>
  67. <!-- required for search, block3 of 5 end -->
  68. <script type="text/javascript">
  69. function confirmation() {
  70. var answer = confirm("Are you sure want to delete")
  71. if (answer){
  72. alert("You successfully deleted")
  73. }
  74. else{
  75. alert("You don't delete")
  76. }
  77. }
  78. function softDelete() {
  79. alert("You successfully deleted from the list.if you want to recover it go to trash list")
  80. }
  81. </script>
  82. </head>
  83. <body>
  84. <div class="container">
  85. <div class="container-fluid">
  86. <div class="social-bookmark">
  87. <a href="https://www.facebook.com/istiyakaminsanto" target="_blank"><img src="../../../resource/img/social_bookmark/facebook.png" alt=""></a>
  88. <a href="https://twitter.com/istiyakamin" target="_blank"><img src="../../../resource/img/social_bookmark/twitter.png" alt=""></a>
  89. <a href="https://www.linkedin.com/in/istiyak-amin-s-06b0aa101" target="_blank"><img src="../../../resource/img/social_bookmark/in.png" alt=""></a>
  90. <a href="https://www.instagram.com/istiyka_amin" target="_blank"><img src="../../../resource/img/social_bookmark/instra.png" alt=""></a>
  91. <a href="https://plus.google.com/u/1/104189513778110467182" target="_blank"><img src="../../../resource/img/social_bookmark/google.png" alt=""></a>
  92. </div>
  93. <header>
  94. <div class="logo_area">
  95. <p class="logo cssanimation fadeInLeft">Atomic Project</p>
  96. <h3 class="subLogo cssanimation fadeInRight">SEIP-142691 Batch-35</h3>
  97. </div>
  98. <nav class="navbar navbar-inner">
  99. <ul class="nav">
  100. <li class="active"><a href="../BookTitle/index.php">BOOKTITLE</a></li>
  101. <li><a href="../Birthday/index.php">BIRTHDAY</a></li>
  102. <li><a href="../Gender/index.php">GENDER</a></li>
  103. <li><a href="../Email/index.php">EMAIL</a></li>
  104. <li><a href="../Hobbies/index.php">HOBBIES</a></li>
  105. <li><a href="../City/index.php">CITY</a></li>
  106. <li><a href="../ProfilePicture/index.php">PROFILE PICTURE</a></li>
  107. <li><a href="../SummaryOfOrganization/index.php">SUMMARY OF ORGANIZATION</a></li>
  108. </ul>
  109. </nav>
  110. </header>
  111. <!-- login messege start -->
  112. <div><img src="../../../resource/img/booktitle.jpg" alt=""></div>
  113. <p class="title">Booktitle</p>
  114. <?php if((array_key_exists('message',$_SESSION)&& (!empty($_SESSION['message'])))) {
  115. echo "&nbsp;".Message::message();
  116. }
  117. Message::message(NULL);
  118. ?>
  119. <!-- login messege end -->
  120. <div class="container-fluid">
  121. <a href="../BookTitle/create.php">
  122. <button class='btn btn-primary'>
  123. <i class="fa fa-plus-square" aria-hidden="true"></i> Add New
  124. </button>
  125. </a>
  126. <a href="trash.php">
  127. <button class='btn btn-primary'>
  128. <i class="fa fa-list" aria-hidden="true"></i> Trash List
  129. </button>
  130. </a>
  131. <a href="pdf.php">
  132. <button class='btn btn-primary'>
  133. <i class="fa fa-book" aria-hidden="true"></i> Download as PDF
  134. </button>
  135. </a>
  136. <a href="xl.php">
  137. <button class='btn btn-primary'>
  138. <i class="fa fa-file-excel-o" aria-hidden="true"></i> Download as XL
  139. </button>
  140. </a>
  141. <a href="email.php?list=1">
  142. <button class='btn btn-primary'>
  143. <i class="fa fa-send" aria-hidden="true"></i> Email to friend
  144. </button>
  145. </a>
  146. <!-- required for search, block 4 of 5 start -->
  147. <div class="input-group col-md-12" style="float: right">
  148. <form id="searchForm" action="index.php" method="get">
  149. <input type="text" value="" id="searchID" class="search-query " name="search" placeholder="Search" >
  150. <span class="input-group-btn">
  151. <button class="btn btn-danger" type="button" value="search">
  152. <span class="fa fa-search"></span>
  153. </button>
  154. </span><br>
  155. <input type="checkbox" name="byTitle" checked >By Title
  156. <input type="checkbox" name="byAuthor" checked >By Author
  157. </form>
  158. </div>
  159. <!-- required for search, block 4 of 5 end -->
  160. </div>
  161. <div class="container-fluid">
  162. <div class="table-responsive">
  163. <table border=2 class="table table-bordered">
  164. <th> Serial </th>
  165. <th> ID </th>
  166. <th> Book Title </th>
  167. <th> Author Name </th>
  168. <th> Action </th>
  169. <?php foreach($someData as $oneData){
  170. echo "<tr>";
  171. echo "<td> $serial </td>";
  172. echo "<td> $oneData->id </td>";
  173. echo "<td> $oneData->book_title </td>";
  174. echo "<td> $oneData->author_name </td>";
  175. echo "
  176. <td>
  177. <a href='Views.php?id=$oneData->id'>
  178. <button class='btn btn-info'>
  179. <i class=\"fa fa-search-plus\" aria-hidden=\"true\"></i> View
  180. </button>
  181. </a>
  182. <a href='edit.php?id=$oneData->id'>
  183. <button class='btn btn-primary'>
  184. <i class=\"fa fa-pencil\" aria-hidden=\"true\"></i> Edit
  185. </button>
  186. </a>
  187. <a href='softDelete.php?id=$oneData->id'>
  188. <button class='btn btn-warning' onclick='softDelete()' >
  189. <i class=\"fa fa-minus-square\" aria-hidden=\"true\"></i> Soft Delete
  190. </button>
  191. </a>
  192. <a href='delete.php?id=$oneData->id'>
  193. <button class='btn btn-danger' onclick='confirmation()'>
  194. <i class=\"fa fa-trash\" aria-hidden=\"true\"></i> Delete
  195. </button>
  196. </a>
  197. </td>
  198. ";
  199. echo "</tr>";
  200. $serial++;
  201. } ?>
  202. </table>
  203. </div>
  204. </div>
  205. </div>
  206. <!-- ######################## pagination code block#2 of 2 start ###################################### -->
  207. <div class="pagination-centered">
  208. <nav class=" pagination">
  209. <ul class="nav">
  210. <?php
  211. $pageMinusOne = $page-1;
  212. $pagePlusOne = $page+1;
  213. if($page>$pages) Utility::redirect("index.php?Page=$pages");
  214. if($page>1) echo "<li><a href='index.php?Page=$pageMinusOne'>" . "Previous" . "</a></li>";
  215. for($i=1;$i<=$pages;$i++)
  216. {
  217. if($i==$page) echo '<li class="active"><a href="">'. $i . '</a></li>';
  218. else echo "<li><a href='?Page=$i'>". $i . '</a></li>';
  219. }
  220. if($page<$pages) echo "<li><a href='index.php?Page=$pagePlusOne'>" . "Next" . "</a></li>";
  221. ?>
  222. </ul>
  223. </nav>
  224. <select class="form-control" name="ItemsPerPage" id="ItemsPerPage" onchange="javascript:location.href = this.value;">
  225. <?php
  226. if($itemsPerPage==5 ) echo '<option value="?ItemsPerPage=5" selected >Show 5 Items Per Page</option>';
  227. else echo '<option value="?ItemsPerPage=5">Show 5 Items Per Page</option>';
  228. if($itemsPerPage==10 ) echo '<option value="?ItemsPerPage=10"selected >Show 10 Items Per Page</option>';
  229. else echo '<option value="?ItemsPerPage=10">Show 10 Items Per Page</option>';
  230. if($itemsPerPage==15 ) echo '<option value="?ItemsPerPage=15"selected >Show 15 Items Per Page</option>';
  231. else echo '<option value="?ItemsPerPage=15">Show 15 Items Per Page</option>';
  232. ?>
  233. </select>
  234. <div style="float: right" class="container-fluid"><a href="../logout.php"><button class="btn btn-inverse">logout</button></a></div>
  235. </div>
  236. <!-- ######################## pagination code block#2 of 2 end ###################################### -->
  237. <div>
  238. <footer class="modal-footer">@copyright IstiyakAmin All data reserved </footer>
  239. </div>
  240. </div>
  241. </body>
  242. </html>
  243. <!-- required for search, block 5 of 5 start -->
  244. <script>
  245. $(function() {
  246. var availableTags = [
  247. <?php
  248. echo $comma_separated_keywords;
  249. ?>
  250. ];
  251. // Filter function to search only from the beginning of the string
  252. $( "#searchID" ).autocomplete({
  253. source: function(request, response) {
  254. var results = $.ui.autocomplete.filter(availableTags, request.term);
  255. results = $.map(availableTags, function (tag) {
  256. if (tag.toUpperCase().indexOf(request.term.toUpperCase()) === 0) {
  257. return tag;
  258. }
  259. });
  260. response(results.slice(0, 15));
  261. }
  262. });
  263. $( "#searchID" ).autocomplete({
  264. select: function(event, ui) {
  265. $("#searchID").val(ui.item.label);
  266. $("#searchForm").submit();
  267. }
  268. });
  269. });
  270. </script>
  271. <!-- required for search, block5 of 5 end -->