<?php
$this->PageTitle = 'Atas';

$botoes = '{view} {update} {PDF} ';

if (User::isAdmin()) {
    $botoes .= ' {delete}';
}

$imagem = (User::getUser()->FUN_TBL_ATAS == 1 ) ? FaHtml::iconNovo() : FaHtml::iconBlank();

$this->menu = array(
    array('label' => $imagem, 'url' => array('create'), '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'))
);
?>
<?php
$dataProvider = $model->search();
?>
<div class="search-form" <?php if($dataProvider->totalItemCount > 0) echo 'style="display: none;"'; ?> >
    <?php
    $this->renderPartial('_search', array(
        'model' => $model,
    ));
    ?>
</div><!-- search-form -->

<?php
$this->widget('ext.Utils.widgets.CrmGridView', array(
    'id' => 'admin-grid',
    'dataProvider' => $dataProvider,
    'afterAjaxUpdate'=>'updated',
    'pager' => Util::getPagerDefaultConfig(),
    'columns' => array(
        //'ATA_IDATA',
        'ATA_DATA',
        'ATA_ASSUNTO',
        //'ATA_CONTEUDO',
        array(
            'name' => 'ATA_IDFUNCIONARIO',
            'value' => 'GxHtml::valueEx($data->Usuario)',
        ),
        array(
            'class' => 'CButtonColumn',
            'template' => $botoes,
            'viewButtonOptions' => array('target' => '_blank'),
            'updateButtonOptions' => array('target' => '_blank'),
            'buttons' => array(
                'PDF' => array(
                    'label' => 'Gerar PDF',
                    'imageUrl' => FaHtml::getImgUrl('ico-pdf.png'),
                    'url' => 'Yii::app()->createUrl("atas/gerarpdf", array("id"=>$data->ATA_IDATA))',
                    'options' => array('target' => '_blank'),
                    'visible' => '$data->isAllowed(false)'
                ),
                'view' => array(
                    'label' => 'Exibir',
                    'url' => 'Yii::app()->createUrl("atas/view", array("id"=>$data->ATA_IDATA))',
                    'visible' => '$data->isAllowed(false)'
                ),
                'update' => array(
                    'label' => 'Editar',
                    'url' => 'Yii::app()->createUrl("atas/update", array("id"=>$data->ATA_IDATA))',
                    'visible' => '$data->isAllowed(false)'
                ),
                'delete' => array(
                    'label' => 'Excluir',
                    'url' => 'Yii::app()->createUrl("atas/delete", array("id"=>$data->ATA_IDATA))',
                ),
            ),
        ),
    ),
));