summaryrefslogtreecommitdiff
path: root/httemplate/edit/rate_time.cgi
diff options
context:
space:
mode:
authormark <mark>2010-07-22 00:11:56 +0000
committermark <mark>2010-07-22 00:11:56 +0000
commit342e2bfbe6aad470ab9dee40640f8ac7d9653003 (patch)
treebf350b2d3876651ee0c4487b0e321ec21f839f0c /httemplate/edit/rate_time.cgi
parentc26fea8a168f255412a8065c0a04758c9b0d340d (diff)
cdr rating by day and time, part 2, RT#4763
Diffstat (limited to 'httemplate/edit/rate_time.cgi')
-rw-r--r--httemplate/edit/rate_time.cgi49
1 files changed, 37 insertions, 12 deletions
diff --git a/httemplate/edit/rate_time.cgi b/httemplate/edit/rate_time.cgi
index 230aef82d..eca8fbb61 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",
- ) )
-%>
-
+ ) %>
+<BR>
<% include('/elements/error.html') %>
+<BR>
<FORM METHOD="POST" ACTION="<% "${p}edit/process/rate_time.cgi" %>">
<INPUT TYPE="hidden" NAME="ratetimenum" VALUE="<% $ratetimenum %>">
@@ -15,12 +16,10 @@
</TR>
</TABLE>
<% include('/elements/auto-table.html',
- header => [ 'Start', 'End' ],
- fields => [ 'stime', 'etime' ],
- size => [ 18, 18 ],
- maxl => [ 15, 15 ],
- align => [ 'right', 'right' ],
- data => \@data,
+ 'header' => [ '', 'Start','','', '','End','','' ],
+ 'fields' => [ qw(sd sh sm sa ed eh em ea) ],
+ 'select' => [ ($day, $hour, $min, $ampm) x 2 ],
+ 'data' => \@data,
) %>
<INPUT TYPE="submit" VALUE="<% $rate_time ? 'Apply changes' : 'Add period'%>">
</FORM>
@@ -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',$_) } 0..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,
+ int($_/60) % 60,
+ int($_/43200) % 2, }
+ ( $interval->stime, $interval->etime )
+ ];
+ }
+ }
}
</%init>