<?php
/* @var $this BadgeAssignmentRuleController */
/* @var $model BadgeAssignmentRule */

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

<?php echo CHtml::link(Yii::t('default', 'Add'), array('create'), array('class' => 'btn btn-primary', 'data-dismiss' => 'modal')); ?>
&nbsp;
<div id="flash-msg">
    <br>
<?php $this->widget('bootstrap.widgets.TbAlert'); ?>
</div>


<?php
$this->widget('ext.bootstrap.widgets.TbGridView', array(
    'id' => 'badge-assignment-rule-grid',
    'type' => 'striped',
    'dataProvider' => $model->search(),
    'filter' => $model,
    'columns' => array(
        array(
            'name' => 'person_type_id',
            'value' => '$data->personType->name',
            'filter' => CHtml::listData(PersonType::getAll(), 'id', 'name')
        ),
        array(
            'name' => 'badge_type_id',
            'value' => '$data->badgeType->name',
            'filter' => CHtml::listData(BadgeType::getAll(), 'id', 'name')
        ),
        array(
            'header' => Yii::t("default", "Manager Condition"),
            'name' => 'only_manager',
            'value' => '($data->only_manager == 1) ?  Yii::t("default","Required") : Yii::t("default","Not required")',
            'filter' => array('0' => Yii::t("default", "Not required"), '1' => Yii::t("default", "Required")),
        ),
        array(
            'header' => Yii::t("default", "Food Manager Condition"),
            'name' => 'only_food_manager',
            'value' => '($data->only_food_manager == 1) ?  Yii::t("default","Required") : Yii::t("default","Not required")',
            'filter' => array('0' => Yii::t("default", "Not required"), '1' => Yii::t("default", "Required")),
        ),
        array(
            'name' => 'no_limit_on_badges_number',
            'value' => '($data->no_limit_on_badges_number == 0) ?  Yii::t("default","Yes") : Yii::t("default","No")',
            'filter' => array('0' => Yii::t('default', 'Yes'), '1' => Yii::t('default', 'No')),
        ),
        'max_badges_allowed',
        array(
            'class' => 'CButtonColumn',
            'htmlOptions' => array('width' => '60'),
            'afterDelete' => 'function(link,success,data){ if(success) $("#flash-msg").html(data); }',
        ),
    ),
));
?>
