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

/view/SEIP143467/Email/index.php

https://gitlab.com/Princy008/Princy_143467_B_37_Atomic_project
PHP | 326 lines | 221 code | 93 blank | 12 comment | 38 complexity | 16dddd75cf9f3461a8b61ecc0f5799b3 MD5 | raw file
  1. <?php
  2. require_once("../../../vendor/autoload.php");
  3. use App\BITM\SEIP143467\Message\Message;
  4. if(!isset( $_SESSION)) session_start();
  5. $message1=Message::message();
  6. use App\BITM\SEIP143467\Email\Email;
  7. $obj= new Email();
  8. $all_email= $obj->index();
  9. ######################## pagination code block#1 of 2 start ######################################
  10. $recordCount= count($all_email);
  11. if(isset($_REQUEST['Page'])) $page = $_REQUEST['Page'];
  12. else if(isset($_SESSION['Page'])) $page = $_SESSION['Page'];
  13. else $page = 1;
  14. $_SESSION['Page']= $page;
  15. if(isset($_REQUEST['ItemsPerPage'])) $itemsPerPage = $_REQUEST['ItemsPerPage'];
  16. else if(isset($_SESSION['ItemsPerPage'])) $itemsPerPage = $_SESSION['ItemsPerPage'];
  17. else $itemsPerPage = 3;
  18. $_SESSION['ItemsPerPage']= $itemsPerPage;
  19. $pages = ceil($recordCount/$itemsPerPage);
  20. $someData = $obj->indexPaginator($page,$itemsPerPage);
  21. $serial = (($page-1) * $itemsPerPage) +1;
  22. ####################### pagination code block#1 of 2 end #########################################
  23. ####################### pagination code block#1 of 2 end #########################################
  24. ################## search block 1 of 5 start ##################
  25. if(isset($_REQUEST['search']) )$all_email = $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/mail.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"> Email 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>email</th>
  99. <th>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['email']?></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-success" 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="trashed.php" class="btn btn-primary role="button"> View Trashed List</a> &nbsp;&nbsp;&nbsp;
  121. <a href="create.php " class="btn btn-info role="button"> Add new Email</a>
  122. &nbsp;&nbsp;&nbsp;
  123. <button type="button" class="btn btn-primary" id="delete">Delete Selected</button>&nbsp;&nbsp;&nbsp;
  124. <button type="submit" class="btn btn-info">Trash Selected</button>
  125. </tbody>
  126. </table>
  127. <!-- ######################## pagination code block#2 of 2 start ###################################### -->
  128. <div align="left" class="container">
  129. <ul class="pagination">
  130. <?php
  131. $previous=$page-1;
  132. if($previous>0)
  133. {echo "<li><a href='index.php?Page=$previous'>" . "Previous" . '</a></li>';}
  134. for($i=1;$i<=$pages;$i++)
  135. {
  136. if($i==$page) echo '<li class="active"><a href="">'. $i . '</a></li>';
  137. else echo "<li><a href='?Page=$i'>". $i . '</a></li>';
  138. }
  139. $next=$page+1;
  140. if($next<=$pages)
  141. echo "<li><a href='index.php?Page=$next'>" . "Next" . '</a></li>';
  142. ?>
  143. <select class="form-control" name="ItemsPerPage" id="ItemsPerPage" onchange="javascript:location.href = this.value;" >
  144. <?php
  145. if($itemsPerPage==3 ) echo '<option value="?ItemsPerPage=3" selected >Show 3 Items Per Page</option>';
  146. else echo '<option value="?ItemsPerPage=3">Show 3 Items Per Page</option>';
  147. if($itemsPerPage==4 ) echo '<option value="?ItemsPerPage=4" selected >Show 4 Items Per Page</option>';
  148. else echo '<option value="?ItemsPerPage=4">Show 4 Items Per Page</option>';
  149. if($itemsPerPage==5 ) echo '<option value="?ItemsPerPage=5" selected >Show 5 Items Per Page</option>';
  150. else echo '<option value="?ItemsPerPage=5">Show 5 Items Per Page</option>';
  151. if($itemsPerPage==6 ) echo '<option value="?ItemsPerPage=6"selected >Show 6 Items Per Page</option>';
  152. else echo '<option value="?ItemsPerPage=6">Show 6 Items Per Page</option>';
  153. if($itemsPerPage==10 ) echo '<option value="?ItemsPerPage=10"selected >Show 10 Items Per Page</option>';
  154. else echo '<option value="?ItemsPerPage=10">Show 10 Items Per Page</option>';
  155. if($itemsPerPage==15 ) echo '<option value="?ItemsPerPage=15"selected >Show 15 Items Per Page</option>';
  156. else echo '<option value="?ItemsPerPage=15">Show 15 Items Per Page</option>';
  157. ?>
  158. </select>
  159. </ul>
  160. </div>
  161. <!-- ######################## pagination code block#2 of 2 end ###################################### -->
  162. <div id="confirmation_message" style="color:red;">
  163. <?php echo $message1 ?>
  164. </div>
  165. </div>
  166. </form>
  167. </div>
  168. </div>
  169. </div>
  170. </div>
  171. <script>
  172. $(document).ready(function(){
  173. $(function() {
  174. $('#confirmation_message').delay(3000).fadeOut();
  175. });
  176. });
  177. $('#delete').on('click',function(){
  178. document.forms[0].action="deletemultiple.php";
  179. $('#multiple').submit();
  180. });
  181. function ConfirmDelete()
  182. {
  183. var x = confirm("Are you sure you want to delete?");
  184. if (x)
  185. return true;
  186. else
  187. return false;
  188. }
  189. $(function() {
  190. var availableTags = [
  191. <?php
  192. echo $comma_separated_keywords;
  193. ?>
  194. ];
  195. // Filter function to search only from the beginning of the string
  196. $( "#searchID" ).autocomplete({
  197. source: function(request, response) {
  198. var results = $.ui.autocomplete.filter(availableTags, request.term);
  199. results = $.map(availableTags, function (tag) {
  200. if (tag.toUpperCase().indexOf(request.term.toUpperCase()) === 0) {
  201. return tag;
  202. }
  203. });
  204. response(results.slice(0, 15));
  205. }
  206. });
  207. $( "#searchID" ).autocomplete({
  208. select: function(event, ui) {
  209. $("#searchID").val(ui.item.label);
  210. $("#searchForm").submit();
  211. }
  212. });
  213. });
  214. //select all checkboxes
  215. $("#select_all").change(function(){ //"select all" change
  216. var status = this.checked; // "select all" checked status
  217. $('.checkbox').each(function(){ //iterate all listed checkbox items
  218. this.checked = status; //change ".checkbox" checked status
  219. });
  220. });
  221. $('.checkbox').change(function(){ //".checkbox" change
  222. //uncheck "select all", if one of the listed checkbox item is unchecked
  223. if(this.checked == false){ //if this item is unchecked
  224. $("#select_all")[0].checked = false; //change "select all" checked status to false
  225. }
  226. //check "select all" if all checkbox items are checked
  227. if ($('.checkbox:checked').length == $('.checkbox').length ){
  228. $("#select_all")[0].checked = true; //change "select all" checked status to true
  229. }
  230. });
  231. </script>
  232. </body>
  233. </html>