summaryrefslogtreecommitdiff
path: root/httemplate
diff options
context:
space:
mode:
authorivan <ivan>2010-02-05 02:39:31 +0000
committerivan <ivan>2010-02-05 02:39:31 +0000
commit8a0204b4a129a3c26dcca18ba401b2de26d22d2b (patch)
treeacc110c2e41d74fefa6c038c6b0d414865fb29b2 /httemplate
parent4cacb3fa439b56fc7c9a742b69ec3f6ffd660433 (diff)
discounts, RT#6679
Diffstat (limited to 'httemplate')
-rwxr-xr-xhttemplate/edit/cust_pkg_discount.html3
-rw-r--r--httemplate/edit/discount.html2
-rw-r--r--httemplate/edit/process/discount.html17
-rw-r--r--httemplate/edit/process/quick-cust_pkg.cgi28
-rw-r--r--httemplate/elements/tr-select-discount.html52
-rw-r--r--httemplate/misc/order_pkg.html2
-rw-r--r--httemplate/view/cust_main/order_pkg_link.html2
-rw-r--r--httemplate/view/cust_main/packages/status.html8
8 files changed, 59 insertions, 55 deletions
diff --git a/httemplate/edit/cust_pkg_discount.html b/httemplate/edit/cust_pkg_discount.html
index 22d8c632f..0bb84b8f2 100755
--- a/httemplate/edit/cust_pkg_discount.html
+++ b/httemplate/edit/cust_pkg_discount.html
@@ -28,7 +28,8 @@
<% include('/elements/tr-select-discount.html',
'empty_label' => ( $pkgdiscountnum ? '' : 'Select discount' ),
- 'onchange' => 'enable_discount_pkg',
+ 'onchange' => 'enable_discount_pkg()',
+ 'cgi' => $cgi,
)
%>
diff --git a/httemplate/edit/discount.html b/httemplate/edit/discount.html
index 4f440b2cb..6e0d8e1a7 100644
--- a/httemplate/edit/discount.html
+++ b/httemplate/edit/discount.html
@@ -29,7 +29,7 @@
'_type' => 'Type&nbsp;',
'amount' => 'Amount&nbsp;',
'percent' => 'Percentage&nbsp;',
- 'months' => '# of Months',
+ 'months' => 'Duration (months)',
},
'viewall_dir' => 'browse',
'new_callback' => $new_callback,
diff --git a/httemplate/edit/process/discount.html b/httemplate/edit/process/discount.html
index 54307b708..80dc0f5bd 100644
--- a/httemplate/edit/process/discount.html
+++ b/httemplate/edit/process/discount.html
@@ -1,7 +1,6 @@
<% include( 'elements/process.html',
'table' => 'discount',
'viewall_dir' => 'browse',
- 'precheck_callback' => $precheck_callback,
)
%>
<%init>
@@ -9,20 +8,4 @@
die "access denied"
unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
-my $precheck_callback = sub {
- my( $cgi ) = @_;
-
- if ( $cgi->param('_type') eq 'Select discount type' ) {
- return 'Please select a discount type';
- } elsif ( $cgi->param('_type') eq 'Amount' ) {
- $cgi->param('percent', '0');
- return 'Amount must be greater than 0' unless $cgi->param('amount') > 0;
- } elsif ( $cgi->param('_type') eq 'Percentage' ) {
- $cgi->param('amount', '0.00');
- return 'Percentage must be greater than 0' unless $cgi->param('percent') > 0;
- }
-
- '';
-};
-
</%init>
diff --git a/httemplate/edit/process/quick-cust_pkg.cgi b/httemplate/edit/process/quick-cust_pkg.cgi
index c60156746..a0958922e 100644
--- a/httemplate/edit/process/quick-cust_pkg.cgi
+++ b/httemplate/edit/process/quick-cust_pkg.cgi
@@ -45,17 +45,27 @@ my $refnum = $1;
$cgi->param('locationnum') =~ /^(\-?\d*)$/
or die 'illegal locationnum '. $cgi->param('locationnum');
my $locationnum = $1;
+$cgi->param('discountnum') =~ /^(\-?\d*)$/
+ or die 'illegal discountnum '. $cgi->param('discountnum');
+my $discountnum = $1;
+
my $cust_pkg = new FS::cust_pkg {
- 'custnum' => $custnum,
- 'pkgpart' => $pkgpart,
- 'start_date' => ( scalar($cgi->param('start_date'))
- ? str2time($cgi->param('start_date'))
- : ''
- ),
- 'discountnum' => scalar($cgi->param('discountnum')),
- 'refnum' => $refnum,
- 'locationnum' => $locationnum,
+ 'custnum' => $custnum,
+ 'pkgpart' => $pkgpart,
+ 'start_date' => ( scalar($cgi->param('start_date'))
+ ? str2time($cgi->param('start_date'))
+ : ''
+ ),
+ 'refnum' => $refnum,
+ 'locationnum' => $locationnum,
+ 'discountnum' => $discountnum,
+ #for the create a new discount case
+ 'discountnum__type' => scalar($cgi->param('discountnum__type')),
+ 'discountnum_amount' => scalar($cgi->param('discountnum_amount')),
+ 'discountnum_percent' => scalar($cgi->param('discountnum_percent')),
+ 'discountnum_months' => scalar($cgi->param('discountnum_months')),
+ #'discountnum_disabled' => scalar($cgi->param('discountnum_disabled')),
};
my %opt = ( 'cust_pkg' => $cust_pkg );
diff --git a/httemplate/elements/tr-select-discount.html b/httemplate/elements/tr-select-discount.html
index df221da96..258eeb349 100644
--- a/httemplate/elements/tr-select-discount.html
+++ b/httemplate/elements/tr-select-discount.html
@@ -6,11 +6,11 @@
% } else {
<TR>
- <TD ALIGN="right"><% $opt{'label'} || '<B>Discount</B>' %></TD>
+ <TD ALIGN="right" WIDTH="176"><% $opt{'label'} || '<B>Discount</B>' %></TD>
<TD <% $colspan %>>
<% include( '/elements/select-discount.html',
'curr_value' => $discountnum,
- 'onchange' => $name.'_changed',
+ 'onchange' => $onchange,
%opt,
)
%>
@@ -19,7 +19,7 @@
% # a weird kind of false laziness w/edit/discount.html
- <INPUT TYPE="hidden" NAME="<% $name %>_disabled" VALUE="Y">
+% # <INPUT TYPE="hidden" NAME="<% $name %>_disabled" VALUE="Y">
<% include( '/elements/tr-select.html',
@@ -27,18 +27,18 @@
'field' => $name. '__type',
'id' => $name. '__type',
'options' => \@_type_options,
- #XXX 'curr_value' =>
- 'onchange' => '_type_changed',
+ 'curr_value' => scalar($cgi->param($name.'__type')),
+ 'onchange' => $name.'__type_changed',
'colspan' => $opt{'colspan'},
)
%>
<% include( '/elements/tr-input-money.html',
- 'label' => '<B>Discount Amount</B>',
+ 'label' => '<B>Discount Amount&nbsp;</B>',
'field' => $name. '_amount',
'id' => $name. '_amount',
'default' => '0.00',
- #XXX 'curr_value' =>
+ 'curr_value' => scalar($cgi->param($name.'_amount')),
'colspan' => $opt{'colspan'},
)
%>
@@ -48,18 +48,18 @@
'field' => $name. '_percent',
'id' => $name. '_percent',
'default' => '0',
- #XXX 'curr_value' =>
+ 'curr_value' => scalar($cgi->param($name.'_percent')),
'colspan' => $opt{'colspan'},
)
%>
<% include( '/elements/tr-input-text.html',
- 'label' => '<B>Discount # of Months</B>',
+ 'label' => '<B>Discount duration (months)</B>',
'field' => $name. '_months',
'id' => $name. '_months',
'size' => 2,
'postfix' => qq(<FONT SIZE="-1" ID="${name}_months_postfix"><I>(blank for non-expiring discount)</I></FONT>),
- #XXX 'curr_value' =>
+ 'curr_value' => scalar($cgi->param($name.'_months')),
'colspan' => $opt{'colspan'},
)
%>
@@ -93,14 +93,14 @@
% #XXX save visibility settings for amount, percent :/
<% $ge %>('<% $name %>_amount_label0').style.display = 'none';
<% $ge %>('<% $name %>_amount_label0').style.visibility = 'hidden';
- <% $ge %>('<% $name %>_amount').style.display = 'none';
- <% $ge %>('<% $name %>_amount').style.visibility = 'hidden';
+ <% $ge %>('<% $name %>_amount_input0').style.display = 'none';
+ <% $ge %>('<% $name %>_amount_input0').style.visibility = 'hidden';
<% $ge %>('<% $name %>_amount_input0').style.display = 'none';
<% $ge %>('<% $name %>_amount_input0').style.visibility = 'hidden';
<% $ge %>('<% $name %>_percent_label0').style.display = 'none';
<% $ge %>('<% $name %>_percent_label0').style.visibility = 'hidden';
- <% $ge %>('<% $name %>_percent').style.display = 'none';
- <% $ge %>('<% $name %>_percent').style.visibility = 'hidden';
+ <% $ge %>('<% $name %>_percent_input0').style.display = 'none';
+ <% $ge %>('<% $name %>_percent_input0').style.visibility = 'hidden';
<% $ge %>('<% $name %>_percent_input0').style.display = 'none';
<% $ge %>('<% $name %>_percent_input0').style.visibility = 'hidden';
@@ -116,7 +116,7 @@
}
function <% $name %>__type_changed(what) {
- var _type = what.options[what.selectedIndex].value;
+ var <% $name %>__type = what.options[what.selectedIndex].value;
if ( <% $name %>__type == '<% $select %>' ) {
<% $ge %>('<% $name %>_amount_label0').style.display = 'none';
@@ -130,31 +130,34 @@
} else if ( <% $name %>__type == 'Amount' ) {
<% $ge %>('<% $name %>_amount_label0').style.display = '';
<% $ge %>('<% $name %>_amount_label0').style.visibility = '';
- <% $ge %>('<% $name %>_amount').style.display = '';
- <% $ge %>('<% $name %>_amount').style.visibility = '';
+ <% $ge %>('<% $name %>_amount_input0').style.display = '';
+ <% $ge %>('<% $name %>_amount_input0').style.visibility = '';
<% $ge %>('<% $name %>_percent_label0').style.display = 'none';
<% $ge %>('<% $name %>_percent_label0').style.visibility = 'hidden';
- <% $ge %>('<% $name %>_percent').style.display = 'none';
- <% $ge %>('<% $name %>_percent').style.visibility = 'hidden';
+ <% $ge %>('<% $name %>_percent_input0').style.display = 'none';
+ <% $ge %>('<% $name %>_percent_input0').style.visibility = 'hidden';
} else if ( <% $name %>__type == 'Percentage' ) {
<% $ge %>('<% $name %>_amount_label0').style.display = 'none';
<% $ge %>('<% $name %>_amount_label0').style.visibility = 'hidden';
- <% $ge %>('<% $name %>_amount').style.display = 'none';
- <% $ge %>('<% $name %>_amount').style.visibility = 'hidden';
+ <% $ge %>('<% $name %>_amount_input0').style.display = 'none';
+ <% $ge %>('<% $name %>_amount_input0').style.visibility = 'hidden';
<% $ge %>('<% $name %>_percent_label0').style.display = '';
<% $ge %>('<% $name %>_percent_label0').style.visibility = '';
- <% $ge %>('<% $name %>_percent').style.display = '';
- <% $ge %>('<% $name %>_percent').style.visibility = '';
+ <% $ge %>('<% $name %>_percent_input0').style.display = '';
+ <% $ge %>('<% $name %>_percent_input0').style.visibility = '';
}
}
+ <% $name %>_changed(<% $ge %>('<% $name %>'));
+
</SCRIPT>
% }
<%init>
my %opt = @_;
+my $cgi = $opt{'cgi'};
my $discountnum = $opt{'curr_value'} || $opt{'value'};
$opt{'discount'} ||= [ qsearch( 'discount', { disabled=>'' } ) ];
@@ -170,4 +173,7 @@ unshift @_type_options, $select;
my $colspan = $opt{'colspan'} ? 'COLSPAN="'.$opt{'colspan'}.'"' : '';
+my $onchange = ( $opt{'onchange'} ? delete($opt{'onchange'}).';' : '' ).
+ $name.'_changed(this);';
+
</%init>
diff --git a/httemplate/misc/order_pkg.html b/httemplate/misc/order_pkg.html
index e05205ba7..864e8328c 100644
--- a/httemplate/misc/order_pkg.html
+++ b/httemplate/misc/order_pkg.html
@@ -69,6 +69,8 @@
% if ( $curuser->access_right('Discount customer package') ) {
<% include('/elements/tr-select-discount.html',
'element_etc' => 'DISABLED',
+ 'colspan' => 7,
+ 'cgi' => $cgi,
)
%>
% }
diff --git a/httemplate/view/cust_main/order_pkg_link.html b/httemplate/view/cust_main/order_pkg_link.html
index 9a12019ba..0c53f2a59 100644
--- a/httemplate/view/cust_main/order_pkg_link.html
+++ b/httemplate/view/cust_main/order_pkg_link.html
@@ -6,7 +6,7 @@
'cust_main' => $cust_main,
'closetext' => 'Close',
'width' => 763,
- 'height' => 408,
+ 'height' => 476,
)
%>
<%init>
diff --git a/httemplate/view/cust_main/packages/status.html b/httemplate/view/cust_main/packages/status.html
index c65eb70e9..7b1b53add 100644
--- a/httemplate/view/cust_main/packages/status.html
+++ b/httemplate/view/cust_main/packages/status.html
@@ -300,9 +300,11 @@ sub pkg_status_row_discount {
my $discount = $cust_pkg_discount->discount;
my $label = '<B>Discount</B>: '. $discount->description;
- $label .= ' ('. ( $discount->months - $cust_pkg_discount->months_used ).
- ' months remaining)'
- if $discount->months;
+ if ( $discount->months ) {
+ my $remaining = $discount->months - $cust_pkg_discount->months_used;
+ $remaining = sprintf('%.2f', $remaining) if $remaining =~ /\./;
+ $label .= " ($remaining months remaining)"
+ }
$label .= ' <FONT SIZE="-1">('.
'<A HREF="../misc/delete-cust_pkg_discount.html?'.