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


$form = $this->beginWidget('ext.PlGrid.PlActiveForm', array(
    'id' => 'gateway-form',
    'gridId' => 'gateway-grid',
    "onValidationError" => '$("#gateway-grid_Modal_saveBtn").button("reset");
                            $("#Gateway_hasAdditionalData").trigger("change");
                           ',
    'action' => $model->isNewRecord ? array('create') : array(),
        ));


$this->widget('bootstrap.widgets.TbTabs', array(
    //'type' => 'tabs', // Menu type. Valid values are tabs, pills and list.
    'tabs' => $this->getTabularFormTabs($form, $model),
    'htmlOptions' => array('data-translation-target' => 'GATEWAY_TAB_MENU_HEADER_TRANSLATION'),
));

if (Yii::app()->user->translateMode) {
    echo '<div id="translationTags">';
    
    echo '<i data-translation-target ="AUTHNAME_ATTRIBUTE" data-translation-id="AUTHNAME_IS_UNIQUE_ERROR_MESSAGE"></i>';
    echo '<i data-translation-target="GATEWAY_MODEL_INBOUND_BLACKLIST_ID_TARGET" data-translation-id="CHOOSE_BLACKLIST"></i>';
    echo '<i data-translation-target="GATEWAY_MODEL_INBOUND_BLACKLIST_ID_TARGET" data-translation-id="CHOOSE_WHITELIST"></i>';
    echo '<i data-translation-target="GATEWAY_MODEL_INBOUND_BLACKLIST_ID_TARGET" data-translation-id="GATEWAY_MODEL_INBOUND_BLACKLIST_ID"></i>';
    echo '<i data-translation-target="GATEWAY_MODEL_OUTBOUND_BLACKLIST_ID_TARGET" data-translation-id="CHOOSE_BLACKLIST"></i>';
    echo '<i data-translation-target="GATEWAY_MODEL_OUTBOUND_BLACKLIST_ID_TARGET" data-translation-id="CHOOSE_WHITELIST"></i>';
    echo '<i data-translation-target="GATEWAY_MODEL_OUTBOUND_BLACKLIST_ID_TARGET" data-translation-id="GATEWAY_MODEL_OUTBOUND_BLACKLIST_ID"></i>';

    echo '<i data-translation-target="GATEWAY_TAB_MENU_HEADER_TRANSLATION" data-translation-id="GATEWAY_MODEL_TAB_MENU_GENERAL_DATA"></i>';
    echo '<i data-translation-target="GATEWAY_TAB_MENU_HEADER_TRANSLATION" data-translation-id="GATEWAY_MODEL_TAB_MENU_LIMITATIONS"></i>';
    echo '<i data-translation-target="GATEWAY_TAB_MENU_HEADER_TRANSLATION" data-translation-id="GATEWAY_MODEL_TAB_MENU_ADDITIONAL_DATA"></i>';

    echo '<i data-translation-target="GATEWAY_FORM_NAME" data-translation-id="GATEWAY_MODEL_NAME"></i>';
    echo '<i data-translation-target="GATEWAY_FORM_NAME" data-translation-id="GATEWAY_MODEL_SHOULD_ONLY_CONTAIN_ALPHANUMERIC_CHARACTERS_ERROR_MESSAGE"></i>';

    echo '<i data-translation-target="GATEWAY_MODEL_PROVIDER_TEMPLATE_TRANSLATION" data-translation-id="GATEWAY_MODEL_PROVIDER_TEMPLATE"></i>';
    echo '<i data-translation-target="GATEWAY_MODEL_PROVIDER_TEMPLATE_TRANSLATION" data-translation-id="GATEWAY_MODEL_PROVIDER_TEMPLATE_EMPTY"></i>';
    echo '<i data-translation-target="GATEWAY_MODEL_PROVIDER_TEMPLATE_TRANSLATION" data-translation-id="GLOBAL_COUNTRY_NAME_DE"></i>';
    echo '<i data-translation-target="GATEWAY_MODEL_PROVIDER_TEMPLATE_TRANSLATION" data-translation-id="GLOBAL_COUNTRY_NAME_FR"></i>';
    echo '<i data-translation-target="GATEWAY_MODEL_PROVIDER_TEMPLATE_TRANSLATION" data-translation-id="GLOBAL_COUNTRY_NAME_NL"></i>';

    echo '<i data-translation-target="INTL_PREFIX_ATTRIBUTE" data-translation-id="GATEWAY_MODEL_INTL_PREFIX"></i>';

    $modes = array(T38Mode::NONE, T38Mode::SELF, T38Mode::PEER, T38Mode::PASSTHROUGH);
    foreach ($modes as $t38Mode) {
        echo '<i data-translation-target="T_38_MODE_ATTRIBUTE" data-translation-id="' . T38Mode::getHumanReadable($t38Mode, false) . '"></i>';
    }

    $cid_headers = array_keys($model->cidTypeListData());
    foreach ($cid_headers as $cid_header) {
        echo CHtml::tag("i", array(
            "data-translation-id" => CIDType::getHumanReadable($cid_header, false),
            "data-translation-target" => "GATEWAY_MODEL_SIP_CID_TYPE_TRANSLATION_TARGET"
        ));
    }
    
    $number_formats = array_keys($model->numberFormatListData());
    foreach ($number_formats as $number_format) {
        echo CHtml::tag("i", array(
            "data-translation-id" => NumberFormat::getHumanReadable($number_format, false),
            "data-translation-target" => "GATEWAY_MODEL_NUMBER_FORMAT_CID_TRANSLATION_TARGET"
        ));
        echo CHtml::tag("i", array(
            "data-translation-id" => NumberFormat::getHumanReadable($number_format, false),
            "data-translation-target" => "GATEWAY_MODEL_NUMBER_FORMAT_TARGET_TRANSLATION_TARGET"
        ));
    }

    $did_headers = array_keys($model->didHeaderListData());
    foreach ($did_headers as $did_header) {
        echo CHtml::tag("i", array(
            "data-translation-id" => SIPHeader::getHumanReadable($did_header, false),
            "data-translation-target" => "GATEWAY_MODEL_DID_HEADER_TRANSLATION_TARGET"
        )
        );
    }
    
    $clirModes = array_keys($model->clirModeListData());
    foreach ($clirModes as $clirMode) {
        echo CHtml::tag("i", array(
            "data-translation-id" => CLIRMode::getHumanReadable($clirMode, false),
            "data-translation-target" => "GATEWAY_MODEL_CLIR_MODE_TRANSLATION_TARGET"
        )
        );
    }
    $cidHeaders = array_keys($model->cidHeaderListData());
    foreach ($cidHeaders as $cidHeader) {
        echo CHtml::tag("i", array(
            "data-translation-id" => SIPHeader::getHumanReadable($cidHeader, false),
            "data-translation-target" => "GATEWAY_MODEL_CID_HEADER_INBOUND_TRANSLATION_TARGET"
        )
        );
    }    
    echo "</div>"; // close translationTags div
}

echo $form->errorSummary($model);
$this->endWidget();
