From b9982a0314b74a8fb342a20568a3e15b90d625bc Mon Sep 17 00:00:00 2001 From: tetragon Date: Sat, 26 May 2007 23:57:13 +0000 Subject: Adding PDF and Postscript support to LedgerSMB::Template Removing all calls to $form->parse_template git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1241 4979c152-3d1c-0410-bac9-87ea11338e46 --- Build.PL | 1 + LedgerSMB/Template.pm | 67 ++++++++++++------ LedgerSMB/Template/HTML.pm | 31 ++++++++- LedgerSMB/Template/PDF.pm | 82 ++++++++++++++++++++++ LedgerSMB/Template/PS.pm | 83 +++++++++++++++++++++++ LedgerSMB/Template/TXT.pm | 83 +++++++++++++++++++++++ Makefile.PL | 1 + bin/arapprn.pl | 58 ++++++---------- bin/cp.pl | 27 +++----- bin/io.pl | 28 +++----- bin/jc.pl | 11 ++- bin/pos.pl | 25 +++---- bin/rp.pl | 80 ++++++++-------------- t/01-load.t | 4 +- t/04-template-handling.t | 32 +++++---- templates/demo/ap_transaction.tex | 69 ++++++++++--------- templates/demo/ar_transaction.tex | 74 +++++++++++--------- templates/demo/bin_list.tex | 65 ++++++++++-------- templates/demo/check.tex | 15 +++-- templates/demo/invoice.tex | 127 +++++++++++++++++++---------------- templates/demo/packing_list.tex | 67 +++++++++--------- templates/demo/pick_list.tex | 60 +++++++++-------- templates/demo/purchase_order.tex | 99 ++++++++++++++------------- templates/demo/receipt.tex | 15 +++-- templates/demo/request_quotation.tex | 89 ++++++++++++------------ templates/demo/sales_order.tex | 107 +++++++++++++++-------------- templates/demo/sales_quotation.tex | 88 +++++++++++++----------- templates/demo/statement.tex | 31 +++++---- templates/demo/timecard.tex | 4 +- templates/demo/work_order.tex | 72 +++++++++++--------- 30 files changed, 973 insertions(+), 622 deletions(-) create mode 100755 LedgerSMB/Template/PDF.pm create mode 100755 LedgerSMB/Template/PS.pm create mode 100755 LedgerSMB/Template/TXT.pm diff --git a/Build.PL b/Build.PL index 0c2bf50c..c0065bb8 100644 --- a/Build.PL +++ b/Build.PL @@ -28,6 +28,7 @@ my $build = Module::Build->new ( 'MIME::Lite' => 0, 'Error' => 0, 'Template' => 0, + 'Template::Latex' => 0, 'Test::More' => 0, 'Test::Trap' => 0, 'Test::Exception' => 0, diff --git a/LedgerSMB/Template.pm b/LedgerSMB/Template.pm index 77c7a78a..0a822f7d 100755 --- a/LedgerSMB/Template.pm +++ b/LedgerSMB/Template.pm @@ -3,10 +3,9 @@ LedgerSMB::Template - Template support module for LedgerSMB -=head1 SYOPSIS +=head1 SYNOPSIS -This module renders templates to provide HTML interfaces. LaTeX support -forthcoming. +This module renders templates. =head1 METHODS @@ -25,6 +24,10 @@ include_path allows one to override the template directory and use this with use This command renders the template and writes the result to standard output. Currently email and server-side printing are not supported. +=item output + +This function outputs the rendered file in an appropriate manner. + =item my $bool = _valid_language() This command checks for valid langages. Returns 1 if the language is valid, @@ -43,7 +46,6 @@ your software. package LedgerSMB::Template; use Error qw(:try); -use Template; use LedgerSMB::Sysconfig; sub new { @@ -55,7 +57,13 @@ sub new { $self->{template} = $args{template}; $self->{format} = $args{format}; $self->{language} = $args{language}; - $self->{output} = ''; + if ($args{outputfile}) { + $self->{outputfile} = + "${LedgerSMB::Sysconfig::tempdir}/$args{outputfile}"; + } else { + $self->{outputfile} = + "${LedgerSMB::Sysconfig::tempdir}/$args{template}-output"; + } $self->{include_path} = $args{path}; $self->{locale} = $args{locale}; @@ -89,16 +97,8 @@ sub _valid_language { sub render { my $self = shift; my $vars = shift; - my $template; my $format = "LedgerSMB::Template::$self->{format}"; - $template = Template->new({ - INCLUDE_PATH => $self->{include_path}, - START_TAG => quotemeta(' quotemeta('?>'), - DELIMITER => ';', - }) || throw Error::Simple Template->error(); - eval "require $format"; if ($@) { throw Error::Simple $@; @@ -108,15 +108,44 @@ sub render { if (UNIVERSAL::isa($self->{locale}, 'LedgerSMB::Locale')){ $cleanvars->{text} = $self->{locale}->text(); } - if (not $template->process( - $format->can('get_template')->($self->{template}), - $cleanvars, \$self->{output}, binmode => ':utf8')) { - throw Error::Simple $template->error(); + + $format->can('process')->($self, $cleanvars); + return $format->can('postprocess')->($self); +} + +sub output { + my $self = shift; + my $method = shift; + + if ('mail' eq lc $method) { + #XXX do something + $self->_http_output; + } elsif ('print' eq lc $method) { + #XXX do something + $self->_http_output; + } else { + $self->_http_output; } +} - $format->can('postprocess')->($self); +sub _http_output { + my $self = shift; + my $FH; - return $self->{output}; + if ($self->{mimetype} =~ /^text/) { + print "Content-Type: $self->{mimetype}; charset=utf-8\n\n"; + } else { + print "Content-Type: $self->{mimetype}\n\n"; + } + open($FH, '<', $self->{rendered}) or + throw Error::Simple 'Unable to open rendered file'; + while (<$FH>) { + print $_; + } + close($FH); + unlink($self->{rendered}) or + throw Error::Simple 'Unable to delete output file'; + exit; } 1; diff --git a/LedgerSMB/Template/HTML.pm b/LedgerSMB/Template/HTML.pm index d052319d..d02000a9 100755 --- a/LedgerSMB/Template/HTML.pm +++ b/LedgerSMB/Template/HTML.pm @@ -7,7 +7,7 @@ LedgerSMB::Template::HTML Template support module for LedgerSMB =over -=item get_template () +=item get_template ($name) Returns the appropriate template filename for this format. @@ -16,7 +16,11 @@ Returns the appropriate template filename for this format. This method returns a reference to a hash that contains a copy of the passed hashref's data with HTML entities converted to escapes. -=item postprocess () +=item process ($parent, $cleanvars) + +Processes the template for HTML. + +=item postprocess ($parent) Currently does nothing. @@ -37,6 +41,7 @@ package LedgerSMB::Template::HTML; use Error qw(:try); use CGI; +use Template; sub get_template { my $name = shift; @@ -65,9 +70,29 @@ sub preprocess { return $vars; } +sub process { + my $parent = shift; + my $cleanvars = shift; + my $template; + + $template = Template->new({ + INCLUDE_PATH => $parent->{include_path}, + START_TAG => quotemeta(' quotemeta('?>'), + DELIMITER => ';', + }) || throw Error::Simple Template->error(); + if (not $template->process( + get_template($parent->{template}), + $cleanvars, "$parent->{outputfile}.html", binmode => ':utf8')) { + throw Error::Simple $template->error(); + } + $parent->{mimetype} = 'text/html'; +} + sub postprocess { my $parent = shift; - return; + $parent->{rendered} = "$parent->{outputfile}.html"; + return "$parent->{outputfile}.html"; } 1; diff --git a/LedgerSMB/Template/PDF.pm b/LedgerSMB/Template/PDF.pm new file mode 100755 index 00000000..72c080c6 --- /dev/null +++ b/LedgerSMB/Template/PDF.pm @@ -0,0 +1,82 @@ + +=head1 NAME + +LedgerSMB::Template::PDF Template support module for LedgerSMB + +=head1 METHODS + +=over + +=item get_template ($name) + +Returns the appropriate template filename for this format. + +=item preprocess ($vars) + +Currently does nothing. + +=item process ($parent, $cleanvars) + +Processes the template for PDF. + +=item postprocess ($parent) + +Currently does nothing. + +=back + +=head1 Copyright (C) 2007, The LedgerSMB core team. + +This work contains copyrighted information from a number of sources all used +with permission. + +It is released under the GNU General Public License Version 2 or, at your +option, any later version. See COPYRIGHT file for details. For a full list +including contact information of contributors, maintainers, and copyright +holders, see the CONTRIBUTORS file. +=cut + +package LedgerSMB::Template::PDF; + +use Error qw(:try); +use Template::Latex; + +sub get_template { + my $name = shift; + return "${name}.tex"; +} +sub preprocess { + my $rawvars = shift; + my $vars; + my $type = ref $rawvars; + return $vars; +} + +sub process { + my $parent = shift; + my $cleanvars = shift; + my $template; + + $template = Template::Latex->new({ + LATEX_FORMAT => 'pdf', + INCLUDE_PATH => $parent->{include_path}, + START_TAG => quotemeta(' quotemeta('?>'), + DELIMITER => ';', + }) || throw Error::Simple Template::Latex->error(); + + if (not $template->process( + get_template($parent->{template}), + $cleanvars, "$parent->{outputfile}.pdf", binmode => ':utf8')) { + throw Error::Simple $template->error(); + } + $parent->{mimetype} = 'application/pdf'; +} + +sub postprocess { + my $parent = shift; + $parent->{rendered} = "$parent->{outputfile}.pdf"; + return "$parent->{outputfile}.pdf"; +} + +1; diff --git a/LedgerSMB/Template/PS.pm b/LedgerSMB/Template/PS.pm new file mode 100755 index 00000000..55349113 --- /dev/null +++ b/LedgerSMB/Template/PS.pm @@ -0,0 +1,83 @@ + +=head1 NAME + +LedgerSMB::Template::PS Template support module for LedgerSMB + +=head1 METHODS + +=over + +=item get_template ($name) + +Returns the appropriate template filename for this format. + +=item preprocess ($vars) + +Currently does nothing. + +=item process ($parent, $cleanvars) + +Processes the template for Postscript. + +=item postprocess ($parent) + +Currently does nothing. + +=back + +=head1 Copyright (C) 2007, The LedgerSMB core team. + +This work contains copyrighted information from a number of sources all used +with permission. + +It is released under the GNU General Public License Version 2 or, at your +option, any later version. See COPYRIGHT file for details. For a full list +including contact information of contributors, maintainers, and copyright +holders, see the CONTRIBUTORS file. +=cut + +package LedgerSMB::Template::PS; + +use Error qw(:try); +use Template::Latex; + +sub get_template { + my $name = shift; + return "${name}.tex"; +} + +sub preprocess { + my $rawvars = shift; + my $vars; + my $type = ref $rawvars; + return $vars; +} + +sub process { + my $parent = shift; + my $cleanvars = shift; + my $template; + + $template = Template::Latex->new({ + LATEX_FORMAT => 'ps', + INCLUDE_PATH => $parent->{include_path}, + START_TAG => quotemeta(' quotemeta('?>'), + DELIMITER => ';', + }) || throw Error::Simple Template::Latex->error(); + + if (not $template->process( + get_template($parent->{template}), + $cleanvars, "$parent->{outputfile}.ps", binmode => ':utf8')) { + throw Error::Simple $template->error(); + } + $parent->{mimetype} = 'application/postscript'; +} + +sub postprocess { + my $parent = shift; + $parent->{rendered} = "$parent->{outputfile}.ps"; + return "$parent->{outputfile}.ps"; +} + +1; diff --git a/LedgerSMB/Template/TXT.pm b/LedgerSMB/Template/TXT.pm new file mode 100755 index 00000000..d7a76430 --- /dev/null +++ b/LedgerSMB/Template/TXT.pm @@ -0,0 +1,83 @@ + +=head1 NAME + +LedgerSMB::Template::TXT Template support module for LedgerSMB + +=head1 METHODS + +=over + +=item get_template ($name) + +Returns the appropriate template filename for this format. + +=item preprocess ($vars) + +Currently does nothing. + +=item process ($parent, $cleanvars) + +Processes the template for text. + +=item postprocess ($parent) + +Currently does nothing. + +=back + +=head1 Copyright (C) 2007, The LedgerSMB core team. + +This work contains copyrighted information from a number of sources all used +with permission. + +It is released under the GNU General Public License Version 2 or, at your +option, any later version. See COPYRIGHT file for details. For a full list +including contact information of contributors, maintainers, and copyright +holders, see the CONTRIBUTORS file. +=cut + +package LedgerSMB::Template::TXT; + +use Error qw(:try); +use Template; + +sub get_template { + my $name = shift; + return "${name}.txt"; +} + +sub preprocess { + my $rawvars = shift; + my $vars; + my $type = ref $rawvars; + + return $vars; +} + +sub process { + my $parent = shift; + my $cleanvars = shift; + my $template; + + $template = Template->new({ + INCLUDE_PATH => $parent->{include_path}, + START_TAG => quotemeta(' quotemeta('?>'), + DELIMITER => ';', + }) || throw Error::Simple Template->error(); + + if (not $template->process( + get_template($parent->{template}), + $cleanvars, "$parent->{outputfile}.txt", binmode => ':utf8')) { + throw Error::Simple $template->error(); + } + $parent->{mimetype} = 'text/plain'; +} + +sub postprocess { + my $parent = shift; + $parent->{rendered} = "$parent->{outputfile}.txt"; + return "$parent->{outputfile}.txt"; +} + +1; diff --git a/Makefile.PL b/Makefile.PL index 3b1c58f5..c3c2c821 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -28,6 +28,7 @@ requires 'Cwd'; requires 'Config::Std'; requires 'MIME::Lite'; requires 'Template'; +requires 'Template::Latex'; requires 'Error'; build_requires 'Test::More'; diff --git a/bin/arapprn.pl b/bin/arapprn.pl index 0d256c28..845d829a 100644 --- a/bin/arapprn.pl +++ b/bin/arapprn.pl @@ -285,24 +285,17 @@ sub print_check { $form->{fileid} = $invnumber; $form->{fileid} =~ s/(\s|\W)+//g; - if ( ( $form->{'media'} eq 'screen' ) and ( $form->{'format'} eq 'html' ) ) - { - my $template = - LedgerSMB::Template->new( - user => \%myconfig, template => $form->{'formname'}, - format => 'HTML' ); - try { - $template->render($form); - $form->header; - print $template->{'output'}; - exit; - } - catch Error::Simple with { - my $E = shift; - $form->error( $E->stacktrace ); - }; - } - $form->parse_template( \%myconfig ); + my $template = LedgerSMB::Template->new( + user => \%myconfig, template => $form->{'formname'}, + format => uc $form->{'format'} ); + try { + $template->render($form); + $template->output($form->{'media'}); + } + catch Error::Simple with { + my $E = shift; + $form->error( $E->stacktrace ); + }; if ( $form->{previousform} ) { @@ -560,24 +553,17 @@ sub print_transaction { $form->{fileid} = $form->{invnumber}; $form->{fileid} =~ s/(\s|\W)+//g; - if ( ( $form->{'media'} eq 'screen' ) and ( $form->{'format'} eq 'html' ) ) - { - my $template = - LedgerSMB::Template->new( - user => \%myconfig, template => $form->{'formname'}, - format => 'HTML' ); - try { - $template->render($form); - $form->header; - print $template->{'output'}; - exit; - } - catch Error::Simple with { - my $E = shift; - $form->error( $E->stacktrace ); - }; - } - $form->parse_template( \%myconfig ); + my $template = LedgerSMB::Template->new( + user => \%myconfig, template => $form->{'formname'}, + format => uc $form->{format} ); + try { + $template->render($form); + $template->output($form->{media}); + } + catch Error::Simple with { + my $E = shift; + $form->error( $E->stacktrace ); + }; if (%$old_form) { $old_form->{invnumber} = $form->{invnumber}; diff --git a/bin/cp.pl b/bin/cp.pl index d21fa18b..d9316fea 100644 --- a/bin/cp.pl +++ b/bin/cp.pl @@ -1473,23 +1473,16 @@ sub print_form { $form->{printmode} = '|-'; } - if ( ( $form->{'media'} eq 'screen' ) and ( $form->{'format'} eq 'html' ) ) - { - my $template = - LedgerSMB::Template->new( user => \%myconfig, - template => $form->{'formname'}, format => 'HTML' ); - try { - $template->render($form); - $form->header; - print $template->{'output'}; - exit; - } - catch Error::Simple with { - my $E = shift; - $form->error( $E->stacktrace ); - }; - } - $form->parse_template( \%myconfig, ${LedgerSMB::Sysconfig::userspath} ); + my $template = LedgerSMB::Template->new( user => \%myconfig, + template => $form->{'formname'}, format => uc $form->{format} ); + try { + $template->render($form); + $template->output($form->{media}); + } + catch Error::Simple with { + my $E = shift; + $form->error( $E->stacktrace ); + }; } diff --git a/bin/io.pl b/bin/io.pl index d1a00af9..6b21c95a 100644 --- a/bin/io.pl +++ b/bin/io.pl @@ -1767,24 +1767,16 @@ sub print_form { $form->{fileid} = $form->{"${inv}number"}; $form->{fileid} =~ s/(\s|\W)+//g; - if ( ( $form->{'media'} eq 'screen' ) and ( $form->{'format'} eq 'html' ) ) - { - my $template = - LedgerSMB::Template->new( user => \%myconfig, - template => $form->{'formname'}, format => 'HTML' ); - try { - $template->render($form); - $form->header; - print $template->{'output'}; - exit; - } - catch Error::Simple with { - my $E = shift; - $form->error( $E->stacktrace ); - }; - } - - $form->parse_template( \%myconfig, ${LedgerSMB::Sysconfig::userspath} ); + my $template = LedgerSMB::Template->new( user => \%myconfig, + template => $form->{'formname'}, format => uc $form->{format} ); + try { + $template->render($form); + $template->output($form->{media}); + } + catch Error::Simple with { + my $E = shift; + $form->error( $E->stacktrace ); + }; # if we got back here restore the previous form if ( defined %$old_form ) { diff --git a/bin/jc.pl b/bin/jc.pl index 0675c2cd..9f6c0015 100644 --- a/bin/jc.pl +++ b/bin/jc.pl @@ -2205,7 +2205,16 @@ qq|$form->{"${item}hour"}:$form->{"${item}min"}:$form->{"${item}sec"}|; $form->audittrail( "", \%myconfig, \%audittrail ); } - $form->parse_template( \%myconfig, ${LedgerSMB::Sysconfig::userspath} ); + my $template = LedgerSMB::Template->new( user => \%myconfig, + template => $form->{'formname'}, format => uc $form->{format} ); + try { + $template->render($form); + $template->output($form->{media}); + } + catch Error::Simple with { + my $E = shift; + $form->error( $E->stacktrace ); + }; if ( defined %$old_form ) { diff --git a/bin/pos.pl b/bin/pos.pl index 87787d08..3071bf33 100644 --- a/bin/pos.pl +++ b/bin/pos.pl @@ -1001,23 +1001,16 @@ sub print_form { delete $form->{stylesheet}; $form->{cd_open} = $pos_config{rp_cash_drawer_open}; - if ( ( $form->{'media'} eq 'screen' ) and ( $form->{'format'} eq 'html' ) ) - { - my $template = - LedgerSMB::Template->new(user => \%myconfig, - template => $form->{'formname'}, format => 'HTML' ); - try { - $template->render($form); - $form->header; - print $template->{'output'}; - exit; - } - catch Error::Simple with { - my $E = shift; - $form->error( $E->stacktrace ); - }; + my $template = LedgerSMB::Template->new(user => \%myconfig, + template => $form->{'formname'}, format => uc $form->{format} ); + try { + $template->render($form); + $template->output($form->{media}); } - $form->parse_template( \%myconfig, ${LedgerSMB::Sysconfig::userspath} ); + catch Error::Simple with { + my $E = shift; + $form->error( $E->stacktrace ); + }; if ( $form->{printed} !~ /$form->{formname}/ ) { $form->{printed} .= " $form->{formname}"; diff --git a/bin/rp.pl b/bin/rp.pl index a5c906d3..5886c2da 100644 --- a/bin/rp.pl +++ b/bin/rp.pl @@ -1080,23 +1080,16 @@ sub generate_income_statement { $form->{IN} = "income_statement.html"; - if ( ( $form->{'media'} eq 'screen' ) and ( $form->{'format'} eq 'html' ) ) - { - my $template = - LedgerSMB::Template->new( user => \%myconfig, - template => $form->{'formname'}, format => 'HTML' ); - try { - $template->render($form); - $form->header; - print $template->{'output'}; - exit; - } - catch Error::Simple with { - my $E = shift; - $form->error( $E->stacktrace ); - }; + my $template = LedgerSMB::Template->new( user => \%myconfig, + template => $form->{'formname'}, format => uc $form->{format} ); + try { + $template->render($form); + $template->output($form->{media}); } - $form->parse_template; + catch Error::Simple with { + my $E = shift; + $form->error( $E->stacktrace ); + }; } @@ -1137,23 +1130,16 @@ sub generate_balance_sheet { $form->{templates} = $myconfig{templates}; - if ( ( $form->{'media'} eq 'screen' ) and ( $form->{'format'} eq 'html' ) ) - { - my $template = - LedgerSMB::Template->new( user => \%myconfig, - template => $form->{'formname'}, format => 'HTML' ); - try { - $template->render($form); - $form->header; - print $template->{'output'}; - exit; - } - catch Error::Simple with { - my $E = shift; - $form->error( $E->stacktrace ); - }; + my $template = LedgerSMB::Template->new( user => \%myconfig, + template => $form->{'formname'}, format => uc $form->{format} ); + try { + $template->render($form); + $template->output($form->{media}); } - $form->parse_template; + catch Error::Simple with { + my $E = shift; + $form->error( $E->stacktrace ); + }; } @@ -2291,27 +2277,17 @@ sub print_form { 2 ); } - if ( ( $form->{'media'} eq 'screen' ) - and ( $form->{'format'} eq 'html' ) ) - { - my $template = - LedgerSMB::Template->new( user => \%myconfig, - template => $form->{'formname'}, - format => 'HTML' ); - try { - $template->render($form); - $form->header; - print $template->{'output'}; - exit; - } - catch Error::Simple with { - my $E = shift; - $form->error( $E->stacktrace ); - }; + my $template = LedgerSMB::Template->new( user => \%myconfig, + template => $form->{'formname'}, + format => uc $form->{format} ); + try { + $template->render($form); + $template->output($form->{media}); } - $form->parse_template( \%myconfig, - ${LedgerSMB::Sysconfig::userspath} ); - + catch Error::Simple with { + my $E = shift; + $form->error( $E->stacktrace ); + }; } } } diff --git a/t/01-load.t b/t/01-load.t index d2cde8f1..ac7c970d 100644 --- a/t/01-load.t +++ b/t/01-load.t @@ -2,7 +2,7 @@ use strict; use warnings; -use Test::More tests => 32; +use Test::More tests => 34; use_ok('LedgerSMB'); use_ok('LedgerSMB::AA'); @@ -34,6 +34,8 @@ use_ok('LedgerSMB::Sysconfig'); use_ok('LedgerSMB::Tax'); use_ok('LedgerSMB::Template'); use_ok('LedgerSMB::Template::HTML'); +use_ok('LedgerSMB::Template::PDF'); +use_ok('LedgerSMB::Template::PS'); use_ok('LedgerSMB::User'); SKIP: { diff --git a/t/04-template-handling.t b/t/04-template-handling.t index f9b458f9..04048b10 100644 --- a/t/04-template-handling.t +++ b/t/04-template-handling.t @@ -18,6 +18,8 @@ use LedgerSMB::Locale; use LedgerSMB::Template; use LedgerSMB::Template::HTML; +$LedgerSMB::Sysconfig::tempdir = 't/var'; + my @r; my $temp; my $form; @@ -131,8 +133,8 @@ is_deeply(LedgerSMB::Template::HTML::preprocess({'fruit' => '&veggies', 'test' => ['nest', 'bird', '0 < 15', 1]}), {'fruit' => '&veggies', 'test' => ['nest', 'bird', '0 < 15', 1]}, 'HTML, preprocess: Returned properly escaped nested contents'); -is(LedgerSMB::Template::HTML::postprocess('04-template'), undef, - 'HTML, postprocess: Return undef'); +is(LedgerSMB::Template::HTML::postprocess({outputfile => '04-template'}), + '04-template.html', 'HTML, postprocess: Return output filename'); # Template->new $myconfig = {'templates' => 't/data'}; @@ -173,9 +175,19 @@ isa_ok($template, 'LedgerSMB::Template', 'Template, new: Object creation with format and template'); is($template->{include_path}, 't/data', 'Template, new: Object creation with format and template'); -is($template->render({'login' => 'foo'}), - "I am a template.\nLook at me foo.\n", - 'Template, render: Simple HTML template'); +is($template->render({'login' => 'foo&bar'}), 't/var/04-template-output.html', + 'Template, render: Simple HTML template, default filename'); +ok(-e 't/var/04-template-output.html', 'Template, render (HTML): File created'); +open($FH, '<', 't/var/04-template-output.html'); +@r = <$FH>; +close($FH); +chomp(@r); +is(join("\n", @r), "I am a template.\nLook at me foo&bar.", + 'Template, render (HTML): Simple HTML template, correct output'); +is(unlink('t/var/04-template-output.html'), 1, + 'Template, render: removing testfile'); +ok(!-e 't/var/04-template-output.html', + 'Template, render (HTML): testfile removed'); $template = undef; $template = new LedgerSMB::Template('user' => $myconfig, 'format' => 'HTML', @@ -184,12 +196,6 @@ ok(defined $template, 'Template, new: Object creation with locale'); isa_ok($template, 'LedgerSMB::Template', 'Template, new: Object creation with locale'); -TODO: { - local $TODO = 'gettext substitution of passed in data'; - is($template->render({'login' => 'April'}), - "I am a template.\nLook at me Avril.\n", - 'Template, render: HTML template with locale'); -} $template = undef; $template = new LedgerSMB::Template('user' => $myconfig, 'format' => 'HTML', @@ -197,7 +203,7 @@ $template = new LedgerSMB::Template('user' => $myconfig, 'format' => 'HTML', ok(defined $template, 'Template, new: Object creation with non-existent template'); throws_ok{$template->render({'login' => 'foo'})} qr/not found/, - 'render: File not found caught'; + 'Template, render: File not found caught'; $template = undef; $template = new LedgerSMB::Template('user' => $myconfig, 'format' => 'TODO', @@ -205,4 +211,4 @@ $template = new LedgerSMB::Template('user' => $myconfig, 'format' => 'TODO', ok(defined $template, 'Template, new: Object creation with non-existent format'); throws_ok{$template->render({'login' => 'foo'})} qr/Can't locate/, - 'render: Invalid format caught'; + 'Template, render: Invalid format caught'; diff --git a/templates/demo/ap_transaction.tex b/templates/demo/ap_transaction.tex index 7df57017..c8edaf4c 100644 --- a/templates/demo/ap_transaction.tex +++ b/templates/demo/ap_transaction.tex @@ -1,5 +1,5 @@ \documentclass{scrartcl} -\usepackage[latin1]{inputenc} +\usepackage[utf8]{inputenc} \usepackage{tabularx} \usepackage[letterpaper,top=2cm,bottom=1.5cm,left=1.1cm,right=1.5cm]{geometry} \usepackage{graphicx} @@ -12,7 +12,7 @@ \fontfamily{cmss}\fontsize{10pt}{12pt}\selectfont - + \centerline{\textbf{A P} \hspace{0.3cm} \textbf{T R A N S A C T I O N}} @@ -26,58 +26,64 @@ - + \hspace{-0.1cm}, - + \vspace{0.3cm} - + \vspace{0.2cm} - + - + Tel: - + - + Fax: - + - + Tax Number: - + } \hfill \begin{tabular}[t]{ll} \textbf{Invoice \#} & \\ \textbf{Date} & \\ \textbf{Due} & \\ - + \textbf{PO \#} & \\ - - + + \textbf{Order \#} & \\ - + \textbf{Employee} & \\ \end{tabular} \vspace{1cm} \begin{tabularx}{\textwidth}[t]{@{}llrX@{\hspace{1cm}}l@{}} - - & & & & \\ - + + + & + & + & + & + \\ + \multicolumn{2}{r}{\textbf{Subtotal}} & & \\ - - \multicolumn{2}{r}{\textbf{ @ \%}} & & \\ - + + + \multicolumn{2}{r}{\textbf{ @ \%}} & & \\ + \multicolumn{2}{r}{\textbf{Total}} & & \\ @@ -87,25 +93,26 @@ Tax Number: ***** /100 - + \vspace{0.3cm} - + \vspace{0.3cm} - + \begin{tabular}{@{}llllr@{}} \multicolumn{5}{c}{\textbf{Payments}} \\ \hline \textbf{Date} & & \textbf{Source} & \textbf{Memo} & \textbf{Amount} \\ - - - & & & & \\ - - + + + + & & & & \\ + + \end{tabular} - + \end{document} diff --git a/templates/demo/ar_transaction.tex b/templates/demo/ar_transaction.tex index 95f9160d..19834aaf 100644 --- a/templates/demo/ar_transaction.tex +++ b/templates/demo/ar_transaction.tex @@ -1,5 +1,5 @@ \documentclass{scrartcl} -\usepackage[latin1]{inputenc} +\usepackage[utf8]{inputenc} \usepackage{tabularx} \usepackage[top=2cm,bottom=1.5cm,left=2cm,right=1cm]{geometry} \usepackage{graphicx} @@ -40,60 +40,66 @@ - + , - + \vspace{0.3cm} - + - + \vspace{0.2cm} - + Tel: - + - + Fax: - + - + Tax Number: - + } \hfill \begin{tabular}[t]{ll} \textbf{Invoice \#} & \\ \textbf{Date} & \\ \textbf{Due} & \\ - + \textbf{PO \#} & \\ - - + + \textbf{Order \#} & \\ - + \textbf{Employee} & \\ \end{tabular} \vspace{1cm} \begin{tabularx}{\textwidth}[t]{@{}llrX@{\hspace{1cm}}l@{}} - - & & & & \\ - + + + & + & + & + & + \\ + \multicolumn{2}{r}{\textbf{Subtotal}} & & \\ - - \multicolumn{2}{r}{\textbf{ @ \%}} & & \\ - + + + \multicolumn{2}{r}{\textbf{ @ \%}} & & \\ + \multicolumn{2}{r}{\textbf{Total}} & & \\ @@ -103,31 +109,33 @@ Tax Number: ***** /100 - + \vspace{0.3cm} - + \vspace{0.3cm} - + \begin{tabular}{@{}lllr@{}} \multicolumn{5}{c}{\textbf{Payments}} \\ \hline \textbf{Date} & & \textbf{Source} & \textbf{Amount} \\ - - - & & & \\ - - + + + + & & & \\ + + \end{tabular} - + \vspace{0.5cm} - -\textbf{\scriptsize Registration } \\ - + + +\textbf{\scriptsize Registration } \\ + \end{document} diff --git a/templates/demo/bin_list.tex b/templates/demo/bin_list.tex index 88d4b3ce..8b96825c 100644 --- a/templates/demo/bin_list.tex +++ b/templates/demo/bin_list.tex @@ -1,5 +1,5 @@ \documentclass{scrartcl} -\usepackage[latin1]{inputenc} +\usepackage[utf8]{inputenc} \usepackage{tabularx} \usepackage[letterpaper,top=2cm,bottom=1.5cm,left=1.1cm,right=1.5cm]{geometry} \usepackage{graphicx} @@ -11,19 +11,20 @@ \fontfamily{cmss}\fontsize{10pt}{12pt}\selectfont - + - - -\end{tabularx} - -\newpage - -\markboth{\hfill }{\hfill } -\begin{tabularx}{\textwidth}{@{}rlXllrrll@{}} - \textbf{Item} & \textbf{Number} & \textbf{Description} & \textbf{Serial Number} & & \textbf{Qty} & \textbf{Recd} & & \textbf{Bin} \\ - +% Breaking old pagebreak directives +% +%\end{tabularx} +% +%\newpage +% +%\markboth{\hfill }{\hfill } +% +%\begin{tabularx}{\textwidth}{@{}rlXllrrll@{}} +% \textbf{Item} & \textbf{Number} & \textbf{Description} & \textbf{Serial Number} & & \textbf{Qty} & \textbf{Recd} & & \textbf{Bin} \\ +% \vspace*{0.5cm} @@ -39,9 +40,9 @@ - + \hspace{-0.1cm}, - + @@ -57,9 +58,9 @@ - + \hspace{-0.1cm}, - + @@ -75,23 +76,23 @@ \begin{tabularx}{\textwidth}{*{6}{|X}|} \hline \textbf{Order \#} & \textbf{Date} & \textbf{Contact} - + & \textbf{Warehouse} - + & \textbf{Shipping Point} & \textbf{Ship via} \\ [0.5em] \hline - + & - - + + & - + & - + & - + & & \\ \hline \end{tabularx} @@ -101,10 +102,18 @@ \begin{tabularx}{\textwidth}{@{}rlXllrrll@{}} \textbf{Item} & \textbf{Number} & \textbf{Description} & \textbf{Serial Number} & & \textbf{Qty} & \textbf{Recd} & & \textbf{Bin} \\ - - & & & & - & & & & \\ - + + + & + & + & + & + & + & + & + & + \\ + \end{tabularx} diff --git a/templates/demo/check.tex b/templates/demo/check.tex index a0298580..b5c8a31c 100644 --- a/templates/demo/check.tex +++ b/templates/demo/check.tex @@ -1,5 +1,5 @@ \documentclass{scrartcl} -\usepackage[latin1]{inputenc} +\usepackage[utf8]{inputenc} \usepackage{tabularx} \usepackage[letterpaper,top=2cm,bottom=1.5cm,left=1.1cm,right=1.5cm]{geometry} \usepackage{graphicx} @@ -38,9 +38,9 @@ - + \hspace{-0.1cm}, - + @@ -61,10 +61,11 @@ \begin{tabularx}{\textwidth}{lXrr@{}} \textbf{Invoice \#} & \textbf{Invoice Date} & \textbf{Amount Due} & \textbf{Applied} \\ - - & \dotfill - & & \\ - + + + & \dotfill + & & \\ + \end{tabularx} \vspace{1cm} diff --git a/templates/demo/invoice.tex b/templates/demo/invoice.tex index a34120fb..36af8d88 100644 --- a/templates/demo/invoice.tex +++ b/templates/demo/invoice.tex @@ -1,5 +1,5 @@ \documentclass{scrartcl} -\usepackage[latin1]{inputenc} +\usepackage[utf8]{inputenc} \usepackage{tabularx} \usepackage[letterpaper,top=2cm,bottom=1.5cm,left=1.1cm,right=1.5cm]{geometry} \usepackage{graphicx} @@ -22,29 +22,30 @@ A return authorization must be obtained from before goods are } } - - - -\end{tabularx} - - \rule{\textwidth}{2pt} - - \vspace{0.2cm} - - \hfill - \begin{tabularx}{\textwidth}{Xr@{\hspace{1cm}}r@{}} - & Subtotal & \\ - \end{tabularx} - -\newpage - -\markboth{\hfill }{\hfill } - -\begin{tabularx}{\textwidth}{@{}rlXlrlrrr@{}} - \textbf{Pos} & \textbf{Number} & \textbf{Description} & & \textbf{Qt'y} & - \textbf{Unit} & \textbf{Price} & \textbf{Disc \%} & \textbf{Amount} \\ [0.5em] - & carried forward from page & & & & & & & \\ [0.5em] - + + +% Disable old pagebreak handling +% +%\end{tabularx} +% +% \rule{\textwidth}{2pt} +% +% \vspace{0.2cm} +% +% \hfill +% \begin{tabularx}{\textwidth}{Xr@{\hspace{1cm}}r@{}} +% & Subtotal & \\ +% \end{tabularx} +% +%\newpage +% +%\markboth{\hfill }{\hfill } +% +%\begin{tabularx}{\textwidth}{@{}rlXlrlrrr@{}} +% \textbf{Pos} & \textbf{Number} & \textbf{Description} & & \textbf{Qt'y} & +% \textbf{Unit} & \textbf{Price} & \textbf{Disc \%} & \textbf{Amount} \\ [0.5em] +% & carried forward from page & & & & & & & \\ [0.5em] +% \vspace*{0.5cm} @@ -60,27 +61,27 @@ A return authorization must be obtained from before goods are - + \hspace{-0.1cm}, - + \vspace{0.3cm} - + \vspace{0.2cm} - + - + Tel: - + - + Fax: - + } @@ -95,27 +96,27 @@ Fax: - + \hspace{-0.1cm}, - + \vspace{0.3cm} - + \vspace{0.2cm} - + - + Tel: - + - + Fax: - + } @@ -142,10 +143,18 @@ Fax: \begin{tabularx}{\textwidth}{@{}rlXlrlrrr@{}} \textbf{Pos} & \textbf{Number} & \textbf{Description} & & \textbf{Qt'y} & \textbf{Unit} & \textbf{Price} & \textbf{Disc \%} & \textbf{Amount} \\ [0.5em] - - & & & & - & & & & \\ - + + + & + & + & + & + & + & + & + & + \\ + \end{tabularx} @@ -157,16 +166,17 @@ Fax: \hfill \begin{tabularx}{7cm}{Xr@{\hspace{1cm}}r@{}} & Subtotal & \\ - - & on & \\ - - + + + & on & \\ + + & Paid & - \\ - + \hline - + & Balance Due & - + \end{tabularx} \vspace{0.3cm} @@ -182,18 +192,19 @@ All prices in \textbf{}. \vfill - + \begin{tabularx}{10cm}{@{}lXlr@{}} \textbf{Payments} & & & \\ \hline \textbf{Date} & & \textbf{Source} & \textbf{Amount} \\ - - - & & & \\ - - + + + + & & & \\ + + \end{tabularx} - + \vspace{1cm} diff --git a/templates/demo/packing_list.tex b/templates/demo/packing_list.tex index 71d90b53..a1b638ec 100644 --- a/templates/demo/packing_list.tex +++ b/templates/demo/packing_list.tex @@ -1,5 +1,5 @@ \documentclass{scrartcl} -\usepackage[latin1]{inputenc} +\usepackage[utf8]{inputenc} \usepackage{tabularx} \usepackage[letterpaper,top=2cm,bottom=1.5cm,left=1.1cm,right=1.5cm]{geometry} \usepackage{graphicx} @@ -23,18 +23,19 @@ returned. Returns must be shipped prepaid and properly insured. } } - + - -\end{tabularx} - -\newpage - -\markboth{\hfill }{\hfill } - -\begin{tabularx}{\textwidth}{@{}rlXllrrl@{}} - \textbf{Item} & \textbf{Number} & \textbf{Description} & \textbf{Serial Number} & & \textbf{Qty} & \textbf{Ship} & \\ - +% Breaking old pagebreak directive +% +%\end{tabularx} +% +%\newpage +% +%\markboth{\hfill }{\hfill } +% +%\begin{tabularx}{\textwidth}{@{}rlXllrrl@{}} +% \textbf{Item} & \textbf{Number} & \textbf{Description} & \textbf{Serial Number} & & \textbf{Qty} & \textbf{Ship} & \\ +% \vspace*{0.5cm} @@ -53,9 +54,9 @@ returned. Returns must be shipped prepaid and properly insured. - + \hspace{-0.1cm}, - + @@ -63,13 +64,13 @@ returned. Returns must be shipped prepaid and properly insured. \parbox[t]{.5\textwidth}{ - + Tel: - + - + Fax: - + } @@ -84,23 +85,22 @@ returned. Returns must be shipped prepaid and properly insured. \begin{tabularx}{\textwidth}{*{7}{|X}|} \hline \textbf{Invoice \#} & \textbf{Order \#} & \textbf{Date} & \textbf{Contact} - + & \textbf{Warehouse} - + & \textbf{Shipping Point} & \textbf{Ship via} \\ [0.5em] \hline & - + & - - + & - + & - + & - + & & \\ \hline \end{tabularx} @@ -110,10 +110,17 @@ returned. Returns must be shipped prepaid and properly insured. \begin{tabularx}{\textwidth}{@{}rlXllrrl@{}} \textbf{Item} & \textbf{Number} & \textbf{Description} & \textbf{Serial Number} & & \textbf{Qty} & \textbf{Ship} & \\ - - & & & & - & & & \\ - + + + & + & + & + & + & + & + & + \\ + \end{tabularx} diff --git a/templates/demo/pick_list.tex b/templates/demo/pick_list.tex index 1b88041f..cc7f67fd 100644 --- a/templates/demo/pick_list.tex +++ b/templates/demo/pick_list.tex @@ -1,5 +1,5 @@ \documentclass{scrartcl} -\usepackage[latin1]{inputenc} +\usepackage[utf8]{inputenc} \usepackage{tabularx} \usepackage[letterpaper,top=2cm,bottom=1.5cm,left=1.1cm,right=1.5cm]{geometry} \usepackage{graphicx} @@ -11,21 +11,22 @@ \fontfamily{cmss}\fontsize{10pt}{12pt}\selectfont - + - - -\end{tabularx} - -\newpage - -\markboth{\hfill }{\hfill } - -\begin{tabularx}{\textwidth}{@{}rlXrcll@{}} - \textbf{Item} & \textbf{Number} & \textbf{Description} & - \textbf{Qty} & \textbf{Ship} & & \textbf{Bin} \\ - +% Breaking old pagebreak directive +% +%\end{tabularx} +% +%\newpage +% +%\markboth{\hfill }{\hfill } +% +%\begin{tabularx}{\textwidth}{@{}rlXrcll@{}} +% \textbf{Item} & \textbf{Number} & \textbf{Description} & +% \textbf{Qty} & \textbf{Ship} & & \textbf{Bin} \\ +% +% \vspace*{0.5cm} @@ -44,9 +45,9 @@ - + \hspace{-0.1cm}, - + @@ -54,13 +55,13 @@ \parbox[t]{.5\textwidth}{ - + Tel: - + - + Fax: - + } @@ -78,12 +79,11 @@ & \textbf{Warehouse} & \textbf{Shipping Point} & \textbf{Ship via} \\ [0.5em] \hline & - + & - - + & - + & & & & \\ \hline \end{tabularx} @@ -93,10 +93,14 @@ \begin{tabularx}{\textwidth}{@{}rlXrcll@{}} \textbf{Item} & \textbf{Number} & \textbf{Description} & \textbf{Qty} & \textbf{Ship} & & \textbf{Bin} \\ - - & & & - & [\hspace{1cm}] & & \\ - + + + & + & + & + & [\hspace{1cm}] & + & \\ + \end{tabularx} diff --git a/templates/demo/purchase_order.tex b/templates/demo/purchase_order.tex index 59511743..c60073a6 100644 --- a/templates/demo/purchase_order.tex +++ b/templates/demo/purchase_order.tex @@ -1,5 +1,5 @@ \documentclass{scrartcl} -\usepackage[latin1]{inputenc} +\usepackage[utf8]{inputenc} \usepackage{tabularx} \usepackage[letterpaper,top=2cm,bottom=1.5cm,left=1.1cm,right=1.5cm]{geometry} \usepackage{graphicx} @@ -12,28 +12,29 @@ \fontfamily{cmss}\fontsize{10pt}{12pt}\selectfont - - - - -\end{tabularx} - - \rule{\textwidth}{2pt} - - \hfill - \begin{tabularx}{7cm}{Xr@{\hspace{1cm}r@{}} - & Subtotal & \\ - \end{tabularx} - -\newpage - -\markboth{\hfill }{\hfill } - -\begin{tabularx}{\textwidth}{@{}lXrlrr@{}} - \textbf{Number} & \textbf{Description} & \textbf{Qt'y} & - \textbf{Unit} & \textbf{Price} & \textbf{Amount} \\ - & carried forward from & & & & \\ - + + + +% Breaking old pagebreak directive +% +%\end{tabularx} +% +% \rule{\textwidth}{2pt} +% +% \hfill +% \begin{tabularx}{7cm}{Xr@{\hspace{1cm}r@{}} +% & Subtotal & \\ +% \end{tabularx} +% +%\newpage +% +%\markboth{\hfill }{\hfill } +% +%\begin{tabularx}{\textwidth}{@{}lXrlrr@{}} +% \textbf{Number} & \textbf{Description} & \textbf{Qt'y} & +% \textbf{Unit} & \textbf{Price} & \textbf{Amount} \\ +% & carried forward from & & & & \\ +% \vspace*{0.5cm} @@ -49,27 +50,27 @@ - + \hspace{-0.1cm}, - + \vspace{0.3cm} - + Attn: \vspace{0.2cm} - + - + Tel: - + - + Fax: - + } @@ -84,27 +85,27 @@ Fax: - + \hspace{-0.1cm}, - + \vspace{0.3cm} - + Attn: \vspace{0.2cm} - + - + Tel: - + - + Fax: - + } @@ -128,10 +129,15 @@ Fax: \begin{tabularx}{\textwidth}{@{}lXrlrr@{}} \textbf{Number} & \textbf{Description} & \textbf{Qt'y} & \textbf{Unit} & \textbf{Price} & \textbf{Amount} \\ - - & & & - & & \\ - + + + & + & + & + & + & + \\ + \end{tabularx} @@ -143,9 +149,10 @@ Fax: \hfill \begin{tabularx}{7cm}{Xr@{\hspace{1cm}}r@{}} & Subtotal & \\ - - & on & \\ - + + + & on & \\ + \hline & Total & \\ \end{tabularx} diff --git a/templates/demo/receipt.tex b/templates/demo/receipt.tex index 7bd4decd..16e88ed0 100644 --- a/templates/demo/receipt.tex +++ b/templates/demo/receipt.tex @@ -1,5 +1,5 @@ \documentclass{scrartcl} -\usepackage[latin1]{inputenc} +\usepackage[utf8]{inputenc} \usepackage{tabularx} \usepackage[letterpaper,top=2cm,bottom=1.5cm,left=1.1cm,right=1.5cm]{geometry} \usepackage{graphicx} @@ -38,9 +38,9 @@ - + \hspace{-0.1cm}, - + @@ -61,10 +61,11 @@ \begin{tabularx}{\textwidth}{lXrr@{}} \textbf{Invoice No.} & \textbf{Invoice Date} & \textbf{Due} & \textbf{Applied} \\ - - & \dotfill - & & \\ - + + + & \dotfill + & & \\ + \end{tabularx} \vspace{1cm} diff --git a/templates/demo/request_quotation.tex b/templates/demo/request_quotation.tex index f866911e..feccc631 100644 --- a/templates/demo/request_quotation.tex +++ b/templates/demo/request_quotation.tex @@ -1,5 +1,5 @@ \documentclass{scrartcl} -\usepackage[latin1]{inputenc} +\usepackage[utf8]{inputenc} \usepackage{tabularx} \usepackage[letterpaper,top=2cm,bottom=1.5cm,left=1.1cm,right=1.5cm]{geometry} \usepackage{graphicx} @@ -11,28 +11,29 @@ \fontfamily{cmss}\fontsize{10pt}{12pt}\selectfont - - - - -\end{tabularx} - - \rule{\textwidth}{2pt} - - \hfill - \begin{tabularx}{7cm}{Xr@{\hspace{1cm}}r@{}} - & \textbf{Subtotal} & \textbf{} \\ - \end{tabularx} - -\newpage - -\markboth{\hfill }{\hfill } - -\begin{tabularx}{\textwidth}{@{}lXrlrr@{}} - \textbf{Number} & \textbf{Description} & \textbf{Qt'y} & - \textbf{Unit} & \textbf{Price} & \textbf{Extended} \\ - & carried forward from & & & & \\ - + + + +% Breaking old pagebreak directive +% +%\end{tabularx} +% +% \rule{\textwidth}{2pt} +% +% \hfill +% \begin{tabularx}{7cm}{Xr@{\hspace{1cm}}r@{}} +% & \textbf{Subtotal} & \textbf{} \\ +% \end{tabularx} +% +%\newpage +% +%\markboth{\hfill }{\hfill } +% +%\begin{tabularx}{\textwidth}{@{}lXrlrr@{}} +% \textbf{Number} & \textbf{Description} & \textbf{Qt'y} & +% \textbf{Unit} & \textbf{Price} & \textbf{Extended} \\ +% & carried forward from & & & & \\ +% \vspace*{0.5cm} @@ -48,27 +49,27 @@ - + \hspace{-0.1cm}, - + \vspace{0.3cm} - + \vspace{0.2cm} - + - + Tel: - + - + Fax: - + } @@ -83,27 +84,27 @@ Fax: - + \hspace{-0.1cm}, - + \vspace{0.3cm} - + \vspace{0.2cm} - + - + Tel: - + - + Fax: - + } @@ -132,9 +133,13 @@ Please provide price and delivery time for the following items: \begin{tabularx}{\textwidth}{@{}lXrllrr@{}} \textbf{Number} & \textbf{Description} & \textbf{Qt'y} & & \textbf{Delivery} & \textbf{Unit Price} & \textbf{Extended} \\ - - & & & \\ - + + + & + & + & + \\ + \end{tabularx} diff --git a/templates/demo/sales_order.tex b/templates/demo/sales_order.tex index 7bcb0dce..2d382cb2 100644 --- a/templates/demo/sales_order.tex +++ b/templates/demo/sales_order.tex @@ -1,5 +1,5 @@ \documentclass{scrartcl} -\usepackage[latin1]{inputenc} +\usepackage[utf8]{inputenc} \usepackage{tabularx} \usepackage[letterpaper,top=2cm,bottom=1.5cm,left=1.1cm,right=1.5cm]{geometry} \usepackage{graphicx} @@ -11,29 +11,30 @@ \fontfamily{cmss}\fontsize{10pt}{12pt}\selectfont - - - - -\end{tabularx} - - \rule{\textwidth}{2pt} - - \hfill - \begin{tabularx}{7cm}{Xr@{\hspace{1cm}}r@{}} - & \textbf{Subtotal} & \textbf{} \\ - \end{tabularx} - -\newpage - -\markboth{\hfill }{\hfill } - - -\begin{tabularx}{\textwidth}{@{}rlXrlrrr@{}} - \textbf{Item} & \textbf{Number} & \textbf{Description} & \textbf{Qt'y} & - \textbf{Unit} & \textbf{Price} & \textbf{Disc \%} & \textbf{Amount} \\ - & carried forward from & & & & & \\ - + + + +% Breaking old pagebreak directive +% +%\end{tabularx} +% +% \rule{\textwidth}{2pt} +% +% \hfill +% \begin{tabularx}{7cm}{Xr@{\hspace{1cm}}r@{}} +% & \textbf{Subtotal} & \textbf{} \\ +% \end{tabularx} +% +%\newpage +% +%\markboth{\hfill }{\hfill } +% +% +%\begin{tabularx}{\textwidth}{@{}rlXrlrrr@{}} +% \textbf{Item} & \textbf{Number} & \textbf{Description} & \textbf{Qt'y} & +% \textbf{Unit} & \textbf{Price} & \textbf{Disc \%} & \textbf{Amount} \\ +% & carried forward from & & & & & \\ +% \vspace*{0.5cm} @@ -49,27 +50,27 @@ - + \hspace{-0.1cm}, - + \vspace{0.3cm} - + \vspace{0.2cm} - + - + Tel: - + - + Fax: - + } @@ -84,27 +85,27 @@ Fax: - + \hspace{-0.1cm}, - + \vspace{0.3cm} - + \vspace{0.2cm} - + - + Tel: - + - + Fax: - + } @@ -129,10 +130,17 @@ Fax: \begin{tabularx}{\textwidth}{@{}rlXrlrrr@{}} \textbf{Item} & \textbf{Number} & \textbf{Description} & \textbf{Qt'y} & \textbf{Unit} & \textbf{Price} & \textbf{Disc \%} & \textbf{Amount} \\ - - & & & & - & & & \\ - + + + & + & + & + & + & + & + & + \\ + \end{tabularx} @@ -144,9 +152,10 @@ Fax: \hfill \begin{tabularx}{7cm}{Xr@{\hspace{1cm}}r@{}} & Subtotal & \\ - - & on & \\ - + + + & on & \\ + \hline & Total & \\ \end{tabularx} @@ -157,9 +166,9 @@ Fax: \hfill All prices in \textbf{}. - + Terms: days - + \vspace{12pt} diff --git a/templates/demo/sales_quotation.tex b/templates/demo/sales_quotation.tex index b80ffacc..43a9fdfc 100644 --- a/templates/demo/sales_quotation.tex +++ b/templates/demo/sales_quotation.tex @@ -1,5 +1,5 @@ \documentclass{scrartcl} -\usepackage[latin1]{inputenc} +\usepackage[utf8]{inputenc} \usepackage{tabularx} \usepackage[letterpaper,top=2cm,bottom=1.5cm,left=1.1cm,right=1.5cm]{geometry} \usepackage{graphicx} @@ -20,28 +20,29 @@ Special order items are subject to a 10\% cancellation fee. } } - - - - -\end{tabularx} - - \rule{\textwidth}{2pt} - - \hfill - \begin{tabularx}{7cm}{Xr@{\hspace{1cm}}r@{}} - & \textbf{Subtotal} & \textbf{} \\ - \end{tabularx} - -\newpage - -\markboth{\hfill }{\hfill } - -\begin{tabularx}{\textwidth}{@{}lXrlrrr@{}} - \textbf{Number} & \textbf{Description} & \textbf{Qt'y} & - \textbf{Unit} & \textbf{Price} & \textbf{Disc \%} & \textbf{Amount} \\ - & carried forward from & & & & & \\ - + + + +% Breaking old pagebreak directive +% +%\end{tabularx} +% +% \rule{\textwidth}{2pt} +% +% \hfill +% \begin{tabularx}{7cm}{Xr@{\hspace{1cm}}r@{}} +% & \textbf{Subtotal} & \textbf{} \\ +% \end{tabularx} +% +%\newpage +% +%\markboth{\hfill }{\hfill } +% +%\begin{tabularx}{\textwidth}{@{}lXrlrrr@{}} +% \textbf{Number} & \textbf{Description} & \textbf{Qt'y} & +% \textbf{Unit} & \textbf{Price} & \textbf{Disc \%} & \textbf{Amount} \\ +% & carried forward from & & & & & \\ +% \vspace*{0.5cm} @@ -55,27 +56,27 @@ Special order items are subject to a 10\% cancellation fee. - + \hspace{-0.1cm}, - + \vspace{0.3cm} - + \vspace{0.2cm} - + - + Tel: - + - + Fax: - + } @@ -99,10 +100,16 @@ Fax: \begin{tabularx}{\textwidth}{@{}lXrlrrr@{}} \textbf{Number} & \textbf{Description} & \textbf{Qt'y} & \textbf{Unit} & \textbf{Price} & \textbf{Disc \%} & \textbf{Amount} \\ - - & & & - & & & \\ - + + + & + & + & + & + & + & + \\ + \end{tabularx} @@ -114,9 +121,10 @@ Fax: \hfill \begin{tabularx}{7cm}{Xr@{\hspace{1cm}}r@{}} & Subtotal & \\ - - & on & \\ - + + + & on & \\ + \hline & Total & \\ \end{tabularx} @@ -126,9 +134,9 @@ Fax: \hfill All prices in \textbf{}. - + Terms: days - + \vspace{12pt} diff --git a/templates/demo/statement.tex b/templates/demo/statement.tex index 4343c5c6..8fedc55f 100644 --- a/templates/demo/statement.tex +++ b/templates/demo/statement.tex @@ -1,5 +1,5 @@ \documentclass{scrartcl} -\usepackage[latin1]{inputenc} +\usepackage[utf8]{inputenc} \usepackage{tabularx} \usepackage[letterpaper,top=2cm,bottom=1.5cm,left=1.1cm,right=1.5cm]{geometry} \usepackage{graphicx} @@ -11,7 +11,7 @@ \fontfamily{cmss}\fontsize{10pt}{12pt}\selectfont - + \parbox[t]{.5\textwidth}{ @@ -21,21 +21,21 @@ - + \hspace{-0.1cm}, - + } \parbox[t]{.5\textwidth}{ - + Tel: - + - + Fax: - + } @@ -52,10 +52,17 @@ Fax: \textbf{Invoice \#} & \textbf{Order \#} & \textbf{Date} & \textbf{Due} & \textbf{Current} & \textbf{30} & \textbf{60} & \textbf{90} \\ \hline - - & & & & - & & & \\ - + + + & + & + & + & + & + & + & + \\ + \multicolumn{8}{|l|}{\mbox{}} \\ \hline \textbf{Subtotal} & & & & & & & \\ diff --git a/templates/demo/timecard.tex b/templates/demo/timecard.tex index 1c54eb4f..e303ac10 100644 --- a/templates/demo/timecard.tex +++ b/templates/demo/timecard.tex @@ -1,5 +1,5 @@ \documentclass{scrartcl} -\usepackage[latin1]{inputenc} +\usepackage[utf8]{inputenc} \usepackage{tabularx} \usepackage[letterpaper,top=2cm,bottom=1.5cm,left=1.1cm,right=1.5cm]{geometry} \usepackage{graphicx} @@ -11,7 +11,7 @@ \fontfamily{cmss}\fontsize{10pt}{12pt}\selectfont - + \centerline{\textbf{T I M E}\hspace{0.5cm}\textbf{C A R D}} diff --git a/templates/demo/work_order.tex b/templates/demo/work_order.tex index d3ca6959..c08a2da5 100644 --- a/templates/demo/work_order.tex +++ b/templates/demo/work_order.tex @@ -1,5 +1,5 @@ \documentclass{scrartcl} -\usepackage[latin1]{inputenc} +\usepackage[utf8]{inputenc} \usepackage{tabularx} \usepackage[letterpaper,top=2cm,bottom=1.5cm,left=1.1cm,right=1.5cm]{geometry} \usepackage{graphicx} @@ -11,20 +11,21 @@ \fontfamily{cmss}\fontsize{10pt}{12pt}\selectfont - + - -\end{tabularx} - -\newpage - -\markboth{\hfill }{\hfill } - -\begin{tabularx}{\textwidth}{@{}rlXrll@{}} - \textbf{Item} & \textbf{Number} & \textbf{Description} & \textbf{Qt'y} & - & \textbf{Serial Number} \\ - +% Break old pagebreak directive +% +%\end{tabularx} +% +%\newpage +% +%\markboth{\hfill }{\hfill } +% +%\begin{tabularx}{\textwidth}{@{}rlXrll@{}} +% \textbf{Item} & \textbf{Number} & \textbf{Description} & \textbf{Qt'y} & +% & \textbf{Serial Number} \\ +% \vspace*{0.5cm} @@ -40,27 +41,27 @@ - + \hspace{-0.1cm}, - + \vspace{0.3cm} - + \vspace{0.2cm} - + - + Tel: - + - + Fax: - + } @@ -75,27 +76,27 @@ Fax: - + \hspace{-0.1cm}, - + \vspace{0.3cm} - + \vspace{0.2cm} - + - + Tel: - + - + Fax: - + } @@ -120,10 +121,15 @@ Fax: \begin{tabularx}{\textwidth}{@{}rlXrll@{}} \textbf{Item} & \textbf{Number} & \textbf{Description} & \textbf{Qt'y} & & \textbf{Serial Number} \\ - - & & & & - & \\ - + + + & + & + & + & + & + \\ + \end{tabularx} -- cgit v1.2.3