Ver Mensaje Individual
  #1 (permalink)  
Antiguo 19/03/2014, 19:52
Avatar de key975
key975
 
Fecha de Ingreso: marzo-2014
Ubicación: Obligado, Itapúa
Mensajes: 11
Antigüedad: 10 años, 2 meses
Puntos: 0
Pasar variable javascript para eliminar registro

Hola chicos, sé que tiene que ser una tontería, pero no me está funcionando.
Estoy con un sistema para un hotel y necesito pasar la variable ID_Reserva para eliminar la reserva que corresponde a esa ID, pero no encuentro manera de recibir la variable.
Les pego el código de mi popUp (en el que tengo mis datos) y el código del archivo en donde elimino la Reserva a ver si ustedes pueden ver algo que yo no :|
popUpReservas.php
Código PHP:
Ver original
  1. <!DOCTYPE html PUCLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3.     <head>
  4.       <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  5. <?php
  6.   include("conex.php");
  7.   include("funciones.php");
  8. ?>
  9. [B]<script type="text/javascript">
  10. function aviso(ID_Reserva)
  11. {
  12. if (!confirm("ALERTA!! Va a proceder a eliminar esta reserva, si desea eliminarla haga click en ACEPTAR,\nde lo contrario haga click en CANCELAR.")) {
  13. return false;
  14. }
  15. else {
  16. document.location.href = "borradoReservas.php?ID_Reserva=" + ID_Reserva;
  17. return true;
  18. }
  19. }
  20. </script>[/B]
  21. <script type="text/javascript">
  22. function cargaDatos(ID_Reserva,ced_ide,nombre,apellido,fecha_inicio,fecha_fin,cantPersonas,numTelefono,correoElectronico,usuario,observaciones)
  23. {
  24.     opener.document.fe.txtID_Reserva.value = ID_Reserva;
  25.     opener.document.fe.txtced_ide.value = ced_ide;
  26.     opener.document.fe.txtnombre.value = nombre;
  27.     opener.document.fe.txtapellido.value = apellido;
  28.     opener.document.fe.txtfecha_inicio.value = fecha_inicio;
  29.     opener.document.fe.txtfecha_fin.value = fecha_fin;
  30.     opener.document.fe.txtcantPersonas.value = cantPersonas;
  31.     opener.document.fe.txtnumTelefono.value = numTelefono;
  32.     opener.document.fe.txtcorreoElectronico.value = correoElectronico;
  33.     opener.document.fe.txtusuario.value = usuario;
  34.     opener.document.fe.txtobservaciones.value = observaciones;
  35.     window.close();
  36. }
  37. iz=(screen.width-document.body.clientWidth) / 2;
  38. de=(screen.height-document.body.clientHeight) / 2;
  39. moveTo(iz,de);
  40. </script>
  41. <form name="fe" action="" method="post">
  42. <center><h2>Reservas</h2>
  43. <table border="2">
  44. <tr>
  45. <td>Buscar por:
  46. <p><INPUT TYPE="radio" NAME="buscar" VALUE="nombre" checked>    Nombre </p>
  47. <p><INPUT TYPE="radio" NAME="buscar" VALUE="apellido">   Apellido </p>
  48. <p><INPUT TYPE="radio" NAME="buscar" VALUE="fecha_inicio">   Fecha de Entrada </p>
  49. <font color="#808080" size="1" style= "margin-left: 16px"> Formato: aaaa-mm-dd</font>
  50. </p>
  51. <td></br><input type="text" name="txtbus"/></td>
  52. <td></br><input type="submit" name="btn1"  value="Buscar"  /></td>
  53. </tr></table>
  54. <?php
  55.         $link=Conectarse();
  56.         $sql="SELECT * FROM reserva";
  57.         $cs=mysql_query($sql,$link);
  58.         echo"<center>
  59. <table border='3'>
  60. <tr>
  61. <th>ID</th>
  62. <th>Documento</th>
  63. <th>Nombre</th>
  64. <th>Apellido</th>
  65. <th>Fecha de Entrada</th>
  66. <th>Fecha de Salida</th>
  67. <th>Habitacion</th>
  68. <th>Cantidad de Personas</th>
  69. <th>Telefono</th>
  70. <th>Correo Electronico</th>
  71. <th>Recepcionista</th>
  72. <th>Observaciones</th>
  73. <th>Editar</th>
  74. <th>Eliminar</th>
  75. <th>Registrar</th>
  76. </tr>";
  77.         while($resul=mysql_fetch_array($cs)){
  78.             $ID_Reserva=$resul[0];
  79.             $ced_ide=$resul[1];
  80.             $nombre=$resul[2];
  81.             $apellido=$resul[3];
  82.             $fecha_inicio=$resul[4];
  83.             $fecha_fin=$resul[5];
  84.             $habitaciones="";
  85.             $sql1= "SELECT habitacion FROM detalle_reserva WHERE ID_Reserva = $resul[0]";
  86.             $cs1=mysql_query($sql1,$link);
  87.                 while($resul1=mysql_fetch_array($cs1)){
  88.                 $habitaciones.="<option value='".$resul1[0]."'>Habitacion ".$resul1[0]."</option>";
  89.                 }
  90.             $cantPersonas=$resul[6];
  91.             $numTelefono=$resul[7];
  92.             $correoElectronico=$resul[8];
  93.             $usuario=$resul[10];
  94.             $observaciones=$resul[9];
  95.             echo "<tr>
  96. <td>$ID_Reserva</td>
  97. <td>$ced_ide</td>
  98. <td>$nombre</td>
  99. <td>$apellido</td>
  100. <td>$fecha_inicio</td>
  101. <td>$fecha_fin</td>
  102. <td>"?><select name="habitacion">
  103.    <?php echo $habitaciones; ?>
  104.    </select> <?php echo"</td>
  105. <td>$cantPersonas</td>
  106. <td>$numTelefono</td>
  107. <td>$correoElectronico</td>
  108. <td>$usuario</td>
  109. <td>$observaciones</td>
  110. "?>
  111. <td><input type="submit" name="datos" value="Editar" onClick="cargaDatos('<?php echo $ID_Reserva;?>','<?php echo $ced_ide;?>','<?php echo $nombre;?>','<?php echo $apellido;?>','<?php echo $fecha_inicio;?>','<?php echo $fecha_fin;?>','<?php echo $cantPersonas;?>','<?php echo $numTelefono;?>','<?php echo $correoElectronico;?>','<?php echo $usuario;?>','<?php echo $observaciones;?>')"/></td>
  112. [B]<td><input type="submit" name="dato" value="Eliminar" onClick="aviso('<?php echo $ID_Reserva;?>')"/></td>
  113. [/B]<td><input type="submit" name="registrar" value="Registrar" onClick="window.open('crearRegistro.php?ci_cliente=<?php echo $ced_ide?>&fecha_inicio=<?php echo $fecha_inicio?>&fecha_fin=<?php echo $fecha_fin?>&cantPersonas=<?php echo $cantPersonas?>&observaciones=<?php echo $observaciones?>')"/></td>
  114. <?php echo "</tr>";
  115.             }
  116.             echo "</table>
  117. </center>";
  118. ?>
  119. <?php
  120. if(isset($_POST["btn1"])){
  121. $btn=$_POST["btn1"];
  122.     $bus=$_POST["txtbus"];
  123.     $buscar= $_POST["buscar"];
  124.     ?>
  125.     <input type="hidden" name="bus" value="<?php echo $bus; ?>">
  126.     <input type="hidden" name="buscar" value="<?php echo $buscar ?>"  />
  127. <?php
  128.     if($btn=="Buscar"){
  129.         $bus=$_POST["txtbus"];
  130.         $buscar= $_POST["buscar"];
  131.         $link=Conectarse();
  132.         $sql="select * from reserva where $buscar LIKE'%$bus%'";
  133.         $cs=mysql_query($sql,$link);
  134.         echo"<center>
  135. <table border='3'>
  136. <tr>
  137. <th>ID</th>
  138. <th>Documento</th>
  139. <th>Nombre</th>
  140. <th>Apellido</th>
  141. <th>Fecha de Entrada</th>
  142. <th>Fecha de Salida</th>
  143. <th>Habitación</th>
  144. <th>Cantidad de Personas</th>
  145. <th>Telefono</th>
  146. <th>Correo Electronico</th>
  147. <th>Observaciones</th>
  148. <th>Editar</th>
  149. <th>Eliminar</th>
  150. <th>Registrar</th>
  151. </tr>";
  152.         while($resul=mysql_fetch_array($cs)){
  153.             $ID_Reserva=$resul[0];
  154.             $ced_ide=$resul[1];
  155.             $nombre=$resul[2];
  156.             $apellido=$resul[3];
  157.             $fecha_inicio=$resul[4];
  158.             $fecha_fin=$resul[5];
  159.             $habitaciones="";
  160.             $sql1= "SELECT habitacion FROM detalle_reserva WHERE ID_Reserva = $resul[0]";
  161.             $cs1=mysql_query($sql1,$link);
  162.                 while($resul1=mysql_fetch_array($cs1)){
  163.                 $habitaciones.="<option value='".$resul1[0]."'>Habitación ".$resul1[0]."</option>";
  164.                 }
  165.             $cantPersonas=$resul[6];
  166.             $numTelefono=$resul[7];
  167.             $correoElectronico=$resul[8];
  168.             $observaciones=$resul[9];
  169.             echo "<tr>
  170. <td>$ID_Reserva</td>
  171. <td>$ced_ide</td>
  172. <td>$nombre</td>
  173. <td>$apellido</td>
  174. <td>$fecha_inicio</td>
  175. <td>$fecha_fin</td>
  176. <td>"?><select name="habitacion">
  177.    <?php echo $habitaciones; ?>
  178.    </select> <?php echo"</td>
  179. <td>$cantPersonas</td>
  180. <td>$numTelefono</td>
  181. <td>$correoElectronico</td>
  182. <td>$observaciones</td>
  183. "?>
  184. <td><input type="submit" name="datos" value="Editar" onClick="cargaDatos('<?php echo $ID_Reserva;?>','<?php echo $ced_ide;?>','<?php echo $nombre;?>','<?php echo $apellido;?>','<?php echo $fecha_inicio;?>','<?php echo $fecha_fin;?>','<?php echo $cantPersonas;?>','<?php echo $numTelefono;?>','<?php echo $correoElectronico;?>','<?php echo $usuario;?>','<?php echo $observaciones;?>')"/></td>
  185. [B]<td><input type="submit" name="dato" value="Eliminar" onClick="aviso('<?php echo $ID_Reserva;?>')"/></td>
  186. [/B]<td><input type="submit" name="registrar" value="Registrar" onClick="window.open('crearRegistro.php?ci_cliente=<?php echo $ced_ide?>&fecha_inicio=<?php echo $fecha_inicio?>&fecha_fin=<?php echo $fecha_fin?>&cantPersonas=<?php echo $cantPersonas?>&observaciones=<?php echo $observaciones?>')"/></td>
  187. <?php echo "</tr>";
  188.             }
  189.             echo "</table>
  190. </center>";
  191. }
  192. }
  193. ?>
borradoReservas.php
Código PHP:
Ver original
  1. <?php
  2.    include("conex.php");
  3.    include("funciones.php");
  4.    $link=Conectarse();
  5.    $ID_Reserva=$_GET['ID_Reserva'];
  6.    mysql_query("delete from reserva where ID_Reserva ='$ID_Reserva'", $link);
  7.    header("Location: popUpReservas.php");
  8. ?>

Última edición por key975; 19/03/2014 a las 20:05