<?php use_helper('UrlFunctions'); ?>
<?php use_helper('UtilFunctions'); ?>

<?php
$o_CrCreditoCronoFN = new CrCreditoCronoFN();
$o_CrCreditoCronoFN->setIdcreditocrono( $i_Id );
$o_CrCreditoCronoBN = $o_CrCreditoCronoFN->selectByPK();

$idCliente = $o_CrCreditoCronoBN->getIdcliente();

$o_TelefonoFN = new CrClienteTelefonoFN();
$o_TelefonoFN->setIdCliente($idCliente);
$o_TelefonoFN->setEliminado(-1);
$o_TelefonoFN->setPertenece('Cliente');
$a_o_Telefono_c = $o_TelefonoFN->select();


$o_TelefonoFN = new CrClienteTelefonoFN();
$o_TelefonoFN->setIdCliente($idCliente);
$o_TelefonoFN->setEliminado(-1);
$o_TelefonoFN->setPertenece('Garante');
$a_o_Telefono_g = $o_TelefonoFN->select();


$o_ClienteBean = new ClienteBean();
$o_ClienteBean->setIdCliente( $idCliente );

$o_ClienteBL = new ClienteBL();
$a_Cliente = $o_ClienteBL->busquedaCliente( $o_ClienteBean );
if( $a_Cliente )
{
    $o_ClienteBN = $a_Cliente[0];
    $s_NombreCompleto = $o_ClienteBN->getNombreCompleto();
    $s_DireccionCliente = $o_ClienteBN->getDireccion();
	$s_ReferenciaCliente = $o_ClienteBN->getReferenciaCliente();
	$s_Telefono = $o_ClienteBN->getTelefono();
	$s_Celular = $o_ClienteBN->getCelular();
	
	$s_conyuge = $o_ClienteBN->getConyuge();
	$s_direccionconyuge = $o_ClienteBN->getDireccionGarante();


    $i_IdMercado =  $o_ClienteBN->getIdMercado();
    $o_MercadoBean = new MercadoBean();
    $o_MercadoBean->setIdMercado( $i_IdMercado );
    
    $o_MercadoBL = new MercadoBL();
    $a_Mercado = $o_MercadoBL->busquedaMercado( $o_MercadoBean );
    if( $a_Mercado )
    {
        $o_MercadoBN = $a_Mercado[0];
        $s_DescripcionMercado = $o_MercadoBN->getDescripcion();
    }
}

$s_FechaOperacion = $o_CrCreditoCronoBN->getFechaTrx();
$s_Tipocredito = $o_CrCreditoCronoBN->getTipocredito();
$s_MontoCap = $o_CrCreditoCronoBN->getMontocapital();
$s_MontoInteres = $o_CrCreditoCronoBN->getMontointeres();

$s_garante = $o_CrCreditoCronoBN->getGarante();
$s_direcciongarante = $o_CrCreditoCronoBN->getDireccionGarante();



$s_telefonogarante = $o_CrCreditoCronoBN->getTelefonoGarante();

$s_Moneda = $o_CrCreditoCronoBN->getMoneda();
$cboFormaPago = $o_CrCreditoCronoBN->getPeriodopago();

$cboDuracion = $o_CrCreditoCronoBN->getDuracion();
$s_Moneda = $o_CrCreditoCronoBN->getMoneda();
$s_InteresMensual = $o_CrCreditoCronoBN->getPorcinteresmensual();
$s_NumMeses = $o_CrCreditoCronoBN->getNumeromeses();
$s_InteresMor = $o_CrCreditoCronoBN->getPorcinteresdiariomora();
$s_Observacion = $o_CrCreditoCronoBN->getObservacion();
$f_MontodescuentoC = $o_CrCreditoCronoBN->getDescuento();

$Saldocredito = $o_CrCreditoCronoBN->getSaldocredito();
?>

<table width="100%" cellspacing="0" cellpadding="0" border="0" style="margin-top: 5px; margin-bottom: 5px;padding-left: 25px; padding-right: 12px;">
    <tr>
        <td class="titleBody"><li>Pagos</li></td>
        <td align="right">
           
            <?php 
			if($s_Tipocredito == 'H'){
				$tipoCom= "HIPOTECA";
			}elseif($s_Tipocredito == 'F'){
				$tipoCom= "FINANCIERO";
			}
             $o_cr_vista_morososFN = new Cr_vista_morosos_compromisoFN();
	    	 $o_cr_vista_morososFN->setTipoprestamo($tipoCom);
	    	 $o_cr_vista_morososFN->setNumeroprestamo($i_Id);
	    	 $a_o_cr_vista_morososFN = $o_cr_vista_morososFN->select();
	    	 
	    	 if(is_array($a_o_cr_vista_morososFN)){
	            $o_Cr_compromiso_cabeceraFN = new CrCompromisoCabeceraFN();
	           
	        	
	            $o_Cr_compromiso_cabeceraFN->setTipoprestamo($tipoCom);
	        	$o_Cr_compromiso_cabeceraFN->setNumeroprestamo($i_Id);
	        	$o_Cr_compromiso_cabeceraFN->setEliminado('-1');
	        	$a_o_Cr_compromiso_cabeceraBN = $o_Cr_compromiso_cabeceraFN->select();
	        	if(is_array($a_o_Cr_compromiso_cabeceraBN)){
	        		foreach ($a_o_Cr_compromiso_cabeceraBN as $key => $o_Cr_compromiso_cabeceraBN){
	        			$i_IdT=$o_Cr_compromiso_cabeceraBN->getIdcabecera();
	        		}
	        		?>
	        	 	<input type="button" onclick="objMainTab.modalDialog('<?php echo buildUrlComplet( 'op.php/cpago/callClie', "block=003&i_Id=".$i_IdT."&p_estado_cuenta=1" ) ?>',{title:'Compromiso de Pago',width:920,height:400})"" value="Mostrar Compromiso" id="Inicia" class="button">
	            <?php }else{?>
					<input type="button" onclick="objMainTab.modalDialog('<?php echo buildUrlComplet( 'op.php/cpago/callClie', "block=003&i_IdPrestamo=".$i_IdT."&s_Tipo=".$tipoCom."&i_IdCliente=".$idCliente."&f_montoPrestado=".($s_MontoCap+$s_MontoInteres)."&p_estado_cuenta=1&f_montoSaldoPrestado=".$Saldocredito ) ?>',{title:'Compromiso de Pago',width:920,height:400})"" value="Iniciar Compromiso" id="Inciar" class="button">                       
	            <?php }
	    	 }?>
             <input type="button" class="button" value="Detalle de pagos" onclick="objMainTab.modalDialog('<?=buildUrl('hip/detallepagos/i_Id/'.$i_Id,"block=006")?>','block=001')" title="Imprimir Cliente"/>
            <input type="button" class="button" value="Detalle de pagos" onclick="objMainTab.modalDialog('<?=buildUrl('hip/detallepagos/i_Id/'.$i_Id,"block=006")?>','block=001')" title="Imprimir Cliente"/>
            <input type="button" class="button" value="Imprimir Cliente" onclick="objMainTab.modalDialog('<?=buildUrl('pgh/showPaymentsClientePdf/i_Id/'.$i_Id,"block=006")?>','block=001')" title="Imprimir Cliente"/>
            <input type="button" class="button" value="Imprimir Administracion" onclick="objMainTab.modalDialog('<?=buildUrl('pgh/showPaymentsPdf/i_Id/'.$i_Id,"block=006")?>','block=001')" title="Imprimir Administracion"/>
            <input type="button" class="button" value="Volver a listado" onclick="objMainTab.windowsCloseAll();" title="Volver a listado"/>
        </td>
    </tr>
</table>
<?php
$s_Param = 'block=006&idCliente='.$idCliente;
if( isset( $i_Id ) )
{
    $s_Param = $s_Param.'&i_Id='.$i_Id;
}
//FORMULA DEL MONTO A PAGAR CON INTERESES
$f_MontoInteres = ($s_InteresMensual/100)*$s_MontoCap*$s_NumMeses;


$f_MontoTotalPagar = $s_MontoInteres + $s_MontoCap;
$f_MontoCuotaPagar = fnroundesp( $f_MontoTotalPagar/$s_NumMeses, 2 );
?>
<style>
fieldset select{ width: 60%; }
.cabecera
{
    color: #000000;
    font-family: Verdana,Arial,Helvetica,sans-serif;
    text-align: left;
}
</style>

		<form action="<?php echo buildUrl('pgh/paymentGroup', $s_Param) ?>" method="post" name="form1" id="form1" enctype="multipart/form-data">
		    <?php if( isset( $i_Id ) && $i_Id != "" ){ ?>
		    <input type="hidden" name="i_Id" id="i_Id" value="<?php echo $i_Id ?>"/>
		    <?php } ?>
		    <!--<input type="hidden" name="b_Control" id="b_Control" value="post"/>-->
		    <table width="100%"  style="padding-left: 10px; padding-right: 10px;" class="marco">
		        <tr>
		            <td width="65%" valign="top">
		            
		                <table  cellspacing="0" cellpadding="0" border="0" class="marco" width="100%" >
		                    <tr>
		                        <td  align="center">
		                            <table width="100%" cellspacing="0" cellpadding="2" border="0" class="" >
		                                <tr>
		                                    <td nowrap="nowrap" width="15%" class="cabecera" style="boder 1px solid #c1c1c1;"><label class="label req" for="txtNotaria" >Cliente</label></td>
		                                    <td nowrap="nowrap" width="85%" align="left"><label class="label"><?php echo $s_NombreCompleto ?></label></td>
		                                </tr>
		                                <tr>
		                                    <td nowrap="nowrap" width="15%" class="cabecera"><label class="label req" for="txtNotaria" >Direcci&oacute;n Cliente</label></td>
		                                    <td  width="500px" align="left"><?php echo $s_DireccionCliente ?></td>
		                                </tr>
										<tr>
		                                    <td nowrap="nowrap" width="15%" class="cabecera"><label class="label req" for="txtNotaria" >Referencia</label></td>
		                                    <td nowrap="nowrap" width="85%" align="left"><label class="label"><?php echo $s_ReferenciaCliente ?></label></td>
		                                </tr> 	
										<tr>
		                                    <td nowrap="nowrap" width="15%" class="cabecera"><label class="label req" for="txtNotaria" >Telefono</label></td>
		                                    <td nowrap="nowrap" width="85%" align="left"><label class="label"><?php 
		                                    if(is_array($a_o_Telefono_c)){
		                                    	foreach ($a_o_Telefono_c as $key => $o_Telefono){
		                                    		echo str_replace(" ","&nbsp;",str_pad($o_Telefono->getNumero(),20," ",STR_PAD_RIGHT))." (".$o_Telefono->getNombreTipoTelefono().") - (".$o_Telefono->getNombreOperador().")<br>";
		                                    	}
		                                    }
		                                    ?></label></td>
		                                </tr>
		                                <tr>
		                                    <td nowrap="nowrap" class="cabecera"><label class="label req" for="txtNotaria" >Tipo</label></td>
		                                    <td nowrap="nowrap" align="left" ><label class="label"><?php if($s_Tipocredito == 'H') echo "Hipoteca"; elseif($s_Tipocredito == 'F') echo "Financiero";   ?></label></td>
		                                </tr>
		                                <tr>
		                                    <td nowrap="nowrap" class="cabecera"><label class="label req" for="txtNotaria" >Garante</label></td>
		                                    <td nowrap="nowrap"  align="left"><label class=""><?php echo $s_garante ?></label></td>
		                                </tr>
		                                <tr>
		                                    <td nowrap="nowrap" class="cabecera"><label class="label req" for="txtNotaria" >Direccion de Garante</label></td>
		                                    <td nowrap="nowrap"  align="left"><label class=""><?php echo $s_direcciongarante ?></label></td>
		                                </tr>
		                                <tr>
		                                    <td nowrap="nowrap" class="cabecera"><label class="label req" for="txtNotaria" >Telefono de Garante</label></td>
		                                    <td nowrap="nowrap"  align="left"><label class=""><?php 
		                                    if(is_array($a_o_Telefono_g)){
		                                    	foreach ($a_o_Telefono_g as $key => $o_Telefono){
		                                    		echo str_replace(" ","&nbsp;",str_pad($o_Telefono->getNumero(),20," ",STR_PAD_RIGHT))." (".$o_Telefono->getNombreTipoTelefono().") - (".$o_Telefono->getNombreOperador().")<br>";
		                                    	}
		                                    }
		                                     ?></label></td>
		                                </tr>
		                                <tr>
		                                    <td nowrap="nowrap" class="cabecera"><label class="label req" for="txtNotaria" >Conyuge</label></td>
		                                    <td nowrap="nowrap"  align="left"><label class=""><?php echo $s_conyuge; ?></label></td>
		                                </tr>
		                                <tr>
		                                    <td nowrap="nowrap" class="cabecera"><label class="label req" for="txtNotaria" >Direccion de Conyuge</label></td>
		                                    <td nowrap="nowrap"  align="left"><label class=""><?php echo $s_direccionconyuge?></label></td>
		                                </tr>
		                              	
		                                <tr>
		                                    <td nowrap="nowrap" class="cabecera"><label class="label req" for="txtNotaria" >Fecha Operaci&oacute;n</label></td>
		                                    <td nowrap="nowrap" align="left" ><label class="label"><?php echo str_replace('-','/',formatoFecha($s_FechaOperacion)) ?></label></td>
		                                </tr>
		                                <tr>                                
											<td nowrap="nowrap" width="15%" class="cabecera"><label class="label req" for="s_MontoCap" >Monto de Capital</label></td>
											<td nowrap="nowrap" width="85%" align="left">
												<label class="label"><?php echo $s_MontoCap ?></label>
												<input type="hidden" name="s_MontoCap" id="s_MontoCap" value="<?php echo $s_MontoCap ?>"/>
											</td>
		                                </tr>
										<tr>
										   <td nowrap="nowrap" class="cabecera" width="15%"><label class="label req" for="s_Moneda" >Moneda&nbsp;&nbsp;</label></td>
											<td nowrap="nowrap" align="left" width="85%"><label class="">
												<?php
												switch ( $s_Moneda ) 
												{
													case "S":
														?><label class="" style="font-family:Geneva, Arial, Helvetica, sans-serif;font-size: 12px;color:#ff0000">Soles</label><?php
													break;
													case "D":
														?><label class="" style="font-family:Geneva, Arial, Helvetica, sans-serif;font-size: 12px;color:#ff0000">Dolares</label><?php
													break;
												}
												?>
											</label></td>
										</tr>
		                                <tr>
		                                    <td nowrap="nowrap" class="cabecera" width="15%"><label class="label req" for="s_InteresMensual" >Monto Total a Pagar</label></td>
		                                    <td nowrap="nowrap" align="left"width="85%" >
		                                        <label class="label"><?php echo number_format( $f_MontoTotalPagar, 2 ) ?></label>
		                                    </td>
		                                </tr>
		                                 <tr>                                
											<td nowrap="nowrap" width="15%" class="cabecera"><label class="label req" for="s_MontoCap" >Monto de Descuento</label></td>
											<td nowrap="nowrap" width="85%" align="left" >
												<label class="label"  style="color:#ff0000"><?php echo number_format((float)$f_MontodescuentoC,2); ?></label>
											</td>
		                                </tr>
		                                <tr>
		                                    <td nowrap="nowrap" class="cabecera" width="15%"><label class="label req" for="s_InteresMensual" >Interes Mensual</label></td>
		                                    <td nowrap="nowrap" align="left" width="85%" >
		                                        <label class="label"><?php echo $s_InteresMensual ?>&nbsp;&nbsp;%</label>
		                                        <input type="hidden" name="$s_InteresMensual" id="$s_InteresMensual" value="<?php echo $s_InteresMensual ?>"/>
		                                    </td>
		                                </tr>
		                                 <tr>
		                                    <td nowrap="nowrap" class="cabecera" width="15%"><label class="label req" for="s_InteresMensual" >Forma de Pago</label></td>
		                                    <td nowrap="nowrap" align="left" width="85%">
										  		<label class="label"><?php 
										  		if($cboFormaPago == 'S'){
										  			echo "Semanal";
										  			$lapso = '+1 week ';
										  		}
										  		if($cboFormaPago == 'Q'){
										  			echo "Quincenal";
										  			$lapso = '+15 days ';
										  		}
										  		if($cboFormaPago == 'M'){
										  			echo "Mensual";
										  			$lapso = '+1 month';
										  		}
										  		?>
										  		</label>
		                                        <input type="hidden" name="cboFormaPago" id="cboFormaPago" value="<?php echo $cboFormaPago ?>"/>
		                                    </td>
		                                </tr> 
		                                <tr>
		                                    <td nowrap="nowrap" class="cabecera"><label class="label req" for="s_InteresMensual" >Duración</label></td>
		                                    <td nowrap="nowrap" align="left">
												<label class="label"><?php echo $cboDuracion ?> meses</label>
		                                        <input type="hidden" name="cboDuracion" id="cboDuracion" value="<?php echo $cboDuracion ?>"/>
		                                    </td>
		                                </tr> 
		                                <tr>
		                                    <td nowrap="nowrap" class="cabecera"><label class="label req" for="s_InteresMensual" ># Cuotas</label></td>
		                                    <td nowrap="nowrap" align="left">
		                                    	<label class="label"><?php echo $s_NumMeses ?></label>
		                                        <input type="hidden" name="s_NumMeses" id="s_NumMeses" value="<?php echo $s_NumMeses ?>"/>
		                                    </td>
		                                </tr>
		                                <tr>
		                                    <td nowrap="nowrap" class="cabecera"><label class="label req" for="s_InteresMor" >Interes Moratorio</label></td>
		                                    <td nowrap="nowrap" align="left" >
		                                        <label class="label"><?php echo $s_InteresMor ?>&nbsp;&nbsp;%</label>
		                                        <input type="hidden" name="s_InteresMor" id="s_InteresMor" value="<?php echo $s_InteresMor ?>"/>
		                                    </td>
		                                </tr>
		                                <tr>
		                                    <td nowrap="nowrap" class="cabecera"><label class="label req" for="s_Observacion" >Observaci&oacute;n</label></td>
		                                    <td nowrap="nowrap" align="left" >
		                                        <label class="label"><?php echo $s_Observacion ?></label>
		                                        <input type="hidden" name="s_Observacion" id="s_Observacion" value="<?php echo $s_Observacion ?>"/>
		                                    </td>
		                                </tr>
		                                <tr>
		                                    <td colspan="2">
		                                        <table class="marco" border="0" cellpadding="0" cellspacing="0" width="98%">
		                                            <tr>
		                                                <td height="17" class="pager">
		                                                    Listado de Cuotas
		                                                </td>
		                                            </tr>
		                                            <tr>
		                                                <td>
		                                                    <table class="grid1" width="100%" border="0" cellpadding="0" cellspacing="0">
		                                                        <tr height="23">
		                                                            <th width="2%" ></th>
		                                                            <th width="2%" >Nro</th>
		                                                            <th width="11%" >F.Cuota</th>
		                                                            <th width="11%" >F.Transaccion</th>
		                                                            <th width="11%" >Monto</th>
		                                                            <th width="11%" >Saldo</th>
		                                                            <th width="11%" >Estado</th>
		                                                            <th width="7%" ># Pagos</th>
		                                                            <th width="11%" ># D&iacute;as Mora</th>
		                                                            <th width="11%" >Monto Mora</th>
		                                                            <th width="15%" >Mora Pagada</th>
		                                                            <th width="11%" >Opciones</th>
		                                                        </tr>
		                                                        <?php
		                                                        $o_CrCreditoCuotaFN = new CrCreditoCuotaFN();
		                                                        $o_CrCreditoCuotaFN->setIdcreditocrono( $i_Id );
		                                                        $a_CrCreditoCuota = $o_CrCreditoCuotaFN->select();
		                                                        $f_SumaMontoTotal = 0;
		                                                        $f_SumaSaldototal = 0;
		                                                        ?>
		                                                        <?php 
		                                                        	$j=0;
		                                                        	if( $a_CrCreditoCuota ){ ?>
		                                                            <?php foreach ( $a_CrCreditoCuota as $i_Key => $o_CrCreditoCuotaBN ){ 
		                                                            	
		                                                            	$j++;
		                                                                $i_Idcuota = $o_CrCreditoCuotaBN->getIdcuota();
		                                                                
		                                                                $o_CrCreditoPagoFN = new CrCreditoPagoFN();
		                                                                $o_CrCreditoPagoFN->setIdcuota( $i_Idcuota );
		                                                                $i_NumPagos = $o_CrCreditoPagoFN->selectNumRows();
		                                                                $f_Pagostotal +=$i_NumPagos;
		                                                                
		                                                                $s_Estado = $o_CrCreditoCuotaBN->getEstado();
		                                                                $s_Moneda = $o_CrCreditoCuotaBN->getMoneda();
		                                                                switch ($s_Estado) {
		                                                                    case "P":
		                                                                        $s_EstadoDesc = "PENDIENTE";
		                                                                    break;
		                                                                    case "C":
		                                                                        $s_EstadoDesc = "CANCELADO";
		                                                                    break;
		                                                                }
		                                                                switch ( $s_Moneda ) {
		                                                                    case "S":
		                                                                        $s_MonedaDesc = "SOLES";
		                                                                    break;
		                                                                    case "D":
		                                                                        $s_MonedaDesc = "DOLARES";
		                                                                    break;
		                                                                }
		                                                                $f_SumaMontoTotal = $f_SumaMontoTotal + $o_CrCreditoCuotaBN->getMontototal();
		                                                                $f_SumaSaldototal = $f_SumaSaldototal + $o_CrCreditoCuotaBN->getSaldototal();
		                                                                
		                                                                //AHORA SE TIENE QUE IDENTIFICAR LA MORA PAGADA Y EL SALDO DE MORA
		                                                                $o_CrCreditoPagoFN = new CrCreditoPagoFN();
		                                                                $o_CrCreditoPagoFN->setIdcuota( $i_Idcuota );
		                                                                $o_CrCreditoPagoFN->setTipopago( "M" );
		                                                                $a_CrCreditoPago = $o_CrCreditoPagoFN->select();
		                                                                $f_SumaMontoMoraPago = 0;
		                                                                $s_FechaTrx = '';
		                                                                if( $a_CrCreditoPago )
		                                                                {
		                                                                    foreach ( $a_CrCreditoPago as $i_Key => $o_CrCreditoPagoBN )
		                                                                    {
		                                                                    	
		                                                                        $f_MontoMoraPago = $o_CrCreditoPagoBN->getMontopago();
		                                                                        if($o_CrCreditoPagoBN->getFechaTrx()) $s_FechaTrx = $o_CrCreditoPagoBN->getFechaTrx();
		                                                                        $f_SumaMontoMoraPago = $f_SumaMontoMoraPago + $f_MontoMoraPago;
		                                                                        
		                                                                    }
		                                                                }
		                                                                
		                                                                //AHORA SE TIENE QUE IDENTIFICAR EL PAGO por capital
		                                                                $o_CrCreditoPagoFN = new CrCreditoPagoFN();
		                                                                $o_CrCreditoPagoFN->setIdcuota( $i_Idcuota );
		                                                                $o_CrCreditoPagoFN->setTipopago( "C" );
		                                                                
																		if(!isset($sortCampos))$sortCampos= "Fechatrx";
																		if(!isset($sortType))  $sortType ="2";
																		$o_CrCreditoPagoFN->sortCampos = $sortCampos;
																		$o_CrCreditoPagoFN->sortType   = $sortType;
		                                                                
		                                                                $a_CrCreditoPago = $o_CrCreditoPagoFN->select();
		                                                                $f_SumaMontoPagado = 0;
		                                                                $s_FechaTrx = '';
		                                                                if( $a_CrCreditoPago )
		                                                                {
		                                                                    foreach ( $a_CrCreditoPago as $i_Key => $o_CrCreditoPagoBN )
		                                                                    {
		                                                                        $f_MontoPago = $o_CrCreditoPagoBN->getMontopago();
		                                                                        if($o_CrCreditoPagoBN->getFechaTrx() && $s_FechaTrx == '') $s_FechaTrx = $o_CrCreditoPagoBN->getFechaTrx();
		                                                                        $f_SumaMontoPagado = $f_SumaMontoPagado + $f_MontoPago;
		                                                                    }
		                                                                }
		                                                                
		                                                                //////////////////////////////////////////////////////////////////////
		                                                                $s_StringStyle = "";
		                                                                if( $s_Estado=="P" && $o_CrCreditoCuotaBN->getDiasmora() > 0 )
		                                                                {
		                                                                    $s_StringStyle = 'style="background-color:#fed91e"';
		                                                                }
		                                                                ?>
		                                                        <tr <?php echo $s_StringStyle ?>>
		                                                            <td align="center"><input type="checkbox" value="<?=$i_Idcuota?>" name="acuotas[]" <?if($s_Estado == "C") echo "style='backgroud:#ccc' disabled='disabled'";?> ></td>
		                                                            <td align="center"><?php echo $j; ?></td>
		                                                            <td align="center"><label class="label"><?php echo str_replace('-','/',formatoFecha($o_CrCreditoCuotaBN->getFechacuota())) ?></label></td>
		                                                            <td align="center"><label class="label"><?php echo str_replace('-','/',formatoFecha($s_FechaTrx)) ?></label></td>
		                                                            <td align="center"><label class="label"><?php echo $o_CrCreditoCuotaBN->getMontototal(); ?></label></td>
		                                                            <td align="center"><label class="label"><?php echo $o_CrCreditoCuotaBN->getSaldototal(); ?></label></td>
		                                                            <td align="center"><label class="label"><?php echo $s_EstadoDesc; ?></label></td>
		                                                            <td align="center"><label class="label"><?php echo $i_NumPagos; ?></label></td>
		                                                            <td align="center"><label class="label"><?php echo $o_CrCreditoCuotaBN->getDiasmora(); ?></label></td>
		                                                            <td align="center"><label class="label"><?php $f_Moratotal += $o_CrCreditoCuotaBN->getMontomora();echo $o_CrCreditoCuotaBN->getMontomora(); ?></label></td>
		                                                            <td align="center"><label class="label"><?php $f_MoraPagadatotal+=$f_SumaMontoMoraPago;echo number_format( $f_SumaMontoMoraPago, 2 ) ?></label></td>
		                                                            <td align="center">
		                                                                <input type="button" class="button" value="Pagar" onclick="location.href='<?php echo buildUrl( 'pgh/addeditPayments', $s_Param.'&i_Idcuota='.$i_Idcuota )?>'"/>
		                                                            </td>
		                                                        </tr>
		                                                            <?php } ?>
		                                                        <?php } ?>
		                                                        <tr>
		                                                        	<td></td>
		                                                        	<td></td>
		                                                            <td align="center" colspan="2"><label class="label req">Totales</label> </td>
		                                                            <td align="center" style="border-top: 1px solid black;"><label><?php echo number_format( $f_SumaMontoTotal, 2 ) ?></label> </td>
		                                                            <td align="center" style="border-top: 1px solid black;"><label><?php echo number_format( $f_SumaSaldototal, 2 ) ?></label> </td>
		                                                            <td>&nbsp;</td>
		                                                            <td align="center" style="border-top: 1px solid black;"><label><?php echo $f_Pagostotal ?></label> </td> 
		                                                            <td>&nbsp;</td>
		                                                            <td align="center" style="border-top: 1px solid black;"><label><?php echo number_format( $f_Moratotal,2) ?></label> </td>
		                                                            <td align="center" style="border-top: 1px solid black;"><label><?php echo number_format( $f_MoraPagadatotal,2) ?></label> </td>
		                                                        </tr>
		                                                    </table>
		                                                </td>
		                                            </tr>
		                                        </table>
		                                    </td>
		                                </tr>
		                                <tr>
		                                    <td colspan="4">
		                                        <table width="100%" cellspacing="0" cellpadding="0" border="0" style="margin-top: 10px;">
		                                            <tr>
		                                                <td align="center">
		                                                    <table width="100%" cellspacing="0" cellpadding="0" border="0"  style="padding-bottom: 5px; padding-top: 5px;">
		                                                        <tr>
		                                                            <td align="center">
		                                                                <input type="submit" value="Pagar / descuento" class="button" onclick="location.href='<?php echo buildUrl('pgh/list','block=006')?>'"/>
		                                                                <input type="button" value="Cancelar" class="button" onclick="location.href='<?php echo buildUrl('pgh/list','block=006')?>'"/>
		                                                            </td>
		                                                        </tr>
		                                                    </table>
		                                                </td>
		                                            </tr>
		                                        </table>
		                                    </td>
		                                </tr>
		                            </table>
		                            
		                            
		                        </td>
		                    </tr>
		                </table>
		                
		            </td>
					<td valign="top" class="marco" width="35%">
						<div style="min-height:300px">
						<table border="0" width="100%">
							<tr>
								<td height="17" class="pager" width="100%">
									<table width="100%">
										<td width="70%">Lista de Comentarios</td>
										<td align="right"><a href="javascript:objMainTab.modalDialog('<?=buildUrl('pgh/addCometario','&idCreditoCrono='.$i_Id);?>',{title:'Ingreso de Comentario',width:720,height:380})">Nuevo comentario</a></td>
									</table>
								</td>
							</tr>
							<tr>
								<td>
									<table width="100%">
										<tr>
											<td bgcolor="Silver">Nro</td>
											<td bgcolor="Silver">Fecha</td>
											<td bgcolor="Silver">Usuario</td>
										</tr>
										<?
										$o_PrestamoInteresComentario = new CrCreditoCronoComentarioFN();
										$o_PrestamoInteresComentario->setIdcreditocrono($i_Id);
										$a_PrestamoInteresComentario = $o_PrestamoInteresComentario->select();
										if(is_array($a_PrestamoInteresComentario)){
										$i=0;
										foreach ($a_PrestamoInteresComentario as $key => $PrestamoInteresComentario){
											$style = '';
											if($PrestamoInteresComentario->getFlagConfidencial() == '1' && (myUser::getUser()->getRoleId() == "sys.hip" || myUser::getUser()->getRoleId() == "sys.ope")){
												continue;
											}elseif($PrestamoInteresComentario->getFlagConfidencial() == '1'){
												$style = "style='color:#0000FF'";
											}
											$i++?>
										<tr <?if($i%2) echo "bgcolor='#F5F4F3'"?>>
											<td <?php echo $style;?>><?=$i;?></td>
											<td><?=$PrestamoInteresComentario->getFechaCreacion();?></td>
											<td><?=$PrestamoInteresComentario->getUsuarioCreacion();?></td>
										</tr>
										<tr>
											<td colspan="3"><b>Comentario:</b> <?=$PrestamoInteresComentario->getComentario();?>
											</td>
										</tr>
										<!--<tr>
											<td colspan="3"><b>C.Ref:</b> Rosa Meza</td>
										</tr>-->
										<?php 
										}
										}
										?>
									</table>
								
								</td>
							</tr>
						</table>
						</div>
						<table width="100%" cellpadding="0" cellspacing="0" class="marco" border="1">
							
							<tr>
								<td height="17"  class="pager" colspan="10">Lista de Pagos</td>
							</tr>
				
							<tr>
					
                                <th width="2%" >Nro</th>
                                <th width="11%" >F.cuota</th>
                                <th width="11%" >Tipo Pago</th>
                               
                                <th width="11%" >F.pago</th>
                                <th width="11%" >Monto</th>
                                <th width="11%" >Nro Recibo</th>
                                <th width="11%" >Banco</th>
                                <th width="11%" >Nro Operaci&oacute;n</th>
                                <th width="11%" >Fecha Ope</th>
                                <th width="11%" >Observaci&oacute;n</th>
                                           
                                        
							</tr>
							<?php
							$o_CrCreditoPagoFN = new CrCreditoPagoFN();
                            $o_CrCreditoPagoFN->setIdcreditocrono($i_Id );
                            $o_CrCreditoPagoFN->setEliminado('-1');
                            if(!isset($sortCampos2))$sortCampos2= "Fechacuota";
							if(!isset($sortType2))  $sortType2 ="1";
							$o_CrCreditoPagoFN->sortCampos = $sortCampos2;
							$o_CrCreditoPagoFN->sortType   = $sortType2;
                            $a_CrCreditoPago = $o_CrCreditoPagoFN->select();
                            $s_SumaMontoPagos = 0;
                            ?>
                            <?php if( is_array($a_CrCreditoPago) ){ ?>
                                <?php foreach ( $a_CrCreditoPago as $i_Key => $o_CrCreditoPagoBN ){ ?>
                                    <?php
                                    $i_Idpago = $o_CrCreditoPagoBN->getIdpago();
                                    $s_SumaMontoPagos = $s_SumaMontoPagos + $o_CrCreditoPagoBN->getMontopago();
                                    $s_Tipopago = $o_CrCreditoPagoBN->getTipopago();
                                    $s_Fechatrx = $o_CrCreditoPagoBN->getFechatrx();
                                    $b_color = '';
                                    switch ( $s_Tipopago )
                                    {
                                        case "C":
                                            $s_TipoPagoDesc = "Cuota";
                                        break;
                                        case "M":
                                            $s_TipoPagoDesc = "Mora";
                                        break;
                                        case "D":
                                            $s_TipoPagoDesc = "Descuento";
                                        	$b_color = "#0000ff";
                                        break;
                                    }
                                    ?>
                            <tr>
                                <td align="center"><?php echo $i_Key+1 ?></td>
                                <td align="center" ><label class="label"><?php echo str_replace('-','/',formatoFecha( $o_CrCreditoPagoBN->getFechaCuota()))?></label></td>
                                <td align="center"><label class="label"><?php echo $s_TipoPagoDesc ?></label></td>
                                
                                <td align="center" ><label class="label"><?php echo str_replace('-','/',formatoFecha( $o_CrCreditoPagoBN->getFechaTrx()))?></label></td>
                                
                                <td align="center"><label class="label" <? if($b_color) echo "style='color:".$b_color."'";?>><?php echo $o_CrCreditoPagoBN->getMontopago(); ?></label></td>
                                <td align="center"><label class="label"><?php echo $o_CrCreditoPagoBN->getNumerorecibo(); ?></label></td>
                                <td align="center"><label class="label"><?php echo $o_CrCreditoPagoBN->getBanco(); ?></label></td>
                                <td align="center"><label class="label"><?php echo $o_CrCreditoPagoBN->getNumerooperacion(); ?></label></td>
                                <td align="center"><label class="label"><?php echo str_replace('-','/',formatoFecha( $o_CrCreditoPagoBN->getFechaoperacion())) ?></label></td>
                                <td align="center"><label class="label"><?php echo $o_CrCreditoPagoBN->getObservacion(); ?></label></td>
                            </tr>
							 	<?php } ?>
                            <?php } ?>
                            <tr>
                                <td colspan="3" align="center"><label class="label req">Total</label></td>
                                <td align="center" style="border-top: 1px solid black;"><label class="label"><?php echo number_format( $s_SumaMontoPagos, 2 ) ?></label></td>
                                <td colspan="5">&nbsp;</td>
                            </tr>
						</table>
					</td>
		        </tr>
			</table>	
		</form>
	
	<script type="text/javascript">
	var valid = new Validation('form1', {immediate : true, useTitles : true});
	formCallback = function () 
	{
	    var result = valid.validate();
	    if(result)
	    {
	        $('form1').submit();
	    }
	}
	</script>
	<script>
	function buscarahora(){
		
		window.location.reload();
	}

</script>
