summaryrefslogtreecommitdiff
path: root/httemplate/elements/tr-select-sip_server.html
blob: 8df1b62885d49dce0d909e3ad44a477e29efcd8b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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>