<h1 style="text-align: center;">Archivo de carga masiva <span style="color: #0B3B0B;"><?php echo $model->nombre_archivo; ?></span></h1>
<table class="detail-view table table-striped table-condensed">
    <tr class="odd">
        <th >Nombre del archivo</th>
        <td><?= $model->nombre_archivo?></td>
    </tr>
    <tr class="even">
        <th>Descripci&oacute;n</th>
        <td><?= $model->descripcion?></td>
    </tr>
    <tr class="odd">
        <th>Fecha de registro</th>
        <td><?= $model->fecha_registro !=''? date('d-m-Y',strtotime($model->fecha_registro)):""?></td>
    </tr>
    <tr class="even">
        <th>Monto Cancelado</th>
        <td><?= number_format($model->total_aportes,2,'.',',')?></td>
    </tr>
    <tr class="odd">
        <th>Cantidad De Cuotas</th>
       <td><?= $model->cant_aportantes?></td>
    </tr>
    <tr class="even">
        <th>Fecha del Aporte</th>
       <td><?=  $model->fecha_aporte !=''? date('d-m-Y',strtotime($model->fecha_aporte)):""?></td>
    </tr>
    <tr class="odd">
        <th>Estatus</th>
        <td><span style="color:#000000"><?= $model->getEstatus()?></span></td>
    </tr>
</table>

<br>
<hr>
<h3 style="text-align: center;color: #0A2A0A;">Informaci&oacute;n de la n&oacute;mina de pr&eacute;stamo</h3>
<hr>
<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>
<br><hr>
<h3 style="text-align: center;color: #0A2A0A;">Informaci&oacute;n de la n&oacute;mina de conciliada</h3><hr>
<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 cancelado</b></td>
        <td style="text-align: center"><b>Monto por cobro</b></td>
        <td style="text-align: center"><b>Monto por gesti&oacute;n de reembolso</b></td>
      </tr>
      <?php    $sumaCuotaN = $sumaMontoPagado=$sumaMontoCobro =$sumaReembolso =  0;
            foreach ($data2 as $key => $value) {
                    $sumaCuotaN+= $value['cantidad_cuota'];
                    $sumaMontoPagado+= $value['monto_pagado'];
                    $sumaMontoCobro+= $value['monto_cobro'];
                    $sumaReembolso+= $value['monto_remanente'];
                    ?>
            <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['monto_pagado'],'')?></td>
                <td style="text-align: right">Bs. <?php echo Yii::app()->numberFormatter->formatCurrency($value['monto_cobro'],'')?></td>
                <td style="text-align: right">Bs. <?php echo Yii::app()->numberFormatter->formatCurrency($value['monto_remanente'],'')?></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 $sumaCuotaN?></b></th>
            <th style="text-align: right"><b>Bs. <?php echo Yii::app()->numberFormatter->formatCurrency($sumaMontoPagado,'')?></b></th>
            <th style="text-align: right"><b>Bs. <?php echo Yii::app()->numberFormatter->formatCurrency($sumaMontoCobro,'')?></b></th>
            <th style="text-align: right"><b>Bs. <?php echo Yii::app()->numberFormatter->formatCurrency($sumaReembolso,'')?></b></th>
        </tr>
    </table>
<br><hr>
    <h3 style="text-align: center;color: #0A2A0A;">Relaci&oacute;n</h3><hr>
<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>Concepto</b></td>
        <td style="text-align: center"><b>Cuotas</b></td>
        <td style="text-align: center"><b>Montos</b></td>
      </tr>
      <tr>
            <td>Monto de la pren&oacute;mina</td>
            <td style="text-align: center"><?= $sumaCuota?></td>
            <td style="text-align: right">Bs. <?= Yii::app()->numberFormatter->formatCurrency($sumaMonto,'')?></td>
        </tr>
        <tr>
            <td>Montos de la n&oacute;mina declarada</td>
            <td style="text-align: center"><?= $sumaCuotaN?></td>
            <td style="text-align: right">Bs. <?= Yii::app()->numberFormatter->formatCurrency($sumaMontoPagado,'')?></td>
        </tr>
        <tr class="info" >
            <th style="text-align: center"><b>Diferencia</b></th>
            <th style="text-align: center"><b><?= $sumaCuota-$sumaCuotaN?></b></th>
            <th style="text-align: right"><b>Bs. <?= Yii::app()->numberFormatter->formatCurrency($sumaMonto -$sumaMontoPagado,'')?></b></th>
        </tr>
    </table>
<?php 
   Yii::import('application.modules.configuracion.models.*',true);
   Yii::import('application.modules.contable.models.*',true);
    if (ConfContable::config('CONFCONTABLE')=='SI'){ 

?>
<br><br>
<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 } ?>
<br><hr>
<h3 style="text-align: center;color: #0A2A0A;">Pagos cargados</h3><hr>
<table class="items table">
    <tr>
        <th>Cedula</th>
        <th>Nombres y Apellidos</th>
        <th>Unidad</th>
        <th>Tipo de pr&eacute;stamo</th>
        <th>Plazo del pr&eacute;stamo</th>
        <th>Fecha de vecimiento</th>
        <th>Número de la cuota</th>
        <th>Cuota pr&eacute;stamo</th>
        <th>Cuota cargada</th>
        <th>Monto Cobro</th>
        <th>Monto Remanente</th>
    </tr>
    <?php foreach ($model->detalleNomina() as $key => $value) {?>
       <tr class="odd">
            <td><?= $value->idTablaAmortizacion->idCredito->idAsociado->cedula?></td>
            <td><?= $value->idTablaAmortizacion->idCredito->idAsociado->nombre." ".$value->idTablaAmortizacion->idCredito->idAsociado->apellidos?></td>
            <td><?= $value->idTablaAmortizacion->idCredito->idAsociado->unidad->descripcion?></td>
            <td><?= ($value->idTablaAmortizacion->idCredito->idTipoCredito->idTituloTipoCredito)?$value->idTablaAmortizacion->idCredito->idTipoCredito->idTituloTipoCredito->nombre_titulo:""?></td>
            <td><?= $value->idTablaAmortizacion->idCredito->idTipoCredito->descripcion?></td>
            <td><?= implode("-",array_reverse(explode("-", $value->idTablaAmortizacion->fecha_vencimiento)))?></td>
            <td><?= $value->idTablaAmortizacion->numero_cuota?></td>
            <td><?= number_format($value->idTablaAmortizacion->monto_cuota,2,",",".")?></td>
            <td><?= number_format($value->monto_cuota_pagado,2,",",".")?></td>
            <td><?= number_format($value->monto_cobro,2,",",".")?></td>
            <td><?= number_format($value->monto_remanente,2,",",".")?></td>
        </tr>
    
    <?php }?>
</table>

<hr>
<h3 style="text-align: center;color: #610B0B;">Retenciones de pr&eacute;stamos sin definir</h3>
<hr>

<table class="items table">
    <tr>
        <th>Cedula</th>
        <th>Monto Cuota</th>
        <th>Tipo Cuota</th>
        <th>Estatus</th>
        <th>Observaciones</th>
    </tr>
    <?php foreach ($model->detalleNominaDiferido() as $key => $value) {?>
       <tr class="odd">
            <td><?= $value->cedula?></td>
            <td><?= number_format($value->monto_cuota,2,",",".")?></td>
            <td><?= $value->tipo_cuota?></td>
            <td><?= (isset($value->idEstatusAmoritzacionDiferida))?$value->idEstatusAmoritzacionDiferida->nombre_estatus:""?></td>
            <td><?= $value->observaciones?></td>
        </tr>
    <?php }?>
</table><br>
<hr>
<h3 style="text-align: center;color: #0A2A0A;">Cuotas excluidas</h3><hr>
<table class="items table">
    <tr>
        <th>Cédula</th>
        <th>Unidad</th>
        <th>Tipo de préstamo</th>
        <th>Plazo del préstamo</th>
        <th>Monto de la cuota</th>
        <th>Estatus</th>
    </tr>
    <?php foreach (PreNominaTablaAmortizacion::model()->searchCuitaExcluidaView($model->id_prenomina_credito) as $key => $value) {?>
       <tr class="odd">
            <td><?= $value->idTablaAmortizacion->idCredito->idAsociado->cedula?></td>
            <td><?= $value->idTablaAmortizacion->idCredito->idAsociado->unidad->descripcion?></td>
            <td><?= (isset($value->idTablaAmortizacion->idCredito->idTipoCredito->idTituloTipoCredito))?$value->idTablaAmortizacion->idCredito->idTipoCredito->idTituloTipoCredito->nombre_titulo:""?></td>
            <td><?= (isset($value->idTablaAmortizacion->idCredito->idTipoCredito))?$value->idTablaAmortizacion->idCredito->idTipoCredito->descripcion:""?></td>
            <td><?= number_format($value->idTablaAmortizacion->monto_cuota,2,",",".")?></td>
            <td><?= (isset($value->idEstatusCuotaExcluida))?$value->idEstatusCuotaExcluida->nombre_estatus:""?></td>
        </tr>
    <?php }?>
</table>

<?php if (!empty($detalle)) { ?>
  <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>
    <br/>
<?php } ?>
