X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Frate_time.cgi;h=9e6b8736c75fcdc7f279147bea54638e0a378edc;hb=63973c641c4be00765fa27e55c57cc5b9aa4da19;hp=230aef82d3c2cacb5d3b129ed299b9cdd4f33154;hpb=de3bf373e97f6875e09fc17d99068a2716bf3b2d;p=freeside.git
diff --git a/httemplate/edit/rate_time.cgi b/httemplate/edit/rate_time.cgi
index 230aef82d..9e6b8736c 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 +50,47 @@
<% 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' ];
+my %choices = (
+ 'd' => $day,
+ 'h' => $hour,
+ 'm' => $min,
+ 'a' => $ampm,
+);
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>