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

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


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

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

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

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

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

$managers = array_values(Person::getArrayOfManagers('Active'));
$form->widget('zii.widgets.jui.CJuiAutoComplete', array(
    'model' => $model,
    'attribute' => 'manager',
    'source' => $managers,
    'options' => array(
        'minLength' => '0',
    ),));

echo $form->dropDownListRow($model, 'type_id', CHtml::listData(PersonType::getAllNonLDAP("Active"), 'id', 'name'), array('empty' => Yii::t('default', 'Select Person Type')));

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

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


if ($model->isNewRecord)
{
    $model->status = 'Active';
    $model->is_manager = 0;
    $model->is_food_manager = 0;
    $model->receive_emails = 1;
}

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(); ?>