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

$this->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'))
);

function cssInativo($cliente, $situacao, $row) {
    $return = ($row%2 == 0 ? 'even' : 'odd');
    if ($cliente->countTitulosPendentes() > 0 || $situacao == 'I')
        $return .= ' row-red';
    return $return;
}
?>

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

<?php
if (isset($_GET['busca_telefonista'])) {
    $this->widget('ext.Utils.widgets.CrmGridView', array(
        'id' => 'admin-grid',
        'dataProvider' => $model->search(),
        'afterAjaxUpdate'=>'updated',
        'selectableRows' => 1,
        'pager' => Util::getPagerDefaultConfig(),
        'rowCssClassExpression' => 'cssInativo($data, $data->CLI_SITUACAO, $row)',
        'columns' => array(
            array(
                'name' => 'CLI_NOME',
                'value' => 'Util::getNomeImplantacao($data->CLI_NOME, $data->CLI_IMPLANTACAO) . Util::getPendencias($data, true)',
                'type' => 'raw',
            ),
            array(
                'name' => 'CLI_IDREVENDA',
                'value' => 'GxHtml::valueEx($data->getRevendaResponsavel2())',
            ),
            array(
                'name' => 'CLI_CIDADE',
                'value' => 'GxHtml::valueEx($data->Cidade)',
            ),
            'CLI_FONE1',
            array(
                'name' => 'CLI_SITUACAO',
                'value' => 'Util::getStatusCliente($data->CLI_SITUACAO)',
            ),
            array(
                'name' => 'CLI_PENDENCIAS',
                'value' => 'Util::getPendencias($data)',
            ),
        ),
    ));
}