Ver Mensaje Individual
  #1 (permalink)  
Antiguo 22/04/2013, 16:45
claudinho
 
Fecha de Ingreso: febrero-2013
Ubicación: Margarita
Mensajes: 72
Antigüedad: 11 años, 2 meses
Puntos: 0
actualizar ventana padre al cerrar la ventana hija

Hola amigos del foro tengo un problema espero me puedan ayudar. tengo una pagina que hace una tabla dinamicamente en donde un boton abre una ventana nueva con un formulario. Al submit el formulario tengo una funcion return window open() esto me retorna a la ventana principal pero a veces recarga la pagina y a veces no.....quizas sea un problema de codigo

la ventana principal seria asi

Código HTML:
<p>[PHP]
print '<table width="100%"  border="1" cellpadding="1" cellspacing="1" bordercolor="#999999" style="cursor:pointer" >';

$query1 = mysql_query("SELECT * FROM citas WHERE  id_user='$id' AND fecha='$f_agenda' ORDER BY hora_inicio") or die("Error en query");	
$datos1 = mysql_fetch_array($query1);
$horacitaini = $datos1['hora_inicio'];	
$horacitafinal = $datos1['hora_final'];	
$ayuda= $media;
$contador =1; 
$cont = mysql_num_rows($query1);
	while($clock<=$horaf)
	
	{
	$id_p = $datos1['id_paciente'];
	$id_proc = $datos1['id_proced'];
	$status = $datos1['status'];
$query2 = mysql_query("SELECT nombre,apellido FROM pacientes WHERE id_paciente='$id_p'") or die("Error en query2");
$datos2 = mysql_fetch_array($query2);
$paciente = $datos2['nombre'].'&nbsp;'.$datos2['apellido'];

$query3 = mysql_query("SELECT * FROM procedimientos WHERE id_procedimiento ='$id_proc'") or die("Error en query3");
$datos3 = mysql_fetch_array($query3);
$procedimiento = $datos3['nombre_p'];
$valor = $datos3['valor'];

$desc = $paciente.$procedimiento.'&nbsp;&nbsp;&nbsp;'.'Bs '.$valor.'&nbsp;&nbsp;'.$status;
$contador = $contador%2;
//$cont = mysql_num_rows($query1);
echo $cont;
if ($cont ==0){
if ($contador==1){
	print ' <tr bgcolor="white" onmouseover=\'this.style.background="#666666"\' onmouseout=\'this.style.background="white"\' style="cursor:pointer">
    <td bgcolor="" >&nbsp;</td>
    <td bgcolor=""\ ><div align= "center"><a href="agendabox.php?f='.$f_agenda.'&p=0&idp2=0&stat=0&val=0&pro=0&idp=0&fecha='.$fech2.'&hora='.date("H:i",strtotime($media)).'" onclick="NewWindow(this.href,\'agenda\',\'500\',\'480\',\'yes\',\'center\');return false; window.location.reload();" onfocus="this.blur()"> <input type="submit" name="Submit" value="'.date("h:i",strtotime($media)).'" on></a></div></td>
    <td bgcolor="" onclick="javascript:show(); return false;" onfocus="this.blur()">&nbsp;</td>
  </tr>';
  }
  if($contador==0){
  print '<tr bgcolor="#f8f8f8" onmouseover=\'this.style.background="#666666"\' onmouseout=\'this.style.background="#F8F8F8"\' style="cursor:pointer">
    <td width="3%" bgcolor="" >&nbsp;</td>
    <td width="6%" bgcolor="" ><div align= "center"><a href="agendabox.php?f='.$f_agenda.'&p=0&idp2=0&stat=0&val=0&pro=0&idp=0&fecha='.$fech2.'&hora='.date("H:i",strtotime($media)).'"  onclick="NewWindow(this.href,\'agenda\',\'500\',\'480\',\'yes\',\'center\');return false; window.location.reload();" onfocus="this.blur()"><input type="submit" name="Submit" value="'.date("h:i",strtotime($media)).'"></a></div></td>
    <td width="91%" bgcolor="" onclick="javascript:show(); return false;" onfocus="this.blur()">&nbsp;</td>
  </tr>';
}

}
else{

	if($media==$horacitaini || $ayuda==$horacitaini){
	
		if ($contador==1){
	print ' <tr bgcolor="#EDF3FE" onmouseover=\'this.style.background="#666666"\' onmouseout=\'this.style.background="#EDF3FE"\' >
    <td bgcolor="" >&nbsp;</td>
    <td bgcolor="" ><div align= "center"><a href="agendabox.php?f='.$f_agenda.'&p='.$id_proc.'&idp2='.$id_p.'&stat='.$status.'&val='.$valor.'&pro='.$procedimiento.'&idp='.$paciente.'&fecha='.$fech2.'&hora='.date("H:i",strtotime($horacitaini)).'" onclick="NewWindow(this.href,\'agenda\',\'500\',\'480\',\'yes\',\'center\');return false; window.location.reload();" onfocus="this.blur()"> <input type="submit" name="Submit" value="'.date("h:i",strtotime($horacitaini)).'" on></a></div></td>
    <td bgcolor="" onclick="javascript:show2(); return false;" onfocus="this.blur()">&nbsp;'.$desc.'</td>
  </tr>';
  }
  if($contador==0){
print '<tr bgcolor="#EDF3FE" onmouseover=\'this.style.background="#666666"\' onmouseout=\'this.style.background="#EDF3FE"\' >
    <td width="3%" bgcolor="" >&nbsp;</td>
    <td width="6%" bgcolor="" ><div align= "center"><a href="agendabox.php?f='.$f_agenda.'&p='.$id_proc.'&idp2='.$id_p.'&stat='.$status.'&val='.$valor.'&pro='.$procedimiento.'&idp='.$paciente.'&fecha='.$fech2.'&hora='.date("H:i",strtotime($horacitaini)).'" onclick="NewWindow(this.href,\'agenda\',\'500\',\'480\',\'yes\',\'center\');return false; window.location.reload();" onfocus="this.blur()"><input type="submit" name="Submit" value="'.date("h:i",strtotime($horacitaini)).'"></a></div></td>
    <td width="91%" bgcolor="" onclick="javascript:show2(); return false;" onfocus="this.blur()">&nbsp;'.$desc.'</td>
  </tr>';
}

$media = dif($horacitafinal,"00:30:00");
$clock=   $media;

$datos1 = mysql_fetch_array($query1);
$horacitaini = $datos1['hora_inicio'];	
$horacitafinal = $datos1['hora_final'];	

}
		else{
	if ($contador==1){
	print ' <tr bgcolor="white" onmouseover=\'this.style.background="#666666"\' onmouseout=\'this.style.background="white"\' >
    <td bgcolor="" >&nbsp;</td>
    <td bgcolor="" ><div align= "center"><a href="agendabox.php?f='.$f_agenda.'&p=0&idp2=0&stat=0&val=0&pro=0&idp=0&fecha='.$fech2.'&hora='.date("H:i",strtotime($media)).'" onclick="NewWindow(this.href,\'agenda\',\'500\',\'480\',\'yes\',\'center\');return false; window.location.reload();;" onfocus="this.blur()"> <input type="submit" name="Submit" value="'.date("h:i",strtotime($media)).'" on></a></div></td>
    <td bgcolor="" onclick="javascript:show(); return false;" onfocus="this.blur()">&nbsp;</td>
  </tr>';
  }
  if($contador==0){
  print '<tr bgcolor="#f8f8f8" onmouseover=\'this.style.background="#666666"\' onmouseout=\'this.style.background="#F8F8F8"\' >
    <td width="3%" bgcolor="" >&nbsp;</td>
    <td width="6%" bgcolor="" ><div align= "center"><a href="agendabox.php?f='.$f_agenda.'&p=0&idp2=0&stat=0&val=0&pro=0&idp=0&fecha='.$fech2.'&hora='.date("H:i",strtotime($media)).'"  onclick="NewWindow(this.href,\'agenda\',\'500\',\'480\',\'yes\',\'center\');return false; window.location.reload();" onfocus="this.blur()"><input type="submit" name="Submit" value="'.date("h:i",strtotime($media)).'"></a></div></td>
    <td width="91%" bgcolor="" onclick="javascript:show(); return false;" onfocus="this.blur()">&nbsp;</td>
  </tr>';
}

}
}	
   $media = sumahoras($media,"00:30:00");
$ayuda = dif($media,'00:30:00');
$contador = $contador+1;
 $clock= sumahoras($clock,"00:30:00");  
}

print '</table>';
//print '</form>'
[/PHP]
</form> </p> 
la ventana se llama mediante NewWindow() y la ventana hija donde esta el formulario es asi

Código HTML:
<body>
<form name="form1" method="post" action="agendabox.php" onSubmit="<?php echo 'return window.open(\'agenda.php?dia='.$d.'&mes='.$m.'&ano='.$y.'&Month='.$M.'&salir=gracias\',\'ventanaprincipal\'); return false; window,opener.location.reload();self.close();' ?>">
  <table width="500"  border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td colspan="3"><input name="fecha" type="text" class="caja" id="fecha" value="<?php echo $fecha_a; ?>" size="30"> </td>
      <td><?php echo $hora;?></td>
      <td width="53"><input name="hora" type="text" id="hora" size="7" value="<?php echo $hora;?>"> </td>
      <td colspan="2"><input name="guardar" type="submit" id="guardar" value="Guardar"></td>
      <td><input type="submit" name="Submit3" value="Historia"></td>
      <td><input name="proc"  type="hidden" id="proc" size="12" value="<?php echo $idproc; ?>"></td>
    </tr>
    <tr>
      <td colspan="4">&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
  
  </table>
</form>

[PHP]

if (isset($_POST['guardar'])){

$hora = $_POST['hora'];
$paciente_name = $_POST['pacientes'];
$proc = $_POST['procedimiento'];
$valor = $_POST['valor'];
$obs = $_POST['observaciones'];
$status = $_POST['status'];
$tiempo = $_POST['tiempo'];
$fecha = $_POST['fecha'];
$fecha_data = $_POST['fecha2'];
$id_paciente = $_POST['id_pac'];
$id_procedimiento = $_POST['proc'];
$hora = $hora.":00";
$hora = date("G:i:s",strtotime($hora));
echo $hora;
$tiempo = "00:".$tiempo.":00";
$horafinal = sumahoras($hora,$tiempo);

//echo $fecha;
//echo $fecha_data;
$fechadata = explode("-",$fecha_data);
$ano= $fechadata[0];
$mes= $fechadata[1];
$dia= $fechadata[2];

$query= mysql_query("INSERT INTO citas(id_user,id_paciente,id_proced,fecha,hora_inicio,hora_final,status) VALUES('$id','$id_paciente','$id_procedimiento','$fecha_data','$hora','$horafinal','$status')") or die("ERROR en insertar");
if($query){
//echo $hora;
header("location:agenda.php?dia=$dia&mes=$mes&ano=$ano&Month=&salir=gracias ");
}

}
[/PHP]
</body>

Cualquier ayuda gracias!!