<?php	
  include("../clases/BDConexion.php");
  include("../clases/clsPer.php");
  include("Funciones.php");
  include("stilos/config.inc.php");
  include("funcion/funciones.php");
  session_start();
  $objPer=new clsPer;
  $objPer1=new clsPer;
  session_register("pasajeros1");
  session_register("pasajeros1_temp");
  session_register("cargac1");
  session_register("cargac2");
  if($borrar==1){
  $pasajeros1 = array();
  $pasajeros1_temp = array(); 
  $pasajeros2_temp = array();  
  $cargac1 = array();
  $cargac2 = array();
  }
  
  /* $resultado=$objPer->getCodManifiesto($via);//getCodMani()
  $filas=$objPer->NextRow($resultado);
  $cod_man=getNumCero($filas['valor']); */
  
$rs=$objPer->getPlanViajeCab($cod_ruta);							   
$row=$objPer->NextRow($rs);
$via=$row['via'];
$fecha_ruta=$row['fecha_ruta'];
$testimado_ruta=$row['testimado_ruta'];
$mat_trans=$row['mat_trans'];
$cod_man=$cod_man;

$rsman=$objPer->getManCab($cod_man,$via);
$rowman=$objPer->NextRow($rsman);
//echo $borrar;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title><MMString:LoadString id="insertbar/formsHidden" /></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="style.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css" href="styles_per.css" />
<link href="Estilos.css" rel="stylesheet" type="text/css">
<link href="stilos/Estilos.css" rel="stylesheet" type="text/css">
<SCRIPT language=JavaScript src="js/calendario.js"></SCRIPT>
<script type="text/javascript" src="ajax_per.js"></script>
<link rel="stylesheet" type="text/css" href="../../desing/estilos_viajes_edit.css">
<script language="javascript" src="../../js/isiAJAX.js"></script>
<script type="text/javascript" src="ajax_per_agregar.js"></script>
<?
$salir="p_verifica_e.php?cod_man=$cod_man&ir=2&cod_ruta=$cod_ruta&via=$via&q=1&grabar=$grabar";
$volver="p_verifica_e.php?cod_ruta=$cod_ruta&via=$via&fecha_ini=$fecha_ini&fecha_fin=$fecha_fin&q=1&borrar=1&v=1&cod_man=$cod_man&ir=1&q=1&grabar=$grabar&matricula=$mat_trans"; 
?>
<script>
function volver(form){
location.reload('<? echo $volver ?>');
}
function salir(form)
{
location.reload('<? echo $salir ?>');
}
function desabilitado(){
document.form1.boton_grabar.disabled = false;
document.form1.boton_print.disabled = true;
document.form1.boton_regresa.disabled = false;
}
</script>
<script language="JavaScript">
function borrarcamposselect(form)
{
    
		if( document.form1.opcion.options[0].value == 'appat_per' || document.form1.opcion.options[1].value == 'dociden_per'){
		var datos=document.form1.opcion.options[0].value;
		var msg=datos;
		//alert(msg);
		form1.personal.value='';
		form1.dociden_per.value='';
		form1.razon_emp.value='';
		form1.peso_per.value='0.0';
		form1.peso_eq.value='0.0';
		}   
} 
</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 language="JavaScript"> 
function PrintManifiesto(sURL,x,y) { 
if (!window.focus) return;
			var par;
			par = "width=" +x + ",height="+y+","
			par = par + "dependent=no,scrollbars=yes,resizable=yes	"
			par = par + "menubar=no,toolbar=no,status=yes"
			var ventana = window.open(sURL,"Manifieto",par)
			ventana.focus();
}
</script>
<script language="JavaScript"> 
function PrintPlanViaje(sURL,x,y) { 
if (!window.focus) return;
			var par;
			par = "width=" +x + ",height="+y+","
			par = par + "dependent=no,scrollbars=yes,resizable=yes	"
			par = par + "menubar=no,toolbar=no,status=yes"
			var ventana = window.open(sURL,"Viaje",par)
			ventana.focus();
}
</script>
<script>
/* function enviarDatosGrabar()
{ */		
		/* if(form1.fecha_man.value==""){
		alert("Debe Ingresar la Fecha");
		form1.orig_ruta.focus;
		return;		
	    }
		if(form1.orig_ruta.value)
		{ 
		form1.submit();
		} */
		/* form1.submit();
} */

</script>
<script LANGUAGE="JavaScript1.1">
function ambos(e) {
if (navigator.appName == 'Netscape' && (e.which == 2)){
alert('Los botones del mouse han sido inhabilitados')
return false;
}
else if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2)){
alert('Los botones del mouse han sido inhabilitados')
}
}
document.onmousedown=ambos
</script>

</head>

<body bgcolor="<?=$c_fondo['fondo']?>" onfocus="foco()" onLoad="desabilitado()"> <!-- background="../imagenes/fondo.jpg" -->
<form name="form1" method="post" action="procesos/p_manifiesto_grabar.php">
  <table width="922" 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="872" background="../estilo_tabla/parte_sup_cen.gif" valign="bottom">
        <div align="left" class="lblTitulo" >Manifiesto </div></td>
      <td width="25"><img src="../estilo_tabla/parte_sup_der.gif" width="25" height="25" border="0" usemap="#MapMapMap"></td>
    </tr>
    <tr class="lblCampoBlanco">
      <td  background="../estilo_tabla/parte_med_izq.gif">&nbsp;</td>
      <td background="../estilo_tabla/parte_med_cen.gif"><div align="center">
          <table width="863" border="0" cellspacing="0" cellpadding="0">
            <tr class="lblCampoBlanco">
              <td colspan="6">&nbsp; </td>
            </tr>
            <tr class="lblCampo">
              <td><div align="right">Via</div></td>
              <td><div align="left">:</div></td>
              <td><div align="left"><?=$via?></div></td>
              <td><div align="right">Codigo de Viaje </div></td>
              <td><div align="left">:</div></td>
              <td><input name="dir" type="hidden" id="valor3" size="3" value="<?=$dir?>">
                <input name="fecha_ruta" type="hidden" id="dir" size="3" value="<?=$fecha_ruta?>">
              <?=$cod_ruta?>
              <input name="cod_ruta" type="hidden" size="5" id="cod_ruta" value="<?=$cod_ruta?>">
              <input name="via" type="hidden" size="3" id="via" value="<?=$via?>">
              <input name="testimado_ruta" type="hidden" size="5" id="testimado_ruta" value="<?=$testimado_ruta?>">
              <input name="mat_trans" type="hidden" size="5" id="mat_trans" value="<?=$mat_trans?>">
              <input name="codigo_man" type="hidden" size="5" id="codigo_man" value="<?=$rowman['codigo_man']?>">
              <input name="v" type="hidden" size="3" id="v" value="<?=$v?>">
              </td>
            </tr>
            <tr class="lblCampo">
              <td width="152"><div align="right">N&ordm; de Manifiesto </div></td>
              <td width="6"><div align="left">:</div></td>
              <td width="140"><div align="left">
                  <input name="cod_man" type="text" id="cod_man2" onkeyup=fn(this.form,this) value="<? echo $cod_man?>" size="20" readonly>
              </div></td>
              <td width="100"><div align="right">Fecha</div></td>
              <td width="3"><div align="left">:</div></td>
              <td width="467"><div align="left">
                <?=extraerfechanormal($fecha_ruta)?> 
                </div></td>
            </tr>
            <tr class="lblCampoBlanco">
              <td><div align="right"></div></td>
              <td><div align="left"></div></td>
              <td><div align="left">
                <input name="hora" type="hidden" id="hora" onkeyup=fn(this.form,this) value="00:00" size="6" maxlength="5">
</div></td>
              <td><div align="right"></div></td>
              <td><div align="left"></div></td>
              <td> <div align="left" id="volver_salir"><? //include("volver_salir.php");?></div></td>
            </tr>
            <tr class="lblCampoBlanco">
              <td colspan="6">                <div align="center">
                <table width="800" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td width="514" valign="top">
                      <div align="left">
                        <table width="493" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="<?=$bordetabla?>" bgcolor="<?=$c_fondo['fondo tabla']?>" style="<?=$stylo['tabla']?>" >
                          <tr valign="top" class="lblCampoBlanco" bgcolor="<?=$c_fondo_tr["fondo tr"]?>">
                            <td width="17">
                              <div align="left" class="lblCampoBlanco">#</div></td>
                            <td width="57"><div align="left" class="lblCampoBlanco">Origen</div></td>
                            <td width="17"><div align="left" class="lblCampoBlanco">#</div></td>
                            <td width="57"><div align="left" class="lblCampoBlanco">Destino</div></td>
                            <td width="97"><div align="left" class="lblCampoBlanco">Fecha Sal/Llega </div></td>
                            <td width="111"><div align="left" class="lblCampoBlanco">Transporte</div></td>
                            <td width="52">
                              <div align="center" class="lblCampoBlanco">Cap. Pax</div></td>
                            <td width="67"><div align="center" class="lblCampoBlanco">Peso Total </div></td>
                          </tr>
                          <? 
				  $contador=0;
				  
				  $rsd=$objPer->getPlanViajeLineas($cod_ruta);							   
                  while($rowd=$objPer->NextRow($rsd))
                   { 
				   $contador++;
				   ?>
                          <tr valign="top" class="lblForm" >
                            <td class="lblForm">
                              <div align="left">
                                <?=$contador?>
                            </div></td>
                            <td class="lblForm"><div align="left">
                                <?=$rowd['de']; ?>
                            </div></td>
                            <td class="lblForm"><div align="left">
                                <?=$contador?>
                            </div></td>
                            <td class="lblForm"><div align="left">
                                <?=$rowd['para']; ?>
                            </div></td>
                            <td class="lblForm"><div align="left">
                                <?=substr(extraerfechanormal($rowd['fecha_ruta']),0,5); ?>
                /
                <?=substr(extraerfechanormal($rowd['testimado_ruta']),0,5); ?>
                            </div></td>
                            <td class="lblForm">
                              <div align="left">
                                <?=$rowd['mat_trans']."--".$rowd['model_trans'];?>
                            </div></td>
                            <td class="lblForm">
                              <div align="center">
                                <?=$rowd['cappass_trans'];?>
                            </div></td>
                            <td class="lblForm"><div align="left"></div>
                                <div align="center">
                                  <?=$rowd['capcarg_trans'];?>
                              </div></td>
                          </tr>
                          <? 
			}
			$objPer->Liberar($rsd);  
			?>
                        </table>
                    </div></td>
                    <td width="286" valign="top"><div align="left" id="totalpeso"><? include("p_manifiesto_peso1.php");?></div></td>
                  </tr>
                </table>
              </div></td>
            </tr>
            <tr class="lblCampo">
              <td colspan="6"><div align="left"></div></td>
            </tr>
            <tr class="lblCampo">
              <td colspan="6">
			  <table width="868" border="1" cellspacing="0" cellpadding="0" style="<?=$stylo['tabla']?>">
                <tr bgcolor="<?=$c_fondo_tr["fondo tr"]?>" class="lblCampoBlanco">
                  <td colspan="11" class="lblCampoBlanco">Detalle del Personal </td>
                </tr>
                <tr class="lblCampoBlanco">
                  <td width="73"><div align="center" class="lblCampoBlanco">Buscar</div></td>
                  <td width="214"><div align="center" class="lblCampoBlanco">Personal</div></td>
                  <td width="45"><div align="center" class="lblCampoBlanco">DNI</div></td>
                  <td width="95"><div align="center" class="lblCampoBlanco">Empresa</div></td>
                  <td width="25"><div align="center" class="lblCampoBlanco">Kg</div></td>
                  <td width="25"><div align="center" class="lblCampoBlanco">EQ.</div></td>
                  <td width="97"><div align="center" class="lblCampoBlanco">Tipo Pax 
                    
                  </div></td>
                  <td width="100"><div align="center" class="lblCampoBlanco">C. Costo </div></td>
                  <td width="68"><div align="center" class="lblCampoBlanco">Origen</div></td>
                  <td width="72"><div align="center" class="lblCampoBlanco">Destino</div></td>
                  <td width="30"><div align="center"></div></td>
                </tr>
                <tr>
                  <td><div align="center">
                      <select name="opcion" id="opcion" onChange="javascript:borrarcamposselect(this.options[this.options.selectedIndex].value)">
                        <option value="appat_per">Apellido</option>
                        <option value="dociden_per">DNI</option>
                      </select>
                  </div></td>
                  <td>
                      <div align="left">
                        <input name="personal" type="text" size="20" onKeyUp="javascript:autocompletar('lista',this.value,opcion.value);" id="personal">
                        <!-- <span id="reloj"> -->
                      <img src='../imagenes/image.gif' border=0 id="reloj"/></div></td>
                  <td><div align="center">
                      <input name="dociden_per" type="text" id="dociden_per" size="9" readonly>
                  </div></td>
                  <td><div align="center">
                      <input name="razon_emp" type="text" id="razon_emp" size="19" readonly>
                  </div></td>
                  <td><div align="center">
                      <input name="peso_per" type="text" id="peso_per" value="0.0" size="5">
                  </div></td>
                  <td><div align="center">
                      <input name="peso_eq" type="text" id="peso_eq" value="0.0" size="5">
                  </div></td>
                  <td><div align="center"><span class="lblForm">
                      <select name="tipo_mpass" id="tipo_mpass">
                        <option value="PASAJERO">PASAJERO</option>
                        <option value="TRIPULANTE">TRIPULANTE</option>
                      </select>
                  </span> </div></td>
                  <td><div align="center">
                      <select name="ccosto" id="select">
                        <option value="0" <? if($ccosto=="0"){?> selected <? }?>>..........</option>
                        <?=$objPer->getCboCCostoT($ccosto);?>
                      </select>
                  </div></td>
                  <td><div align="center">
                      <select name="origen" id="select7">
                        <option value="0" <? if($origen=="0"){?> selected <? }?>>Origen</option>
                        <?=$objPer->getCboOrigenMan1($origen,$cod_ruta);?>
                      </select>
                  </div></td>
                  <td><div align="center">
                      <select name="destino" id="select6">
                        <option value="0" <? if($destino=="0"){?> selected <? }?>>Destino</option>
                        <?=$objPer->getCboDestinoMan1($destino,$cod_ruta);?>
                      </select>
                  </div></td>
                  <td><div align="center">
                    <input name="boton_agreper" type="button" class="botira" id="boton_agreper" style="<?=$stylo['st2']?>" value="&gt;&gt;" onClick="AgregarDatosPerEdit()">
                    <!-- <a href="#" onClick="AgregarDatosPer()"><img src="../imagenes/btn_siguiente.gif" width="15" height="15" border="0"></a> --></div></td>
                </tr>
                <tr>
                  <td>&nbsp;</td>
                  <td colspan="3"><div id="lista">&nbsp;</div></td>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                </tr>
                <tr>
                  <td colspan="11"><div id="lista_personal"><? include('p_per_detalle_ver.php');?></div></td>
                  </tr>
                <tr>
                  <td colspan="11">&nbsp;</td>
                </tr>
              </table></td>
            </tr>
            <tr class="lblCampo">
              <td colspan="6"><div align="left">
                <table width="868" border="1" cellspacing="0" cellpadding="0" style="<?=$stylo['tabla']?>">
                  <tr bgcolor="<?=$c_fondo_tr["fondo tr"]?>" class="lblCampoBlanco">
                    <td colspan="11" class="lblCampoBlanco">Detalle del Embarque </td>
                    </tr>
                  <tr valign="top" class="lblCampo">
                    <td width="180"><div align="center" class="lblCampoBlanco">Descripcion</div></td>
                    <td width="114"><div align="center" class="lblCampoBlanco">Empresa</div></td>
                    <td width="65"><div align="center" class="lblCampoBlanco">G. Remision</div></td>
                    <td width="100"><div align="center" class="lblCampoBlanco">C. Costo </div></td>
                    <td width="68"><div align="center" class="lblCampoBlanco">Origen</div></td>
                    <td width="72"><div align="center" class="lblCampoBlanco">Destino</div></td>
                    <td width="52"><div align="center" class="lblCampoBlanco">Carga </div></td>
                    <td width="82"><div align="center" class="lblCampoBlanco">U. M. </div></td>
                    <td width="41"><div align="center" class="lblCampoBlanco">Cantidad</div></td>
                    <td width="40"><div align="center" class="lblCampoBlanco"> Kg </div></td>
                    <td width="30"><div align="center"></div></td>
                  </tr>
                  <tr>
                    <td>
                        <div align="left">
                          <input name="des_w" type="text" id="nombres3" size="30">
                      </div></td><td><div align="center">
                      <input name="compania" type="text" id="compania" size="18">
                    </div></td>
                    <td><div align="center">
                      <input name="guia_w" type="text" id="peso_mpass23" size="11">
                    </div></td>
                    <td><div align="center">
                      <select name="ccosto_w" id="select2">
                        <option value="0" <? if($ccosto_w=="0"){?> selected <? }?>>Centro Costo</option>
                        <?=$objPer->getCboCCostoT($filas['centrocosto']);?>
                      </select>
                    </div></td>
                    <td><div align="center">
                      <select name="origen_w" id="select3">
                        <option value="0" <? if($origen_w=="0"){?> selected <? }?>>Origen</option>
                        <?=$objPer->getCboOrigenMan1($origen_w,$cod_ruta);?>
                      </select>
                    </div></td>
                    <td><div align="center">
                      <select name="destino_w" id="select4">
                        <option value="0" <? if($destino_w=="0"){?> selected <? }?>>Destino</option>
                        <?=$objPer->getCboDestinoMan1($destino_w,$cod_ruta);?>
                      </select>
                    </div></td>
                    <td><div align="center">
                      <select name="ttc" id="ttc">                        
                        <option value="Int">Int</option>
						<option value="Ext">Ext</option>
                      </select>
                    </div></td>
                    <td><div align="center">
                      <select name="tipounidad" id="tipounidad">
                        <option value="UND">UND</option>
                        <option value="KG">KG</option>
                        <option value="BULTOS">BULTOS</option>
                        <option value="GAL">GALONES</option>
                      </select>
                    </div></td>
                    <td><div align="center">
                      <input name="cant_w" type="text" id="peso_mpass22" value="0" size="5" maxlength="5">
                    </div></td>
                    <td><div align="center">
                      <input name="peso_w" type="text" id="pesoeq_mpass22" value="0.00" size="8" maxlength="20">
                    </div></td>
                    <td><div align="center">
                      <input name="boton_agrecar" type="button" class="botira" id="boton_agrecar" style="<?=$stylo['st2']?>" value="&gt;&gt;" onClick="AgregarDatosCarEdit()">
                      <!-- <a href="#" onClick="AgregarDatosCar()"><img src="../imagenes/btn_siguiente.gif" width="15" height="15" border="0"></a> --></div></td>
                  </tr>
                  <tr>
                    <td colspan="11"><div id="lista_carga"><? include('p_carga_detalle_ver.php');?></div></td>
                    </tr>
                </table>
              </div></td>
            </tr>
            <tr class="lblCampo">
              <td colspan="6">&nbsp;</td>
            </tr>
            <tr class="lblCampo">
              <td colspan="6"><div align="left">
                <table width="862" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td width="261"><div align="left">Comentarios</div></td>
                    <td colspan="3">&nbsp;</td>
                  </tr>
                  <tr>
                    <td colspan="4"><div align="left">
                      <textarea name="obser" cols="160" id="obser"><?=$rowman['obser']?>
                      </textarea>
                    </div></td>
                    </tr>
                  <tr>
                    <td>&nbsp;</td>
                    <td width="281">&nbsp;</td>
                    <td width="231">&nbsp;</td>
                    <td width="89">&nbsp;</td>
                  </tr>
                  <tr>
                    <td><div align="left">Representante por Perenco </div></td>
                    <td><div align="left"></div></td>
                    <td><div align="left">Responsable por Transporte </div></td>
                    <td><div align="left"></div></td>
                  </tr>
                  <tr>
                    <td><div align="left">
                      <input name="repre" type="text" id="repre" value="<?=$rowman['repre']?>" size="50">
                      <?=$contador?>
</div></td>
                    <td><div align="left"></div></td>
                    <td><div align="left">
                      <input name="respon" type="text" id="respon" value="<?=$rowman['respon']?>" size="50">
                    </div></td>
                    <td><div align="left"></div></td>
                  </tr>
                </table>
              </div></td>
            </tr>
            <tr class="lblCampo">
              <td colspan="6"><div id="lugar_mensaje"></div></td>
            </tr>
            <tr class="lblCampo">
              <td colspan="6"><div align="center">
                <table width="600" border="0" cellpadding="0" cellspacing="0">
                  <tr>
                    <td width="120">
                        <div align="left">
                          <input name="boton_grabar" type="button" class="botira" id="boton_grabar" style="<?=$stylo['st2']?>" onClick="enviarDatosEditarMan()" value=".::         Grabar         ::.">
                          </div></td>
                    <td width="120"><div align="center">
                      <input name="boton_print" type="button" class="botira" id="boton_print" style="<?=$stylo['st2']?>" onClick="PrintManifiesto('p_manifiesto_print_dir.php?cod_man=<?=$cod_man?>&cod_ruta=<?=$cod_ruta?>&via=<?=$via?>',600,800)" value=".::       Imprimir       ::.">
                    </div></td>
                    <td width="120">
                      <div align="center">
					  <? if($contador>1){?>
                        <input name="boton_plan" type="button" id="boton_plan2" value=".::     Plan de Viaje    ::." onClick="PrintPlanViaje('p_plan_viaje_print.php?cod_man=<?=$cod_man?>&cod_ruta=<?=$cod_ruta?>&via=<?=$via?>',600,800)" class="botira" style="<?=$stylo['st2']?>" >
						<? }elseif($contador<=1){?>
						<input name="boton_plan" type="button" id="boton_plan2" value=".::     Plan de Viaje    ::." onClick="PrintPlanViaje('p_plan_viaje_print.php?cod_man=<?=$cod_man?>&cod_ruta=<?=$cod_ruta?>&via=<?=$via?>',600,800)" class="botira" style="<?=$stylo['st2']?>" disabled>
						<? }?>
</div></td>
                    <td width="120"><div align="center">
                      <input name="boton_regresa" type="button" class="botira" id="boton_regresa2" style="<?=$stylo['st2']?>" onClick="volver(this.form)" value=".::      Regresar       ::.">
                    </div></td>
                    <td width="120"><div align="left">
                      <input name="boton_salir" type="button" class="botira" id="boton_salir" style="<?=$stylo['st2']?>" onClick="salir(this.form);" value=".::       Cancelar      ::.">
                    </div></td>
                  </tr>
                </table>
              </div></td>
            </tr>
            
          </table>
      </div></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">&nbsp;</td>
      <td><img src="../estilo_tabla/parte_inf_der.gif" width="25" height="25"></td>
    </tr>
  </table>
  <map name="MapMapMap">
    <area shape="rect" coords="1,4,21,21" href="#" onClick="salir(this.form);">
  </map>
</form>
<map name="MapMap">
  <area shape="rect" coords="3,4,23,21" href="fondo.php">
</map>



</body>
</html>

