<?php
use_helper('UrlFunctions');
use_helper('UtilFunctions');
$o_ObjectBean = new PrestamoBean();

$o_ObjectBean->setIdPrestamo($id);

$o_ObjectDP = new PrestamoDP($o_ObjectBean);
$a_o_Prestamo = $o_ObjectDP->select();

$a_cuotas = $o_ObjectDP->ObtenerCronograma($id);
$a_pagos = $o_ObjectDP->ObtenerPagos($id);


  
$tamanioPag = 300;

//echo $txtFecha."-------------------";

//echo $cadena_cat;

echo "<pre>";
//print_r($a_o_CrCategoriaCoutaFN);
echo "</pre>";
function formatoFecha($fecha){
	$a_fecha = explode('-',$fecha);
	$cadena = $a_fecha[2]."/".$a_fecha[1]."/".substr($a_fecha[0],2,2);
	return $cadena;
}

?>

<img src="/images/common/spacer.gif" width="10">
 <table class="cuerpo" width="98%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td height="0">
      <table border="0" cellpadding="0" cellspacing="0" width="100%">
        <tr>
          <td class="titleBody">
            <li>Prestamo</li><span class="subtitle"><I>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:::&nbsp;Detalle x Cronograma</I></span></td>
          <td align="right" valign="baseline">&nbsp;</td>
        </tr>
      </table>
    </td>
  </tr>
  <tr>
    <td valign="top">
    		<?php
                $s_Param = '';
                if( isset( $id ) )
                {
                    $s_Param = 'id='.$id;
                }
                ?>
				<table id="tabShowScan" cellpadding="0" cellspacing="0" class="" style="margin-top: 5px;">
	                <tr>
	                  <td class="mnuInactivoIzq" type='maintTabguiaGeneral'><img src="/images/common/spacer.gif" width="7"></td>
	                  <td class="mnuInactivoTxt" type='maintTabguiaGeneral' nowrap onclick="location.href='<?php echo buildUrl('cat/estado_prestamocat', $s_Param) ?>';">Grafico del Cronograma</td>
	                  <td class="mnuInactivoDer" type='maintTabguiaGeneral'><img src="/images/common/spacer.gif" width="8"></td>
              
	                  	                  
	                  <td class="mnuActivoIzq" type='maintTabguiaGeneral'><img src="/images/common/spacer.gif" width="7"></td>
	                  <td class="mnuActivoTxt" type='maintTabguiaGeneral' nowrap onclick="location.href='<?php echo buildUrl('cat/estado_prestamocrono', $s_Param) ?>';">Detalle del Cronograma</td>
	                  <td class="mnuActivoDer" type='maintTabguiaGeneral'><img src="/images/common/spacer.gif" width="8"></td>
					  
					   	                  
	                  
	                </tr>
	           </table>
				<?php printHeaderPrestamo($a_o_Prestamo)?>
			<table width="80%" border="1" cellpadding="0" cellspacing="0">
				<tr>
					<td width="50%">Cronograma</td>
					<td width="50%">Pagos</td>
				</tr>
				<tr>
					<td style="vertical-align:top">
						<table class="grid" width="100%" style="border:1px solid #ECECEC">
							<tr>
								<th>Nro</th>
								<th>Fecha</th>
								<th>Cuota Redondeado</th>
								<th>Saldo</th>
								<th>Estado</th>
							</tr>
							<?if(is_array($a_cuotas)){
								$i=1;
								foreach ($a_cuotas as $key => $cuota){?>
								<tr style="<?if($i%2){?>background:#ECECEC<?}?>">
									<td align="center"><?=$i;?></td>
									<td align="center"><?=$cuota->fecha;?></td>
									<td align="right"><?php echo number_format($cuota->montocuota,2);$sumamontocuota += $cuota->montocuota;?></td>
									<td align="right"><?php echo $cuota->saldocuota;$sumasaldocuota += $cuota->saldocuota;?></td>
									<td align="center" <? if($cuota->estado=="C") echo "style='color:#00b050'"; if($cuota->estado=="P") echo "style='color:#0000FF'";?>><? if($cuota->estado=="C") echo "Cancelado"; if($cuota->estado=="P") echo "Pendiente";;?></td>
								</tr>
								<?php
								$i++;
								}
							}
							?>
							<tr>
								<td colspan="2" align="right"><label class="label req">Totales</label></td>
								<td align="right" class="req">S/.<?php echo number_format($sumamontocuota,2);?></td>
								<td align="right"  class="req">S/.<?php echo number_format($sumasaldocuota,2);?></td>
								<td></td>
							</tr>
						</table>
			
					</td>
					<td style="vertical-align:top">
						<table class="grid" width="100%" style="border:1px solid #ECECEC">
							<tr>
								<th>Nro</th>
								<th>Fecha</th>
								<th>Pago</th>
								<th>Usuario</th>
							</tr>
							<?if(is_array($a_pagos)){
								$i=1;
								foreach ($a_pagos as $key => $pago){?>
								<tr style="<?if($i%2){?>background:#ECECEC<?}?>">
									<td align="center"><?=$i;?></td>
									<td align="center"><?=$pago->FechaPago;?></td>
									<td align="right"><?php echo number_format($pago->MontoPago,2);$sumaMontoPago += $pago->MontoPago;?></td>
									<td align="center"><?php echo $pago->UsuarioCreacion;?></td>
								</tr>
								<?php
								$i++;
								}
							}
							?>
							<tr>
								<td colspan="2" align="right"><label class="label req">Totales</label></td>
								<td align="right"  class="req">S/.<?php echo number_format($sumaMontoPago,2);?></td>
								<td></td>
							</tr>
						</table>
					
						
					</td>
				</tr>
			
			</table>
			
			
    
    </td>
   </tr>
  </table>



