summaryrefslogtreecommitdiff
path: root/httemplate/misc
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/misc
parent77be6115a8972c8e7917fc9f80e30a6ba571a552 (diff)
option to credit unused time on suspension as part of suspend reason, #31702
Diffstat (limited to 'httemplate/misc')
-rw-r--r--httemplate/misc/cancel_cust.html2
-rwxr-xr-xhttemplate/misc/cancel_pkg.html6
-rwxr-xr-xhttemplate/misc/cust_main-cancel.cgi30
-rwxr-xr-xhttemplate/misc/cust_main-suspend.cgi37
-rwxr-xr-xhttemplate/misc/process/cancel_pkg.html19
-rw-r--r--httemplate/misc/process/elements/reason17
-rw-r--r--httemplate/misc/suspend_cust.html2
7 files changed, 53 insertions, 60 deletions
diff --git a/httemplate/misc/cancel_cust.html b/httemplate/misc/cancel_cust.html
index 3259a03f6..e4bfdba76 100644
--- a/httemplate/misc/cancel_cust.html
+++ b/httemplate/misc/cancel_cust.html
@@ -50,7 +50,7 @@ STYLE="margin-left:auto; margin-right:auto">
'field' => 'reasonnum',
'reason_class' => 'C',
'cgi' => $cgi,
- 'control_button' => "document.getElementById('confirm_cancel_cust_button')",
+ 'control_button' => 'confirm_cancel_cust_button',
&>
</TABLE>
diff --git a/httemplate/misc/cancel_pkg.html b/httemplate/misc/cancel_pkg.html
index e2734e97d..c80b2b278 100755
--- a/httemplate/misc/cancel_pkg.html
+++ b/httemplate/misc/cancel_pkg.html
@@ -6,9 +6,9 @@
<INPUT TYPE="hidden" NAME="pkgnum" VALUE="<% $pkgnum %>">
<INPUT TYPE="hidden" NAME="method" VALUE="<% $method %>">
-<BR><BR>
+<BR>
<% emt(ucfirst($method)." [_1]", $part_pkg->pkg_comment(cust_pkg=>$cust_pkg) ) %>
-<% ntable("#cccccc", 2) %>
+<table style="background-color: #cccccc; border-spacing: 2; width: 100%">
% my $date_init = 0;
% if ($method eq 'expire' || $method eq 'adjourn' || $method eq 'resume') {
@@ -58,7 +58,7 @@
field => 'reasonnum',
reason_class => $class,
curr_value => $reasonnum,
- control_button => "document.getElementById('confirm_cancel_pkg_button')",
+ control_button => "confirm_cancel_pkg_button",
&>
% }
diff --git a/httemplate/misc/cust_main-cancel.cgi b/httemplate/misc/cust_main-cancel.cgi
index 2ae9f1021..a78a8b3dc 100755
--- a/httemplate/misc/cust_main-cancel.cgi
+++ b/httemplate/misc/cust_main-cancel.cgi
@@ -22,51 +22,43 @@ if ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
$custnum = $1;
}
-#false laziness w/process/cancel_pkg.html
-#untaint reasonnum
-my $reasonnum = $cgi->param('reasonnum');
-$reasonnum =~ /^(-?\d+)$/ || die "Illegal reasonnum";
-$reasonnum = $1;
-
-if ($reasonnum == -1) {
- $reasonnum = {
- 'typenum' => scalar( $cgi->param('newreasonnumT') ),
- 'reason' => scalar( $cgi->param('newreasonnum' ) ),
- };
+#untaint reasonnum / create new reason
+my ($reasonnum, $error) = $m->comp('process/elements/reason');
+if (!$reasonnum) {
+ $error ||= 'Reason required'
}
-#eslaf
-
my $cust_main = qsearchs( {
'table' => 'cust_main',
'hashref' => { 'custnum' => $custnum },
'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
} );
-my @errors;
-if($cgi->param('now_or_later')) {
+if ( $error ) {
+ # do nothing
+} elsif ( $cgi->param('now_or_later') ) {
$expire = parse_datetime($expire);
if($expire) {
#warn "setting expire dates on custnum#$custnum\n";
my @pkgs = $cust_main->ncancelled_pkgs;
- @errors = grep {$_} map { $_->cancel(
+ my @errors = grep {$_} map { $_->cancel(
'reason' => $reasonnum,
'date' => $expire,
) } @pkgs;
+ $error = join(' / ', @errors);
}
else {
- @errors = ("error parsing expire date: ".$cgi->param('expire'));
+ $error = ("error parsing expire date: ".$cgi->param('expire'));
}
}
else {
warn "cancelling $cust_main";
- @errors = $cust_main->cancel(
+ $error = $cust_main->cancel(
'ban' => $ban,
'reason' => $reasonnum,
);
}
-my $error = join(' / ', @errors) if scalar(@errors);
if ( $error ) {
$cgi->param('error', $error);
diff --git a/httemplate/misc/cust_main-suspend.cgi b/httemplate/misc/cust_main-suspend.cgi
index 61851364e..7a501d61a 100755
--- a/httemplate/misc/cust_main-suspend.cgi
+++ b/httemplate/misc/cust_main-suspend.cgi
@@ -22,50 +22,39 @@ if ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
$custnum = $1;
}
-#false laziness w/process/cancel_pkg.html
-
-#untaint reasonnum
-my $reasonnum = $cgi->param('reasonnum');
-$reasonnum =~ /^(-?\d+)$/ || die "Illegal reasonnum";
-$reasonnum = $1;
-
-if ($reasonnum == -1) {
- $reasonnum = {
- 'typenum' => scalar( $cgi->param('newreasonnumT') ),
- 'reason' => scalar( $cgi->param('newreasonnum' ) ),
- };
+#untaint reasonnum / create new reason
+my ($reasonnum, $error) = $m->comp('process/elements/reason');
+if (!$reasonnum) {
+ $error ||= 'Reason required';
}
-#eslaf
-
my $cust_main = qsearchs( {
'table' => 'cust_main',
'hashref' => { 'custnum' => $custnum },
'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
} );
-my @errors;
-if($cgi->param('now_or_later')) {
+if ( $error ) {
+ # do nothing
+} elsif ( $cgi->param('now_or_later') ) {
$adjourn = parse_datetime($adjourn);
if($adjourn) {
#warn "setting adjourn dates on custnum#$custnum\n";
my @pkgs = $cust_main->unsuspended_pkgs;
- @errors = grep {$_} map { $_->suspend(
+ my @errors = grep {$_} map { $_->suspend(
'reason' => $reasonnum,
'date' => $adjourn,
) } @pkgs;
+ $error = join(' / ', @errors);
+ } else {
+ $error = ("error parsing adjourn date: ".$cgi->param('adjourn'));
}
- else {
- @errors = ("error parsing adjourn date: ".$cgi->param('adjourn'));
- }
-}
-else {
+} else {
warn "suspending $cust_main";
- @errors = $cust_main->suspend(
+ $error = $cust_main->suspend(
'reason' => $reasonnum,
);
}
-my $error = join(' / ', @errors) if scalar(@errors);
if ( $error ) {
$cgi->param('error', $error);
diff --git a/httemplate/misc/process/cancel_pkg.html b/httemplate/misc/process/cancel_pkg.html
index a106b845a..47ceca23b 100755
--- a/httemplate/misc/process/cancel_pkg.html
+++ b/httemplate/misc/process/cancel_pkg.html
@@ -65,17 +65,12 @@ if ( $method eq 'suspend' ) { #or 'adjourn'
my $cust_pkg = qsearchs( 'cust_pkg', {'pkgnum'=>$pkgnum} );
-#untaint reasonnum
-my $reasonnum = $cgi->param('reasonnum');
-if ( $method !~ /^(unsuspend|uncancel)$/ ) {
- $reasonnum =~ /^(-?\d+)$/ or die "Illegal reasonnum";
- $reasonnum = $1;
-
- if ($reasonnum == -1) {
- $reasonnum = {
- 'typenum' => scalar( $cgi->param('newreasonnumT') ),
- 'reason' => scalar( $cgi->param('newreasonnum' ) ),
- };
+#untaint reasonnum, and set up new reason if appropriate
+my ($reasonnum, $error);
+if ($method ne 'resume' and $method ne 'uncancel') {
+ ($reasonnum, $error) = $m->comp('elements/reason');
+ if (!$reasonnum) {
+ $error ||= 'Reason required';
}
}
@@ -87,7 +82,7 @@ my $bill =
my $svc_fatal = ( $cgi->param('svc_not_fatal') ne 'Y' );
-my $error = $cust_pkg->$method( 'reason' => $reasonnum,
+$error ||= $cust_pkg->$method( 'reason' => $reasonnum,
'date' => $date,
'resume_date' => $resume_date,
'last_bill' => $last_bill,
diff --git a/httemplate/misc/process/elements/reason b/httemplate/misc/process/elements/reason
new file mode 100644
index 000000000..ae92a7528
--- /dev/null
+++ b/httemplate/misc/process/elements/reason
@@ -0,0 +1,17 @@
+<%init>
+#untaint reasonnum, and set up new reason if appropriate
+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("reasonnum_new_$_") ) }
+ qw( reason_type reason unsuspend_pkgpart unsuspend_hold unused_credit )
+ }); # not sanitizing them here, but check() will do it
+ $error = $new_reason->insert;
+ $reasonnum = $new_reason->reasonnum;
+}
+return ($reasonnum, $error);
+</%init>
diff --git a/httemplate/misc/suspend_cust.html b/httemplate/misc/suspend_cust.html
index e0d17f30b..3a49e136d 100644
--- a/httemplate/misc/suspend_cust.html
+++ b/httemplate/misc/suspend_cust.html
@@ -42,7 +42,7 @@ STYLE="margin-left:auto; margin-right:auto">
'field' => 'reasonnum',
'reason_class' => 'S',
'cgi' => $cgi,
- 'control_button' => "document.getElementById('confirm_suspend_cust_button')",
+ 'control_button' => 'confirm_suspend_cust_button',
&>
</TABLE>