<?php
cs()->registerScriptFile(Yii::app()->baseUrl . '/js/vmAnnouncementVisibility/vmAnnouncementVisibility.js', CClientScript::POS_HEAD);

echo $form->textFieldRow($model, 'name', array(
    'class' => 'span3',
    'maxlength' => 40,
    'data-translation-id' => 'USERGROUPS_MODEL_NAME',
));

if (cfg('DP_BRANCH_PREFIX')) {

    echo $form->textFieldRow($model, 'extension', array(
        'prepend' => cfg('DP_BRANCH_PREFIX'),
        'class' => 'span3',
        'style' => 'width: 179px;',
        'maxlength' => 40,
        'data-translation-id' => 'USERGROUPS_MODEL_EXTENSION',
    ));
} else {
    echo $form->textFieldRow($model, 'extension', array(
        'class' => 'span3',
        'maxlength' => 40,
        'data-translation-id' => 'USERGROUPS_MODEL_EXTENSION',
    ));
}

echo CHtml::activeHiddenField($model, 'type', array(
    'class' => 'span3',
    'maxlength' => 40,
    'data-translation-id' => 'USERGROUPS_MODEL_NAME',
));

if ($model->parent != '0') {
    echo $form->dropDownListRow($model, 'parent', $model->getNestedGroupList($model->id), array(
        'class' => 'span3',
        'data-translation-id' => 'USERGROUPS_MODEL_PARENT',
    ));
}

$data = $model->getMusicOnHoldListData();
$htmlOptions = array(
    'class' => 'span3',
    'maxlength' => 40,
    'data-translation-id' => 'USERGROUPS_MODEL_PLAYLIST_ID',);

echo $form->dropDownListRow($model, 'playlistId', $data, $htmlOptions);

$targetList = $model->getTargetList();
$selectedValue = $model->getSelectedValueForAttributes('target_type_on_timeout', 'target_on_timeout');
echo $form->dropDownListRow($model, 'target_on_timeout', $targetList, array(
    'class' => 'span3',
    'data-translation-id' => 'USERGROUPS_MODEL_TARGET_ON_TIMEOUT',
    'data-translation-target' => 'TARGET_ON_TIMEOUT_DROPDOWN',
    'options' => array(
        $selectedValue => array('selected' => true)
    )
        )
);

$announcementFileList = Queue::getAnnouncementFileList();
echo $form->dropDownListRow($model, 'target_on_timeout_meta', $announcementFileList, array(
    'class' => 'span3',
    'data-translation-id' => 'USERGROUPS_MODEL_TARGET_ON_TIMEOUT_META',
        )
);


$selectedValue = $model->getSelectedValueForAttributes('target_type_on_busy', 'target_on_busy');
echo $form->dropDownListRow($model, 'target_on_busy', $targetList, array(
    'class' => 'span3',
    'data-translation-id' => 'USERGROUPS_MODEL_TARGET_ON_BUSY',
    'data-translation-target' => 'TARGET_ON_BUSY_DROPDOWN',
    'options' => array(
        $selectedValue => array('selected' => true)
    )
        )
);

echo $form->dropDownListRow($model, 'target_on_busy_meta', $announcementFileList, array(
    'class' => 'span3',
    'data-translation-id' => 'USERGROUPS_MODEL_TARGET_ON_BUSY_META',
        )
);


$selectedValue = $model->getSelectedValueForAttributes('target_type_on_nightcircut', 'target_on_nightcircut');
echo $form->dropDownListRow($model, 'target_on_nightcircut', $targetList, array(
    'class' => 'span3',
    'data-translation-id' => 'USERGROUPS_MODEL_TARGET_ON_NIGHTCIRCUT',
    'data-translation-target' => 'TARGET_ON_NIGHTCIRCUT_DROPDOWN',
    'options' => array(
        $selectedValue => array('selected' => true)
    )
        )
);

echo $form->dropDownListRow($model, 'target_on_nightcircut_meta', $announcementFileList, array(
    'class' => 'span3',
    'data-translation-id' => 'USERGROUPS_MODEL_TARGET_ON_NIGHTCIRCUT_META',
        )
);


echo $form->checkBoxRow($model, 'night_circut', array(
    'data-translation-id' => 'USERGROUPS_MODEL_NIGHT_CIRCUT',
));
?>
<script>
    $(function () {
        var modelName = 'Groups';
        var metaList = [
            'target_on_timeout',
            'target_on_busy',
            'target_on_nightcircut'
        ];
        new $.vmAnnouncementVisibility(modelName, metaList);
    });
</script>
