<?php $form=$this->beginWidget('bootstrap.widgets.TbActiveForm',array(
	
)); ?>
        <tr class="detalle_capacidad_pago">
            <td colspan="2"><b>Descripci&oacute;n</b></td>
            <td><b>Asignaci&oacute;n</b></td>
            <td><b>Deducciones</b></td>
        </tr>
    <?php  
        $sueldo= '';
        if(!$modelTipoCredito->capacidad_pago_sueldo_aporte){
            foreach ($modelCapacidadPago as $key=> $value) {
                if($value->idCapacidadPago){?>            
                <tr class="detalle_capacidad_pago">
                    <?php $value->monto=0; ?>
                    <td colspan="2"><b><?php echo $value->idCapacidadPago->nombre_concepto; ?></b></td>
                    <td><?php echo ($value->idCapacidadPago->asignacion)?' Bs.' .$form->textField($value,"[$value->id]monto",array('style'=>'text-align:right','onChange'=>'calcularCapacidadPago();' ,'class'=>'span2 campo_asignacion')):""; ?><br>
                         <?php echo ($value->idCapacidadPago->asignacion)?$form->error($value,"[$value->id]monto"):""; ?></td>
                    <td><?php echo (!$value->idCapacidadPago->asignacion)?' Bs.' .$form->textField($value,"[$value->id]monto",array('style'=>'text-align:right','onChange'=>'calcularCapacidadPago();','class'=>'span2 campo_deduccion')):""; ?><br>
                         <?php echo (!$value->idCapacidadPago->asignacion)?$form->error($value,"[$value->id]monto"):""; ?></td>

                </tr>
            <?php  }
                }?>
       <?php }
       
       else{
           $sueldo = Asociado::model()->utltimoSueldoPorcentajeAporte($idAsociado);?>
           <tr class="detalle_capacidad_pago">
               <td colspan="2">&Uacute;ltimo Sueldo</td>
                    <td>Bs. <?php echo trim(Yii::app()->numberFormatter->formatCurrency($sueldo,'')); ?></td>
                    <td></td>

                </tr>
       <?php }
        
            $prestamos = 0;
            foreach ($modelCreditos as $key => $value) {?>      
                <tr class="detalle_capacidad_pago">
                    <td colspan="2">Cuota mensual del prestamos "<b><?php echo $value->idTipoCredito->descripcion; ?></b>"</td>
                    <td></td>
                    <td style="text-align: left" class="monto_haberes_comprometido">Bs. <?php echo trim(Yii::app()->numberFormatter->formatCurrency($value->cuota_pagar,'')) ;$prestamos+=$value->cuota_pagar; ?></td>
                </tr>
        <?php } ?>
        <tr class="detalle_capacidad_pago">
            <td colspan="2"><b>Totales</b></td>
            <td style="text-align: left"><div id="total_asignacion" class="campo_asignacion"><?php echo ($modelTipoCredito->capacidad_pago_sueldo_aporte)?'Bs. '.trim(Yii::app()->numberFormatter->formatCurrency($sueldo,'')):""?></div></td>
            <td style="text-align: left"><div id="total_deducciones" class="campo_deduccion"><?php echo 'Bs. '.trim(Yii::app()->numberFormatter->formatCurrency($prestamos,''));?></div></td>
        </tr>
        
        <tr class="detalle_capacidad_pago">
            <td><b>Sueldo integral</b></td>
            <td><div id="sueldo_integral"><?php echo ($modelTipoCredito->capacidad_pago_sueldo_aporte)?'Bs. '.trim(Yii::app()->numberFormatter->formatCurrency($sueldo,'')):""?></div></td>
            <td><b><?php echo $porcentajeCapacidadPago?>% del descunto integral</b></td>
            <td><div id="porcentaje_sueldo"><?php echo ($modelTipoCredito->capacidad_pago_sueldo_aporte)?"Bs. ".trim(Yii::app()->numberFormatter->formatCurrency($sueldo*($porcentajeCapacidadPago/100),'')):""?></div></td>
        </tr>
		<tr class="detalle_capacidad_pago">
            <td><b>Monto total comprometido mensual</b></td>
            <td><div id="total_prestamos"><?php echo 'Bs. '.trim(Yii::app()->numberFormatter->formatCurrency($prestamos,''))?></div></td>
            <td><b>% en pr&eacute;stamos mensual</b></td>
            <td><div id="porcentaje_total_prestamos"><?php echo ($modelTipoCredito->capacidad_pago_sueldo_aporte)?(($prestamos>0 && $sueldo>0)?trim(Yii::app()->numberFormatter->formatCurrency(($prestamos*100)/$sueldo,'')).'%':"0%"):""?></div></td>
        </tr>
		<tr class="detalle_capacidad_pago">
            <td><b>Monto disponible para comprometer hasta el <?php echo $porcentajeCapacidadPago?>%</b></td>
            <td><div id="total_disponible"><?php echo ($modelTipoCredito->capacidad_pago_sueldo_aporte)?"Bs. ".trim(Yii::app()->numberFormatter->formatCurrency(($sueldo*($porcentajeCapacidadPago/100))-$prestamos,'')):""?></div></td>
            <td><b>% del monto disponible</b></td>
            <td><div id="porcentaje_total_disponible"><?php echo ($modelTipoCredito->capacidad_pago_sueldo_aporte && $sueldo>0)?trim(Yii::app()->numberFormatter->formatCurrency(33-(($prestamos*100)/$sueldo),''))."%":"" ?></div></td>
        </tr>
<?php $this->endWidget(); ?>
