fixup per call billing
authorjeff <jeff>
Wed, 26 Mar 2008 15:43:08 +0000 (15:43 +0000)
committerjeff <jeff>
Wed, 26 Mar 2008 15:43:08 +0000 (15:43 +0000)
FS/FS/rate_detail.pm
httemplate/browse/rate_detail.html
httemplate/edit/rate_detail.html
httemplate/edit/rate_region.cgi

index ad41b40..533fb1e 100644 (file)
@@ -5,6 +5,7 @@ use vars qw( @ISA );
 use FS::Record qw( qsearch qsearchs );
 use FS::rate;
 use FS::rate_region;
+use Tie::IxHash;
 
 @ISA = qw(FS::Record);
 
@@ -189,6 +190,31 @@ sub dest_prefixes_short {
 
 =back
 
+=head1 SUBROUTINES
+
+=over 4
+
+=item granularities
+
+  Returns an (ordered) hash of granularity => name pairs
+
+=cut
+
+tie my %granularities, 'Tie::IxHash',
+  '1', => '1 second',
+  '6'  => '6 second',
+  '30' => '30 second', # '1/2 minute',
+  '60' => 'minute',
+  '0'  => 'call',
+;
+
+sub granularities {
+  %granularities;
+}
+
+
+=back
+
 =head1 BUGS
 
 =head1 SEE ALSO
index 5dde85f..044d5c6 100644 (file)
 %>
 <%once>
 
-my %granularity = (
-  '1', => '1 second',
-  '6'  => '6 second',
-  '30' => '30 second', # '1/2 minute',
-  '60' => 'minute',
-);
+tie my %granularity, 'Tie::IxHash', FS::rate_detail::granularities();
 
 my $conf = new FS::Conf;
 my $money_char = $conf->config('money_char') || '$';
index b9eaf65..73d2d9b 100644 (file)
@@ -19,7 +19,7 @@
                    { field=>'min_charge',          type=>'money', size=>4 },
                    { field         =>'sec_granularity',
                      type          =>'select',
-                     options       => [qw( 1 6 30 60 )],
+                     options       => [ keys %granularity ],
                      labels        => \%granularity,
                      disable_empty => 1,
                    },
 %>
 <%once>
 
-tie my %granularity, 'Tie::IxHash',
-  '1', => '1 second',
-  '6'  => '6 second',
-  '30' => '30 second', # '1/2 minute',
-  '60' => 'minute',
-;
+tie my %granularity, 'Tie::IxHash', FS::rate_detail::granularities();
 
 </%once>
 
@@ -46,7 +41,8 @@ die "access denied"
 
 #slightly inefficient, i suppose an edit+error callback would be better
 my $name = 'rate';
-if (    $cgi->keywords               =~ /^(\d+)$/
+my ($keywords) = $cgi->keywords;
+if (    $keywords                    =~ /^(\d+)$/
      || $cgi->param('ratedetailnum') =~ /^(\d+)$/ ) {
   my $rate_detail = qsearchs('rate_detail', { 'ratedetailnum' => $1 } )
     or die "unknown ratedetailnum $1";
index 04f285f..c58fc80 100644 (file)
@@ -132,13 +132,7 @@ my $action = $rate_region->regionnum ? 'Edit' : 'Add';
 
 my $p1 = popurl(1);
 
-tie my %granularity, 'Tie::IxHash',
-  '1', => '1 second',
-  '6'  => '6 second',
-  '30' => '30 second', # '1/2 minute',
-  '60' => 'minute',
-  '0'  => 'call',
-;
+tie my %granularity, 'Tie::IxHash', FS::rate_detail::granularities();
 
 my @rate_prefix = $rate_region->rate_prefix;
 my $countrycode = '';