PageRenderTime 26ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/tablageneral.php

https://gitlab.com/juliocesartors/t-rex-proyect
PHP | 254 lines | 160 code | 89 blank | 5 comment | 20 complexity | 2615792811f248e20b38cfe1bb87a067 MD5 | raw file
  1. <?php
  2. session_start();
  3. if (!(isset($_SESSION['login']) && $_SESSION['login'] != '')) {
  4. header ("Location: index.php");
  5. }
  6. if ($_SESSION['rol'] =='visitador' || $_SESSION['rol'] == 'Coordinador Parroquial') {
  7. header ("Location: 404.html");
  8. }
  9. ?>
  10. <?php
  11. require "base.php";
  12. ?>
  13. <!DOCTYPE html>
  14. <html>
  15. <head>
  16. <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
  17. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
  18. <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
  19. <link rel="stylesheet" href="css/scroll.css">
  20. <style>
  21. table, th, td {
  22. border: 1px solid black;
  23. }
  24. table.scroll {
  25. width: 100%;
  26. /* border-collapse: collapse; */
  27. border-spacing: 0;
  28. border: 2px solid black;
  29. margin-left: -0%;
  30. }
  31. table.scroll tbody,
  32. table.scroll thead { display: block; }
  33. table.scroll tbody {
  34. height: 250px;
  35. overflow-y: auto;
  36. overflow-x: hidden;
  37. }
  38. tbody { border-top: 2px solid black; }
  39. tr td {
  40. width: 20%; /* Optional */
  41. border-right: 1px solid black;
  42. }
  43. th {
  44. width: 20%; /* Optional */
  45. background: #707070;
  46. border-right: 1px solid black;
  47. }
  48. tbody td:last-child, thead th:last-child {
  49. border-right: none;
  50. }
  51. thead{
  52. background: #707070;
  53. text-align: center;
  54. display: inline-block;
  55. }
  56. </style>
  57. <script>
  58. var tableToExcel = (function() {
  59. var uri = 'data:application/vnd.ms-excel;base64,'
  60. , template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><meta http-equiv="content-type" content="application/vnd.ms-excel; charset=UTF-8"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body><table>{table}</table></body></html>'
  61. , base64 = function(s) { return window.btoa(unescape(encodeURIComponent(s))) }
  62. , format = function(s, c) { return s.replace(/{(\w+)}/g, function(m, p) { return c[p]; }) }
  63. return function(table, name) {
  64. if (!table.nodeType) table = document.getElementById(table)
  65. var ctx = {worksheet: name || 'Worksheet', table: table.innerHTML}
  66. window.location.href = uri + base64(format(template, ctx))
  67. }
  68. })()
  69. </script>
  70. <script>
  71. // Change the selector if needed
  72. var $table = $('table.scroll'),
  73. $bodyCells = $table.find('tbody tr:first').children(),
  74. colWidth;
  75. // Adjust the width of thead cells when window resizes
  76. $(window).resize(function() {
  77. // Get the tbody columns width array
  78. colWidth = $bodyCells.map(function() {
  79. return $(this).width();
  80. }).get();
  81. // Set the width of thead columns
  82. $table.find('thead tr').children().each(function(i, v) {
  83. $(v).width(colWidth[i]);
  84. });
  85. }).resize(); // Trigger resize handler
  86. </script>
  87. <script type="text/javascript">
  88. $(document).ready(function () {
  89. $(window).scroll(function () {
  90. if ($(this).scrollTop() > 225) {
  91. $('.scrollup').fadeIn();
  92. } else {
  93. $('.scrollup').fadeOut();
  94. }
  95. });
  96. $('.scrollup').click(function () {
  97. $("html, body").animate({
  98. scrollTop: 0
  99. }, 600);
  100. return false;
  101. });
  102. });
  103. </script>
  104. </head>
  105. <body>
  106. <center>
  107. <div id="contenedor2">
  108. <div id="contenedor3">
  109. <?php
  110. $conexion = new mysqli("localhost","tesis","utp.2015","saga");
  111. if($conexion -> connect_error){
  112. die("Error en la conexion!");
  113. }
  114. else {
  115. echo("<u><h2>Reportes general de alcancías </h2></u><br/>");
  116. }
  117. $sql = "SELECT `familia`.codigo_alcancia,`familia`.apellido,`familia`.direccion, `alcancia`.codigo_alcancia, `alcancia`.codigo_vicaria, `alcancia`.codigo_parroquia, `alcancia`.fecha_entrega,`alcancia`.fecha_devolucion
  118. FROM `familia` INNER JOIN `alcancia` ON `familia`.codigo_alcancia = `alcancia`.codigo_alcancia";
  119. $result = $conexion->query($sql);
  120. $result1 = $conexion->query("SELECT COUNT(codigo_alcancia) AS cantidad_alcancia FROM alcancia");
  121. $result2 = $conexion->query("SELECT COUNT(codigo_alcancia) AS cantidad_alcancia FROM alcancia WHERE estado='Entregada'");
  122. $result3 = $conexion->query("SELECT COUNT(codigo_alcancia) AS cantidad_alcancia FROM alcancia WHERE estado='Devuelta'");
  123. if ($result->num_rows > 0) {
  124. echo ' <div class="table-responsive"> <table class="table" id="testTable" class="scroll"> <tr> <th >Alcancía</th> <th>Parroquia</th> <th>Vicaría</th> <th>Familia</th> <th>Dirección</th> <th>Fecha de entrega</th> <th>Fecha de devolución</th> </tr> ';
  125. while($row = $result->fetch_assoc()) {
  126. echo "<tr><td>".$row["codigo_alcancia"]."</td><td>".$row["codigo_parroquia"]."</td><td>".$row["codigo_vicaria"]."</td><td>".$row["apellido"]."</td><td>".$row["direccion"]."</td><td>".$row["fecha_entrega"]."</td><td>".$row["fecha_devolucion"]."</td></tr>";
  127. }
  128. echo ' </table></div>';
  129. } else {
  130. echo "0 Resultados.";
  131. }
  132. if ($result1->num_rows > 0) {
  133. while($row = $result1->fetch_assoc()) {
  134. echo '<br><b>Total de Alcancias= </b>'.'<b>'.$row["cantidad_alcancia"].'</b><br><br>';
  135. }
  136. } else {
  137. echo "0 Resultados.";
  138. }
  139. if ($result2->num_rows > 0) {
  140. while($row = $result2->fetch_assoc()) {
  141. echo '<b>Entregadas= </b>'.'<b>'.$row["cantidad_alcancia"].'</b><br>';
  142. }
  143. } else {
  144. echo "0 Resultados.";
  145. }
  146. if ($result3->num_rows > 0) {
  147. while($row = $result3->fetch_assoc()) {
  148. echo '<b>Devueltas= </b>'.'<b>'.$row["cantidad_alcancia"].'</b><br><br>';
  149. }
  150. } else {
  151. echo "0 Resultados.";
  152. }
  153. $conexion->close();
  154. ?>
  155. <br>
  156. <button class= "boton" type="button" onclick="tableToExcel('testTable', 'W3C Example Table')" style='width:35%; height:10%'>Guardar en Excel <img src="css/fondos/save.png"> </button>
  157. <br/> <a href="#"><img class="scrollup" src="img/arrowtop.png"/></a>
  158. <br>
  159. </div>
  160. </div>
  161. </body>
  162. </html>
  163. <?php
  164. require "footer.html";
  165. ?>