From 1d2cbbff7fe3600eef0abfb3c0fc0712b3b0506b Mon Sep 17 00:00:00 2001 From: khoff Date: Tue, 30 Dec 2003 06:02:17 +0000 Subject: Pass type as scalar instead of a hashref to work around a bug in DBD::Pg version 1.31. --- FS/FS/Record.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm index 2517d1841..191eee5f0 100644 --- a/FS/FS/Record.pm +++ b/FS/FS/Record.pm @@ -313,9 +313,9 @@ sub qsearch { if ( $record->{$field} =~ /^\d+(\.\d+)?$/ && $dbdef->table($table)->column($field)->type =~ /(int|serial)/i ) { - $sth->bind_param($bind++, $record->{$field}, { TYPE => SQL_INTEGER } ); + $sth->bind_param($bind++, $record->{$field}, SQL_INTEGER); } else { - $sth->bind_param($bind++, $record->{$field}, { TYPE => SQL_VARCHAR } ); + $sth->bind_param($bind++, $record->{$field}, SQL_VARCHAR); } } -- cgit v1.2.1 From e728f9664160d943e02657dd9d83aa1bb7d8e5f4 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 1 Jan 2004 20:40:39 +0000 Subject: escape stuff from latex --- FS/FS/cust_bill.pm | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm index e5c19668d..8adbb6c1d 100644 --- a/FS/FS/cust_bill.pm +++ b/FS/FS/cust_bill.pm @@ -928,15 +928,15 @@ sub print_ps { my %invoice_data = ( 'invnum' => $self->invnum, 'date' => time2str('%b %o, %Y', $self->_date), - 'agent' => $cust_main->agent->agent, - 'payname' => $cust_main->payname, - 'company' => $cust_main->company, - 'address1' => $cust_main->address1, - 'address2' => $cust_main->address2, - 'city' => $cust_main->city, - 'state' => $cust_main->state, - 'zip' => $cust_main->zip, - 'country' => $cust_main->country, + 'agent' => _latex_escape($cust_main->agent->agent), + 'payname' => _latex_escape($cust_main->payname), + 'company' => _latex_escape($cust_main->company), + 'address1' => _latex_escape($cust_main->address1), + 'address2' => _latex_escape($cust_main->address2), + 'city' => _latex_escape($cust_main->city), + 'state' => _latex_escape($cust_main->state), + 'zip' => _latex_escape($cust_main->zip), + 'country' => _latex_escape($cust_main->country), 'footer' => join("\n", $conf->config('invoice_latexfooter') ), 'quantity' => 1, 'terms' => $conf->config('invoice_default_terms') || 'Payable upon receipt', @@ -951,7 +951,7 @@ sub print_ps { $invoice_data{'po_line'} = ( $cust_main->payby eq 'BILL' && $cust_main->payinfo ) - ? "Purchase Order #". $cust_main->payinfo + ? _latex_escape("Purchase Order #". $cust_main->payinfo) : '~'; my @line_item = (); @@ -969,11 +969,11 @@ sub print_ps { foreach my $line_item ( $self->_items ) { #foreach my $line_item ( $self->_items_pkg ) { $invoice_data{'ref'} = $line_item->{'pkgnum'}; - $invoice_data{'description'} = $line_item->{'description'}; + $invoice_data{'description'} = _latex_escape($line_item->{'description'}); if ( exists $line_item->{'ext_description'} ) { $invoice_data{'description'} .= "\\tabularnewline\n~~". - join("\\tabularnewline\n~~", @{$line_item->{'ext_description'}} ); + join("\\tabularnewline\n~~", map { _latex_escape($_) } @{$line_item->{'ext_description'}} ); } $invoice_data{'amount'} = $line_item->{'amount'}; $invoice_data{'product_code'} = $line_item->{'pkgpart'} || 'N/A'; @@ -992,7 +992,7 @@ sub print_ps { my $taxtotal = 0; foreach my $tax ( $self->_items_tax ) { - $invoice_data{'total_item'} = $tax->{'description'}; + $invoice_data{'total_item'} = _latex_escape($tax->{'description'}); $taxtotal += ( $invoice_data{'total_amount'} = $tax->{'amount'} ); push @total_fill, map { my $b=$_; $b =~ s/\$(\w+)/$invoice_data{$1}/eg; $b } @@ -1019,7 +1019,7 @@ sub print_ps { # credits foreach my $credit ( $self->_items_credits ) { - $invoice_data{'total_item'} = $credit->{'description'}; + $invoice_data{'total_item'} = _latex_escape($credit->{'description'}); #$credittotal $invoice_data{'total_amount'} = '-\dollar '. $credit->{'amount'}; push @total_fill, @@ -1029,7 +1029,7 @@ sub print_ps { # payments foreach my $payment ( $self->_items_payments ) { - $invoice_data{'total_item'} = $payment->{'description'}; + $invoice_data{'total_item'} = _latex_escape($payment->{'description'}); #$paymenttotal $invoice_data{'total_amount'} = '-\dollar '. $payment->{'amount'}; push @total_fill, @@ -1143,7 +1143,7 @@ sub _items_previous { my @b = (); foreach ( @pr_cust_bill ) { push @b, { - 'description' => 'Previous Balance, Invoice \#'. $_->invnum. + 'description' => 'Previous Balance, Invoice #'. $_->invnum. ' ('. time2str('%x',$_->_date). ')', #'pkgpart' => 'N/A', 'pkgnum' => 'N/A', -- cgit v1.2.1 From c58132f6a26349d09744ef2b3b235dfb7c3757f6 Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 3 Jan 2004 08:42:10 +0000 Subject: fix heading colspan when there is no agent.disabled column --- httemplate/browse/agent.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httemplate/browse/agent.cgi b/httemplate/browse/agent.cgi index 44343e15c..2eef5bb91 100755 --- a/httemplate/browse/agent.cgi +++ b/httemplate/browse/agent.cgi @@ -55,7 +55,7 @@ full offerings (via their type).

<%= table() %> - param('showdisabled') ? 2 : 3 %>>Agent + param('showdisabled') || !dbdef->table('agent')->column('disabled') ) ? 2 : 3 %>>Agent Type Customers Freq. -- cgit v1.2.1 From c57a4fc790d9ba9eaec58021ef9ee56b8649b6f1 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 4 Jan 2004 03:52:54 +0000 Subject: remove obsolete netscape CCK support depend on HTTP::BrowserDetect directly instead of via deprecated HTTP::Headers::UserAgent (closes: Bug#578) --- fs_signup/FS-SignupClient/cgi/signup.cgi | 41 +++++--------------------------- 1 file changed, 6 insertions(+), 35 deletions(-) diff --git a/fs_signup/FS-SignupClient/cgi/signup.cgi b/fs_signup/FS-SignupClient/cgi/signup.cgi index 8dae9dd12..0a9a51008 100755 --- a/fs_signup/FS-SignupClient/cgi/signup.cgi +++ b/fs_signup/FS-SignupClient/cgi/signup.cgi @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: signup.cgi,v 1.49 2003-12-10 23:53:34 ivan Exp $ +# $Id: signup.cgi,v 1.50 2004-01-04 03:52:54 ivan Exp $ use strict; use vars qw( @payby $cgi $locales $packages @@ -11,7 +11,7 @@ use vars qw( @payby $cgi $locales $packages $paycvv $paydate $payname $referral_custnum $init_popstate $pkgpart $username $password $password2 $sec_phrase $popnum $agentnum $refnum - $ieak_file $ieak_template $cck_file $cck_template + $ieak_file $ieak_template $signup_html $signup_template $success_html $success_template $decline_html $decline_template @@ -26,7 +26,7 @@ use CGI; #use CGI::Carp qw(fatalsToBrowser); use Text::Template; use Business::CreditCard; -use HTTP::Headers::UserAgent 2.00; +use HTTP::BrowserDetect; use FS::SignupClient 0.03 qw( signup_info new_customer ); #acceptable payment methods @@ -37,7 +37,6 @@ use FS::SignupClient 0.03 qw( signup_info new_customer ); @payby = qw( CARD PREPAY ); $ieak_file = '/usr/local/freeside/ieak.template'; -$cck_file = '/usr/local/freeside/cck.template'; $signup_html = -e 'signup.html' ? 'signup.html' : '/usr/local/freeside/signup.html'; @@ -62,17 +61,6 @@ if ( -e $ieak_file ) { $ieak_template = ''; } -if ( -e $cck_file ) { - my $cck_txt = Text::Template::_load_text($cck_file) - or die $Text::Template::ERROR; - $cck_txt =~ /^(.*)$/s; #untaint the template source - it's trusted - $cck_txt = $1; - $cck_template = new Text::Template ( TYPE => 'STRING', SOURCE => $cck_txt ) - or die $Text::Template::ERROR; -} else { - $cck_template = ''; -} - $agentnum = ''; if ( -e $signup_html ) { my $signup_txt = Text::Template::_load_text($signup_html) @@ -339,7 +327,7 @@ sub print_decline { } sub print_okay { - my $user_agent = new HTTP::Headers::UserAgent $ENV{HTTP_USER_AGENT}; + my $user_agent = new HTTP::BrowserDetect $ENV{HTTP_USER_AGENT}; $cgi->param('username') =~ /^(.+)$/ or die "fatal: invalid username got past FS::SignupClient::new_customer"; @@ -362,27 +350,10 @@ sub print_okay { #global for template $pkg = ( grep { $_->{'pkgpart'} eq $pkgpart } @$packages )[0]->{'pkg'}; - if ( $ieak_template - && $user_agent->platform eq 'ia32' - && $user_agent->os =~ /^win/ - && ($user_agent->browser)[0] eq 'IE' - ) - { #send an IEAK config + if ( $ieak_template && $user_agent->windows && $user_agent->ie ) { + #send an IEAK config print $cgi->header('application/x-Internet-signup'), $ieak_template->fill_in(); - } elsif ( $cck_template - && $user_agent->platform eq 'ia32' - && $user_agent->os =~ /^win/ - && ($user_agent->browser)[0] eq 'Netscape' - ) - { #send a Netscape config - my $cck_data = $cck_template->fill_in(); - print $cgi->header('application/x-netscape-autoconfigure-dialer-v2'), - map { - m/(.*)\s+(.*)$/; - pack("N", length($1)). $1. pack("N", length($2)). $2; - } split(/\n/, $cck_data); - } else { #send a simple confirmation print $cgi->header( '-expires' => 'now' ), $success_template->fill_in(); -- cgit v1.2.1 From f75be857e668201b46c88cf8ba718c1f64ec645e Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 4 Jan 2004 03:54:52 +0000 Subject: remove obsolete netscape CCK supportsignup.cgi depend on HTTP::BrowserDetect directly instead of via deprecated HTTP::Headers::UserAgent (closes: Bug#578) --- httemplate/docs/signup.html | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/httemplate/docs/signup.html b/httemplate/docs/signup.html index 684521dc0..97d7aa794 100644 --- a/httemplate/docs/signup.html +++ b/httemplate/docs/signup.html @@ -12,7 +12,7 @@ webserver. On this machine, install:
  • Text::Template
  • Storable
  • Business-CreditCard -
  • HTTP::Headers::UserAgent (version 2.0 or higher; not yet indexed correctly on CPAN) +
  • HTTP::BrowserDetect
  • FS::SignupClient (copy the fs_signup/FS-SignupClient directory to the external machine, then: perl Makefile.PL; make; make install) @@ -37,8 +37,6 @@ Optional:
    • If you create a /usr/local/freeside/ieak.template file on the external machine, it will be sent to IE users with MIME type application/x-Internet-signup. This file will be processed with Text::Template with the variables listed below available. (an example file is included as fs_signup/ieak.template) See the section on internet settings files in the IEAK documentation for more information. -
    • If you create a /usr/local/freeside/cck.template file on the external machine, the variables defined will be sent to Netscape users with MIME type application/x-netscape-autoconfigure-dialer-v2. This file will be processed with Text::Template with the variables listed below available. - (an example file is included as fs_signup/cck.template). See the Netscape documentation for more information.
    • If you create a /usr/local/freeside/success.html file on the external machine, it will be used as the success HTML page. Although template substiutions are available, a regular HTML file will work fine here, unlike signup.html. An example file is included as fs_signup/FS-SignupClient/cgi/success.html
    • Variable substitutions available in ieak.template, cck.template and success.html:
        -- cgit v1.2.1 From 92917c8a5ad3566460e4107e2f23febaa8353fe2 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 4 Jan 2004 04:44:07 +0000 Subject: no more HTTP::Headers::UserAgent! --- fs_signup/FS-SignupClient/Makefile.PL | 1 - 1 file changed, 1 deletion(-) diff --git a/fs_signup/FS-SignupClient/Makefile.PL b/fs_signup/FS-SignupClient/Makefile.PL index c3c213fb6..310200b57 100644 --- a/fs_signup/FS-SignupClient/Makefile.PL +++ b/fs_signup/FS-SignupClient/Makefile.PL @@ -11,7 +11,6 @@ WriteMakefile( 'PREREQ_PM' => { 'Business::CreditCard' => 0, 'HTTP::BrowserDetect' => 0, - 'HTTP::Headers::UserAgent' => 3, 'Text::Template' => 0, 'FS::SelfService' => 0, }, -- cgit v1.2.1 From 430f200a2b7d1862b3923648d3c85168a8e45046 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 5 Jan 2004 20:24:48 +0000 Subject: fix other packages by next bill date link --- httemplate/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httemplate/index.html b/httemplate/index.html index d024de0bf..d4284fa4a 100644 --- a/httemplate/index.html +++ b/httemplate/index.html @@ -123,7 +123,7 @@
      • all packages (by package number)
      • suspended packages (by package number)
      • packages with unconfigured services (by package number) -
      • packages (by next bill date range) +
      • packages (by next bill date range)
      Package definitions (by number of active packages)

      Customers -- cgit v1.2.1 From 89e8639b36b1b0fd474143c53d1664842405c29c Mon Sep 17 00:00:00 2001 From: khoff Date: Wed, 7 Jan 2004 06:10:01 +0000 Subject: Added billing plan sql_external for billing services in an external sql database. --- httemplate/edit/part_pkg.cgi | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/httemplate/edit/part_pkg.cgi b/httemplate/edit/part_pkg.cgi index b697a76b2..f2f99b757 100755 --- a/httemplate/edit/part_pkg.cgi +++ b/httemplate/edit/part_pkg.cgi @@ -474,6 +474,36 @@ tie my %plans, 'Tie::IxHash', #'recur' => '\'my $dbh = DBI->connect("\' + what.datasrc.value + \'", "\' + what.db_username.value + \'", "\' what.db_password.value + \'" ) or die $DBI::errstr; my $sth = $dbh->prepare("\' + what.query.value + \'") or die $dbh->errstr; my $units = 0; foreach my $cust_svc ( grep { $_->part_svc->svcdb eq "svc_domain" } $cust_pkg->cust_svc ) { my $domain = $cust_svc->svc_x->domain; $sth->execute($domain) or die $sth->errstr; $units += $sth->fetchrow_arrayref->[0]; } $units -= \' + what.recur_included.value + \'; $units = 0 if $units < 0; \' + what.recur_flat.value + \' + $units * \' + what.recur_unit_charge + \';\'', }, + + + 'sql_external' => { + 'name' => 'Base charge plus additional fees for external services from a configurable SQL query', + 'fields' => { + 'setup_fee' => { 'name' => 'Setup fee for this package', + 'default' => 0, + }, + 'recur_flat' => { 'name' => 'Base monthly charge for this package', + 'default' => 0, + }, + 'datasrc' => { 'name' => 'DBI data source', + 'default' => '', + }, + 'db_username' => { 'name' => 'Database username', + 'default' => '', + }, + 'db_password' => { 'name' => 'Database password', + 'default' => '', + }, + 'query' => { 'name' => 'SQL query', + 'default' => '', + }, + }, + 'fieldorder' => [qw( setup_fee recur_flat datasrc db_username db_password query )], + 'setup' => 'what.setup_fee.value', + 'recur' => q!'my $dbh = DBI->connect("' + what.datasrc.value + '", "' + what.db_username.value + '", "' + what.db_password.value + '" ) or die $DBI::errstr; my $sth = $dbh->prepare("' + what.query.value + '") or die $dbh->errstr; my $price = ' + what.recur_flat.value + '; foreach my $cust_svc ( grep { $_->part_svc->svcdb eq "svc_external" } $cust_pkg->cust_svc ){ my $id = $cust_svc->svc_x->id; $sth->execute($id) or die $sth->errstr; $price += $sth->fetchrow_arrayref->[0]; } $price;'!, + + }, + ; my %plandata = map { /^(\w+)=(.*)$/; ( $1 => $2 ); } -- cgit v1.2.1 From e68e85f88922d6678a9c6fc1a7624065e38b7361 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 9 Jan 2004 21:10:56 +0000 Subject: adding system_usernames config value --- FS/FS/Conf.pm | 6 ++++++ FS/FS/svc_acct.pm | 16 ++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index b391fe44b..2404e5902 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -1151,6 +1151,12 @@ httemplate/docs/config.html 'type' => 'checkbox', }, + { + 'key' => 'system_usernames' + 'section' => 'username', + 'description' => 'A list of system usernames that cannot be edited or removed, one per line. Use a bare username to prohibit modification/deletion of the username in any domain, or username@domain to prohibit modification/deletetion of a specific username and domain.', + 'type' => 'textarea', + }, ); 1; diff --git a/FS/FS/svc_acct.pm b/FS/FS/svc_acct.pm index fce443634..3ddd70a93 100644 --- a/FS/FS/svc_acct.pm +++ b/FS/FS/svc_acct.pm @@ -427,6 +427,8 @@ The corresponding FS::cust_svc record will be deleted as well. sub delete { my $self = shift; + return "can't delete system account" if $self->_check_system; + return "Can't delete an account which is a (svc_forward) source!" if qsearch( 'svc_forward', { 'srcsvc' => $self->svcnum } ); @@ -515,6 +517,8 @@ sub replace { my $error; warn "$me replacing $old with $new\n" if $DEBUG; + return "can't modify system account" if $old->_check_system; + return "Username in use" if $old->username ne $new->username && qsearchs( 'svc_acct', { 'username' => $new->username, @@ -614,6 +618,7 @@ Called by the suspend method of FS::cust_pkg (see L). sub suspend { my $self = shift; + return "can't suspend system account" if $self->_check_system; my %hash = $self->hash; unless ( $hash{_password} =~ /^\*SUSPENDED\* / || $hash{_password} eq '*' @@ -839,6 +844,17 @@ sub check { $self->SUPER::check; } +=item _check_system + +=cut + +sub _check_system { + my $self = shift; + scalar( grep { $self->username eq $_ || $self->email eq $_ } + $conf->config('system_usernames') + ); +} + =item radius Depriciated, use radius_reply instead. -- cgit v1.2.1 From f3212b82d6d54500bbe31c02c8ffa456f018a067 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 9 Jan 2004 22:11:54 +0000 Subject: add deletecredits config value to enable deletion of credits --- FS/FS/Conf.pm | 9 +++++- FS/FS/cust_credit.pm | 59 +++++++++++++++++++++++++++++++++- FS/FS/cust_credit_bill.pm | 5 ++- httemplate/misc/delete-cust_credit.cgi | 16 +++++++++ httemplate/view/cust_main.cgi | 11 ++++++- 5 files changed, 96 insertions(+), 4 deletions(-) create mode 100755 httemplate/misc/delete-cust_credit.cgi diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index 2404e5902..11243a91b 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -332,7 +332,14 @@ httemplate/docs/config.html { 'key' => 'deletepayments', 'section' => 'UI', - 'description' => 'Enable deletion of unclosed payments. Be very careful! Only delete payments that were data-entry errors, not adjustments. Optionally specify one or more comma-separated email addresses to be notified when a payment is deleted.', + 'description' => 'Enable deletion of unclosed payments. Be very careful! Only delete payments that were data-entry errors, not adjustments. Optionally specify one or more comma-separated email addresses to be notified when a payment is deleted.', + 'type' => [qw( checkbox text )], + }, + + { + 'key' => 'deletecredits', + 'section' => 'UI', + 'description' => 'Enable deletion of unclosed credits. Be very careful! Only delete credits that were data-entry errors, not adjustments. Optionally specify one or more comma-separated email addresses to be notified when a credit is deleted.', 'type' => [qw( checkbox text )], }, diff --git a/FS/FS/cust_credit.pm b/FS/FS/cust_credit.pm index 18ab1c361..90f9b59ed 100644 --- a/FS/FS/cust_credit.pm +++ b/FS/FS/cust_credit.pm @@ -130,7 +130,64 @@ Currently unimplemented. sub delete { my $self = shift; return "Can't delete closed credit" if $self->closed =~ /^Y/i; - $self->SUPER::delete(@_); + + local $SIG{HUP} = 'IGNORE'; + local $SIG{INT} = 'IGNORE'; + local $SIG{QUIT} = 'IGNORE'; + local $SIG{TERM} = 'IGNORE'; + local $SIG{TSTP} = 'IGNORE'; + local $SIG{PIPE} = 'IGNORE'; + + my $oldAutoCommit = $FS::UID::AutoCommit; + local $FS::UID::AutoCommit = 0; + my $dbh = dbh; + + foreach my $cust_credit_bill ( $self->cust_credit_bill ) { + my $error = $cust_credit_bill->delete; + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return $error; + } + } + + my $error = $self->SUPER::delete(@_); + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return $error; + } + + if ( $conf->config('deletecredits') ne '' ) { + + my $cust_main = qsearchs('cust_main',{ 'custnum' => $self->custnum }); + + my $error = send_email( + 'from' => $conf->config('invoice_from'), #??? well as good as any + 'to' => $conf->config('deletecredits'), + 'subject' => 'FREESIDE NOTIFICATION: Credit deleted', + 'body' => [ + "This is an automatic message from your Freeside installation\n", + "informing you that the following credit has been deleted:\n", + "\n", + 'crednum: '. $self->crednum. "\n", + 'custnum: '. $self->custnum. + " (". $cust_main->last. ", ". $cust_main->first. ")\n", + 'amount: $'. sprintf("%.2f", $self->amount). "\n", + 'date: '. time2str("%a %b %e %T %Y", $self->_date). "\n", + 'reason: '. $self->reason. "\n", + ], + ); + + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return "can't send credit deletion notification: $error"; + } + + } + + $dbh->commit or die $dbh->errstr if $oldAutoCommit; + + ''; + } =item replace OLD_RECORD diff --git a/FS/FS/cust_credit_bill.pm b/FS/FS/cust_credit_bill.pm index 88a732bc6..bd76c2e1a 100644 --- a/FS/FS/cust_credit_bill.pm +++ b/FS/FS/cust_credit_bill.pm @@ -96,7 +96,10 @@ Currently unimplemented. =cut sub delete { - return "Can't unapply credit!" + my $self = shift; + return "Can't delete application for closed credit" + if $self->cust_credit->closed =~ /^Y/i; + $self->SUPER::delete(@_); } =item replace OLD_RECORD diff --git a/httemplate/misc/delete-cust_credit.cgi b/httemplate/misc/delete-cust_credit.cgi new file mode 100755 index 000000000..30de04d27 --- /dev/null +++ b/httemplate/misc/delete-cust_credit.cgi @@ -0,0 +1,16 @@ +<% + +#untaint crednum +my($query) = $cgi->keywords; +$query =~ /^(\d+)$/ || die "Illegal crednum"; +my $crednum = $1; + +my $cust_credit = qsearchs('cust_credit',{'crednum'=>$crednum}); +my $custnum = $cust_credit->custnum; + +my $error = $cust_credit->delete; +eidiot($error) if $error; + +print $cgi->redirect($p. "view/cust_main.cgi?". $custnum); + +%> diff --git a/httemplate/view/cust_main.cgi b/httemplate/view/cust_main.cgi index fb015671f..8123b2f82 100755 --- a/httemplate/view/cust_main.cgi +++ b/httemplate/view/cust_main.cgi @@ -554,6 +554,11 @@ function cust_pay_unapply_areyousure(href) { == true) window.location.href = href; } +function cust_credit_areyousure(href) { + if (confirm("Are you sure you want to delete this credit?") + == true) + window.location.href = href; +} END @@ -628,9 +633,13 @@ if ( $conf->config('payby-default') ne 'HIDE' ) { $cust_credit->reason, time2str("%D", $cust_credit_bill->_date), ); + my $delete = + $cust_credit->closed !~ /^Y/i && $conf->exists('deletecredits') + ? qq! (delete)! + : ''; push @history, "$date\tCredit #$crednum: $reason
      ". - "(applied to invoice #$invnum on $app_date)\t\t\t$amount\t"; + "(applied to invoice #$invnum on $app_date)$delete\t\t\t$amount\t"; } } -- cgit v1.2.1