8addbd65791c80030d5a889d969f40c84af52105
[freeside.git] / htdocs / misc / delete-customer.cgi
1 #!/usr/bin/perl -Tw
2 #
3 # $Id: delete-customer.cgi,v 1.1 1999-04-15 16:44:36 ivan Exp $
4 #
5 # $Log: delete-customer.cgi,v $
6 # Revision 1.1  1999-04-15 16:44:36  ivan
7 # delete customers
8 #
9
10 use strict;
11 use vars qw( $cgi $conf $query $custnum $new_custnum $cust_main );
12 use CGI;
13 use CGI::Carp qw(fatalsToBrowser);
14 use FS::UID qw(cgisuidsetup);
15 use FS::CGI qw(header popurl);
16 use FS::Record qw(qsearch qsearchs);
17 use FS::cust_main;
18
19 $cgi = new CGI;
20 cgisuidsetup($cgi);
21
22 $conf = new FS::Conf;
23 die "Customer deletions not enabled" unless $conf->exists('deletecustomers');
24
25 if ( $cgi->param('error') ) {
26   $custnum = $cgi->param('custnum');
27   $new_custnum = $cgi->param('new_custnum');
28 } else {
29   ($query) = $cgi->keywords;
30   $query =~ /^(\d+)$/ or die "Illegal query: $query";
31   $custnum = $1;
32   $new_custnum = '';
33 }
34 $cust_main = qsearchs( 'cust_main', { 'custnum' => $custnum } )
35   or die "Customer not found: $custnum";
36
37 print $cgi->header ( '-expires' => 'now' ), header('Delete customer');
38
39 print qq!<FONT SIZE="+1" COLOR="#ff0000">Error: !, $cgi->param('error'),
40       "</FONT>"
41   if $cgi->param('error');
42
43 print 
44   qq!<form action="!, popurl(1), qq!process/delete-customer.cgi" method=post>!,
45   qq!<input type="hidden" name="custnum" value="$custnum">!;
46
47 if ( qsearch('cust_pkg', { 'custnum' => $custnum, 'cancel' => '' } ) ) {
48   print "Move uncancelled packages to customer number ",
49         qq!<input type="text" name="new_custnum" value="$new_custnum"><br><br>!;
50 }
51
52 print <<END;
53 This will <b>completely remove</b> all traces of this customer record.
54 <br>Are you <b>absolutely sure</b> you want to delete this customer?
55 <br><input type="submit" value="Yes">
56 </form></body></html>
57 END
58