summaryrefslogtreecommitdiff
path: root/httemplate/elements/select-svc-domain.html
blob: 4c04466dbb3867fa240cd5bd5f4d79f2a4ccc7ac (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
49
50
<SELECT NAME="domsvc" SIZE=1>
% foreach my $svcnum (
%                      sort { $svc_domain{$a} cmp $svc_domain{$b} }
%                      keys %svc_domain
%                    ) {

    <OPTION VALUE="<% $svcnum %>"
            <% ($svcnum == $domsvc) ? ' SELECTED' : '' %>
    ><% $svc_domain{$svcnum} %>

% } 

</SELECT>
<%init>

my %opt = @_;

my %svc_domain = ();
my $domsvc;

my $domsvc = $opt{'curr_value'};
my $part_svc = $opt{'part_svc'}
               || qsearchs('part_svc', { 'svcpart' => $opt{'svcpart'} });

#optional
my $cust_pkg = $opt{'cust_pkg'};
$cust_pkg ||= qsearchs('cust_pkg', { 'pkgnum' => $opt{'pkgnum'} })
  if $opt{'pkgnum'};

my $pkgnum = $cust_pkg ? $cust_pkg->pkgnum : '';

my %svc_domain = ();

if ( $domsvc ) {
  my $svc_domain = qsearchs('svc_domain', { 'svcnum' => $domsvc } );
  if ( $svc_domain ) {
    $svc_domain{$svc_domain->svcnum} = $svc_domain;
  } else {
    warn "unknown svc_domain.svcnum for svc_acct.domsvc: $domsvc";
  }
}

%svc_domain = (
  %svc_domain,
  FS::svc_Domain_Mixin->domain_select_hash( 'svcpart' => $part_svc->svcpart,
                                            'pkgnum'  => $pkgnum,
                                          )
);

</%init>