show imported region and rate #s, RT#83146
[freeside.git] / httemplate / browse / rate.cgi
index 02d670f..79bebad 100644 (file)
@@ -1,18 +1,20 @@
 <% include( 'elements/browse.html',
               'title'       => 'Rate plans',
-              'menubar'     => [ 'Regions and Prefixes' =>
-                                   $p.'browse/rate_region.html',
-                               ],
+              'menubar'     => \@menubar,
               'html_init'   => $html_init,
               'name'        => 'rate plans',
               'query'       => { 'table'     => 'rate',
                                  'hashref'   => {},
-                                 'extra_sql' => 'ORDER BY ratenum',
+                                 'order_by' => 'ORDER BY ratenum',
                                },
               'count_query' => $count_query,
-              'header'      => [ '#',       'Rate plan', 'Rates'    ],
-              'fields'      => [ 'ratenum', 'ratename',  $rates_sub ],
-              'links'       => [ $link,     $link,       ''         ],
+              'header'      => \@header,
+              'fields'      => \@fields,
+              'links'       => \@links,
+              'agent_virt'  => 1,
+              'agent_pos'   => 1,
+              'agent_null_right' => 'Configuration', #'Edit global CDR rates',
+              'really_disable_download' => 1
           )
 %>
 <%once>
@@ -25,7 +27,7 @@ my $rates_sub = sub {
   my $rate = shift;
   my $ratenum = $rate->ratenum;
 
-  qq( <FORM METHOD="GET" ACTION="${p}browse/rate_detail.html">
+  qq( <FORM METHOD="GET" ACTION="${p}edit/rate.cgi">
         <INPUT TYPE="hidden" NAME="ratenum" VALUE="$ratenum">
         <SELECT NAME="countrycode" onChange="this.form.submit();">
           <OPTION SELECTED>Select Country Code
@@ -53,12 +55,39 @@ my $html_init =
 
 my $count_query = 'SELECT COUNT(*) FROM rate';
 
-my $link = [ $p.'edit/rate.cgi?', 'ratenum' ];
+my $link = [ $p.'edit/rate.cgi?ratenum=', 'ratenum' ];
 
 </%once>
 <%init>
 
+my $curuser = $FS::CurrentUser::CurrentUser;
+
 die "access denied"
-  unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
+  unless $curuser->access_right('Edit CDR rates')
+  #||     $curuser->access_right('Edit global CDR rates')
+  ||     $curuser->access_right('Configuration');
+
+my @menubar;
+if ( $curuser->access_right('Configuration') ) { #, 'Edit global CDR rates') ) {
+  push @menubar,
+    'Regions and Prefixes' => $p.'browse/rate_region.html',
+    'Time Periods'         => $p.'browse/rate_time.html',
+    'CDR Types'            => $p.'edit/cdr_type.cgi',
+  ;
+}
+
+my @header = ();
+my @fields = ();
+my @links = ();
+
+if ( FS::Record->scalar_sql('SELECT 1 FROM rate WHERE agent_rateid IS NOT NULL LIMIT 1') ) {
+  push @header, 'Legacy #';
+  push @fields, 'agent_rateid';
+  push @links, $link;
+}
+
+push @header, 'Rate plan', 'Rates';
+push @fields, 'ratename',  $rates_sub;
+push @links, $link, '';
 
 </%init>