summaryrefslogtreecommitdiff
path: root/httemplate/misc
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2013-04-27 13:22:24 -0700
committerMark Wells <mark@freeside.biz>2013-04-27 13:22:24 -0700
commitb594ce910540fae472cfa1fb132f658d4846c638 (patch)
treea6885d97486ea10e482286ce1a769f617a5d936c /httemplate/misc
parent42cb9f2b2935355862192c2de507efd824840411 (diff)
allow service smart_search to find unlinked svc_* records, related to #22385
Diffstat (limited to 'httemplate/misc')
-rwxr-xr-xhttemplate/misc/cancel-unaudited.cgi37
1 files changed, 25 insertions, 12 deletions
diff --git a/httemplate/misc/cancel-unaudited.cgi b/httemplate/misc/cancel-unaudited.cgi
index 4919c6632..4b3084f00 100755
--- a/httemplate/misc/cancel-unaudited.cgi
+++ b/httemplate/misc/cancel-unaudited.cgi
@@ -15,19 +15,32 @@ my($query) = $cgi->keywords;
$query =~ /^(\d+)$/;
my $svcnum = $1;
-#my $svc_acct = qsearchs('svc_acct',{'svcnum'=>$svcnum});
-#die "Unknown svcnum!" unless $svc_acct;
-
+my $error = '';
my $cust_svc = qsearchs('cust_svc',{'svcnum'=>$svcnum});
-die "Unknown svcnum!" unless $cust_svc;
-my $cust_pkg = $cust_svc->cust_pkg;
-if ( $cust_pkg ) {
- errorpage( 'This account has already been audited. Cancel the '.
- qq!<A HREF="${p}view/cust_main.cgi?!. $cust_pkg->custnum.
- '#cust_pkg'. $cust_pkg->pkgnum. '">'.
- 'package</A> instead.');
-}
+if ( $cust_svc ) {
+ my $cust_pkg = $cust_svc->cust_pkg;
+ if ( $cust_pkg ) {
+ errorpage( 'This account has already been audited. Cancel the '.
+ qq!<A HREF="${p}view/cust_main.cgi?!. $cust_pkg->custnum.
+ '#cust_pkg'. $cust_pkg->pkgnum. '">'.
+ 'package</A> instead.'); #'
+ }
-my $error = $cust_svc->cancel;
+ $error = $cust_svc->cancel;
+} else {
+ # the rare obscure case: svc_x without cust_svc
+ my $svc_x;
+ foreach my $svcdb (FS::part_svc->svc_tables) {
+ $svc_x = qsearchs($svcdb, { 'svcnum' => $svcnum });
+ last if $svc_x;
+ }
+ if ( $svc_x ) {
+ $error = $svc_x->return_inventory
+ || $svc_x->FS::Record::delete;
+ } else {
+ # the svcnum really doesn't exist
+ $error = "svcnum $svcnum not found";
+ }
+}
</%init>