X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fmisc%2Fdelete-customer.cgi;h=203ed36a5ac2cbcf7780659ae8370db92e077646;hb=aed8ec35ccb9cdeb7ea0cb6ff2946f9d83d582f6;hp=d3e7c798f972105138d80f62c083d06fd5d46141;hpb=c14a267229fc0d6f2d2afdebab3bd34d825df2ef;p=freeside.git diff --git a/httemplate/misc/delete-customer.cgi b/httemplate/misc/delete-customer.cgi index d3e7c798f..203ed36a5 100755 --- a/httemplate/misc/delete-customer.cgi +++ b/httemplate/misc/delete-customer.cgi @@ -1,57 +1,64 @@ -<% -# +<% include('/elements/header.html', 'Delete customer') %> -use strict; -use vars qw( $cgi $conf $query $custnum $new_custnum $cust_main ); -use CGI; -use CGI::Carp qw(fatalsToBrowser); -use FS::UID qw(cgisuidsetup); -use FS::CGI qw(header popurl); -use FS::Record qw(qsearch qsearchs); -use FS::cust_main; +<% include('/elements/error.html') %> -$cgi = new CGI; -cgisuidsetup($cgi); +
+ -$conf = new FS::Conf; -die "Customer deletions not enabled" unless $conf->exists('deletecustomers'); +%if ( qsearch('cust_pkg', { 'custnum' => $custnum, 'cancel' => '' } ) ) { + Move uncancelled packages to customer number +

+%} +This will completely remove all traces of this customer record. This +is not what you want if this is a real customer who has simply +canceled service with you. For that, cancel all of the customer's packages. +(you can optionally hide cancelled customers with the hidecancelledcustomers configuration option) +
+
Are you absolutely sure you want to delete this customer? +
+
+ +<% include('/elements/footer.html') %> + +%#Deleting a customer you have financial records on (i.e. credits) is +%#typically considered fraudulant bookkeeping. Remember, deleting +%#customers should ONLY be used for completely bogus records. You should +%#NOT delete real customers who simply discontinue service. +%# +%#For real customers who simply discontinue service, cancel all of the +%#customer's packages. Customers with all cancelled packages are not +%#billed. There is no need to take further action to prevent billing on +%#customers with all cancelled packages. +%# +%#Also see the "hidecancelledcustomers" and "hidecancelledpackages" +%#configuration options, which will allow you to surpress the display of +%#cancelled customers and packages, respectively. + +<%init> + +my $conf = new FS::Conf; +die "Customer deletions not enabled in configuration" + unless $conf->exists('deletecustomers'); + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Delete customer'); + +my($custnum, $new_custnum); if ( $cgi->param('error') ) { $custnum = $cgi->param('custnum'); $new_custnum = $cgi->param('new_custnum'); } else { - ($query) = $cgi->keywords; + my($query) = $cgi->keywords; $query =~ /^(\d+)$/ or die "Illegal query: $query"; $custnum = $1; $new_custnum = ''; } -$cust_main = qsearchs( 'cust_main', { 'custnum' => $custnum } ) - or die "Customer not found: $custnum"; +my $cust_main = qsearchs( { + 'table' => 'cust_main', + 'hashref' => { 'custnum' => $custnum }, + 'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql, +} ) + or die 'Unknown custnum'; -print header('Delete customer'); - -print qq!Error: !, $cgi->param('error'), - "" - if $cgi->param('error'); - -print - qq!
!, - qq!!; - -if ( qsearch('cust_pkg', { 'custnum' => $custnum, 'cancel' => '' } ) ) { - print "Move uncancelled packages to customer number ", - qq!

!; -} - -print <completely remove all traces of this customer record. This -is not what you want if this is a real customer who has simply -canceled service with you. For that, cancel all of the customer's packages. -(you can optionally hide cancelled customers with the hidecancelledcustomers configuration file) -
-
Are you absolutely sure you want to delete this customer? -
- -END - -%> +