PageRenderTime 28ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/views/Library/Librarian/Book/index.php

https://gitlab.com/tanvir/Library-Management-System
PHP | 322 lines | 291 code | 31 blank | 0 comment | 8 complexity | 6e30f76fbc1cfbf7b04550c6c0f5370d MD5 | raw file
  1. <?php
  2. include '../Authentication/gate.php';
  3. use App\Bitm\Library\Book\Book;
  4. use App\Bitm\Library\Category\Category;
  5. use App\Bitm\Library\Message\Message;
  6. use App\Bitm\Library\Utility\Utility;
  7. $book = new Book();
  8. $allBook = $book->prepare($_POST)->count();
  9. $category = new Category();
  10. $allCategory = $category->prepare($_POST)->index();
  11. $allTitle=$book->title();
  12. $comma_separated_title= '"'.implode('","',$allTitle).'"';
  13. $allAuthor=$book->author();
  14. $comma_separated_author= '"'.implode('","',$allAuthor).'"';
  15. $comma_separated='"'.$comma_separated_title.$comma_separated_author.'"';
  16. $totalItem=$book->count();
  17. if(array_key_exists('itemPerPage',$_SESSION)) {
  18. if(array_key_exists('itemPerPage',$_GET)){
  19. $_SESSION['itemPerPage']=$_GET['itemPerPage'];
  20. }
  21. }
  22. else{
  23. $_SESSION['itemPerPage']=5;
  24. }
  25. $itemPerPage= $_SESSION['itemPerPage'];
  26. $noOfPage=ceil($totalItem/$itemPerPage);
  27. $pagination="";
  28. if(array_key_exists('pageNo',$_GET)){
  29. $pageNo= $_GET['pageNo'];
  30. }else {
  31. $pageNo = 1;
  32. }
  33. for($i=1;$i<=$noOfPage;$i++){
  34. $active=($i==$pageNo)?"active":"";
  35. $pagination.="<li class='$active'><a href='index.php?pageNo=$i'>$i</a></li>";
  36. }
  37. $pageStartFrom=$itemPerPage*($pageNo-1);
  38. if(strtoupper($_SERVER['REQUEST_METHOD']=='GET')) {
  39. $allBook = $book->paginator($pageStartFrom, $itemPerPage);
  40. }
  41. if(strtoupper($_SERVER['REQUEST_METHOD']=='POST')) {
  42. $allBook = $book->prepare($_POST)->index();
  43. }
  44. if(strtoupper(($_SERVER['REQUEST_METHOD']=='GET')) && isset($_GET['search'])) {
  45. $allBook = $book->prepare($_GET)->index();
  46. }
  47. ?>
  48. <!DOCTYPE html>
  49. <html lang="en">
  50. <head>
  51. <meta charset="utf-8">
  52. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  53. <meta name="viewport" content="width=device-width, initial-scale=1">
  54. <meta name="description" content="">
  55. <meta name="author" content="">
  56. <title>Dashboard - Library Management System 2016</title>
  57. <!-- Bootstrap Core CSS -->
  58. <link href="../../../../resource/css/bootstrap.min.css" rel="stylesheet">
  59. <!-- Custom CSS -->
  60. <link href="../../../../resource/css/sb-admin.css" rel="stylesheet">
  61. <!-- Morris Charts CSS -->
  62. <link href="../../../../resource/css/plugins/morris.css" rel="stylesheet">
  63. <!-- Custom Fonts -->
  64. <link href="../../../../resource/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
  65. <link rel="stylesheet" href="//code.jquery.com/ui/1.12.0/themes/base/jquery-ui.css">
  66. <script src="https://code.jquery.com/ui/1.12.0/jquery-ui.js"></script>
  67. <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
  68. <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
  69. <!--[if lt IE 9]>
  70. <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
  71. <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
  72. <![endif]-->
  73. </head>
  74. <body style=" background-color: #fff;">
  75. <div id="wrapper">
  76. <!-- Navigation -->
  77. <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
  78. <!-- Brand and toggle get grouped for better mobile display -->
  79. <div class="navbar-header">
  80. <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
  81. <span class="sr-only">Toggle navigation</span>
  82. <span class="icon-bar"></span>
  83. <span class="icon-bar"></span>
  84. <span class="icon-bar"></span>
  85. </button>
  86. <a class="navbar-brand" href=""><i class="fa fa-fw fa-dashboard"></i> Library Management System - Dashboard</a>
  87. </div>
  88. <!-- Sidebar Menu Items - These collapse to the responsive navigation menu on small screens -->
  89. <div class="collapse navbar-collapse navbar-ex1-collapse">
  90. <ul class="nav navbar-nav side-nav">
  91. <li>
  92. <a href="../dashboard.php"><i class="fa fa-fw fa-home"></i> Home</a>
  93. </li>
  94. <li>
  95. <a href="create.php"> <i class="fa fa-fw fa-book"></i> Add Books</a>
  96. </li>
  97. <li class="active">
  98. <a href="index.php"><i class="fa fa-fw fa-th"></i> All Book in Library</a>
  99. </li>
  100. <li>
  101. <a href="../Student/create.php"><i class="fa fa-fw fa-male"></i> Add Students</a>
  102. </li>
  103. <li>
  104. <a href="../Student/index.php"><i class="fa fa-fw fa-users"></i> All Students List</a>
  105. </li>
  106. <li>
  107. <a href="../Issue/create.php"><i class="fa fa-fw fa-sign-out"></i> Issue/Return Book</a>
  108. </li>
  109. <li>
  110. <a href="../Issue/index.php"><i class="fa fa-fw fa-list-ul"></i> View all books currently issued</a>
  111. </li>
  112. <li>
  113. <a href="../Authentication/logout.php"><i class="fa fa-fw fa-wrench"></i>Logout</a>
  114. </li>
  115. </ul>
  116. </div>
  117. </nav>
  118. <div id="page-wrapper">
  119. <!-- Page Heading -->
  120. <div class="row">
  121. <div class="col-lg-12">
  122. <h1 class="page-header breadcrumb">
  123. All Books List
  124. </h1>
  125. </div>
  126. </div>
  127. <div class="container-fluid">
  128. <!-- Page Heading -->
  129. <div class="row">
  130. <div class="col-lg-12">
  131. <div id="message">
  132. <?php
  133. if((array_key_exists('message',$_SESSION))&& !empty($_SESSION['message'])) {
  134. echo Message::message();
  135. }
  136. ?>
  137. </div>
  138. <form role="form" action="index.php" method="post" class="form-inline">
  139. <div class="form-group col-lg-4">
  140. <label>Filter by Title:</label>
  141. <input class="form-control" type="text" name="filterByTitle" value="" id="title">
  142. </div>
  143. <button type="submit" class="btn btn-primary">Go!</button>
  144. </form>
  145. <br>
  146. <div class="table-responsive col-md-12 text-center ">
  147. <form role="form" action="index.php" method="get" class="form-inline navbar-left">
  148. <div class="form-group">
  149. <label>Search:</label>
  150. <input class="form-control" type="text" name="search" value="" id="search">
  151. <button type="submit" class="btn btn-primary">Search</button>
  152. </div>
  153. <br>
  154. </form>
  155. <form role="form" action="index.php" class="navbar-right">
  156. <select class="form-control" id="sel1" name="itemPerPage" onchange='this.form.submit()'>
  157. <option<?php if($itemPerPage==5){?> selected <?php }?>>5</option>
  158. <option<?php if($itemPerPage==10){?> selected <?php }?>>10</option>
  159. <option<?php if($itemPerPage==15){?> selected <?php }?>>15</option>
  160. <option<?php if($itemPerPage==20){?> selected <?php }?>>20</option>
  161. <option<?php if($itemPerPage==25){?> selected <?php }?>>25</option>
  162. </select><noscript><input type="submit" value="Submit"></noscript>
  163. </form> <br/>
  164. <table class="table table-striped table-bordered" style="margin-top: 30px">
  165. <thead align="center">
  166. <tr>
  167. <th>Sl.</th>
  168. <th>Acc No.</th>
  169. <th>Book Title</th>
  170. <th>Category</th>
  171. <th>Author</th>
  172. <th class="action">copies</th>
  173. <th>Book Pub</th>
  174. <th>Publisher Name</th>
  175. <th>ISBN</th>
  176. <th>Copyright Year</th>
  177. <th>Date Added</th>
  178. <th class="action">Action</th>
  179. </tr>
  180. </thead>
  181. <tbody>
  182. <?php
  183. $sl=0;
  184. foreach ($allBook as $book){
  185. $sl++?>
  186. <tr>
  187. <td><?php echo $sl+$pageStartFrom?></td>
  188. <td><?php echo $book->book_id ?></td>
  189. <td><?php echo $book->book_title ?></td>
  190. <td><?php echo $book->category_id ?></td>
  191. <td><?php echo $book->author ?></td>
  192. <td><?php echo $book->book_copies ?></td>
  193. <td><?php echo $book->book_pub ?></td>
  194. <td><?php echo $book->publisher_name ?></td>
  195. <td><?php echo $book->isbn ?></td>
  196. <td><?php echo $book->copyright_year ?></td>
  197. <td><?php echo $book->date_added ?></td>
  198. <td>
  199. <a href="edit.php?book_id=<?php echo $book->book_id ?>" ><i class="fa fa-edit"></i></a>
  200. <a href="delete.php?book_id=<?php echo $book->book_id ?>"><i class="fa fa-trash"></i></a>
  201. </td>
  202. </tr>
  203. <?php }?>
  204. </tbody>
  205. </table>
  206. <?php if(strtoupper($_SERVER['REQUEST_METHOD']=='GET')) { ?>
  207. <ul class="pagination navbar-right">
  208. <?php if( $pageNo > 1 ): ?>
  209. <li><a href="index.php?pageNo=<?php $prev = $pageNo-1; echo $prev; ?>">Prev</a></li>
  210. <?php endif; ?>
  211. <?php echo $pagination; ?>
  212. <?php if( $pageNo < $noOfPage ): ?>
  213. <li><a href="index.php?pageNo=<?php $next = $pageNo+1; echo $next;?>">Next</a></li>
  214. <?php endif; ?>
  215. </ul>
  216. <?php } ?>
  217. </div>
  218. </div>
  219. </div>
  220. </div>
  221. <!-- /.container-fluid -->
  222. </div>
  223. </div>
  224. <!-- jQuery -->
  225. <script src="../../../../resource/js/jquery.js"></script>
  226. <!-- Bootstrap Core JavaScript -->
  227. <script src="../../../../resource/js/bootstrap.min.js"></script>
  228. <script>
  229. $('#message').show().delay(3000).fadeOut();
  230. </script>
  231. <script>
  232. $( function() {
  233. var availableTags = [
  234. <?php echo $comma_separated_title?>
  235. ];
  236. $( "#title" ).autocomplete({
  237. source: availableTags
  238. });
  239. } );
  240. </script>
  241. <script>
  242. $( function() {
  243. var availableTags = [
  244. <?php echo $comma_separated_author?>
  245. ];
  246. $( "#author" ).autocomplete({
  247. source: availableTags
  248. });
  249. } );
  250. </script>
  251. <script>
  252. $( function() {
  253. var availableTags = [
  254. <?php echo $comma_separated?>
  255. ];
  256. $( "#search" ).autocomplete({
  257. source: availableTags
  258. });
  259. } );
  260. </script>
  261. <!-- Morris Charts JavaScript -->
  262. <script src="../../../../resource/js/plugins/morris/raphael.min.js"></script>
  263. <script src="../../../../resource/js/plugins/morris/morris.min.js"></script>
  264. <script src="../../../../resource/js/plugins/morris/morris-data.js"></script>
  265. </body>
  266. </html>