<?php
$this->PageTitle = 'contratos-itens';

if (User::getUser()->USR_PRM_UPDATE == 1) {
	$botoes = '{view} {update}';
} else {
	$botoes = '{view}';
}

if (User::getUser()->USR_PRM_PRIVILEGIO == 1) {
	$botoes .= ' {delete}';
}

if(User::getUser()->USR_PRM_INCLUIR == 1 ) {
	$imagem = FaHtml::iconNovo();
} else {
	$imagem = 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
$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(
		'CTI_ID',
		array(
			'name'=>'CTI_IDCONTRATO',
			'value'=>'GxHtml::valueEx($data->Contrato)',
		),
		array(
			'name'=>'CTI_IDPRODUTO',
			'value'=>'GxHtml::valueEx($data->Modulo)',
		),
		'CTI_QUANTIDADE',
		'CTI_VLRMENSAL',
		'CTI_VLRIMPLANTACAO',
		array(
			'class' => 'CButtonColumn',
			'template'=>$botoes,
			'viewButtonOptions'=>array('target'=>'_blank'),
			'updateButtonOptions'=>array('target'=>'_blank'),
			'buttons'=>array(
				'view' => array(
					'label'=>'Exibir',
					'url'=>'Yii::app()->createUrl("contratosItens/view", array("id"=>$data->CTI_ID))',
				),
				'update' => array(
					'label'=>'Editar',
					'url'=>'Yii::app()->createUrl("contratosItens/update", array("id"=>$data->CTI_ID))',
				),
				'delete' => array(
					'label'=>'Excluir',
					'url'=>'Yii::app()->createUrl("contratosItens/delete", array("id"=>$data->CTI_ID))',
				),
			),			
		),
	),
));