default to a session cookie instead of setting an explicit timeout, weird timezone...
[freeside.git] / httemplate / edit / rate_detail.html
1 <% include('elements/edit.html',
2      'popup'  => 1,
3      'name'   => $name,
4      'table'  => 'rate_detail',
5      'labels' => { 'ratedetailnum'       => 'Rate', #should hide...
6                    'dest_regionname'     => 'Region',
7                    'dest_prefixes_short' => 'Prefix(es)',
8                    'rate_time_name'      => 'Time period',
9                    'min_included'        => 'Included minutes/calls',
10                    'region_group'        => 'Region Group',
11                    'conn_charge'         => 'Retail connection charge',
12                    'conn_sec'            => 'For',
13                    'min_charge'          => 'Retail charge per minute/call',
14                    'sec_granularity'     => 'Granularity',
15                    'conn_cost'           => 'Wholesale connection cost',
16                    'min_cost'            => 'Wholesale cost per minute/call',
17                    'classnum'            => 'Usage class',
18                    'upstream_mult_charge'=> 'Upstream multiplier (retail)',
19                    'upstream_mult_cost'  => 'Upstream multiplier (cost)',
20                  },
21      'fields' => [
22                    { field=>'ratenum',             type=>'hidden', },
23                    { field=>'orig_regionnum',      type=>'hidden', },
24                    { field=>'dest_regionnum',      type=>'hidden', },
25                    { field=>'ratetimenum',         type=>'hidden', },
26                    { field=>'cdrtypenum',          type=>'hidden', },
27                    { field=>'dest_regionname',     type=>'fixed',  },
28                    { field=>'dest_prefixes_short', type=>'fixed',  },
29                    { field=>'rate_time_name',      type=>'fixed',  },
30                    { field => 'region_group',
31                      type => 'checkbox',
32                      value => 'Y',
33                    },
34                    { field=>'min_included',        type=>'text',  size=>5 },
35                    { field=>'conn_charge',         type=>'money', size=>4 },
36                    { field=>'conn_cost',         type=>'money', size=>4 },
37                    { field          =>'conn_sec',
38                       type          =>'select',
39                       options       => [ keys %conn_secs ],
40                       labels        => \%conn_secs,
41                       disable_empty => 1,
42                    },
43                    { field=>'min_charge',          type=>'money', size=>4 },
44                    { field=>'min_cost',          type=>'money', size=>4 },
45                    { field         =>'sec_granularity',
46                      type          =>'select',
47                      options       => [ keys %granularity ],
48                      labels        => \%granularity,
49                      disable_empty => 1,
50                    },
51                    { field         => 'classnum',
52                      type          => 'select-table',
53                      table         => 'usage_class',
54                      name_col      => 'classname',
55                      empty_label   => '(default)',
56                      hashref       => { disabled => '' },
57                    },
58                    { field         => 'upstream_mult_charge', type => 'text', },
59                    { field         => 'upstream_mult_cost', type => 'text', },
60
61                  ],
62      'new_hashref_callback' => sub {
63         { ratenum        => scalar($cgi->param('ratenum')),
64           dest_regionnum => scalar($cgi->param('dest_regionnum')),
65           ratetimenum    => scalar($cgi->param('ratetimenum')),
66           cdrtypenum     => scalar($cgi->param('cdrtypenum')),
67           min_included   => 0,
68           conn_charge    => 0,
69           upstream_mult_charge  => 0,
70           upstream_mult_cost    => 0,
71         }
72       },
73    )
74 %>
75 <%once>
76
77 tie my %granularity, 'Tie::IxHash', FS::rate_detail::granularities();
78 tie my %conn_secs,   'Tie::IxHash', FS::rate_detail::conn_secs();
79
80 </%once>
81 <%init>
82
83 my $conf = new FS::Conf;
84 die "access denied"
85   unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
86
87 #slightly inefficient, i suppose an edit+error callback would be better
88 my $name = 'rate';
89 my ($keywords) = $cgi->keywords;
90 if (    $keywords                    =~ /^(\d+)$/
91      || $cgi->param('ratedetailnum') =~ /^(\d+)$/ ) {
92   my $rate_detail = qsearchs('rate_detail', { 'ratedetailnum' => $1 } )
93     or die "unknown ratedetailnum $1";
94   $name = $rate_detail->rate->ratename. ' rate for '. 
95           ($rate_detail->dest_regionname || 'global default');
96 }
97
98 #sec_granularity should default to 60!  for new rates when this gets used for em
99
100 </%init>