<link rel="stylesheet" href="css/jquery.dataTables.min.css" >
<?php Yii::app()->clientScript->registerScriptFile(Yii::app()->request->baseUrl.'/js/jquery.dataTables.min.js', CClientScript::POS_HEAD); ?>

<h3 style="text-align: center">Vista de préstamo</h3>
<?= CHtml::link('<i class="icon icon-list-alt icon-white"></i> Bandeja de préstamos', CHtml::normalizeUrl(['admin']), array('class' => 'btn btn-inverse')); ?>
<?php if (Yii::app()->user->checkAccess('boton_aprobar_credito_view')): ?>
&nbsp;
<?= CHtml::link('<i class="icon icon-ok icon-white"></i> Aprobar', CHtml::normalizeUrl(['aprobar', 'id' => $model->id]), array('class' => 'btn btn-inverse')); ?>
&nbsp;
    <?php if($model->id_estatus==4):?>
    <?= CHtml::link('<i class="icon icon-random icon-white"></i> Reestructuración del préstamo', CHtml::normalizeUrl(['ReestructuracionCredito', 'id' => $model->id]), array('class' => 'btn btn-inverse'));
        endif;
    ?>
<?php endif ?>
<br>
<br>
<fieldset>
    <legend style=" font-size: 17px;"><b>Datos del solicitante</b></legend>
    <table class="table table-bordered">
        <tr>
            <td style="width: 25%"><b>C&eacute;dula de identidad del solicitante</b></td>
            <td style="width: 25%"> <?php echo$model->idAsociado->cedula; ?></td>
            <td style="width: 20%"><b>Nombres y apellidos</b></td>
            <td style="width: 30%"><?php echo $model->idAsociado->nombre.' '.$model->idAsociado->apellidos; ?></td>
        </tr>
        <tr>
            <td><b>Empresa</b></td>
            <td><?php echo ($model->idAsociado->lugartrabajo0)?$model->idAsociado->lugartrabajo0->descripcion:""; ?></td>
            <td><b>Unidad</b></td>
            <td><?php echo ($model->idAsociado->unidad)?$model->idAsociado->unidad->descripcion:""; ?></td>
        </tr>
        <tr>
            <td><b>&Uacute;ltimo sueldo</b></td>
            <td>Bs. <?php echo $model->idAsociado->utltimoSueldo($model->idasociado);?></td>
            <td><b>Porcentaje de aporte</b></td>
            <td><?php echo ($model->idAsociado->aportes)?$model->idAsociado->aportes->descripcion.'%':""; ?></td>
        </tr>
        <tr>
            <td><b>Fecha de inscripci&oacute;n</b></td>
            <td><?php echo $model->idAsociado->fechaingreso ?></td>
            <td><b>Estatus</b></td>
            <td><?php echo ($model->idAsociado->blnborrado=="1")?"Inacivo":"Activo"; ?></td>
        </tr>
        <tr>
            <td colspan="4" id="calculadoraHaberesSocio" class="datosCredito" style="display: none"></td>
        </tr>

    </table>
</fieldset>
<fieldset><legend style=" font-size: 17px;"><b>Capacidad de pago</b></legend>
<table class="table table-bordered" id="datos_prestamos_calculadora">
        <tr>
            <td style="width: 25%"><b>Categor&iacute;a del pr&eacute;stamo </b></td>
            <td style="width: 25%"><?php echo ($model->idTipoCredito)?(($model->idTipoCredito->idTituloTipoCredito)?$model->idTipoCredito->idTituloTipoCredito->nombre_titulo:""):"" ?></td>
            <td style="width: 20%"><b>Tipo de pr&eacute;stamo</b></td>
            <td style="width: 30%"><?php echo ($model->idTipoCredito)?$model->idTipoCredito->descripcion:"" ?></td>
        </tr>

        <tr>
            <td colspan="4" id="calculadoraHaberes" class="datosCredito" style="display: none"></td>
        </tr>
        <?php
            if(isset($modelCapacidadPago['detalle_capacidad_pago']) && count($modelCapacidadPago['detalle_capacidad_pago'])>0){?>
                <tr>
                    <td> <b>Monto total disponible: </b></td>
                    <td>Bs. <?php echo Yii::app()->numberFormatter->formatCurrency($modelCapacidadPago['total_haberes'],'') ?>
                    </td>
                    <td><b>Total en pr&eacute;stamos:</b></td>
                    <td>Bs. <?php echo Yii::app()->numberFormatter->formatCurrency($modelCapacidadPago['total_monto_prestamo'],'') ?>
                    </td>
                </tr>
                <tr>
                    <td> <b>Porcentaje de disponibilidad: </b></td>
                    <td><?php echo number_format($modelCapacidadPago['porcentaje_tipo_credito'], 3, ',', '.') ?>%
                    </td>
                    <td><b>Monto disponible a solicitar:</b></td>
                    <td>Bs. <?php echo Yii::app()->numberFormatter->formatCurrency(($modelCapacidadPago['total_haberes']*($modelCapacidadPago['porcentaje_tipo_credito']/100))-$modelCapacidadPago['total_monto_prestamo'],'') ?>
                    </td>
                </tr>
                <tr class="detalle_capacidad_pago">
                    <td colspan="2"><b>Descripci&oacute;n</b></td>
                    <td><b>Asignaci&oacute;n</b></td>
                    <td><b>Deducciones</b></td>
                </tr>
                <?php   foreach ($modelCapacidadPago['detalle_capacidad_pago'] as $key => $value) {?>
                            <tr class="detalle_capacidad_pago">
                                <td colspan="2"><b><?php echo $value['nombre_concepto']; ?></b></td>
                                <td><?php echo ($value['asignacion'])?'Bs . '.$value['monto']:"" ?></td>
                                <td><?php echo (!$value['asignacion'])?'Bs. '.$value['monto']:""; ?></td>
                            </tr>
                <?php }?>
                <tr class="detalle_capacidad_pago">
                        <td colspan="2"><b>Totales</b></td>
                        <td style="text-align: left"><div id="total_asignacion" class="campo_asignacion"><?php echo 'Bs. '.number_format($modelCapacidadPago['total_asiganaciones'], 2, ',', '.') ?></div></td>
                        <td style="text-align: left"><div id="total_deducciones" class="campo_deduccion"><?php echo 'Bs. '.number_format($modelCapacidadPago['total_deducciones'], 2, ',', '.') ?></div></td>
                </tr>
                <tr class="detalle_capacidad_pago">
                        <td><b>Sueldo integral</b></td>
                        <td><div id="sueldo_integral"><?php echo 'Bs. '.Yii::app()->numberFormatter->formatCurrency($modelCapacidadPago['total_asiganaciones'],'') ?></div></td>
                        <td><b>33% del descunto integral</b></td>
                        <td><div id="porcentaje_sueldo"><?php echo 'Bs. '.Yii::app()->numberFormatter->formatCurrency(($modelCapacidadPago['total_asiganaciones']*0.33),'') ?></div></td>
                </tr>
                            <tr class="detalle_capacidad_pago">
                        <td><b>Monto total comprometido mensual</b></td>
                        <td><div id="total_prestamos"><?php echo 'Bs. '.Yii::app()->numberFormatter->formatCurrency($modelCapacidadPago['total_deducciones'],'') ?></div></td>
                        <td><b>% en pr&eacute;stamos mensual</b></td>
                        <td><div id="porcentaje_total_prestamos"><?php echo Yii::app()->numberFormatter->formatCurrency(($modelCapacidadPago['total_deducciones']*100)/$modelCapacidadPago['total_asiganaciones'] ,'') ?>%</div></td>
                    </tr>
                            <tr class="detalle_capacidad_pago">
                        <td><b>Monto disponible para comprometer hasta el 33%</b></td>
                        <td><div id="total_disponible"><?php echo 'Bs. '.Yii::app()->numberFormatter->formatCurrency(($modelCapacidadPago['total_asiganaciones']*0.33)-$modelCapacidadPago['total_deducciones'] ,'') ?></div></td>
                        <td><b>% del monto disponible</b></td>
                        <td><div id="porcentaje_total_disponible"><?php echo Yii::app()->numberFormatter->formatCurrency(33-(($modelCapacidadPago['total_deducciones']*100)/$modelCapacidadPago['total_asiganaciones']) ,'') ?>%</div></td>
                    </tr>
                <?php } ?>
    </table>

</fieldset>
<fieldset><legend style=" font-size: 17px;"><b>Datos del pr&eacute;stamo</b></legend>
<table class="table table-bordered" id="datos_prestamos">
        <tr>
            <td style="width: 25%"><b>Monto del pr&eacute;stamo</b></td>
            <td style="width: 25%">Bs. <?php echo  number_format($model->monto_credito,2,',','.') ?></td>
            <td style="width: 20%"><b>Fecha de solicitud</b></td>
            <td style="width: 30%"><?php echo date('d-m-Y',  strtotime($model->fecha_registro));?></td>
        </tr>
        <tr>
            <td style="width: 25%"><b>N&uacute;mero de cuenta</b></td>
            <td style="width: 25%">
                <?php echo $model->cuenta ?>
            </td>
            <td style="width: 20%"><b><?php echo ($model->nombre_recibo_pago!="")?"Recibo de pago":""?></b></td>
            <td style="width: 30%"><?php echo  ($model->nombre_recibo_pago!="")?CHtml::link('Descargar',  Credito::$ruta.$model->nombre_recibo_pago,array('target'=>'_blank','class'=>'btn btn-link')):"";?> </td>
        </tr>
        <tr>
                <td colspan="2"><b>Datos del préstamo:</b></td>
                <td colspan="2"><b>Resultados del préstamo:</b></td>
        </tr>

        <tr class="detalle_tabla_amoritzacion">
            <td><b>Monto a financiar:</b></td>
            <td>Bs. <?php echo  number_format($model->monto_credito,2,',','.') ?></td>
            <td><b>Monto promedio de las cuotas:</b></td>
            <td>Bs. <?php echo number_format($model->cuota_pagar,2,',','.') ?> </td>
        </tr>
        <tr class="detalle_tabla_amoritzacion">
            <td><b>Gastos administrativos:</b></td>
            <td>Bs. <?php echo number_format($model->gastos_administrativo,3,',','.'); ?></td>
            <td><b>Monto total intereses:</b></td>
            <td>Bs. <?php  echo number_format( CreditoTablaAmortizacion::model()->find(array('select'=>'sum(monto_interes) as monto_interes',
                                                                                     'condition'=>'idcredito=:idcredito',
                                                                                     'params'=>array(':idcredito'=>$model->id)))->monto_interes,2,',','.'); ?></td>
        </tr>

        <?php if ($model->monto_bloqueo_anticipado > 0): ?>
        <tr>
            <td><b>Bloqueo anticipado de préstamos:</b></td>
            <td><?= Yii::app()->format->number($model->monto_bloqueo_anticipado) ?></td>
            <td colspan="2"></td>
        </tr>
        <?php endif ?>

                 <?php if($model->idTipoCredito->id_clasificacion_tipo_credito==2):?>
        <tr class="detalle_tabla_amoritzacion">
            <td><b>Gastos administrativos afianzadora:</b></td>
            <td>Bs. <?php echo number_format(($model->gastos_administrativos_afianzadora+$model->gastos_administrativos_afianzadora_caja),2,',','.');?> </td>
            <td><b>Forma de Pago:</b></td>
            <td><?php echo ($model->idTipoNomina)?$model->idTipoNomina->nombre_nomina:"";?></td>
        </tr>
                <?php endif;?>
        <tr class="detalle_tabla_amoritzacion">
                    <td><b>Plazo &oacute; per&iacute;odo:</b></td>
            <td><?php echo $model->idTipoCredito->duracion_credito;?> meses</td>
                        <?php if($model->idTipoCredito->id_clasificacion_tipo_credito==2){?>
                            <td></td>
                            <td></td>
                        <?php }
                            else{?>
                                <td><b>Forma de pago:</b></td>
                                <td><?php echo ($model->idTipoNomina)?$model->idTipoNomina->nombre_nomina:"";?></td>
                        <?php }?>

        </tr>
        <tr class="detalle_tabla_amoritzacion">
                    <td><b>Tasa de inter&eacute;s:</b></td>
            <td><?php echo number_format($model->taza_interes,3,',','.'); ?>%</td>
            <td>Monto deuda cartera de préstamo</td>
            <td><?php echo ($model->monto_credito_anterior>0)?'Bs '.number_format($model->monto_credito_anterior,2,',','.'):""?> </td>
        </tr>

        <tr class="detalle_tabla_amoritzacion">
            <td><b>Total de cuotas: </b></td>
                        <td><?php echo count($model->creditoTablaAmortizacionsCuotaOrdinaria);?> </td>
                        <td><b><?php echo "Monto a depositar"?></b> </td>
                        <td><?php echo 'Bs '.number_format(($model->monto_credito_depositar),2,',','.')?> </td>
        </tr>
        <?php $cuotasEspaciales = count($model->creditoTablaAmortizacionsCuotaEspecial);
                    if($cuotasEspaciales >0):?>
        <tr class="detalle_tabla_amortizacion">
            <td><b>Total de cuotas especiales:  </b></td>
            <td> <?php echo $cuotasEspaciales;?> </td>
            <td></td>
            <td></td>
        </tr>
        <?php endif;?>
        <tr class="detalle_tabla_amortizacion">
            <td><strong>Total cuenta por cobrar capital de préstamo</strong></td>
            <td><?= Yii::app()->format->number(
                (new Warp($modelCreditoSeleccionado))->sum('capital_cuotas_no_afectadas')
            ) ?></td>
            <td><strong>Total cuenta por cobrar interés de préstamo</strong></td>
            <td><?= Yii::app()->format->number(
                (new Warp($modelCreditoSeleccionado))->sum('interes_cuotas_no_afectadas')
            ) ?></td>
        </tr>
        <tr class="detalle_tabla_amortizacion">
            <td><b>Tipo de cobro:  </b></td>
            <td> <?= $model->idTipoCobro?$model->idTipoCobro->descripcion : ""?> </td>
            <td><b>Saldo para abonos:  </b></td>
            <td> Bs. <?= number_format(ReporteCreditos::model()->getMontoDeudaActualConfigurado($model->id),2,',','.');?> </td>
        </tr>
  </table>
  <?php if(count($modelCreditoSeleccionado)> 0){ ?>
<fieldset><legend style=" font-size: 17px;"><b>Pr&eacute;stamos <?= ($model->refinanciado>0)?(($model->refinanciado==1)?'Refinanciado(s)':'Reestructurado(s)'):""?></b></legend>
    <table class="table display items table table-bordered">
        <tr>
            <th style="width: 18%">Categor&iacute;a</th>
            <th style="width: 18%">Plazo del pr&eacute;stamo</th>
            <th style="width: 12%">Monto solicitado</th>
            <th style="width: 12%">Monto aprobado</th>
            <th style="width: 10%">Fecha del pr&eacute;stamo</th>
            <th style="width: 8%">Cuotas pagadas</th>
            <th style="width: 14%">Saldo deudor</th>
            <th style="width: 14%">Capital por cobrar</th>
            <th style="width: 14%">Cnteres por cobrar</th>
        </tr>
    <?php foreach ($modelCreditoSeleccionado as $key => $prestamo) { ?>

                <tr>
                    <td><?= $prestamo['categoria'] ?></td>
                    <td><?= $prestamo['plazo_prestamo'] ?></td>
                    <td>Bs. <?=  number_format($prestamo['prestamo'],2,',','.') ?></td>
                    <td>Bs. <?=  number_format($prestamo['prestamo'],2,',','.'); ?></td>
                    <td><?= date('d-m-Y',strtotime($prestamo['fecha_registro']));?></td>
                    <td><?= (integer) $prestamo['cuotas_pagadas'];?></td>
                    <td>Bs. <?= number_format($prestamo['monto'],2,',','.');?></td>
                    <td>Bs. <?= number_format($prestamo['capital_cuotas_no_afectadas'],2,',','.');?></td>
                    <td>Bs. <?= number_format($prestamo['interes_cuotas_no_afectadas'],2,',','.');?></td>
                </tr>
    <?php }?>
    </table>

</fieldset>
<?php }?>
<?php //echo "<pre>";print_r($model);exit; ?>
<?php if ($model->id_estatus != 2 || $model->id_estatus != 3): ?>
    </fieldset>
    <h3  style="text-align:center">Abonos a pr&eacute;stamos</h3>

     <?php $this->widget('bootstrap.widgets.TbGridView',array(
        'id'=>'conf-retiro-parcial-grid',
        'dataProvider'=> CreditoAbono::model()->searchPrestamo($model->id),
        //'filter'=>$model,
        'columns'=>array(
            array(//'header' => 'Cedula',
                        'name' => 'idbanco',
                        'value' => '$data["idBanco"]["banco"]',
                        'filter' => CHtml::listData(ParamBancos::model()->findAll(), 'id', 'banco'),
                        'type' => 'text',
                    ),
                    array(//'header' => 'Cedula',
                        'name' => 'idforma_pago',
                        'value' => '$data->idFormaPago->descripcion',
                        'filter' => CHtml::listData(FormaPago::model()->findAll(), 'id', 'descripcion'),
                        'type' => 'text',
                    ),
                    'numero_referencia',
                    array(
                        'header' => 'Monto depositado',
                        'name' => 'monto_abonar',
                        'value' => "\$data->monto_abonar"
                    ),
                    array(
                        'name' => 'monto_abonar',
                        'value' => "\$data->getMontoMultipleAbonado(".$model->id.")"
                    ),
                    array(
                        'name' => 'mantener_cuota',
                        'value' => "(\$data->mantener_cuota)?'Si':'No'"
                    ),
                    // array(
                    //     'header' => 'Monto de la cuota',
                    //     'value' => '($data->idCuotaAfectada)?"Bs. ".number_format($data->idCuotaAfectada->monto_cuota,2,",",".") :""'
                    // ),


                    array(
                        'header'=>'Fecha de Solicitud',
                        'name'=>'fecha_registro',
                        'value' => 'date("d-m-Y",strtotime($data->fecha_registro))' ,
                       // 'htmlOptions'=>array('width'=>'180px'),
                        'class'=>'SYDateColumn',
                      ),
                    array(
                        'name'=>'id_estatus',
                        'value'=>'$data->nombre_estatus',
                        'filter'=>CHtml::listData(EstatusCredito::model()->findAll('blnborrado= false'), 'id', 'nombre_estatus'),
                    ),
                    array(
                        'class' => 'bootstrap.widgets.TbButtonColumn',
                        'template' => '{view}',
                        'buttons' => array(
                            'view' => array(
                                'url' => "CHtml::normalizeUrl(array('CreditoAbono/view', 'id'=>\$data->id))",
                                'imageUrl' => Yii::app()->request->baseUrl . '/images/aprobar.png',
                            ),
                        ),
                    ),

        ),
    )); ?>

    <?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
        ),
    ));
    ?>
       <div>
            <?php /*echo CHtml::submitButton('Imprimir Solicitud',
           array('style'=>'margin-left:7px; padding:6px;','icon'=>'icon-print','class'=>'btn btn-info',
           'submit'=>array('/credito/solicitudPrestamo','id'=>$model->id),));*/
            ?>
        </div>

    <h3  style="text-align:center">Cuotas Ordinarias <?php echo ($model->idTipoNomina)?$model->idTipoNomina->nombre_nomina:"";?></h3>
    <?php
    $this->widget('bootstrap.widgets.TbGridView',array(
      'type'=>'bordered',
      'id'=>'creditospagos-grid',
      'dataProvider'=>  CreditoTablaAmortizacion::model()->search($model->id),
      'columns'=>array(
            array(
               // 'header' => 'Número Cuota',
                'name' => 'numero_cuota',
                'value' => '$data->numero_cuota'
            ),
            array(
               // 'header' => 'Monto restante',
                'name' => 'fecha_vencimiento',
                'value' => '($data->fecha_vencimiento)?date("d-m-Y",strtotime($data->fecha_vencimiento)):""',
                'visible'=>(($model->fecha_primer_descuento)?TRUE:FALSE)
            ),
            array(
               // 'header' => 'Monto restante',
                'name' => 'monto_base',
                'value' => 'number_format($data->monto_base, 2,",",".")'
            ),
            array(
               // 'header' => 'Monto restante',
                'name' => 'monto_capital',
                'value' => 'number_format($data->monto_capital, 2,",",".")'
            ),
            array(
               // 'header' => 'Monto restante',
                'name' => 'monto_interes',
                'value' => 'number_format($data->monto_interes, 2,",",".")'
            ),
            array(
               // 'header' => 'Monto restante',
                'name' => 'monto_cuota',
                'value' => 'number_format($data->monto_cuota, 2,",",".")'
            ),
            'monto_pagado:number',
            array(
                'header' => 'Saldo actual',
                'name' => 'monto_credito',
                'value' => 'number_format($data->monto_credito, 2,",",".")'
            ),
            array(
                'name' => 'id_estatus_cuota', // 'header' => 'Pagada',
                'value' => '($data->idEstatusCuota)?$data->idEstatusCuota->nombre_estatus:""',
            ),
          ),
    ));?>

    <?php

        if(count(CreditoTablaAmortizacion::model()->searchCuotaEspecial($model->id)->getData())>0){?>
            <h3 style="text-align:center">Cuotas Especiales </h3>
            <?php $this->widget('bootstrap.widgets.TbGridView',array(
                        'type'=>'bordered',
                        'id'=>'cuotasespeciales-grid',
                        'dataProvider'=> CreditoTablaAmortizacion::model()->searchCuotaEspecial($model->id),
                        'columns'=>array(
                              array(
                                 // 'header' => 'Número Cuota',
                                  'name' => 'numero_cuota',
                                  'value' => '$data->numero_cuota'
                              ),
                              array(
                                 // 'header' => 'Monto restante',
                                  'name' => 'fecha_vencimiento',
                                  'value' => '($data->fecha_vencimiento)?date("d-m-Y",strtotime($data->fecha_vencimiento)):""',
                                  'visible'=>(($model->fecha_primer_descuento)?TRUE:FALSE)
                              ),
                              array(
                                 // 'header' => 'Monto restante',
                                  'name' => 'monto_base',
                                  'value' => 'number_format($data->monto_base, 2,",",".")'
                              ),
                              array(
                                 // 'header' => 'Monto restante',
                                  'name' => 'monto_capital',
                                  'value' => 'number_format($data->monto_capital, 2,",",".")'
                              ),
                              array(
                                 // 'header' => 'Monto restante',
                                  'name' => 'monto_interes',
                                  'value' => 'number_format($data->monto_interes, 2,",",".")'
                              ),
                              array(
                                 // 'header' => 'Monto restante',
                                  'name' => 'monto_cuota',
                                  'value' => 'number_format($data->monto_cuota, 2,",",".")'
                              ),
                              array(
                                 'header' => 'Saldo actual',
                                  'name' => 'monto_credito',
                                  'value' => 'number_format($data->monto_credito, 2,",",".")'
                              ),
                              array(
                                    'name' => 'id_estatus_cuota', // 'header' => 'Pagada',
                                    'value' => '($data->idEstatusCuota)?$data->idEstatusCuota->nombre_estatus:""',
                                ),
                            ),
                      ));
        }
    ?>
<?php endif ?>
<br>
<?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>
        <?php echo CHtml::submitButton('Imprimir Solicitud',
       array('style'=>'margin-left:7px; padding:6px;','icon'=>'icon-print','class'=>'btn btn-info',
       'submit'=>array('ComprobanteSolcitudPrestamo','id'=>$model->id),));
        ?>
    </div>
 <?php $this->widget('bootstrap.widgets.TbGridView',array(
    'id'=>'conf-retiro-parcial-grid',
    'dataProvider'=> CreditoSeguimiento::model()->searchSeguimientoCredito($model->id),
    //'filter'=>$model,
    'columns'=>array(
        array(
                    'name'=>'fecha_registro',
                    'value'=>'date("d-m-Y h:m:s",strtotime($data->fecha_registro))',
                ),
        array(
                    'header'=>'Estatus del crédito',
                    'name'=>'id_estatus_retiro',
                    'value'=>'$data->nombre_estatus',
                ),
        array(
                    'header'=>'Observación',
                    'name'=>'observacion',
                    'value'=>'$data->observacion',
                ),
        array(
                    'header'=>'Usuario',
                    'name'=>'id_usuario',
                    'value'=>'$data["idUsuario"]["username"]',
                ),
    ),
)); ?>

<?php if( $model->reestructuracion_seguimiento !=""){?>

    <h2 class="text-center">Auditoria de la reestructuraci&oacute;n</h2>

    <table id="tabla" class="table display items table table-bordered">
        <thead>
            <tr>
              <th style="width: 18%">Usuario</th>
              <th style="width: 14%">Fecha del registro</th>
              <th style="width: 12%">Saldo deudor de reestructuraci&oacute;n</th>
              <th style="width: 12%">Cuota anterior</th>
              <th style="width: 7%">N&uacute;mero de cuotas</th>
              <th style="width: 8%">Tipo de la n&oacute;mina</th>
              <th style="width: 8%">Tipo de cobro</th>
              <th style="width: 10%">Fecha del primer descuento</th>
            </tr>
        </thead>
        <tbody>
        <?php foreach (json_decode($model->reestructuracion_seguimiento, true) as $key => $value) {?>
          <tr>
            <td><?= $value['id_usuario']!=""? CrugeUserI::model()->findByPk($value['id_usuario'])->username :"" ?></td>
            <td><?= $value['fecha_registro']!=""? date('d-m-Y h:m:s A',strtotime($value['fecha_registro'])) :"" ?></td>
            <td><?= number_format($value['saldo_deudor'], 2, ',','.')  ?></td>
            <td><?= number_format($value['cuota_pagar'], 2, ',','.')  ?></td>
            <td><?= $value['numero_cuota'] ?></td>
            <td><?= $value['id_tipo_nomina']!=""? TipoNomina::model()->findByPk($value['id_tipo_cobro'])->nombre_nomina :"" ?></td>
            <td><?= $value['id_tipo_cobro']!=""? TipoCobro::model()->findByPk($value['id_tipo_cobro'])->descripcion :"" ?></td>
            <td><?= $value['fecha_primer_descuento'] ?></td>

          </tr>
        <?php }?>
        </tbody>
    </table>

             <?php               }?>


<script>


  $('#tabla').DataTable( {
          "language": {
              "url": "js/jquery.dataTables.Spanish.json",
          }
      });
</script>
<br>
