[freeside-commits] branch master updated. a17d255a7678d360c3673a461b091608b181716c

Ivan ivan at 420.am
Thu May 15 14:59:25 PDT 2014


The branch, master has been updated
       via  a17d255a7678d360c3673a461b091608b181716c (commit)
       via  881215feafc01aeee19864c39f0d98d3d6909e65 (commit)
      from  78b44177a16bc4da793da1c461455a0e77d52999 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit a17d255a7678d360c3673a461b091608b181716c
Merge: 881215f 78b4417
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Thu May 15 14:59:21 2014 -0700

    Merge branch 'master' of git.freeside.biz:/home/git/freeside


commit 881215feafc01aeee19864c39f0d98d3d6909e65
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Thu May 15 14:59:14 2014 -0700

    agent-virtualize VoIP rates, RT#29183

diff --git a/FS/FS/AccessRight.pm b/FS/FS/AccessRight.pm
index ecbaa64..de0a557 100644
--- a/FS/FS/AccessRight.pm
+++ b/FS/FS/AccessRight.pm
@@ -359,6 +359,9 @@ tie my %rights, 'Tie::IxHash',
 
     'Bulk edit package definitions',
 
+    'Edit CDR rates',
+    #{ rightname=>'Edit global CDR rates', global=>1, },
+
     'Edit fee definitions',
     { rightname=>'Edit global fee definitions', global=>1 },
 
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm
index 94d7f36..416587d 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -4750,12 +4750,18 @@ sub tables_hashref {
 
     'rate' => {
       'columns' => [
-        'ratenum',  'serial', '', '', '', '', 
-        'ratename', 'varchar', '', $char_d, '', '', 
+        'ratenum',   'serial',     '',      '', '', '', 
+        'ratename', 'varchar',     '', $char_d, '', '', 
+        'agentnum',     'int', 'NULL',      '', '', '',
       ],
       'primary_key' => 'ratenum',
       'unique'      => [],
       'index'       => [],
+      'foreign_keys' => [
+                          { columns    => [ 'agentnum' ],
+                            table      => 'agent',
+                          },
+                        ],
     },
 
     'rate_detail' => {
diff --git a/FS/FS/part_pkg/voip_cdr.pm b/FS/FS/part_pkg/voip_cdr.pm
index 7e21b0f..b8f1eee 100644
--- a/FS/FS/part_pkg/voip_cdr.pm
+++ b/FS/FS/part_pkg/voip_cdr.pm
@@ -12,7 +12,7 @@ use FS::cdr;
 use FS::detail_format;
 #use FS::rate;
 #use FS::rate_prefix;
-#use FS::rate_detail;
+#use FS::rate_detail; #for ::granularities
 
 $DEBUG = 0;
 
@@ -108,19 +108,13 @@ tie my %accountcode_tollfree_field, 'Tie::IxHash',
                   },
 
     'ratenum'   => { 'name' => 'Rate plan',
-                     'type' => 'select',
-                     'select_table' => 'rate',
-                     'select_key'   => 'ratenum',
-                     'select_label' => 'ratename',
+                     'type' => 'select-rate',
                    },
                    
     'intrastate_ratenum'   => { 'name' => 'Optional alternate intrastate rate plan',
-                     'type' => 'select',
-                     'select_table' => 'rate',
-                     'select_key'   => 'ratenum',
-                     'select_label' => 'ratename',
+                     'type' => 'select-rate',
                      'disable_empty' => 0,
-                     'empty_label'   => '',
+                     'empty_label'   => ' ',
                    },
 
     'calls_included' => { 'name' => 'Number of calls included at no usage charge', },
diff --git a/FS/FS/part_pkg/voip_sqlradacct.pm b/FS/FS/part_pkg/voip_sqlradacct.pm
index f58194f..a205f9f 100644
--- a/FS/FS/part_pkg/voip_sqlradacct.pm
+++ b/FS/FS/part_pkg/voip_sqlradacct.pm
@@ -19,10 +19,7 @@ $DEBUG = 1;
   'inherit_fields' => [ 'global_Mixin' ],
   'fields' => {
     'ratenum'   => { 'name' => 'Rate plan',
-                     'type' => 'select',
-                     'select_table' => 'rate',
-                     'select_key'   => 'ratenum',
-                     'select_label' => 'ratename',
+                     'type' => 'select-rate',
                    },
   },
   'fieldorder' => [qw( ratenum ignore_unrateable )],
diff --git a/FS/FS/rate.pm b/FS/FS/rate.pm
index 4052807..b2348ca 100644
--- a/FS/FS/rate.pm
+++ b/FS/FS/rate.pm
@@ -4,6 +4,7 @@ use base qw(FS::Record);
 use strict;
 use vars qw( $DEBUG );
 use FS::Record qw( qsearch qsearchs dbh fields );
+#use FS::agent; #causes a weird dep loop in freeside-cdrrated, only needed for v3-style manual FK-checking, so, probably not bother
 use FS::rate_detail;
 
 $DEBUG = 0;
@@ -34,10 +35,18 @@ FS::Record.  The following fields are currently supported:
 
 =over 4
 
-=item ratenum - primary key
+=item ratenum
+
+primary key
 
 =item ratename
 
+Rate name
+
+=item agentnum
+
+Optional agent (see L<FS::agent>) for agent-virtualized rates.
+
 =back
 
 =head1 METHODS
@@ -253,15 +262,13 @@ and replace methods.
 
 =cut
 
-# the check method should currently be supplied - FS::Record contains some
-# data checking routines
-
 sub check {
   my $self = shift;
 
   my $error =
        $self->ut_numbern('ratenum')
     || $self->ut_text('ratename')
+    #|| $self->ut_foreign_keyn('agentnum', 'agent', 'agentnum')
   ;
   return $error if $error;
 
diff --git a/httemplate/browse/rate.cgi b/httemplate/browse/rate.cgi
index 0c425a5..ea59a0c 100644
--- a/httemplate/browse/rate.cgi
+++ b/httemplate/browse/rate.cgi
@@ -1,12 +1,6 @@
 <% include( 'elements/browse.html',
               'title'       => 'Rate plans',
-              'menubar'     => [ 'Regions and Prefixes' =>
-                                   $p.'browse/rate_region.html',
-                                 'Time Periods' =>
-                                   $p.'browse/rate_time.html',
-                                 'CDR Types' =>
-                                   $p.'edit/cdr_type.cgi',
-                               ],
+              'menubar'     => \@menubar,
               'html_init'   => $html_init,
               'name'        => 'rate plans',
               'query'       => { 'table'     => 'rate',
@@ -17,6 +11,9 @@
               'header'      => [ '#',       'Rate plan', 'Rates'    ],
               'fields'      => [ 'ratenum', 'ratename',  $rates_sub ],
               'links'       => [ $link,     $link,       ''         ],
+              'agent_virt'  => 1,
+              'agent_pos'   => 1,
+              'agent_null_right' => 'Configuration', #'Edit global CDR rates',
               'really_disable_download' => 1
           )
 %>
@@ -63,7 +60,20 @@ 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',
+  ;
+}
 
 </%init>
diff --git a/httemplate/edit/part_pkg.cgi b/httemplate/edit/part_pkg.cgi
index c7d314c..2d2c070 100755
--- a/httemplate/edit/part_pkg.cgi
+++ b/httemplate/edit/part_pkg.cgi
@@ -972,7 +972,15 @@ my $html_bottom = sub {
                    ? ' CHECKED'
                    : ''
                  ). '>';
-  
+
+      } elsif ( $href->{$field}{'type'} eq 'select-rate' ) {
+
+        $html .= include('/elements/select-rate.html',
+                           map { $_ => $href->{$field}{$_} }
+                             grep { $_ !~ /^(name|type)$/ }
+                               keys %{ $href->{$field} }
+                        );
+
       } elsif ( $href->{$field}{'type'} =~ /^select/ ) {
   
         $html .= '<SELECT';
diff --git a/httemplate/edit/rate.cgi b/httemplate/edit/rate.cgi
index 1abfb0d..652c1a6 100644
--- a/httemplate/edit/rate.cgi
+++ b/httemplate/edit/rate.cgi
@@ -13,9 +13,19 @@
 <FORM NAME="OneTrueForm">
 <INPUT TYPE="hidden" NAME="ratenum" VALUE="<% $rate->ratenum %>">
 
-Rate plan
-<INPUT TYPE="text" NAME="ratename" SIZE=32 VALUE="<% $rate->ratename %>">
-<BR><BR>
+<TABLE CLASS="fsinnerbox">
+
+<& /elements/tr-select-agent.html,
+     disable_empty => ! $FS::CurrentUser::CurrentUser->access_right('Configuration'), #, 'Edit global CDR rates'
+     empty_label   => '(global)',
+&>
+
+<TR>
+  <TD>Rate plan</TD>
+  <TD><INPUT TYPE="text" NAME="ratename" SIZE=32 VALUE="<% $rate->ratename %>"></TD>
+</TR>
+</TABLE>
+<BR>
 
 <INPUT TYPE="hidden" NAME="preserve_rate_detail" VALUE="1">
 
diff --git a/httemplate/elements/menu.html b/httemplate/elements/menu.html
index 7abd76a..de5ea19 100644
--- a/httemplate/elements/menu.html
+++ b/httemplate/elements/menu.html
@@ -615,15 +615,19 @@ tie my %config_sales, 'Tie::IxHash',
   'Sales People' => [ $fsurl.'browse/sales.html', 'Sales people bring in new business.' ],
 ;
 
-tie my %config_billing_rates, 'Tie::IxHash',
-  'Rate plans' => [ $fsurl.'browse/rate.cgi', 'Manage rate plans' ],
-  'Regions and prefixes' => [ $fsurl.'browse/rate_region.html', 'Manage regions and prefixes' ],
-  'Usage classes'  => [ $fsurl.'browse/usage_class.html', 'Usage classes define groups of usage for taxation.' ],
-  'Time periods' => [ $fsurl.'browse/rate_time.html', 'Time periods define days and hours for rate plans' ],
-  'Edit rates with Excel' => [ $fsurl.'misc/rate_edit_excel.html', 'Download and edit rates with Excel, then upload changes.' ], #"Edit with Excel" ?
-  'separator'     => '', #its a separator!
-  'Tiering plans' => [ $fsurl.'browse/rate_tier.html', 'Rating tiers' ],
-;
+tie my %config_billing_rates, 'Tie::IxHash';
+$config_billing_rates{'Rate plans'} = [ $fsurl.'browse/rate.cgi', 'Manage rate plans' ]
+  if $curuser->access_right('Edit CDR rates')
+  #|| $curuser->access_right('Edit global CDR rates')
+  || $curuser->access_right('Configuration');
+if ( $curuser->access_right('Configuration') ) {
+  $config_billing_rates{'Regions and prefixes'} = [ $fsurl.'browse/rate_region.html', 'Manage regions and prefixes' ];
+  $config_billing_rates{'Usage classes'} = [ $fsurl.'browse/usage_class.html', 'Usage classes define groups of usage for taxation.' ];
+  $config_billing_rates{'Time periods'} = [ $fsurl.'browse/rate_time.html', 'Time periods define days and hours for rate plans' ];
+  $config_billing_rates{'Edit rates with Excel'} = [ $fsurl.'misc/rate_edit_excel.html', 'Download and edit rates with Excel, then upload changes.' ]; #"Edit with Excel" ?
+  $config_billing_rates{'separator'} = ''; #its a separator!
+  $config_billing_rates{'Tiering plans'} = [ $fsurl.'browse/rate_tier.html', 'Rating tiers' ];
+}
 
 tie my %config_billing, 'Tie::IxHash';
 #  'Payment gateways'         => [ $fsurl.'browse/payment_gateway.html', 'Credit card and electronic check processors' ];
@@ -636,7 +640,10 @@ if ( $curuser->access_right('Configuration') ) {
   $config_billing{'Invoice templates'}      = [ $fsurl.'browse/invoice_template.html', 'Edit templates for HTML, plaintext and typeset invoices' ];
   $config_billing{'separator'} = ''; #its a separator!
   $config_billing{'Prepaid cards'}          = [ $fsurl.'search/prepay_credit.html', 'View outstanding cards, generate new cards' ];
-  $config_billing{'Call rates and regions'} = [ \%config_billing_rates, 'Manage rate plans, regions and prefixes for VoIP and call billing' ];
+}
+$config_billing{'Call rates and regions'} = [ \%config_billing_rates, 'Manage rate plans, regions and prefixes for VoIP and call billing' ]
+  if keys %config_billing_rates;
+if ( $curuser->access_right('Configuration') ) {
   $config_billing{'separator2'} = ''; #its a separator!
 
   my $config_taxes_name = 'Locales and tax rates'.
diff --git a/httemplate/elements/select-rate.html b/httemplate/elements/select-rate.html
index 83a7add..4f2a1b2 100644
--- a/httemplate/elements/select-rate.html
+++ b/httemplate/elements/select-rate.html
@@ -1,9 +1,10 @@
-<% include( '/elements/select-table.html',
-                 'table'       => 'rate',
-                 'name_col'    => 'ratename',
-                 'empty_label' => 'Select rate plan',
-                 #'hashref'     => { 'disabled' => '' },
-                 'order_by'    => ' ORDER BY ratenum', #ratename ?
-                 @_,
-             )
-%>
+<& /elements/select-table.html,
+     'table'            => 'rate',
+     'name_col'         => 'ratename',
+     'empty_label'      => 'Select rate plan',
+     #'hashref'          => { 'disabled' => '' },
+     'order_by'         => ' ORDER BY ratenum', #ratename ?
+     'agent_virt'       => 1,
+     'agent_null_right' => 'Configuration', #'Edit global CDR rates'
+     @_,
+&>

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/AccessRight.pm                 |    3 +++
 FS/FS/Schema.pm                      |   10 ++++++++--
 FS/FS/part_pkg/voip_cdr.pm           |   14 ++++----------
 FS/FS/part_pkg/voip_sqlradacct.pm    |    5 +----
 FS/FS/rate.pm                        |   15 +++++++++++----
 httemplate/browse/rate.cgi           |   26 ++++++++++++++++++--------
 httemplate/edit/part_pkg.cgi         |   10 +++++++++-
 httemplate/edit/rate.cgi             |   16 +++++++++++++---
 httemplate/elements/menu.html        |   27 +++++++++++++++++----------
 httemplate/elements/select-rate.html |   19 ++++++++++---------
 10 files changed, 94 insertions(+), 51 deletions(-)




More information about the freeside-commits mailing list