<?php
    $pageTitle = "Regras de Negócio &raquo; {$model->Grupo->REG_NOME}";
    $this->PageTitle = $pageTitle;

    $this->menu = array(
        array('label' => FaHtml::iconNovo(), 'url' => array('create&grupo=' . $grupo->REG_ID), 'linkOptions' => array('target' => '_blank', 'class' => 'novo')),
        array('label' => FaHtml::iconSetaClose(), 'url' => '#', 'linkOptions' => array('class' => 'search-button')),
        array('label' => FaHtml::iconRefresh(), 'url' => 'javascript:void(0);', 'linkOptions' => array('onclick' => 'reloadFrame();', 'class' => 'refresh-button'))
    );

    $display = $dataProvider->totalItemCount > 0 ? 'none' : 'block';
?>

<div class="search-form" style="display: <?= $display; ?>" >
    <?php
        $this->renderPartial('_search', array(
            'model' => $model,
            'grupo' => $grupo,
            'origem' => $origem,
            'tiposAcoes' => $tiposAcoes
        ));
    ?>
</div><!-- search-form -->

<div class="table-responsive">
    <?php
        $this->widget('ext.Utils.widgets.CrmGridView', array(
            'id' => 'admin-grid',
            'dataProvider' => $dataProvider,
            'selectableRows'=>1,
            'afterAjaxUpdate'=>'updated',
            'pager' => Util::getPagerDefaultConfig(),
            'columns' => array(
                'REN_ID',
                'Origem',
                array(
                    'name' => 'Descricao',
                    'value' => '$data->getDescricao()',
                    'type' => 'raw',
                ),
                array(
                    'name' => 'REN_SITUACAO',
                    'value' => '$data->REN_SITUACAO == 1 ? "Ativo" : "Inativo"'
                ),
                array(
                    'class' => 'CButtonColumn',
                    'template'=> '{view} {update} {delete}',
                    'viewButtonOptions'   => array('target'   => '_blank'),
                    'updateButtonOptions' => array('target' => '_blank'),
                    'buttons'=>array(
                        'view' => array(
                            'label'=>'Exibir',
                            'url'=>'Yii::app()->createUrl("regrasNegocio/view", array("id"=>$data->REN_ID))',
                        ),
                        'update' => array(
                            'label'=>'Editar',
                            'url'=>'Yii::app()->createUrl("regrasNegocio/update", array("id"=>$data->REN_ID))',
                        ),
                        'delete' => array(
                            'label' => 'Excluir',
                            'url'   => 'Yii::app()->createUrl("regrasNegocio/delete", array("id"=>$data->REN_ID))',
                        ),
                    ),
                ),
            ),
        ));
    ?>
</div>