<style>
    #tid-status-grid {
        width: auto !important;
    }

    #flash-msg-inner .alert {
        width: 1065px !important;
    }
</style>

<?php echo CHtml::link(Yii::t('default', 'Export'), array('tid/ExportToExcelStatusInfo', 'tid_id' => $tid_id), array('class' => 'btn btn-success')); ?>
<div id="flash-msg-inner">
    <br>
    <?php $this->widget('bootstrap.widgets.TbAlert'); ?>
</div>
<?php
$this->widget('yiiwheels.widgets.grid.WhGridView', array(
    'id' => 'tid-status-grid',
    'ajaxUrl' => Yii::app()->createAbsoluteUrl('tid/viewStatus', array("id" => $tid_id)),
    'dataProvider' => $model->search($tid_id),
    'filter' => $model,
    'columns' => array(
        array(
            'name' => 'ti_type_id',
            'value' => '($data->tiType != null) ? $data->tiType->name : ""',
            'filter' => TiType::getNamesForView()
        ),
        array(
            'name' => 'contract_id',
            'value' => '($data->contract != null) ?$data->contract->reference: ""',
            'filter' => Contract::getNamesForView()
        ),
        array(
            'name' => 'contract_expiry_date',
            'value' => '($data->contract != null) ?$data->contract->expiry_date: ""'
        ),
        'ti_issue_date',
         array(
            'name' => 'ti_expiry_date',
            'value' => '($data->ti_expiry_date != "0000-00-00") ?$data->ti_expiry_date: ""',            
        ),        
        array(
            'name' => 'cca_id',
            'value' => '($data->cca != null) ?$data->cca->full_name: ""',
            'filter' => Cca::getNamesForView()
        ),
        array(
            'name' => 'ti_status',
            'value' => '$data->ti_status',
            'filter' => TidStatus::getStatusOptions()
        ),
        //'comments',
        array(
            'name' => 'under_processing',
            'value' => '($data->under_processing == null) ? "" : $data->under_processing',
            'filter' => array('Yes' => Yii::t('default', 'Yes'), 'No' => Yii::t('default', 'No'))
        ),
        array(
            'name' => 'renewal_stage_id',
            'value' => '($data->renewal_stage_id != null) ? $data->renewalStage->name : ""',
            'filter' => RenewalStage::getNamesForView()
        ),
        array(
            'class' => 'CButtonColumn',
            'template' => '{update} {delete}',
            'afterDelete' => 'function(link,success,data){ 
                    
                    if(success) {
                        if(data.indexOf("refresh") != -1){
                       
                            var results = data.split("@");                             
                            $("#flash-msg-inner").html(results[1]); 
                            window.location.reload();                             
                        }
                        else
                            $("#flash-msg-inner").html(data); 
                        }
                }',
            'buttons' => array(
                'delete' => array
                    (
                    'url' => 'Yii::app()->createAbsoluteUrl("tid/deleteStatus", array("id" => $data->id,"tid_id"=>$data->tid_id))',
                    'visible' => '!Yii::app()->user->isGuest && Yii::app()->user->checkAccess(User::SYSTEM_ADMIN_ROLE)',
                ),
                'update' => array
                    (
                    'url' => 'Yii::app()->createAbsoluteUrl("tid/editStatus", array("id" => $data->id,"tid_id"=>$data->tid_id))',
		    'visible' => '!Yii::app()->user->isGuest'

                ),
            ),
        ),
    ),
));
?>
