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