<?
session_start();
if($fun==1){
include("Funciones.php");
include("funcion/funciones.php");
}
if($v==1){
include("stilos/config.inc.php");
}
?>
<table width="870" border="1" cellpadding="0" cellspacing="0" bordercolor="<?=$bordetabla?>" bgcolor="<?=$c_fondo['fondo tabla']?>" style="<?=$stylo['tabla']?>">
  
  <tr class="lblCampoBlanco" bgcolor="<?=$c_fondo_tr["fondo tr"]?>">
    <td width="17"><div align="center" class="lblCampoBlanco">#</div></td>
    <td width="41"><div align="center" class="lblCampoBlanco">De</div></td>
    <td width="41"><div align="center" class="lblCampoBlanco">Para</div></td>
    <? if($via=='A'){?><td width="30" ><div align="center" class="lblCampoBlanco">HAR</div></td><? }?>
    <td width="33"><div align="center" class="lblCampoBlanco">HAI</div></td>
    <td width="30"><div align="center" class="lblCampoBlanco">
	HTI     
    </div></td>
    <td width="31"><div align="center" class="lblCampoBlanco">HDES</div></td>
    <? if($via=='A'){?><td width="32"><div align="center" class="lblCampoBlanco">HAP
      
    </div></td><? }?>
    <td width="28"><div align="center" class="lblCampoBlanco">THD</div></td>
    <td width="27"><div align="center" class="lblCampoBlanco">TVC</div></td>
    <td width="33"><div align="center" class="lblCampoBlanco">TVT</div></td>
    <td width="60"><div align="center" class="lblCampoBlanco">Combust.</div></td>
    <td width="55"><div align="center" class="lblCampoBlanco">Fact.</div></td>
    <td width="60"><div align="center" class="lblCampoBlanco">Fecha Sal </div></td>
    <td width="80"><div align="center" class="lblCampoBlanco">Fecha Ate. </div></td>
    <td width="30"><div align="center" class="lblCampoBlanco">Pax</div></td>
    <td width="45"><div align="center" class="lblCampoBlanco">Carga</div></td>
    <td width="90"><div align="center" class="lblCampoBlanco">Observaciones</div></td>
    <td width="48"><div align="center" class="lblCampoBlanco">Prog.</div></td>
    <td width="17"><input name="verificar" type="hidden" size="3" id="verificar" value="<?=$verificar?>">    </td>
  </tr>
  <?php
if($q==1){	   
$rsd=$objPer->getDatosViajeDet($cod_ruta);	
while($rowd=$objPer->NextRow($rsd)){

$har=$rowd['har'];
$hs=$rowd['hs'];
$hl=$rowd['hl'];											
$hap=$rowd['hap'];																				
$de=$rowd['de'];
$para=$rowd['para'];											
$distancia=$rowd['distancia'];
$obser=$rowd['obser'];
$cod_rutadet=$rowd['cod_rutadet'];
$combustible=$rowd['combus'];
$facturable=$rowd['factu'];
$thpv=$rowd['tvcom'];
$thpt=$rowd['tvtec'];
$tvhm=substr($rowd['tvhm'],0,5);
$tvthm=substr($rowd['tvthm'],0,5);
$programado=$rowd['programado'];
$fechasalida=extraerfechanormal($rowd['fechasalida']);
$fechallegada=extraerfechanormal($rowd['fechallegada']);
$hdes=$rowd['hdes'];
$tvdhm=$rowd['tvdhm'];
$pax=$rowd['pax'];
$carga=$rowd['carga'];
						
$control_v[]=array("$har",$hs,$hl,$hap,$de,$para,$distancia,$obser,$cod_rutadet,$combustible,$facturable,$thpv,$thpt,$tvhm,$tvthm,$programado,$fechasalida,$fechallegada,$hdes,$tvdhm,$pax,$carga);
}$objPer->Liberar($rsd);  
} 
$n=1;

if($v==1){
if (isset($control_v)){
$contarItem = count($control_v);
while(list($clave,$valor1)=each($control_v)){
$har=$valor1[0];
$hs=$valor1[1];
$hl=$valor1[2];											
$hap=$valor1[3];																				
$de=$valor1[4];
$para=$valor1[5];											
$distancia=$valor1[6];
$obser=$valor1[7];
$cod_rutadet=$valor1[8];
$combustible=$valor1[9];
$facturable=$valor1[10];
$thpv=$valor1[11];
$thpt=$valor1[12];
$tvhm=$valor1[13];
$tvthm=$valor1[14];
$programado=$valor1[15];
$fechasalida=$valor1[16];
$fechallegada=$valor1[17];
$hdes=$valor1[18];
$tvdhm=$valor1[19];
$pax=$valor1[20];
$carga=$valor1[21];
?>
  <tr >
    <td><div align="center"><?=$n++;?></div></td>
    <td><div align="center">
      <? if($cod_rutadet!=''){?>
      <select onFocus="Focus(this.id, this.options[this.options.selectedIndex].value)" onBlur="Blur(this.id, this.options[this.options.selectedIndex].value, 'de', <?=$cod_rutadet;?>, '<?=$cod_ruta;?>', '1', '<?=$via;?>', '<?=$clave;?>')" class="inputoff" id="a<?=$cod_rutadet;?>" >
        <?=$objPer->getCboLugaresDef($de);?>
      </select>
      <? }else{ echo $de;}?>
    </div></td>
    <td><div align="center">
	<? if($cod_rutadet!=''){?>
	<select onFocus="Focus(this.id, this.options[this.options.selectedIndex].value)" onBlur="Blur(this.id, this.options[this.options.selectedIndex].value, 'para', <?=$cod_rutadet;?>, '<?=$cod_ruta;?>', '1', '<?=$via;?>', '<?=$clave;?>')" class="inputoff" id="b<?=$cod_rutadet;?>">
	<?=$objPer->getCboLugaresDef($para);?>
    </select>
	<? }else{ echo $para;}?>
	</div></td>
    <? if($via=='A'){?><td><div align="center">
	<? if($cod_rutadet!=''){?>
	<input class="inputoff" id="c<?=$cod_rutadet;?>" onFocus="Focus(this.id, this.value)" onBlur="Blur(this.id, this.value, 'har', <?=$cod_rutadet;?>, '<?=$cod_ruta;?>', '1', '<?=$via;?>', '<?=$clave;?>')" value="<?=$har;?>" size="5" maxlength="5">
	<? //$distancia?>	
	<? }else{ echo $har;}?>
    </div></td><? }?>
    <td><div align="center">
	<? if($cod_rutadet!=''){?>
	<input class="inputoff" id="d<?=$cod_rutadet;?>" onFocus="Focus(this.id, this.value)" onBlur="Blur(this.id, this.value, 'hs', <?=$cod_rutadet;?>, '<?=$cod_ruta;?>', '1', '<?=$via;?>', '<?=$clave;?>')" value="<?=$hs;?>" size="5" maxlength="5">
	<? }else{ echo $hs;}?>
    </div></td>
    <td><div align="center">
	<? if($cod_rutadet!=''){?>
	<input class="inputoff" id="e<?=$cod_rutadet;?>" onFocus="Focus(this.id, this.value)" onBlur="Blur(this.id, this.value, 'hl', <?=$cod_rutadet;?>, '<?=$cod_ruta;?>', '1', '<?=$via;?>', '<?=$clave;?>')" value="<?=$hl;?>" size="5" maxlength="5">
	<? }else{ echo $hl;}?>
    </div></td>
    <td><div align="center">
	  <? if($cod_rutadet!=''){?>
	  <input class="inputoff" id="o<?=$cod_rutadet;?>" onFocus="Focus(this.id, this.value)" onBlur="Blur(this.id, this.value, 'hdes', <?=$cod_rutadet;?>, '<?=$cod_ruta;?>', '1', '<?=$via;?>', '<?=$clave;?>')" value="<?=$hdes;?>" size="5" maxlength="5">
	  <? }else{ echo $hdes;}?>
	</div></td>
    <? if($via=='A'){?><td><div align="center">
	<? if($cod_rutadet!=''){?>
	<input class="inputoff" id="f<?=$cod_rutadet;?>" onFocus="Focus(this.id, this.value)" onBlur="Blur(this.id, this.value, 'hap', <?=$cod_rutadet;?>, '<?=$cod_ruta;?>', '1', '<?=$via;?>', '<?=$clave;?>')" value="<?=$hap;?>" size="5" maxlength="5">
	<? }else{ echo $hap;}?>
    </div></td><? }?>
    <td><div align="center">
      <?	
	  if($v==1){
	  
		  if($via=='A'){		  
			  //$hmv=calcular_tiempo_trasnc($hl,$hs);			  
		  echo $tvdhm; 
		  //echo convertirhhmmtohoras($tvhm)."/".$tvhm; 
		  //$thpvola=calcular_tiempo_trasnc($hdes,$hl);
		  $thpvola=calcular_horas_formato_inversa1($tvhm);
		  //$thpv=convertirhhmmtohoras($tvhm);
			  
			}
	  }
	  $thd=$thd+$thpvola;
       
	  $thatt=$thatt+$that;
	  ?>
    </div></td>
    <td><div align="center">
      <?	
	  if($v==1){
	  
		  if($via=='A'){		  
			  //$hmv=calcular_tiempo_trasnc($hl,$hs);
			  $hmv=$thpv;
		  echo round($hmv,2)."/".$tvhm; 
		  //echo convertirhhmmtohoras($tvhm)."/".$tvhm; 
		  $thpvol=calcular_tiempo_trasnc($hdes,$hs);
		  //$thpv=convertirhhmmtohoras($tvhm);
			  
			}elseif($via=='F'){
			$hmv=calcular_tiempo_trasnc($hl,$hs);
			  echo round($hmv,2)."/".$tvhm; 
			  $thpvol=calcular_tiempo_trasnc($hl,$hs);
			}
	  }
	  $th=$th+$thpvol;
       
	  $thatt=$thatt+$that;
	  ?>
    </div></td>
    <td><div align="center">
      <?
	if($v==1){
	$hmt=calcular_tiempo_trasnc($hap,$har);
	echo round($hmt,2)."/".$tvthm;
	$thpt=calcular_tiempo_trasnc($hap,$har);
	}
	 $tht=$tht+$thpt;
	?>
	</div></td>
    <td><div align="center">
	<? if($cod_rutadet!=''){?>
      <input class="inputoff" id="h<?=$cod_rutadet;?>" onFocus="Focus(this.id, this.value)" onBlur="Blur(this.id, this.value, 'combustible', <?=$cod_rutadet;?>, '<?=$cod_ruta;?>', '1', '<?=$via;?>', '<?=$clave;?>')" value="<?=$combustible;?>" size="10" maxlength="12">
	  <? }else{ echo $combustible;}
	  if($facturable=='SI'){	 
	  $totalcombus=$totalcombus+$combustible;
	  }
	  ?>
	</div></td>
    <td><div align="center">
	<? if($cod_rutadet!=''){?>
      <select class="inputoff" id="i<?=$cod_rutadet;?>" onFocus="Focus(this.id, this.options[this.options.selectedIndex].value)" onBlur="Blur(this.id, this.options[this.options.selectedIndex].value, 'facturable', <?=$cod_rutadet;?>, '<?=$cod_ruta;?>', '1', '<?=$via;?>', '<?=$clave;?>')">
        <option value="SI" <? if($facturable=='SI'){?> selected<? }?>>SI</option>
        <option value="NO" <? if($facturable=='NO'){?> selected<? }?>>NO</option>
      </select>
	<? }else{ echo $facturable;}?>
</div></td>
    <td><div align="center">        
	  <? if($cod_rutadet!=''){?>
	  <input name="Input" class="inputoff" id="m<?=$cod_rutadet;?>" onFocus="Focus(this.id, this.value)" onBlur="Blur(this.id, this.value, 'fechasalida', <?=$cod_rutadet;?>, '<?=$cod_ruta;?>', '1', '<?=$via;?>', '<?=$clave;?>')" value="<?=$fechasalida;?>" size="10">
	  <? }else{ echo $fechasalida;}
	  //echo $fechasalida;
	  ?>
</div></td>
    <td><div align="center">
      <? if($cod_rutadet!=''){?>
      <input name="Input" class="inputoff" id="n<?=$cod_rutadet;?>" onFocus="Focus(this.id, this.value)" onBlur="Blur(this.id, this.value, 'fechallegada', <?=$cod_rutadet;?>, '<?=$cod_ruta;?>', '1', '<?=$via;?>', '<?=$clave;?>')" value="<?=$fechallegada;?>" size="10">
      <? }else{ echo $fechallegada;}
	  //echo $fechallegada;
	  ?>

    </div></td>
    <td><div align="center">
	<? if($cod_rutadet!=''){?>
	<input name="Input" class="inputoff" id="p<?=$cod_rutadet;?>" onFocus="Focus(this.id, this.value)" onBlur="Blur(this.id, this.value, 'pax', <?=$cod_rutadet;?>, '<?=$cod_ruta;?>', '1', '<?=$via;?>', '<?=$clave;?>')" value="<?=$pax;?>" size="5">
	<? }else{ echo $pax;}?>
	</div></td>
    <td><div align="center">
	<? if($cod_rutadet!=''){?>
	<input name="Input" class="inputoff" id="q<?=$cod_rutadet;?>" onFocus="Focus(this.id, this.value)" onBlur="Blur(this.id, this.value, 'carga', <?=$cod_rutadet;?>, '<?=$cod_ruta;?>', '1', '<?=$via;?>', '<?=$clave;?>')" value="<?=$carga;?>" size="5">
	<? }else{ echo $carga;}?>
	</div></td>
    <td><div align="center">
      <? if($cod_rutadet!=''){?>
      <input name="Input" class="inputoff" id="g<?=$cod_rutadet;?>" onFocus="Focus(this.id, this.value)" onBlur="Blur(this.id, this.value, 'obser', <?=$cod_rutadet;?>, '<?=$cod_ruta;?>', '1', '<?=$via;?>', '<?=$clave;?>')" value="<?=$obser;?>" size="15">
      <? }else{ echo $obser;}?>
</div></td>
    <td><div align="center">
	<? if($cod_rutadet!=''){?>
      <select class="inputoff" id="j<?=$cod_rutadet;?>" onFocus="Focus(this.id, this.options[this.options.selectedIndex].value)" onBlur="Blur(this.id, this.options[this.options.selectedIndex].value, 'programado', <?=$cod_rutadet;?>, '<?=$cod_ruta;?>', '1', '<?=$via;?>', '<?=$clave;?>')">
        <option value="S" <? if($programado=='S'){?> selected<? }?>>S</option>
        <option value="N" <? if($programado=='N'){?> selected<? }?>>N</option>
        <option value="M" <? if($programado=='M'){?> selected<? }?>>M</option>
        <option value="I" <? if($programado=='I'){?> selected<? }?>>I</option>
      </select>
	<? }else{ echo $programado;}?>
	</div></td>
    <td><div align="center">
	<? if($cod_rutadet!=''){?>
	<a href="#" onClick="DatosDeleteItem('<?=$clave?>',<?=$cod_rutadet?>,'<?=$via?>')"><img src="../imagenes/btn_eliminar.gif" width="15" height="15" border="0"></a>
	<? }else{?>
	<a href="#" onClick="DatosDeleteItem1('<?=$clave?>','<?=$via?>')"><img src="../imagenes/btn_eliminar.gif" width="15" height="15" border="0"></a>
	<? }?>
	</div></td>
  </tr>
  
  <?php }}}?>
  <tr class="lblCampo">
    <td colspan="8"><div align="center">
    </div>      <div align="center">
      <input name="tvcom" type="hidden" value="<?=$th?>" size="4">
      <input name="tvhm" type="hidden" id="tvhm2" value="<? if($th!=''){echo calcular_horas_formato_inversa($th);}?>" size="4">
      <input name="tvtec" type="hidden" size="3" id="tvtec3" value="<?=$tht?>">
      <input name="numeroingre" type="hidden" size="5" id="numeroingre" value="<?=$_SESSION['canasta_viaje']=count($control_v); ?>">
</div></td>
    <? if($via=='A'){?><? }?>
    <? if($via=='A'){?><? }?>
    <td><div align="center"></div>      <div align="center"></div>      <div align="center"></div>      <div align="center"></div>      <div align="center"></div>      <div align="center"></div>      <div align="center"></div>      <div align="center"></div>      <div align="center"></div>      <div align="center"></div>      <div align="center"></div>      <div align="center"></div>      <div align="center"></div>      <div align="center"></div></td>
    <td><div align="center">
      <?
	   if($v==1){
	  $tvhm;
	  //echo $th."/".calcular_horas_formato_inversa($th);
	  echo round($th,2)."/".calcular_horas_formato_inversa($th);
	  $_SESSION['th1']=$th;
	  $thoras=$th;
	  $thoramintvc=calcular_horas_formato_inversa($th);
	  $_SESSION['thvhm1']=$thoramintvc;
	  }
	  ?>
    </div></td>
    <td><div align="center">
      <?
	   if($v==1){
	  echo round($tht,2)."/".calcular_horas_formato_inversa($tht);
	  $_SESSION['tht1']=$tht;
	  $thoras=$tht;
	  $thoramintvt=calcular_horas_formato_inversa($tht);
	  $_SESSION['ththm1']=$thoramintvt;
	  }
	  ?>
    </div></td>
    <td>          <div align="center">
      <? 
	  if($v==1){	
	  echo $totalcombus;
	  $_SESSION['tcombustible']=$totalcombus;	  
	  }
	  ?>
</div></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td><div align="center"></div></td>
    <td>&nbsp;</td>
  </tr>
</table>

