summaryrefslogtreecommitdiff
path: root/httemplate/edit/rate_detail.html
blob: dd8c3f6b38c1a7491f7253b4d394785da35fa0d3 (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
51
52
53
54
55
56
57
58
59
60
61
62
63
<% include('elements/edit.html',
     'popup'  => 1,
     'name'   => $name,
     'table'  => 'rate_detail',
     'labels' => { 'ratedetailnum'       => 'Rate', #should hide...
                   'dest_regionname'     => 'Region',
                   'dest_prefixes_short' => 'Prefix(es)',
                   'min_included'        => 'Included minutes/calls',
                   'min_charge'          => 'Charge per minute/call',
                   'sec_granularity'     => 'Granularity',
                   'classnum'            => 'Usage class',
                 },
     'fields' => [
                   { field=>'ratenum',             type=>'hidden', },
                   { field=>'orig_regionnum',      type=>'hidden', },
                   { field=>'dest_regionnum',      type=>'hidden', },
                   { field=>'dest_regionname',     type=>'fixed',  },
                   { field=>'dest_prefixes_short', type=>'fixed',  },
                   { field=>'min_included',        type=>'text',  size=>5 },
                   { field=>'min_charge',          type=>'money', size=>4 },
                   { field         =>'sec_granularity',
                     type          =>'select',
                     options       => [ keys %granularity ],
                     labels        => \%granularity,
                     disable_empty => 1,
                   },
                   { field         =>'classnum',
                     type          =>'select-table',
                     table         =>'usage_class',
                     name_col      =>'classname',
                     empty_label   =>'(default)',
                     hashref        =>{ disabled => '' },
                   },

                 ],
   )
%>
<%once>

tie my %granularity, 'Tie::IxHash', FS::rate_detail::granularities();

</%once>

<%init>

my $conf = new FS::Conf;
die "access denied"
  unless $FS::CurrentUser::CurrentUser->access_right('Configuration');

#slightly inefficient, i suppose an edit+error callback would be better
my $name = 'rate';
my ($keywords) = $cgi->keywords;
if (    $keywords                    =~ /^(\d+)$/
     || $cgi->param('ratedetailnum') =~ /^(\d+)$/ ) {
  my $rate_detail = qsearchs('rate_detail', { 'ratedetailnum' => $1 } )
    or die "unknown ratedetailnum $1";
  $name =
    $rate_detail->rate->ratename. ' rate for '. $rate_detail->dest_regionname;
}

#sec_granularity should default to 60!  for new rates when this gets used for em

</%init>