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


<?php
$form = $this->beginWidget('bootstrap.widgets.FTbActiveForm', array(
            'id' => 'geomarket-form',
            'enableAjaxValidation' => false,
        ));


$this->widget('bootstrap.widgets.TbAlert');


echo $form->textFieldRow($model, 'name', array('size' => 60, 'maxlength' => 255));

echo $form->textFieldRow($model, 'activation_period') . " " . yii::t('default', 'Month(s)');

echo $form->textFieldRow($model, 'non_manager_meals') . " " . yii::t('default', 'Meal(s)');

echo $form->textFieldRow($model, 'manager_meals') . " " . yii::t('default', 'Meal(s)');

echo $form->textFieldRow($model, 'food_manager_meals') . " " . yii::t('default', 'Meal(s)');

if ($model->isNewRecord)
{
    $model->allow_reassign = 1;
    $model->notify_before_badge_expire = 1;
    $model->status = 'Active';
}

echo $form->radioButtonListInlineRow($model, 'allow_reassign', array('1' => Yii::t('default', 'Yes'), '0' => Yii::t('default', 'No')));

echo $form->radioButtonListInlineRow($model, 'notify_before_badge_expire', array('1' => Yii::t('default', 'Yes'), '0' => Yii::t('default', 'No')), array(
    'onchange' => 'manage_notify_days_visibility()',
));

if ($model->notify_before_badge_expire == 1)
{
    echo $form->textFieldRow($model, 'start_notify_from_x_days_before_expiry') . " " . yii::t('default', 'Day(s)');
}
else
{
    echo $form->textFieldRow($model, 'start_notify_from_x_days_before_expiry', array('disabled' => 'disabled')) . " " . yii::t('default', 'Day(s)');
}

echo $form->radioButtonListInlineRow($model, 'status', array('Active' => Yii::t('default', 'Active'), 'Inactive' => Yii::t('default', 'Inactive')));
?>

<div class="actions">
<?php echo CHtml::submitButton(Yii::t('default', 'Save'), array('class' => 'btn primary')); ?>
    &ensp;
<?php echo CHtml::link(Yii::t('default', 'Cancel'), array('index'), array('class' => 'btn primary')); ?>
</div>

<?php $this->endWidget(); ?>


<script language="javascript" type="text/javascript">
    
    function manage_notify_days_visibility(){
        //TODO: bug fix
        if($("#BadgeType_notify_before_badge_expire_1").attr('checked')){
            $('#BadgeType_start_notify_from_x_days_before_expiry').attr('disabled','disabled').val('');
        }
        else{
            $('#BadgeType_start_notify_from_x_days_before_expiry').removeAttr('disabled');
        }
    }
</script>
