<?php

#
# XiVO Web-Interface
# Copyright (C) 2006-2014  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');

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

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

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

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

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

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>
<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>
