diff options
author | ivan <ivan> | 2011-10-25 22:35:14 +0000 |
---|---|---|
committer | ivan <ivan> | 2011-10-25 22:35:14 +0000 |
commit | 75769d888d9c306d5d5ccde3260c0267268cf4ed (patch) | |
tree | cbcb69b4d672826dc78064393d182e3eb7144659 /httemplate | |
parent | a4c7ef67a9ca3c473c48f7176865408e619933d0 (diff) |
add legacy_cust_bill to hold legacy invoice content, RT#12981
Diffstat (limited to 'httemplate')
-rw-r--r-- | httemplate/view/cust_main/payment_history.html | 9 | ||||
-rw-r--r-- | httemplate/view/cust_main/payment_history/legacy_invoice.html | 23 | ||||
-rwxr-xr-x | httemplate/view/legacy_cust_bill-pdf.cgi | 35 | ||||
-rwxr-xr-x | httemplate/view/legacy_cust_bill.html | 62 |
4 files changed, 129 insertions, 0 deletions
diff --git a/httemplate/view/cust_main/payment_history.html b/httemplate/view/cust_main/payment_history.html index 64a708976..752f56562 100644 --- a/httemplate/view/cust_main/payment_history.html +++ b/httemplate/view/cust_main/payment_history.html @@ -396,6 +396,15 @@ my %opt = ( ) ); +#legacy invoices +foreach my $legacy_cust_bill ($cust_main->legacy_cust_bill) { + push @history, { + 'date' => $legacy_cust_bill->_date, + 'desc' => include('payment_history/legacy_invoice.html', $legacy_cust_bill, %opt ), + 'charge' => $legacy_cust_bill->charged, + }; +} + #invoices foreach my $cust_bill ($cust_main->cust_bill) { push @history, { diff --git a/httemplate/view/cust_main/payment_history/legacy_invoice.html b/httemplate/view/cust_main/payment_history/legacy_invoice.html new file mode 100644 index 000000000..e999a251e --- /dev/null +++ b/httemplate/view/cust_main/payment_history/legacy_invoice.html @@ -0,0 +1,23 @@ +<% $link %><% $invoice %><% $link ? '</A>' : '' %> +<%init> + +my( $legacy_cust_bill ) = @_; #, %opt ) + +my $invoice; +if ( length($legacy_cust_bill->legacyid) ) { + $invoice = emt('Legacy Invoice #[_1]', $legacy_cust_bill->legacyid); +} else { + $invoice = emt('Legacy Invoice'); +} + +my $legacyinvnum = $legacy_cust_bill->legacyinvnum; + +my $link = ''; +if ( $FS::CurrentUser::CurrentUser->access_right('View invoices') ) { + $link = length($legacy_cust_bill->content_html) + ? qq!<A HREF="${p}view/legacy_cust_bill.html?$legacyinvnum">! + : length($legacy_cust_bill->content_pdf) + ? qq!<A HREF="${p}view/legacy_cust_bill-pdf.cgi?$legacyinvnum">! + : ''; + +</%init> diff --git a/httemplate/view/legacy_cust_bill-pdf.cgi b/httemplate/view/legacy_cust_bill-pdf.cgi new file mode 100755 index 000000000..c6ecfb17f --- /dev/null +++ b/httemplate/view/legacy_cust_bill-pdf.cgi @@ -0,0 +1,35 @@ +<% $content %>\ +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('View invoices'); + +my $legacyinvnum; +my($query) = $cgi->keywords; +if ( $query =~ /^(\d+)(.pdf)?$/ ) { #.pdf probably not necessary anymore? + $legacyinvnum = $1; +} else { + $legacyinvnum = $cgi->param('legacyinvnum'); + $legacyinvnum =~ s/\.pdf//i; #probably not necessary anymore +} + +my $legacy_cust_bill = qsearchs({ + 'select' => 'legacy_cust_bill.*', + 'table' => 'legacy_cust_bill', + 'addl_from' => 'LEFT JOIN cust_main USING ( custnum )', + 'hashref' => { 'legacyinvnum' => $legacyinvnum }, + 'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql, +}); +die "Legacy invoice #$legacyinvnum not found!" unless $legacy_cust_bill; + +my $content = $legacy_cust_bill->content_pdf; + +#maybe should name the file after legacyid if present, but have to clean it +#my $filename = $legacy_cust_bill->legacyid + +http_header('Content-Type' => 'application/pdf' ); +http_header('Content-Disposition' => "filename=$legacyinvnum.pdf" ); +http_header('Content-Length' => length($content) ); +#http_header('Cache-control' => 'max-age=60' ); + +</%init> diff --git a/httemplate/view/legacy_cust_bill.html b/httemplate/view/legacy_cust_bill.html new file mode 100755 index 000000000..29e4e6ebe --- /dev/null +++ b/httemplate/view/legacy_cust_bill.html @@ -0,0 +1,62 @@ +<& /elements/header.html, mt('Legacy Invoice View'), menubar( + emt("View this customer (#[_1])",$display_custnum) => "${p}view/cust_main.cgi?$custnum", +) &> + +% if ( 0 ) { #implement resending of legacy invoices? +% #if ( $curuser->access_right('Resend invoices') ) { + + <A HREF="<% $p %>misc/send-invoice.cgi?method=print;<% $link %>"><% mt('Re-print this invoice') |h %></A> + +% if ( grep { $_ ne 'POST' } $legacy_cust_bill->cust_main->invoicing_list ) { + | <A HREF="<% $p %>misc/send-invoice.cgi?method=email;<% $link %>"><% mt('Re-email this invoice') |h %></A> +% } + +% if ( $conf->exists('hylafax') && length($legacy_cust_bill->cust_main->fax) ) { + | <A HREF="<% $p %>misc/send-invoice.cgi?method=fax;<% $link %>"><% mt('Re-fax this invoice') |h %></A> +% } + + <BR><BR> + +% } + +% if ( length($legacy_cust_bill->content_pdf) ) { + + <A HREF="<% $p %>view/legacy_cust_bill-pdf.cgi?<% $link %>"><% mt('View typeset invoice PDF') |h %></A> + <BR><BR> +% } + +<% $legacy_cust_bill->content_html %> + +<& /elements/footer.html &> +<%init> + +my $curuser = $FS::CurrentUser::CurrentUser; + +die "access denied" + unless $curuser->access_right('View invoices'); + +my $legacyinvnum; +my($query) = $cgi->keywords; +if ( $query =~ /^(\d+)$/ ) { + $legacyinvnum = $3; +} else { + $legacyinvnum = $cgi->param('legacyinvnum'); +} + +my $conf = new FS::Conf; + +my $legacy_cust_bill = qsearchs({ + 'select' => 'legacy_cust_bill.*', + 'table' => 'legacy_cust_bill', + 'addl_from' => 'LEFT JOIN cust_main USING ( custnum )', + 'hashref' => { 'legacyinvnum' => $legacyinvnum }, + 'extra_sql' => ' AND '. $curuser->agentnums_sql, +}); +die "Legacy invoice #$legacyinvnum not found!" unless $legacy_cust_bill; + +my $custnum = $legacy_cust_bill->custnum; +my $display_custnum = $legacy_cust_bill->cust_main->display_custnum; + +my $link = "legacyinvnum=$legacyinvnum"; + +</%init> |