02d670fbd50b0f1435f9fde96a62bddcf4efe58e
[freeside.git] / httemplate / browse / rate.cgi
1 <% include( 'elements/browse.html',
2               'title'       => 'Rate plans',
3               'menubar'     => [ 'Regions and Prefixes' =>
4                                    $p.'browse/rate_region.html',
5                                ],
6               'html_init'   => $html_init,
7               'name'        => 'rate plans',
8               'query'       => { 'table'     => 'rate',
9                                  'hashref'   => {},
10                                  'extra_sql' => 'ORDER BY ratenum',
11                                },
12               'count_query' => $count_query,
13               'header'      => [ '#',       'Rate plan', 'Rates'    ],
14               'fields'      => [ 'ratenum', 'ratename',  $rates_sub ],
15               'links'       => [ $link,     $link,       ''         ],
16           )
17 %>
18 <%once>
19
20 my $all_countrycodes = join("\n", map qq(<OPTION VALUE="$_">$_),
21                                       FS::rate_prefix->all_countrycodes
22                            );
23
24 my $rates_sub = sub {
25   my $rate = shift;
26   my $ratenum = $rate->ratenum;
27
28   qq( <FORM METHOD="GET" ACTION="${p}browse/rate_detail.html">
29         <INPUT TYPE="hidden" NAME="ratenum" VALUE="$ratenum">
30         <SELECT NAME="countrycode" onChange="this.form.submit();">
31           <OPTION SELECTED>Select Country Code
32           <OPTION VALUE="">(all)
33           $all_countrycodes
34         </SELECT>
35       </FORM>
36     );
37
38
39 };
40
41 my $html_init = 
42   'Rate plans for VoIP and call billing.<BR><BR>'.
43   qq!<A HREF="${p}edit/rate.cgi"><I>Add a rate plan</I></A>!.
44   qq! | <A HREF="${p}misc/copy-rate_detail.html"><I>Copy rates between plans</I></A>!.
45   '<BR><BR>
46    <SCRIPT>
47    function rate_areyousure(href) {
48     if (confirm("Are you sure you want to delete this rate plan?") == true)
49       window.location.href = href;
50    }
51    </SCRIPT>
52   ';
53
54 my $count_query = 'SELECT COUNT(*) FROM rate';
55
56 my $link = [ $p.'edit/rate.cgi?', 'ratenum' ];
57
58 </%once>
59 <%init>
60
61 die "access denied"
62   unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
63
64 </%init>