summaryrefslogtreecommitdiff
path: root/httemplate/misc/process
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2015-11-28 16:48:35 -0800
committerMark Wells <mark@freeside.biz>2015-11-28 16:58:16 -0800
commitd1025e8f571644fadeb476f8ec631c4ba7501c85 (patch)
treecbafc5f906b09bd7f18f44ad18df718cc324466b /httemplate/misc/process
parent7dc5c471d9ab413aa437980be219a52c92e016c2 (diff)
when unholding a package, optionally set it to start on the next bill date, #38921
Diffstat (limited to 'httemplate/misc/process')
-rwxr-xr-xhttemplate/misc/process/unhold_pkg.html54
1 files changed, 54 insertions, 0 deletions
diff --git a/httemplate/misc/process/unhold_pkg.html b/httemplate/misc/process/unhold_pkg.html
new file mode 100755
index 000000000..6eec7ee8a
--- /dev/null
+++ b/httemplate/misc/process/unhold_pkg.html
@@ -0,0 +1,54 @@
+<& /elements/header-popup.html &>
+ <SCRIPT TYPE="text/javascript">
+ window.top.location.reload();
+ </SCRIPT>
+ </BODY>
+</HTML>
+<%init>
+
+warn Dumper +{$cgi->Vars}; # XXX
+
+my $curuser = $FS::CurrentUser::CurrentUser;
+die "access denied"
+ unless $curuser->access_right('Unsuspend customer package');
+
+$cgi->param('pkgnum') =~ /^(\d+)$/
+ or die "illegal pkgnum";
+my $pkgnum = $1;
+
+my $cust_pkg = qsearchs({
+ table => 'cust_pkg',
+ addl_from => ' JOIN cust_main USING (custnum) ',
+ hashref => { 'pkgnum' => $pkgnum },
+ extra_sql => ' AND '. $curuser->agentnums_sql,
+}) or die "Unknown pkgnum: $pkgnum";
+
+my $cust_main = $cust_pkg->cust_main;
+
+my $error;
+my $start_date;
+if ( $cgi->param('when') eq 'now' ) {
+ # start it the next time billing runs
+ $start_date = '';
+} elsif ( $cgi->param('when') eq 'next_bill_date' ) {
+ $start_date = $cust_main->next_bill_date;
+} elsif ( $cgi->param('when') eq 'date' ) {
+ $start_date = parse_datetime($cgi->param('start_date'));
+}
+
+# In this process, always unsuspend the package _now_ but with a future start
+# date, rather than set a resume date. (There is some semantic overlap between
+# them, yes.)
+
+if ( $cust_pkg->setup or !$cust_pkg->susp ) {
+ $error = 'This package is '. $cust_pkg->status . ', not on hold.';
+} else {
+ $cust_pkg->set('start_date', $start_date);
+ $error = $cust_pkg->unsuspend;
+}
+
+if ( $error ) {
+ $cgi->param('error', $error);
+ print $cgi->redirect($fsurl.'misc/unhold_pkg.html?', $cgi->query_string);
+}
+</%init>