<?php
	include("stilos/config.inc.php");
	include("../clases/BDConexion.php");
 
  include("../clases/clsPer.php");
  include("Funciones.php");
  include("funcion/funciones.php");
  session_start();
  $objPer=new clsPer;
   
  session_register("control_v");
  session_register("control_v1");
  session_register("control_ve");
   if($borrar==1){
  $control_v = array();
  $control_v1 = array(); 
  $control_ve = array(); 
  } 
  
 $rs=$objPer->getDatosViaje($cod_ruta);	
 $row=$objPer->NextRow($rs);
 $cod_ruta=$row['cod_ruta'];
 $matricula=$row['mat_trans'];
 $fecha_ruta=$row['fecha_ruta'];
 $testimado_ruta=$row['testimado_ruta'];
 $combustible=$row['combustible'];
 $facturable=$row['facturable'];
 $via=$row['via'];
 $cod_man=$row['cod_man'];
 echo $nvuelo=$row['numvuelo'];
 
 $existecod=$objPer->ExisteManifiestoV($cod_ruta);
?>

<html>
<head>
<title></title>
<link href="style.css" rel="stylesheet" type="text/css">
<link href="Estilos.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css" href="../../desing/estilos_viajes_edit.css">
<link href="stilos/Estilos.css" rel="stylesheet" type="text/css">
<SCRIPT language=JavaScript src="js/calendario.js"></SCRIPT>
<script language="javascript" src="../../js/isiAJAX.js"></script>
<script language="javascript" src="ajax_viajedet_edit.js"></script>
<? 
$envia="p_lista_viajes_d.php?via=$via&fecha_ini=$fecha_ini&fecha_fin=$fecha_fin&matricula=$matricula&v=1";
$salirform="fondo.php";
$enviaformu="cvp_rutas_v.php?borrar=1";
?>
<script>
function NuevoFormu(form)
{
location.reload('<?=$enviaformu?>');
}
function volver(form)
{
location.reload('<?=$envia?>');
}
function salir(form)
{
location.reload('<?=$salirform?>');
}
function desabilitado(){
//document.form1.boton_man.disabled = true;
document.form1.boton_editar.disabled = false;
document.form1.boton_regresar.disabled = false;
}
</script>
<SCRIPT LANGUAGE=javascript>
function fn(form,field)
{
var next=0, found=false
var f=form
if(event.keyCode!=13) return;
for(var i=0;i<f.length;i++) {
if(field.name==f.item(i).name){
next=i+1;
found=true
break;
}
}
while(found){
if( f.item(next).disabled==false && f.item(next).type!='hidden'){
f.item(next).focus();
break;
}
else{
if(next<f.length-1)
next=next+1;
else
break;
}
}
}
</SCRIPT>
<script>
/* function enviar_url(form,url)
{

		if(form1.cod_ruta.value==""){
		alert("Debe Ingresar el codigo de la ruta");
		form1.cod_ruta.focus();
		return;		
	    }		
		if(form1.fecha_ruta.value==""){
		alert("Debe Ingresar la fecha");
		form1.fecha_ruta.focus();
		return;		
	    }
		if(form1.via.value=="0"){
		alert("Debe Ingresar la via");
		form1.via.focus();
		return;		
	    }
		
		if(form1.button.value)
		{
		form1.submit();
		}
} */
function GenerarManifiesto()
{
		form1.submit();
}
</script>
</head>
<body onLoad="desabilitado()" bgcolor="<?=$c_fondo['fondo']?>">
<form name="form1" method="post" action="p_manifiesto_dinamico.php" enctype="multipart/form-data">
          <table width="900" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="25"><img src="../estilo_tabla/parte_sup_izq.gif" width="25" height="25"></td>
              <td width="824" background="../estilo_tabla/parte_sup_cen.gif" valign="bottom">
                <div align="left" class="lblTitulo" >Editar Plan de Viaje </div></td>
              <td width="25"><img src="../estilo_tabla/parte_sup_der.gif" width="25" height="25" border="0" usemap="#Map"></td>
            </tr>
            <tr class="lblCampoBlanco">
              <td  background="../estilo_tabla/parte_med_izq.gif">&nbsp;</td>
              <td  height="86" background="../estilo_tabla/parte_med_cen.gif">                  
			  <table width="875" border="0" cellspacing="0" cellpadding="0">
                <tr class="lblCampoBlanco">
                  <td colspan="6">&nbsp;</td>
                </tr>
                <tr class="lblCampoBlanco">
                  <td width="132"><div align="left">Codigo de Ruta </div></td>
                  <td width="10"><div align="left">:</div></td>
                  <td width="250"><div align="left">
                      <input name="cod_ruta" type="text" id="apellidos2" onkeyup=fn(this.form,this) value="<? echo $cod_ruta?>" size="20" readonly>
                      <input name="valor1" type="hidden" id="valor" size="3" value="<? echo $filas['valor']?>" readonly>
                      <input name="tiporuta" type="hidden" id="tiporuta3" value="1">
                      <input name="activo_ruta" type="hidden" id="activo_ruta4" onKeyUp=fn(this.form,this) value="1" size="5">
                      <input name="cod_man" type="hidden" size="3" id="cod_man" value="<?=$cod_man?>">
</div></td>
                  <td width="145"><div align="right">Via</div></td>
                  <td width="6"><div align="left">:</div></td>
                  <td width="276"><div align="left"><?=$via?>
                    <input name="via" type="hidden" id="via" value="<?=$via?>">
                    <input name="borrar" type="hidden" id="borrar" value="1">
                    <input name="retorno" type="hidden" id="retorno" value="1">
                  </div></td>
                </tr>
                      
                <tr class="lblCampo">
                  <td colspan="6"><div >
                    <div align="left">
                      <table width="874" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                          <td width="143"><div align="left">Transporte </div></td>
                          <td colspan="3"><div align="left">
                              <select name="matricula" id="select" onkeyup=fn(this.form,this)>
							  
                                <? 
						echo $objPer->getCboTransViaEdit($via,$matricula);
						?>
                              </select>
                          </div></td>
                        </tr>
                        <tr >
                          <td><div align="left">Fecha 
                            <? if($via=='A'){ echo "Salida";}else{ echo "Ruta";}?>
                          </div></td>
                          <td width="295"><div align="left">
                              <table width="73" border="0" cellspacing="0" cellpadding="0">
                                <tr>
                                  <td width="67"><div align="left">
                                      <input name="fecha_ruta" type="text" onKeyUp=fn(this.form,this) value="<?=extraerfechanormal($fecha_ruta)?>" size="12" maxlength="10" title="FORMATO dd/mm/AA">
                                  </div></td>
                                  <td width="10">&nbsp;</td>
                                  <td width="109"><div align="left"> <a onMouseOver="window.status='Calendario';return true;" onMouseOut="window.status='';return true;"  href="javascript:show_calendar('form1.fecha_ruta');"> <img src="../imagenes/calendar.jpg" alt="Calendario" width="16" height="15" border="0"> </a> </div></td>
                                </tr>
                            </table>
                          </div></td>
						  <? if($via=='F'){?>
                          <td width="155"><div align="left">Fecha LLegada </div></td>
                          <td width="222"><div align="left">
                              <table width="67" border="0" cellspacing="0" cellpadding="0">
                                <tr>
                                  <td width="67"><div align="left">
                                      <input name="testimado_ruta" type="text" id="testimado_ruta2" onKeyUp=fn(this.form,this) value="<?=extraerfechanormal($testimado_ruta)?>" size="12" maxlength="10" title="FORMATO dd/mm/AA">
                                  </div></td>
                                  <td width="10">&nbsp;</td>
                                  <td width="109"><div align="left"> <a onMouseOver="window.status='Calendario';return true;" onMouseOut="window.status='';return true;"  href="javascript:show_calendar('form1.testimado_ruta');"> <img src="../imagenes/calendar.jpg" alt="Calendario" width="16" height="15" border="0"> </a> </div></td>
                                </tr>
                            </table>
                          </div></td>
						  <? }?>
                        </tr>
                        <tr>
                          <td>Numero de Vuelo </td>
                          <td><div align="left">
                            <select name="nv" id="nv">
                              <? for($nv=1;$nv<=15;$nv++){?>
                              <option value="<?=$nv?>" <? if($nv==$nvuelo){?> selected <? }?>><?=$nv?></option>
                              <? }?>
                            </select>
                            <input name="file" type="hidden" id="file">
                            <input name="importar" type="hidden" class="botira" id="importar" style="<?=$stylo['st2']?>" value="Importar" onClick="ImportarDatosE()">
                          </div></td>
                          <td><div align="left"></div></td>
                          <td><div align="left">
                          </div></td>
                        </tr>
                        <tr>
                          <td colspan="4" ><div align="left">
                              <table width="872" border="1" cellspacing="0" cellpadding="0" style="<?=$stylo['tabla']?>">
                                <tr bgcolor="<?=$c_fondo_tr["fondo tr"]?>" class="lblCampoBlanco">
                                  <td height="13" colspan="2"><div align="center" class="lblCampoBlanco">Ruta</div></td>
                                  <td height="13" colspan="<? if($via=='A'){ echo 5;}elseif($via=='F'){ echo 2;}?>">
                                    <div align="center" class="lblCampoBlanco">Tiempo</div>                                  </td>
                                  <td width="44" rowspan="2">
                                    <div align="center" class="lblCampoBlanco">Combus</div>                                  </td>
                                  <td width="51" rowspan="2"><div align="center" class="lblCampoBlanco">Fact.</div></td>
                                  <td width="76" rowspan="2"><div align="center">FechaSal</div></td>
                                  <td width="70" rowspan="2"><div align="center">FechaLLe</div></td>
                                  <td width="33" rowspan="2"><div align="center">Pax</div></td>
                                  <td width="27" rowspan="2"><div align="center">Carga</div></td>
                                  <td width="144" rowspan="2"><div align="center" class="lblCampoBlanco">
                                    Observacion 
                                  </div></td>
                                  <td width="44" rowspan="2"><div align="center" class="lblCampoBlanco">Prog.</div></td>
                                  <td rowspan="2"><input name="vias" type="hidden" value="<?=$via?>" size="5"></td>
                                </tr>
                                <tr bgcolor="<?=$c_fondo_tr["fondo tr"]?>" >
                                  <td height="13"><div align="center" class="lblCampoBlanco">De</div></td>
                                  <td><div align="center" class="lblCampoBlanco">Para</div></td>
                                  <? if($via=='A'){?>
                                  <td><div align="center" class="lblCampoBlanco">HAR</div></td>
                                  <? }?>
                                  <td><div align="center" class="lblCampoBlanco">HSAL</div></td>
                                  <td><div align="center" class="lblCampoBlanco">HLLE</div></td>
								  <? if($via=='A'){?>
                                  <td><div align="center" class="lblCampoBlanco">HDES</div></td>
                                  
                                  <td><div align="center" class="lblCampoBlanco">HAP</div></td>
                                  <? }?>
                                </tr>
                                <tr>
                                  <td width="72"><div align="center">
                                      <select name="origen" id="select7">
                                        <option value="0" <? if($origen=="0"){?> selected <? }?>>Origen</option>
                                        <? 
						    echo $objPer->getCboLugaresDef($origen);
						    ?>
                                      </select>
                                  </div></td>
                                  <td width="77"><div align="center">
                                      <select name="destino" id="select6">
                                        <option value="0" <? if($destino=="0"){?> selected <? }?>>Destino</option>
                                        <? 
						    echo $objPer->getCboLugaresDef($destino);
						?>
                                      </select>
                                  </div></td>
                                  <? if($via=='A'){?>
                                  <td width="27"><div align="center">
                                      <input name="harranq_dch" type="text" id="harranq_dch" value="00:00" size="5" maxlength="5">
                                  </div></td>
                                  <? }else{?>
                                  <input name="harranq_dch" type="hidden" id="harranq_dch" value="00:00" size="8" maxlength="5">
                                  <? }?>
                                  <td width="32"><div align="center">
                                      <input name="haire_dch" type="text" id="haire_dch" value="00:00" size="5" maxlength="5">
                                  </div></td>
                                  <td width="30">
                                    <div align="center">
                                      <input name="htierra_dch" type="text" id="htierra_dch" value="00:00" size="5" maxlength="5">
                                    </div></td>
									<? if($via=='A'){?>
                                  <td width="31"><div align="center">
                                    <input name="hdes" type="text" id="hdes" value="00:00" size="5" maxlength="5">
                                  </div></td>
                                  
                                  <td width="52"><div align="center">
                                      <input name="hapaga_dch" type="text" id="hapaga_dch" value="00:00" size="5" maxlength="5">
                                  </div></td>
                                  <? }else{?>
                                  <input name="hapaga_dch" type="hidden" id="hapaga_dch" value="00:00" size="8" maxlength="5">
								  <input name="hdes" type="hidden" id="hdes" value="00:00" size="8" maxlength="5">
                                  <? }?>
                                  <td>                                    
                                    <div align="center">
                                      <input name="combustible" type="text" id="combustible" value="0.00" size="10"> 
                                    </div></td>
                                  <td><div align="center">
                                    <select name="facturable" id="select2">
                                      <option value="SI">SI</option>
                                      <option value="NO">NO</option>
                                    </select>
                                  </div></td>
                                  <td><div align="center">
                                    <table width="73" border="0" cellspacing="0" cellpadding="0">
                                      <tr>
                                        <td width="67"><div align="left">
                                            <input name="fechasalida" type="text" onKeyUp=fn(this.form,this) value="<?=extraerfechanormal($fechasalida)?>" size="12" maxlength="10" title="FORMATO dd/mm/AA">
                                        </div></td>
                                        <td width="10">&nbsp;</td>
                                        <td width="109"><div align="left"> <a onMouseOver="window.status='Calendario';return true;" onMouseOut="window.status='';return true;"  href="javascript:show_calendar('form1.fechasalida');"> <img src="../imagenes/calendar.jpg" alt="Calendario" width="16" height="15" border="0"> </a> </div></td>
                                      </tr>
                                    </table>
                                  </div></td>
                                  <td><div align="center">
                                    <table width="67" border="0" cellspacing="0" cellpadding="0">
                                      <tr>
                                        <td width="67"><div align="left">
                                            <input name="fechallegada" type="text" onKeyUp=fn(this.form,this) value="<?=extraerfechanormal($fechallegada)?>" size="12" maxlength="10" title="FORMATO dd/mm/AA">
                                        </div></td>
                                        <td width="10">&nbsp;</td>
                                        <td width="109"><div align="left"> <a onMouseOver="window.status='Calendario';return true;" onMouseOut="window.status='';return true;"  href="javascript:show_calendar('form1.fechallegada');"> <img src="../imagenes/calendar.jpg" alt="Calendario" width="16" height="15" border="0"> </a> </div></td>
                                      </tr>
                                    </table>
                                  </div></td>
                                  <td><div align="center">
                                    <input name="pax" type="text" id="pax" value="0" size="5">
                                  </div></td>
                                  <td><div align="center">
                                    <input name="carga" type="text" id="carga" value="0" size="5">
                                  </div></td>
                                  <td><div align="center">
                                    <textarea name="obser" cols="25" rows="2" id="textarea2"></textarea>
                                  </div></td>
                                  <td><div align="center">
                                    <select name="programado" id="programado">
                                      <option value="S" title="SI">S</option>
                                      <option value="N" title="NO">N</option>
                                      <option value="M" title="Mantenimiento">M</option>
                                      <option value="I" title="Indisponibilidad">I</option>
                                    </select>
                                  </div></td>
                                  <td width="28"><div align="center">
                                    <input name="boton_agregar" type="button" id="boton_agregar" title="Agregar a la lista" onClick="enviarDatosViaje()" value=">>" class="botira" style="<?=$stylo['st2']?>">
                                    <!-- <a href="#" onClick="enviarDatosViaje()"><img src="../imagenes/btn_siguiente.gif" width="20" height="20" border="0"></a> --> </div>
                                  <!-- <input name="boton_Per2" type="button" class="lblForm" id="boton_Per22" onClick="Enviar()" value="&gt;&gt;&gt;"> --></td>
                                </tr>
                            </table>
                          </div></td>
                        </tr>
                        <tr>
                          <td colspan="4">&nbsp;</td>
                        </tr>
                        <tr>
                          <td colspan="4"><div id="canasta" class="lblCampoBlanco">
                              <? include('p_rutas_detalle_edit.php');?>
                          </div></td>
                        </tr>
                        <tr>
                          <td colspan="4"><div id="lugar_grabar">&nbsp;</div></td>
                        </tr>
                        <tr>
                          <td colspan="4"><div align="center">
                              <table width="574" border="0" cellpadding="0" cellspacing="0">
                                <tr>
                                  <td width="122"><div align="right">
                                      <input name="boton_editar" type="button" class="botira" id="boton_editar" style="<?=$stylo['st2']?>" onClick="enviarDatosGrabar()" value=".::        Editar       ::.">
                                  </div></td>
                                  <td width="107"><div align="center">
                                    <? if($existecod==0){?><input name="boton_man" type="button" class="botira" id="boton_man" style="<?=$stylo['st2']?>" onClick="GenerarManifiesto();" value=".::     Manifiesto     ::.">
									<? } else{?>
									<input name="boton_man1" type="button" class="botira" id="boton_man1" style="<?=$stylo['st2']?>" onClick="GenerarManifiesto();" value=".::     Manifiesto     ::." disabled>
                                    <? }?>
                                    </div></td>
                                  <td width="102"><div align="left">
                                      <input name="boton_regresar" type="button" class="botira" id="boton_regresar" style="<?=$stylo['st2']?>" onClick="volver(this.form);" value=".::     Regresar     ::.">
                                  </div></td>
                                  <td width="121"><div align="left">
                                    <input name="boton_nuevo" type="button" class="botira" id="boton_nuevo" style="<?=$stylo['st2']?>" onClick="NuevoFormu(this.form)" value=".::    Nuevo    ::.">
                                  </div></td>
                                  <td width="122"><div align="left">
                                    <input name="boton_salir" type="button" class="botira" id="boton_salir" style="<?=$stylo['st2']?>" onClick="salir(this.form);" value=".::      Salir     ::.">
                                  </div></td>
                                </tr>
                            </table>
                          </div></td>
                        </tr>
                      </table>
                    </div>
                  </div></td>
                </tr>
                </table></td><td background="../estilo_tabla/parte_med_der.gif">&nbsp;</td>
            </tr>
            <tr>
              <td><img src="../estilo_tabla/parte_inf_izq.gif" width="25" height="25"></td>
              <td background="../estilo_tabla/parte_inf_cen.gif"><div align="right"><a href="p_manifiesto_dinamico.php"><!-- IR A MANIFIESTO --> </a></div></td>
              <td><img src="../estilo_tabla/parte_inf_der.gif" width="25" height="25"></td>
            </tr>
  </table>
</form>
<map name="Map">
  <area shape="rect" coords="3,4,23,21" href="fondo.php">
</map>
</body>
</html>

