PageRenderTime 43ms CodeModel.GetById 5ms RepoModel.GetById 1ms app.codeStats 0ms

/views/Admin/indexcopy.php

https://gitlab.com/ehfahad/Library_Management_System
PHP | 356 lines | 307 code | 30 blank | 19 comment | 16 complexity | 4c17b85f7686581d57759ff11f9c90cb MD5 | raw file
  1. <?php
  2. session_start();
  3. include_once('../../vendor/autoload.php');
  4. use App\Library\Library;
  5. use App\Message\Message;
  6. use App\Utility\Utility;
  7. use App\Admin\Auth;
  8. $auth = new Auth();
  9. //if (!$auth->logged_in())
  10. // Utility::redirect("admin_login.php");
  11. $logged_in = true;
  12. $book= new Library;
  13. $book->prepare($_GET);
  14. $singleItem=$book->view();
  15. //Utility::d($singleItem);
  16. $auth = new Auth();
  17. if (!$auth->logged_in())
  18. Utility::redirect("admin_login.php");
  19. $logged_in = true;
  20. if (array_key_exists("itemPerPage", $_SESSION)) {
  21. if (array_key_exists("itemPerPage", $_GET))
  22. $_SESSION['itemPerPage'] = $_GET['itemPerPage'];
  23. } else
  24. $_SESSION['itemPerPage'] = 5;
  25. $itemPerPage = $_SESSION['itemPerPage'];
  26. $obj = new Library();
  27. $totalItem = $obj->count();
  28. //echo $totalItem;
  29. $totalPage = ceil($totalItem / $itemPerPage);
  30. if (array_key_exists("pageNumber", $_GET))
  31. $pageNumber = $_GET['pageNumber'];
  32. else
  33. $pageNumber = 1;
  34. $pagination = "";
  35. for ($count = 1; $count <= $totalPage; $count++) {
  36. $class = ($pageNumber == $count) ? "active" : "";
  37. $pagination .= "<li class='$class'><a href='index.php?pageNumber=$count'>$count</a></li>";
  38. }
  39. $pageStartFrom = $itemPerPage * ($pageNumber - 1);
  40. //$allInfo = $obj->paginator($pageStartFrom,$itemPerPage);
  41. if (strtoupper($_SERVER['REQUEST_METHOD'] == 'GET')) {
  42. $allInfo = $obj->paginator($pageStartFrom, $itemPerPage);
  43. }
  44. if (strtoupper($_SERVER['REQUEST_METHOD'] == 'GET') && isset($_GET['category'])) {
  45. $obj->prepare($_GET);
  46. $allInfo = $obj->index();
  47. }
  48. if ((strtoupper($_SERVER['REQUEST_METHOD'] == 'GET')) && isset($_GET['search'])) {
  49. $obj->prepare($_GET);
  50. $allInfo = $obj->index();
  51. }
  52. //Utility::dd($itemPerPage);
  53. //$availableTitle=$obj->getAllTitle();
  54. //$comma_separated= '"'.implode('","',$availableTitle).'"';
  55. //
  56. //$availableDescription=$obj->getAllDescription();
  57. //$comma_separated2= '"'.implode('","',$availableDescription).'"';
  58. ////Utility::dd($comma_separated);
  59. ?>
  60. <!DOCTYPE html>
  61. <html>
  62. <head>
  63. <title>Library Management System</title>
  64. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  65. <!-- Bootstrap -->
  66. <link href="../../Resources/bootstrap/css/bootstrap.min.css" rel="stylesheet">
  67. <!-- styles -->
  68. <link href="../../Resources/bootstrap/css/styles.css" rel="stylesheet">
  69. <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
  70. <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
  71. <!--[if lt IE 9]>
  72. <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
  73. <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
  74. <![endif]-->
  75. </head>
  76. <body>
  77. <div class="header">
  78. <div class="container-fluid">
  79. <div class="row">
  80. <div class="col-md-4">
  81. <!-- Logo -->
  82. <div class="logo">
  83. <h1><a href="index.php">Library Management System</a></h1>
  84. </div>
  85. </div>
  86. <div class="col-md-4">
  87. <div class="row">
  88. <div class="col-lg-12">
  89. <div>
  90. <form style="float: right" class="form-inline" action="index.php" method="get">
  91. <input size="50" type="text" class="form-control " name="search" placeholder="Search...">
  92. <button class="btn btn-primary" type="button" >Search</button>
  93. </span>
  94. </form>
  95. </div>
  96. </div>
  97. </div>
  98. </div>
  99. <div class="col-md-4">
  100. <div class="navbar navbar-inverse" role="banner">
  101. <nav class="collapse navbar-collapse bs-navbar-collapse navbar-right" role="navigation">
  102. <ul class="nav navbar-nav">
  103. <li class="dropdown">
  104. <a href="" class="dropdown-toggle" data-toggle="dropdown">Downloads <b class="caret"></b></a>
  105. <ul class="dropdown-menu animated fadeInUp">
  106. <li>
  107. <a href="pdf.php" class="btn btn-default" role="button">Download As PDF</a>
  108. <a href="xl.php" class="btn btn-default" role="button">Download As XL File</a>
  109. </li>
  110. </ul>
  111. </li>
  112. </ul>
  113. <ul class="nav navbar-nav">
  114. <li class="dropdown">
  115. <a href="" class="dropdown-toggle" data-toggle="dropdown">Pagination <b class="caret"></b></a>
  116. <ul class="dropdown-menu animated fadeInUp">
  117. <li>
  118. <form role="form">
  119. <div class=" form-group form-inline margintop">
  120. Item Per Page :
  121. <label class="lablewidth" for="sel1"></label>
  122. <select class="form-control formwidth" id="sel1" name="itemPerPage">
  123. <option <?php if($itemPerPage==5): ?> selected <?php endif;?> >5</option>
  124. <option <?php if($itemPerPage==10): ?> selected <?php endif;?> >10</option>
  125. <option <?php if($itemPerPage==15): ?> selected <?php endif;?> >15</option>
  126. <option <?php if($itemPerPage==20): ?> selected <?php endif;?> >20</option>
  127. <option <?php if($itemPerPage==25): ?> selected <?php endif;?> >25</option>
  128. </select>
  129. <button class=" btn btn-default buttonwidth" type="submit">Go!</button>
  130. </div>
  131. </form>
  132. </li>
  133. </ul>
  134. </li>
  135. </ul>
  136. <ul class="nav navbar-nav">
  137. <li class="dropdown">
  138. <a href="" class="dropdown-toggle" data-toggle="dropdown">My Account <b class="caret"></b></a>
  139. <ul class="dropdown-menu animated fadeInUp">
  140. <li><a href="admin_logout.php">Logout</a></li>
  141. </ul>
  142. </li>
  143. </ul>
  144. </nav>
  145. </div>
  146. </div>
  147. </div>
  148. </div>
  149. </div>
  150. <div class="page-content">
  151. <div class="row">
  152. <div class="col-md-2">
  153. <div class="sidebar content-box" style="display: block;">
  154. <ul class="nav">
  155. <!-- Main menu -->
  156. <li class="current"><a href="index.php"><i class="glyphicon glyphicon-home"></i> Dashboard</a></li>
  157. <li><a href="forms.php"><i class="glyphicon glyphicon-tasks"></i> Add Book</a></li>
  158. <li><a href="requested_books.php"><i class="glyphicon glyphicon-book"></i> Requsted Book</a></li>
  159. <li><a href="issued_book.php"><i class="glyphicon glyphicon-book"></i> Issued Book</a></li>
  160. <li><a href="return_book.php"><i class="glyphicon glyphicon-backward"></i> Return Book</a></li>
  161. <li><a href="admin_panel.php"><i class="glyphicon glyphicon-backward"></i> Admin Panel</a></li>
  162. <li class="submenu">
  163. <a href="#">
  164. <i class="glyphicon glyphicon-list"></i> Pages
  165. <span class="caret pull-right"></span>
  166. </a>
  167. <!-- Sub menu -->
  168. <ul>
  169. <li><a href="../../index.php">Normal Index</a></li>
  170. <li><a href="../index.php">User Index</a></li>
  171. </ul>
  172. </li>
  173. </ul>
  174. </div>
  175. </div>
  176. <div style="min-height: 610px; width: 80%" class="col-md-10">
  177. <div class="container">
  178. <h2>Edit Book</h2>
  179. <form class="form-group " role="form" method="post" action="update_book.php" enctype="multipart/form-data">
  180. <div class="form-group">
  181. <input class="form-control" type="hidden" name="id" id="title" value="<?php echo $singleItem->id?>">
  182. <label>Book Name:</label>
  183. <input type="text" name="name" class="form-control" id="name" placeholder="Enter Book Name" value="<?php echo $singleItem->name?>">
  184. <label>Author Name:</label>
  185. <input type="text" name="author" class="form-control" id="author" placeholder="Enter Author Name" value="<?php echo $singleItem->author?>">
  186. <label>Edition:</label>
  187. <input type="text" name="edition" class="form-control" id="edition" placeholder="Enter Edition" value="<?php echo $singleItem->edition?>">
  188. <label>Cover</label>
  189. <input type="file" name="cover" class="form-control" >
  190. <img src="../../Resources/Images/<?php echo $singleItem->cover?>"alt="cover" height="421px" width="270px" class="img-responsive">
  191. </div>
  192. <div class="form-group">
  193. <label class="col-md-2 control-label">Select Location </label>
  194. <div class="col-md-4">
  195. <select class="form-control" name="location" id="sel1">
  196. <option>Select any</option>
  197. <option <?php if($singleItem->location=="Shelf 1"):?>selected<?php endif ?>>Shelf 1</option>
  198. <option <?php if($singleItem->location=="Shelf 2"):?>selected<?php endif ?>>Shelf 2</option>
  199. <option <?php if($singleItem->location=="Shelf 3"):?>selected<?php endif ?>>Shelf 3</option>
  200. <option <?php if($singleItem->location=="Shelf 4"):?>selected<?php endif ?>>Shelf 4</option>
  201. </select>
  202. </div>
  203. <label class="col-md-2 control-label">Select Category </label>
  204. <div class="col-md-4">
  205. <select class="form-control" name="category" id="sel1">
  206. <option>Select any</option>
  207. <option <?php if($singleItem->category=="Science Fiction"):?>selected<?php endif ?>>Science Fiction</option>
  208. <option <?php if($singleItem->category=="Novel"):?>selected<?php endif ?>>Novel</option>
  209. <option <?php if($singleItem->category=="Physics"):?>selected<?php endif ?>>Physics</option>
  210. <option <?php if($singleItem->category=="Programming"):?>selected<?php endif ?>>Programming</option>
  211. <option <?php if($singleItem->category=="Reference Book"):?>selected<?php endif ?>>Reference Book</option>
  212. </select>
  213. </div>
  214. <label>amount</label>
  215. <input type="number" name="amount" class="form-control" id="amount" placeholder="Enter Number" value="<?php echo $singleItem->amount?>">
  216. </div>
  217. <button type="submit" class="btn btn-primary">Update</button>
  218. <a href="index.php" class="btn btn-warning">Cancel</a>
  219. </form>
  220. </div>
  221. </div>
  222. </div>
  223. </div>
  224. </div>
  225. </div>
  226. <footer>
  227. <div class="container">
  228. <div class="copy text-center">
  229. Copyright 2016 <b>Core i5</b>
  230. </div>
  231. </div>
  232. </footer>
  233. <script>
  234. $('#message').show().delay(2840).fadeOut();
  235. // $(document).ready(function(){
  236. // $("#delete").click(function(){
  237. // if (!confirm("Do you want to delete")){
  238. // return false;
  239. // }
  240. // });
  241. // });
  242. function ConfirmDelete()
  243. {
  244. var x = confirm("Are you sure you want to delete?");
  245. if (x)
  246. return true;
  247. else
  248. return false;
  249. }
  250. $('#multiple_delete').on('click',function(){
  251. document.forms[0].action="deleteMultiple.php";
  252. $('#multiple').submit();
  253. });
  254. </script>
  255. <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
  256. <script src="https://code.jquery.com/jquery.js"></script>
  257. <!-- Include all compiled plugins (below), or include individual files as needed -->
  258. <script src="../../Resources/bootstrap/js/bootstrap.min.js"></script>
  259. <script src="../../Resources/bootstrap/js/custom.js"></script>
  260. </body>
  261. </html>