Merge branch 'master' of git.freeside.biz:/home/git/freeside
[freeside.git] / httemplate / edit / rate.cgi
1 <% include("/elements/header.html","$action Rate plan", menubar(
2       'View all rate plans' => "${p}browse/rate.cgi",
3     ))
4 %>
5
6 <% include('/elements/progress-init.html',
7               'OneTrueForm',
8               [ 'rate', 'preserve_rate_detail' ], # 'rate', 'min_', 'sec_' ],
9               'process/rate.cgi',
10               $p.'browse/rate.cgi',
11            )
12 %>
13 <FORM NAME="OneTrueForm">
14 <INPUT TYPE="hidden" NAME="ratenum" VALUE="<% $rate->ratenum %>">
15
16 <TABLE CLASS="fsinnerbox">
17
18 <& /elements/tr-select-agent.html,
19      disable_empty => ! $FS::CurrentUser::CurrentUser->access_right('Configuration'), #, 'Edit global CDR rates'
20      empty_label   => '(global)',
21 &>
22
23 <TR>
24   <TD>Rate plan</TD>
25   <TD><INPUT TYPE="text" NAME="ratename" SIZE=32 VALUE="<% $rate->ratename %>"></TD>
26 </TR>
27 </TABLE>
28 <BR>
29
30 <INPUT TYPE="hidden" NAME="preserve_rate_detail" VALUE="1">
31
32 <INPUT NAME="submit" TYPE="button" VALUE="<% 
33   $rate->ratenum ? "Apply changes" : "Add rate plan"
34 %>" onClick="document.OneTrueForm.submit.disabled=true; process();">
35 </FORM>
36
37 % if($rate->ratenum) {
38 <BR><BR><FONT SIZE="+2">Rates in this plan</FONT>
39 % if ( my $select_cdr_type = include('/elements/select-cdr_type.html',
40 %  'curr_value'   => $cdrtypenum,
41 %  'onchange'     => 'form.submit();',
42 %  'name_col'     => 'cdrtypename',
43 %  'value_col'    => 'cdrtypenum',
44 %  'empty_label'  => '(default)',
45 % ) ) {
46 <FORM ACTION="<%$cgi->url%>" METHOD="GET">
47 <INPUT TYPE="hidden" NAME="ratenum" VALUE="<% $rate->ratenum %>">
48 <INPUT TYPE="hidden" NAME="countrycode" VALUE="<% $countrycode %>">
49 <FONT SIZE="+1">Usage type: <% $select_cdr_type %></FONT>
50 </FORM>
51 % }
52
53 <% include('/edit/elements/rate_detail.html',
54             'ratenum'     => $rate->ratenum,
55             'countrycode' => $countrycode,
56             'cdrtypenum'  => $cdrtypenum,
57 ) %>
58 % }
59
60 <% include('/elements/footer.html') %>
61
62 <%init>
63
64 die "access denied"
65   unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
66
67 my $rate;
68 if ( $cgi->param('ratenum') ) {
69   $cgi->param('ratenum') =~ /^(\d+)$/;
70   $rate = qsearchs( 'rate', { 'ratenum' => $1 } );
71 } else { #adding
72   $rate = new FS::rate {};
73 }
74 my $action = $rate->ratenum ? 'Edit' : 'Add';
75
76 my $countrycode = '';
77 if ( $cgi->param('countrycode') =~ /^(\d+)$/ ) {
78   $countrycode = $1;
79 }
80
81 my $cdrtypenum = '';
82 if ( $cgi->param('cdrtypenum') =~ /^(\d+)$/ ) {
83   $cdrtypenum = $1;
84 }
85 </%init>