PageRenderTime 66ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/BD/sitio-atonaltzin/mostrar_tabla_camionetas.php

https://github.com/astrocumbia/UTM
PHP | 164 lines | 143 code | 18 blank | 3 comment | 4 complexity | 1d4c01902bc06317c3de54979e786661 MD5 | raw file
Possible License(s): GPL-2.0
  1. <?php
  2. @session_start();
  3. /* Verificar que el usuario inicio sesion */
  4. if(!isset($_SESSION['usuario']))
  5. {
  6. echo '<script> location.href = "login.php"; </script>';
  7. exit();
  8. }
  9. /* rechazar si el taquillero intenta entrar localhost/sitio/reportes.php */
  10. if( $_SESSION['puesto']=="Taquillero" ){
  11. echo '<script> location.href = "inicio.php"; </script>';
  12. exit();
  13. }
  14. include("funciones.php");
  15. //print_r( $_POST );
  16. ?>
  17. <!--TABLA PARA RESULTADOS-->
  18. <div class="table-responsive col-md-12 col-lg-offset-1">
  19. <table class="table table-hover" id="tabla_resultados">
  20. <!--FILA ENCABEZADO -->
  21. <thead>
  22. <tr>
  23. <th bgcolor="#45A0FF"> Código </th>
  24. <th bgcolor="#45A0FF"> Matricula </th>
  25. <th bgcolor="#45A0FF"> Número de asientos </th>
  26. <th bgcolor="#45A0FF"> Modelo </th>
  27. <th bgcolor="#45A0FF"> Dueño </th>
  28. <th bgcolor="#45A0FF"> Estado Actual </th>
  29. <th > </th>
  30. <th > </th>
  31. <th > </th>
  32. <th > </th>
  33. </tr>
  34. </thead>
  35. <!--CUERPO DE TABLA-->
  36. <tbody>
  37. <?php
  38. switch ($_POST['tipo']) {
  39. case 0:
  40. $myquery = "select * from CAMIONETA;";
  41. break;
  42. default:
  43. break;
  44. }
  45. $GLOBALS["CONEXION"] = mysql_connect( $GLOBALS["servidor"], $GLOBALS["usuario"], $GLOBALS["password"] ) or die(mysql_error() );
  46. mysql_select_db( $GLOBALS["basedatos"], $GLOBALS["CONEXION"] );
  47. $resultados = mysql_query( $myquery, $GLOBALS["CONEXION"]) or die ( mysql_error() );
  48. $rows = mysql_num_rows( $resultados );
  49. for ($i=0; $i < $rows ; $i++) {
  50. $tupla = mysql_fetch_assoc( $resultados );
  51. $ID = $tupla['id_camioneta'];
  52. $matricula = $tupla['matricula'];
  53. $num_asientos = $tupla['n_asientos'];
  54. $modelo = $tupla['modelo'];
  55. $id_dueno = $tupla['DUENO_id_dueno'];
  56. $id_estado = $tupla['ESTADO_id_estado'];
  57. $res_dueno = mysql_query("select * from DUENO where id_dueno=$id_dueno", $GLOBALS["CONEXION"]) or die ( mysql_error() );
  58. $tupla_dueno = mysql_fetch_assoc( $res_dueno );
  59. $nombre_dueno = $tupla_dueno['nombre'].' '.$tupla_dueno['apellido'];
  60. $res_estado = mysql_query( "select * from ESTADO where id_estado=$id_estado", $GLOBALS["CONEXION"]) or die ( mysql_error() );
  61. $tupla_estado = mysql_fetch_assoc( $res_estado );
  62. $descripcion_estado = $tupla_estado['descripcion'];
  63. echo '
  64. <tr class="info">
  65. <td class="info" width="5%" >
  66. '.$ID.'
  67. </td>
  68. <td class="info" width="10%">
  69. '.$matricula.'
  70. </td>
  71. <td class="info" width="13%">
  72. '.$num_asientos.'
  73. </td>
  74. <td class="info" width="15%">
  75. '.$modelo.'
  76. </td>
  77. <td class="info" width="22%">
  78. '.$nombre_dueno.'
  79. </td>
  80. <td class="info" width="15%">
  81. '.$descripcion_estado.'
  82. </td>
  83. <td class="info" width="2%">
  84. <button type="button" data-toggle="modal" data-target="#modal_agregar_camioneta" id="boton_agregar_camioneta_'.$ID.'" >
  85. <span class="glyphicon glyphicon-plus-sign"></span>
  86. </button>
  87. </td>
  88. <td class="info" width="2%">
  89. <button type="button" data-toggle="modal" data-target="#modal_ver_camioneta" id="boton_ver_camioneta_'.$ID.'">
  90. <span class="glyphicon glyphicon-eye-open"></span>
  91. </button>
  92. </td>
  93. <td class="info" width="2%">
  94. <button type="button" data-toggle="modal" data-target="#modal_modificar_camioneta" id="boton_modificar_camioneta_'.$ID.'">
  95. <span class="glyphicon glyphicon-pencil"></span>
  96. </button>
  97. </td>
  98. </tr>
  99. <script>
  100. $( "#boton_ver_camioneta_'.$ID.'" ).mousedown(function() {
  101. $.ajax({
  102. type: "POST",
  103. url: "ver_camioneta.php",
  104. data: "ID='.$ID.'&matricula='.$matricula.'&num_asientos='.$num_asientos.'&modelo='.$modelo.'&nombre_dueno='.$nombre_dueno.'&descripcion='.$descripcion_estado.'",
  105. success: function(data) {
  106. $("#div_moda_ver_camioneta").html(data);
  107. }
  108. });
  109. });
  110. $( "#boton_modificar_camioneta_'.$ID.'" ).mousedown(function() {
  111. $.ajax({
  112. type: "POST",
  113. url: "formulario_modificar_camioneta.php",
  114. data: "ID='.$ID.'&matricula='.$matricula.'&num_asientos='.$num_asientos.'&modelo='.$modelo.'&id_dueno='.$id_dueno.'&id_estado='.$id_estado.'",
  115. success: function(data) {
  116. $("#div_modal_modificar_camioneta").html(data);
  117. }
  118. });
  119. });
  120. $( "#boton_agregar_camioneta_'.$ID.'" ).mousedown(function() {
  121. $.ajax({
  122. type: "POST",
  123. url: "formulario_agregar_camioneta.php",
  124. data: "",
  125. success: function(data) {
  126. $("#div_modal_agregar_camioneta").html(data);
  127. }
  128. });
  129. });
  130. </script>
  131. ';
  132. }
  133. ?>
  134. </tbody>
  135. </table>
  136. </div>