1 <% include("/elements/header.html", { title => "$action Time Period" }) %>
2 <% include("/elements/menubar.html",
3 'Rate plans' => "${p}browse/rate.cgi",
6 <% include('/elements/error.html') %>
9 <FORM METHOD="POST" ACTION="<% "${p}edit/process/rate_time.cgi" %>">
10 <INPUT TYPE="hidden" NAME="ratetimenum" VALUE="<% $ratetimenum %>">
11 <% ntable('#cccccc',2) %>
14 <TH ALIGN="right">Period name</TH>
15 <TD><INPUT TYPE="text" NAME="ratetimename" VALUE="<% $rate_time ? $rate_time->ratetimename : '' %>"></TD>
20 <TH COLSPAN=4 ALIGN="center">Start</TH>
21 <TH COLSPAN=4 ALIGN="center">End</TH>
24 % for my $pre (qw(s e)) {
25 % for my $f (qw(d h m a)) { # day, hour, minute, am/pm
27 <SELECT NAME="<%$pre.$f%>">
29 % while ($i < @{ $choices{$f} }) {
30 <OPTION VALUE="<%$choices{$f}[$i]%>">
32 <%$choices{$f}[$i]%></OPTION>
40 <& /elements/auto-table.html,
41 'template_row' => 'mytemplate',
43 'fieldorder' => [qw(sd sh sm sa ed eh em ea)],
46 <INPUT TYPE="submit" VALUE="<% $rate_time ? 'Apply changes' : 'Add period'%>">
49 <A HREF="<% "${p}edit/process/rate_time.cgi?ratetimenum=$ratetimenum;delete=1" %>">Delete this period</A>
50 <% include('/elements/footer.html') %>
53 my $ratetimenum = ($cgi->keywords)[0] || $cgi->param('ratetimenum') || '';
57 my $day = [ 0 => 'Sun',
64 my $hour = [ map( {$_, sprintf('%02d',$_) } 12, 1..11 )];
65 my $min = [ map( {$_, sprintf('%02d',$_) } 0,30 )];
66 my $ampm = [ 0 => 'AM', 1 => 'PM' ];
75 $rate_time = qsearchs('rate_time', {ratetimenum => $ratetimenum})
76 or die "ratetimenum $ratetimenum not found";
77 if($cgi->param('error')) {
78 my %vars = $cgi->Vars;
79 foreach my $i (sort {$a <=> $b } map { /^sd(\d+)$/ } keys(%vars)) {
80 push @data, [ @vars{"sd$i", "sh$i", "sm$i", "sa$i",
81 "ed$i", "eh$i", "em$i", "ea$i"} ];
85 foreach my $interval ($rate_time->intervals) {
86 push @data, [ map { int($_/86400) % 7,
87 (int($_/3600) % 12 || 12),
90 ( $interval->stime, $interval->etime )