<?
session_start(); 
if($v==1){
include("stilos/config.inc.php");
  include("../clases/BDConexion.php");
  include("../clases/clsPer.php");
  include("funcion/funciones.php");
  include("Funciones.php");

  $objPer=new clsPer;
  function getTiempo() { 
        list($usec, $sec) = explode(" ",microtime()); 
        return ((float)$usec + (float)$sec); 
  } 
$TiempoInicial = getTiempo();  
  }

?>
<table width="834" border="0">
<?

$mesess=$month;
$anioss=$year;
$fecha1=$days1."-".$mesess."-".$anioss;
$fecha2=$days."-".$mesess."-".$anioss;
$rstrans=$objPer->TransT($matricula,$ccosto,extraerfechamysql($fecha1),extraerfechamysql($fecha2));
while ($rowtrans=$objPer->NextRow($rstrans)){
if($rowtrans['mat_trans']){$A1=array();$A2=array();$A3=array();$A4=array();$A5=array();$A6=array();$A7=array();$A8=array();$A9=array();$A10=array();$A11=array();$A12=array();$A13=array();$A14=array();$A15=array();
$A16=array();$A17=array();$A18=array();$A19=array();$A20=array();$A21=array();$A22=array();$A23=array();$A24=array();$A25=array();$A26=array();$A27=array();$A28=array();$A29=array();$A30=array();$A31=array();
}
?>
  <tr>
    <td><div align="left"><?=$rowtrans['model_trans']." / ".$rowtrans['mat_trans']?></div></td>
  </tr>
  
  <tr>
    <td><div align="left">
      <table width="810" 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="197"><div align="center">Centros de costos </div></td>
          <? for($j=$days1;$j<=$days;$j++){?>
          <td width="220"><div align="center">
            <table width="98" border="0">
              <tr>
                <td colspan="3"><div align="center">
                  <?=$j?>
                </div></td>
                </tr>
              <tr>
                <td><div align="center">H</div></td>
                <td><div align="center">P</div></td>
                <td><div align="center">C</div></td>
              </tr>
            </table>
          </div></td>
          <? }?>
          <td width="68"><div align="center">Total Horas x CC </div></td>
          <td width="51"><div align="center">Total Pax </div></td>
          <td width="58"><div align="center">Total Carga Kg </div></td>
          <td width="67"><div align="center">Costo Vuelo Total
            <? if($rowtrans['mat_trans']=='OB-317'){ echo "S/. incluye IGV";}else{ echo "USD$";}?>
          </div></td>
          <td width="38"><div align="center">%</div></td>
          <td width="93"><div align="center">
              <div align="center">Distribucion del Costo
                <? if($rowtrans['mat_trans']=='OB-317'){ echo "S/.";}else{ echo "USD$";}?>
              </div>
          </div></td>
        </tr>
        <?
				$n=0;
				$totalhoracol1=0;
				$pertotal=0;
				$cartotal=0;				
				$rscd=$objPer->manpercardiasTransCC($rowtrans['mat_trans'],$ccosto,extraerfechamysql($fecha1),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>
          <? 
		  if($rowpcp['sumdispercar']!='' || $rowpcp['sumdispercar']>0){
		  for($i=$days1;$i<=$days;$i++){
		  
		  ?>
          <td><div align="center">
            <table width="107" border="0">
              <tr>
                <td width="33"><div align="center">
                  <?
					
				  if($rowcd['ccosto']){
				  $rshd=$objPer->getHorasxDia($rowtrans['mat_trans'],$anioss."-".$mesess."-".$i);
				  $rowhd=$objPer->NextRow($rshd);
				  
				  $rspcdc=$objPer->manpercarpesodiscc($rowtrans['mat_trans'],$rowcd['ccosto'],$anioss."-".$mesess."-".$i);
				  $rowpcdc=$objPer->NextRow($rspcdc);
				  
				  $rspcdt=$objPer->manpercarpesodish($rowtrans['mat_trans'],$anioss."-".$mesess."-".$i);
				  $rowpcdt=$objPer->NextRow($rspcdt);			  		  	  
				  
				  if(($rowpcdt['dispesototal']!='') || ($rowpcdt['dispesototal']!=0) || ($rowpcdt['dispesototal']!=NULL)){
				  if($rowpcdt['dispesototal']!=0){  
				  if($rowtipohora['tipohora']=='T'){ $tipoh=$rowhd['horastec'];$tipohora=$rowcd['horatec'];}else{$tipoh=$rowhd['horasvol']; $tipohora=$rowcd['horavol'];}
				  $t=round(($rowpcdc['dispercar']/$rowpcdt['dispesototal'])*$tipoh*60,3);
				  $tt1=($rowpcdc['dispercar']/$rowpcdt['dispesototal'])*$tipoh*60;
				  $sumap+=$rowpcdc['dispercar'];
				  //$tothorascc1+=$tt1;
				  $tothorascc1+=round($t);				  
				  
				  if($rowtrans['mat_trans']){
				  if($i==1){ $A1[]=(($rowpcdc['dispercar']/$rowpcdt['dispesototal'])*$tipoh*60);}
				  if($i==2){ $A2[]=($rowpcdc['dispercar']/$rowpcdt['dispesototal'])*$tipoh*60;}
				  if($i==3){ $A3[]=($rowpcdc['dispercar']/$rowpcdt['dispesototal'])*$tipoh*60;}
				  if($i==4){ $A4[]=($rowpcdc['dispercar']/$rowpcdt['dispesototal'])*$tipoh*60;}
				  if($i==5){ $A5[]=($rowpcdc['dispercar']/$rowpcdt['dispesototal'])*$tipoh*60;}
				  if($i==6){ $A6[]=($rowpcdc['dispercar']/$rowpcdt['dispesototal'])*$tipoh*60;}
				  if($i==7){ $A7[]=($rowpcdc['dispercar']/$rowpcdt['dispesototal'])*$tipoh*60;}
				  if($i==8){ $A8[]=($rowpcdc['dispercar']/$rowpcdt['dispesototal'])*$tipoh*60;}
				  if($i==9){ $A9[]=($rowpcdc['dispercar']/$rowpcdt['dispesototal'])*$tipoh*60;}
				  if($i==10){ $A10[]=($rowpcdc['dispercar']/$rowpcdt['dispesototal'])*$tipoh*60;}
				  if($i==11){ $A11[]=($rowpcdc['dispercar']/$rowpcdt['dispesototal'])*$tipoh*60;}
				  if($i==12){ $A12[]=($rowpcdc['dispercar']/$rowpcdt['dispesototal'])*$tipoh*60;}
				  if($i==13){ $A13[]=($rowpcdc['dispercar']/$rowpcdt['dispesototal'])*$tipoh*60;}
				  if($i==14){ $A14[]=($rowpcdc['dispercar']/$rowpcdt['dispesototal'])*$tipoh*60;}
				  if($i==15){ $A15[]=($rowpcdc['dispercar']/$rowpcdt['dispesototal'])*$tipoh*60;}
				  if($i==16){ $A16[]=($rowpcdc['dispercar']/$rowpcdt['dispesototal'])*$tipoh*60;}
				  if($i==17){ $A17[]=($rowpcdc['dispercar']/$rowpcdt['dispesototal'])*$tipoh*60;}
				  if($i==18){ $A18[]=($rowpcdc['dispercar']/$rowpcdt['dispesototal'])*$tipoh*60;}
				  if($i==19){ $A19[]=($rowpcdc['dispercar']/$rowpcdt['dispesototal'])*$tipoh*60;}
				  if($i==20){ $A20[]=($rowpcdc['dispercar']/$rowpcdt['dispesototal'])*$tipoh*60;}
				  if($i==21){ $A21[]=($rowpcdc['dispercar']/$rowpcdt['dispesototal'])*$tipoh*60;}
				  if($i==22){ $A22[]=($rowpcdc['dispercar']/$rowpcdt['dispesototal'])*$tipoh*60;}
				  if($i==23){ $A23[]=($rowpcdc['dispercar']/$rowpcdt['dispesototal'])*$tipoh*60;}
				  if($i==24){ $A24[]=($rowpcdc['dispercar']/$rowpcdt['dispesototal'])*$tipoh*60;}
				  if($i==25){ $A25[]=($rowpcdc['dispercar']/$rowpcdt['dispesototal'])*$tipoh*60;}
				  if($i==26){ $A26[]=($rowpcdc['dispercar']/$rowpcdt['dispesototal'])*$tipoh*60;}
				  if($i==27){ $A27[]=($rowpcdc['dispercar']/$rowpcdt['dispesototal'])*$tipoh*60;}
				  if($i==28){ $A28[]=($rowpcdc['dispercar']/$rowpcdt['dispesototal'])*$tipoh*60;}
				  if($i==29){ $A29[]=($rowpcdc['dispercar']/$rowpcdt['dispesototal'])*$tipoh*60;}
				  if($i==30){ $A30[]=($rowpcdc['dispercar']/$rowpcdt['dispesototal'])*$tipoh*60;}
				  if($i==31){ $A31[]=($rowpcdc['dispercar']/$rowpcdt['dispesototal'])*$tipoh*60;}
				  
				  }
				  }
				  				
					  //$r=($rowpcdc['dispercar']/$rowpcdt['dispesototal'])*$rowhd['horastec']*60;
					  //$c.$i=$r;
					  //$calculo[$n++]=array($c1,$c2,$c3,$c4,$c5,$c6,$c7,$c8,$c9,$c10,$c11,$c12,$c13,$c14,$c15,$c16,$c17,$c18,$c19,$c20,$c21,$c22,$c23,$c24,$c25,$c26,$c27,$c28,$c29,$c30,$c7,$c31); 
					  //$totalhoradia=$totalhoradia+$r;					  
				  	
				      $divisora=60;
					  $minutosa=60;
					  //echo round($t);
					  round($t)/60;
					  $tminutosa=$minutosa*(round($t)/60);    
					  $cocientea=floor($tminutosa/$divisora);
					  
					  $restoa=$tminutosa%$divisora;
					  if($restoa<10){
					  	if($cocientea.":0".$restoa!='0:00'){
					  		echo $cocientea.":0".$restoa;
						}
					  }else{
					  	if($cocientea.":0".$restoa!='0:00'){
					  		echo $cocientea.":".$restoa;
						}
					  }
					  
					 }else{
					 echo "&nbsp;";
					 }
					 }
					 
				  ?>
                </div></td>
                <td width="27"><div align="center">
				<?
				if($rowcd['ccosto']){
					$rspercar=$objPer->percarcc($rowtrans['mat_trans'],$rowcd['ccosto'],$anioss."-".$mesess."-".$i);
				  	$rowpercar=$objPer->NextRow($rspercar);
					echo $per=$rowpercar['per'];
					$perpar+=$per;
					$dispaxt[]=array($rowcd['ccosto'],$i,$per);									  
				}
				?>
				</div></td>
                <td width="33"><div align="center">
				<?
				if($rowcd['ccosto']){
					echo $car=$rowpercar['peso'];
					$carpar+=$car;
					$discart[]=array($rowcd['ccosto'],$i,$car);
				}
				?>
				</div></td>
              </tr>
            </table>
          </div></td>
          <? }
		  }else{
					echo "&nbsp;";
		  }
		  ?>
          <td><div align="center">
              <?
				  if($rowcd['ccosto']){
				  $hcc=round($tothorascc1)/60;
				  //echo $tothorascc1;
				  round($tothorascc1)/60;
				  echo calcular_horas_formato_inversa(round($tothorascc1)/60);				  
				  $totalhoracol=round($tothorascc1,1);
				  $totalhoracol1+=$totalhoracol;
				  $dish[]=array($rowcd['ccosto'],$hcc);
				  }
				  ?>
          </div></td>
          <td><div align="center">
		  <?
		  if($rowtrans['mat_trans']){
		  	if($rowcd['ccosto']){
		  echo $perpar;
		  $pertotal+=$perpar;
		  $dispax[]=array($rowcd['ccosto'],$perpar);
		  }
		  }
		  ?>
		  </div></td>
          <td><div align="center">
            <?
			echo $carpar;
			$cartotal+=$carpar;
			$discar[]=array($rowcd['ccosto'],$carpar);
			?>
          </div></td>
          <td><div align="center">
              <? 					 
					if($rowt['tipohora']=='V'){
						if($rowt['horamaxtra']!=0){
							$dind=$rowthi['horasv']/$rowt['horamaxtra'];
						}
					}elseif($rowt['tipohora']=='T'){
						if($rowt['horamaxtra']!=0){
							$dind=$rowthi['horastec']/$rowt['horamaxtra'];
						}
					}
				//if($ccosto=='0'){						
					if($rowtrans['mat_trans']=='OB-317'){
					echo $ctotalcal=((round($tipohora)/3)*$rowt['tarifav']);
					}elseif($rowtrans['mat_trans']=='OB-1842 P'){
					if(($rowt['dias_indotor']-$dind)>=0){ $dindcal=0;}elseif(($rowt['dias_indotor']-$dind)<0){ $dindcal=($rowt['dias_indotor']-$dind);}
					$tipohora=round($tipohora,1);
					$cdi=$rowt['tarifa']/30;  //$cdi=costo diario de indisponibilidad
					$dic=$dindcal; //$dic=dia de indisponibilidad calculado
					//$cfm=$rowt['tarifa']+$cdi*$dic;   // $cfm=costo fijo mensional
					$cfm=$cdi*$dic;   // $cfm=costo fijo mensional
					////////////////////////////////////////////////////////////////////////////////////
					if($tipohora<=40){$ci1=40*1000;}else{$ci1=40*1000;}
					if($tipohora>40){ 
						if($tipohora<60){
						$hi=$tipohora-40;
						}else{
						$hi=20;
						}
					$ci2=$hi*2500;
					}else{$ci2=0;}
					if($tipohora>=60){
						$hi3=$tipohora-60;
						$ci3=$hi3*2400;
					}else{$ci3=0;}
					
						echo $ctotalcal=$cfm+($ci1+$ci2+$ci3);
					/***************************************************************/
					}elseif($rowtrans['mat_trans']=='C-GKHL'){
						if(($rowt['dias_indotor']-$dind)>=0){ $dindcal=0;}elseif(($rowt['dias_indotor']-$dind)<0){ $dindcal=($rowt['dias_indotor']-$dind);}
						$tipohora=$tipohora."<br>";//-0.03;
						$cdi=$rowt['tarifa']/30;  //$cdi=costo diario de indisponibilidad
						$dic=$dindcal; //$dic=dia de indisponibilidad calculado
						//$cfm=$rowt['tarifa']+$cdi*$dic;   // $cfm=costo fijo mensional
						$cfm=$cdi*$dic;   // $cfm=costo fijo mensional
						////////////////////////////////////////////////////////////////////////////////////
						if($tipohora<=120){$ci1=$tipohora*2400;}
						elseif($tipohora>120){$ci2=($tipohora-120)*2400;}
							echo $ctotalcal=($cfm+($ci1+$ci2));
					}elseif($rowtrans['mat_trans']=='CFIGR'){
						if(($rowt['dias_indotor']-$dind)>=0){ $dindcal=0;}elseif(($rowt['dias_indotor']-$dind)<0){ $dindcal=($rowt['dias_indotor']-$dind);}
						$tipohora=$tipohora;//-0.03;
						$cdi=$rowt['tarifa']/30;  //$cdi=costo diario de indisponibilidad
						$dic=$dindcal; //$dic=dia de indisponibilidad calculado
						//$cfm=$rowt['tarifa']+$cdi*$dic;   // $cfm=costo fijo mensional
						$cfm=$cdi*$dic;   // $cfm=costo fijo mensional
						////////////////////////////////////////////////////////////////////////////////////
						if($tipohora<=120){$ci1=$tipohora*2800;}
						elseif($tipohora>120){$ci2=($tipohora-120)*3190;}
							echo $ctotalcal=$cfm+($ci1+$ci2);
					}else{
					if($rowt['horamaxtra']!=''){
						
							if($dind>$rowt['dias_indotor']){
								$diaind=$dind;														
								echo $ctotalcal=round((($rowt['tarifa']*($ultimodia-$diaind)/$ultimodia)+(round($tipohora,1)*$rowt['tarifah'])),2);
							}elseif($dind<=$rowt['dias_indotor']){
								$diaind=0;								
								echo $ctotalcal=round((($rowt['tarifa']*($ultimodia-$diaind)/$ultimodia)+(round($tipohora,1)*$rowt['tarifah'])),2);
							}					
						}
					}
				/* }else{
					if($rowtrans['mat_trans']=='OB-317'){
					echo $ctotalcal=((round($tothorascc1)/3)*$rowt['tarifav']);
					}elseif($rowtrans['mat_trans']=='OB-1842 P'){
					if(($rowt['dias_indotor']-$dind)>=0){ $dindcal=0;}elseif(($rowt['dias_indotor']-$dind)<0){ $dindcal=($rowt['dias_indotor']-$dind);}
					$tothorascc1=round($tothorascc1,1);
					$cdi=$rowt['tarifa']/30;  //$cdi=costo diario de indisponibilidad
					$dic=$dindcal; //$dic=dia de indisponibilidad calculado
					$cfm=$rowt['tarifa']+$cdi*$dic;   // $cfm=costo fijo mensional
					////////////////////////////////////////////////////////////////////////////////////
					if($tothorascc1<=40){$ci1=40*1000;}else{$ci1=40*1000;}
					if($tothorascc1>40){ 
						if($tothorascc1<60){
						$hi=$tothorascc1-40;
						}else{
						$hi=20;
						}
					$ci2=$hi*2500;
					}else{$ci2=0;}
					if($tothorascc1>=60){
						$hi3=$tothorascc1-60;
						$ci3=$hi3*2400;
					}else{$ci3=0;}
					
						$ctotalcal+=$cfm+($ci1+$ci2+$ci3);
					//////////////////////////////////////////////////////////////
					}elseif($rowtrans['mat_trans']=='C-GKHL'){
						if(($rowt['dias_indotor']-$dind)>=0){ $dindcal=0;}elseif(($rowt['dias_indotor']-$dind)<0){ $dindcal=($rowt['dias_indotor']-$dind);}
						$tothorascc1=$tothorascc1;//-0.03;
						$cdi=$rowt['tarifa']/30;  //$cdi=costo diario de indisponibilidad
						$dic=$dindcal; //$dic=dia de indisponibilidad calculado
						$cfm=$rowt['tarifa']+$cdi*$dic;   // $cfm=costo fijo mensional
						////////////////////////////////////////////////////////////////////////////////////
						if($tothorascc1<=120){$ci1=$t*2400;}
						elseif($tothorascc1>120){$ci2=($t-120)*2400;}
							$ctotalcal+=$cfm+($ci1+$ci2);
					}elseif($rowtrans['mat_trans']=='CFIGR'){
						if(($rowt['dias_indotor']-$dind)>=0){ $dindcal=0;}elseif(($rowt['dias_indotor']-$dind)<0){ $dindcal=($rowt['dias_indotor']-$dind);}
						$tothorascc1=$tothorascc1;//-0.03;
						$cdi=$rowt['tarifa']/30;  //$cdi=costo diario de indisponibilidad
						$dic=$dindcal; //$dic=dia de indisponibilidad calculado
						$cfm=$rowt['tarifa']+$cdi*$dic;   // $cfm=costo fijo mensional
						////////////////////////////////////////////////////////////////////////////////////
						if($tothorascc1<=120){$ci1=120*2800;}
						elseif($tothorascc1>120){$ci2=($tothorascc1-120)*3190;}
							$ctotalcal+=$cfm+($ci1+$ci2);
					}else{
					if($rowt['horamaxtra']!=''){
						
							if($dind>$rowt['dias_indotor']){
								$diaind=$dind;														
								echo $ctotalcal=round((($rowt['tarifa']*($ultimodia-$diaind)/$ultimodia)+(round($tothorascc1,1)*$rowt['tarifah'])),2);
							}elseif($dind<=$rowt['dias_indotor']){
								$diaind=0;								
								echo $ctotalcal=round((($rowt['tarifa']*($ultimodia-$diaind)/$ultimodia)+(round($tothorascc1,1)*$rowt['tarifah'])),2);
							}					
						}
					}
				}   */							
					?>
          </div></td>
          <td><div align="center">
              <?
					if($rowpcp['sumdispercar']!='' || $rowpcp['sumdispercar']!=0){
					if($rowpcp['sumdispercar']!=0){
					//echo $sumap."-".$rowpcp['sumdispercar'];
					//echo round(($sumap/$rowpcp['sumdispercar']*100),2);
					echo round((round($sumap)/round($rowpcp['sumdispercar']))*100,1);				  
					/*echo $ss=round($sumap)."<br>";
					echo $sst=round($rowpcp['sumdispercar']);*/
				  $porcentaje1=round(($sumap/$rowpcp['sumdispercar']),4)*100;
				  $tper+=round(($sumap/$rowpcp['sumdispercar']),3)*100;
				  }
				  }else{
				  echo "0.00";
				  }
				  ?>
          </div></td>
          <td><div align="center">
              <?
					if($rowcd['ccosto']){
					echo $dcc=number_format((($porcentaje1/100)*$ctotalcal),2,'.','');
					//echo $porcentaje1;
					$dcct=$dcct+$dcc;
					$discosto[]=array($rowcd['ccosto'],$dcc);
					}
					?>
          </div></td>
        </tr>
        <? }$objPer->Liberar($rscd);?>
        <tr class="lblCampoBlanco" bgcolor="<?=$c_fondo_tr["fondo tr"]?>">
          <td>TOTALES</td>
          <? 
		  
		  for($z=$days1;$z<=$days;$z++){
		  
		  ?>
          <td><div align="center">
            <table width="107" border="0">
              <tr>
                <td width="29"><div align="center">
                  <?
				  if($rowtrans['mat_trans']){
				  if($z==1){$sumab1=0; if(isset($A1)){foreach($A1 as $b1){$sumab1+=$b1;}echo calcular_horas_formato_inversa(round($sumab1,2)/60);}}
				  if($z==2){$sumab2=0; if(isset($A2)){foreach($A2 as $b2){$sumab2+=$b2;}echo calcular_horas_formato_inversa(round($sumab2,2)/60);}}
				  if($z==3){$sumab3=0; if(isset($A3)){foreach($A3 as $b3){$sumab3+=$b3;}echo calcular_horas_formato_inversa(round($sumab3,2)/60);}}
				  if($z==4){$sumab4=0; if(isset($A4)){foreach($A4 as $b4){$sumab4+=$b4;}echo calcular_horas_formato_inversa(round($sumab4,2)/60);}}
				  if($z==5){$sumab5=0; if(isset($A5)){foreach($A5 as $b5){$sumab5+=$b5;}echo calcular_horas_formato_inversa(round($sumab5,2)/60);}}
				  if($z==6){$sumab6=0; if(isset($A6)){foreach($A6 as $b6){$sumab6+=$b6;}echo calcular_horas_formato_inversa(round($sumab6,2)/60);}}
				  if($z==7){$sumab7=0; if(isset($A7)){foreach($A7 as $b7){$sumab7+=$b7;}echo calcular_horas_formato_inversa(round($sumab7,2)/60);}}
				  if($z==8){$sumab8=0; if(isset($A8)){foreach($A8 as $b8){$sumab8+=$b8;}echo calcular_horas_formato_inversa(round($sumab8,2)/60);}}
				  if($z==9){$sumab9=0; if(isset($A9)){foreach($A9 as $b9){$sumab9+=$b9;}echo calcular_horas_formato_inversa(round($sumab9,2)/60);}}
				  if($z==10){$sumab10=0; if(isset($A10)){foreach($A10 as $b10){$sumab10+=$b10;}
				  echo calcular_horas_formato_inversa(round($sumab10,2)/60);
				  /* $diez=(round($sumab10,2)/60);
				  	  $div=60;
					  $min=60;
					   
					  $tmin=$min*$diez."<br>";    
					  $coci=floor($tmin/$div);
					  
					  $res=$tmin%60;
					  if($res<10){
					  	if($coci.":0".$res!='0:00'){
					  		echo $coci.":0".$res;
						}
					  }else{
					  	if($coci.":0".$res!='0:00'){
					  		echo $coci.":".$res;
						}
					  } */
					  }
				  }
				  if($z==11){$sumab11=0; if(isset($A11)){foreach($A11 as $b11){$sumab11+=$b11;}echo calcular_horas_formato_inversa(round($sumab11,2)/60);}}
				  if($z==12){$sumab12=0; if(isset($A12)){foreach($A12 as $b12){$sumab12+=$b12;}echo calcular_horas_formato_inversa(round($sumab12,2)/60);}}
				  if($z==13){$sumab13=0; if(isset($A13)){foreach($A13 as $b13){$sumab13+=$b13;}echo calcular_horas_formato_inversa(round($sumab13,2)/60);}}
				  if($z==14){$sumab14=0; if(isset($A14)){foreach($A14 as $b14){$sumab14+=$b14;}echo calcular_horas_formato_inversa(round($sumab14,2)/60);}}
				  if($z==15){$sumab15=0; if(isset($A15)){foreach($A15 as $b15){$sumab15+=$b15;}echo calcular_horas_formato_inversa(round($sumab15,2)/60);}}
				  if($z==16){$sumab16=0; if(isset($A16)){foreach($A16 as $b16){$sumab16+=$b16;}echo calcular_horas_formato_inversa(round($sumab16,2)/60);}}
				  if($z==17){$sumab17=0; if(isset($A17)){foreach($A17 as $b17){$sumab17+=$b17;}echo calcular_horas_formato_inversa(round($sumab17,2)/60);}}
				  if($z==18){$sumab18=0; if(isset($A18)){foreach($A18 as $b18){$sumab18+=$b18;}echo calcular_horas_formato_inversa(round($sumab18,2)/60);}}
				  if($z==19){$sumab19=0; if(isset($A19)){foreach($A19 as $b19){$sumab19+=$b19;}echo calcular_horas_formato_inversa(round($sumab19,2)/60);}}
				  if($z==20){$sumab20=0; if(isset($A20)){foreach($A20 as $b20){$sumab20+=$b20;}echo calcular_horas_formato_inversa(round($sumab20,2)/60);}}
				  if($z==21){$sumab21=0; if(isset($A21)){foreach($A21 as $b21){$sumab21+=$b21;}
				  $veinte1=(round($sumab21/60,2));
				  $div=60;
					  $min=60;					   
					  $tmin=round($min*$veinte1)."<br>";    
					  $coci=floor($tmin/$div);					  
					  $res=$tmin%60;
					  if($res<10){
					  	if($coci.":0".$res!='0:00'){
					  		echo $coci.":0".$res;
						}
					  }else{
					  	if($coci.":0".$res!='0:00'){
					  		echo $coci.":".$res;
						}
					  }
				  }}
				  if($z==22){$sumab22=0; if(isset($A22)){foreach($A22 as $b22){$sumab22+=$b22;}echo calcular_horas_formato_inversa(round($sumab22,2)/60);}}
				  if($z==23){$sumab23=0; if(isset($A23)){foreach($A23 as $b23){$sumab23+=$b23;}echo calcular_horas_formato_inversa(round($sumab23,2)/60);}}
				  if($z==24){$sumab24=0; if(isset($A24)){foreach($A24 as $b24){$sumab24+=$b24;}echo calcular_horas_formato_inversa(round($sumab24,2)/60);}}
				  if($z==25){$sumab25=0; if(isset($A25)){foreach($A25 as $b25){$sumab25+=$b25;}echo calcular_horas_formato_inversa(round($sumab25,2)/60);}}
				  if($z==26){$sumab26=0; if(isset($A26)){foreach($A26 as $b26){$sumab26+=$b26;}echo calcular_horas_formato_inversa(round($sumab26,2)/60);}}
				  if($z==27){$sumab27=0; if(isset($A27)){foreach($A27 as $b27){$sumab27+=$b27;}echo calcular_horas_formato_inversa(round($sumab27,2)/60);}}
				  if($z==28){$sumab28=0; if(isset($A28)){foreach($A28 as $b28){$sumab28+=$b28;}echo calcular_horas_formato_inversa(round($sumab28,2)/60);}}
				  if($z==29){$sumab29=0; if(isset($A29)){foreach($A29 as $b29){$sumab29+=$b29;}echo calcular_horas_formato_inversa(round($sumab29,2)/60);}}
				  if($z==30){$sumab30=0; if(isset($A30)){foreach($A30 as $b30){$sumab30+=$b30;}echo calcular_horas_formato_inversa(round($sumab30,2)/60);}}
				  if($z==31){$sumab31=0; if(isset($A31)){foreach($A31 as $b31){$sumab31+=$b31;}echo calcular_horas_formato_inversa(round($sumab31,2)/60);}}
				  }
				  ?>
                </div></td>
                <td width="33"><div align="center">
				<?
				$rspcxd=$objPer->percarxdia($rowtrans['mat_trans'],$anioss."-".$mesess."-".$z);
				$rowpcxd=$objPer->NextRow($rspcxd);
				echo $rowpcxd['per'];
				$dispaxtot[]=array($z,$rowpcxd['per']);
				?>
				</div></td>
                <td width="31"><div align="center"><? echo $rowpcxd['peso'];?></div></td>
              </tr>
            </table>
          </div></td>
          <? }?>
          <td><div align="center">
              <?
				  echo calcular_horas_formato_inversa(round($totalhoracol1)/60)."/".round(round($totalhoracol1)/60,2);
				  ?>
          </div></td>
          <td><div align="center"><?=$pertotal?></div></td>
          <td><div align="center">
            <?=$cartotal?>
          </div></td>
          <td><div align="center"></div></td>
          <td><div align="center">
              <?
					//$tper
					echo "100.00";
					?>
          </div></td>
          <td><div align="center">
              <?
				  //$dcct
				  echo $ctotalcal;
				  ?>
          </div></td>
        </tr>
        <tr class="lblCampoBlanco" bgcolor="<?=$c_fondo_tr["fondo tr"]?>">
          <td><div align="left">Horas indisponibles </div></td>
          <? for($k=$days1;$k<=$days;$k++){?>
          <td><div align="center">
              <? 
				  $rsind=$objPer->getHorasIndisponibleDia($rowtrans['mat_trans'],$anioss."-".$mesess."-".$k);
				  $rowind=$objPer->NextRow($rsind);
				  if($rowtipohora['tipohora']=='T'){ 
				  $hid=calcular_horas_formato_inversai($rowind['horastecind']);
				  if($hid!='0:00'){ echo $hid;}
				  $tothind+=$rowind['horastecind'];
				  }else{
				  $hid=calcular_horas_formato_inversai($rowind['horasvolind']);
				  if($hid!='0:00'){ echo $hid;}
				  $tothind+=$rowind['horasvolind'];
				  }				  				  
				  ?>
          </div></td>
          <? }?>
          <td><div align="center">
              <?=calcular_horas_formato_inversai($tothind)?>
          </div></td>
          <td><div align="center"></div></td>
          <td><div align="center"></div></td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
        <tr class="lblCampoBlanco" bgcolor="<?=$c_fondo_tr["fondo tr"]?>">
          <td><div align="left">JP-1 Facturable  Iquitos </div></td>
          <? for($y=$days1;$y<=$days;$y++){?>
          <td><div align="center">
              <? 
				  $rscombusi=$objPer->getConsolCombus($rowtrans['mat_trans'],$anioss."-".$mesess."-".$y,'IQUITOS');
				  $rowcombusi=$objPer->NextRow($rscombusi);
				  echo $rowcombusi['combus'];
				  $totcombusi+=$rowcombusi['combus'];
				  ?>
          </div></td>
          <? }?>
          <td><div align="center">
              <?=$totcombusi?>
          </div></td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td><div align="center"></div></td>
          <td><div align="center"></div></td>
          <td><div align="center"></div></td>
        </tr>
        <tr class="lblCampoBlanco" bgcolor="<?=$c_fondo_tr["fondo tr"]?>">
          <td><div align="left">JP-1 Facturable  LBC </div></td>
          <? for($f=$days1;$f<=$days;$f++){?>
          <td><div align="center">
              <? 
				  $rscombusl=$objPer->getConsolCombus($rowtrans['mat_trans'],$anioss."-".$mesess."-".$f,'LBC');
				  $rowcombusl=$objPer->NextRow($rscombusl);
				  echo $rowcombusl['combus'];
				  $totcombusl+=$rowcombusl['combus'];
				  ?>
          </div></td>
          <? }?>
          <td><div align="center">
              <?=$totcombusl?>
          </div></td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td><div align="center"></div></td>
          <td><div align="center"></div></td>
          <td><div align="center"></div></td>
        </tr>
        <tr class="lblCampoBlanco" bgcolor="<?=$c_fondo_tr["fondo tr"]?>">
          <td><div align="left">JP-1 Iquitos </div></td>
          <? for($m=$days1;$m<=$days;$m++){?>
          <td><div align="center">
              <? 
				  $rscombusni=$objPer->getConsolCombusNoFact($rowtrans['mat_trans'],$anioss."-".$mesess."-".$m,'IQUITOS');
				  $rowcombusni=$objPer->NextRow($rscombusni);
				  echo $rowcombusni['combus'];
				  $totcombusni+=$rowcombusni['combus'];
				  ?>
          </div></td>
          <? }?>
          <td><div align="center">
              <?=$totcombusni?>
          </div></td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td><div align="center"></div></td>
          <td><div align="center"></div></td>
          <td><div align="center"></div></td>
        </tr>
        <tr class="lblCampoBlanco" bgcolor="<?=$c_fondo_tr["fondo tr"]?>">
          <td><div align="left">JP-1 LBC </div></td>
          <? for($o=$days1;$o<=$days;$o++){?>
          <td><div align="center">
              <? 
				  $rscombusnl=$objPer->getConsolCombusNoFact($rowtrans['mat_trans'],$anioss."-".$mesess."-".$o,'LBC');
				  $rowcombusnl=$objPer->NextRow($rscombusnl);
				  echo $rowcombusnl['combus'];
				  $totcombusnl+=$rowcombusnl['combus'];
				  ?>
          </div></td>
          <? }?>
          <td><div align="center">
              <?=$totcombusnl?>
          </div></td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td><div align="center"></div></td>
          <td><div align="center"></div></td>
          <td><div align="center"></div></td>
        </tr>
      </table>
    </div></td>
  </tr>
  <? } $objPer->Liberar($rstrans);?>
  <tr class="lblCampo">
    <td><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 width="150"><div align="left">Centros de Costo </div></td>
		  <? for($kc=$days1;$kc<=$days;$kc++){?>
          <td width="75"><div align="center">
            <table width="74" border="0">
              <tr>
                <td colspan="3"><div align="center">
                  <?=$kc?>
                </div></td>
                </tr>
              <tr>
                <td width="20"><div align="center">H</div></td>
                <td width="20"><div align="center">P</div></td>
                <td width="20"><div align="center">C</div></td>
              </tr>
            </table>
          </div></td>
		  <? }?>
          <td width="46"><div align="center">Total Hora</div></td>
          <td width="58"><div align="center">Total Pax </div></td>
          <td width="64"><div align="center">Total Carga Kg </div></td>
          <td width="47"><div align="center">Costo</div></td>
        </tr>
		<?
			
		$rstccs=$objPer->TransCCSel($matricula,$ccosto,extraerfechamysql($fecha1),extraerfechamysql($fecha2));
		while($rowtccs=$objPer->NextRow($rstccs)){
		//if($rowtccs['ccosto']){ $dispax=array(); }
		?>
        <tr>
          <td><div align="left"><?=$rowtccs['ccosto']?></div></td>
		  <? for($h=$days1;$h<=$days;$h++){?>
          <td><div align="center">
            <table width="74" border="0">
              <tr>
                <td width="19">&nbsp;</td>
                <td width="23"><div align="center">
                  <?
			//if($rowtccs['ccosto']){
			$sumapaxp=0;
			foreach($dispaxt as $clavept=>$valorpt)
			{
				if($rowtccs['ccosto']==$valorpt[0] && $h==$valorpt[1]){	
					//if($h==$valorpt[1]){		  			  
					$sumapaxp=$sumapaxp+$valorpt[2];
					//}
				}
			}echo $sumapaxp;
			$sumapaxt+=sumapaxp;
			//}
			?>
                </div></td>
                <td width="18"><div align="center">
                  <?
			
			$sumacarp=0;
			foreach($discart as $clavect=>$valorct)
			{
				if($rowtccs['ccosto']==$valorct[0] && $h==$valorct[1]){	
					
					$sumacarp=$sumacarp+$valorct[2];
					
				}
			}echo $sumacarp;
			$sumacart+=sumacarp;
			//}
			?>
                </div></td>
              </tr>
            </table>
          </div></td>
		  <? }?>
          <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;
			?>
          </div></td>
          <td><div align="center">
            <?
			$sumapp=0;
			foreach($dispax as $clavep=>$valorp)
			{
				if($rowtccs['ccosto']==$valorp[0]){				  			  
				$sumapp+=$valorp[1];
				//echo $valorp[0]."-".$valorp[1]."<br>";
				}
			} echo $sumapp;
			
			$sumapt+=$sumapp;
			
			?>
          </div></td>
          <td><div align="center">
            <?
			$sumacp=0;
			foreach($discar as $clavec=>$valorc)
			{
				if($rowtccs['ccosto']==$valorc[0]){				  			  
				$sumacp+=$valorc[1];
				}
			}echo $sumacp;
			$sumact+=$sumacp;
			?>
          </div></td>
          <td><div align="right">
            <?
			$sumcosto=0;
			foreach($discosto as $clave=>$valor)
			{
				if($rowtccs['ccosto']==$valor[0]){				  			  
				$sumcosto+=$valor[1];
				}
			}echo $sumcosto;
			$sumcostot+=$sumcosto;
			?>
          </div></td>
        </tr>
		<? } $objPer->Liberar($rstccs);?>
        <tr>
          <td>&nbsp;</td>
		  <? for($mc=$days1;$mc<=$days;$mc++){?>
          <td><div align="center">
            <table width="74" border="0">
              <tr>
                <td width="21">&nbsp;</td>
                <td width="19"><div align="center">
                  <?
			if(isset($dispaxtot)){
			$sumapaxtp=0;
			foreach($dispaxtot as $indice => $value)
			{
				if($mc==$value[0]){	
						  			  
					$sumapaxtp+=$value[1];
					
				}
			}echo $sumapaxtp;
			}
			//$sumapaxtot+=$sumapaxtp;
			
			?>
                </div></td>
                <td width="20">&nbsp;</td>
              </tr>
            </table>
          </div></td>
		  <? }?>
          <td><div align="center">
            <?=calcular_horas_formato_inversa($sumaht)?>
          </div></td>
          <td><div align="center"><?=$sumapt?></div></td>
          <td><div align="center"><?=$sumact?></div></td>
          <td><div align="right"><?=$sumcostot?></div></td>
        </tr>
      </table>
	  <? }?>
    </div></td>
  </tr>
  <tr>
    <td><div align="center">
	<? if($fecha1!=''){?>
      <table width="450" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="104"><div align="right">
              <input type="button" name="Submit2" value=".:Imprimir:." style="<?=$stylo['st2']?>" class="botira" onClick="javascript:print_1('p_consol_v_g_cc_print.php?month=<?=$month?>&amp;year=<?=$year?>&days=<?=$days?>&days1=<?=$days1?>&ccosto=<?=$ccosto?>&matricula=<?=$matricula?>',800,600)" />
          </div></td>
          <td width="93">&nbsp;</td>
          <td width="104"><div align="left">
              <input type="button" name="Submit22" value=".:    Salir    :." style="<?=$stylo['st2']?>" class="botira" onClick="volver();" />
          </div></td>
        </tr>
      </table>
	  <? }?>
    </div></td>
  </tr>
</table>
<?
if($v==1){
$TiempoFinal = getTiempo(); 
$Tiempo = $TiempoFinal - $TiempoInicial; 
$Tiempo = round($Tiempo,6); 
echo "Esta pagina ha cargado en $Tiempo segundos.";  
}
//var_dump($dispax)."<br>";
//count($dispax);
?>