Re-Email Invoice patch
Rick Eicher II
rick at pbol.net
Tue Apr 16 10:06:53 PDT 2002
The boss wanted to be able to resend and email invoice. So I wrote this code
for it.
On the /view/cust_bill.cgi page, I put in a if statement that reads the
cust_main_invoice table to see if they are a print or email invoice
customer. Then I only shows the link that applies to that customer.
I added the email-invoice.cgi file to the /misc dir. I based this from the
print-invoice.cgi file.
Since the files in question are either not in the latest cvs or match the
files there I have submited the code to the group. Here is the patch for the
/view/cust_bill.cgi file.
###################################################
--- cust_bill.cgi Tue Apr 16 05:47:35 2002
+++ /home/freeside/aspdocs/view/cust_bill.cgi Tue Apr 16 05:45:07 2002
@@ -20,9 +20,14 @@
print qq!<A HREF="${p}edit/cust_pay.cgi?$invnum">Enter payments (check/cash)
against this invoice</A> | !
if $cust_bill->owed > 0;
-print qq!<A HREF="${p}misc/print-invoice.cgi?$invnum">Reprint this
invoice</A>!. '<BR><BR>';
+my $cust_main_invoice =
qsearchs('cust_main_invoice',{'custnum'=>$custnum});
+my $dest = $cust_main_invoice->getfield('dest');
-#false laziness with search/cust_bill_event.cgi
+if ($dest eq 'POST'){
+ print qq!<A HREF="${p}misc/print-invoice.cgi?$invnum">Reprint this
invoice</A>!. '<BR><BR>';
+} else {
+ print qq!<A HREF="${p}misc/email-invoice.cgi?$invnum">Re-Email this
invoice</A>!. '<BR><BR>';
+}
print table(). '<TR><TH>Event</TH><TH>Date</TH><TH>Status</TH></TR>';
foreach my $cust_bill_event (
###########################################################
WARNING: the lines probably word wrap.
Here is the email-invoice.cgi file.
#####################################################
<%
my $conf = new FS::Conf;
$invoice_from = $conf->config('invoice_from');
$smtpmachine = $conf->config('smtpmachine');
#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 $custnum = $cust_bill->getfield('custnum');
my $cust_main_invoice = qsearchs('cust_main_invoice',{'custnum'=>$custnum});
my $email = $cust_main_invoice->getfield('dest');
$ENV{SMTPHOSTS} = $smtpmachine;
$ENV{MAILADDRESS} = $invoice_from;
my $header = new Mail::Header ( [
"From: $invoice_from",
"To: $email",
"Sender: $invoice_from",
"Reply-To: $invoice_from",
"Date: ". time2str("%a, %d %b %Y %X %z", time),
"Subject: Invoice",
] );
my $message = new Mail::Internet (
'Header' => $header,
'Body' => [ $cust_bill->print_text ], #( date)
);
$message->smtpsend;
print $cgi->redirect(popurl(2). "view/cust_main.cgi?$custnum#history");
%>
##############################################################
With this patch and this file you can re-email an invoice to a customer or
reprint it.
Rick
More information about the freeside-devel
mailing list