PageRenderTime 28ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/views/SEIP151534/SummaryofOrganization/index.php

https://gitlab.com/sdlion/nandini_151534_b35_atomic_project
PHP | 244 lines | 176 code | 62 blank | 6 comment | 32 complexity | 0b5d457a9b24f15cd47453133888de4a MD5 | raw file
  1. <?PHP
  2. require_once("../../../vendor/autoload.php");
  3. use App\SummaryofOrganization\SummaryofOrganization;
  4. use App\Message\Message;
  5. use App\Utility\Utility;
  6. $objSummaryofOrganization=new SummaryofOrganization();
  7. $allData=$objSummaryofOrganization->index("obj");
  8. ################## search block 1 of 5 start ##################
  9. if(isset($_REQUEST['search']) )$allData = $objSummaryofOrganization->search($_REQUEST);
  10. $availableKeywords=$objSummaryofOrganization->getAllKeywords();
  11. $comma_separated_keywords= '"'.implode('","',$availableKeywords).'"';
  12. ################## search block 1 of 5 end ##################
  13. ######################## pagination code block#1 of 2 start ######################################
  14. $recordCount= count($allData);
  15. if(isset($_REQUEST['Page'])) $page = $_REQUEST['Page'];
  16. else if(isset($_SESSION['Page'])) $page = $_SESSION['Page'];
  17. else $page = 1;
  18. $_SESSION['Page']= $page;
  19. if(isset($_REQUEST['ItemsPerPage'])) $itemsPerPage = $_REQUEST['ItemsPerPage'];
  20. else if(isset($_SESSION['ItemsPerPage'])) $itemsPerPage = $_SESSION['ItemsPerPage'];
  21. else $itemsPerPage = 3;
  22. $_SESSION['ItemsPerPage']= $itemsPerPage;
  23. $pages = ceil($recordCount/$itemsPerPage);
  24. $someData = $objSummaryofOrganization->indexPaginator($page,$itemsPerPage);
  25. $serial = (($page-1) * $itemsPerPage) +1;
  26. ####################### pagination code block#1 of 2 end #########################################
  27. ################## search block 2 of 5 start ##################
  28. if(isset($_REQUEST['search']) ) {
  29. $someData = $objSummaryofOrganization->search($_REQUEST);
  30. $serial = 1;
  31. }
  32. ################## search block 2 of 5 end ##################
  33. ?>
  34. <!Doctype html>
  35. <script src="../../../resource/assets/bootstrap/js/bootstrap.min.js"></script>
  36. <link rel="stylesheet" href="../../../resource/assets/bootstrap/css/bootstrap.min.css">
  37. <link rel="stylesheet" href="../../../resource/assets/font-awesome/css/font-awesome.min.css">
  38. <link rel="stylesheet" href="../../../resource/assets/css/form-elements.css">
  39. <link rel="stylesheet" href="../../../resource/assets/css/style.css">
  40. <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Roboto:400,100,300,500">
  41. <link rel="stylesheet" href="../../../resource/assets/bootstrap/css/s.css">
  42. <!-- required for search, block3 of 5 start -->
  43. <link rel="stylesheet" href="../../../resource/assets/bootstrap/css/jquery-ui.css">
  44. <script src="../../../resource/assets/bootstrap/js/jquery-1.12.4.js"></script>
  45. <script src="../../../resource/assets/bootstrap/js/jquery-ui.js"></script>
  46. <!-- required for search, block3 of 5 end -->
  47. <body>
  48. <div align="right">
  49. <a href="pdf.php" class="btn btn-primary" role="button">Download as PDF</a>
  50. <a href="xl.php" class="btn btn-primary" role="button">Download as XL</a>
  51. <a href="email.php?list=1" class="btn btn-primary" role="button">Email to friend</a>
  52. <!-- required for search, block 4 of 5 start -->
  53. <br><br>
  54. <form id="searchForm" action="index.php" method="get">
  55. <input type="text" value="" id="searchID" name="search" placeholder="Search" width="60" ><br>
  56. <input type="checkbox" name="byName" checked >By Name
  57. <input type="checkbox" name="byComment" checked >By Comment
  58. <input hidden type="submit" class="btn-primary" value="search">
  59. </form>
  60. </div>
  61. <!-- required for search, block 4 of 5 end -->
  62. <div align="center">
  63. <div id="TopMenuBar">
  64. <button type="button" onclick="window.location.href='../index.php'" class=" btn-info btn-lg">Home</button>
  65. <button type="button" onclick="window.location.href='create.php'" class=" btn-info btn-lg">Add new</button>
  66. <button type="button" onclick="window.location.href='trashed.php?Page=1'" class=" btn-info btn-lg">Trashed List</button>
  67. </div>
  68. </div>
  69. <br>
  70. <?php
  71. echo "<table align='center'>";
  72. echo"<center><th> serial</th><th> ID</th><th>NAME</th><th>COMMENT</th><th>Action</th><center>";
  73. foreach($someData as $OneData){
  74. echo"<tr>";
  75. echo "<td>$serial</td> ";
  76. echo "<td>$OneData->id</td> ";
  77. echo "<td>$OneData->name</td> ";
  78. echo "<td>$OneData->comment</td> ";
  79. echo"
  80. <td>
  81. <a href='view.php?id=$OneData->id'><button class='btn btn-info'>view</button></a>
  82. <a href='edit.php?id=$OneData->id'><button class='btn btn-success'>edit</button></a>
  83. <a href='trash.php?id=$OneData->id'><button class='btn btn-sucess'>trash</button></a>
  84. </td>
  85. ";
  86. $serial++;
  87. echo"</tr>";
  88. }
  89. echo"</table>";
  90. ?>
  91. <html>
  92. <!-- ######################## pagination code block#2 of 2 start ###################################### -->
  93. <div align="center" class="container">
  94. <ul class="pagination">
  95. <?php
  96. $pageMinusOne = $page-1;
  97. $pagePlusOne = $page+1;
  98. if($page>$pages) Utility::redirect("index.php?Page=$pages");
  99. if($page>1) echo "<li><a href='index.php?Page=$pageMinusOne'>" . "Previous" . "</a></li>";
  100. for($i=1;$i<=$pages;$i++)
  101. {
  102. if($i==$page) echo '<li class="active"><a href="">'. $i . '</a></li>';
  103. else echo "<li><a href='?Page=$i'>". $i . '</a></li>';
  104. }
  105. if($page<$pages) echo "<li><a href='index.php?Page=$pagePlusOne'>" . "Next" . "</a></li>";
  106. ?>
  107. <select class="form-control" name="ItemsPerPage" id="ItemsPerPage" onchange="javascript:location.href = this.value; " >
  108. <?php
  109. if($itemsPerPage==3 ) echo '<option value="?ItemsPerPage=3" selected >Show 3 Items Per Page</option>';
  110. else echo '<option value="?ItemsPerPage=3">Show 3 Items Per Page</option>';
  111. if($itemsPerPage==4 ) echo '<option value="?ItemsPerPage=4" selected >Show 4 Items Per Page</option>';
  112. else echo '<option value="?ItemsPerPage=4">Show 4 Items Per Page</option>';
  113. if($itemsPerPage==5 ) echo '<option value="?ItemsPerPage=5" selected >Show 5 Items Per Page</option>';
  114. else echo '<option value="?ItemsPerPage=5">Show 5 Items Per Page</option>';
  115. if($itemsPerPage==6 ) echo '<option value="?ItemsPerPage=6"selected >Show 6 Items Per Page</option>';
  116. else echo '<option value="?ItemsPerPage=6">Show 6 Items Per Page</option>';
  117. if($itemsPerPage==10 ) echo '<option value="?ItemsPerPage=10"selected >Show 10 Items Per Page</option>';
  118. else echo '<option value="?ItemsPerPage=10">Show 10 Items Per Page</option>';
  119. if($itemsPerPage==15 ) echo '<option value="?ItemsPerPage=15"selected >Show 15 Items Per Page</option>';
  120. else echo '<option value="?ItemsPerPage=15">Show 15 Items Per Page</option>';
  121. ?>
  122. </select>
  123. </ul>
  124. </div>
  125. <!-- ######################## pagination code block#2 of 2 end ###################################### -->
  126. </html>
  127. <!-- ######################## pagination code block#2 of 2 end ###################################### -->
  128. <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
  129. <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
  130. <!--[if lt IE 9]>
  131. <script src="../../../resource/https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
  132. <script src="../../../resource/https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
  133. <![endif]-->
  134. <!-- Favicon and touch icons -->
  135. <link rel="shortcut icon" href="../../../resource/assets/ico/favicon.png">
  136. <link rel="apple-touch-icon-precomposed" sizes="144x144" href="../../../resource/assets/ico/apple-touch-icon-144-precomposed.png">
  137. <link rel="apple-touch-icon-precomposed" sizes="114x114" href="../../../resource/assets/ico/apple-touch-icon-114-precomposed.png">
  138. <link rel="apple-touch-icon-precomposed" sizes="72x72" href="../../../resource/assets/ico/apple-touch-icon-72-precomposed.png">
  139. <link rel="apple-touch-icon-precomposed" href="../../../resource/assets/ico/apple-touch-icon-57-precomposed.png">
  140. <!-- required for search, block 5 of 5 start -->
  141. <script>
  142. $(function() {
  143. var availableTags = [
  144. <?php
  145. echo $comma_separated_keywords;
  146. ?>
  147. ];
  148. // Filter function to search only from the beginning of the string
  149. $( "#searchID" ).autocomplete({
  150. source: function(request, response) {
  151. var results = $.ui.autocomplete.filter(availableTags, request.term);
  152. results = $.map(availableTags, function (tag) {
  153. if (tag.toUpperCase().indexOf(request.term.toUpperCase()) === 0) {
  154. return tag;
  155. }
  156. });
  157. response(results.slice(0, 15));
  158. }
  159. });
  160. $( "#searchID" ).autocomplete({
  161. select: function(event, ui) {
  162. $("#searchID").val(ui.item.label);
  163. $("#searchForm").submit();
  164. }
  165. });
  166. });
  167. </script>