X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Frate_time.cgi;h=7ee39efca9860af56029ffbdf4856e1c8deddca9;hb=6f5b68a5dc6a6b145c88aa1b2bad3848cc6f8788;hp=230aef82d3c2cacb5d3b129ed299b9cdd4f33154;hpb=de3bf373e97f6875e09fc17d99068a2716bf3b2d;p=freeside.git
diff --git a/httemplate/edit/rate_time.cgi b/httemplate/edit/rate_time.cgi
index 230aef82d..7ee39efca 100644
--- a/httemplate/edit/rate_time.cgi
+++ b/httemplate/edit/rate_time.cgi
@@ -1,9 +1,10 @@
-<% include("/elements/header.html","$action Time Period", menubar(
+<% include("/elements/header.html", { title => "$action Time Period" }) %>
+<% include("/elements/menubar.html",
'Rate plans' => "${p}browse/rate.cgi",
- ) )
-%>
-
+ ) %>
+
<% include('/elements/error.html') %>
+
@@ -29,16 +28,42 @@
<% include('/elements/footer.html') %>
<%init>
-my $ratetimenum = ($cgi->keywords)[0] || '';
+my $ratetimenum = ($cgi->keywords)[0] || $cgi->param('ratetimenum') || '';
my $action = 'Add';
my $rate_time;
my @data = ();
+my $day = [ 0 => 'Sun',
+ 1 => 'Mon',
+ 2 => 'Tue',
+ 3 => 'Wed',
+ 4 => 'Thu',
+ 5 => 'Fri',
+ 6 => 'Sat', ];
+my $hour = [ map( {$_, sprintf('%02d',$_) } 12, 1..11 )];
+my $min = [ map( {$_, sprintf('%02d',$_) } 0,30 )];
+my $ampm = [ 0 => 'AM', 1 => 'PM' ];
if($ratetimenum) {
$action = 'Edit';
$rate_time = qsearchs('rate_time', {ratetimenum => $ratetimenum})
or die "ratetimenum $ratetimenum not found";
- @data = $rate_time->description;
+ if($cgi->param('error')) {
+ my %vars = $cgi->Vars;
+ foreach my $i (sort {$a <=> $b } map { /^sd(\d+)$/ } keys(%vars)) {
+ push @data, [ @vars{"sd$i", "sh$i", "sm$i", "sa$i",
+ "ed$i", "eh$i", "em$i", "ea$i"} ];
+ }
+ }
+ else {
+ foreach my $interval ($rate_time->intervals) {
+ push @data, [ map { int($_/86400) % 7,
+ (int($_/3600) % 12 || 12),
+ int($_/60) % 60,
+ int($_/43200) % 2, }
+ ( $interval->stime, $interval->etime )
+ ];
+ }
+ }
}
%init>