From da068326c1f0df0cc574caf86745847ebf855b39 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 11 Jan 2004 23:38:17 +0000 Subject: fix for pdf --- httemplate/view/cust_bill-pdf.cgi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/httemplate/view/cust_bill-pdf.cgi b/httemplate/view/cust_bill-pdf.cgi index 03340a16f..7aa69100d 100755 --- a/httemplate/view/cust_bill-pdf.cgi +++ b/httemplate/view/cust_bill-pdf.cgi @@ -8,6 +8,6 @@ my $invnum = $1; my $cust_bill = qsearchs('cust_bill',{'invnum'=>$invnum}); die "Invoice #$invnum not found!" unless $cust_bill; -http_header('Content-Type' => 'application/postscript' ); +http_header('Content-Type' => 'application/pdf' ); %> -<%= $cust_bill->print_ps %> +<%= $cust_bill->print_pdf %> -- cgit v1.2.1 From 0fd894c50eaa84169115ccbb682a53f5148a8c9c Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 11 Jan 2004 23:59:20 +0000 Subject: typeset invoice view in web UI uses pdf instead of postscript, closes Bug#614 --- FS/FS/cust_bill.pm | 84 ++++++++++++++++++++++++++++++++++++++----- httemplate/view/cust_bill.cgi | 2 +- 2 files changed, 76 insertions(+), 10 deletions(-) diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm index 8adbb6c1d..a5602a708 100644 --- a/FS/FS/cust_bill.pm +++ b/FS/FS/cust_bill.pm @@ -888,9 +888,12 @@ sub print_text { } -=item print_ps [ TIME [ , TEMPLATE ] ] +=item print_latex [ TIME [ , TEMPLATE ] ] -Returns an postscript invoice, as a scalar. +Internal method - returns a filename of a filled-in LaTeX template for this +invoice (Note: add ".tex" to get the actual filename). + +See print_ps and print_pdf for methods that return PostScript and PDF output. TIME an optional value used to control the printing of overdue messages. The default is now. It isn't the date of the invoice; that's the `_date' field. @@ -900,7 +903,7 @@ L and L for conversion functions. =cut #still some false laziness w/print_text -sub print_ps { +sub print_latex { my( $self, $today, $template ) = @_; $today ||= time; @@ -1070,17 +1073,37 @@ sub print_ps { print TEX join("\n", @filled_in ), "\n"; close TEX; + return $file; + +} + +=item print_ps [ TIME [ , TEMPLATE ] ] + +Returns an postscript invoice, as a scalar. + +TIME an optional value used to control the printing of overdue messages. The +default is now. It isn't the date of the invoice; that's the `_date' field. +It is specified as a UNIX timestamp; see L. Also see +L and L for conversion functions. + +=cut + +sub print_ps { + my $self = shift; + + my $file = $self->print_latex(@_); + #error checking!! system('pslatex', "$file.tex"); system('pslatex', "$file.tex"); - #system('dvips', '-t', 'letter', "$file.dvi", "$file.ps"); - system('dvips', '-t', 'letter', "$file.dvi", '-o', "$file.ps" ); + system('dvips', '-q', '-t', 'letter', "$file.dvi", '-o', "$file.ps" ); - open(POSTSCRIPT, "<$file.ps") or die "can't open $file.ps (probable error in LaTeX template): $!\n"; + open(POSTSCRIPT, "<$file.ps") + or die "can't open $file.ps (probable error in LaTeX template): $!\n"; #rm $file.dvi $file.log $file.aux - #unlink("$file.dvi", "$file.log", "$file.aux", "$file.ps"); - unlink("$file.dvi", "$file.log", "$file.aux"); + unlink("$file.dvi", "$file.log", "$file.aux", "$file.ps"); + #unlink("$file.dvi", "$file.log", "$file.aux"); my $ps = ''; while () { @@ -1093,7 +1116,50 @@ sub print_ps { } -# quick subroutine for print_ps +=item print_pdf [ TIME [ , TEMPLATE ] ] + +Returns an PDF invoice, as a scalar. + +TIME an optional value used to control the printing of overdue messages. The +default is now. It isn't the date of the invoice; that's the `_date' field. +It is specified as a UNIX timestamp; see L. Also see +L and L for conversion functions. + +=cut + +sub print_pdf { + my $self = shift; + + my $file = $self->print_latex(@_); + + #system('pdflatex', "$file.tex"); + #system('pdflatex', "$file.tex"); + #! LaTeX Error: Unknown graphics extension: .eps. + + #error checking!! + system('pslatex', "$file.tex"); + system('pslatex', "$file.tex"); + + #system('dvipdf', "$file.dvi", "$file.pdf" ); + system("dvips -q -t letter -f $file.dvi | gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=$file.pdf -c save pop -"); + + open(PDF, "<$file.pdf") + or die "can't open $file.pdf (probably error in LaTeX tempalte: $!\n"; + + unlink("$file.dvi", "$file.log", "$file.aux", "$file.pdf"); + + my $pdf = ''; + while () { + $pdf .= $_; + } + + close PDF; + + return $pdf; + +} + +# quick subroutine for print_latex # # There are ten characters that LaTeX treats as special characters, which # means that they do not simply typeset themselves: diff --git a/httemplate/view/cust_bill.cgi b/httemplate/view/cust_bill.cgi index ddc92748d..4e0c4383b 100755 --- a/httemplate/view/cust_bill.cgi +++ b/httemplate/view/cust_bill.cgi @@ -23,7 +23,7 @@ print qq!Enter payments (check/cash) aga print qq!Reprint this invoice!. '

'; print menubar( - 'View typeset invoice' => "${p}view/cust_bill-ps.cgi?$invnum", + 'View typeset invoice' => "${p}view/cust_bill-pdf.cgi?$invnum", ), '

'; #false laziness with search/cust_bill_event.cgi -- cgit v1.2.1 From 13481802b29a511fa0aa1d10e2ad463e362bf8ed Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 12 Jan 2004 00:03:45 +0000 Subject: only display "view typeset invoice" when there is an invoice_latex template --- httemplate/view/cust_bill.cgi | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/httemplate/view/cust_bill.cgi b/httemplate/view/cust_bill.cgi index 4e0c4383b..4d98f3ebc 100755 --- a/httemplate/view/cust_bill.cgi +++ b/httemplate/view/cust_bill.cgi @@ -22,9 +22,12 @@ print qq!Enter payments (check/cash) aga print qq!Reprint this invoice!. '

'; -print menubar( - 'View typeset invoice' => "${p}view/cust_bill-pdf.cgi?$invnum", -), '

'; +my $conf = new FS::Conf; +if ( $conf->exists('invoice_latex') ) { + print menubar( + 'View typeset invoice' => "${p}view/cust_bill-pdf.cgi?$invnum", + ), '

'; +} #false laziness with search/cust_bill_event.cgi -- cgit v1.2.1 From eb54e94a13683132c91bfb33ab90339e88e465c2 Mon Sep 17 00:00:00 2001 From: khoff Date: Mon, 12 Jan 2004 20:34:02 +0000 Subject: $pvf isn't a global. --- httemplate/browse/part_virtual_field.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httemplate/browse/part_virtual_field.cgi b/httemplate/browse/part_virtual_field.cgi index 9bb5c1373..a0009dabd 100644 --- a/httemplate/browse/part_virtual_field.cgi +++ b/httemplate/browse/part_virtual_field.cgi @@ -23,7 +23,7 @@ foreach (qsearch('part_virtual_field', {})) { <%=table()%> Field nameDescription -<% foreach $pvf (sort {$a->name cmp $b->name} @{ $pvfs{$dbtable} }) { %> +<% foreach my $pvf (sort {$a->name cmp $b->name} @{ $pvfs{$dbtable} }) { %> -- cgit v1.2.1 From bceb76982c9a2516122d7996f2a4c2a30cd79a45 Mon Sep 17 00:00:00 2001 From: khoff Date: Mon, 12 Jan 2004 20:40:28 +0000 Subject: Lists are just better sorted. --- httemplate/edit/part_virtual_field.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httemplate/edit/part_virtual_field.cgi b/httemplate/edit/part_virtual_field.cgi index 8bc84387f..fb10321e8 100644 --- a/httemplate/edit/part_virtual_field.cgi +++ b/httemplate/edit/part_virtual_field.cgi @@ -47,7 +47,7 @@ Field #<%=$vfieldpart or "(NEW)"%>

<% if ($action eq 'Add') { %>