% include("/elements/header.html", { title => "$action Time Period" }) %>
<% include("/elements/menubar.html",
'Rate plans' => "${p}browse/rate.cgi",
) %>
<% include('/elements/error.html') %>
">Delete this period
<% include('/elements/footer.html') %>
<%init>
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";
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>