use FS::Record qw( qsearch qsearchs );
use FS::rate;
use FS::rate_region;
+use Tie::IxHash;
@ISA = qw(FS::Record);
=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
%>
<%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') || '$';
{ 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>
#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";
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 = '';