summaryrefslogtreecommitdiff
path: root/httemplate/edit/rate.cgi
blob: 5bfc108c1c2445bbb586166fb4e4a71677de7b97 (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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<& /elements/header.html,
  "$action Rate plan",
  menubar(
      'View all rate plans' => "${p}browse/rate.cgi",
      'View packages that use this plan' => "${p}browse/part_pkg.cgi?ratenum="
                                            . $rate->ratenum,
  )
&>

<% include('/elements/progress-init.html',
              'OneTrueForm',
              [ 'rate', 'agentnum' ],
              'process/rate.cgi',
              $p.'browse/rate.cgi',
           )
%>
<FORM NAME="OneTrueForm">
<INPUT TYPE="hidden" NAME="ratenum" VALUE="<% $rate->ratenum %>">

<TABLE CLASS="fsinnerbox">

<& /elements/tr-select-agent.html,
     disable_empty => ! $FS::CurrentUser::CurrentUser->access_right('Configuration'), #, 'Edit global CDR rates'
     empty_label   => '(global)',
&>

<TR>
  <TD>Rate plan</TD>
  <TD><INPUT TYPE="text" NAME="ratename" SIZE=32 VALUE="<% $rate->ratename %>"></TD>
</TR>
</TABLE>
<BR>

<INPUT NAME="submit" TYPE="button" VALUE="<% 
  $rate->ratenum ? "Apply changes" : "Add rate plan"
%>" onClick="document.OneTrueForm.submit.disabled=true; process();">
</FORM>

% if($rate->ratenum) {
<BR><BR><FONT SIZE="+2">Rates in this plan</FONT>
% if ( my $select_cdr_type = include('/elements/select-cdr_type.html',
%  'curr_value'   => $cdrtypenum,
%  'onchange'     => 'form.submit();',
%  'name_col'     => 'cdrtypename',
%  'value_col'    => 'cdrtypenum',
%  'empty_label'  => '(default)',
% ) ) {
<FORM ACTION="<%$cgi->url%>" METHOD="GET">
<INPUT TYPE="hidden" NAME="ratenum" VALUE="<% $rate->ratenum %>">
<INPUT TYPE="hidden" NAME="countrycode" VALUE="<% $countrycode %>">
<FONT SIZE="+1">Usage type: <% $select_cdr_type %></FONT>
</FORM>
% }

<% include('/edit/elements/rate_detail.html',
            'ratenum'     => $rate->ratenum,
            'countrycode' => $countrycode,
            'cdrtypenum'  => $cdrtypenum,
) %>
% }

<% include('/elements/footer.html') %>

<%init>

die "access denied"
  unless $FS::CurrentUser::CurrentUser->access_right('Configuration');

my $rate;
if ( $cgi->param('ratenum') ) {
  $cgi->param('ratenum') =~ /^(\d+)$/;
  $rate = qsearchs( 'rate', { 'ratenum' => $1 } );
} else { #adding
  $rate = new FS::rate {};
}
my $action = $rate->ratenum ? 'Edit' : 'Add';

my $countrycode = '';
if ( $cgi->param('countrycode') =~ /^(\d+)$/ ) {
  $countrycode = $1;
}

my $cdrtypenum = '';
if ( $cgi->param('cdrtypenum') =~ /^(\d+)$/ ) {
  $cdrtypenum = $1;
}
</%init>