merging RT 4.0.6
[freeside.git] / httemplate / misc / process / delete-customer.cgi
1 %if ( $error ) {
2 %  $cgi->param('error', $error);
3 <% $cgi->redirect(popurl(2). "delete-customer.cgi?". $cgi->query_string ) %>
4 %} elsif ( $new_custnum ) {
5 <% $cgi->redirect(popurl(3). "view/cust_main.cgi?$new_custnum") %>
6 %} else {
7 <% $cgi->redirect(popurl(3)) %>
8 %}
9 <%init>
10
11 my $conf = new FS::Conf;
12 die "Customer deletions not enabled in configuration"
13   unless $conf->exists('deletecustomers');
14
15 die "access denied"
16   unless $FS::CurrentUser::CurrentUser->access_right('Delete customer');
17
18 $cgi->param('custnum') =~ /^(\d+)$/;
19 my $custnum = $1;
20 my $new_custnum;
21 if ( $cgi->param('new_custnum') ) {
22   $cgi->param('new_custnum') =~ /^(\d+)$/
23     or die "Illegal new customer number: ". $cgi->param('new_custnum');
24   $new_custnum = $1;
25 } else {
26   $new_custnum = '';
27 }
28 my $cust_main = qsearchs( 'cust_main', { 'custnum' => $custnum } )
29   or die "Customer not found: $custnum";
30
31 my $error = $cust_main->delete('new_custnum' => $new_custnum);
32
33 </%init>