<?php
    $this->PageTitle = 'Relatório de Comissão das Revendas';
    $menu = array();

    $menu = array(
        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'))
    );

    if (isset($_GET['busca'])) {

        $menu = array(

            array('label' => FaHtml::iconExcel(),
                  'url' => array('generateExcel'),
                  'linkOptions' => array('class' => 'novo exportar')),

            array('label' => FaHtml::iconPdf() . ' Exportar PDF',
                  'url' => array('generatePdf'),
                  'linkOptions' => array('class' => 'novo exportarPdf')),

            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'))

        );
    }

    $this->menu = $menu;

?>
<div class="search-form" style="display:<?= (isset($_GET['busca'])) ? 'none' : 'block'; ?>" >
    <?php $this->renderPartial('../titulos/_searchcomissao', array('model' => $model)); ?>
</div>

<?php
    if (isset($_GET['busca'])) {

        $columns = array();

        $columns[] = 'TIT_TITULO';
        $columns[] = 'TIT_SERIE';

        $columns[] = array('name' => 'TIT_IDCLIENTE',
                         'value' => 'GxHtml::valueEx($data->Cliente)');

        $columns[] = array('name' => 'TIT_EMISSAO',
                           'value' => 'Util::formatDataBr($data->TIT_EMISSAO)');
        $columns[] = array('name' => 'TIT_VENCIMENTO',
                           'value' => 'Util::formatDataBr($data->TIT_VENCIMENTO)');
        $columns[] = array('name' => 'TIT_DTPAGAMENTO',
                           'value' => 'Util::formatDataBr($data->TIT_DTPAGAMENTO)');

        $columns[] = array('name' => 'Mensal',
                            'value' => 'Util::verMoeda($data->TIT_VALOR)');

        $columns[] = array('name' => 'Juros',
                            'value' => 'Util::verMoeda($data->TIT_VALORPAGO)');

        $columns[] = array('name' => 'Total',
                            'value' => 'Util::verMoeda($data->TIT_VALOR_TOTAL)');

        $this->widget('ext.Utils.widgets.CrmGridView', array(
            'id' => 'admin-grid',
            'dataProvider' => $dataProvider,
            'afterAjaxUpdate'=>'updated',
            'selectableRows' => 1,
            'pager' => Util::getPagerDefaultConfig(),
            'columns' => $columns,
            'summaryText'     => "Exibindo {start}-{end} de {count} resultado(s) |
                                  <span class='align-left'>Total Geral: ".Util::verMoeda($count)."</span>
                                  | <span class='align-rigth'> Total Comissão: ".Util::verMoeda($countComissao)." </span>",
            )
        );
    }