<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 class="help-block">Los campos con <span class="required">*</span> son obligatorios.</p>
    <br>

    <?php echo $form->errorSummary($model); ?>

    <?php //echo $form->textFieldRow($model,'referencia',array());?>

    <?php echo $form->textFieldRow($model, 'fecha_referencia', array('class' => 'input-xlarge', 'readOnly' => 'readOnly')); ?>

    <?php // echo $form->textFieldRow($model,'fecha_aporte',array('class'=>'span8'));?>

    <?php // echo $form->textFieldRow($model,'total_aportes',array('class'=>'span8','maxlength'=>20));?>

    <?php // echo $form->textFieldRow($model,'cant_aportantes',array('class'=>'span8'));?>

    <div class="form-actions">
            <?php echo CHtml::link('Cancelar', Yii::app()->createUrl(($model->id_tipo_carga == 1) ? '/aportes/datosTxtIntegrado/adminAE' : '/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(); ?>

<div id="barra_carga" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="Barra de progreso">
    <div class="modal-dialog modal-lg">
        <div class="modal-body">
            <div class="progress progress-striped active" style="margin-bottom: 15px;">
                <div class="bar" style="width: 100%;"></div>
            </div>
            <div style="text-align: center;font-weight: bold;">Aprobando n&oacute;mina de aportes...</div>
        </div>
    </div>
</div>

<?php Yii::app()->clientScript->registerScript('modal', '

function activar_barra()
{
    $("#barra_carga").modal(\'show\');
}


', CClientScript::POS_END); ?>

<div class="row">
    <div class="span12">
        <h3 class="text-center" style="color: #0A2A0A;">Resumen</h3>
    </div>
    <div class="span12">
        <table class="table table-bordered table-striped table-hover items table table-striped table-bordered table-condensed">
            <thead>
                    <th style="width: 25%;">Retiro aporte</th>
                    <th style="width: 25%;">Aporte capitalizado</th>
                    <th style="width: 25%;">Aporte distribuido</th>
                    <th style="width: 25%;"><?= CHtml::link('Retiros sin cuenta de banco', ['/aportes/datosTxtIntegrado/sinCuenta', 'id' => $model->id], array('class' => 'btn btn-link', 'style' => 'padding:0px;')); ?></th>
            </thead>
            <tbody>
                <tr>
                    <td style="text-align: center;"><?= AporteVoluntario::model()->count('id_txt_integrado=:id AND opcion_retiro=:retira', array('id' => $model->id, 'retira' => 2)) ?></td>
                    <td style="text-align: center;"><?= AporteVoluntario::model()->count('id_txt_integrado=:id AND opcion_retiro=:retira', array('id' => $model->id, 'retira' => 1)) ?></td>
                    <td style="text-align: center;"><?= AporteVoluntario::model()->count('id_txt_integrado=:id AND opcion_retiro=:retira', array('id' => $model->id, 'retira' => 3)) ?></td>
                    <td style="text-align: center;"><?= AporteVoluntario::model()->count('id_txt_integrado=:id AND opcion_retiro in (2,3) and cuenta_destino is null', array('id' => $model->id)) ?></td>
                </tr>
            </tbody>
        </table>
    </div>
 </div>

<div class="row">
    <div class="span12">
        <h3 class="text-center" style="color: #0A2A0A;">Aportes Cargados</h3>
    </div>
    <div class="span12">
        <?php $this->widget('bootstrap.widgets.TbGridView', array(
            'id' => 'aporte-voluntario-grid',
            'dataProvider' => $modelAportes->searchV($model->id),
            'filter' => $modelAportes,
            'columns' => array(
                array(
                    'name' => 'acedula',
                    'value' => '$data->idAsociado->cedula',
                ),
                array(
                    'name' => 'anombre',
                    'value' => '$data->idAsociado->nombre',
                ),
                array(
                    'name' => 'aapellido',
                    'value' => '$data->idAsociado->apellidos',
                ),
                array(
                    'name' => 'id_aportante',
                    'value' => '$data->idAportante->nombre',
                    'filter' => CHtml::activeDropDownList($modelAportes, 'id_aportante',
                    CHtml::listData(Aportante::model()->findAll('blnborrado=FALSE'), 'id', 'nombre'), array('prompt' => 'SELECCIONE')),
                ),
                array(
                    'name' => 'opcion_retiro',
                    'value' => '$data->opcionRetiro->nombre',
                    'filter' => CHtml::activeDropDownList(
                        $modelAportes,
                        'opcion_retiro',
                        CHtml::listData(TipoOperacion::model()->findAll(), 'id', 'nombre'),
                        array('prompt' => '--Seleccione--')
                    ),
                ),
               array(
                    'name' => 'monto_cargado',
                    'value' => '$data->monto_cargado',
                    'htmlOptions' => array('style' => 'text-align: right;'),
                    'type' => 'number',
                ),
                array(
                    'name' => 'monto_retirado',
                    'value' => '$data->monto_retirado',
                    'htmlOptions' => array('style' => 'text-align: right;'),
                    'type' => 'number',
                ),
                array(
                    'name' => 'monto_comision_retira',
                    'value' => '$data->monto_comision_retira',
                    'htmlOptions' => array('style' => 'text-align: right;'),
                    'type' => 'number',
                ),
                array(
                    'name' => 'monto_capitalizado',
                    'value' => '$data->monto_capitalizado',
                    'htmlOptions' => array('style' => 'text-align: right;'),
                    'type' => 'number',
                ),
                array(
                    'name' => 'monto_comision_capitaliza',
                    'value' => '$data->monto_comision_capitaliza',
                    'htmlOptions' => array('style' => 'text-align: right;'),
                    'type' => 'number',
                ),
                array(
                    'name' => 'fecha_pagos',
                    'value' => 'implode("-",array_reverse(explode("-",$data->fecha_pago)))',
                    'class' => 'SYDateColumn',
                ),
                array(
                    'name' => 'nombre_estatus',
                    'value' => '$data->idTxtIntegrado->getEstatus()',
                    'type' => 'raw',
                    'filter' => CHtml::activeDropDownList(new AporteVoluntario(), 'estatus',
                        CHtml::listData(EstatusTxt::model()->findAll('blnborrado=FALSE'), 'id', 'nombre_estatus'),
                        array('prompt' => 'SELECCIONE')
                    ),
                ),
                array(
                    'header' => 'Acciones',
                    'class' => 'bootstrap.widgets.TbButtonColumn',
                    'htmlOptions' => array('width' => '1%'),
                    'template' => '{update} {historial_modificaciones}',
                    'buttons' => array(
                        'update' => array(
                            'label' => 'Actualizar',
                            'url' => 'CHtml::normalizeUrl(array("AporteVoluntario/OpcionRetiro", "id" => $data->id))',
                        ),
                        'historial_modificaciones' => array(
                            'icon' => 'icon-list-alt',
                            'label' => 'Historial de modificaciones',
                            'url' => 'CHtml::normalizeUrl(array("AporteVoluntario/historialAporteEspecial", "id" => $data->id))',
                        ),
                    ),
                ),
            ),
        )); ?>
    </div>
</div>
