This commit was generated by cvs2svn to compensate for changes in r6252,
[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 $sth = dbh->prepare("SELECT DISTINCT(countrycode) FROM rate_prefix")
21   or die dbh->errstr;
22 $sth->execute or die $sth->errstr;
23 my @all_countrycodes = map $_->[0], @{ $sth->fetchall_arrayref };
24 my $all_countrycodes = join("\n", map qq(<OPTION VALUE="$_">$_),
25                                       @all_countrycodes
26                            );
27
28 my $rates_sub = sub {
29   my $rate = shift;
30   my $ratenum = $rate->ratenum;
31
32   qq( <FORM METHOD="GET" ACTION="${p}browse/rate_detail.html">
33         <INPUT TYPE="hidden" NAME="ratenum" VALUE="$ratenum">
34         <SELECT NAME="countrycode" onChange="this.form.submit();">
35           <OPTION SELECTED>Select Country Code
36           <OPTION VALUE="">(all)
37           $all_countrycodes
38         </SELECT>
39       </FORM>
40     );
41
42
43 };
44
45 </%once>
46 <%init>
47
48 die "access denied"
49   unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
50
51 my $html_init = 
52   'Rate plans for VoIP and call billing.<BR><BR>'.
53   qq!<A HREF="${p}edit/rate.cgi"><I>Add a rate plan</I></A>!.
54   '<BR><BR>
55    <SCRIPT>
56    function rate_areyousure(href) {
57     if (confirm("Are you sure you want to delete this rate plan?") == true)
58       window.location.href = href;
59    }
60    </SCRIPT>
61   ';
62
63 my $count_query = 'SELECT COUNT(*) FROM rate';
64
65 my $link = [ $p.'edit/rate.cgi?', 'ratenum' ];
66
67 </%init>