<?php
/* @var $this PrestamoController */
/* @var $model Prestamo */

Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
	$('.search-form').toggle();
	return false;
});

$('.search-form form').submit(function(){
	$('#prestamo-grid').yiiGridView('update', {
		data: $(this).serialize()
	});
        
 });
");
?>

<div class="row m-b-20">
        
    <div class="col-12 col-sm-12 col-md-3 ">
        <?php
                     $this->widget('booster.widgets.TbButton', array(
                        'context'=>'primary',
                         'label'=>'AGREGAR',
                         'buttonType' => 'link',
                         'icon' => 'fa fa-plus fa-lg',
                         'url'=>Yii::app()->createUrl('prestamo/create'),
                          'htmlOptions' => array(
                                                'data-toggle' => "tooltip",
                                                'data-original-title' => 'AGREGAR',
                                                'class'=>'btn btn-block btn-primary'
                                            ),  
                     ));
                     ?>  
        </div>
        
        <div class="col-12 col-sm-12 col-md-3 ">
                       <?php
                        $this->widget('booster.widgets.TbButton', array(
                        'context'=>'success',
                         'buttonType' => 'link',
                         'label'=>'EXCEL',
                         'icon' => 'fa fa-file-excel fa-lg',
                         'url' => Yii::app()->createUrl('prestamo/excel'),
                          'htmlOptions' => array(
                                                'data-toggle' => "tooltip",
                                                'data-original-title' => 'EXPORTAR A EXCEL',
                                                'class'=>'btn btn-block btn-success',
                                              
                                                ),  
                         ));
                         ?>   
        </div>  
    
    <div class="col-12 col-sm-12 col-md-3 ">
        <?php echo CHtml::link('<i class="fa fa-search fa-lg"></i> BUSCAR', 
             '#', 
             array('class'=>'btn btn-info btn-block  search-button',
                 'data-toggle' => "tooltip",
                 'data-original-title' => 'BUSCAR',

                 )); 
     ?> 
    </div>
     
    
    
             
        <div class="col-12 col-sm-12 col-md-3 ">


                         <?php
                         $this->widget('booster.widgets.TbButton', array(
                        'context'=>'danger',
                         'buttonType' => 'link',
                             
                              'label' => ' REFRESCAR',
                                            'icon' => 'fas fa-redo-alt',
                                            'htmlOptions' => array(
                                                'class'=>'text-capitalize',
                                                'data-toggle' => "tooltip",
                                                'data-original-title' => 'REFRESCAR LISTA',
                                                'onClick' => 'window.location="' . Yii::app()->createUrl('prestamo') . '"; ',
                                                'class'=>'btn btn-block btn-danger'
                                            ),
                                              'url' => '#',
                     ));
                     ?>        
            </div>
</div>



<div class="row">
    <div class="col-12 col-sm-12 col-md-3 ">
        <?php
        $pageSize = Yii::app()->user->getState('pageSize', Yii::app()->params['defaultPageSize']);
        echo
        'Ver ' .
         CHtml::dropDownList('pageSize', $pageSize, Utility::listaPageSize(), array(
            'onchange' => "$.fn.yiiGridView.update('prestamo-grid',{ data:{pageSize: $(this).val() }})",
        ))
         . ' Registros';
        ?>
    </div>
</div>


<div class="col-12 p-4">
        <div class="search-form" style="display:none">
        <?php 
        $this->renderPartial('_search',array('model'=>$model,)); 
        ?>
        </div>
</div>


<div class='table-responsive'>   
<?php $this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'prestamo-grid',
	'dataProvider'=>$model->search(),
        'pager' => array('cssFile' => Yii::app()->baseUrl.'/public/css/tablas.css'),
	'filter'=>$model,
	'columns'=>array(
	        array(
                'header'=>'ID',  
                'value' => '$data->id_prestamo',
                'type' => 'text',
                'name' => 'id_prestamo',
                'htmlOptions' => array('class' => 'text-center'),
                ),
            
            
             array(
                'header'=>'DNI',  
                'value' => '$data->dni',
                'type' => 'text',
                'name' => 'dni',
                'htmlOptions' => array('class' => 'text-center'),
                ),
                array(
                'header'=>'NOMBRE',  
                'value' => '$data->nombre',
                'type' => 'text',
                'name' => 'nombre',
                'htmlOptions' => array('class' => 'text-center'),
                ),
            
            
                array(
                'header'=>'APELLIDO',  
                'value' => '$data->apellido',
                'type' => 'text',
                'name' => 'apellido',
                'htmlOptions' => array('class' => 'text-center'),
                ),
            
                array(
                'header'=>'FECHA',  
                'value' => '$data->fecha_inicio',
                'type' => 'text',
                'name' => 'fecha_inicio',
                'htmlOptions' => array('class' => 'text-center'),
                ),
            
		array(
                'header'=>'MONTO',  
                'value' => '$data->monto',
                'type' => 'text',
                'name' => 'monto',
                'htmlOptions' => array('class' => 'text-center'),
                ),
        
                array(
                'header'=>'ESTATUS',  
                'value' => '$data->estatus',
                'type' => 'text',
                'name' => 'estatus',
                'htmlOptions' => array('class' => 'text-center'),
                ),

            array(
                'header' => 'CANCELAR',
                'class' => 'CButtonColumn',
                'htmlOptions' => array( 'class' => 'text-center'),
                'template' => '{pdf}',
                'buttons' => array(
                   'pdf' => array(
                        'label' => '',
                        'url' => 'Yii::app()->controller->createUrl("cancelar",array("id"=>$data->id_prestamo))',
                        'options' => array(
                            'data-toggle' => 'tooltip',
                            'class' => ' fa fa-times fa-lg mr-3 text-danger',
                            'data-original-title' => 'CANCELAR PRESTAMO',

                           
                        ),
                        'visible' => 'true',
                    ),

                ),
            ),
            
            
            
            array(
                'header' => 'ESTADO',
                'class' => 'CButtonColumn',
                'htmlOptions' => array( 'class' => 'text-center'),
                'template' => '{pdf}',
                'buttons' => array(
                   'pdf' => array(
                        'label' => '',
                        'url' => 'Yii::app()->controller->createUrl("estado",array("id"=>$data->id_prestamo))',
                        'options' => array(
                            'data-toggle' => 'tooltip',
                            'class' => ' fa fa-file-pdf fa-lg mr-3 text-danger',
                            'data-original-title' => 'GENERAR ESTADO DE CUENTA',

                            'target'=>'_black'
                        ),
                        'visible' => 'true',
                    ),

                ),
            ),
            
            
            
		array(
                  'header' => 'ACCION',
                  'class' => 'CButtonColumn',
                  'deleteButtonImageUrl' => false,
                  'updateButtonImageUrl' => false,
                  'viewButtonImageUrl' => false,
                  'htmlOptions' => array('width' => '100', 'class' => 'text-center'),
                  'template' => '{view}{update}{delete}',
                  'buttons' => array(
                      'view' => array(
                          'label' => ' ',
                          'options' => array(
                              'class' => 'mdi mdi-18px mdi-eye m-r-10 text-primary',
                              'title' => 'VER',
                          ),
                          'visible' => 'true',
                      ),
                        'update' => array(
                          'label' => ' ',
                          'options' => array(
                              'class' => 'mdi mdi-18px mdi-pencil m-r-10 text-primary',
                              'title' => 'ACTUALIZAR',
                          ),
                          'visible' => 'true',
                      ),
                        'delete' => array(
                            'label' => ' ',
                            'options' => array(
                                'class' => 'mdi mdi-18px mdi-trash-can-outline m-r-10 text-primary',
                                'title' => 'ELIMINAR',
                          ),
                            'visible' => 'true',
                      ),
                  )
              ),
	),
)); ?>
</div> 