[freeside-commits] freeside/httemplate/edit/process rate_region.cgi, 1.7, 1.8 rate_time.cgi, 1.1, 1.2
Mark Wells
mark at wavetail.420.am
Wed Jul 21 17:11:58 PDT 2010
- Previous message: [freeside-commits] freeside/httemplate/edit rate_region.cgi, 1.13, 1.14 rate.cgi, 1.16, 1.17 rate_time.cgi, 1.1, 1.2
- Next message: [freeside-commits] freeside/httemplate/elements auto-table.html, 1.1, 1.2 menu.html, 1.90, 1.91
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /home/cvs/cvsroot/freeside/httemplate/edit/process
In directory wavetail.420.am:/tmp/cvs-serv30444/httemplate/edit/process
Modified Files:
rate_region.cgi rate_time.cgi
Log Message:
cdr rating by day and time, part 2, RT#4763
Index: rate_region.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/edit/process/rate_region.cgi,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -w -d -r1.7 -r1.8
--- rate_region.cgi 21 Mar 2010 23:13:24 -0000 1.7
+++ rate_region.cgi 22 Jul 2010 00:11:56 -0000 1.8
@@ -1,6 +1,8 @@
%if ( $error ) {
% $cgi->param('error', $error);
<% $cgi->redirect(popurl(2). "rate_region.cgi?". $cgi->query_string ) %>
+%} elsif ( $action eq 'Add' ) {
+<% $cgi->redirect(popurl(2). "rate_region.cgi?$regionnum") %>
%} else {
<% $cgi->redirect(popurl(3). "browse/rate_region.html") %>
%}
@@ -11,6 +13,7 @@
unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
my $regionnum = $cgi->param('regionnum');
+my $action = $regionnum ? 'Edit' : 'Add';
my $old = qsearchs('rate_region', { 'regionnum' => $regionnum } ) if $regionnum;
@@ -33,24 +36,12 @@
'npa' => $_,
}
} @npa;
-
-my @dest_detail = map {
- my $ratenum = $_->ratenum;
- new FS::rate_detail {
- 'ratenum' => $ratenum,
- map { $_ => $cgi->param("$_$ratenum") }
- qw( min_included conn_charge conn_sec min_charge sec_granularity classnum )
- };
-} qsearch('rate', {} );
-
-
+# we no longer process dest_detail records here
my $error;
if ( $regionnum ) {
- $error = $new->replace($old, 'rate_prefix' => \@rate_prefix,
- 'dest_detail' => \@dest_detail, );
+ $error = $new->replace($old, 'rate_prefix' => \@rate_prefix );
} else {
- $error = $new->insert( 'rate_prefix' => \@rate_prefix,
- 'dest_detail' => \@dest_detail, );
+ $error = $new->insert( 'rate_prefix' => \@rate_prefix );
$regionnum = $new->getfield('regionnum');
}
Index: rate_time.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/edit/process/rate_time.cgi,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -w -d -r1.1 -r1.2
--- rate_time.cgi 1 Jul 2010 01:53:50 -0000 1.1
+++ rate_time.cgi 22 Jul 2010 00:11:56 -0000 1.2
@@ -44,12 +44,13 @@
$ratetimenum = $rate_time->ratetimenum;
}
+my @new_ints;
if(!$delete and !$error) {
- foreach my $i (map { /stime(\d+)/ } keys(%vars)) {
- my $stime = str2wtime($vars{"stime$i"});
- my $etime = str2wtime($vars{"etime$i"});
- next if !defined($stime) or !defined($etime);
+ foreach my $i (map { /^sd(\d+)$/ } keys(%vars)) {
+ my $stime = l2wtime(@vars{"sd$i", "sh$i", "sm$i", "sa$i"});
+ my $etime = l2wtime(@vars{"ed$i", "eh$i", "em$i", "ea$i"});
#warn "$i: $stime-$etime";
+ next if !defined($stime) or !defined($etime) or $etime == $stime;
# try to avoid needlessly wiping and replacing intervals every
# time this is edited.
if( %old_ints ) {
@@ -63,12 +64,9 @@
next; #$i
}
}
- my $new_int = FS::rate_time_interval->new({ ratetimenum => $ratetimenum,
+ push @new_ints, FS::rate_time_interval->new({ ratetimenum => $ratetimenum,
stime => $stime,
etime => $etime, } );
- $error = $new_int->insert;
- #warn "inserting $stime-$etime\n";
- last if $error;
}
}
if(!$error) {
@@ -78,17 +76,19 @@
last if $error;
}
}
+if(!$error) {
+ # do this last to avoid overlap errors with deleted intervals
+ foreach (@new_ints) {
+ $error = $_->insert;
+ #warn "inserting $stime-$etime\n";
+ last if $error;
+ }
+}
-sub str2wtime {
- my %days;
- @days{qw(Sun Mon Tue Wed Thu Fri Sat)} = (0..6);
- my $str = shift;
- my ($d, $h, $m, $s, $ampm) =
- ($str =~ /^(\w{3}) (\d{2}):(\d{2}):(\d{2}) (\w{2})$/);
- return () if !$d;
- $h += 24*$days{$d} + ($ampm eq 'PM' ? 12 : 0);
+sub l2wtime {
+ my ($d, $h, $m, $a) = @_;
+ $h += 24*$d + 12*$a;
$m += 60*$h;
- $s += 60*$m;
- return $s;
+ return 60*$m
}
</%init>
- Previous message: [freeside-commits] freeside/httemplate/edit rate_region.cgi, 1.13, 1.14 rate.cgi, 1.16, 1.17 rate_time.cgi, 1.1, 1.2
- Next message: [freeside-commits] freeside/httemplate/elements auto-table.html, 1.1, 1.2 menu.html, 1.90, 1.91
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the freeside-commits
mailing list