<h4 class="text-center">Información de la prenómina</h4>
<br>
<table class="table table-bordered table-striped table-hover items table table-striped table-bordered table-condensed" >
    <tr>
    <td style="width: 20%;"><b><?= $model->getAttributeLabel('nombre_archivo'); ?></b></td>
    <td style=""><?= $model->nombre_archivo; ?></td>
    <td style="width: 20%;""><b><?= $model->getAttributeLabel('descripcion'); ?></b></td>
    <td style=""><?= $model->descripcion; ?></td>
    </tr>
    <tr >
    <td style="width: 20%;"><b><?= $model->getAttributeLabel('cant_aportantes'); ?></b></td>
    <td style=""><?= $model->cant_aportantes ?></td>
    <td style="width: 20%;""><b><?= $model->getAttributeLabel('total_aportes'); ?></b></td>
    <td style="">Bs. <?= Yii::app()->numberFormatter->formatCurrency($model->total_aportes,'') ?></td>
    </tr>
    <tr >
    <td style="width: 20%;"><b><?= $model->getAttributeLabel('fecha_registro'); ?></b></td>
    <td style=""><?= date('d-m-Y',strtotime($model->fecha_registro)); ?></td>
    <td style="width: 20%;""><b>Estatus</b></td>
    <td style=""><?= $model->preNominaSeguimientosActual[0]->idEstatusPreNomina->nombre_estatus; ?></td>
    </tr>
    <tr>
    <td style="width: 20%;"><b><?= $model->getAttributeLabel('id_tipo_carga'); ?></b></td>
    <td style=""><?= $model->idTipoCarga->nombre; ?></td>
    <td style=""><b>Perido de descuento</b></td>
    <td style="">Periodo: <?= (isset($model->idTipoMominaPeriodo))?$model->idTipoMominaPeriodo->numero_periodo 
                                        .' desde: '.date('d-m-Y', strtotime($model->idTipoMominaPeriodo->fecha_desde))
                                        .' hasta: '.date('d-m-Y',  strtotime($model->idTipoMominaPeriodo->fecha_hasta)):""?></td>
    </tr>
    <tr>
    <td style="width: 20%;"><b><?= $model->getAttributeLabel('id_unidad'); ?></b></td>
    <td style="text-align: justify" colspan="3"><?= ($model->idUnidad)?$model->idUnidad->descripcion:""?></td>
    </tr>
</table>
<?php $this->widget('bootstrap.widgets.TbAlert', array(
    'block' => true, // display a larger alert block?
    'fade' => true, // use transitions?
    'closeText' => '×', // close link text - if set to false, no close link is displayed
    'alerts' => array(// configurations per alert type
        'success' => array('block' => true, 'fade' => true, 'closeText' => '×'), // success, info, warning, error or danger
        'error' => array('block' => true, 'fade' => true, 'closeText' => '×'), // success, info, warning, error or danger
    ),
)); ?>

<h4 class="text-center">Resumen</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 class="text-center">Cuotas</h4>
<?php $this->widget('bootstrap.widgets.TbGridView', [
    'type' => 'bordered',
    'id' => 'PreNominaTablaAmortizacion-grid',
    'dataProvider' => $modelPrenomina->searchGetPrenomina($model->id),
    'filter' => $modelPrenomina,
    'columns' => [
        [//'header' => 'Cedula',
            'name' => 'cedula',
            'value' => '$data->idCredito->idAsociado->cedula',
            'type' => 'text',
            // 'filter' =>false
        ],

        [
            'header' => 'Nombres y apellidos',
            'name' => 'nombre',
            'value' => '$data->idCredito->idAsociado->nombre." ".$data->idCredito->idAsociado->apellidos',
            'type' => 'text',
            'filter' => false,
        ],

        [
            'name' => 'id_titulo_credito', // Nombre del dato en el modelo
            'value' => '(isset($data->idCredito->idTipoCredito->idTituloTipoCredito))?$data->idCredito->idTipoCredito->idTituloTipoCredito->nombre_titulo:""', // Valor a mostrar
            'htmlOptions' => ['style' => 'text-align: center', 'width' => '80px'], // Opciones HTML
            'filter' => CHtml::listData(TituloTipoCredito::model()->findAll(), 'id', 'nombre_titulo'), // Colocamos un combo en el filtro
        ],
        [
            'header' => 'Plazo',
            'name' => 'id_tipo_credito', // Nombre del dato en el modelo
            'value' => '(isset($data->idCredito->idTipoCredito))?$data->idCredito->idTipoCredito->descripcion:""', // Valor a mostrar
            'htmlOptions' => ['style' => 'text-align: center', 'width' => '80px'], // Opciones HTML
            'filter' => CHtml::listData(TipoCredito::model()->findAll(
                'id_titulo_tipo_credito=:id_titulo_credito AND blnborrado=false',
                [':id_titulo_credito' => (int) $modelPrenomina->id_titulo_credito]
            ), 'id', 'descripcion'), // Colocamos un combo en el filtro
        ],
        [
            'name' => 'numero_cuota',
            'value' => '$data->numero_cuota',
            'filter' => false,
        ],
        [
            'name' => 'monto_capital',
            'value' => "number_format(\$data->monto_capital, 2,',','.')",
            'filter' => false,
        ],
        [
            'name' => 'monto_interes',
            'value' => "number_format(\$data->monto_interes, 2,',','.')",
            'filter' => false,
        ],
        [
            'name' => 'monto_cuota',
            'value' => "number_format(\$data->monto_cuota, 2,',','.')",
            'filter' => false,
        ],
        [
            'name' => 'tipo_cuota',
            'value' => '($data->tipo_cuota==\'A\')?"ANUAL": $data["idCredito"]["idTipoNomina"]["nombre_nomina"]',
            'filter' => false,
        ],
    ],
]); ?>

<h4 class="text-center">Cuotas pagadas por subprocesos</h4>
<?php $this->widget('bootstrap.widgets.TbGridView', [
    'type' => 'bordered',
    'id' => 'prenomina_cuotas_subproceso-grid',
    'dataProvider' => $modelPrenominaCuotasSubproceso->search($model->id),
    'filter' => $modelPrenominaCuotasSubproceso,
    'columns' => [
        [
            'name' => 'cedula',
            'value' => '$data->cedula',
        ],
        [
            'name' => 'nombre',
            'value' => '$data->nombre',
        ],
        [
            'name' => 'id_titulo_tipo_credito',
            'value' => '$data->titulo_credito',
            'htmlOptions' => ['style' => 'text-align: left', 'width' => '120px'],
            'filter' => CHtml::listData(TituloTipoCredito::model()->findAll(), 'id', 'nombre_titulo'),
        ],
        [
            'name' => 'id_tipo_credito',
            'value' => '$data->tipo_credito',
            'htmlOptions' => ['style' => 'text-align: left', 'width' => '120px'],
            'filter' => CHtml::listData(TipoCredito::model()->findAll(
                'id_titulo_tipo_credito=:id_titulo_tipo_credito AND blnborrado=false',
                [':id_titulo_tipo_credito' => (int) $modelPrenominaCuotasSubproceso->id_titulo_tipo_credito]
            ), 'id', 'descripcion'),
        ],
        [
            'name' => 'numero_cuota',
            'value' => '$data->numero_cuota',
            'filter' => false,
        ],
        [
            'name' => 'monto_capital',
            'value' => "\$data->monto_capital",
            'type' => 'number',
            'filter' => false,
        ],
        [
            'name' => 'monto_interes',
            'value' => "\$data->monto_interes",
            'type' => 'number',
            'filter' => false,
        ],
        [
            'name' => 'monto_cuota',
            'value' => "\$data->monto_cuota",
            'type' => 'number',
            'filter' => false,
        ],
        [
            'name' => 'id_tipo_nomina',
            'value' => '$data->tipo_nomina',
            'filter' => TipoNomina::getAll(),
        ],
        [
            'name' => 'id_tipo_subproceso',
            'value' => '$data->tipo_subproceso',
            'filter' => PrenominaTipoSubproceso::getAll(),
        ],
        [
            'name' => 'fecha_registro',
            'type' => 'datetime',
            'filter' => false,
            'htmlOptions' => ['style' => 'text-align: center;', 'width' => '120px'],
        ],
    ],
]); ?>
