<?php defined('MW_PATH') || exit('No direct script access allowed');

/**
 * This file is part of the MailWizz EMA application.
 * 
 * @package MailWizz EMA
 * @author Serban George Cristian <cristian.serban@mailwizz.com> 
 * @link http://www.mailwizz.com/
 * @copyright 2013-2014 MailWizz EMA (http://www.mailwizz.com)
 * @license http://www.mailwizz.com/license/
 * @since 1.0
 */
 
?>

<div class="panel panel-default">
    <div class="panel-heading">
        <div class="pull-left">
            <h3 class="panel-title">
                <span class="glyphicon glyphicon-user"></span> <?php echo Yii::t('users', 'Users');?>
            </h3>
        </div>
        <div class="pull-right">
            <?php echo CHtml::link(Yii::t('app', 'Create new'), array('users/create'), array('class' => 'btn btn-default btn-xs', 'title' => Yii::t('app', 'Create new')));?>
            <?php echo CHtml::link(Yii::t('app', 'Refresh'), array('users/index'), array('class' => 'btn btn-default btn-xs', 'title' => Yii::t('app', 'Refresh')));?>
        </div>
        <div class="clearfix"><!-- --></div>
    </div>
    <div class="panel-body">
        
        <div class="table-responsive">
        <?php 
        $this->widget('zii.widgets.grid.CGridView', array(
            'id'                => $user->modelName.'-grid',
            'dataProvider'      => $user->search(),
            'filter'            => $user,
            'filterPosition'    => 'body',
            'filterCssClass'    => 'grid-filter-cell',
            'itemsCssClass'     => 'table table-bordered table-hover table-striped',
            'selectableRows'    => 0,
            'enableSorting'     => false,
            'cssFile'           => false,
            'pagerCssClass'     => 'pagination pull-right',
            'pager'             => array(
                'class'         => 'CLinkPager',
                'cssFile'       => false,
                'header'        => false,
                'htmlOptions'   => array('class' => 'pagination')
            ),
            'columns' => $hooks->applyFilters('backend_customers_list_grid_columns', array(
        
                array(
                    'name'  => 'first_name',
                    'value' => '$data->first_name',
                ),
                
                array(
                    'name'  => 'last_name',
                    'value' => '$data->last_name'
                ),
                
                array(
                    'name'  => 'email',
                    'value' => '$data->email'
                ),
        
                array(
                    'name'  => 'status',
                    'value' => '$data->status',
                    'filter'=> CHtml::activeDropDownList($user, 'status',  CMap::mergeArray(array('' => Yii::t('app', 'Choose')), $user->getStatusesArray())),
                ),
        
                array(
                    'name'  => 'date_added',
                    'value' => '$data->dateAdded',
                    'filter'=> false,
                ),
                
                array(
                    'name'  => 'last_updated',
                    'value' => '$data->lastUpdated',
                    'filter'=> false,
                ),
        
                array(
                    'class'     => 'CButtonColumn',
                    'header'    => Yii::t('app', 'Options'),
                    'buttons'   => array(
                        'update' => array(
                            'label'     => ' &nbsp; <span class="glyphicon glyphicon-pencil"></span> &nbsp;', 
                            'url'       => 'Yii::app()->createUrl("users/update", array("id" => $data->user_id))',
                            'imageUrl'  => null,
                            'options'   => array('title' => Yii::t('app', 'Update'), 'class' => ''),
                        ),
                        'delete' => array(
                            'label'     => ' &nbsp; <span class="glyphicon glyphicon-remove-circle"></span> &nbsp; ', 
                            'url'       => 'Yii::app()->createUrl("users/delete", array("id" => $data->user_id))',
                            'imageUrl'  => null,
                            'options'   => array('title' => Yii::t('app', 'Delete'), 'class' => 'delete'),
                            'visible'   => '$data->removable === User::TEXT_YES',
                        ),    
                    ),
                    'htmlOptions' => array(
                        'style' => 'width:70px;',
                    ),
                    'template' => '{update} {delete}'
                ),
            ), $user),
        )); ?>
        </div>    
    </div>
</div>