<?php
/* @var $this PlanillaController */
/* @var $model Planilla */

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

$('.search-form form').submit(function(){
	$('#comision-grid').yiiGridView('update', {
		data: $(this).serialize()
	});
        
        $('#total').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('comision/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('comision/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('comision') . '"; ',
                                                '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('comision-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'=>'comision-grid',
	'dataProvider'=>$model->search(),
        'pager' => array('cssFile' => Yii::app()->baseUrl.'/public/css/tablas.css'),
	'filter'=>$model,
	'columns'=>array(
            
                array(
                'header'=>'ID',  
                'value' => '$data->id_comision',
                'type' => 'text',
                'name' => 'id_comision',
                'htmlOptions' => array('class' => 'text-center'),
                ),
            
		array(
                'header'=>'GESTOR',  
                'value' => '$data->gestor',
                'type' => 'text',
                'name' => 'gestor',
                'htmlOptions' => array('class' => 'text-center'),
                ),
            
            array(
                'header'=>'FECHA',  
                'value' => 'Utility::fecha($data->fecha)',
                'type' => 'text',
                'name' => 'fecha',
                'htmlOptions' => array('class' => 'text-center'),
                ),
            
                array(
                'header'=>'CLIENTE',  
                'value' => '$data->cliente',
                'type' => 'text',
                'name' => 'cliente',
                'htmlOptions' => array('class' => 'text-center'),
                ),
            
            
		array(
                'header'=>'MONTO',  
                'value' => 'number_format($data->monto, 2, ",", ".")  ',
                'type' => 'text',
                'name' => 'monto',
                'htmlOptions' => array('class' => 'text-center'),
                ),
            
                array(
                'header'=>'comision',  
                'value' => 'number_format($data->comision, 2, ",", ".")  ',
                'type' => 'text',
                'name' => 'monto',
                'htmlOptions' => array('class' => 'text-center'),
                ),

            
		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> 