summaryrefslogtreecommitdiff
path: root/httemplate/elements/tr-select-svc_circuit.html
blob: fb55501c568f5c0afb1513962171cd0bc2b4e82e (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
% if ( $columnflag eq 'F' ) { # no good reason for this, but support it anyway
  <INPUT TYPE="hidden" NAME="circuit_svcnum" VALUE="<% $circuit_svcnum %>">
% } else { 
  <& tr-select-table.html,
    'table'       => 'svc_circuit',
    'name_col'    => 'circuit_id',
    'empty_label' => ' ',
    %select_hash,
    %opt
  &>
% } 
<%init>

my %opt = @_;

my $circuit_svcnum;
if ( $opt{'curr_value'} =~ /^(\d+)$/ ) {
  $circuit_svcnum = $1;
}

# generally not the svcpart of the circuit service (or any circuit service)
my $part_svc = $opt{'part_svc'}
               || qsearchs('part_svc', { 'svcpart' => $opt{'svcpart'} });

my $columnflag = $part_svc->part_svc_column('circuit_svcnum')->columnflag;

my $cust_pkg = $opt{'cust_pkg'};
my $custnum;
$custnum = $cust_pkg->custnum if $cust_pkg;

my %select_hash;
if ( $custnum =~ /^(\d+)$/ ) {
  %select_hash = (
    'addl_from' => ' LEFT JOIN cust_svc USING (svcnum)' .
                   ' LEFT JOIN cust_pkg USING (pkgnum)',
    'extra_sql' => " WHERE cust_pkg.custnum = $custnum".
                   " OR svcnum = $circuit_svcnum",
  );
}

</%init>