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

//COLOCAR CAMPOS DE LA CABECERA DEL LISTADO  

$o_MercadoBean = new MercadoBean();
$o_MercadoBean->setIdMercado($cboMercado);

$o_MercadoBL = new MercadoBL();
$a_o_mercado = $o_MercadoBL->busquedaMercado($o_MercadoBean);

foreach ($a_o_mercado as $key => $o_mercado){
	$Descripcion = $o_mercado->getDescripcion();
}


$o_ObjectBean->setIdCliente($idCliente); 
$o_ObjectBean->setIdColaborador(myUser::getUser()->getIdColaborador()); 
$o_ObjectBean->setIdColaboradorPrestamo(myUser::getUser()->getIdColaborador()); 
$o_ObjectBean->setEstado("P"); 
 
$o_class = new PrestamoBL();
$a_ObjectBean = $o_class->busquedaPrestamo($o_ObjectBean);

?>
<script>
	function VerificarSaldo(object,Saldo){
		
		
	}
</script>
<script type="text/javascript">
  validatePass = function(){
    valid.onSubmit = true;
  }
</script>

	<table class="marco" border="0" cellpadding="0" cellspacing="0" width="100%">
        <tr>
          <td>
            <table class="grid" width="100%" border="0" cellpadding="0" cellspacing="0">
              <tr height="23">
                <th width="4%" >No.</th>
			    <th width="20%" align="left">Cliente&nbsp;&nbsp;&nbsp;</th>
			    <th width="4%" >F.Inicio</th>
				<th width="4%" >F.Vencim.</th>
				<th width="5%" align="right">Capital</th>
                <th width="3%" align="right" >Int.(%)</th>
                <th width="6%" align="right">M. Total(S/.)</th>
                <th width="6%" align="right">Cuota(S/.)</th>
                <th width="4%" align="right">Saldo</th>
                <th width="5%" align="center">Refinanciar</th>
               </tr>
              <? if(count($a_ObjectBean)>0){ ?>
	              <? foreach ($a_ObjectBean as $iKey => $o_objBean){ ?>
	              <tr onClick="TR_click(this);">
	                <td align="center"><?=$o_objBean->getIdPrestamo()?></td>
	                <td align="left"><?=$o_objBean->getObjectCliente()->getNombreCompleto()?></td>
	                <td><?=$o_objBean->getFechaInicio()?></td>
	                <td><?=$o_objBean->getFechaVencimiento()?></td>  
					<td align="right"><?=number_format($o_objBean->getMontoPrestado(),2)?></td>
					<td align="right"><?=$o_objBean->getInteresPorcentaje()?></td>
					<td align="right"><?=number_format($o_objBean->getMontoTotal(),2);?></td>
					<td align="right"><?=number_format($o_objBean->getCuotaPago(),2);?></td>
					<td align="right"><?=number_format($o_objBean->getSaldoPrestamo(),2)?></td>
					<?//if($o_objBean->getEstado() == 'P' && $o_objBean->getFechaVencimiento() < date('Y-m-d')){?><td align="center">
					    <!--<input type="image" name="Eliminar" src="/images/common/buttons/btnAnnul.gif" title="Refinanciar" onclick="parent.objMainTab.reqBody('<?=buildUrl('ipe/ref/id/'.$o_objBean->getIdPrestamo());?>','001');">-->
					    <?php //}?>
					    <input type="image" name="Eliminar" src="/images/common/buttons/btnAnnul.gif" title="Solicitar Refinanciar" onclick="parent.objMainTab.reqBody('<?=buildUrl('ipe/refped/id/'.$o_objBean->getIdPrestamo());?>','001');">
					    </td>				
	              </tr>
	              <? } ?>
              <? }else{ ?>
              <tr>
                <td colspan="7" align="center"><b>No tiene prestamos para Refinanciar.</b></td>
              </tr>
              <? } ?>
            </table>
          </td>
        </tr>
        <tr>
          <td>Total Registros: <?=count($a_ObjectBean)?></td>
        </tr>
      </table>
      <table width="100%">
      	<tr>
      		<td align="right">
      		<input class="button" type="button" value="Cancelar" onclick="parent.objMainTab.reqBody('<?=buildUrl('ipa/list')?>','001')" />	
      		</td>
        </tr>
      </table>	
      

<script type="text/javascript">
	function formCallback(result, form) {
		window.status = "valiation callback for form '" + form.id + "': result = " + result;
	}
	var valid = new Validation('form1', {immediate : true});
</script>