<style>
    span.required {
	color: #eee!important;
    }

    .red-star {
	color: #eee!important;
	display: none;
    }
</style>
<?php
/* @var $this TidController */
/* @var $model Tid */
$this->breadcrumbs = array(
    yii::t('default', 'TIDs Management') => array('dashboardLayout/tids'),
    yii::t('default', 'Invoices') => array('index'),
);


Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
	$('.search-form').toggle();
	return false;
});
$('.search-form form').submit(function(){
	$('#invoice-grid').yiiGridView('update', {
		data: $(this).serialize()
	});
	return false;
});
");
?>


<?php
if (!Yii::app()->user->isGuest)
    echo CHtml::link(Yii::t('default', 'Add'), array('create'), array('class' => 'btn btn-primary', 'data-dismiss' => 'modal')); ?>
&nbsp;
<?php
echo TbHtml::buttonDropdown('Export', array(
    array('label' => 'Invoices Summary', 'url' => array('summaryExportToExcel', 'tid_id' => $tid_id)),
    array('label' => 'Invoices Detailed', 'url' => array('detailExportToExcel', 'tid_id' => $tid_id)),
	), array('class' => 'btn btn-success')
);
?>

&nbsp;
<?php echo CHtml::link('Advanced Search', '#', array('class' => 'search-button btn')); ?>
<div class="search-form" style="display:none">
    <?php
    $this->renderPartial('_search', array(
	'model' => $model,
    ));
    ?>
</div><!-- search-form -->


<div id="flash-msg">
    <br>
    <?php $this->widget('bootstrap.widgets.TbAlert'); ?>
</div>


<?php
    $this->widget('yiiwheels.widgets.grid.WhGridView', array(
	'id' => 'invoice-grid',
	'dataProvider' => $model->search($tid_id),
	'filter' => $model,
	'columns' => array(
	    array(
		'type' => 'html',
		'name' => 'tid_id',
		'value' => 'CHtml::link($data->tid->tid_no, array("/tid/view", "id" => $data->tid_id))',
	    //'filter' => Tid::getNumberForView(),
	    ),
	    array(
		'type' => 'html',
		'name' => 'number',
		'value' => 'CHtml::link($data->number, array("/invoice/view", "id" => $data->id))',
	    ),
	    'value',
	    'description',
	    'comments',
	    array(
		'class' => 'CButtonColumn',
		'htmlOptions' => array('width' => '60'),
		'template' => '{update} {delete} {add_asset}',
		'afterDelete' => 'function(link,success,data){ if(success) $("#flash-msg").html(data); }',
		'buttons' => array(
		    'delete' => array(
			'visible' => 'Yii::app()->user->checkAccess(User::SYSTEM_ADMIN_ROLE)',
		    ),
		    'update' => array(
			'visible' => '!Yii::app()->user->isGuest'
		    ),
		    'add_asset' => array(
			'label' => Yii::t('default', 'Add New Asset'),
			'url' => 'array("asset/create","invoice_id"=>$data->id,"tid_id"=>$data->tid_id)',
			'imageUrl' => Yii::app()->request->baseUrl . '/css/flags/add_asset.png',
			'visible' => '!Yii::app()->user->isGuest'
		    ),
		    'manage_asset' => array(
			'label' => Yii::t('default', 'Add New Asset'),
			'url' => 'array("asset/index","invoice_id"=>$data->id)',
			'imageUrl' => Yii::app()->request->baseUrl . '/css/flags/manage.png',
			'visible' => '!Yii::app()->user->isGuest'
		    ),
		),
	    ),
	),
    ));
?>
