summaryrefslogtreecommitdiff
path: root/httemplate/browse/rate.cgi
blob: c6cfec074b3eb8ae1f6820d0296fbadcbdd15e03 (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
<% include( 'elements/browse.html',
              'title'       => 'Rate plans',
              'menubar'     => [ 'Regions and Prefixes' =>
                                   $p.'browse/rate_region.html',
                                 'Time Periods' =>
                                   $p.'browse/rate_time.html',
                               ],
              'html_init'   => $html_init,
              'name'        => 'rate plans',
              'query'       => { 'table'     => 'rate',
                                 'hashref'   => {},
                                 'order_by' => 'ORDER BY ratenum',
                               },
              'count_query' => $count_query,
              'header'      => [ '#',       'Rate plan', 'Rates'    ],
              'fields'      => [ 'ratenum', 'ratename',  $rates_sub ],
              'links'       => [ $link,     $link,       ''         ],
          )
%>
<%once>

my $all_countrycodes = join("\n", map qq(<OPTION VALUE="$_">$_),
                                      FS::rate_prefix->all_countrycodes
                           );

my $rates_sub = sub {
  my $rate = shift;
  my $ratenum = $rate->ratenum;

  qq( <FORM METHOD="GET" ACTION="${p}browse/rate_detail.html">
        <INPUT TYPE="hidden" NAME="ratenum" VALUE="$ratenum">
        <SELECT NAME="countrycode" onChange="this.form.submit();">
          <OPTION SELECTED>Select Country Code
          <OPTION VALUE="">(all)
          $all_countrycodes
        </SELECT>
      </FORM>
    );


};

my $html_init = 
  'Rate plans for VoIP and call billing.<BR><BR>'.
  qq!<A HREF="${p}edit/rate.cgi"><I>Add a rate plan</I></A>!.
  qq! | <A HREF="${p}misc/copy-rate_detail.html"><I>Copy rates between plans</I></A>!.
  '<BR><BR>
   <SCRIPT>
   function rate_areyousure(href) {
    if (confirm("Are you sure you want to delete this rate plan?") == true)
      window.location.href = href;
   }
   </SCRIPT>
  ';

my $count_query = 'SELECT COUNT(*) FROM rate';

my $link = [ $p.'edit/rate.cgi?', 'ratenum' ];

</%once>
<%init>

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

</%init>