summaryrefslogtreecommitdiff
path: root/httemplate/edit
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2014-11-25 19:39:23 -0800
committerMark Wells <mark@freeside.biz>2014-11-25 19:39:23 -0800
commit3cda3a85eb0daa5b8b9f4d30cd0896da6ccf4a9b (patch)
treee1d8a4f8b8572396fd2d4fe7a82327f1c9768c0f /httemplate/edit
parent77be6115a8972c8e7917fc9f80e30a6ba571a552 (diff)
option to credit unused time on suspension as part of suspend reason, #31702
Diffstat (limited to 'httemplate/edit')
-rw-r--r--httemplate/edit/credit-cust_bill_pkg.html4
-rwxr-xr-xhttemplate/edit/cust_credit.cgi2
-rw-r--r--httemplate/edit/process/credit-cust_bill_pkg.html26
-rwxr-xr-xhttemplate/edit/process/cust_credit.cgi17
4 files changed, 28 insertions, 21 deletions
diff --git a/httemplate/edit/credit-cust_bill_pkg.html b/httemplate/edit/credit-cust_bill_pkg.html
index 40faddc46..85f794317 100644
--- a/httemplate/edit/credit-cust_bill_pkg.html
+++ b/httemplate/edit/credit-cust_bill_pkg.html
@@ -80,9 +80,9 @@
<& /elements/tr-select-reason.html,
'field' => 'reasonnum',
'reason_class' => 'R',
- #XXX reconcile both this and show_taxes wanteding to enable this
+ #XXX reconcile both this and show_taxes wanting to enable this
'id' => 'select_reason',
- 'control_button' => "document.getElementById('credit_button')",
+ 'control_button' => 'credit_button',
'cgi' => $cgi,
&>
diff --git a/httemplate/edit/cust_credit.cgi b/httemplate/edit/cust_credit.cgi
index a3565f125..29801efef 100755
--- a/httemplate/edit/cust_credit.cgi
+++ b/httemplate/edit/cust_credit.cgi
@@ -24,7 +24,7 @@
<& /elements/tr-select-reason.html,
'field' => 'reasonnum',
'reason_class' => 'R',
- 'control_button' => "document.getElementById('confirm_credit_button')",
+ 'control_button' => 'confirm_credit_button',
'cgi' => $cgi,
&>
diff --git a/httemplate/edit/process/credit-cust_bill_pkg.html b/httemplate/edit/process/credit-cust_bill_pkg.html
index 8e66368d4..75900bde5 100644
--- a/httemplate/edit/process/credit-cust_bill_pkg.html
+++ b/httemplate/edit/process/credit-cust_bill_pkg.html
@@ -27,19 +27,35 @@ foreach my $billpkgnum_setuprecur (@billpkgnum_setuprecurs) {
push @amounts, $amount;
}
-my $error = FS::cust_credit->credit_lineitems(
+my $reasonnum = $cgi->param('reasonnum');
+$reasonnum =~ /^(-?\d+)$/ or die "Illegal reasonnum";
+$reasonnum = $1;
+
+my $error;
+if ($reasonnum == -1) {
+ my $new_reason = FS::reason->new({
+ map { $_ => scalar( $cgi->param("select_reason_new_$_") ) }
+ qw( reason_type reason )
+ });
+ $error = $new_reason->insert;
+ $reasonnum = $new_reason->reasonnum;
+}
+
+if ( !$reasonnum ) {
+ $error ||= 'Reason required'
+}
+
+$error ||= FS::cust_credit->credit_lineitems(
#the lineitems to credit
'billpkgnums' => \@billpkgnums,
'setuprecurs' => \@setuprecurs,
'amounts' => \@amounts,
'apply' => ( $cgi->param('apply') eq 'yes' ),
+ 'reasonnum' => $reasonnum,
- #the credit
- 'newreasonnum' => scalar($cgi->param('newreasonnum')),
- 'newreasonnum_type' => scalar($cgi->param('newreasonnumT')),
map { $_ => scalar($cgi->param($_)) }
#fields('cust_credit')
- qw( custnum _date amount reason reasonnum addlinfo ), #pkgnum eventnum
+ qw( custnum _date amount addlinfo ), #pkgnum eventnum
);
</%init>
diff --git a/httemplate/edit/process/cust_credit.cgi b/httemplate/edit/process/cust_credit.cgi
index 245f31af7..e442d7fa6 100755
--- a/httemplate/edit/process/cust_credit.cgi
+++ b/httemplate/edit/process/cust_credit.cgi
@@ -1,5 +1,4 @@
%if ( $error ) {
-% $cgi->param('reasonnum', $reasonnum);
% $cgi->param('error', $error);
% $dbh->rollback if $oldAutoCommit;
%
@@ -37,19 +36,11 @@ my $oldAutoCommit = $FS::UID::AutoCommit;
local $FS::UID::AutoCommit = 0;
my $dbh = dbh;
-my $error = '';
-if ($reasonnum == -1) {
-
- $error = 'Enter a new reason (or select an existing one)'
- unless $cgi->param('newreasonnum') !~ /^\s*$/;
- my $reason = new FS::reason {
- 'reason_type' => scalar($cgi->param('newreasonnumT')),
- 'reason' => scalar($cgi->param('newreasonnum')),
- };
- $error ||= $reason->insert;
- $cgi->param('reasonnum', $reason->reasonnum)
- unless $error;
+my ($reasonnum, $error) = $m->comp('/misc/process/elements/reason');
+if (!$reasonnum) {
+ $error ||= 'Reason required'
}
+$cgi->param('reasonnum', $reasonnum) unless $error;
unless ($error) {
my $new = new FS::cust_credit ( {