<?php
$this->PageTitle = 'Financeiro &raquo; Documentos para assinar digitalmente';

if(empty($model->TOKEN)) {
    $model->TOKEN = Util::uid();
}
$menus = array();
$menus[] = array('label' => FaHtml::iconSetaClose(), 'url' => '#', 'linkOptions' => array('class' => 'search-button'));
$menus[] = array('label' => FaHtml::iconRefresh(), 'url' => 'javascript:void(0);', 'linkOptions' => array('onclick' => 'reloadFrame();', 'class' => 'refresh-button'));

$this->menu = $menus;

$dataProvider = $model->search(); 

?>
<div class="search-form" <?php if($dataProvider->totalItemCount > 0) echo 'style="display: none;"'; ?> >
	<?php $this->renderPartial('/contratos/_search', array('model' => $model)); ?>
</div>

<?php $this->widget('ext.Utils.widgets.CrmGridView', array(
	'id' => 'admin-grid',
	'dataProvider' => $dataProvider,
	'afterAjaxUpdate'=>'updated',
	'pager' => Util::getPagerDefaultConfig(),
	'columns' => array(
		'COT_IDCONTRATO',
		array(
            'name' => 'COT_SITUACAO',
            'value' => 'Util::getTipoDocumento($data->COT_SITUACAO) . ($data->COT_SITUACAO == Contratos::ADENDO && !empty($data->COT_IDSERVICO) ? " - " . $data->Servico : "").$data->getIconAssinatura()',
            'type' => 'raw'
        ),
		'COT_DTCADASTRO',
		'COT_CLI_NOME',
		'COT_CLI_CNPJCPF',
        'Revenda',
        array(
			'name' => 'ValorNegociado',
			'value' => '$data->getValorNegociado()',
			),
        'Status',
		array(
			'class' => 'CButtonColumn',
			'template'=>'{view} {anexar} {PDF}',
			'buttons'=>array(
				'view' => array(
                    'label' => 'Exibir',
                    'url' => 'Yii::app()->createUrl("contratos/view", array("id"=>$data->COT_IDCONTRATO))',
                    'options' => array('target' => '_blank'),
                ),
                'anexar' => array(
                    'label' => 'Anexar',
                    'imageUrl' => FaHtml::getImgUrl('ico-attach.png'),
                    'url' => 'Yii::app()->createUrl("contratos/anexar", array("id"=>$data->COT_IDCONTRATO))',
                    'options' => array('target' => '_blank'),
                ),
                'PDF' => array(
                    'label' => 'Gerar PDF',
                    'imageUrl' => FaHtml::getImgUrl('ico-pdf.png'),
                    'url' => 'Yii::app()->createUrl("contratos/GerarCopiaAssinadaDigitalmente", array("id"=>$data->COT_IDCONTRATO))',
                    'options' => array('target' => '_blank'),
                    'visible' => '$data->mostrarCopiaDigitalAssinada()'
                ),
			),			
		),
	),
));