<?php
/* @var $this ItemRequestHeaderController */
/* @var $model ItemRequestHeader */

$this->breadcrumbs = array(
    yii::t('default', 'Requests') => array('/dashboard/requests'),
    yii::t('default', 'Items') => array('index'),
);


?>

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

<?php
    if (Yii::app()->user->checkAccess('System Admin') || Yii::app()->user->checkAccess('Super Admin') || Yii::app()->user->checkAccess('Facility Admin') || (User::model()->checkFoodManagerUser()))
	echo CHtml::link(Yii::t('default', 'Add'), array('create'), array('class' => 'btn btn-primary'));?>
     &nbsp;
     <?php
    $this->widget('bootstrap.widgets.TbButtonGroup', array(
    'type' => 'primary',
    'buttons' => array(
        array('label' => Yii::t('default', 'Export'),  'url' => array('exportToExcel')),
    ),
));
    $this->widget('ext.bootstrap.widgets.TbGridView', array(
	'id' => 'item-request-header-grid',
	'type' => 'striped',
	'dataProvider' => $model->search(),
	'filter' => $model,
	'columns' => array(
	    'id',
	    array(
		'name' => 'user_id',
		'value' => '$data->user->identifier',
		'filter' => CHtml::listData(User::getAll(), 'id', 'identifier')
	    ),
	    array(
		'name' => 'location_id',
		'value' => '$data->location->code',
		'filter' => CHtml::listData(Location::getAll(), 'id', 'code')
	    ),
	    array(
		'name' => 'department_id',
		'value' => '$data->department->name',
		'filter' => CHtml::listData(Department::getAll(), 'id', 'name')
	    ),	    
	    'date_time',
	    array(
		'name' => 'cancelled',
		'value' => '$data->cancelled==1?yii::t("default", "Yes"):yii::t("default", "No")',
		'filter' => array('1' => Yii::t('default', 'Yes'), '0' => Yii::t('default', 'No')),
	    ),
	    array(
		'class' => 'CButtonColumn',
		'htmlOptions' => array('width' => '30'),
		'template' => '{view} {Cancel} {Activate}',
		'buttons' => array(
		    'view' => array(
			'url' => 'array("/itemRequestHeader/view","id"=>$data->id)',
		    ),
		    'Cancel' => array
			(
			'imageUrl' => Yii::app()->request->baseUrl . '/css/flags/cancel_ticket.png',
			'url' => 'array("/itemRequestHeader/cancelled","id"=>$data->id)',
			'visible' => '$data->cancelled==0 && (Yii::app()->user->checkAccess("System Admin") || Yii::app()->user->checkAccess("Super Admin"))',
			'click' => "function(){
                            return confirm('" . Yii::t("default", "Are you sure you want to cancel this item?") . "');}
                          ",
		    ),
		    'Activate' => array
			(
			'imageUrl' => Yii::app()->request->baseUrl . '/css/flags/reactivate_ticket.png',
			'url' => 'array("/itemRequestHeader/cancelled","id"=>$data->id)',
			'visible' => '$data->cancelled==1 && (Yii::app()->user->checkAccess("System Admin") || Yii::app()->user->checkAccess("Super Admin"))',
			'click' => "function(){
                            return confirm('" . Yii::t("default", "Are you sure you want to activate this item?") . "');}
                          ",
		    ),
		)
	    ),
	    array(
                'class' => 'application.extensions.Grid.WhRelationalColumn',
               // 'name' => 'Details',
		'filter'=>'',
                'url' => $this->createUrl('itemRequestHeader/ViewItemRequestHeaderDetail'),
                'value' => Yii::t('default', '"Details"'),               
		//'htmlOptions' => array('style'=>'background-color:white !important'),
            ),
	),
    )); ?>
