<?php
$this->PageTitle = 'Condições de Pagamento';

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

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

$imagem = (User::canCreate() ) ? 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')),
);
?>

<?php
$dataProvider = $model->search();
?>
<div class="search-form" style="display:<?php echo ($dataProvider->totalItemCount > 0) ? 'none' : 'block'; ?>" >
<?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',
	'selectableRows'=>1,
	'pager' => Util::getPagerDefaultConfig(),
	'columns' => array(
		'COD_DESCRICAO',
		array(
			'name' => 'COD_SITUACAO',
			'value' => '$data->COD_SITUACAO == "A" ? "Ativo" : "Inativo"',
		),
		array(
			'class' => 'CButtonColumn',
			'template'=>$botoes,
			'viewButtonOptions'=>array('target'=>'_blank'),
			'updateButtonOptions'=>array('target'=>'_blank'),
			'buttons'=>array(
				'view' => array(
					'label'=>'Exibir',
					'url'=>'Yii::app()->createUrl("condicaopagto/view", array("id"=>$data->COD_IDCONDPAGTO))',
				),
				'update' => array(
					'label'=>'Editar',
					'url'=>'Yii::app()->createUrl("condicaopagto/update", array("id"=>$data->COD_IDCONDPAGTO))',
				),
				'delete' => array(
					'label'=>'Excluir',
					'url'=>'Yii::app()->createUrl("condicaopagto/delete", array("id"=>$data->COD_IDCONDPAGTO))',
				),
			),			
		),
	),
));