<?php

#
# XiVO Web-Interface
# Copyright (C) 2006-2016  Avencall
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

$form = &$this->get_module('form');
$url = $this->get_module('url');

$info = $this->get_var('info');
$element = $this->get_var('element');

$context_list = $this->get_var('context_list');

if(isset($info['protocol']) === true):
	if(dwho_issa('allow',$info['protocol']) === true):
		$allow = $info['protocol']['allow'];
	else:
		$allow = array();
	endif;

	$host = (string) dwho_ak('host',$info['protocol'],true);
	$protocol_disable = (bool) dwho_ak('commented',$info['protocol'],true);
else:
	$allow = array();
	$host = '';
	$protocol_disable = false;
endif;

$codec_active = empty($allow) === false;
$host_static = ($host !== '' && $host !== 'dynamic');

if(($reg_active = $this->get_var('info','register','commented')) !== null):
	$reg_active = dwho_bool($reg_active) === false;
endif;

?>
<uib-tabset active="active">
	<uib-tab index="0" heading="<?=$this->bbf('smenu_general');?>">
		<?php
			echo	$form->text(array('desc'	=> $this->bbf('fm_protocol_name'),
							'name'	=> 'protocol[name]',
							'labelid'	=> 'protocol-name',
							'size'	=> 15,
							'default'	=> $element['protocol']['name']['default'],
							'value'	=> $info['protocol']['name'],
							'error'	=> $this->bbf_args('error',
									$this->get_var('error', 'protocol', 'name')) )),

				$form->text(array('desc'	=> $this->bbf('fm_protocol_username'),
							'name'	=> 'protocol[username]',
							'labelid'	=> 'protocol-username',
							'size'	=> 15,
							'default'	=> $element['protocol']['username']['default'],
							'value'	=> $info['protocol']['username'],
							'error'	=> $this->bbf_args('error',
									$this->get_var('error', 'protocol', 'username')) )),

				$form->text(array('desc'	=> $this->bbf('fm_protocol_secret'),
							'name'	=> 'protocol[secret]',
							'labelid'	=> 'protocol-secret',
							'size'	=> 15,
							'default'	=> $element['protocol']['secret']['default'],
							'value'	=> $info['protocol']['secret'],
							'error'	=> $this->bbf_args('error',
									$this->get_var('error', 'protocol', 'secret')) )),

				$form->text(array('desc'	=> $this->bbf('fm_protocol_callerid'),
							'name'	=> 'protocol[callerid]',
							'labelid'	=> 'protocol-callerid',
							'size'	=> 15,
							'notag'	=> false,
							'default'	=> $element['protocol']['callerid']['default'],
							'value'	=> $info['protocol']['callerid'],
							'error'	=> $this->bbf_args('error',
									$this->get_var('error', 'protocol', 'callerid')) )),

				$form->select(array('desc'	=> $this->bbf('fm_protocol_calllimit'),
								'name'	=> 'protocol[call-limit]',
								'labelid'	=> 'protocol-calllimit',
								'key'	=> false,
								'bbf'	=> 'fm_protocol_calllimit-opt',
								'bbfopt'	=> array('argmode' => 'paramvalue'),
								'default'	=> $element['protocol']['call-limit']['default'],
								'selected'	=> $info['protocol']['call-limit']),
								$element['protocol']['call-limit']['value']),

				$form->select(array('desc'	=> $this->bbf('fm_protocol_type'),
								'name'	=> 'protocol[type]',
								'labelid'	=> 'protocol-type',
								'key' => false,
								'bbf'	=> 'fm_protocol_type-opt',
								'bbfopt'	=> array('argmode' => 'paramvalue'),
								'default'	=> $element['protocol']['type']['default'],
								'selected'	=> $info['protocol']['type']),
								$element['protocol']['type']['value'],
								'onchange="xivo_ast_chg_trunk_type(this.value);"'),

				$form->select(array('desc'	=> $this->bbf('fm_protocol_host-type'),
								'name'	=> 'protocol[host-type]',
								'labelid'	=> 'protocol-host-type',
								'key'	=> false,
								'bbf'	=> 'fm_protocol_host-type-opt',
								'bbfopt'	=> array('argmode' => 'paramvalue'),
								'default'	=> $element['protocol']['host']['default'],
								'selected'	=> ($host_static === true ? 'static' : $host)),
								$element['protocol']['host-type']['value'],
								'onchange="xivo_chg_attrib(\'ast_fm_trunk_host\',
									\'fd-protocol-host-static\',
									Number((this.value === \'static\')));"'),

				$form->text(array('desc'	=> '&nbsp;',
							'name'	=> 'protocol[host-static]',
							'labelid'	=> 'protocol-host-static',
							'size'	=> 15,
							'default'	=> $element['protocol']['host-static']['default'],
							'value'	=> ($host_static === true ? $host : ''),
							'error'	=> $this->bbf_args('error',
									$this->get_var('error', 'protocol', 'host-static')) ));

			if($context_list !== false):
				echo	$form->select(array('desc'	=> $this->bbf('fm_protocol_context'),
									'name'	=> 'protocol[context]',
									'labelid'	=> 'protocol-context',
									'empty'	=> true,
									'key'	=> 'identity',
									'altkey'	=> 'name',
									'default'	=> $element['protocol']['context']['default'],
									'selected'	=> $info['protocol']['context']),
									$context_list);
			endif;
?>
<div id="fd-trunkfeatures-mediaserver" class="form-group form-group-sm form-inline ng-scope">
<label class="control-label col-sm-3" id="lb-trunkfeatures-mediaserver" for="it-trunkfeatures-mediaserver"><?=$this->bbf('fm_mediaserver');?></label>
    <div class="col-sm-3">
        <select name="trunkfeatures[mediaserverid]" id="it-trunkfeatures-mediaserver" class="form-control">
            <option ng-repeat="mds in list" value="{{mds.id}}"
                ng-selected="<?=$info['trunkfeatures']['mediaserverid']
                    ? 'mds.id == '.$info['trunkfeatures']['mediaserverid']
                    : 'mds.name == \'' . $element['trunkfeatures']['mediaserver']['default_name'] . '\''
                ?>">{{mds.display_name}}</option>
        </select>
    </div>
</div>
<?php
            echo    $form->select(array('desc'	=> $this->bbf('fm_protocol_language'),
								'name'	=> 'protocol[language]',
								'labelid'	=> 'protocol-language',
								'empty'	=> true,
								'key'	=> false,
								'default'	=> $element['protocol']['language']['default'],
								'selected'	=> $info['protocol']['language']),
								$element['protocol']['language']['value']),

				$form->select(array('desc'	=> $this->bbf('fm_protocol_nat'),
								'name'	=> 'protocol[nat]',
								'labelid'	=> 'protocol-nat',
								'empty'	=> true,
								'key'	=> false,
								'bbf'	=> 'fm_protocol_nat-opt',
								'bbfopt'	=> array('argmode' => 'paramvalue'),
								'default'	=> $element['protocol']['nat']['default'],
								'selected'	=> $info['protocol']['nat']),
								$element['protocol']['nat']['value']);
		?>
	</uib-tab>

	<uib-tab index="1" heading="<?=$this->bbf('smenu_register');?>">
		<?php
			echo	$form->checkbox(array('desc'		=> $this->bbf('fm_register'),
									'name'		=> 'register-active',
									'labelid'		=> 'register-active',
									'checked'		=> $reg_active,
									'disabled'	=> $protocol_disable,
									'error'		=> $this->bbf_args('error',
									$this->get_var('error', 'register')),),
									'onclick="xivo_chg_attrib(\'ast_fm_trunk_register\',
										\'it-register-username\',
										Number((this.checked === false)));"'),

					$form->select(array('desc'  => $this->bbf('fm_register-transport'),
							'name'    => 'register[transport]',
							'labelid' => 'register-transport',
							'key'   => false,
							'help'    => $this->bbf('hlp_fm_register-transport'),
							'selected'  => $info['register']['transport'],
							'default' => $element['register']['transport']['default']),
								$element['register']['transport']['value']),

				$form->text(array('desc'	=> $this->bbf('fm_register_name'),
							'name'	=> 'register[username]',
							'labelid'	=> 'register-username',
							'size'	=> 15,
							'default'	=> $element['register']['username']['default'],
							'value'	=> $this->get_var('info','register','username'),
							'error'	=> $this->bbf_args('error',
									$this->get_var('error', 'register', 'username')) )),

				$form->text(array('desc'	=> $this->bbf('fm_register_authuser'),
							'name'	=> 'register[authuser]',
							'labelid'	=> 'register-authuser',
							'size'	=> 15,
							'default'	=> $element['register']['authuser']['default'],
							'value'	=> $this->get_var('info','register','authuser'),
							'error'	=> $this->bbf_args('error',
								$this->get_var('error', 'register', 'authuser')) )),

				$form->text(array('desc'	=> $this->bbf('fm_register_password'),
							'name'	=> 'register[password]',
							'labelid'	=> 'register-password',
							'size'	=> 15,
							'default'	=> $element['register']['password']['default'],
							'value'	=> $this->get_var('info','register','password'),
							'error'	=> $this->bbf_args('error',
									$this->get_var('error', 'register', 'password')) )),

				$form->text(array('desc'	=> $this->bbf('fm_register_host'),
							'name'	=> 'register[host]',
							'labelid'	=> 'register-host',
							'size'	=> 15,
							'default'	=> $element['register']['host']['default'],
							'value'	=> $this->get_var('info','register','host'),
							'error'	=> $this->bbf_args('error',
									$this->get_var('error', 'register', 'host')) )),

				$form->text(array('desc'	=> $this->bbf('fm_register_port'),
							'name'	=> 'register[port]',
							'labelid'	=> 'register-port',
							'size'	=> 15,
							'default'	=> $element['register']['port']['default'],
							'value'	=> $this->get_var('info','register','port'),
							'error'	=> $this->bbf_args('error',
									$this->get_var('error', 'register', 'port')) )),

				$form->checkbox(array('desc'	=> $this->bbf('fm_register-callbackextension'),
									'name'	=> 'register[callbackextension]',
									'labelid'	=> 'register-callbackextension',
									'checked'	=> $this->get_var('info', 'register', 'callbackextension')),
						'onclick="xivo_chg_attrib(\'ast_fm_register_contact\',
										\'it-register-contact\',
										Number((this.checked === true)));"'),

				$form->text(array('desc'	=> $this->bbf('fm_register_contact'),
							'name'	=> 'register[contact]',
							'labelid'	=> 'register-contact',
							'size'	=> 15,
							'default'	=> $element['register']['contact']['default'],
							'value'	=> $this->get_var('info','register','contact'),
							'error'	=> $this->bbf_args('error',
									$this->get_var('error', 'register', 'contact')) )),

				$form->select(array('desc'  => $this->bbf('fm_register-expiry'),
								'name'     => 'register[expiry]',
								'labelid'  => 'register-expiry',
								'key'      => false,
								'empty'    => true,
								'help'     => $this->bbf('hlp_fm_register-expiry'),
								'selected' => $info['register']['expiry'],
								'default'  => $element['register']['expiry']['default']),
						$element['register']['expiry']['value']);
		?>
	</uib-tab>

	<uib-tab index="2" heading="<?=$this->bbf('smenu_signalling');?>">
		<?php
			echo	$form->select(array('desc'	=> $this->bbf('fm_protocol_progressinband'),
								'name'	=> 'protocol[progressinband]',
								'labelid'	=> 'protocol-progressinband',
								'empty'	=> true,
								'key'	=> false,
								'bbf'	=> 'fm_protocol_progressinband-opt',
								'bbfopt'	=> array('argmode' => 'paramvalue'),
								'default'	=> $element['protocol']['progressinband']['default'],
								'selected'	=> $info['protocol']['progressinband']),
								$element['protocol']['progressinband']['value']),

				$form->select(array('desc'	=> $this->bbf('fm_protocol_dtmfmode'),
								'name'	=> 'protocol[dtmfmode]',
								'labelid'	=> 'protocol-dtmfmode',
								'empty'	=> true,
								'key'	=> false,
								'bbf'	=> 'fm_protocol_dtmfmode-opt',
								'bbfopt'	=> array('argmode' => 'paramvalue'),
								'default'	=> $element['protocol']['dtmfmode']['default'],
								'selected'	=> $info['protocol']['dtmfmode']),
								$element['protocol']['dtmfmode']['value']),

				$form->select(array('desc'	=> $this->bbf('fm_protocol_rfc2833compensate'),
								'name'	=> 'protocol[rfc2833compensate]',
								'labelid'	=> 'protocol-rfc2833compensate',
								'empty'	=> true,
								'key'	=> false,
								'bbf'	=> 'fm_bool-opt',
								'bbfopt'	=> array('argmode' => 'paramvalue'),
								'default'	=> $element['protocol']['rfc2833compensate']['default'],
								'selected'	=> $info['protocol']['rfc2833compensate']),
								$element['protocol']['rfc2833compensate']['value']),

				$form->select(array('desc'	=> $this->bbf('fm_protocol_qualify'),
								'name'	=> 'protocol[qualify]',
								'labelid'	=> 'protocol-qualify',
								'empty'	=> true,
								'key'	=> false,
								'bbf'	=> 'fm_protocol_qualify-opt',
								'bbfopt'	=> array('argmode' => 'paramvalue'),
								'default'	=> $element['protocol']['qualify']['default'],
								'selected'	=> $info['protocol']['qualify']),
								$element['protocol']['qualify']['value']),

				$form->select(array('desc'  => $this->bbf('fm_protocol-qualifyfreq'),
								'name'     => 'protocol[qualifyfreq]',
								'labelid'  => 'protocol-qualifyfreq',
								'key'      => false,
								'empty'    => true,
								'help'     => $this->bbf('hlp_fm_protocol-qualifyfreq'),
								'selected' => $info['protocol']['qualifyfreq'],
								'default'  => $element['protocol']['qualifyfreq']['default']),
						$element['protocol']['qualifyfreq']['value']),

				$form->select(array('desc'	=> $this->bbf('fm_protocol_rtptimeout'),
								'name'	=> 'protocol[rtptimeout]',
								'labelid'	=> 'protocol-rtptimeout',
								'empty'	=> true,
								'key'	=> false,
								'bbf'		=> 'time-opt',
								'bbfopt'	=> array(
								'argmode' => 'paramvalue',
								'time' => array('from' => 'second', 'format' => '%M%s')),
								'default'	=> $element['protocol']['rtptimeout']['default'],
								'selected'	=> $info['protocol']['rtptimeout']),
								$element['protocol']['rtptimeout']['value']),

				$form->select(array('desc'	=> $this->bbf('fm_protocol_rtpholdtimeout'),
								'name'	=> 'protocol[rtpholdtimeout]',
								'labelid'	=> 'protocol-rtpholdtimeout',
								'empty'	=> true,
								'key'	=> false,
								'bbf'		=> 'time-opt',
								'bbfopt'	=> array(
								'argmode' => 'paramvalue',
								'time' => array('from' => 'second', 'format' => '%M%s')),
								'default'	=> $element['protocol']['rtpholdtimeout']['default'],
								'selected'	=> $info['protocol']['rtpholdtimeout']),
								$element['protocol']['rtpholdtimeout']['value']),

				$form->select(array('desc'	=> $this->bbf('fm_protocol_rtpkeepalive'),
								'name'	=> 'protocol[rtpkeepalive]',
								'labelid'	=> 'protocol-rtpkeepalive',
								'empty'	=> true,
								'key'	=> false,
								'bbf'		=> 'time-opt',
								'bbfopt'	=> array(
								'argmode' => 'paramvalue',
								'time' => array('from' => 'second', 'format' => '%M%s')),
								'default'	=> $element['protocol']['rtpkeepalive']['default'],
								'selected'	=> $info['protocol']['rtpkeepalive']),
								$element['protocol']['rtpkeepalive']['value']),

				$form->select(array('desc'	=> $this->bbf('fm_protocol_allowtransfer'),
								'name'	=> 'protocol[allowtransfer]',
								'labelid'	=> 'protocol-allowtransfer',
								'empty'	=> true,
								'key'	=> false,
								'bbf'	=> 'fm_bool-opt',
								'bbfopt'	=> array('argmode' => 'paramvalue'),
								'default'	=> $element['protocol']['allowtransfer']['default'],
								'selected'	=> $info['protocol']['allowtransfer']),
								$element['protocol']['allowtransfer']['value']),

				$form->select(array('desc'	=> $this->bbf('fm_protocol_autoframing'),
								'name'	=> 'protocol[autoframing]',
								'labelid'	=> 'protocol-autoframing',
								'empty'	=> true,
								'key'	=> false,
								'bbf'	=> 'fm_bool-opt',
								'bbfopt'	=> array('argmode' => 'paramvalue'),
								'default'	=> $element['protocol']['autoframing']['default'],
								'selected'	=> $info['protocol']['autoframing']),
								$element['protocol']['autoframing']['value']),

				$form->select(array('desc'	=> $this->bbf('fm_protocol_videosupport'),
								'name'	=> 'protocol[videosupport]',
								'labelid'	=> 'protocol-videosupport',
								'empty'	=> true,
								'key'	=> false,
								'bbf'	=> 'fm_protocol-videosupport-opt',
								'bbfopt'	=> array('argmode' => 'paramvalue'),
								'default'	=> $element['protocol']['videosupport']['default'],
								'selected'	=> $info['protocol']['videosupport']),
								$element['protocol']['videosupport']['value']),

				$form->text(array('desc'	=> $this->bbf('fm_protocol_outboundproxy'),
							'name'	=> 'protocol[outboundproxy]',
							'labelid'	=> 'protocol-outboundproxy',
							'size'	=> 10,
							'default'	=> $element['protocol']['outboundproxy']['default'],
							'value'	=> $info['protocol']['outboundproxy'],
							'error'	=> $this->bbf_args('error',
									$this->get_var('error', 'protocol', 'outboundproxy')) )),

				$form->text(array('desc'	=> $this->bbf('fm_protocol_maxcallbitrate'),
							'name'	=> 'protocol[maxcallbitrate]',
							'labelid'	=> 'protocol-maxcallbitrate',
							'size'	=> 10,
							'default'	=> $element['protocol']['maxcallbitrate']['default'],
							'value'	=> $info['protocol']['maxcallbitrate'],
							'error'	=> $this->bbf_args('error',
									$this->get_var('error', 'protocol', 'maxcallbitrate')) )),

				$form->select(array('desc'	=> $this->bbf('fm_protocol_g726nonstandard'),
								'name'	=> 'protocol[g726nonstandard]',
								'labelid'	=> 'protocol-g726nonstandard',
								'empty'	=> true,
								'key'	=> false,
								'bbf'	=> 'fm_bool-opt',
								'bbfopt'	=> array('argmode' => 'paramvalue'),
								'default'	=> $element['protocol']['g726nonstandard']['default'],
								'selected'	=> $info['protocol']['g726nonstandard']),
								$element['protocol']['g726nonstandard']['value']),

				$form->text(array('desc'  => $this->bbf('fm_protocol-timert1'),
								'name'     => 'protocol[timert1]',
								'labelid'  => 'protocol-timert1',
								'size'     => 5,
								'help'     => $this->bbf('hlp_fm_protocol-timert1'),
								'required' => false,
								'value'    => $info['protocol']['timert1'],
								'default'  => $element['protocol']['timert1']['default'],
								'error'    => $this->bbf_args('error',
						$this->get_var('error', 'timert1')) )),

				$form->text(array('desc'  => $this->bbf('fm_protocol-timerb'),
								'name'     => 'protocol[timerb]',
								'labelid'  => 'protocol-timerb',
								'size'     => 5,
								'help'     => $this->bbf('hlp_fm_protocol-timerb'),
								'required' => false,
								'value'    => $info['protocol']['timerb'],
								'default'  => $element['protocol']['timerb']['default'],
								'error'    => $this->bbf_args('error',
						$this->get_var('error', 'timerb')) )),

				$form->select(array('desc'  => $this->bbf('fm_protocol-ignoresdpversion'),
								'name'      => 'protocol[ignoresdpversion]',
								'labelid'   => 'protocol-ignoresdpversion',
								'key'       => false,
								'empty'     => true,
								'bbf'       => 'fm_bool-opt',
								'bbfopt'    => array('argmode' => 'paramvalue'),
								'help'      => $this->bbf('hlp_fm_protocol-ignoresdpversion'),
								'selected'  => $info['protocol']['ignoresdpversion'],
								'default'   => $element['protocol']['ignoresdpversion']['default']),
						$element['protocol']['ignoresdpversion']['value']),

				$form->select(array('desc'  => $this->bbf('fm_protocol-session-timers'),
								'name'    => 'protocol[session-timers]',
								'labelid' => 'protocol-session-timers',
								'key'   => false,
								'empty' => true,
								'bbf'   => 'fm_protocol-session-timers-opt',
								'bbfopt'  => array('argmode' => 'paramvalue'),
								'help'    => $this->bbf('hlp_fm_protocol-session-timers'),
								'selected'  => $info['protocol']['session-timers'],
								'default' => $element['protocol']['session-timers']['default']),
						$element['protocol']['session-timers']['value']),

						$form->select(array('desc'  => $this->bbf('fm_protocol-session-expires'),
								'name'     => 'protocol[session-expires]',
								'labelid'  => 'protocol-session-expires',
								'key'      => false,
								'empty'    => true,
								'bbf'       => 'time-opt',
								'bbfopt'    => array('argmode' => 'paramvalue',
 								'time'      => array('from'=>'second', 'format'=>'%M%s')),
								'help'     => $this->bbf('hlp_fm_protocol-session-expires'),
								'selected' => $info['protocol']['session-expires'],
								'default'  => $element['protocol']['session-expires']['default']),
						$element['protocol']['session-expires']['value']),

				$form->select(array('desc'  => $this->bbf('fm_protocol-session-minse'),
								'name'     => 'protocol[session-minse]',
								'labelid'  => 'protocol-session-minse',
								'key'      => false,
								'bbf'       => 'time-opt',
								'bbfopt'    => array('argmode' => 'paramvalue',
								'time'      => array('from'=>'second', 'format'=>'%M%s')),
								'empty'    => true,
								'help'     => $this->bbf('hlp_fm_protocol-session-minse'),
								'selected' => $info['protocol']['session-minse'],
								'default'  => $element['protocol']['session-minse']['default']),
						$element['protocol']['session-minse']['value']),

				$form->select(array('desc'  => $this->bbf('fm_protocol-session-refresher'),
								'name'    => 'protocol[session-refresher]',
								'labelid' => 'protocol-session-refresher',
								'key'   => false,
								'empty' => true,
								'bbf'   => 'fm_protocol-session-refresher-opt',
								'bbfopt'  => array('argmode' => 'paramvalue'),
								'help'    => $this->bbf('hlp_fm_protocol-session-refresher'),
								'selected'  => $info['protocol']['session-refresher'],
								'default' => $element['protocol']['session-refresher']['default']),
						$element['protocol']['session-refresher']['value']);

		?>
		<fieldset id="fld-codeclist">
			<legend><?=$this->bbf('fld-codeclist');?></legend>
			<?php
				echo	$form->checkbox(array('desc'	=> $this->bbf('fm_codec-custom'),
										'name'		=> 'codec-active',
										'labelid'	=> 'codec-active',
										'checked'	=> $codec_active));
			?>
			<div id="codeclist">
				<?php
					echo	$form->select(array('desc'	=> $this->bbf('fm_protocol_codec-disallow'),
											'name'		=> 'protocol[disallow]',
											'labelid'	=> 'protocol-disallow',
											'key'		=> false,
											'bbf'		=> 'fm_protocol_codec-disallow-opt',
											'bbfopt'	=> array('argmode' => 'paramvalue')),
									$element['protocol']['disallow']['value']);
				?>
				<div class="col-sm-offset-2 fm-paragraph fm-description">
					<?=$form->jq_select(array('paragraph'	=> false,
										'label'		=> false,
										'name'		=> 'protocol[allow][]',
										'id' 		=> 'it-protocol-allow',
										'key'		=> false,
										'bbf'		=> 'ast_codec_name_type',
										'bbfopt'	=> array('argmode' => 'paramvalue'),
										'selected'  => $allow),
								$element['protocol']['allow']['value']);?>
					<div class="clearboth"></div>
				</div>
			</div>
		</fieldset>
	</uib-tab>

	<uib-tab index="3" heading="<?=$this->bbf('smenu_advanced');?>">
		<?php
			echo	$form->select(array('desc'	=> $this->bbf('fm_protocol_insecure'),
								'name'	=> 'protocol[insecure]',
								'labelid'	=> 'protocol-insecure',
								'empty'	=> true,
								'bbf'	=> 'fm_protocol_insecure-opt',
								'bbfopt'	=> array('argmode' => 'paramvalue'),
								'default'	=> $element['protocol']['insecure']['default'],
								'selected'	=> $info['protocol']['insecure']),
								$element['protocol']['insecure']['value']),

				$form->text(array('desc'	=> $this->bbf('fm_protocol_port'),
							'name'	=> 'protocol[port]',
							'labelid'	=> 'protocol-port',
							'size'	=> 10,
							'default'	=> $element['protocol']['port']['default'],
							'value'	=> $info['protocol']['port'],
							'error'	=> $this->bbf_args('error',
									$this->get_var('error', 'protocol', 'maxcallbitrate')) )),

				$form->text(array('desc'	=> $this->bbf('fm_protocol_permit'),
							'name'	=> 'protocol[permit]',
							'labelid'	=> 'protocol-permit',
							'size'	=> 20,
							'default'	=> $element['protocol']['permit']['default'],
							'value'	=> $info['protocol']['permit'],
							'error'	=> $this->bbf_args('error',
									$this->get_var('error', 'protocol', 'maxcallbitrate')) )),

				$form->text(array('desc'	=> $this->bbf('fm_protocol_deny'),
							'name'	=> 'protocol[deny]',
							'labelid'	=> 'protocol-deny',
							'size'	=> 20,
							'default'	=> $element['protocol']['deny']['default'],
							'value'	=> $info['protocol']['deny'],
							'error'	=> $this->bbf_args('error',
									$this->get_var('error', 'protocol', 'maxcallbitrate')) )),

				$form->select(array('desc'	=> $this->bbf('fm_protocol_trustrpid'),
								'name'	=> 'protocol[trustrpid]',
								'labelid'	=> 'protocol-trustrpid',
								'empty'	=> true,
								'key'	=> false,
								'bbf'	=> 'fm_bool-opt',
								'bbfopt'	=> array('argmode' => 'paramvalue'),
								'default'	=> $element['protocol']['trustrpid']['default'],
								'selected'	=> $info['protocol']['trustrpid']),
								$element['protocol']['trustrpid']['value']),

				$form->select(array('desc'	=> $this->bbf('fm_protocol_sendrpid'),
								'name'	=> 'protocol[sendrpid]',
								'labelid'	=> 'protocol-sendrpid',
								'empty'	=> true,
								'key'	=> false,
								'bbf'	=> 'fm_sendrpid-opt',
								'bbfopt'	=> array('argmode' => 'paramvalue'),
								'default'	=> $element['protocol']['sendrpid']['default'],
								'selected'	=> $info['protocol']['sendrpid']),
								$element['protocol']['sendrpid']['value']),

				$form->select(array('desc'	=> $this->bbf('fm_protocol_allowsubscribe'),
								'name'	=> 'protocol[allowsubscribe]',
								'labelid'	=> 'protocol-allowsubscribe',
								'empty'	=> true,
								'key'	=> false,
								'bbf'	=> 'fm_bool-opt',
								'bbfopt'	=> array('argmode' => 'paramvalue'),
								'default'	=> $element['protocol']['allowsubscribe']['default'],
								'selected'	=> $info['protocol']['allowsubscribe']),
								$element['protocol']['allowsubscribe']['value']),

				$form->select(array('desc'	=> $this->bbf('fm_protocol_allowoverlap'),
								'name'	=> 'protocol[allowoverlap]',
								'labelid'	=> 'protocol-allowoverlap',
								'empty'	=> true,
								'key'	=> false,
								'bbf'	=> 'fm_bool-opt',
								'bbfopt'	=> array('argmode' => 'paramvalue'),
								'default'	=> $element['protocol']['allowoverlap']['default'],
								'selected'	=> $info['protocol']['allowoverlap']),
								$element['protocol']['allowoverlap']['value']),

				$form->select(array('desc'	=> $this->bbf('fm_protocol_promiscredir'),
								'name'	=> 'protocol[promiscredir]',
								'labelid'	=> 'protocol-promiscredir',
								'empty'	=> true,
								'key'	=> false,
								'bbf'	=> 'fm_bool-opt',
								'bbfopt'	=> array('argmode' => 'paramvalue'),
								'default'	=> $element['protocol']['promiscredir']['default'],
								'selected'	=> $info['protocol']['promiscredir']),
								$element['protocol']['promiscredir']['value']),

				$form->select(array('desc'	=> $this->bbf('fm_protocol_usereqphone'),
								'name'	=> 'protocol[usereqphone]',
								'labelid'	=> 'protocol-usereqphone',
								'empty'	=> true,
								'key'	=> false,
								'bbf'	=> 'fm_bool-opt',
								'bbfopt'	=> array('argmode' => 'paramvalue'),
								'default'	=> $element['protocol']['usereqphone']['default'],
								'selected'	=> $info['protocol']['usereqphone']),
								$element['protocol']['usereqphone']['value']),

				$form->select(array('desc'  => $this->bbf('fm_protocol-directmedia'),
								'name'    => 'protocol[directmedia]',
								'labelid' => 'protocol-directmedia',
								'key'   => false,
								'empty' => true,
								'bbf'   => 'fm_protocol-directmedia-opt',
								'bbfopt'  => array('argmode' => 'paramvalue'),
								'help'    => $this->bbf('hlp_fm_protocol-directmedia'),
								'selected'  => $info['protocol']['directmedia'],
								'default' => $element['protocol']['directmedia']['default']),
						$element['protocol']['directmedia']['value']),

				$form->text(array('desc'	=> $this->bbf('fm_protocol_fromuser'),
							'name'	=> 'protocol[fromuser]',
							'labelid'	=> 'protocol-fromuser',
							'size'	=> 15,
							'default'	=> $element['protocol']['fromuser']['default'],
							'value'	=> $info['protocol']['fromuser'],
							'error'	=> $this->bbf_args('error',
									$this->get_var('error', 'protocol', 'fromuser')) )),

				$form->text(array('desc'	=> $this->bbf('fm_protocol_fromdomain'),
							'name'	=> 'protocol[fromdomain]',
							'labelid'	=> 'protocol-fromdomain',
							'size'	=> 15,
							'default'	=> $element['protocol']['fromdomain']['default'],
							'value'	=> $info['protocol']['fromdomain'],
							'error'	=> $this->bbf_args('error',
									$this->get_var('error', 'protocol', 'fromdomain')) )),

				$form->select(array('desc'	=> $this->bbf('fm_protocol_amaflags'),
								'name'	=> 'protocol[amaflags]',
								'labelid'	=> 'protocol-amaflags',
								'key'	=> false,
								'bbf'	=> 'ast_amaflag_name_info',
								'bbfopt'	=> array('argmode' => 'paramvalue'),
								'default'	=> $element['protocol']['amaflags']['default'],
								'selected'	=> $info['protocol']['amaflags']['default']),
								$element['protocol']['amaflags']['value']),

				$form->text(array('desc'	=> $this->bbf('fm_protocol_accountcode'),
							'name'	=> 'protocol[accountcode]',
							'labelid'	=> 'protocol-accountcode',
							'size'	=> 15,
							'default'	=> $element['protocol']['accountcode']['default'],
							'value'	=> $info['protocol']['accountcode'],
							'error'	=> $this->bbf_args('error',
									$this->get_var('error', 'protocol', 'accountcode')) )),

				$form->select(array('desc'	=> $this->bbf('fm_protocol_useclientcode'),
								'name'	=> 'protocol[useclientcode]',
								'labelid'	=> 'protocol-useclientcode',
								'empty'	=> true,
								'key'	=> false,
								'bbf'	=> 'fm_bool-opt',
								'bbfopt'	=> array('argmode' => 'paramvalue'),
								'default'	=> $element['protocol']['useclientcode']['default'],
								'selected'	=> $info['protocol']['useclientcode']),
							$element['protocol']['useclientcode']['value']),

			// asterisk 1.8 fields
					$form->select(array('desc'  => $this->bbf('fm_protocol-transport'),
								'name'    => 'protocol[transport]',
								'labelid' => 'protocol-transport',
								'key'   => false,
								'help'    => $this->bbf('hlp_fm_protocol-transport'),
								'selected'  => $info['protocol']['transport'],
								'default' => $element['protocol']['transport']['default']),
						$element['protocol']['transport']['value']),

				$form->text(array('desc'  => $this->bbf('fm_protocol-remotesecret'),
								'name'     => 'protocol[remotesecret]',
								'labelid'  => 'protocol-remotesecret',
								'size'     => 25,
								'help'     => $this->bbf('hlp_fm_protocol-remotesecret'),
								'required' => false,
								'value'    => $info['protocol']['remotesecret'],
								'default'  => $element['protocol']['remotesecret']['default'],
								'error'    => $this->bbf_args('error',
						$this->get_var('error', 'remotesecret')) )),

				$form->select(array('desc'  => $this->bbf('fm_protocol-callcounter'),
								'name'      => 'protocol[callcounter]',
								'labelid'   => 'protocol-callcounter',
								'key'       => false,
								'empty'     => true,
								'bbf'       => 'fm_bool-opt',
								'bbfopt'    => array('argmode' => 'paramvalue'),
								'help'      => $this->bbf('hlp_fm_protocol-callcounter'),
								'selected'  => $info['protocol']['callcounter'],
								'default'   => $element['protocol']['callcounter']['default']),
						$element['protocol']['callcounter']['value']),

				$form->select(array('desc'  => $this->bbf('fm_protocol-busylevel'),
								'name'     => 'protocol[busylevel]',
								'labelid'  => 'protocol-busylevel',
								'key'      => false,
								'empty'    => true,
								'help'     => $this->bbf('hlp_fm_protocol-busylevel'),
								'selected' => $info['protocol']['busylevel'],
								'default'  => $element['protocol']['busylevel']['default']),
						$element['protocol']['busylevel']['value']),

				$form->text(array('desc'  => $this->bbf('fm_protocol-callbackextension'),
								'name'     => 'protocol[callbackextension]',
								'labelid'  => 'protocol-callbackextension',
								'size'     => 25,
								'help'     => $this->bbf('hlp_fm_protocol-callbackextension'),
								'required' => false,
								'value'    => $info['protocol']['callbackextension'],
								'default'  => $element['protocol']['callbackextension']['default'],
								'error'    => $this->bbf_args('error',
						$this->get_var('error', 'callbackextension')) )),

				$form->text(array('desc'  => $this->bbf('fm_protocol-contactpermit'),
								'name'     => 'protocol[contactpermit]',
								'labelid'  => 'protocol-contactpermit',
								'size'     => 25,
								'help'     => $this->bbf('hlp_fm_protocol-contactpermit'),
								'required' => false,
								'value'    => $info['protocol']['contactpermit'],
								'default'  => $element['protocol']['contactpermit']['default'],
								'error'    => $this->bbf_args('error',
						$this->get_var('error', 'contactpermit')) )),

				$form->text(array('desc'  => $this->bbf('fm_protocol-contactdeny'),
								'name'     => 'protocol[contactdeny]',
								'labelid'  => 'protocol-contactdeny',
								'size'     => 25,
								'help'     => $this->bbf('hlp_fm_protocol-contactdeny'),
								'required' => false,
								'value'    => $info['protocol']['contactdeny'],
								'default'  => $element['protocol']['contactdeny']['default'],
								'error'    => $this->bbf_args('error',
						$this->get_var('error', 'contactdeny')) ));

		?>
		<div class="col-sm-offset-2 fm-paragraph fm-description">
			<p>
				<label id="lb-trunkfeatures-description" for="it-trunkfeatures-description">
					<?=$this->bbf('fm_trunkfeatures_description');?>
				</label>
			</p>
			<?=$form->textarea(array('paragraph'	=> false,
						'label'	=> false,
						'name'		=> 'trunkfeatures[description]',
						'id'		=> 'it-trunkfeatures-description',
						'cols'		=> 60,
						'rows'		=> 5,
						'default'	=> $element['trunkfeatures']['description']['default'],
						'error'	=> $this->bbf_args('error',
								$this->get_var('error', 'trunkfeatures', 'description')) ),
						$info['trunkfeatures']['description']);?>
		</div>
	</uib-tab>
</uib-tabset>
