<?php
session_start();
//set_time_limit(0);
  include("stilos/config.inc.php");
  include("../clases/BDConexion.php");
  include("../clases/clsPer.php");
  include("funcion/funciones.php");
  include("Funciones.php");
 
  $objPer=new clsPer;

header("Pragma: public");
header("Expires: 0");
$filename = "nombreArchivoQueDescarga.xls";
//header("Content-type: application/x-msdownload");
header("Content-type: application/x-msexcel");
//header('Content-type: application/vnd.ms-excel');
header("Content-Disposition: attachment; filename=$filename");
header("Pragma: no-cache");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
/* function redondeado($numero, $decimales) {
$factor = pow(10, $decimales);
return (round($numero*$factor)/$factor); }  */

function redondeodecimal($valor){
$float_redondeado=round($valor * 100) / 100;
return $float_redondeado;
}
$rsdato=$objPer->getManTrans($matricula);				
 $rowdato=$objPer->NextRow($rsdato); 
 $mm=substr($fecha1,3,2); 
?>
<!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 href="Estilos.css" rel="stylesheet" type="text/css">

<link href="stilos/Estilos.css" rel="stylesheet" type="text/css">

<!-- Copyright 2000,2001 Macromedia, Inc. All rights reserved. -->
<script language="JavaScript">
var nav = (navigator.appName).search("Microsoft");
function aCapa(capa, accion)
{
var act='none';
if (accion=='abrir') { act = 'block'; }
if (nav==-1)
{
document.getElementById(capa).style.display = act;
} else {
eval("document.all." + capa + ".style.display = act;")
}
return;
}
</script>
<SCRIPT language=JavaScript src="js/calendario.js"></SCRIPT>
<script language="javascript" type="text/javascript">
  function volver(){
     window.location="fondo.php";
                   }
</script>
</head>

<body background="../imagenes/fondo.jpg">
<table width="1017" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="199" height="15"><div align="left"></div></td>
    <td width="818"><div align="left" class="lblTitulo"></div></td>
  </tr>
  <tr class="lblCampo">
    <td colspan="2"><div align="left">
      <table width="834" border="0">
        <tr>
          <td width="205"><div align="left"><img src="../imagenes/logo_perenco.GIF" width="150" height="54"></div></td>
          <td width="619"><span class="lblTitulo">HORAS-COSTO-COMBUSTIBLE POR <br>
CENTRO DE COSTO Y TRANSPORTE DEL DIA</span></td>
        </tr>
        <tr>
          <td colspan="2"><div align="left"> <a href=# onclick="aCapa('container','abrir')">Ver</a> <a href=# onclick="aCapa('container','cerrar')">Ocultar</a> </div></td>
        </tr>
        <tr>
          <td colspan="2"><div align="left">
              <div id="container">
                <div id="vertical_container" >
                  <?
$days1='01';
$mesess=$month;
$anioss=$year;
$fecha1=$days1."-".$mesess."-".$anioss;
$fecha2=$days."-".$mesess."-".$anioss;
$rstrans=$objPer->TransT($matricula,$ccosto,extraerfechamysql($fecha1),extraerfechamysql($fecha2));
$totalfilasResumen = $objPer->totalrows($rstrans);
while ($rowtrans=$objPer->NextRow($rstrans)){

?>
                  <h1 align="left" class="accordion_toggle">
                    <?=$rowtrans['model_trans']." / ".$rowtrans['mat_trans']?>
                  </h1>
                  <div class="accordion_content">
                    <table width="402" border="1" cellpadding="0" cellspacing="0" style="<?=$stylo['tabla']?>" bgcolor="<?=$c_fondo['fondo tabla']?>" bordercolor="<?=$bordetabla?>">
                      <tr class="lblCampoBlanco" bgcolor="<?=$c_fondo_tr["fondo tr"]?>">
                        <?
				$mess=substr($fecha1,3,2);
		  		$anio=substr($fecha1,6,4);
				$day="01";
				
				
				$diass=date(d);
				$ultimodia=date("t",mktime(0,0,0,$mesess,$diass,$anioss));
				
				
				$rspcp=$objPer->manpercarpesodispeso($rowtrans['mat_trans'],extraerfechamysql($fecha1),extraerfechamysql($fecha2));//
				$rowpcp=$objPer->NextRow($rspcp);
				
				$rstipohora=$objPer->getConsolVuelos($rowtrans['mat_trans'],extraerfechamysql($fecha1),extraerfechamysql($fecha2));
				$rowtipohora=$objPer->NextRow($rstipohora);
				
				$abcde=1;
				$rst=$objPer->getTransTarifa($rowtrans['mat_trans']); 
				$rowt=$objPer->NextRow($rst);				
					
				$rsthi=$objPer->getHoraIndisponible($rowtrans['mat_trans'],extraerfechamysql($fecha1),extraerfechamysql($fecha2));
				$rowthi=$objPer->NextRow($rsthi);
				
				//$rowthi['horasv']."-".$rowthi['horastec'];
							
				
				?>
                        <td width="201"><div align="center">Centros de costos </div></td>
                        <? //for($j=$days1;$j<=$days;$j++){?>
                        <td width="69"><div align="center"> Dia
                          <?=$days;?>
                        </div></td>
                        <? //}?>
                        <td width="124"><div align="center"></div></td>
                      </tr>
                      <?
				$n=0;
				$totalhoracol1=0;
				$pertotal=0;
				$cartotal=0;				
				$rscd=$objPer->manpercardiasTransCC($rowtrans['mat_trans'],$ccosto,extraerfechamysql($fecha2),extraerfechamysql($fecha2));
				$totalfilas=$objPer->totalrows($rscd);
				while($rowcd=$objPer->NextRow($rscd)){
				$n++;
				$tothorascc1=0;
				$sumap=0;
				$perpar=0;
				$carpar=0;
				
				?>
                      <tr class="lblCampo">
                        <td><div align="left">
                            <?=$rowcd['ccosto']?>
                        </div></td>
                        <? //?>
                        <td><div align="center">
                            <?
			if($rowpcp['sumdispercar']!='' || $rowpcp['sumdispercar']>0){
			$thdia=0;
		  	for($i=$days;$i<=$days;$i++){
					
				  if($rowcd['ccosto']){
				  $tt1=0;
				  $rshd=$objPer->getHorasxDiaRutaCod($rowtrans['mat_trans'],$anioss."-".$mesess."-".$i);
				  while($rowhd=$objPer->NextRow($rshd)){
				  
					      $rspcdc=$objPer->manpercarpesodisccRutaCod($rowtrans['mat_trans'],$rowcd['ccosto'],$anioss."-".$mesess."-".$i,$rowhd['cod_ruta']);
						  $rowpcdc=$objPer->NextRow($rspcdc);
						  
						  $rspcdt=$objPer->manpercarpesodishRutaCod($rowtrans['mat_trans'],$anioss."-".$mesess."-".$i,$rowhd['cod_ruta']);
						  $rowpcdt=$objPer->NextRow($rspcdt);
						  
						  $rstv=$objPer->manpercarHrsTecVol($rowtrans['mat_trans'],extraerfechamysql($fecha1),extraerfechamysql($fecha2));
						  $rowtv=$objPer->NextRow($rstv);		  		  	  
				  
				  if(($rowpcdt['dispesototal']!='') || ($rowpcdt['dispesototal']!=0) || ($rowpcdt['dispesototal']!=NULL)){
								if($rowpcdt['dispesototal']!=0){$dispercar=$rowpcdc['dispercar']; $dispesototal=$rowpcdt['dispesototal'];}else{$dispercar=1; $dispesototal=1;} 
				  				if($rowtipohora['tipohora']=='T'){ $tipoh=$rowhd['horastec'];$tipohora=$rowtv['horatec'];}else{$tipoh=$rowhd['horasvol']; $tipohora=$rowtv['horavol'];}
				  		  if($rowcd['ccosto']==$rowpcdc['ccosto']){
						  $t=(($dispercar/$dispesototal)*$tipoh*60)."<br>";
						  $tt1+=(($dispercar/$dispesototal)*$tipoh*60)."<br>";				 
						  $sumap+=$dispercar;
						  
						  $tothorasccosto=$tipohora;
						  $tothorascc1+=($t);				  //desbloquear luego de probar 
				  	
				  		  $horasdia[]=array($rowtrans['mat_trans'],$rowcd['ccosto'],$i,$t);
						  if($days==$i){
						  $combustible=$rowcombusi['combus'];
						  $thdia+=(($dispercar/$dispesototal)*$tipoh*60);
						  $cfhora=($rowt['tarifa']/28.5);
						  $cviaje=((round($tipohora)/3)*$rowt['tarifav']);
						  $choratrans=($rowt['tarifah']);
						  $horavoladas=$tipohora;
						  $horasdiacum[]=array($rowtrans['mat_trans'],$rowcd['ccosto'],$i,$t,$cfhora,$cviaje,$horavoladas,$thdia,$choratrans,$combustible,round($t/60,5));
						  }	
						  }  
					 }else{					 	
					 		echo "&nbsp;";						
					 }
					 }
					 	      $timeh=round($tt1,5);
							  $timeho=round($timeh/60,3);
							  $sumahorav+=round($timeh/60,3);
							  $sumahorav1+=round($timeh/60,4);
							  if($timeho>0){echo $timeho;}else{echo "&nbsp;";}
					 }
					
					}
		  }else{
					echo "&nbsp;";
		  } 
				  ?>
                        </div></td>
                        <? //?>
                        <td><div align="center">
                            <?
				  if($rowcd['ccosto']){
				  $hcc=round($tothorascc1)/60;
				  //echo $tothorascc1;
				  round($tothorascc1)/60;
				  //echo calcular_horas_formato_inversa(round($tothorascc1)/60);
				  round($tothorascc1/60,3);				  
				  $totalhoracol=round($tothorascc1,1);
				  $totalhoracole=$tothorascc1;
				  $totalhoracol1+=$totalhoracol;
				  $dish[]=array($rowcd['ccosto'],$hcc);
				  }
				  ?>
                        </div></td>
                      </tr>
                      <? }$objPer->Liberar($rscd);?>
                      <tr class="lblCampoBlanco" bgcolor="<?=$c_fondo_tr["fondo tr"]?>">
                        <td>TOTALES</td>
                        <? //?>
                        <td><div align="center">
                            <?
			for($z=$days1;$z<=$days;$z++){			
			$sumahourdia=0;
			if(isset($horasdia)){
			foreach($horasdia as $indicehd=>$valuehd)
			{
				if($rowtrans['mat_trans']==$valuehd[0] && $z==$valuehd[2]){					
					$sumahourdia+=$valuehd[3];			
				}
			}
			} 
			
				  
				  }
				  if($sumahourdia!=''){
					if($sumahourdia!=0){ 
				  	
							  $divisorat=60;
							  $minutosat=60;
							  
							  $timeht=round(round($sumahourdia,1));
							  $timehot=round($timeht/60,2);
							  
							  $tminutosat=round($minutosat*$timehot);    
							  $cocienteat=floor($tminutosat/$divisorat);
							  
							  $restoat=$tminutosat%$divisorat;
							  if($restoat<10){
								if($cocienteat.":0".$restoat!='0:00'){
									echo $cocienteat.":0".$restoat;
								}
							  }else{
								if($cocienteat.":0".$restoat!='0:00'){
									echo $cocienteat.":".$restoat;
								}
							  }   
				  	$horaresumen[]=array($rowtrans['mat_trans'],$sumahourdia);
					$sumahourpt+=$sumahourp;
					}else{echo "&nbsp;";}
				}else{
					echo "&nbsp;";
				}
				  
				  ?>
                        </div></td>
                        <? //?>
                        <td><div align="center">
                            <?
				  //echo calcular_horas_formato_inversa(round($totalhoracol1)/60)."/".round(round($totalhoracol1)/60,2);
				  $tothorasccosto;
				  $tothorasccosto
				  ?>
                        </div></td>
                      </tr>
                    </table>
                  </div>
                  <? } $objPer->Liberar($rstrans);?>
                </div>
              </div>
          </div></td>
        </tr>
        <tr class="lblCampo">
          <td colspan="2"><div align="left">
              <? if($fecha1!=''){?>
              <table width="454" border="1" cellpadding="0" cellspacing="0" style="<?=$stylo['tabla']?>" bgcolor="<?=$c_fondo['fondo tabla']?>" bordercolor="<?=$bordetabla?>">
                <tr class="lblCampoBlanco" bgcolor="<?=$c_fondo_tr["fondo tr"]?>">
                  <td>Resumen Horas </td>
                  <td colspan="<?=$totalfilasResumen?>"><div align="center"></div></td>
                  <td width="89"><div align="center"></div></td>
                </tr>
                <tr class="lblCampoBlanco" bgcolor="<?=$c_fondo_tr["fondo tr"]?>">
                  <td width="277"><div align="left">Centros de Costo </div></td>
                  <? //for($kc=$days1;$kc<=$days;$kc++){
		  $rstransHori=$objPer->TransT($matricula,$ccosto,extraerfechamysql($fecha1),extraerfechamysql($fecha2));
		  $totalfilas = $objPer->totalrows($rstransHori);
		  while ($rowtransHori=$objPer->NextRow($rstransHori)){
		  ?>
                  <td width="80"><div align="center">
                      <?=$rowtransHori['mat_trans']?>
                  </div></td>
                  <? //}
		  } $objPer->Liberar($rstransHori);
		  ?>
                  <td><div align="center">Total Hora</div></td>
                </tr>
                <?
			
		$rstccs=$objPer->TransCCSel($matricula,$ccosto,extraerfechamysql($fecha1),extraerfechamysql($fecha2));
		while($rowtccs=$objPer->NextRow($rstccs)){
		//if($rowtccs['ccosto']){ $dispax=array(); }
		$hourparcctrans=0;
		?>
                <tr>
                  <td><div align="left">
                    <?=$rowtccs['ccosto']?>
                  </div></td>
                  <? //for($h=$days1;$h<=$totalfilas;$h++){
		  $rstransVerti=$objPer->TransT($matricula,$ccosto,extraerfechamysql($fecha1),extraerfechamysql($fecha2));
		  $totalfilasV = $objPer->totalrows($rstransVerti);
		  while ($rowtransVerti=$objPer->NextRow($rstransVerti)){
		  
		  ?>
                  <td><div align="center">
                      <?
			
			$sumahourdiacum=0;
			//$sumahdiacum=0;
			if(isset($horasdiacum)){
			foreach($horasdiacum as $indicehda=>$valuehda)
			{
				if($rowtransVerti['mat_trans']==$valuehda[0] && $rowtccs['ccosto']==$valuehda[1]){	
			
					$sumahourdiacum+=$valuehda[3];
					
					//$horaparcialcctrans[]=array($rowtccs['ccosto'],$sumahourdiacum);
			
				}
				//if($rowtransVerti['mat_trans']==$valuehda[0]){$sumahdiacum+=$valuehda[7];}
			}
			}
			if($sumahourdiacum!=''){
			//echo calcular_horas_formato_inversa(($sumahourdiacum/60));
			echo round($sumahourdiacum/60,3);
			$hourparcctrans+=$sumahourdiacum;
			}else{echo "&nbsp;";}
			//$sumahourpt+=$sumahourp;
			
			?>
                  </div></td>
                  <? //}
		  } $objPer->Liberar($rstransVerti);
		  ?>
                  <td><div align="center">
                      <?
			/* $sumahp=0;
			foreach($dish as $claveh=>$valorh)
			{
				if($rowtccs['ccosto']==$valorh[0]){				  			  
				$sumahp+=$valorh[1];
				}
			}echo calcular_horas_formato_inversa($sumahp);
			$sumaht+=$sumahp; */
			echo calcular_horas_formato_inversa($hourparcctrans/60);
			?>
                  </div></td>
                </tr>
                <? } $objPer->Liberar($rstccs);?>
                <tr>
                  <td><div align="left">Total -&gt; </div></td>
                  <? //for($mc=$days1;$mc<=$totalfilas;$mc++){
		  $rstransT=$objPer->TransT($matricula,$ccosto,extraerfechamysql($fecha1),extraerfechamysql($fecha2));
		  $totalfilasT = $objPer->totalrows($rstransT);
		  while ($rowtransT=$objPer->NextRow($rstransT)){
		  ?>
                  <td><div align="center">
                      <?
			if(isset($horaresumen)){
			$sumahourtp=0;
			foreach($horaresumen as $indiceh => $valueh)
			{
				if($rowtransT['mat_trans']==$valueh[0]){	
						  			  
					$sumahourtp+=$valueh[1];
					
				}
			}echo calcular_horas_formato_inversa($sumahourtp/60);
			}
			
			
			?>
                  </div></td>
                  <? //}
		  } $objPer->Liberar($rstransT);
		  ?>
                  <td><div align="center">
                      <? //calcular_horas_formato_inversa($sumaht)?>
                  </div></td>
                </tr>
              </table>
              <? }?>
</div></td>
        </tr>
        <tr class="lblCampo">
          <td colspan="2"><div align="left">
              <? if($fecha1!=''){?>
              <table width="454" border="1" cellpadding="0" cellspacing="0" style="<?=$stylo['tabla']?>" bgcolor="<?=$c_fondo['fondo tabla']?>" bordercolor="<?=$bordetabla?>">
                <tr class="lblCampoBlanco" bgcolor="<?=$c_fondo_tr["fondo tr"]?>">
                  <td>Resumen Costo Hora </td>
                  <td colspan="<?=$totalfilasResumen?>"><div align="center"></div></td>
                  <td width="89">&nbsp;</td>
                </tr>
                <tr class="lblCampoBlanco" bgcolor="<?=$c_fondo_tr["fondo tr"]?>">
                  <td width="275"><div align="left">Centros de Costo </div></td>
                  <? //for($kc=$days1;$kc<=$days;$kc++){
		  $rstransHori=$objPer->TransT($matricula,$ccosto,extraerfechamysql($fecha1),extraerfechamysql($fecha2));
		  $totalfilas = $objPer->totalrows($rstransHori);
		  while ($rowtransHori=$objPer->NextRow($rstransHori)){
		  ?>
                  <td width="82"><div align="center">
                      <?=$rowtransHori['mat_trans']?>
                  </div></td>
                  <? //}
		  } $objPer->Liberar($rstransHori);
		  ?>
                  <td><div align="center">Total $ </div></td>
                </tr>
                <?
			
		$rstccs=$objPer->TransCCSel($matricula,$ccosto,extraerfechamysql($fecha1),extraerfechamysql($fecha2));
		while($rowtccs=$objPer->NextRow($rstccs)){
		//if($rowtccs['ccosto']){ $dispax=array(); }
		$ctotalcalcu=0;
		?>
                <tr>
                  <td><div align="left">
                      <?=$rowtccs['ccosto']?>
                  </div></td>
                  <? //for($h=$days1;$h<=$totalfilas;$h++){
		  $rstransVerti=$objPer->TransT($matricula,$ccosto,extraerfechamysql($fecha1),extraerfechamysql($fecha2));
		  $totalfilasV = $objPer->totalrows($rstransVerti);
		  while ($rowtransVerti=$objPer->NextRow($rstransVerti)){
		  ?>
                  <td><div align="center">
                      <?
			
			$sumahourdiacum=0;
			$sumahdiacum=0;
			$sumacfhdiacum=0;
			$sumacvdiacum=0;
			$sumahvolacum=0;
			$sumachvoltrans=0;
			foreach($horasdiacum as $indicehda=>$valuehda)
			{
				if($rowtransVerti['mat_trans']==$valuehda[0] && $rowtccs['ccosto']==$valuehda[1]){	
			
					$sumahourdiacum+=$valuehda[3];
					//$dishourtott[]=array($h,$sumahourp);
			
				} 
				if($rowtransVerti['mat_trans']==$valuehda[0]){$sumahdiacum+=$valuehda[7];$sumacfhdiacum=$valuehda[4];$sumacvdiacum=$valuehda[5];$sumahvolacum=$valuehda[6];$sumachvoltrans=$valuehda[8];}
			}
			if($sumahourdiacum!=''){
			calcular_horas_formato_inversa(($sumahourdiacum/60));
			calcular_horas_formato_inversa(($sumahdiacum/60));
			//($rowtrans['mat_trans'],$rowcd['ccosto'],$i,round($t),$cfhora,$cviaje,$horavoladas,$thdia);
			$hdiacc=($sumahourdiacum/60);
			//$hdiat=($sumahdiacum/60); 
			if(($sumahdiacum/60)!=''){
				if(($sumahdiacum/60)!=0){
					$hdiat=($sumahdiacum/60);	
				}
			}else{$hdiat=1;}
			$cfhtrans=$sumacfhdiacum;
			$cviajetrans=$sumacvdiacum;
			$horavoladatrans=$sumahvolacum;
			$costotranshora=$sumachvoltrans;
			
				 	if($rowtransVerti['mat_trans']=='OB-317'){
						echo $ctotalcal=round(($hdiacc/3)*$cviajetrans,2);
						
					}elseif($rowtransVerti['mat_trans']=='OB-1842 P'){									
						if($horavoladatrans<=40){
							$ci1=$hdiacc*(1000);
						}elseif($horavoladatrans>40 && $horavoladatrans<=60){ 							
							$ci1=$hdiacc*2500;
						}elseif($horavoladatrans>60){							
							$ci1=$hdiacc*2400;
						}
						$cotofijohdia=($cfhtrans/$hdiat)*$hdiacc;
						echo $ctotalcal=round($cotofijohdia+$ci1,2);
						
					}elseif($rowtransVerti['mat_trans']=='C-GKHL' || $rowtransVerti['mat_trans']=='C-FTVI'){											
							$cotofijohdia=($cfhtrans/$hdiat)*$hdiacc;
							$ci1=$hdiacc*(2400);
							
							echo $ctotalcal=round($cotofijohdia+$ci1,2);
							
					}elseif($rowtransVerti['mat_trans']=='CFIGR'){												
						if($horavoladatrans<=120){$ci1=$hdiacc*2800;}elseif($horavoladatrans>120){$ci1=$hdiacc*3190;}
						$cotofijohdia=($cfhtrans/$hdiat)*$hdiacc;						
						echo $ctotalcal=round($cotofijohdia+$ci1,2);
										
					}else{							
						$cotofijohdia=($cfhtrans/$hdiat)*$hdiacc;						
						echo $ctotalcal=round($cotofijohdia+($hdiacc*$costotranshora),2);
						
					} 
				$ctotalcalcu+=round($ctotalcal,2);
				$ctotalcalculado+=$ctotalcalcu;
				$CostoTotaldiaTrans[]=array($rowtransVerti['mat_trans'],round($ctotalcal,2));
			}else{echo "&nbsp;";}
			
			//$sumahourpt+=$sumahourp;
			
			?>
                  </div></td>
                  <? //}
		  } $objPer->Liberar($rstransVerti);
		  ?>
                  <td><div align="center">
                      <?
			echo $ctotalcalcu;
			?>
                  </div></td>
                </tr>
                <? } $objPer->Liberar($rstccs);?>
                <tr>
                  <td><div align="left">Total -&gt;</div></td>
                  <? //for($mc=$days1;$mc<=$totalfilas;$mc++){
		  $rstransT=$objPer->TransT($matricula,$ccosto,extraerfechamysql($fecha1),extraerfechamysql($fecha2));
		  $totalfilasT = $objPer->totalrows($rstransT);
		  while ($rowtransT=$objPer->NextRow($rstransT)){
		  ?>
                  <td><div align="center">
                      <?
			if(isset($CostoTotaldiaTrans)){
			$sumacostototal=0;
			foreach($CostoTotaldiaTrans as $indiceTotalCosto => $valueTotalCosto)
			{
				if($rowtransT['mat_trans']==$valueTotalCosto[0]){	
						  			  
					$sumacostototal+=$valueTotalCosto[1];
					
				}
			}echo $sumacostototal;//calcular_horas_formato_inversa($sumahourtp/60);
			}
			
			
			?>
                  </div></td>
                  <? //}
		  } $objPer->Liberar($rstransT);
		  ?>
                  <td><div align="center">
                      <? //calcular_horas_formato_inversa($sumaht)?>
                  </div></td>
                </tr>
              </table>
            <? }?>
          </div></td>
        </tr>
        <tr class="lblCampo">
          <td colspan="2"><div align="left">
              <? if($fecha1!=''){?>
              <table width="454" border="1" cellpadding="0" cellspacing="0" style="<?=$stylo['tabla']?>" bgcolor="<?=$c_fondo['fondo tabla']?>" bordercolor="<?=$bordetabla?>">
                <tr class="lblCampoBlanco" bgcolor="<?=$c_fondo_tr["fondo tr"]?>">
                  <td>Resumen JP-1 </td>
                  <td colspan="<?=$totalfilasResumen?>"><div align="center"></div></td>
                  <td width="89">&nbsp;</td>
                </tr>
                <tr class="lblCampoBlanco" bgcolor="<?=$c_fondo_tr["fondo tr"]?>">
                  <td width="277"><div align="left">Centros de Costo </div></td>
                  <? //for($kc=$days1;$kc<=$days;$kc++){
		  $rstransHori=$objPer->TransT($matricula,$ccosto,extraerfechamysql($fecha1),extraerfechamysql($fecha2));
		  $totalfilas = $objPer->totalrows($rstransHori);
		  while ($rowtransHori=$objPer->NextRow($rstransHori)){
		  ?>
                  <td width="80"><div align="center">
                      <?=$rowtransHori['mat_trans']?>
                  </div></td>
                  <? //}
		  } $objPer->Liberar($rstransHori);
		  ?>
                  <td><div align="center">Total $ </div></td>
                </tr>
                <?
			
		$rstccs=$objPer->TransCCSel($matricula,$ccosto,extraerfechamysql($fecha1),extraerfechamysql($fecha2));
		while($rowtccs=$objPer->NextRow($rstccs)){
		//if($rowtccs['ccosto']){ $dispax=array(); }
		$costocombuspar=0;
		?>
                <tr>
                  <td><div align="left">
                      <?=$rowtccs['ccosto']?>
                  </div></td>
                  <? //for($h=$days1;$h<=$totalfilas;$h++){
		  $rstransVerti=$objPer->TransT($matricula,$ccosto,extraerfechamysql($fecha1),extraerfechamysql($fecha2));
		  $totalfilasV = $objPer->totalrows($rstransVerti);
		  while ($rowtransVerti=$objPer->NextRow($rstransVerti)){
		  ?>
                  <td><div align="center">
                      <?
			
			$sumahourdiacum=0;
			$sumahdiacum=0;
			
			foreach($horasdiacum as $indicehda=>$valuehda)
			{
				if($rowtransVerti['mat_trans']==$valuehda[0] && $rowtccs['ccosto']==$valuehda[1]){			
					$sumahourdiacum+=$valuehda[3];		
				}
				if($rowtransVerti['mat_trans']==$valuehda[0]){$sumahdiacum+=$valuehda[7];$sumacfhdiacum=$valuehda[4];$sumacvdiacum=$valuehda[5];$sumahvolacum=$valuehda[6];$sumachvoltrans=$valuehda[8];$combust=$valuehda[9];}
			}
			if($sumahourdiacum!=''){
				$hdiacc=($sumahourdiacum/60);
				if(($sumahdiacum/60)!=''){
					if(($sumahdiacum/60)!=0){
						$hdiat=($sumahdiacum/60);	
					}
				}else{$hdiat=1;}
					if($costocombus!=''){$costocombusapli=$costocombus;}else{$costocombusapli=3;}
					echo round((($hdiacc*$combust)/$hdiat)*$costocombusapli,2);
					$discombust[]=array($rowtransVerti['mat_trans'],round((($hdiacc*$combust)/$hdiat)*$costocombusapli,2));
					$costocombuspar+=round((($hdiacc*$combust)/$hdiat)*$costocombusapli,2);
			}else{echo "&nbsp;";}
			
			//$sumahourpt+=$sumahourp;
			
			?>
                  </div></td>
                  <? //}
		  } $objPer->Liberar($rstransVerti);
		  ?>
                  <td><div align="center">
                      <?
			/* $sumahp=0;
			foreach($dish as $claveh=>$valorh)
			{
				if($rowtccs['ccosto']==$valorh[0]){				  			  
				$sumahp+=$valorh[1];
				}
			}echo calcular_horas_formato_inversa($sumahp);
			$sumaht+=$sumahp; */
			echo $costocombuspar;
			?>
                  </div></td>
                </tr>
                <? } $objPer->Liberar($rstccs);?>
                <tr>
                  <td><div align="left">Total -&gt;</div></td>
                  <? //for($mc=$days1;$mc<=$totalfilas;$mc++){
		  $rstransT=$objPer->TransT($matricula,$ccosto,extraerfechamysql($fecha1),extraerfechamysql($fecha2));
		  $totalfilasT = $objPer->totalrows($rstransT);
		  while ($rowtransT=$objPer->NextRow($rstransT)){
		  ?>
                  <td><div align="center">
                      <?
			/* if(isset($horaresumen)){
			$sumahourtp=0;
			foreach($horaresumen as $indiceh => $valueh)
			{
				if($rowtransT['mat_trans']==$valueh[0]){	
						  			  
					$sumahourtp+=$valueh[1];
					
				}
			}echo calcular_horas_formato_inversa($sumahourtp/60);
			} */			
			
			if(isset($discombust)){
			$sumacombus=0;
			foreach($discombust as $indicecombus => $valuecombus)
			{
				if($rowtransT['mat_trans']==$valuecombus[0]){	
					 			  
					$sumacombus+=$valuecombus[1];
					
				}
			} echo $sumacombus;
			}
			?>
                  </div></td>
                  <? //}
		  } $objPer->Liberar($rstransT);
		  ?>
                  <td><div align="center">
                      <? //calcular_horas_formato_inversa($sumaht)?>
                  </div></td>
                </tr>
              </table>
            <? }?>
          </div></td>
        </tr>
        <tr>
          <td colspan="2"><div align="center"></div></td>
        </tr>
      </table>
    </div></td>
  </tr>
  <tr class="lblCampo">
    <td colspan="2"><div align="left">
	<?
	
	//meshoy($mm);
	?>
	</div></td>
  </tr>
</table>
<map name="Map">
  <area shape="rect" coords="2,5,22,21" href="fondo.php">
</map>
</body>

</html>

