<?php
$this->PageTitle = 'clientes-documentos-fiscais';

$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')),
	array('label' => FaHtml::iconRefresh(), 'url' => 'javascript:void(0);', 'linkOptions' => array('onclick' => 'reloadFrame();', 'class' => 'refresh-button')),
);
?>
<?php
?>
<div class="search-form" style="display:<?php echo (count($_GET) > 1) ? 'none' : 'block'; ?>" >
<?php $this->renderPartial('_search', array(
	'model' => $model,
)); ?>
</div><!-- search-form -->

<?php $this->widget('ext.Utils.widgets.CrmGridView', array(
	'id' => 'admin-grid',
	'dataProvider' => $model->search(),
	'afterAjaxUpdate'=>'updated',
	'pager' => Util::getPagerDefaultConfig(),
	'columns' => array(
		'CDF_CODIGO',
		array(
			'name'=>'CDF_IDCLIENTE',
			'value'=>'GxHtml::valueEx($data->Cliente)',
		),
		array(
			'name'=>'CDF_IDDOCUMENTO',
			'value'=>'GxHtml::valueEx($data->DocumentoFiscal)',
		),
		array(
			'class' => 'CButtonColumn',
			'template'=>$botoes,
			'viewButtonOptions'=>array('target'=>'_blank'),
			'updateButtonOptions'=>array('target'=>'_blank'),
			'buttons'=>array(
				'view' => array(
					'label'=>'Exibir',
					'url'=>'Yii::app()->createUrl("clientes-documentos-fiscais/view", array("id"=>$data->CDF_CODIGO))',
				),
				'update' => array(
					'label'=>'Editar',
					'url'=>'Yii::app()->createUrl("clientes-documentos-fiscais/update", array("id"=>$data->CDF_CODIGO))',
				),
				'delete' => array(
					'label'=>'Excluir',
					'url'=>'Yii::app()->createUrl("clientes-documentos-fiscais/delete", array("id"=>$data->CDF_CODIGO))',
				),
			),			
		),
	),
));