re-email invoice, closes: bug#526 and have print and email invoice links redirect...
authorivan <ivan>
Thu, 12 Feb 2004 06:31:37 +0000 (06:31 +0000)
committerivan <ivan>
Thu, 12 Feb 2004 06:31:37 +0000 (06:31 +0000)
htetc/global.asa
htetc/handler.pl
httemplate/misc/email-invoice.cgi [new file with mode: 0755]
httemplate/misc/print-invoice.cgi
httemplate/view/cust_bill.cgi

index e05701d..e4661c3 100644 (file)
@@ -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;
index 584d930..618c585 100644 (file)
@@ -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 (executable)
index 0000000..7ab1613
--- /dev/null
@@ -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");
+
+%>
index 0dda68a..144f615 100755 (executable)
@@ -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");
 
 %>
index 4d98f3e..50ee8b3 100755 (executable)
@@ -20,7 +20,13 @@ print header('Invoice View', menubar(
 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>';
+print qq!<A HREF="${p}misc/print-invoice.cgi?$invnum">Reprint this invoice</A>!;
+if ( grep { $_ ne 'POST' } $cust_bill->cust_main->invoicing_list ) {
+  print qq! | <A HREF="${p}misc/email-invoice.cgi?$invnum">!.
+        qq!Re-email this invoice</A>!;
+}
+
+print '<BR><BR>';
 
 my $conf = new FS::Conf;
 if ( $conf->exists('invoice_latex') ) {