<?php

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

$('.search-form form').submit(function(){
	$('#cliente-grid').yiiGridView('update', {
		data: $(this).serialize()
	});
	return false;
});
");

 
    $v='FALSE';
    if(!empty($_SESSION['id_perfil']) and ($_SESSION['id_perfil']=='1') ){
        $v='TRUE';
    }




?>

<div class="row">
  
    <div class="col-12  col-sm-12 col-md-3"  style="margin-left: 23px;">
        <?php
        $pageSize = Yii::app()->user->getState('pageSize', Yii::app()->params['defaultPageSize']);
        echo
        'Ver ' .
         CHtml::dropDownList('pageSize', $pageSize, Utility::listaPageSize(), array(
            'class'=>'p-2 border-primary text-primary',
            'onchange' => "$.fn.yiiGridView.update('cliente-grid',{ data:{pageSize: $(this).val() }})",
        ))
         . ' Registros';
        ?>
    </div> 
    
    
    <div class="col-12  col-sm-12 col-md-8 text-right"  style="margin-right: 25px;" >
         
 <?php echo CHtml::link('<i class="fa fa-plus fa-lg"></i>  AGREGAR CLIENTE', 
             Yii::app()->createUrl('cliente/create'), 
             array('class'=>'btn btn-primary',
                 'data-toggle' => "tooltip",
                 'data-original-title' => 'AGREGAR CLIENTE',
                 )); 
     ?>     
    <?php
    $this->widget('booster.widgets.TbButton', array(
       'context'=>'danger',
        'label'=>'MODIFICAR GESTORES',
        'buttonType' => 'link',
        'icon' => 'fa fa-edit fa-lg',
        'url'=>Yii::app()->createUrl('cliente/gestores'),
         'htmlOptions' => array(
                               'data-toggle' => "tooltip",
                               'data-original-title' => 'MODIFICAR GESTORES',
                               'class'=>'btn btn-info'
                           ),  
    ));
    ?>
    <?php echo CHtml::link('<i class="fa fa-file-pdf fa-lg"></i> EXCEL', 
             Yii::app()->createUrl('cliente/excel'), 
             array('class'=>'btn btn-success',
                 'data-toggle' => "tooltip",
                 'data-original-title' => 'EXPORTAR A EXCEL',
                 'style'=>'background-color:#066100;'
                 )); 
     ?> 
 
     <?php echo CHtml::link('<i class="fas fa-sync fa-lg"></i>', 
             '#', 
             array('class'=>'btn btn-danger',
                 'onClick' => 'window.location="' . Yii::app()->createUrl('cliente') . '"; ',
                 'data-toggle' => "tooltip",
                 'data-original-title' => 'REFRESCAR LISTA'
                 )); 
     ?>   
    </div>
</div>



<div class='table-responsive'>   
<?php $this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'cliente-grid',
	'dataProvider'=>$model->search(),
        'pager' => array('cssFile' => Yii::app()->baseUrl.'/public/css/tablas.css'),
	'filter'=>$model,
	'columns'=>array(
            
                array(
                    'filter'=> FALSE,
                    'header'=>'ID',
                    'name' => 'id_cliente',
                    'value' => '$data->id_cliente',
                    'type' => 'text',
                    'htmlOptions' => array('class' => 'text-center'),
                ),
                array(
                    'name' => 'dni',
                    'value' => '$data->dni',
                    'type' => 'text',
                    'htmlOptions' => array('class' => 'text-center'),
                ),
                array(
                    'name' => 'nombre',
                    'value' => '$data->nombre',
                    'type' => 'text',
                    'htmlOptions' => array('class' => 'text-center'),
                ),
                array(
                    'name' => 'apellido',
                    'value' => '$data->apellido',
                    'type' => 'text',
                    '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}{borrar}',
                  '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' => $v,
                      ),
                        'borrar' => array(
                            'label' => ' ',
                            'url' => 'Yii::app()->controller->createUrl("borrar",array("id"=>$data->id_cliente))',
                            'options' => array(
                                'class' => 'mdi mdi-18px mdi-trash-can-outline m-r-10 text-primary ',
                                'title' => 'ELIMINAR',
                                'confirm' => '¿Confirma que desea eliminar el cliente?',
                          ),
                            'visible' => $v,
                      ),
                  )
              ),
            
             
          	array(
                  'header' => 'EXPORTAR',
                  'class' => 'CButtonColumn',
                  'htmlOptions' => array('width' => '100', 'class' => 'text-center'),
                  'template' => '{pdf}',
                  'buttons' => array(
                       'pdf' => array(
                            'label' => '',
                            'url' => 'Yii::app()->controller->createUrl("Pdfcliente",array("id"=>$data->id_cliente))',
                            'options' => array(
                                'data-toggle' => 'tooltip',
                                'class' => ' fa fa-file-pdf fa-lg mr-3 text-danger',
                                'data-original-title' => 'PDF',
                                'onclick' => 'app(this)',
                                'target'=>'_black'
                            ),
                            'visible' => 'true',
                        ),

                  )
              ),  
            
            
	),
)); ?>
</div> 