<?php
  include("stilos/config.inc.php");
  include("../clases/BDConexion.php");
  include("../clases/clsPer.php");
  include("funcion/funciones.php");
  include("Funciones.php");
  session_start();
  $objPer=new clsPer;
/* 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;
}
  
?>
<!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"> 
<!--
function print_1(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=no"
			var ventana = window.open(sURL,"Ver",par)
			ventana.focus();
}
//--> 
</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="891" 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="841" background="../estilo_tabla/parte_sup_cen.gif" valign="bottom">
      <div align="left" class="lblTitulo" >Distribucion de centro de costo FLUVIAL </div></td>
    <td width="25"><img src="../estilo_tabla/parte_sup_der.gif" width="25" height="25" border="0" usemap="#MapMap"></td>
  </tr>
  <tr>
    <td width="25" background="../estilo_tabla/parte_med_izq.gif">&nbsp;</td>
    <td width="841" height="86" background="../estilo_tabla/parte_med_cen.gif"><div align="center">
        <table width="835" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td height="15"><div align="center"></div></td>
          </tr>
          <tr>
            <form action="p_consolidadofluvial.php" method="post" name="form1">
              <td height="15">
                <div align="left" class="lblForm">
                  <table width="736" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                      <td width="57"><div align="right">Tipo : </div></td>
                      <td width="203"><div align="left">
                          <select name="matricula" id="select2" onkeyup=fn(this.form,this)>
                            <option value="0" <? if($mat_trans=="0"){?> selected <? }?>>Ninguno</option>
                            <? 
						echo $objPer->getCboTransCCF($matricula);
						?>
                          </select>
                      </div></td>
                      <td width="59"><div align="right">Fecha : </div></td>
                      <td width="198"><div align="left">
                          <table width="197" height="19" border="0" cellpadding="0" cellspacing="0">
                            <tr>
                              <td width="69"><div align="left">
                                <select name="days" id="days">
                                  <?=getCboDias($days);?>
                                </select>
                              </div></td>
                              <td width="72"><div align="left">
                                <select name="month" id="month">
                                  <?=getCboMeses($month);?>
                                </select>
                              </div></td>
                              <td width="56"><div align="left">
                                <select name="year" id="year" onkeyup=fn(this.form,this)>                                  
                                  <?=getCboAnnos($year);?>
                                </select>
                              </div></td>
                            </tr>
                          </table>
                      </div></td>
                      <td width="145"><input type="submit" name="Submit" value="Buscar" style="<?=$stylo['st2']?>" class="botira">
                      <input name="days1" type="hidden" id="days1" value="01"></td>
                      <td width="74">&nbsp;</td>
                    </tr>
                  </table>
              </div></td>
            </form>
          </tr>
          <tr class="lblCampo">
            <td><div align="left">
              <table width="709" 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";
				
				$mesess=$month;
				$anioss=$year;
				$diass=date(d);
				$ultimodia=date("t",mktime(0,0,0,$mesess,$diass,$anioss));
				$fecha1=$day."-".$mesess."-".$anioss;
				$fecha2=$ultimodia."-".$mesess."-".$anioss; */
				$mesess=$month;
				$anioss=$year;
				$fecha1=$days1."-".$mesess."-".$anioss;
				$fecha2=$days."-".$mesess."-".$anioss;
				extraerfechamysql($fecha1);
				$rspcp=$objPer->manpercarpesodispeso($matricula,extraerfechamysql($fecha1),extraerfechamysql($fecha2));
				$rowpcp=$objPer->NextRow($rspcp);
				
				$rstipohora=$objPer->getConsolVuelos($matricula,extraerfechamysql($fecha1),extraerfechamysql($fecha2));
				$rowtipohora=$objPer->NextRow($rstipohora);
				
				$abcde=1;
				$rst=$objPer->getTransTarifa($matricula); 
				$rowt=$objPer->NextRow($rst);
				
				$rstnv=$objPer->getTransNumViaje($matricula,extraerfechamysql($fecha1),extraerfechamysql($fecha2));
				$rowtnv=$objPer->NextRow($rstnv);				
					
				$rsthi=$objPer->getHoraIndisponible($matricula,extraerfechamysql($fecha1),extraerfechamysql($fecha2));
				$rowthi=$objPer->NextRow($rsthi);
				
				//$rowthi['horasv']."-".$rowthi['horastec'];
							
				
				?>
                  <td width="178"><div align="center">Centros de costos </div></td>
                  <? for($j=$days1;$j<=$days;$j++){?>
                  <td width="313"><div align="center">
                    <?=$j?>
                  </div></td>                  
                  <? }?>
				  <td width="46"><div align="center">Total Carga Kg x CC </div></td>
                  <td width="61"><div align="center">Costo Total </div></td>
                  <td width="35"><div align="center">%</div></td>
                  <td width="62"><div align="center">
                    <div align="center">Distribucion del Costo</div>
                  </div></td>
                </tr>
                <?
				$n=0;
				
				$rscd=$objPer->manpercardiasT($matricula,extraerfechamysql($fecha1),extraerfechamysql($fecha2));
				$totalfilas=$objPer->totalrows($rscd);
				while($rowcd=$objPer->NextRow($rscd)){
				$n++;
				$tothorascc1=0;
				$sumap=0;
				?>
                <tr class="lblCampo">
                  <td><div align="left">
                    <?=$rowcd['ccosto']?></div></td>
                  <? for($i=$days1;$i<=$days;$i++){?>
                  <td><div align="center">
                      <?
					
				  if($rowcd['ccosto']){ 
				  
				  $rspcdc=$objPer->manpercarpesodisccF($matricula,$rowcd['ccosto'],$anioss."-".$mesess."-".$i);
				  $rowpcdc=$objPer->NextRow($rspcdc);			  			  	  
				  
				  if($rowpcdc['sumap']!=''){
				  	  
				  //if($rowtipohora['tipohora']=='T'){ $tipoh=$rowhd['horastec'];$tipohora=$rowcd['horatec'];}else{$tipoh=$rowhd['horasvol']; $tipohora=$rowcd['horavol'];}
				  echo $t=$rowpcdc['sumap'];
				  $tt1=$rowpcdc['sumap'];
				  $sumap+=$rowpcdc['sumap'];
				  $tothorascc1+=$tt1;
				  
				  
				  
				  if($i==1){ $A1[]=($rowpcdc['sumap']);}
				  if($i==2){ $A2[]=$rowpcdc['sumap'];}
				  if($i==3){ $A3[]=$rowpcdc['sumap'];}
				  if($i==4){ $A4[]=$rowpcdc['sumap'];}
				  if($i==5){ $A5[]=$rowpcdc['sumap'];}
				  if($i==6){ $A6[]=$rowpcdc['sumap'];}
				  if($i==7){ $A7[]=$rowpcdc['sumap'];}
				  if($i==8){ $A8[]=$rowpcdc['sumap'];}
				  if($i==9){ $A9[]=$rowpcdc['sumap'];}
				  if($i==10){ $A10[]=$rowpcdc['sumap'];}
				  if($i==11){ $A11[]=$rowpcdc['sumap'];}
				  if($i==12){ $A12[]=$rowpcdc['sumap'];}
				  if($i==13){ $A13[]=$rowpcdc['sumap'];}
				  if($i==14){ $A14[]=$rowpcdc['sumap'];}
				  if($i==15){ $A15[]=$rowpcdc['sumap'];}
				  if($i==16){ $A16[]=$rowpcdc['sumap'];}
				  if($i==17){ $A17[]=$rowpcdc['sumap'];}
				  if($i==18){ $A18[]=$rowpcdc['sumap'];}
				  if($i==19){ $A19[]=$rowpcdc['sumap'];}
				  if($i==20){ $A20[]=$rowpcdc['sumap'];}
				  if($i==21){ $A21[]=$rowpcdc['sumap'];}
				  if($i==22){ $A22[]=$rowpcdc['sumap'];}
				  if($i==23){ $A23[]=$rowpcdc['sumap'];}
				  if($i==24){ $A24[]=$rowpcdc['sumap'];}
				  if($i==25){ $A25[]=$rowpcdc['sumap'];}
				  if($i==26){ $A26[]=$rowpcdc['sumap'];}
				  if($i==27){ $A27[]=$rowpcdc['sumap'];}
				  if($i==28){ $A28[]=$rowpcdc['sumap'];}
				  if($i==29){ $A29[]=$rowpcdc['sumap'];}
				  if($i==30){ $A30[]=$rowpcdc['sumap'];}
				  if($i==31){ $A31[]=$rowpcdc['sumap'];}
				  				
					  //$r=$rowpcdc['sumap']*$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;					  
				  	
				      
					  
					 }else{
					 echo "&nbsp;";
					 }
					 }
					 
				  ?>
                  </div></td>                  
                  <? }?>
				  <td><div align="center">
				  <?
				  echo $tothorascc1;
				  
				  $totalhoracol=$tothorascc1;
				  $totalhoracol1+=$totalhoracol;
				  ?>
				  </div></td>
                  <td><div align="center">
				  <?
				  if($matricula=='IQ-23175' || $matricula=='IQ-22431' || $matricula=='IQ-28859' || $matricula=='IQ-28678' || $matricula=='IQ-20208' || $matricula=='PA-28641'){
				  echo $tari=($rowtnv['numviaje']/2)*$rowt['tarifav'];
				  /* echo $rowtnv['numviaje']."<br>";
				  echo $rowt['tarifav']; */
				  }else{
				  echo $tari=$rowt['tarifa'];
				  }
				  ?>
				  </div></td>
                  <td><div align="center">
                    <?
					//echo $sumap."-".$rowpcp['sumdispercar'];
					echo round(($sumap/$rowpcp['dispesototal']*100),2);				  
				  $porcentaje1=round(($sumap/$rowpcp['dispesototal']),4)*100;
				  $tper+=round(($sumap/$rowpcp['dispesototal']),3)*100;
				  ?>
                  </div></td>
                  <td><div align="center">
                    <?
					
					echo $dcc=number_format((($porcentaje1/100)*$tari),2,'.','');
					//echo $porcentaje1;
					$dcct=$dcct+$dcc;
					?>
                  </div></td>
                </tr>
                <? }$objPer->Liberar($rscd);?>
                <tr class="lblCampoBlanco" bgcolor="<?=$c_fondo_tr["fondo tr"]?>">
                  <td>Carga Dairia  Totales </td>
                  <? for($z=$days1;$z<=$days;$z++){?>
                  <td><div align="center">
				  <?
				  if($z==1){if(isset($A1)){foreach($A1 as $b1){$sumab1+=$b1;}echo $sumab1;}}
				  if($z==2){if(isset($A2)){foreach($A2 as $b2){$sumab2+=$b2;}echo $sumab2;}}
				  if($z==3){if(isset($A3)){foreach($A3 as $b3){$sumab3+=$b3;}echo $sumab3;}}
				  if($z==4){if(isset($A4)){foreach($A4 as $b4){$sumab4+=$b4;}echo $sumab4;}}
				  if($z==5){if(isset($A5)){foreach($A5 as $b5){$sumab5+=$b5;}echo $sumab5;}}
				  if($z==6){if(isset($A6)){foreach($A6 as $b6){$sumab6+=$b6;}echo $sumab6;}}
				  if($z==7){if(isset($A7)){foreach($A7 as $b7){$sumab7+=$b7;}echo $sumab7;}}
				  if($z==8){if(isset($A8)){foreach($A8 as $b8){$sumab8+=$b8;}echo $sumab8;}}
				  if($z==9){if(isset($A9)){foreach($A9 as $b9){$sumab9+=$b9;}echo $sumab9;}}
				  if($z==10){if(isset($A10)){foreach($A10 as $b10){$sumab10+=$b10;}echo $sumab10;}}
				  if($z==11){if(isset($A11)){foreach($A11 as $b11){$sumab11+=$b11;}echo $sumab11;}}
				  if($z==12){if(isset($A12)){foreach($A12 as $b12){$sumab12+=$b12;}echo $sumab12;}}
				  if($z==13){if(isset($A13)){foreach($A13 as $b13){$sumab13+=$b13;}echo $sumab13;}}
				  if($z==14){if(isset($A14)){foreach($A14 as $b14){$sumab14+=$b14;}echo $sumab14;}}
				  if($z==15){if(isset($A15)){foreach($A15 as $b15){$sumab15+=$b15;}echo $sumab15;}}
				  if($z==16){if(isset($A16)){foreach($A16 as $b16){$sumab16+=$b16;}echo $sumab16;}}
				  if($z==17){if(isset($A17)){foreach($A17 as $b17){$sumab17+=$b17;}echo $sumab17;}}
				  if($z==18){if(isset($A18)){foreach($A18 as $b18){$sumab18+=$b18;}echo $sumab18;}}
				  if($z==19){if(isset($A19)){foreach($A19 as $b19){$sumab19+=$b19;}echo $sumab19;}}
				  if($z==20){if(isset($A20)){foreach($A20 as $b20){$sumab20+=$b20;}echo $sumab20;}}
				  if($z==21){if(isset($A21)){foreach($A21 as $b21){$sumab21+=$b21;}echo $sumab21;}}
				  if($z==22){if(isset($A22)){foreach($A22 as $b22){$sumab22+=$b22;}echo $sumab22;}}
				  if($z==23){if(isset($A23)){foreach($A23 as $b23){$sumab23+=$b23;}echo $sumab23;}}
				  if($z==24){if(isset($A24)){foreach($A24 as $b24){$sumab24+=$b24;}echo $sumab24;}}
				  if($z==25){if(isset($A25)){foreach($A25 as $b25){$sumab25+=$b25;}echo $sumab25;}}
				  if($z==26){if(isset($A26)){foreach($A26 as $b26){$sumab26+=$b26;}echo $sumab26;}}
				  if($z==27){if(isset($A27)){foreach($A27 as $b27){$sumab27+=$b27;}echo $sumab27;}}
				  if($z==28){if(isset($A28)){foreach($A28 as $b28){$sumab28+=$b28;}echo $sumab28;}}
				  if($z==29){if(isset($A29)){foreach($A29 as $b29){$sumab29+=$b29;}echo $sumab29;}}
				  if($z==30){if(isset($A30)){foreach($A30 as $b30){$sumab30+=$b30;}echo $sumab30;}}
				  if($z==31){if(isset($A31)){foreach($A31 as $b31){$sumab31+=$b31;}echo $sumab31;}}
				  ?>
                  </div></td>                  
                  <? }?>
				  <td><div align="center">
				  <?
				  echo $totalhoracol1;
				  ?>
				  </div></td>
                  <td><div align="center"></div></td>
                  <td><div align="center">
                    <?
					//$tper
					echo "100.00";
					?>
                  </div></td>
                  <td><div align="center"><?=$tari?></div></td>
                </tr>
                
                <tr class="lblCampoBlanco" bgcolor="<?=$c_fondo_tr["fondo tr"]?>">
                  <td><div align="left">Combustibles Iquitos </div></td>
                  <? for($y=$days1;$y<=$days;$y++){?>
                  <td><div align="center">
                      <? 
				  $rscombusi=$objPer->getConsolCombusF($matricula,$anioss."-".$mesess."-".$y,'LBC');
				  $rowcombusi=$objPer->NextRow($rscombusi);
				  echo $rowcombusi['combus'];
				  $totcombusi+=$rowcombusi['combus'];
				  ?>
                  </div></td>                  
                  <? }?>
				  <td><div align="center"><?=$totcombusi?></div></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">Combustibles LBC </div></td>
				  <? for($f=$days1;$f<=$days;$f++){?>
                  <td><div align="center">
				  <? 
				  $rscombusl=$objPer->getConsolCombusF($matricula,$anioss."-".$mesess."-".$f,'IQUITOS');
				  $rowcombusl=$objPer->NextRow($rscombusl);
				  echo $rowcombusl['combus'];
				  $totcombusl+=$rowcombusl['combus'];
				  ?>
				  </div></td>
				  <? }?>
                  <td><div align="center"><?=$totcombusl?></div></td>
                  <td><div align="center"></div></td>
                  <td><div align="center"></div></td>
                  <td><div align="center"></div></td>
                </tr>
              </table>
            </div></td>
          </tr>
		  <?
		  /* $rss=$objPer->manpercar($matricula,extraerfechamysql($fecha1),extraerfechamysql($fecha2));
		  //$aaa=$objPer->totalrows($rss);
		  while($rowss=$objPer->NextRow($rss))
          {	 */
		  	  
		  ?>
          <tr class="lblCampo">
            <td><div align="left"></div></td>
          </tr>
		  <?
		  /* }
			$objPer->Liberar($rss); */
		  ?>
          <tr>
		  <form name="form2" method="post" action="p_consolidadovuelos_print.php">
            <td><div align="center">
              
                <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_consolidadofluvial_print.php?month=<?=$month?>&year=<?=$year?>&matricula=<?=$matricula?>',800,600)">
                    </div></td>
                    <td width="93">&nbsp;                        </td>
                    <td width="104"><div align="left">
                        <input type="button" name="Submit2" value=".:    Salir    :." style="<?=$stylo['st2']?>" class="botira" onClick="volver();">
                    </div></td>
                  </tr>
                </table>
              
            </div></td>
			</form>
          </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="MapMap">
  <area shape="rect" coords="2,5,22,21" href="fondo.php">
</map>
<map name="Map">
  <area shape="rect" coords="2,5,22,21" href="fondo.php">
</map>
</body>

</html>

