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', 'agentnum' ],
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 NAME="submit" TYPE="button" VALUE="<% 
31   $rate->ratenum ? "Apply changes" : "Add rate plan"
32 %>" onClick="document.OneTrueForm.submit.disabled=true; process();">
33 </FORM>
34
35 % if($rate->ratenum) {
36 <BR><BR><FONT SIZE="+2">Rates in this plan</FONT>
37 % if ( my $select_cdr_type = include('/elements/select-cdr_type.html',
38 %  'curr_value'   => $cdrtypenum,
39 %  'onchange'     => 'form.submit();',
40 %  'name_col'     => 'cdrtypename',
41 %  'value_col'    => 'cdrtypenum',
42 %  'empty_label'  => '(default)',
43 % ) ) {
44 <FORM ACTION="<%$cgi->url%>" METHOD="GET">
45 <INPUT TYPE="hidden" NAME="ratenum" VALUE="<% $rate->ratenum %>">
46 <INPUT TYPE="hidden" NAME="countrycode" VALUE="<% $countrycode %>">
47 <FONT SIZE="+1">Usage type: <% $select_cdr_type %></FONT>
48 </FORM>
49 % }
50
51 <% include('/edit/elements/rate_detail.html',
52             'ratenum'     => $rate->ratenum,
53             'countrycode' => $countrycode,
54             'cdrtypenum'  => $cdrtypenum,
55 ) %>
56 % }
57
58 <% include('/elements/footer.html') %>
59
60 <%init>
61
62 die "access denied"
63   unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
64
65 my $rate;
66 if ( $cgi->param('ratenum') ) {
67   $cgi->param('ratenum') =~ /^(\d+)$/;
68   $rate = qsearchs( 'rate', { 'ratenum' => $1 } );
69 } else { #adding
70   $rate = new FS::rate {};
71 }
72 my $action = $rate->ratenum ? 'Edit' : 'Add';
73
74 my $countrycode = '';
75 if ( $cgi->param('countrycode') =~ /^(\d+)$/ ) {
76   $countrycode = $1;
77 }
78
79 my $cdrtypenum = '';
80 if ( $cgi->param('cdrtypenum') =~ /^(\d+)$/ ) {
81   $cdrtypenum = $1;
82 }
83 </%init>