summaryrefslogtreecommitdiff
path: root/httemplate
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2014-12-28 23:27:48 -0800
committerMark Wells <mark@freeside.biz>2014-12-28 23:27:48 -0800
commite3503e19a5a6c876f410903a3946dd9f1597aa46 (patch)
tree6d361bb09fd1aa0f1d9b9578198a913a0950e955 /httemplate
parentaf96802d080094c381dd06b74488adfb20396574 (diff)
voip.ms export, #31834
Diffstat (limited to 'httemplate')
-rwxr-xr-xhttemplate/browse/part_export.cgi24
-rw-r--r--httemplate/edit/part_export.cgi16
-rw-r--r--httemplate/edit/svc_phone.cgi3
-rw-r--r--httemplate/elements/select-did.html24
-rw-r--r--httemplate/elements/tr-select-sip_server.html48
-rw-r--r--httemplate/view/svc_phone.cgi3
6 files changed, 95 insertions, 23 deletions
diff --git a/httemplate/browse/part_export.cgi b/httemplate/browse/part_export.cgi
index 876633afc..1f835d729 100755
--- a/httemplate/browse/part_export.cgi
+++ b/httemplate/browse/part_export.cgi
@@ -60,21 +60,25 @@ function part_export_areyousure(href) {
% my %opt = $part_export->options;
% my $defs = $part_export->info->{options};
% my %multiples;
-% foreach my $opt (keys %$defs) { # is a Tie::IxHash
-% my $group = $defs->{$opt}->{multiple};
+% foreach my $optname (keys %$defs) { # is a Tie::IxHash
+% my $def = $defs->{$optname};
+% my $group = $def->{multiple};
% if ( $group ) {
-% my @values = split("\n", $opt{$opt});
+% my @values = split("\n", $opt{$optname});
% $multiples{$group} ||= [];
-% push @{ $multiples{$group} }, [ $opt, @values ] if @values;
-% delete $opt{$opt};
-% } elsif (length($opt{$opt})) { # the normal case
-%# foreach my $opt ( keys %opt ) {
+% push @{ $multiples{$group} }, [ $optname, @values ] if @values;
+% delete $opt{$optname};
+% } elsif (length($opt{$optname})) { # the normal case
+% my $value = $opt{$optname};
+% if ( $def->{option_labels} ) {
+% $value = $def->{option_labels}->{$value} || $value;
+% }
<TR>
- <TD ALIGN="right" VALIGN="top" WIDTH="33%"><% $opt %>:&nbsp;</TD>
- <TD ALIGN="left" WIDTH="67%"><% encode_entities($opt{$opt}) %></TD>
+ <TD ALIGN="right" VALIGN="top" WIDTH="33%"><% $optname %>:&nbsp;</TD>
+ <TD ALIGN="left" WIDTH="67%"><% encode_entities($value) %></TD>
</TR>
-% delete $opt{$opt};
+% delete $opt{$optname};
% }
% }
% # now any that are somehow not in the options list
diff --git a/httemplate/edit/part_export.cgi b/httemplate/edit/part_export.cgi
index 2897cf39d..0e53e29d0 100644
--- a/httemplate/edit/part_export.cgi
+++ b/httemplate/edit/part_export.cgi
@@ -201,6 +201,15 @@ my $widget = new HTML::Widgets::SelectLayers(
$html .= qq!<TR><TD ALIGN="right">$label</TD><TD>!;
}
if ( $type eq 'select' ) {
+
+ # 'select' options can specify options one of two ways:
+ # the "preferred" way:
+ # options: arrayref of allowed option values
+ # option_labels: hashref of option value => label
+ # OR the weird and semi-deprecated way:
+ # option_values: coderef to return a list of allowed option values
+ # option_label: coderef to take an option value and return its label
+
my $size = defined($optinfo->{size}) ? " SIZE=" . $optinfo->{size} : '';
my $multi = ($optinfo->{multi} || $optinfo->{multiple})
? ' MULTIPLE' : '';
@@ -218,10 +227,15 @@ my $widget = new HTML::Widgets::SelectLayers(
#} else {
my $selected = ($multi ? grep {$_ eq $select_option} @values : $select_option eq $value ) ? ' SELECTED' : '';
my $label = $select_option;
- if (defined($optinfo->{option_label})) {
+ if ( defined $optinfo->{option_label} ) {
my $labelsub = $optinfo->{option_label};
$label = &$labelsub($select_option);
+ } elsif ( defined $optinfo->{option_labels} ) {
+ if (exists $optinfo->{option_labels}->{$select_option}) {
+ $label = $optinfo->{option_labels}->{$select_option};
+ }
}
+
$html .= qq!<OPTION VALUE="$select_option"$selected>!.
qq!$label</OPTION>!;
#}
diff --git a/httemplate/edit/svc_phone.cgi b/httemplate/edit/svc_phone.cgi
index f9c0d4005..f1471e283 100644
--- a/httemplate/edit/svc_phone.cgi
+++ b/httemplate/edit/svc_phone.cgi
@@ -132,6 +132,9 @@ my $begin_callback = sub {
value => 'Carrier Information',
colspan => 8,
},
+ { field => 'sip_server',
+ type => 'select-sip_server',
+ },
{ field => 'sms_carrierid',
label => 'SMS Carrier',
type => 'select-cdr_carrier',
diff --git a/httemplate/elements/select-did.html b/httemplate/elements/select-did.html
index c39603156..8a91d7a61 100644
--- a/httemplate/elements/select-did.html
+++ b/httemplate/elements/select-did.html
@@ -81,18 +81,18 @@ Example:
% # if/when other folks need an areacode-less DID selector that goes
% # directly from state to region
- <TD VALIGN="top">
- <% include('/elements/select.html',
- 'field' => 'phonenum_state',
- 'id' => 'phonenum_state',
- 'options' => [ '', @{ $export->get_dids } ],
- 'labels' => { '' => 'Select province' },
- 'onchange' => 'phonenum_state_changed(this);',
- 'disabled' => ( $manual_checked ? 1 : 0 ),
- )
- %>
- <BR><FONT SIZE="-1" ID="phonenum_state_label" <% $manual_checked ? 'STYLE="color:#999999"' : '' %>>Province</FONT>
- </TD>
+ <TD VALIGN="top">
+ <% include('/elements/select.html',
+ 'field' => 'phonenum_state',
+ 'id' => 'phonenum_state',
+ 'options' => [ '', @{ $export->get_dids } ],
+ 'labels' => { '' => 'Select province' },
+ 'onchange' => 'phonenum_state_changed(this);',
+ 'disabled' => ( $manual_checked ? 1 : 0 ),
+ )
+ %>
+ <BR><FONT SIZE="-1" ID="phonenum_state_label" <% $manual_checked ? 'STYLE="color:#999999"' : '' %>>Province</FONT>
+ </TD>
<TD VALIGN="top">
<% include('/elements/select-region.html',
diff --git a/httemplate/elements/tr-select-sip_server.html b/httemplate/elements/tr-select-sip_server.html
new file mode 100644
index 000000000..8df1b6288
--- /dev/null
+++ b/httemplate/elements/tr-select-sip_server.html
@@ -0,0 +1,48 @@
+% if ( $columnflag eq 'F' ) {
+<& fixed.html, %opt &>
+% } elsif ( $use_selector ) {
+% my $servers = $exports[0]->get_sip_servers;
+% # pretty simple selector, they're all just hostnames/IP addresses
+<& tr-select.html,
+ %opt,
+ options => $servers,
+&>
+% } else {
+<& tr-input-text.html, %opt &>
+% }
+</TR>
+
+<%init>
+
+my %opt = @_;
+my $cell_style = $opt{'cell_style'} ? 'STYLE="'. $opt{'cell_style'}. '"' : '';
+
+$opt{'field'} ||= 'sip_server';
+
+#false laziness w/select-did.html
+#XXX make sure this comes through on errors too
+my $svcpart = $opt{'svcpart'}
+ || $opt{'object'}->svcpart
+ || $opt{'object'}->cust_svc->svcpart;
+
+my $part_svc = qsearchs('part_svc', { 'svcpart'=>$svcpart } );
+die "unknown svcpart $svcpart" unless $part_svc;
+
+my $columnflag;
+my $psc = $part_svc->part_svc_column($opt{'field'});
+if ( $psc ) {
+ $columnflag = $psc->columnflag;
+}
+
+my @exports = $part_svc->part_export_did;
+if ( scalar(@exports) > 1 ) {
+ die "more than one DID-providing export attached to svcpart $svcpart";
+}
+
+my $use_selector = 0;
+
+if ( $exports[0] and $exports[0]->can('get_sip_servers') ) {
+ $use_selector = 1;
+}
+
+</%init>
diff --git a/httemplate/view/svc_phone.cgi b/httemplate/view/svc_phone.cgi
index 1c0fb39c5..aca412969 100644
--- a/httemplate/view/svc_phone.cgi
+++ b/httemplate/view/svc_phone.cgi
@@ -19,6 +19,7 @@ my %labels = map { $_ => ( ref($fields->{$_})
my @fields = qw( countrycode phonenum sim_imsi );
push @fields, 'domain' if $conf->exists('svc_phone-domain');
push @fields, qw( pbx_title );
+$labels{pbx_title} = 'PBX';
if ( $conf->exists('showpasswords') ) {
push @fields, qw( sip_password );
@@ -58,6 +59,8 @@ push @fields, { field => 'circuit_label',
link => [ $p.'view/svc_circuit.html?', 'circuit_svcnum' ]
};
+push @fields, 'sip_server';
+
my $html_foot = sub {
my $svc_phone = shift;