<?php
/* @var $this PersonController */
/* @var $model Person */
/* @var $form CActiveForm */
?>

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


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



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

echo $form->hiddenField($model, 'name');

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

echo $form->hiddenField($model, 'alias');

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

echo $form->hiddenField($model, 'number');

echo $form->uneditableRow($model, 'type_id');

echo $form->hiddenField($model, 'type_id');

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

echo $form->hiddenField($model, 'mobile');

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

echo $form->uneditableRow($model, 'manager', array('size' => 45, 'maxlength' => 45));

echo $form->hiddenField($model, 'manager');

// Get department list wich user can see it and add the default department if the user doesn't have access to it
$department_list = CHtml::listData(Department::getAllInGeomarket("Active"), 'id', 'name');
$department_id = $model->department_id;
if (isset($department_id) && $department_id != '')
{
    if (!array_key_exists($department_id, $department_list))
    {
        $department_model = Department::model()->model()->findByPk($department_id);
        $department_list[$department_id] = $department_model->name;
    }
}

echo $form->dropDownListRow($model, 'department_id', $department_list, array('empty' => Yii::t('default', 'Select Department')));

if ($model->isNewRecord)
{
    $model->status = 'Active';
    $model->is_manager = 0;
    $model->is_food_manager = 0;
    $model->receive_emails = 1;
}
echo $form->radioButtonListInlineRow($model, 'is_manager', array('1' => Yii::t('default', 'Yes'), '0' => Yii::t('default', 'No')));

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

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

echo $form->dropDownListRow($model, 'status', array('Active' => Yii::t('default', 'Active')
    , 'On Leave' => Yii::t('default', 'On Leave')
    , 'Terminated' => Yii::t('default', 'Terminated')
    , 'Resigned' => Yii::t('default', 'Resigned')
    , 'Transferred' => Yii::t('default', 'Transferred')
    , '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('/person/index'), array('class' => 'btn primary')); ?>
    &ensp;
    <?php
    if (!$model->isNewRecord)
    {
        echo CHtml::link(Yii::t('default', 'Manage POSs'), array('/personPos/create', 'personId' => $model->id), array('class' => 'btn primary')); ?>
        &ensp;
    <?php echo CHtml::link(Yii::t('default', 'Manage Badges'), array('/person/manageBadges', 'id' => $model->id), array('class' => 'btn primary'));
    } ?>
</div>

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