From f4ffa3596c3b8bfc9e862c2a7e8efc68f86207ab Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 12 Feb 2004 06:31:37 +0000 Subject: [PATCH] re-email invoice, closes: bug#526 and have print and email invoice links redirect back to top of customer view page instead of #history tag --- htetc/global.asa | 1 + htetc/handler.pl | 1 + httemplate/misc/email-invoice.cgi | 23 +++++++++++++++++++++++ httemplate/misc/print-invoice.cgi | 2 +- httemplate/view/cust_bill.cgi | 8 +++++++- 5 files changed, 33 insertions(+), 2 deletions(-) create mode 100755 httemplate/misc/email-invoice.cgi diff --git a/htetc/global.asa b/htetc/global.asa index e05701d56..e4661c3cb 100644 --- a/htetc/global.asa +++ b/htetc/global.asa @@ -22,6 +22,7 @@ use FS::Conf; use FS::CGI qw(header menubar popurl table itable ntable idiot eidiot small_custview myexit http_header); use FS::Msgcat qw(gettext geterror); +use FS::Misc qw( send_email ); use FS::agent; use FS::agent_type; diff --git a/htetc/handler.pl b/htetc/handler.pl index 584d930b1..618c5856f 100644 --- a/htetc/handler.pl +++ b/htetc/handler.pl @@ -80,6 +80,7 @@ sub handler use FS::CGI qw(header menubar popurl table itable ntable idiot eidiot small_custview myexit http_header); use FS::Msgcat qw(gettext geterror); + use FS::Misc qw( send_email ); use FS::agent; use FS::agent_type; diff --git a/httemplate/misc/email-invoice.cgi b/httemplate/misc/email-invoice.cgi new file mode 100755 index 000000000..7ab1613ee --- /dev/null +++ b/httemplate/misc/email-invoice.cgi @@ -0,0 +1,23 @@ +<% + +my $conf = new FS::Conf; + +#untaint invnum +my($query) = $cgi->keywords; +$query =~ /^(\d*)$/; +my $invnum = $1; +my $cust_bill = qsearchs('cust_bill',{'invnum'=>$invnum}); +die "Can't find invoice!\n" unless $cust_bill; + +my $error = send_email( + 'from' => $conf->config('invoice_from'), + 'to' => [ grep { $_ ne 'POST' } $cust_bill->cust_main->invoicing_list ], + 'subject' => 'Invoice', + 'body' => [ $cust_bill->print_text ], +); +eidiot($error) if $error; + +my $custnum = $cust_bill->getfield('custnum'); +print $cgi->redirect("${p}view/cust_main.cgi?$custnum"); + +%> diff --git a/httemplate/misc/print-invoice.cgi b/httemplate/misc/print-invoice.cgi index 0dda68a4e..144f6156a 100755 --- a/httemplate/misc/print-invoice.cgi +++ b/httemplate/misc/print-invoice.cgi @@ -24,6 +24,6 @@ die "Can't find invoice!\n" unless $cust_bill; my $custnum = $cust_bill->getfield('custnum'); -print $cgi->redirect(popurl(2). "view/cust_main.cgi?$custnum#history"); +print $cgi->redirect("${p}view/cust_main.cgi?$custnum"); %> diff --git a/httemplate/view/cust_bill.cgi b/httemplate/view/cust_bill.cgi index 4d98f3ebc..50ee8b36c 100755 --- a/httemplate/view/cust_bill.cgi +++ b/httemplate/view/cust_bill.cgi @@ -20,7 +20,13 @@ print header('Invoice View', menubar( print qq!Enter payments (check/cash) against this invoice | ! if $cust_bill->owed > 0; -print qq!Reprint this invoice!. '

'; +print qq!Reprint this invoice!; +if ( grep { $_ ne 'POST' } $cust_bill->cust_main->invoicing_list ) { + print qq! | !. + qq!Re-email this invoice!; +} + +print '

'; my $conf = new FS::Conf; if ( $conf->exists('invoice_latex') ) { -- 2.11.0