<?php
session_start();
require_once("clases/covensol_fop_c_formulacion.php");
$objfop=new covensol_fop_c_formulacion('');
$objfop->io_conexiones->decodificar_post();
$datos = $objfop->io_conexiones->asignar_post();
if(!$datos['nroh']){$resultado = $objfop->ConsultaEp1($datos);}
else{$resultado = $objfop->ConsultaEp1Fases($datos);}
?>
<link href="../shared/css/catalogos.css" rel="stylesheet" type="text/css">
<link href="../shared/css/ventanas.css" rel="stylesheet" type="text/css">
<link href="../shared/css/general.css" rel="stylesheet" type="text/css">
<link href="../shared/css/tablas.css" rel="stylesheet" type="text/css">
<?php 
$ancho[0] = 40;
$ancho[1] = 60;
$ancho[2] = 40;
$ancho[3] = 400;
$ancho[4] = 200;
$ancho[5] = 200;
$ancho[6] = 40;
$ancho_total = array_sum($ancho);
$nrofila=0;
?>

<table width="<?php echo $ancho_total; ?>" border="0" cellpadding="0" cellspacing="0"  class='fondo-tabla'>
  <tr class="titulo-celda">
     <td width="<?php echo $ancho[0]; ?>"><div align="center">AÑO</div></td>
     <td width="<?php echo $ancho[1]; ?>"><div align="center">COD</div></td>
     <td width="<?php echo $ancho[2]; ?>"><div align="center">TIPO</div></td>
     <td width="<?php echo $ancho[3]; ?>"><div align="center">DESCRIPCIÓN</div></td>
     <td width="<?php echo $ancho[4]; ?>"><div align="center">MONTO ESTIMADO</div></td> 
	 <td width="<?php echo $ancho[5]; ?>"><div align="center">MONTO CARGADO</div></td>
	 <td width="<?php echo $ancho[6]; ?>"><div align="center">FICHA</div></td> 
	   
  </tr>
  <?php foreach($resultado['rs'] as $fila) { ?>
          <?php
		  					
				$objfop->codintper = $fila['anopresup'].' - '.$fila['estcla'].' - '.$fila['codestpro1'];		
				if(!$objfop->obtSegEstructuras()){continue;}
				
				if(!$dato['abvrhist']){
					$fila['criterio'] = 'por_ultimo_mov';
					$rshist = $objfop->ConsultaFases($fila);
					if($rshist===false){return false;}
					
					$fila['abvrhist']=$rshist->fields['abvrhist'];
					$fila['denhist']=$rshist->fields['denhist'];
				}
				
				$dato = $objfop->FormatLonCodEstPro($fila);
				$aceptar="aceptar('".$fila['codestpro1']."','".$fila['estcla']."','".$fila['anopresup']."','".$fila['codplangob']."','".$nrofila."','".$dato['codestpro1']."','".$dato['nroh']."','".$dato['abvrhist']."')";			
				$imprimir="uf_mostrar_reporte('".$fila['codestpro1']."','".$fila['estcla']."','".$fila['anopresup']."','".$fila['codplangob']."','".$nrofila."','".$dato['codestpro1']."','".$dato['nroh']."','".$dato['abvrhist']."')";			
				$montotpry = number_format($dato['montotpry'],2,',','.');
				$montocargado = number_format($fila['totdtep1'],2,',','.');
				$total += $fila['totdtep1'];
				$totalest += $fila['montotpry'];
				
				
				
				
				
				//echo "ok".$dato['denhist'];
		   ?>    
                  <tr id="consulta">
                    <td width="<?php echo $ancho[0]; ?>"><div align="center"><a href="#" onClick="<?php echo $aceptar; ?>"><?php echo $dato['anopresup'];?></a></div></td>
                    <td width="<?php echo $ancho[1]; ?>"><div align="center"><a href="#" onClick="<?php echo $aceptar; ?>"><?php echo $dato['codestpro1'];?></a></div></td>
                    <td width="<?php echo $ancho[2]; ?>"><div align="center"><a href="#" onClick="<?php echo $aceptar; ?>"><?php echo $dato['estcla'];?></a></div></td>
                    <td width="<?php echo $ancho[3]; ?>"><div align="left"><a href="#" onClick="<?php echo $aceptar; ?>"><?php echo $dato['denestpro1'];?></a></div></td>
                    <td width="<?php echo $ancho[4]; ?>"><div align="right"><a href="#" onClick="<?php echo $aceptar; ?>"><?php echo $montotpry;?></a></div></td>
                    <td width="<?php echo $ancho[5]; ?>"><div align="right"><a href="#" onClick="<?php echo $aceptar; ?>"><?php echo $montocargado;?></a></div></td>
				    <td width="<?php echo $ancho[6]; ?>"><div align="right"><a href="#" onClick="<?php echo $imprimir; ?>"><img src="../shared/imagebank/tools20/imprimir.gif" alt="Imprimir" width="20" height="20" border="0" title="Imprimir"></a></div></td>
				  </tr>
                  <tr>
                    <td height="1" bgcolor="#BBBBBB" colspan="4">
					  <input name="hdenestpro1<?php echo $nrofila;?>" type="hidden" id="hdenestpro1<?php echo $nrofila;?>"  value="<?php echo $dato['denestpro1']; ?>"/>
					  <input name="hdenhist<?php echo $nrofila;?>" type="hidden" id="hdenhist<?php echo $nrofila;?>"  value="<?php echo $dato['denhist']; ?>"/>
                   	</td>
                  </tr>
          <?php 
		 		$nrofila++; 
		  ?>
  <?php }  ?>
</table>
<?php

$total = number_format($total,2,',','.');
$totalest = number_format($totalest,2,',','.');
$objfop->io_conexiones->dato_js('htotal',$total);
$objfop->io_conexiones->dato_js('htotalest',$totalest);
$objfop->io_conexiones->ejecutar_js("mostrar_total");

?>    