summaryrefslogtreecommitdiff
path: root/httemplate/elements
diff options
context:
space:
mode:
authorMitch Jackson <mitch@freeside.biz>2018-02-28 08:27:16 +0000
committerMitch Jackson <mitch@freeside.biz>2018-02-28 08:32:32 +0000
commit71231d6bd803d2a3977c3ce2fa1f3c0ed4746b2d (patch)
tree1641a5a1fae4f5332a96153aeb0474be62b35bc9 /httemplate/elements
parent0ed464c391924a455fc2a9ba3f89eb6ca2ebab6b (diff)
RT# 79284 Option to set discount at Change Package
Diffstat (limited to 'httemplate/elements')
-rw-r--r--httemplate/elements/select-discount.html36
1 files changed, 35 insertions, 1 deletions
diff --git a/httemplate/elements/select-discount.html b/httemplate/elements/select-discount.html
index 3a267ed08..4bbdc661a 100644
--- a/httemplate/elements/select-discount.html
+++ b/httemplate/elements/select-discount.html
@@ -6,6 +6,7 @@
'empty_label' => '(none)',
'hashref' => $hashref,
'post_options' => $post_options,
+ 'label_callback' => $label_callback,
%opt,
)
%>
@@ -22,9 +23,42 @@ my $curuser = $FS::CurrentUser::CurrentUser;
my $hashref = $opt{hashref} || { 'disabled' => '' };
my $post_options = [];
+
+# If a 'custom' discount is applied to existing cust_pkg,
+# also add that option to the selectbox
+my $pkgnum = $cgi ? $cgi->param('pkgnum') : undef;
+if ($pkgnum) {
+
+ # Does pkgnum have a custom discount?
+ my $cust_pkg_discount = qsearchs(cust_pkg_discount => {
+ disabled => '',
+ pkgnum => $pkgnum,
+ });
+
+ if ($cust_pkg_discount) {
+ my $discount = qsearchs(discount => {
+ discountnum => $cust_pkg_discount->discountnum,
+ disabled => 'Y',
+ });
+ if ($discount) {
+ my $descr = $opt{carry_value} eq $discount->discountnum
+ ? $discount->description.' [Continue existing discount]'
+ : $discount->description;
+ push @$post_options, $discount->discountnum, $descr;
+ }
+ }
+}
+
push @$post_options, -1 => 'Custom discount'
if $curuser->access_right('Custom discount customer package')
&& ! $opt{disable_custom_discount};
-</%init>
+my $label_callback = sub {
+ my $rec = shift;
+ if ( $opt{carry_value} eq $rec->discountnum ) {
+ return $rec->description.' [Continue existing discount]';
+ }
+ return $rec->description;
+};
+</%init>