X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fedit%2Frate_time.cgi;h=9e6b8736c75fcdc7f279147bea54638e0a378edc;hp=230aef82d3c2cacb5d3b129ed299b9cdd4f33154;hb=b71b1576c68bc40ad26592b354feace37a029f0e;hpb=de3bf373e97f6875e09fc17d99068a2716bf3b2d 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') %> +
"> @@ -14,14 +15,34 @@ -<% include('/elements/auto-table.html', - header => [ 'Start', 'End' ], - fields => [ 'stime', 'etime' ], - size => [ 18, 18 ], - maxl => [ 15, 15 ], - align => [ 'right', 'right' ], - data => \@data, - ) %> + + + + + + +% for my $pre (qw(s e)) { +% for my $f (qw(d h m a)) { # day, hour, minute, am/pm + +% } #$f +% } #$pre + +<& /elements/auto-table.html, + 'template_row' => 'mytemplate', + 'data' => \@data, + 'fieldorder' => [qw(sd sh sm sa ed eh em ea)], +&> +
StartEnd
+ +

@@ -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 ) + ]; + } + } }