summaryrefslogtreecommitdiff
path: root/httemplate/misc/unprovision.cgi
blob: 6f2c23815f263f0778dbc7bce241c70d16c304d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
%if ( $error ) {
%  errorpage($error);
%} elsif ( $pkgnum ) {
<% $cgi->redirect(popurl(2)."search/cust_pkg_svc.html?svcpart=$svcpart;pkgnum=$pkgnum") %>
%} else { # $custnum should always exist
<% $cgi->redirect(popurl(2)."view/cust_main.cgi?$custnum") %>
%}
<%init>

die "access denied"
  unless $FS::CurrentUser::CurrentUser->access_right('Unprovision customer service');

#untaint svcnum
my @svcnums;
my ($pkgnum, $svcpart, $custnum);
if( $cgi->param('svcnum') ) {
  @svcnums = grep { $_ } map { /^(\d+)$/ && $1 } $cgi->param('svcnum');
  $pkgnum = $cgi->param('pkgnum');
  $svcpart = $cgi->param('svcpart');
  $custnum = $cgi->param('custnum');
}
else {
  @svcnums = map { /^(\d+)$/ && $1 } $cgi->keywords;
}

my $error = '';
foreach my $svcnum (@svcnums) {

  my $cust_svc = qsearchs('cust_svc',{'svcnum'=>$svcnum});
  die "Unknown svcnum!" unless $cust_svc;

  $custnum ||= $cust_svc->cust_pkg->custnum;

  $error .= $cust_svc->cancel;

}

</%init>