[freeside-commits] freeside/httemplate/edit rate_region.cgi, 1.13, 1.14 rate.cgi, 1.16, 1.17 rate_time.cgi, 1.1, 1.2
Mark Wells
mark at wavetail.420.am
Wed Jul 21 17:11:58 PDT 2010
Update of /home/cvs/cvsroot/freeside/httemplate/edit
In directory wavetail.420.am:/tmp/cvs-serv30444/httemplate/edit
Modified Files:
rate_region.cgi rate.cgi rate_time.cgi
Log Message:
cdr rating by day and time, part 2, RT#4763
Index: rate_region.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/edit/rate_region.cgi,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -w -d -r1.13 -r1.14
--- rate_region.cgi 21 Mar 2010 23:13:24 -0000 1.13
+++ rate_region.cgi 22 Jul 2010 00:11:55 -0000 1.14
@@ -35,113 +35,19 @@
</TABLE>
-%# rate plan info
-
-<BR>
-
-<% include('/elements/table-grid.html') %>
-% my $bgcolor1 = '#eeeeee';
-% my $bgcolor2 = '#ffffff';
-% my $bgcolor = '';
-
- <TR>
- <TH CLASS="grid" BGCOLOR="#cccccc">
- Rate plan
- </TH>
- <TH CLASS="grid" BGCOLOR="#cccccc">
- <FONT SIZE=-1>Included<BR>minutes/calls</FONT>
- </TH>
- <TH CLASS="grid" BGCOLOR="#cccccc">
- <FONT SIZE=-1>Connection<BR>charge</FONT>
- </TH>
- <TH CLASS="grid" BGCOLOR="#cccccc">
- <FONT SIZE=-1>Connection<BR>charge for</FONT>
- </TH>
- <TH CLASS="grid" BGCOLOR="#cccccc">
- <FONT SIZE=-1>Charge per<BR>minute/call</FONT>
- </TH>
- <TH CLASS="grid" BGCOLOR="#cccccc">
- <FONT SIZE=-1>Granularity</FONT>
- </TH>
- <TH CLASS="grid" BGCOLOR="#cccccc">
- <FONT SIZE=-1>Usage class</FONT>
- </TH>
- </TR>
-
-% foreach my $rate ( qsearch('rate', {}) ) {
-%
-% my $n = $rate->ratenum;
-% my $rate_detail = $rate->dest_detail($rate_region)
-% || new FS::rate_region { 'min_included' => 0,
-% 'min_charge' => 0,
-% 'sec_granularity' => '60'
-% };
-%
-% if ( $bgcolor eq $bgcolor1 ) {
-% $bgcolor = $bgcolor2;
-% } else {
-% $bgcolor = $bgcolor1;
-% }
-
- <TR>
-
- <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
- <A HREF="<%$p%>edit/rate.cgi?<% $rate->ratenum %>"><% $rate->ratename %></A>
- </TD>
-
- <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
- <INPUT TYPE="text" SIZE=9 NAME="min_included<%$n%>" VALUE="<% $cgi->param("min_included$n") || $rate_detail->min_included |h %>">
- </TD>
-
- <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
- <%$money_char%><INPUT TYPE="text" SIZE=9 NAME="conn_charge<%$n%>" VALUE="<% $cgi->param("conn_charge$n") || $rate_detail->conn_charge |h %>">
- </TD>
-
- <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
- <SELECT NAME="conn_sec<%$n%>">
-% foreach my $conn_sec ( keys %conn_secs ) {
-% my $curr_value = $cgi->param("conn_sec$n") || $rate_detail->conn_sec;
-% my $selected = ($conn_sec==$curr_value) ? ' SELECTED' : '';
- <OPTION VALUE="<% $conn_sec %>" <%$selected%>><% $conn_secs{$conn_sec} %></OPTION>
-% }
- </TD>
-
- <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
- <%$money_char%><INPUT TYPE="text" SIZE=6 NAME="min_charge<%$n%>" VALUE="<% $cgi->param("min_charge$n") || $rate_detail->min_charge |h %>">
- </TD>
-
- <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
- <SELECT NAME="sec_granularity<%$n%>">
-% foreach my $granularity ( keys %granularity ) {
- <OPTION VALUE="<%$granularity%>"<% $granularity == ( $cgi->param("sec_granularity$n") || $rate_detail->sec_granularity ) ? ' SELECTED' : '' %>><%$granularity{$granularity}%>
-% }
- </SELECT>
- </TD>
-
- <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
- <% include( '/elements/select-table.html',
- 'element_name' => "classnum$n",
- 'table' => 'usage_class',
- 'name_col' => 'classname',
- 'empty_label' => '(default)',
- 'hashref' => { disabled => '' },
- 'curr_value' => ( $cgi->param("classnum$n") ||
- $rate_detail->classnum ),
- )
- %>
- </TD>
-
- </TR>
-
-% }
-
-</TABLE>
-
-
<BR><BR>
<INPUT TYPE="submit" VALUE="<% $rate_region->regionnum ? "Apply changes" : "Add region" %>">
-
</FORM>
+%# rate plan info, if the region has been created yet
+
+% if($rate_region->regionnum) {
+<BR>
+<BR>
+<FONT SIZE="+2">Rates in this region</FONT>
+<% include('/edit/elements/rate_detail.html',
+ 'regionnum' => $rate_region->regionnum,
+) %>
+% }
<% include('/elements/footer.html') %>
<%once>
Index: rate_time.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/edit/rate_time.cgi,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -w -d -r1.1 -r1.2
--- rate_time.cgi 1 Jul 2010 01:53:50 -0000 1.1
+++ rate_time.cgi 22 Jul 2010 00:11:55 -0000 1.2
@@ -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>
Index: rate.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/edit/rate.cgi,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -w -d -r1.16 -r1.17
--- rate.cgi 14 May 2010 02:16:30 -0000 1.16
+++ rate.cgi 22 Jul 2010 00:11:55 -0000 1.17
@@ -22,9 +22,15 @@
<INPUT NAME="submit" TYPE="button" VALUE="<%
$rate->ratenum ? "Apply changes" : "Add rate plan"
%>" onClick="document.OneTrueForm.submit.disabled=true; process();">
-
</FORM>
+% if($rate->ratenum) {
+<BR><BR><FONT SIZE="+2">Rates in this plan</FONT>
+<% include('/edit/elements/rate_detail.html',
+ 'ratenum' => $rate->ratenum
+) %>
+% }
+
<% include('/elements/footer.html') %>
<%init>
More information about the freeside-commits
mailing list