<?php 
$this->breadcrumbs = array(
    'Datos Txt Integrados' => array('index'),
    $model->id,
);
$this->menu = array(
    array('label' => 'List DatosTxtIntegrado', 'url' => array('index')),
    array('label' => 'Create DatosTxtIntegrado', 'url' => array('create')),
    array('label' => 'Update DatosTxtIntegrado', 'url' => array('update', 'id' => $model->id)),
    array('label' => 'Delete DatosTxtIntegrado', 'url' => '#', 'linkOptions' => array('submit' => array('delete', 'id' => $model->id), 'confirm' => 'Are you sure you want to delete this item?')),
    array('label' => 'Manage DatosTxtIntegrado', 'url' => array('admin')),
);
?>
    <div class="btn-toolbar">
        <div class="btn-group">
            <?= CHtml::submitButton('Descargar detalle pdf', array(
                'class' => 'btn btn-info',
               'submit' => array('pdfAOFaltante', 'id' => $model->id)
            )) ?>
        </div>
        <div class="btn-group">
            <?= CHtml::submitButton('Descargar detalle Excel', array(
                'class' => 'btn btn-info',
                'submit' => array('xlsAOF', 'id' => $model->id)
            )) ?>
        </div>
    </div>

     <table class="table table-bordered">
        <tr>
            <td  style="text-align: center;"  colspan="4"><b>Informaci&oacute;n de carga inicial</b></td>
        </tr>
         <tr>
            <td><b><?php echo $model->getAttributeLabel('nombre_archivo')?></b></td>
            <td><?php echo $model->nombre_archivo?></td>
            <td><b><?php echo $model->getAttributeLabel('descripcion')?></b></td>
            <td><?php echo $model->descripcion?></td>
        </tr>
        <tr>
            <td><b><?php echo $model->getAttributeLabel('cant_aportantes')?></b></td>
            <td><?php echo $model->cant_aportantes?></td>
            <td><b><?php echo $model->getAttributeLabel('total_aportes')?></b></td>
            <td><?php echo number_format($model->total_aportes, 2, ',', '.')?></td>
        </tr>
        <tr>
            <td><b><?php echo $model->getAttributeLabel('fecha_aporte')?></b></td>
            <td><?php echo date('d-m-Y', strtotime($model->fecha_aporte))?></td>
            <td><b><?php echo $model->getAttributeLabel('fecha_registro')?></b></td>
            <td><?php echo date('d-m-Y', strtotime($model->fecha_registro))?></td>
        </tr>
        <tr>
            <td><b>Monto cancelado por RRHH</b></td>
            <td><?php echo number_format($aportesComprobante->monto_pagado, 2, ',', '.')?></td>
            <td><b>Monto faltante</b></td>
            <td><?php echo number_format($model->total_aportes - $aportesComprobante->monto_pagado, 2, ',', '.')?></td>
        </tr>
        <tr>
            <td><b>Aportantes con aportes del patrono en cero (0)</b></td>
            <td><?php echo $aportesCeroPatrono; ?></td>
            <td><b>Aportantes con aportes en cero (0)</b></td>
            <td><?php echo $aportesCeroSocio; ?></td>
        </tr>
        <tr>
            <td colspan="1"><b>Aportantes con aportes propios y del patrono en cero (0)</b></td>
            <td colspan="3" style="text-align: center;"><?php echo $aportesCero; ?></td>
        </tr>
        <tr>
            <td colspan="1"><b><?php echo $model->getAttributeLabel('estatus')?></b></td>
            <td colspan="3" style="text-align: center;"><?php echo $model->getEstatus(); ?></td>
        </tr>
    </table>

    <table class="table table-bordered">
        <tr>
            <td colspan="7" style="text-align: center;"><b>Resultado de la depuraci&oacute;n de carga </b></td>
        </tr>
        <tr>
            <td colspan="6" ><b>Arportes activos</b></td>
            <td style="text-align: center;"><b>Totales</b></td>
        </tr>
       
        <tr>
            <td>Cant. asociados activos</td>
            <td style="text-align: center;"><?php echo $totalAportantes?></td>
            <td>Total aporte empleado</td>
            <td style="text-align: right;"><?php  echo number_format($totalMontoAporteActivo->aporte_asociado, 2, ',', '.')?> Bs.</td>
            <td>Total aporte patronal</td>
            <td style="text-align: right;"><?php  echo number_format($totalMontoAporteActivo->aporte_patrono, 2, ',', '.')?> Bs.</td>
            <td style="text-align: right;"><b><?php  echo number_format($totalMontoAporteActivo->aporte_asociado + $totalMontoAporteActivo->aporte_patrono, 2, ',', '.')?> Bs.</b></td>
        </tr>
        <tr>
            <td colspan="7" ><b>Descuentos a ex-asociados</b></td>
        </tr> 
        <tr>
            <td>Cant. ex-asociados</td>
            <td style="text-align: center;"><?php echo $modelAportesLiquidados; ?></td>
            <td>Total empleado</td>
            <td style="text-align: right;"><?php  echo number_format($totalMontoAporteLiquidados->aporte_asociado, 2, ',', '.')?> Bs.</td>
            <td>Total patronal</td>
            <td style="text-align: right;"><?php  echo number_format($totalMontoAporteLiquidados->aporte_patrono, 2, ',', '.')?> Bs.</td>
           <td style="text-align: right;"><b><?php echo number_format($totalMontoAporteLiquidados->aporte_asociado + $totalMontoAporteLiquidados->aporte_patrono, 2, ',', '.') ?> Bs.</b></td>
        </tr>

        <tr>
            <td colspan="7" ><b>Descuentos a no asociados</b></td>
        </tr> 
        <tr>
            <td>Cant. no asociados</td>
            <td style="text-align: center;"><?php echo $modelAportesTotalDiferidos; ?></td>
            <td>Total empleado</td>
            <td style="text-align: right;"><?php  echo number_format($totalMontoAporteDiferidos->aporte_asociado, 2, ',', '.')?> Bs.</td>
            <td>Total patronal</td>
            <td style="text-align: right;"><?php  echo number_format($totalMontoAporteDiferidos->aporte_patrono, 2, ',', '.')?> Bs.</td>
        <td style="text-align: right;"><b><?php echo number_format($totalMontoAporteDiferidos->aporte_asociado + $totalMontoAporteDiferidos->aporte_patrono, 2, ',', '.')?> Bs.</td>
        </tr>
        <tr>
            <td><b>Total de trabajadores</b></td>
            <td><b><?php echo $totalAportantes + $modelAportesTotalDiferidos + $modelAportesLiquidados?></b></td>
            <td><b>Total carga por empleado</b></td>
            <td style="text-align: right;"><b><?php  echo number_format(($totalMontoAporteActivo->aporte_asociado + $totalMontoAporteLiquidados->aporte_asociado + $totalMontoAporteDiferidos->aporte_asociado), 2, ',', '.')?> Bs.</b></td>
            <td><b>Total carga por patrono</b></td>
            <td style="text-align: right;"><b><?php  echo number_format(($totalMontoAporteActivo->aporte_patrono + $totalMontoAporteLiquidados->aporte_patrono + $totalMontoAporteDiferidos->aporte_patrono), 2, ',', '.')?> Bs.</b></td>
            <td   style="text-align: right;"><b><?php  echo number_format(($totalMontoAporteActivo->aporte_asociado + $totalMontoAporteLiquidados->aporte_asociado + $totalMontoAporteDiferidos->aporte_asociado + $totalMontoAporteActivo->aporte_patrono + $totalMontoAporteLiquidados->aporte_patrono + $totalMontoAporteDiferidos->aporte_patrono), 2, ',', '.')?> Bs.</b></td>
            </tr>


    </table>
<?php /*
   Yii::import('application.modules.configuracion.models.*',true);
   Yii::import('application.modules.contable.models.*',true);
    if (ConfContable::config('CONFCONTABLE')=='SI'){

?>
<div style="text-align: center;">
    <h3>Información contable</h3>
    <table class="table table-hover">
    <tr>
        <th>Fecha</th>
        <th>N° compropante</th>
        <th>Descripcion</th>
        <th>N° referencia</th>
        <th>Estatus</th>
    </tr>
<?php

    $modeloComprobante= Comprobante::model()->findAll('nro_documento=:doc',array(':doc'=>$model->id));
//    echo "<pre>";    print_r($modeloComprobante); exit;
 foreach ($modeloComprobante as $comprobante):

     $num_comprobante= CHtml::link('<i class="icon-file"></i> '.$comprobante->num_comprobante, Yii::app()->createUrl('contable/comprobante/view&id='.$comprobante->id),array());

     $fecha=date('d-m-Y',  strtotime($comprobante->fecha_comprobante));
     if($comprobante->status==1){
       $comprobante->status='Contabilizado';
     }else{
       $comprobante->status='No Contabilizado';
     }
 echo " <tr>
        <td>$fecha</td>
        <td>$num_comprobante</td>
        <td>$comprobante->descripcion</td>
        <td>$comprobante->nro_documento</td>
        <td>$comprobante->status</td>
    </tr>";


 endforeach;

?>

</table>
</div>
<?php }*/ ?>
<div style="text-align: center;">
<?php  echo CHtml::link('Ir a bandeja de Aportes', Yii::app()->createUrl('/aportes/datosTxtIntegrado/adminAO'), array('class' => 'btn btn-inverse')); ?>
</div>
<div class="col-xs-12"><hr></div>
<h3 style="text-align: center;color: #0A2A0A;">Aportes por cobrar diferidos</h3>

<?php $this->widget('bootstrap.widgets.TbGridView', array(
    'id' => 'aporte-voluntario-grid',
    'dataProvider' => $modelAportes->searchV2($model->id),
    'filter' => $modelAportes,
    'columns' => array(
        array(
            'name' => 'cedula',
            'value' => '$data->idAsociado->cedula',
        ),
        array(
            'name' => 'nombre_completo',
            'value' => '$data->getNombreCompleto()',
            'htmlOptions' => array('style' => 'width: 16%;'),
        ),
        array(
            'name' => 'deuda_actual_patrono',
            'value' => '$data->historial->deuda_actual_patrono',
            'type' => 'number',
            'htmlOptions' => array('style' => 'text-align: right; width: 11%;'),

        ),
        array(
            'name' => 'deuda_actual_socio',
            'value' => '$data->historial->deuda_actual_socio',
            'type' => 'number',
            'htmlOptions' => array('style' => 'text-align: right; width: 12%;'),
        ),
        array(
            'name' => 'aporte_x_pagar',
            'value' => '$data->aporte_x_pagar',
            'htmlOptions' => array('style' => 'width: 12%;text-align: right'),
            'filter' => false,
        ),
        array(
            'name' => 'fecha_aporte',
            'value' => '$data->fecha_aporte',
            'type' => 'date',
            'class' => 'SYDateColumn',
            'htmlOptions' => array('style' => 'text-align: center'),
        ),
        // array(
        //     'header' => 'Acciones',
        //     'class' => 'bootstrap.widgets.TbButtonColumn',
        //     'htmlOptions' => array('width' => '80', 'style' => 'text-align: center'),
        //     'template' => '{view}',
        //     'buttons' => array(
        //         'view' => array(
        //             'label' => 'Modificar Aporte Extra',
        //             'url' => 'CHtml::normalizeUrl(array("/aportes/aporteOrdinario/view", "id" => $data->id, "cmao" => true))',
        //         ),
        //     )
        // ),
    ),
)) ?>

<?php if (!empty($detalle)) {
    ?>
  <br>  
  <h3 style="text-align: center">Detalle del pago</h3>
    <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>Fecha del pago</b></td>
            <td style="text-align: center"><b>Banco origen</b></td>
            <td style="text-align: center"><b>Cuenta origen</b></td>
            <td style="text-align: center"><b>Referencia del pago</b></td>
            <td style="text-align: center"><b>Monto pagado</b></td>
            <td style="text-align: center"><b>Observaci&oacute;n</b></td>
        </tr>
        <tr>
            <td style="text-align: center"><?php echo date('d-m-Y', strtotime($detalle->fecha_pago)); ?></td>
            <td style="text-align: center"><?php echo $detalle["banco_desc"]["banco"]; ?></td>
            <td style="text-align: center"><?php echo $detalle["banco_desc"]["num_cuenta"]; ?></td>
            <td style="text-align: center"><?php echo $detalle->referencia; ?></td>
            <td style="text-align: center"><?php echo number_format($detalle->monto_pagado, 2, ',', '.'); ?></td>
            <td style="text-align: center"><?php echo $detalle->observacion; ?></td>
        </tr>
    </table>
<?php
} ?>


<div style="text-align: center;">
<?php  echo CHtml::link('Ir a bandeja de Aportes', Yii::app()->createUrl('/aportes/datosTxtIntegrado/adminAO'), array('class' => 'btn btn-inverse')); ?>
</div>
