<?php
$this->PageTitle = 'Relatório de Pendências CRM';

$botoes = (User::canUpdate()) ? '{view}' : '{view}';

$menus = array();
if (isset($_GET['busca'])) {
    $menus[] = array('label' => FaHtml::iconExcel(),
                     'url' => array('generateExcel',
                                    'token' => $model->TOKEN),
                     'linkOptions' => array('class' => 'novo exportar'));
}
$menus[] = array('label' => FaHtml::iconSetaClose(), 'url' => '#', 'linkOptions' => array('class' => 'search-button'));
$menus[] = array('label' => FaHtml::iconRefresh(), 'url' => 'javascript:void(0);', 'linkOptions' => array('onclick' => 'reloadFrame();', 'class' => 'refresh-button'));

$this->menu = $menus;

$dataProvider = $model->search();
?>
<div class="search-form" style="display:<?php echo (isset($_GET['relatorio'])) ? 'none' : 'block'; ?>" >
    <?php
    $this->renderPartial('_search_relatorio', array(
        'model' => $model,
    ));
    ?>
</div><!-- search-form -->

<?php
if (isset($_GET['relatorio'])) {
    $this->widget('ext.Utils.widgets.CrmGridView', array(
        'id' => 'admin-grid',
        'dataProvider' => $model->search(),
        'afterAjaxUpdate'=>'updated',
        'pager' => Util::getPagerDefaultConfig(),
        'columns' => array(
            'PEN_IDPENDENCIA',
            'PEN_DATACADASTRO',
            'PEN_DATAENTREGA',
            'PEN_TITULO',
            array(
                'name' => 'PEN_IDFUNCIONARIO',
                'value' => 'GxHtml::valueEx($data->Autor)'
            ),
            array(
                'name' => 'PEN_IDPRIORIDADE',
                'value' => 'GxHtml::valueEx($data->Prioridade)',
            ),
            array(
                'name' => 'PEN_IDMOTIVO',
                'value' => 'GxHtml::valueEx($data->Motivo)',
            ),
            array(
                'name' => 'PEN_IDFORMULARIO',
                'value' => 'GxHtml::valueEx($data->Formulario)',
            ),
            array(
                'name' => 'PEN_IDLOCAL',
                'value' => 'GxHtml::valueEx($data->Local)',
            ),
            array(
                'name' => 'PEN_IDSETOR',
                'value' => 'GxHtml::valueEx($data->Setor)',
            ),
            array(
                'name' => 'PEN_SITUACAO',
                'value' => 'Util::getSituacaoPendencias($data->PEN_SITUACAO)',
            ),
            array(
            'name' => 'PEN_IDPREVISAOVERSAO',
            'value' => '$data->PrevisaoVersao',
            ),
        )
    ));
}