<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/datepicker.min.css" />
<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/datepicker3.min.css" />
<script src="<?php echo Yii::app()->request->baseUrl; ?>/js/bootstrap-datepicker.min.js"></script>
<?php
$this->breadcrumbs=array(
	'Datos Txt Integrados'=>array('index'),
	'Create',
);

$this->menu=array(
	array('label'=>'List DatosTxtIntegrado','url'=>array('index')),
	array('label'=>'Manage DatosTxtIntegrado','url'=>array('admin')),
);
?>

<h3 style="text-align: center;">Aprobaci&oacute;n de Carga Masiva</h3>
<?php
    foreach(Yii::app()->user->getFlashes() as $key => $message) {
        echo '<div class="alert alert-'. $key .'">' . $message . "</div>\n";
    }
?>
<script type="text/javascript">
// When the document is ready
$(document).ready(function () {
	$('#DatosTxtIntegrado_fecha_referencia').datepicker({
		format: "dd-mm-yyyy",
		endDate: "0d",
		todayBtn: "linked",
		// clearBtn: true,
		// multidateSeparator: " ",
		forceParse: false,
		daysOfWeekDisabled: "0,6",
		orientation: "top auto",
		todayHighlight: true,
		toggleActive: true,
		language:'es',
                autoclose: true
	});

});
</script>


<?php $form=$this->beginWidget('bootstrap.widgets.TbActiveForm',array(
	'id'=>'aprobar-txt-integrado-form',
	'enableAjaxValidation'=>false,
        'htmlOptions'=>array('onsubmit'=>'activar_barra();'),
         'type'=>'horizontal',
)); ?>

	<p style="text-align: center;" class="help-block">Los campos con <span class="required">*</span> son obligatorios.</p>
	<br>
	<?php echo $form->errorSummary($model); ?>
	<h4>Tabla de totalizados de la pren&oacute;mina</h4>
    <table class="table table-bordered table-striped table-hover items table table-striped table-bordered table-condensed" >
        <tr class="info" >
            <td style="text-align: center"><b>Categor&iacute;a del pr&eacute;stamo</b></td>
            <td style="text-align: center"><b>Plazo</b></td>
            <td style="text-align: center"><b>Cantidad de cuotas</b></td>
            <td style="text-align: center"><b>Monto capital</b></td>
            <td style="text-align: center"><b>Monto interes</b></td>
            <td style="text-align: center"><b>Monto total</b></td>
        </tr>
        <?php    $sumaCuota = $sumaMonto=$sumaCapita = $sumaInteres =  0;
        foreach ($data as $key => $value) {
        $sumaCuota+= $value['cantidad_cuota'];
        $sumaInteres+= $value['interes'];
        $sumaCapita+= $value['capital'];
        $sumaMonto+= $value['monto'];
        ?>
        <tr>
            <td><?php echo $value['nombre_titulo']?></td>
            <td><?php echo $value['descripcion']?></td>
            <td style="text-align: center"><?php echo $value['cantidad_cuota']?></td>
            <td style="text-align: right">Bs. <?php echo Yii::app()->numberFormatter->formatCurrency($value['capital'],'')?></td>
            <td style="text-align: right">Bs. <?php echo Yii::app()->numberFormatter->formatCurrency($value['interes'],'')?></td>
            <td style="text-align: right">Bs. <?php echo Yii::app()->numberFormatter->formatCurrency($value['monto'],'')?></td>
        </tr>
        <?php }?>
        <tr class="info" >
            <th></th>
            <th style="text-align: center"><b>Totales</b></th>
            <th style="text-align: center"><b><?php echo $sumaCuota?></b></th>
            <th style="text-align: right"><b>Bs. <?php echo Yii::app()->numberFormatter->formatCurrency($sumaCapita,'')?></b></th>
            <th style="text-align: right"><b>Bs. <?php echo Yii::app()->numberFormatter->formatCurrency($sumaInteres,'')?></b></th>
            <th style="text-align: right"><b>Bs. <?php echo Yii::app()->numberFormatter->formatCurrency($sumaMonto,'')?></b></th>
        </tr>
    </table>
    <h4>Totalizado de pagos conciliados</h4>
    <?= $this->renderPartial('application.modules.prestamo.views.datosPreNominaCredito._analisisCapitalRecuperado', [
        'ver' => false,
        'prenomina' => $model
    ]) ?>

    <h4>Análisis de la nómina conciliada</h4>
    <?= $this->renderPartial('application.modules.prestamo.views.datosPreNominaCredito._analisisNominaConciliada', [
        'model' => $model
    ]) ?>
	<?php echo $form->textFieldRow($model,'fecha_referencia',array('class'=>'input-xlarge','readOnly'=>'readOnly')); ?>
	<div class="form-actions">
        <?php echo CHtml::link('Cancelar', Yii::app()->createUrl(($model->id_tipo_carga==5)?'/aportes/datosTxtIntegrado/adminPrestamo':'/aportes/datosTxtIntegrado/adminAO'),array('class'=>'btn btn-danger')); ?>
		<?php $this->widget('bootstrap.widgets.TbButton', array(
			'buttonType'=>'submit',
			'type'=>'success',
			'label'=> 'Aprobar',
		)); ?>
	</div>
<?php $this->endWidget(); ?>

<?= $this->renderPartial('application.modules.aportes.views.datosTxtIntegrado.barra_carga', ['titulo' => 'Aprobando nómina de préstamos...']) ?>
