4.x style
[freeside.git] / httemplate / elements / tr-select-svc_phone-forward.html
1 % if ( $hide ) {
2   <tr style="display: none"><td>
3   <INPUT TYPE="hidden" NAME="<% $opt{field} %>" VALUE="<% $opt{curr_value}%>">
4   </td></tr>
5 % } else {
6   <& tr-select-table.html,
7     'table'       => 'svc_acct', # for now
8     'name_col'    => 'email',
9     'order_by'    => 'order by username',
10     'empty_label' => ' ',
11     %select_hash,
12     %opt
13   &>
14 % } 
15 <%init>
16
17 my %opt = @_;
18 my $pkgnum = $opt{pkgnum};
19 my $svcpart = $opt{svcpart};
20
21 my $field = $opt{'field'} ||= 'forward_svcnum';
22
23 my $part_svc = FS::part_svc->by_key($svcpart);
24 # kludgey assumptions for now:
25 # - this is only used to route DIDs to their real destinations
26 # - which is a svc_acct
27 # - in the same package (part_export::svc_with_role assumes this)
28 # - and shares an export
29
30 my $cust_pkg = FS::cust_pkg->by_key($pkgnum);
31 my @svcparts;
32 foreach my $part_export ( $part_svc->part_export ) {
33   foreach my $export_svc ( $part_export->export_svc ) {
34     push @svcparts, $export_svc->svcpart;
35   }
36 }
37
38 $pkgnum =~ /^(\d+)$/ or die "bad pkgnum $pkgnum";
39
40 my %select_hash = (
41   'addl_from' => ' JOIN cust_svc USING (svcnum) ',
42   'extra_sql' => "WHERE pkgnum = $pkgnum AND svcpart IN(".
43     join(',', @svcparts) . ")"
44 );
45
46 my $hide = 0;
47 $hide = 1 if $part_svc->part_svc_column($field) eq 'F';
48 $hide = 1 if !@svcparts;
49
50 </%init>