<?php
 /* @var $this BadgeTypeController */
 /* @var $model BadgeType */

 $this->breadcrumbs = array(
     yii::t('default', 'Configurations') => array('/dashboard/configuration'),
     Yii::t('default', 'Badge Types') => array('index'),
 );



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

<?php
 if ((Yii::app()->user->checkAccess('Facility Admin')) == false)
 {
     echo CHtml::link(Yii::t('default', 'Add'), array('create'), array('class' => 'btn btn-primary', 'data-dismiss' => 'modal'));
 }
?>
&nbsp;
<?php echo CHtml::link(Yii::t('default', 'Advance 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('ext.bootstrap.widgets.TbGridView', array(
         'id' => 'badge-type-grid',
         'type' => 'striped',
         'dataProvider' => $model->search(),
         'filter' => $model,
         'columns' => array(
             'name',
             array(
                 'name' => 'activation_period',
                 'value' => '$data->activation_period.\' \'.($data->activation_period > 1 ? "Months" : "Month")'
             ),
             array(
                 'name' => 'non_manager_meals',
                 'value' => '$data->non_manager_meals.\' \'.($data->non_manager_meals > 1 ? "Meals" : "Meal")'
             ),
             array(
                 'name' => 'manager_meals',
                 'value' => '$data->manager_meals.\' \'.($data->manager_meals > 1 ? "Meals" : "Meal")'
             ),
             array(
                 'name' => 'status',
                 'type' => 'html',
                 'value' => 'CHtml::link(CHtml::image(Yii::app()->request->baseUrl."/css/flags/".$data->status.".png", "img")  ,"#",array("rel"=>"tooltip","title"=>Yii::t(\'default\',$data->status)))',
                 'filter' => array('Active' => Yii::t('default', 'Active'), 'Inactive' => Yii::t('default', 'Inactive')),
                 'htmlOptions' => array('style' => 'text-align:center;'),
             ),
             array(
                 'class' => 'CButtonColumn',
                 'htmlOptions' => array('width' => '60'),
                 'afterDelete' => 'function(link,success,data){ if(success) $("#flash-msg").html(data); }',
                 'buttons' => array(
                     'update' => array(
                         'visible' => 'Yii::app()->user->checkAccess("Facility Admin")? false:true',
                     ),
                     'delete' => array(
                         'visible' => 'Yii::app()->user->checkAccess("Facility Admin")? false:true',
                     ),
                 ),
             ),
         ),
     ));
?>
