[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb: [1241] trunk



Revision: 1241
          http://svn.sourceforge.net/ledger-smb/?rev=1241&view=rev
Author:   tetragon
Date:     2007-05-26 16:57:13 -0700 (Sat, 26 May 2007)

Log Message:
-----------
Adding PDF and Postscript support to LedgerSMB::Template
Removing all calls to $form->parse_template

Modified Paths:
--------------
    trunk/Build.PL
    trunk/LedgerSMB/Template/HTML.pm
    trunk/LedgerSMB/Template.pm
    trunk/Makefile.PL
    trunk/bin/arapprn.pl
    trunk/bin/cp.pl
    trunk/bin/io.pl
    trunk/bin/jc.pl
    trunk/bin/pos.pl
    trunk/bin/rp.pl
    trunk/t/01-load.t
    trunk/t/04-template-handling.t
    trunk/templates/demo/ap_transaction.tex
    trunk/templates/demo/ar_transaction.tex
    trunk/templates/demo/bin_list.tex
    trunk/templates/demo/check.tex
    trunk/templates/demo/invoice.tex
    trunk/templates/demo/packing_list.tex
    trunk/templates/demo/pick_list.tex
    trunk/templates/demo/purchase_order.tex
    trunk/templates/demo/receipt.tex
    trunk/templates/demo/request_quotation.tex
    trunk/templates/demo/sales_order.tex
    trunk/templates/demo/sales_quotation.tex
    trunk/templates/demo/statement.tex
    trunk/templates/demo/timecard.tex
    trunk/templates/demo/work_order.tex

Added Paths:
-----------
    trunk/LedgerSMB/Template/PDF.pm
    trunk/LedgerSMB/Template/PS.pm
    trunk/LedgerSMB/Template/TXT.pm

Modified: trunk/Build.PL
===================================================================
--- trunk/Build.PL	2007-05-25 18:08:01 UTC (rev 1240)
+++ trunk/Build.PL	2007-05-26 23:57:13 UTC (rev 1241)
@@ -28,6 +28,7 @@
 		'MIME::Lite'			=> 0,
 		'Error'				=> 0,
 		'Template'			=> 0,
+		'Template::Latex'		=> 0,
 		'Test::More'			=> 0,
 		'Test::Trap'			=> 0,
 		'Test::Exception'		=> 0,

Modified: trunk/LedgerSMB/Template/HTML.pm
===================================================================
--- trunk/LedgerSMB/Template/HTML.pm	2007-05-25 18:08:01 UTC (rev 1240)
+++ trunk/LedgerSMB/Template/HTML.pm	2007-05-26 23:57:13 UTC (rev 1241)
@@ -7,7 +7,7 @@
 
 =over
 
-=item get_template ()
+=item get_template ($name)
 
 Returns the appropriate template filename for this format.
 
@@ -16,8 +16,12 @@
 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.
 
 =back
@@ -37,6 +41,7 @@
 
 use Error qw(:try);
 use CGI;
+use Template;
 
 sub get_template {
     my $name = shift;
@@ -65,9 +70,29 @@
     return $vars;
 }
 
+sub process {
+	my $parent = shift;
+	my $cleanvars = shift;
+	my $template;
+
+	$template = Template->new({
+		INCLUDE_PATH => $parent->{include_path},
+		START_TAG => quotemeta('<?lsmb'),
+		END_TAG => 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;

Added: trunk/LedgerSMB/Template/PDF.pm
===================================================================
--- trunk/LedgerSMB/Template/PDF.pm	                        (rev 0)
+++ trunk/LedgerSMB/Template/PDF.pm	2007-05-26 23:57:13 UTC (rev 1241)
@@ -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('<?lsmb'),
+		END_TAG => 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;


Property changes on: trunk/LedgerSMB/Template/PDF.pm
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/LedgerSMB/Template/PS.pm
===================================================================
--- trunk/LedgerSMB/Template/PS.pm	                        (rev 0)
+++ trunk/LedgerSMB/Template/PS.pm	2007-05-26 23:57:13 UTC (rev 1241)
@@ -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('<?lsmb'),
+		END_TAG => 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;


Property changes on: trunk/LedgerSMB/Template/PS.pm
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/LedgerSMB/Template/TXT.pm
===================================================================
--- trunk/LedgerSMB/Template/TXT.pm	                        (rev 0)
+++ trunk/LedgerSMB/Template/TXT.pm	2007-05-26 23:57:13 UTC (rev 1241)
@@ -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('<?lsmb'),
+		END_TAG => 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;


Property changes on: trunk/LedgerSMB/Template/TXT.pm
___________________________________________________________________
Name: svn:executable
   + *

Modified: trunk/LedgerSMB/Template.pm
===================================================================
--- trunk/LedgerSMB/Template.pm	2007-05-25 18:08:01 UTC (rev 1240)
+++ trunk/LedgerSMB/Template.pm	2007-05-26 23:57:13 UTC (rev 1241)
@@ -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 @@
 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 @@
 package LedgerSMB::Template;
 
 use Error qw(:try);
-use Template;
 use LedgerSMB::Sysconfig;
 
 sub new {
@@ -55,7 +57,13 @@
 	$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 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('<?lsmb'),
-		END_TAG => quotemeta('?>'),
-		DELIMITER => ';',
-		}) || throw Error::Simple Template->error(); 
-
 	eval "require $format";
 	if ($@) {
 		throw Error::Simple $@;
@@ -108,15 +108,44 @@
 	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;

Modified: trunk/Makefile.PL
===================================================================
--- trunk/Makefile.PL	2007-05-25 18:08:01 UTC (rev 1240)
+++ trunk/Makefile.PL	2007-05-26 23:57:13 UTC (rev 1241)
@@ -28,6 +28,7 @@
 requires 'Config::Std';
 requires 'MIME::Lite';
 requires 'Template';
+requires 'Template::Latex';
 requires 'Error';
 
 build_requires 'Test::More';

Modified: trunk/bin/arapprn.pl
===================================================================
--- trunk/bin/arapprn.pl	2007-05-25 18:08:01 UTC (rev 1240)
+++ trunk/bin/arapprn.pl	2007-05-26 23:57:13 UTC (rev 1241)
@@ -285,24 +285,17 @@
     $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 );
-        };
+    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 );
+    catch Error::Simple with {
+        my $E = shift;
+        $form->error( $E->stacktrace );
+    };
 
     if ( $form->{previousform} ) {
 
@@ -560,24 +553,17 @@
     $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 );
-        };
+    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 );
+    catch Error::Simple with {
+        my $E = shift;
+        $form->error( $E->stacktrace );
+    };
 
     if (%$old_form) {
         $old_form->{invnumber} = $form->{invnumber};

Modified: trunk/bin/cp.pl
===================================================================
--- trunk/bin/cp.pl	2007-05-25 18:08:01 UTC (rev 1240)
+++ trunk/bin/cp.pl	2007-05-26 23:57:13 UTC (rev 1241)
@@ -1473,23 +1473,16 @@
         $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 );
-        };
+    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 );
+    };
 
 }
 

Modified: trunk/bin/io.pl
===================================================================
--- trunk/bin/io.pl	2007-05-25 18:08:01 UTC (rev 1240)
+++ trunk/bin/io.pl	2007-05-26 23:57:13 UTC (rev 1241)
@@ -1767,25 +1767,17 @@
     $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 );
-        };
+    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 );
+    };
 
-    $form->parse_template( \%myconfig, ${LedgerSMB::Sysconfig::userspath} );
-
     # if we got back here restore the previous form
     if ( defined %$old_form ) {
 

Modified: trunk/bin/jc.pl
===================================================================
--- trunk/bin/jc.pl	2007-05-25 18:08:01 UTC (rev 1240)
+++ trunk/bin/jc.pl	2007-05-26 23:57:13 UTC (rev 1241)
@@ -2205,7 +2205,16 @@
           $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 ) {
 

Modified: trunk/bin/pos.pl
===================================================================
--- trunk/bin/pos.pl	2007-05-25 18:08:01 UTC (rev 1240)
+++ trunk/bin/pos.pl	2007-05-26 23:57:13 UTC (rev 1241)
@@ -1001,23 +1001,16 @@
     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}";

Modified: trunk/bin/rp.pl
===================================================================
--- trunk/bin/rp.pl	2007-05-25 18:08:01 UTC (rev 1240)
+++ trunk/bin/rp.pl	2007-05-26 23:57:13 UTC (rev 1241)
@@ -1080,23 +1080,16 @@
 
     $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 @@
 
     $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 @@
                         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 );
+                };
             }
         }
     }

Modified: trunk/t/01-load.t
===================================================================
--- trunk/t/01-load.t	2007-05-25 18:08:01 UTC (rev 1240)
+++ trunk/t/01-load.t	2007-05-26 23:57:13 UTC (rev 1241)
@@ -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::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: {

Modified: trunk/t/04-template-handling.t
===================================================================
--- trunk/t/04-template-handling.t	2007-05-25 18:08:01 UTC (rev 1240)
+++ trunk/t/04-template-handling.t	2007-05-26 23:57:13 UTC (rev 1241)
@@ -18,6 +18,8 @@
 use LedgerSMB::Template;
 use LedgerSMB::Template::HTML;
 
+$LedgerSMB::Sysconfig::tempdir = 't/var';
+
 my @r;
 my $temp;
 my $form;
@@ -131,8 +133,8 @@
 		'test' => ['nest', 'bird', '0 < 15', 1]}), 
 	{'fruit' => '&amp;veggies', 'test' => ['nest', 'bird', '0 &lt; 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 @@
 	'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');
..hidden.. = <$FH>;
+close($FH);
+chomp(@r);
+is(join("\n", @r), "I am a template.\nLook at me foo&amp;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 @@
 	'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 @@
 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 @@
 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';

Modified: trunk/templates/demo/ap_transaction.tex
===================================================================
--- trunk/templates/demo/ap_transaction.tex	2007-05-25 18:08:01 UTC (rev 1240)
+++ trunk/templates/demo/ap_transaction.tex	2007-05-26 23:57:13 UTC (rev 1241)
@@ -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
 
-<?lsmb include letterhead.tex ?>
+<?lsmb INCLUDE letterhead.tex ?>
 
 \centerline{\textbf{A P} \hspace{0.3cm} \textbf{T R A N S A C T I O N}}
 
@@ -26,58 +26,64 @@
 <?lsmb address2 ?>
 
 <?lsmb city ?>
-<?lsmb if state>
+<?lsmb IF state>
 \hspace{-0.1cm}, <?lsmb state ?>
-<?lsmb end state ?> <?lsmb zipcode ?>
+<?lsmb END ?> <?lsmb zipcode ?>
 
 <?lsmb country ?>
 
 \vspace{0.3cm}
 
-<?lsmb if contact ?>
+<?lsmb IF contact ?>
 <?lsmb contact ?>
 \vspace{0.2cm}
-<?lsmb end contact ?>
+<?lsmb END ?>
 
-<?lsmb if vendorphone ?>
+<?lsmb IF vendorphone ?>
 Tel: <?lsmb vendorphone ?>
-<?lsmb end vendorphone ?>
+<?lsmb END ?>
 
-<?lsmb if vendorfax ?>
+<?lsmb IF vendorfax ?>
 Fax: <?lsmb vendorfax ?>
-<?lsmb end vendorfax ?>
+<?lsmb END ?>
 
 <?lsmb email ?>
 
-<?lsmb if vendortaxnumber ?>
+<?lsmb IF vendortaxnumber ?>
 Tax Number: <?lsmb vendortaxnumber ?>
-<?lsmb end vendortaxnumber ?>
+<?lsmb END ?>
 }
 \hfill
 \begin{tabular}[t]{ll}
   \textbf{Invoice \#} & <?lsmb invnumber ?> \\
   \textbf{Date} & <?lsmb invdate ?> \\
   \textbf{Due} & <?lsmb duedate ?> \\
-  <?lsmb if ponumber ?>
+  <?lsmb IF ponumber ?>
     \textbf{PO \#} & <?lsmb ponumber ?> \\
-  <?lsmb end ponumber ?>
-  <?lsmb if ordnumber ?>
+  <?lsmb END ?>
+  <?lsmb IF ordnumber ?>
     \textbf{Order \#} & <?lsmb ordnumber ?> \\
-  <?lsmb end ordnumber ?>
+  <?lsmb END ?>
   \textbf{Employee} & <?lsmb employee ?> \\
 \end{tabular}
 
 \vspace{1cm}
 
 ..hidden..@..hidden..
-<?lsmb foreach amount ?>
-  <?lsmb accno ?> & <?lsmb account ?> & <?lsmb amount ?> & <?lsmb description ?> & <?lsmb projectnumber ?> \\
-<?lsmb end amount ?>
+<?lsmb FOREACH amount ?>
+<?lsmb lc = loop.count - 1 ?>
+  <?lsmb accno.${lc} ?> &
+  <?lsmb account.${lc} ?> &
+  <?lsmb amount.${lc} ?> &
+  <?lsmb description.${lc} ?> &
+  <?lsmb projectnumber.${lc} ?> \\
+<?lsmb END ?>
 
   \multicolumn{2}{r}{\textbf{Subtotal}} & <?lsmb subtotal ?> & \\
-<?lsmb foreach tax ?>
-  \multicolumn{2}{r}{\textbf{<?lsmb taxdescription ?> @ <?lsmb taxrate ?> \%}} & <?lsmb tax ?> & \\
-<?lsmb end tax ?>
+<?lsmb FOREACH tax ?>
+<?lsmb lc = loop.count - 1 ?>
+  \multicolumn{2}{r}{\textbf{<?lsmb taxdescription.${lc} ?> @ <?lsmb taxrate.${lc} ?> \%}} & <?lsmb tax.${lc} ?> & \\
+<?lsmb END ?>
 
   \multicolumn{2}{r}{\textbf{Total}} & <?lsmb invtotal ?> & \\
   
@@ -87,25 +93,26 @@
 
 <?lsmb text_amount ?> ***** <?lsmb decimal ?>/100 <?lsmb currency ?>
 
-<?lsmb if notes ?>
+<?lsmb IF notes ?>
 \vspace{0.3cm}
 <?lsmb notes ?>
-<?lsmb end notes ?>
+<?lsmb END ?>
 
 \vspace{0.3cm}
 
-<?lsmb if paid_1 ?>
+<?lsmb IF paid_1 ?>
 ..hidden..@{}}
   \multicolumn{5}{c}{\textbf{Payments}} \\
   \hline
   \textbf{Date} & & \textbf{Source} & \textbf{Memo} & \textbf{Amount} \\
-<?lsmb end paid_1 ?>
-<?lsmb foreach payment ?>
-  <?lsmb paymentdate ?> & <?lsmb paymentaccount ?> & <?lsmb paymentsource ?> & <?lsmb paymentmemo ?> & <?lsmb payment ?> \\
-<?lsmb end payment ?>
-<?lsmb if paid_1 ?>
+<?lsmb END ?>
+<?lsmb FOREACH payment ?>
+<?lsmb lc = loop.count - 1 ?>
+  <?lsmb paymentdate.${lc} ?> & <?lsmb paymentaccount.${lc} ?> & <?lsmb paymentsource.${lc} ?> & <?lsmb paymentmemo.${lc} ?> & <?lsmb payment.${lc} ?> \\
+<?lsmb END ?>
+<?lsmb IF paid_1 ?>
 \end{tabular}
-<?lsmb end paid_1 ?>
+<?lsmb END ?>
 
 \end{document}
 

Modified: trunk/templates/demo/ar_transaction.tex
===================================================================
--- trunk/templates/demo/ar_transaction.tex	2007-05-25 18:08:01 UTC (rev 1240)
+++ trunk/templates/demo/ar_transaction.tex	2007-05-26 23:57:13 UTC (rev 1241)
@@ -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 @@
 <?lsmb address2 ?>
 
 <?lsmb city ?>
-<?lsmb if state ?>
+<?lsmb IF state ?>
 , <?lsmb state ?>
-<?lsmb end state ?>
+<?lsmb END ?>
 <?lsmb zipcode ?>
 
 <?lsmb country ?>
 
 \vspace{0.3cm}
 
-<?lsmb if contact ?>
+<?lsmb IF contact ?>
 <?lsmb contact ?>
-<?lsmb end contact ?>
+<?lsmb END ?>
 
 \vspace{0.2cm}
 
-<?lsmb if customerphone ?>
+<?lsmb IF customerphone ?>
 Tel: <?lsmb customerphone ?>
-<?lsmb end customerphone ?>
+<?lsmb END ?>
 
-<?lsmb if customerfax ?>
+<?lsmb IF customerfax ?>
 Fax: <?lsmb customerfax ?>
-<?lsmb end customerfax ?>
+<?lsmb END ?>
 
 <?lsmb email ?>
 
-<?lsmb if customertaxnumber ?>
+<?lsmb IF customertaxnumber ?>
 Tax Number: <?lsmb customertaxnumber ?>
-<?lsmb end customertaxnumber ?>
+<?lsmb END ?>
 }
 \hfill
 \begin{tabular}[t]{ll}
   \textbf{Invoice \#} & <?lsmb invnumber ?> \\
   \textbf{Date} & <?lsmb invdate ?> \\
   \textbf{Due} & <?lsmb duedate ?> \\
-  <?lsmb if ponumber ?>
+  <?lsmb IF ponumber ?>
     \textbf{PO \#} & <?lsmb ponumber ?> \\
-  <?lsmb end ponumber ?>
-  <?lsmb if ordnumber ?>
+  <?lsmb END ?>
+  <?lsmb IF ordnumber ?>
     \textbf{Order \#} & <?lsmb ordnumber ?> \\
-  <?lsmb end ordnumber ?>
+  <?lsmb END ?>
   \textbf{Employee} & <?lsmb employee ?> \\
 \end{tabular}
 
 \vspace{1cm}
 
 ..hidden..@..hidden..
-<?lsmb foreach amount ?>
-  <?lsmb accno ?> & <?lsmb account ?> & <?lsmb amount ?> & <?lsmb description ?> & <?lsmb projectnumber ?> \\
-<?lsmb end amount ?>
+<?lsmb FOREACH amount ?>
+<?lsmb lc = loop.count - 1 ?>
+  <?lsmb accno.${lc} ?> &
+  <?lsmb account.${lc} ?> &
+  <?lsmb amount.${lc} ?> &
+  <?lsmb description.${lc} ?> &
+  <?lsmb projectnumber.${lc} ?> \\
+<?lsmb END ?>
 
   \multicolumn{2}{r}{\textbf{Subtotal}} & <?lsmb subtotal ?> & \\
-<?lsmb foreach tax ?>
-  \multicolumn{2}{r}{\textbf{<?lsmb taxdescription ?> @ <?lsmb taxrate ?> \%}} & <?lsmb tax ?> & \\
-<?lsmb end tax ?>
+<?lsmb FOREACH tax ?>
+<?lsmb lc = loop.count - 1 ?>
+  \multicolumn{2}{r}{\textbf{<?lsmb taxdescription.${lc} ?> @ <?lsmb taxrate.${lc} ?> \%}} & <?lsmb tax.${lc} ?> & \\
+<?lsmb END ?>
 
   \multicolumn{2}{r}{\textbf{Total}} & <?lsmb invtotal ?> & \\
   
@@ -103,31 +109,33 @@
 
 <?lsmb text_amount ?> ***** <?lsmb decimal ?>/100 <?lsmb currency ?>
 
-<?lsmb if notes ?>
+<?lsmb IF notes ?>
 \vspace{0.3cm}
 <?lsmb notes ?>
-<?lsmb end notes ?>
+<?lsmb END ?>
 
 \vspace{0.3cm}
 
-<?lsmb if paid_1 ?>
+<?lsmb IF paid_1 ?>
 ..hidden..@{}}
   \multicolumn{5}{c}{\textbf{Payments}} \\
   \hline
   \textbf{Date} & & \textbf{Source} & \textbf{Amount} \\
-<?lsmb end paid_1 ?>
-<?lsmb foreach payment ?>
-  <?lsmb paymentdate ?> & <?lsmb paymentaccount ?> & <?lsmb paymentsource ?> & <?lsmb payment ?> \\
-<?lsmb end payment ?>
-<?lsmb if paid_1 ?>
+<?lsmb END ?>
+<?lsmb FOREACH payment ?>
+<?lsmb lc = loop.count - 1 ?>
+  <?lsmb paymentdate.${lc} ?> & <?lsmb paymentaccount.${lc} ?> & <?lsmb paymentsource.${lc} ?> & <?lsmb payment.${lc} ?> \\
+<?lsmb END ?>
+<?lsmb IF paid_1 ?>
 \end{tabular}
-<?lsmb end paid_1 ?>
+<?lsmb END ?>
 
 \vspace{0.5cm}
 
-<?lsmb foreach tax ?>
-\textbf{\scriptsize <?lsmb taxdescription ?> Registration <?lsmb taxnumber ?>} \\
-<?lsmb end tax ?>
+<?lsmb FOREACH tax ?>
+<?lsmb lc = loop.count - 1 ?>
+\textbf{\scriptsize <?lsmb taxdescription.${lc} ?> Registration <?lsmb taxnumber.${lc} ?>} \\
+<?lsmb END ?>
   
 \end{document}
 

Modified: trunk/templates/demo/bin_list.tex
===================================================================
--- trunk/templates/demo/bin_list.tex	2007-05-25 18:08:01 UTC (rev 1240)
+++ trunk/templates/demo/bin_list.tex	2007-05-26 23:57:13 UTC (rev 1241)
@@ -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
 
-<?lsmb include letterhead.tex ?>
+<?lsmb INCLUDE letterhead.tex ?>
 
- 
-<?lsmb pagebreak 65 27 37 ?>
-\end{tabularx}
 
-\newpage
+% Breaking old pagebreak directives
+%<?xlsmb pagebreak 65 27 37 ?>
+%\end{tabularx}
+%
+%\newpage
+%
+%\markboth{<?xlsmb company ?>\hfill <?xlsmb ordnumber ?>}{<?xlsmb company ?>\hfill <?xlsmb ordnumber ?>}
+%
..hidden..@{}}
+%  \textbf{Item} & \textbf{Number} & \textbf{Description} & \textbf{Serial Number} & & \textbf{Qty} & \textbf{Recd} & & \textbf{Bin} \\
+%<?xlsmb end pagebreak ?>
 
-\markboth{<?lsmb company ?>\hfill <?lsmb ordnumber ?>}{<?lsmb company ?>\hfill <?lsmb ordnumber ?>}
 
..hidden..@{}}
-  \textbf{Item} & \textbf{Number} & \textbf{Description} & \textbf{Serial Number} & & \textbf{Qty} & \textbf{Recd} & & \textbf{Bin} \\
-<?lsmb end pagebreak ?>
-
-
 \vspace*{0.5cm}
 
 \parbox[t]{.5\textwidth}{
@@ -39,9 +40,9 @@
 <?lsmb address2 ?>
 
 <?lsmb city ?>
-<?lsmb if state ?>
+<?lsmb IF state ?>
 \hspace{-0.1cm}, <?lsmb state ?>
-<?lsmb end state ?>
+<?lsmb END ?>
 <?lsmb zipcode ?>
 
 <?lsmb country ?>
@@ -57,9 +58,9 @@
 <?lsmb shiptoaddress2 ?>
 
 <?lsmb shiptocity ?>
-<?lsmb if shiptostate ?>
+<?lsmb IF shiptostate ?>
 \hspace{-0.1cm}, <?lsmb shiptostate ?>
-<?lsmb end shiptostate ?>
+<?lsmb END ?>
 <?lsmb shiptozipcode ?>
 
 <?lsmb shiptocountry ?>
@@ -75,23 +76,23 @@
 
 \begin{tabularx}{\textwidth}{*{6}{|X}|} \hline
   \textbf{Order \#} & \textbf{Date} & \textbf{Contact}
-  <?lsmb if warehouse ?>
+  <?lsmb IF warehouse ?>
   & \textbf{Warehouse}
-  <?lsmb end warehouse ?>
+  <?lsmb END ?>
   & \textbf{Shipping Point} & \textbf{Ship via} \\ [0.5em]
   \hline
   
   <?lsmb ordnumber ?>
-  <?lsmb if shippingdate ?>
+  <?lsmb IF shippingdate ?>
   & <?lsmb shippingdate ?>
-  <?lsmb end shippingdate ?>
-  <?lsmb if not shippingdate ?>
+  <?lsmb END ?>
+  <?lsmb IF NOT shippingdate ?>
   & <?lsmb orddate ?>
-  <?lsmb end shippingdate ?>
+  <?lsmb END ?>
   & <?lsmb employee ?>
-  <?lsmb if warehouse ?>
+  <?lsmb IF warehouse ?>
   & <?lsmb warehouse ?>
-  <?lsmb end warehouse ?>
+  <?lsmb END ?>
   & <?lsmb shippingpoint ?> & <?lsmb shipvia ?> \\
   \hline
 \end{tabularx}
@@ -101,10 +102,18 @@
 ..hidden..@{}}
   \textbf{Item} & \textbf{Number} & \textbf{Description} & \textbf{Serial Number} & & \textbf{Qty} & \textbf{Recd} & & \textbf{Bin} \\
 
-<?lsmb foreach number ?>
-  <?lsmb runningnumber ?> & <?lsmb number ?> & <?lsmb description ?> & <?lsmb serialnumber ?> &
-  <?lsmb deliverydate ?> & <?lsmb qty ?> & <?lsmb ship ?> & <?lsmb unit ?> & <?lsmb bin ?> \\
-<?lsmb end number ?>
+<?lsmb FOREACH number ?>
+<?lsmb lc = loop.count - 1 ?>
+  <?lsmb runningnumber.${lc} ?> &
+  <?lsmb number.${lc} ?> &
+  <?lsmb description.${lc} ?> &
+  <?lsmb serialnumber.${lc} ?> &
+  <?lsmb deliverydate.${lc} ?> &
+  <?lsmb qty.${lc} ?> &
+  <?lsmb ship.${lc} ?> &
+  <?lsmb unit.${lc} ?> &
+  <?lsmb bin.${lc} ?> \\
+<?lsmb END ?>
 \end{tabularx}
 
 

Modified: trunk/templates/demo/check.tex
===================================================================
--- trunk/templates/demo/check.tex	2007-05-25 18:08:01 UTC (rev 1240)
+++ trunk/templates/demo/check.tex	2007-05-26 23:57:13 UTC (rev 1241)
@@ -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 @@
 <?lsmb address2 ?>
 
 <?lsmb city ?>
-<?lsmb if state ?>
+<?lsmb IF state ?>
 \hspace{-0.1cm}, <?lsmb state ?>
-<?lsmb end state ?>
+<?lsmb END ?>
 <?lsmb zipcode ?>
 
 <?lsmb country ?>
@@ -61,10 +61,11 @@
 ..hidden..
 \textbf{Invoice \#} & \textbf{Invoice Date}
   & \textbf{Amount Due} & \textbf{Applied} \\
-<?lsmb foreach invnumber ?>
-<?lsmb invnumber ?> & <?lsmb invdate ?> \dotfill
-  & <?lsmb due ?> & <?lsmb paid ?> \\
-<?lsmb end invnumber ?>
+<?lsmb FOREACH invnumber ?>
+<?lsmb lc = loop.count - 1 ?>
+<?lsmb invnumber.${lc} ?> & <?lsmb invdate.${lc} ?> \dotfill
+  & <?lsmb due.${lc} ?> & <?lsmb paid.${lc} ?> \\
+<?lsmb END ?>
 \end{tabularx}
 
 \vspace{1cm}

Modified: trunk/templates/demo/invoice.tex
===================================================================
--- trunk/templates/demo/invoice.tex	2007-05-25 18:08:01 UTC (rev 1240)
+++ trunk/templates/demo/invoice.tex	2007-05-26 23:57:13 UTC (rev 1241)
@@ -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,31 +22,32 @@
   }
 }
 
-<?lsmb include letterhead.tex ?>
+<?lsmb INCLUDE letterhead.tex ?>
 
-<?lsmb pagebreak 65 27 37 ?>
-\end{tabularx}
+% Disable old pagebreak handling
+%<?xlsmb pagebreak 65 27 37 ?>
+%\end{tabularx}
+%
+%  \rule{\textwidth}{2pt}
+%  
+%  \vspace{0.2cm}
+%
+%  \hfill
+%  ..hidden..@{}}
+%  & Subtotal & <?xlsmb sumcarriedforward ?> \\
+%  \end{tabularx}
+%
+%\newpage
+%
+%\markboth{<?xlsmb company ?>\hfill <?xlsmb invnumber ?>}{<?xlsmb company ?>\hfill <?xlsmb invnumber ?>}
+%
..hidden..@{}}
+%  \textbf{Pos} & \textbf{Number} & \textbf{Description} & & \textbf{Qt'y} &
+%    \textbf{Unit} & \textbf{Price} & \textbf{Disc \%} & \textbf{Amount} \\ [0.5em]
+%  & carried forward from page <?xlsmb lastpage ?> & & & & & & & <?xlsmb sumcarriedforward ?> \\ [0.5em]
+%<?xlsmb end pagebreak ?>
 
-  \rule{\textwidth}{2pt}
-  
-  \vspace{0.2cm}
 
-  \hfill
-  ..hidden..@{}}
-  & Subtotal & <?lsmb sumcarriedforward ?> \\
-  \end{tabularx}
-
-\newpage
-
-\markboth{<?lsmb company ?>\hfill <?lsmb invnumber ?>}{<?lsmb company ?>\hfill <?lsmb invnumber ?>}
-
..hidden..@{}}
-  \textbf{Pos} & \textbf{Number} & \textbf{Description} & & \textbf{Qt'y} &
-    \textbf{Unit} & \textbf{Price} & \textbf{Disc \%} & \textbf{Amount} \\ [0.5em]
-  & carried forward from page <?lsmb lastpage ?> & & & & & & & <?lsmb sumcarriedforward ?> \\ [0.5em]
-<?lsmb end pagebreak ?>
-
-
 \vspace*{0.5cm}
 
 \parbox[t]{.5\textwidth}{
@@ -60,27 +61,27 @@
 <?lsmb address2 ?>
 
 <?lsmb city ?>
-<?lsmb if state ?>
+<?lsmb IF state ?>
 \hspace{-0.1cm}, <?lsmb state ?>
-<?lsmb end state ?>
+<?lsmb END ?>
 <?lsmb zipcode ?>
 
 <?lsmb country ?>
 
 \vspace{0.3cm}
 
-<?lsmb if contact ?>
+<?lsmb IF contact ?>
 <?lsmb contact ?>
 \vspace{0.2cm}
-<?lsmb end contact ?>
+<?lsmb END ?>
 
-<?lsmb if customerphone ?>
+<?lsmb IF customerphone ?>
 Tel: <?lsmb customerphone ?>
-<?lsmb end customerphone ?>
+<?lsmb END ?>
 
-<?lsmb if customerfax ?>
+<?lsmb IF customerfax ?>
 Fax: <?lsmb customerfax ?>
-<?lsmb end customerfax ?>
+<?lsmb END ?>
 
 <?lsmb email ?>
 }
@@ -95,27 +96,27 @@
 <?lsmb shiptoaddress2 ?>
 
 <?lsmb shiptocity ?>
-<?lsmb if shiptostate ?>
+<?lsmb IF shiptostate ?>
 \hspace{-0.1cm}, <?lsmb shiptostate ?>
-<?lsmb end shiptostate ?>
+<?lsmb END ?>
 <?lsmb shiptozipcode ?>
 
 <?lsmb shiptocountry ?>
 
 \vspace{0.3cm}
 
-<?lsmb if shiptocontact ?>
+<?lsmb IF shiptocontact ?>
 <?lsmb shiptocontact ?>
 \vspace{0.2cm}
-<?lsmb end shiptocontact ?>
+<?lsmb END ?>
 
-<?lsmb if shiptophone ?>
+<?lsmb IF shiptophone ?>
 Tel: <?lsmb shiptophone ?>
-<?lsmb end shiptophone ?>
+<?lsmb END ?>
 
-<?lsmb if shiptofax ?>
+<?lsmb IF shiptofax ?>
 Fax: <?lsmb shiptofax ?>
-<?lsmb end shiptofax ?>
+<?lsmb END ?>
 
 <?lsmb shiptoemail ?>
 }
@@ -142,10 +143,18 @@
 ..hidden..@{}}
   \textbf{Pos} & \textbf{Number} & \textbf{Description} & & \textbf{Qt'y} &
     \textbf{Unit} & \textbf{Price} & \textbf{Disc \%} & \textbf{Amount} \\ [0.5em]
-<?lsmb foreach number ?>
-  <?lsmb runningnumber ?> & <?lsmb number ?> & <?lsmb description ?> & <?lsmb deliverydate ?> &
-  <?lsmb qty ?> & <?lsmb unit ?> & <?lsmb sellprice ?> & <?lsmb discountrate ?> & <?lsmb linetotal ?> \\
-<?lsmb end number ?>
+<?lsmb FOREACH number ?>
+<?lsmb lc = loop.count - 1 ?>
+  <?lsmb runningnumber.${lc} ?> & 
+  <?lsmb number.${lc} ?> & 
+  <?lsmb description.${lc} ?> & 
+  <?lsmb deliverydate.${lc} ?> &
+  <?lsmb qty.${lc} ?> & 
+  <?lsmb unit.${lc} ?> &
+  <?lsmb sellprice.${lc} ?> &
+  <?lsmb discountrate.${lc} ?> &
+  <?lsmb linetotal.${lc} ?> \\
+<?lsmb END ?>
 \end{tabularx}
 
 
@@ -157,16 +166,17 @@
 \hfill
 ..hidden..@{}}
   & Subtotal & <?lsmb subtotal ?> \\
-<?lsmb foreach tax ?>
-  & <?lsmb taxdescription ?> on <?lsmb taxbase ?> & <?lsmb tax ?> \\
-<?lsmb end tax ?>
-<?lsmb if paid ?>
+<?lsmb FOREACH tax ?>
+<?lsmb lc = loop.count - 1 ?>
+  & <?lsmb taxdescription.${lc} ?> on <?lsmb taxbase.${lc} ?> & <?lsmb tax.${lc} ?> \\
+<?lsmb END ?>
+<?lsmb IF paid ?>
   & Paid & - <?lsmb paid ?> \\
-<?lsmb end paid ?>
+<?lsmb END ?>
   \hline
-<?lsmb if total ?>
+<?lsmb IF total ?>
   & Balance Due & <?lsmb total ?>
-<?lsmb end total ?>
+<?lsmb END ?>
 \end{tabularx}
 
 \vspace{0.3cm}
@@ -182,18 +192,19 @@
 
 \vfill
 
-<?lsmb if paid_1 ?>
+<?lsmb IF paid_1 ?>
 ..hidden..@{}}
   \textbf{Payments} & & & \\
   \hline
   \textbf{Date} & & \textbf{Source} & \textbf{Amount} \\
-<?lsmb end paid_1 ?>
-<?lsmb foreach payment ?>
-  <?lsmb paymentdate ?> & <?lsmb paymentaccount ?> & <?lsmb paymentsource ?> & <?lsmb payment ?> \\
-<?lsmb end payment ?>
-<?lsmb if paid_1 ?>
+<?lsmb END ?>
+<?lsmb FOREACH payment ?>
+<?lsmb lc = loop.count - 1 ?>
+  <?lsmb paymentdate.${lc} ?> & <?lsmb paymentaccount.${lc} ?> & <?lsmb paymentsource.${lc} ?> & <?lsmb payment.${lc} ?> \\
+<?lsmb END ?>
+<?lsmb IF paid_1 ?>
 \end{tabularx}
-<?lsmb end paid_1 ?>
+<?lsmb END ?>
 
 \vspace{1cm}
 

Modified: trunk/templates/demo/packing_list.tex
===================================================================
--- trunk/templates/demo/packing_list.tex	2007-05-25 18:08:01 UTC (rev 1240)
+++ trunk/templates/demo/packing_list.tex	2007-05-26 23:57:13 UTC (rev 1241)
@@ -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,20 +23,21 @@
   }
 }
 
-<?lsmb include letterhead.tex ?>
+<?lsmb INCLUDE letterhead.tex ?>
 
-<?lsmb pagebreak 65 27 37 ?>
-\end{tabularx}
+% Breaking old pagebreak directive
+%<?xlsmb pagebreak 65 27 37 ?>
+%\end{tabularx}
+%
+%\newpage
+%
+%\markboth{<?xlsmb company ?>\hfill <?xlsmb ordnumber ?>}{<?xlsmb company ?>\hfill <?xlsmb ordnumber ?>}
+%
..hidden..@{}}
+%  \textbf{Item} & \textbf{Number} & \textbf{Description} & \textbf{Serial Number} & & \textbf{Qty} & \textbf{Ship} & \\
+%<?xlsmb end pagebreak ?>
 
-\newpage
 
-\markboth{<?lsmb company ?>\hfill <?lsmb ordnumber ?>}{<?lsmb company ?>\hfill <?lsmb ordnumber ?>}
-
..hidden..@{}}
-  \textbf{Item} & \textbf{Number} & \textbf{Description} & \textbf{Serial Number} & & \textbf{Qty} & \textbf{Ship} & \\
-<?lsmb end pagebreak ?>
-
-
 \vspace*{0.5cm}
 
 \parbox[t]{.5\textwidth}{
@@ -53,9 +54,9 @@
 <?lsmb shiptoaddress2 ?>
 
 <?lsmb shiptocity ?>
-<?lsmb if shiptostate ?>
+<?lsmb IF shiptostate ?>
 \hspace{-0.1cm}, <?lsmb shiptostate ?>
-<?lsmb end shiptostate ?>
+<?lsmb END ?>
 <?lsmb shiptozipcode ?>
 
 <?lsmb shiptocountry ?>
@@ -63,13 +64,13 @@
 \parbox[t]{.5\textwidth}{
   <?lsmb shiptocontact ?>
   
-  <?lsmb if shiptophone ?>
+  <?lsmb IF shiptophone ?>
   Tel: <?lsmb shiptophone ?>
-  <?lsmb end shiptophone ?>
+  <?lsmb END ?>
   
-  <?lsmb if shiptofax ?>
+  <?lsmb IF shiptofax ?>
   Fax: <?lsmb shiptofax ?>
-  <?lsmb end shiptofax ?>
+  <?lsmb END ?>
   
   <?lsmb shiptoemail ?>
 }
@@ -84,23 +85,22 @@
 
 \begin{tabularx}{\textwidth}{*{7}{|X}|} \hline
   \textbf{Invoice \#} & \textbf{Order \#} & \textbf{Date} & \textbf{Contact}
-  <?lsmb if warehouse ?>
+  <?lsmb IF warehouse ?>
   & \textbf{Warehouse}
-  <?lsmb end warehouse ?>
+  <?lsmb END ?>
   & \textbf{Shipping Point} & \textbf{Ship via} \\ [0.5em]
   \hline
   
   <?lsmb invnumber ?> & <?lsmb ordnumber ?>
-  <?lsmb if shippingdate ?>
+  <?lsmb IF shippingdate ?>
   & <?lsmb shippingdate ?>
-  <?lsmb end shippingdate ?>
-  <?lsmb if not shippingdate ?>
+  <?lsmb ELSE ?>
   & <?lsmb transdate ?>
-  <?lsmb end shippingdate ?>
+  <?lsmb END shippingdate ?>
   & <?lsmb employee ?>
-  <?lsmb if warehouse ?>
+  <?lsmb IF warehouse ?>
   & <?lsmb warehouse ?>
-  <?lsmb end warehouse ?>
+  <?lsmb END ?>
   & <?lsmb shippingpoint ?> & <?lsmb shipvia ?> \\
   \hline
 \end{tabularx}
@@ -110,10 +110,17 @@
 ..hidden..@{}}
   \textbf{Item} & \textbf{Number} & \textbf{Description} & \textbf{Serial Number} & & \textbf{Qty} & \textbf{Ship} & \\
 
-<?lsmb foreach number ?>
-  <?lsmb runningnumber ?> & <?lsmb number ?> & <?lsmb description ?> & <?lsmb serialnumber ?> &
-  <?lsmb deliverydate ?> & <?lsmb qty ?> & <?lsmb ship ?> & <?lsmb unit ?> \\
-<?lsmb end number ?>
+<?lsmb FOREACH number ?>
+<?lsmb lc = loop.count - 1 ?>
+  <?lsmb runningnumber.${lc} ?> &
+  <?lsmb number.${lc} ?> &
+  <?lsmb description.${lc} ?> &
+  <?lsmb serialnumber.${lc} ?> &
+  <?lsmb deliverydate.${lc} ?> &
+  <?lsmb qty.${lc} ?> &
+  <?lsmb ship.${lc} ?> &
+  <?lsmb unit.${lc} ?> \\
+<?lsmb END ?>
 \end{tabularx}
 
 

Modified: trunk/templates/demo/pick_list.tex
===================================================================
--- trunk/templates/demo/pick_list.tex	2007-05-25 18:08:01 UTC (rev 1240)
+++ trunk/templates/demo/pick_list.tex	2007-05-26 23:57:13 UTC (rev 1241)
@@ -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,22 +11,23 @@
 
 \fontfamily{cmss}\fontsize{10pt}{12pt}\selectfont
 
-<?lsmb include letterhead.tex ?>
+<?lsmb INCLUDE letterhead.tex ?>
 
- 
-<?lsmb pagebreak 65 27 37 ?>
-\end{tabularx}
 
-\newpage
+% Breaking old pagebreak directive
+%<?xlsmb pagebreak 65 27 37 ?>
+%\end{tabularx}
+%
+%\newpage
+%
+%\markboth{<?xlsmb company ?>\hfill <?xlsmb ordnumber ?>}{<?xlsmb company ?>\hfill <?xlsmb ordnumber ?>}
+%
..hidden..@{}}
+%  \textbf{Item} & \textbf{Number} & \textbf{Description} &
+%  \textbf{Qty} & \textbf{Ship} & & \textbf{Bin} \\
+%
+%<?xlsmb end pagebreak ?>
 
-\markboth{<?lsmb company ?>\hfill <?lsmb ordnumber ?>}{<?lsmb company ?>\hfill <?lsmb ordnumber ?>}
-
..hidden..@{}}
-  \textbf{Item} & \textbf{Number} & \textbf{Description} &
-  \textbf{Qty} & \textbf{Ship} & & \textbf{Bin} \\
-
-<?lsmb end pagebreak ?>
-
 \vspace*{0.5cm}
 
 \parbox[t]{.5\textwidth}{
@@ -44,9 +45,9 @@
 <?lsmb shiptoaddress2 ?>
 
 <?lsmb shiptocity ?>
-<?lsmb if shiptostate ?>
+<?lsmb IF shiptostate ?>
 \hspace{-0.1cm}, <?lsmb shiptostate ?>
-<?lsmb end shiptostate ?>
+<?lsmb END ?>
 <?lsmb shiptozipcode ?>
 
 <?lsmb shiptocountry ?>
@@ -54,13 +55,13 @@
 \parbox[t]{.5\textwidth}{
   <?lsmb shiptocontact ?>
 
-  <?lsmb if shiptophone ?>
+  <?lsmb IF shiptophone ?>
   Tel: <?lsmb shiptophone ?>
-  <?lsmb end shiptophone ?>
+  <?lsmb END ?>
 
-  <?lsmb if shiptofax ?>
+  <?lsmb IF shiptofax ?>
   Fax: <?lsmb shiptofax ?>
-  <?lsmb end shiptofax ?>
+  <?lsmb END ?>
 
   <?lsmb shiptoemail ?>
 }
@@ -78,12 +79,11 @@
   & \textbf{Warehouse} & \textbf{Shipping Point} & \textbf{Ship via} \\ [0.5em]
   \hline
   <?lsmb invnumber ?> & <?lsmb ordnumber ?>
-  <?lsmb if shippingdate ?>
+  <?lsmb IF shippingdate ?>
   & <?lsmb shippingdate ?>
-  <?lsmb end shippingdate ?>
-  <?lsmb if not shippingdate ?>
+  <?lsmb ELSE ?>
   & <?lsmb transdate ?>
-  <?lsmb end shippingdate ?>
+  <?lsmb END ?>
   & <?lsmb employee ?> & <?lsmb warehouse ?> & <?lsmb shippingpoint ?> & <?lsmb shipvia ?> \\
   \hline
 \end{tabularx}
@@ -93,10 +93,14 @@
 ..hidden..@{}}
   \textbf{Item} & \textbf{Number} & \textbf{Description} &
   \textbf{Qty} & \textbf{Ship} & & \textbf{Bin} \\
-<?lsmb foreach number ?>
-  <?lsmb runningnumber ?> & <?lsmb number ?> & <?lsmb description ?> &
-  <?lsmb qty ?> & [\hspace{1cm}] & <?lsmb unit ?> & <?lsmb bin ?> \\
-<?lsmb end number ?>
+<?lsmb FOREACH number ?>
+<?lsmb lc = loop.count - 1 ?>
+  <?lsmb runningnumber.${lc} ?> &
+  <?lsmb number.${lc} ?> &
+  <?lsmb description.${lc} ?> &
+  <?lsmb qty.${lc} ?> & [\hspace{1cm}] &
+  <?lsmb unit.${lc} ?> & <?lsmb bin.${lc} ?> \\
+<?lsmb END ?>
 \end{tabularx}
 
 

Modified: trunk/templates/demo/purchase_order.tex
===================================================================
--- trunk/templates/demo/purchase_order.tex	2007-05-25 18:08:01 UTC (rev 1240)
+++ trunk/templates/demo/purchase_order.tex	2007-05-26 23:57:13 UTC (rev 1241)
@@ -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,30 +12,31 @@
 
 \fontfamily{cmss}\fontsize{10pt}{12pt}\selectfont
 
-<?lsmb include letterhead.tex ?>
+<?lsmb INCLUDE letterhead.tex ?>
 
 
-<?lsmb pagebreak 65 27 48 ?>
-\end{tabularx}
+% Breaking old pagebreak directive
+%<?xlsmb pagebreak 65 27 48 ?>
+%\end{tabularx}
+%
+%  \rule{\textwidth}{2pt}
+%  
+%  \hfill
+%  ..hidden..@{}}
+%  & Subtotal & <?xlsmb sumcarriedforward ?> \\
+%  \end{tabularx}
+%
+%\newpage
+%
+%\markboth{<?xlsmb company ?>\hfill <?xlsmb ordnumber ?>}{<?xlsmb company ?>\hfill <?xlsmb ordnumber ?>}
+%
..hidden..@{}}
+%  \textbf{Number} & \textbf{Description} & \textbf{Qt'y} &
+%    \textbf{Unit} & \textbf{Price} & \textbf{Amount} \\
+%  & carried forward from <?xlsmb lastpage ?> & & & & <?xlsmb sumcarriedforward ?> \\
+%<?xlsmb end pagebreak ?>
 
-  \rule{\textwidth}{2pt}
-  
-  \hfill
-  ..hidden..@{}}
-  & Subtotal & <?lsmb sumcarriedforward ?> \\
-  \end{tabularx}
 
-\newpage
-
-\markboth{<?lsmb company ?>\hfill <?lsmb ordnumber ?>}{<?lsmb company ?>\hfill <?lsmb ordnumber ?>}
-
..hidden..@{}}
-  \textbf{Number} & \textbf{Description} & \textbf{Qt'y} &
-    \textbf{Unit} & \textbf{Price} & \textbf{Amount} \\
-  & carried forward from <?lsmb lastpage ?> & & & & <?lsmb sumcarriedforward ?> \\
-<?lsmb end pagebreak ?>
-
-
 \vspace*{0.5cm}
 
 \parbox[t]{.5\textwidth}{
@@ -49,27 +50,27 @@
 <?lsmb address2 ?>
 
 <?lsmb city ?>
-<?lsmb if state ?>
+<?lsmb IF state ?>
 \hspace{-0.1cm}, <?lsmb state ?>
-<?lsmb end state ?>
+<?lsmb END ?>
 <?lsmb zipcode ?>
 
 <?lsmb country ?>
 
 \vspace{0.3cm}
 
-<?lsmb if contact ?>
+<?lsmb IF contact ?>
 Attn: <?lsmb contact ?>
 \vspace{0.2cm}
-<?lsmb end contact ?>
+<?lsmb END ?>
 
-<?lsmb if vendorphone ?>
+<?lsmb IF vendorphone ?>
 Tel: <?lsmb vendorphone ?>
-<?lsmb end vendorphone ?>
+<?lsmb END ?>
 
-<?lsmb if vendorfax ?>
+<?lsmb IF vendorfax ?>
 Fax: <?lsmb vendorfax ?>
-<?lsmb end vendorfax ?>
+<?lsmb END ?>
 
 <?lsmb email ?>
 }
@@ -84,27 +85,27 @@
 <?lsmb shiptoaddress2 ?>
 
 <?lsmb shiptocity ?>
-<?lsmb if shiptostate ?>
+<?lsmb IF shiptostate ?>
 \hspace{-0.1cm}, <?lsmb shiptostate ?>
-<?lsmb end shiptostate ?>
+<?lsmb END ?>
 <?lsmb shiptozipcode ?>
 
 <?lsmb shiptocountry ?>
 
 \vspace{0.3cm}
 
-<?lsmb if shiptocontact ?>
+<?lsmb IF shiptocontact ?>
 Attn: <?lsmb shiptocontact ?>
 \vspace{0.2cm}
-<?lsmb end shiptocontact ?>
+<?lsmb END ?>
 
-<?lsmb if shiptophone ?>
+<?lsmb IF shiptophone ?>
 Tel: <?lsmb shiptophone ?>
-<?lsmb end shiptophone ?>
+<?lsmb END ?>
 
-<?lsmb if shiptofax ?>
+<?lsmb IF shiptofax ?>
 Fax: <?lsmb shiptofax ?>
-<?lsmb end shiptofax ?>
+<?lsmb END ?>
 
 <?lsmb shiptoemail ?>
 }
@@ -128,10 +129,15 @@
 ..hidden..@{}}
   \textbf{Number} & \textbf{Description} & \textbf{Qt'y} &
     \textbf{Unit} & \textbf{Price} & \textbf{Amount} \\
-<?lsmb foreach number ?>
-  <?lsmb number ?> & <?lsmb description ?> & <?lsmb qty ?> &
-    <?lsmb unit ?> & <?lsmb sellprice ?> & <?lsmb linetotal ?> \\
-<?lsmb end number ?>
+<?lsmb FOREACH number ?>
+<?lsmb lc = loop.count - 1 ?>
+  <?lsmb number.${lc} ?> &
+  <?lsmb description.${lc} ?> &
+  <?lsmb qty.${lc} ?> &
+  <?lsmb unit.${lc} ?> &
+  <?lsmb sellprice.${lc} ?> &
+  <?lsmb linetotal.${lc} ?> \\
+<?lsmb END ?>
 \end{tabularx}
 
 
@@ -143,9 +149,10 @@
 \hfill
 ..hidden..@{}}
   & Subtotal & <?lsmb subtotal ?> \\
-<?lsmb foreach tax ?>
-  & <?lsmb taxdescription ?> on <?lsmb taxbase ?> & <?lsmb tax ?>\\
-<?lsmb end tax ?>
+<?lsmb FOREACH tax ?>
+<?lsmb lc = loop.count - 1 ?>
+  & <?lsmb taxdescription.${lc} ?> on <?lsmb taxbase.${lc} ?> & <?lsmb tax.${lc} ?>\\
+<?lsmb END ?>
   \hline
   & Total & <?lsmb ordtotal ?>\\
 \end{tabularx}

Modified: trunk/templates/demo/receipt.tex
===================================================================
--- trunk/templates/demo/receipt.tex	2007-05-25 18:08:01 UTC (rev 1240)
+++ trunk/templates/demo/receipt.tex	2007-05-26 23:57:13 UTC (rev 1241)
@@ -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 @@
 <?lsmb address2 ?>
 
 <?lsmb city ?>
-<?lsmb if state ?>
+<?lsmb IF state ?>
 \hspace{-0.1cm}, <?lsmb state ?>
-<?lsmb end state ?>
+<?lsmb END ?>
 <?lsmb zipcode ?>
 
 <?lsmb country ?>
@@ -61,10 +61,11 @@
 ..hidden..
 \textbf{Invoice No.} & \textbf{Invoice Date}
   & \textbf{Due} & \textbf{Applied} \\
-<?lsmb foreach invnumber ?>
-<?lsmb invnumber ?> & <?lsmb invdate ?> \dotfill
-  & <?lsmb due ?> & <?lsmb paid ?> \\
-<?lsmb end invnumber ?>
+<?lsmb FOREACH invnumber ?>
+<?lsmb lc = loop.count - 1 ?>
+<?lsmb invnumber.${lc} ?> & <?lsmb invdate.${lc} ?> \dotfill
+  & <?lsmb due.${lc} ?> & <?lsmb paid.${lc} ?> \\
+<?lsmb END ?>
 \end{tabularx}
 
 \vspace{1cm}

Modified: trunk/templates/demo/request_quotation.tex
===================================================================
--- trunk/templates/demo/request_quotation.tex	2007-05-25 18:08:01 UTC (rev 1240)
+++ trunk/templates/demo/request_quotation.tex	2007-05-26 23:57:13 UTC (rev 1241)
@@ -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,30 +11,31 @@
 
 \fontfamily{cmss}\fontsize{10pt}{12pt}\selectfont
 
-<?lsmb include letterhead.tex ?>
+<?lsmb INCLUDE letterhead.tex ?>
 
 
-<?lsmb pagebreak 65 27 48 ?>
-\end{tabularx}
+% Breaking old pagebreak directive
+%<?xlsmb pagebreak 65 27 48 ?>
+%\end{tabularx}
+%
+%  \rule{\textwidth}{2pt}
+%  
+%  \hfill
+%  ..hidden..@{}}
+%  & \textbf{Subtotal} & \textbf{<?xlsmb sumcarriedforward ?>} \\
+%  \end{tabularx}
+%
+%\newpage
+%
+%\markboth{<?xlsmb company ?>\hfill <?xlsmb ordnumber ?>}{<?xlsmb company ?>\hfill <?xlsmb ordnumber ?>}
+%
..hidden..@{}}
+%  \textbf{Number} & \textbf{Description} & \textbf{Qt'y} &
+%    \textbf{Unit} & \textbf{Price} & \textbf{Extended} \\
+%  & carried forward from <?xlsmb lastpage ?> & & & & <?xlsmb sumcarriedforward ?> \\
+%<?xlsmb end pagebreak ?>
 
-  \rule{\textwidth}{2pt}
-  
-  \hfill
-  ..hidden..@{}}
-  & \textbf{Subtotal} & \textbf{<?lsmb sumcarriedforward ?>} \\
-  \end{tabularx}
 
-\newpage
-
-\markboth{<?lsmb company ?>\hfill <?lsmb ordnumber ?>}{<?lsmb company ?>\hfill <?lsmb ordnumber ?>}
-
..hidden..@{}}
-  \textbf{Number} & \textbf{Description} & \textbf{Qt'y} &
-    \textbf{Unit} & \textbf{Price} & \textbf{Extended} \\
-  & carried forward from <?lsmb lastpage ?> & & & & <?lsmb sumcarriedforward ?> \\
-<?lsmb end pagebreak ?>
-
-
 \vspace*{0.5cm}
 
 \parbox[t]{.5\textwidth}{
@@ -48,27 +49,27 @@
 <?lsmb address2 ?>
 
 <?lsmb city ?>
-<?lsmb if state ?>
+<?lsmb IF state ?>
 \hspace{-0.1cm}, <?lsmb state ?>
-<?lsmb end state ?>
+<?lsmb END ?>
 <?lsmb zipcode ?>
 
 <?lsmb country ?>
 
 \vspace{0.3cm}
 
-<?lsmb if contact ?>
+<?lsmb IF contact ?>
 <?lsmb contact ?>
 \vspace{0.2cm}
-<?lsmb end contact ?>
+<?lsmb END ?>
 
-<?lsmb if vendorphone ?>
+<?lsmb IF vendorphone ?>
 Tel: <?lsmb vendorphone ?>
-<?lsmb end vendorphone ?>
+<?lsmb END ?>
 
-<?lsmb if vendorfax ?>
+<?lsmb IF vendorfax ?>
 Fax: <?lsmb vendorfax ?>
-<?lsmb end vendorfax ?>
+<?lsmb END ?>
 
 <?lsmb email ?>
 }
@@ -83,27 +84,27 @@
 <?lsmb shiptoaddress2 ?>
 
 <?lsmb shiptocity ?>
-<?lsmb if shiptostate ?>
+<?lsmb IF shiptostate ?>
 \hspace{-0.1cm}, <?lsmb shiptostate ?>
-<?lsmb end shiptostate ?>
+<?lsmb END ?>
 <?lsmb shiptozipcode ?>
 
 <?lsmb shiptocountry ?>
 
 \vspace{0.3cm}
 
-<?lsmb if shiptocontact ?>
+<?lsmb IF shiptocontact ?>
 <?lsmb shiptocontact ?>
 \vspace{0.2cm}
-<?lsmb end shiptocontact ?>
+<?lsmb END ?>
 
-<?lsmb if shiptophone ?>
+<?lsmb IF shiptophone ?>
 Tel: <?lsmb shiptophone ?>
-<?lsmb end shiptophone ?>
+<?lsmb END ?>
 
-<?lsmb if shiptofax ?>
+<?lsmb IF shiptofax ?>
 Fax: <?lsmb shiptofax ?>
-<?lsmb end shiptofax ?>
+<?lsmb END ?>
 
 <?lsmb shiptoemail ?>
 }
@@ -132,9 +133,13 @@
 ..hidden..@{}}
   \textbf{Number} & \textbf{Description} & \textbf{Qt'y} & &
   \textbf{Delivery} & \textbf{Unit Price} & \textbf{Extended} \\
-<?lsmb foreach number ?>
-  <?lsmb number ?> & <?lsmb description ?> & <?lsmb qty ?> & <?lsmb unit ?> \\
-<?lsmb end number ?>
+<?lsmb FOREACH number ?>
+<?lsmb lc = loop.count - 1 ?>
+  <?lsmb number.${lc} ?> &
+  <?lsmb description.${lc} ?> &
+  <?lsmb qty.${lc} ?> &
+  <?lsmb unit.${lc} ?> \\
+<?lsmb END ?>
 \end{tabularx}
 
 

Modified: trunk/templates/demo/sales_order.tex
===================================================================
--- trunk/templates/demo/sales_order.tex	2007-05-25 18:08:01 UTC (rev 1240)
+++ trunk/templates/demo/sales_order.tex	2007-05-26 23:57:13 UTC (rev 1241)
@@ -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,31 +11,32 @@
 
 \fontfamily{cmss}\fontsize{10pt}{12pt}\selectfont
 
-<?lsmb include letterhead.tex ?>
+<?lsmb INCLUDE letterhead.tex ?>
 
 
-<?lsmb pagebreak 65 27 48 ?>
-\end{tabularx}
+% Breaking old pagebreak directive
+%<?xlsmb pagebreak 65 27 48 ?>
+%\end{tabularx}
+%
+%  \rule{\textwidth}{2pt}
+%  
+%  \hfill
+%  ..hidden..@{}}
+%  & \textbf{Subtotal} & \textbf{<?xlsmb sumcarriedforward ?>} \\
+%  \end{tabularx}
+%
+%\newpage
+%
+%\markboth{<?xlsmb company ?>\hfill <?xlsmb ordnumber ?>}{<?xlsmb company ?>\hfill <?xlsmb ordnumber ?>}
+%
+%
..hidden..@{}}
+%  \textbf{Item} & \textbf{Number} & \textbf{Description} & \textbf{Qt'y} &
+%  \textbf{Unit} & \textbf{Price} & \textbf{Disc \%} & \textbf{Amount} \\
+%  & carried forward from <?xlsmb lastpage ?> & & & & & <?xlsmb sumcarriedforward ?> \\
+%<?xlsmb end pagebreak ?>
 
-  \rule{\textwidth}{2pt}
-  
-  \hfill
-  ..hidden..@{}}
-  & \textbf{Subtotal} & \textbf{<?lsmb sumcarriedforward ?>} \\
-  \end{tabularx}
 
-\newpage
-
-\markboth{<?lsmb company ?>\hfill <?lsmb ordnumber ?>}{<?lsmb company ?>\hfill <?lsmb ordnumber ?>}
-
-
..hidden..@{}}
-  \textbf{Item} & \textbf{Number} & \textbf{Description} & \textbf{Qt'y} &
-  \textbf{Unit} & \textbf{Price} & \textbf{Disc \%} & \textbf{Amount} \\
-  & carried forward from <?lsmb lastpage ?> & & & & & <?lsmb sumcarriedforward ?> \\
-<?lsmb end pagebreak ?>
-
-
 \vspace*{0.5cm}
 
 \parbox[t]{.5\textwidth}{
@@ -49,27 +50,27 @@
 <?lsmb address2 ?>
 
 <?lsmb city ?>
-<?lsmb if state ?>
+<?lsmb IF state ?>
 \hspace{-0.1cm}, <?lsmb state ?>
-<?lsmb end state ?>
+<?lsmb END ?>
 <?lsmb zipcode ?>
 
 <?lsmb country ?>
 
 \vspace{0.3cm}
 
-<?lsmb if contact ?>
+<?lsmb IF contact ?>
 <?lsmb contact ?>
 \vspace{0.2cm}
-<?lsmb end contact ?>
+<?lsmb END ?>
 
-<?lsmb if customerphone ?>
+<?lsmb IF customerphone ?>
 Tel: <?lsmb customerphone ?>
-<?lsmb end customerphone ?>
+<?lsmb END ?>
 
-<?lsmb if customerfax ?>
+<?lsmb IF customerfax ?>
 Fax: <?lsmb customerfax ?>
-<?lsmb end customerfax ?>
+<?lsmb END ?>
 
 <?lsmb email ?>
 }
@@ -84,27 +85,27 @@
 <?lsmb shiptoaddress2 ?>
 
 <?lsmb shiptocity ?>
-<?lsmb if shiptostate ?>
+<?lsmb IF shiptostate ?>
 \hspace{-0.1cm}, <?lsmb shiptostate ?>
-<?lsmb end shiptostate ?>
+<?lsmb END ?>
 <?lsmb shiptozipcode ?>
 
 <?lsmb shiptocountry ?>
 
 \vspace{0.3cm}
 
-<?lsmb if shiptocontact ?>
+<?lsmb IF shiptocontact ?>
 <?lsmb shiptocontact ?>
 \vspace{0.2cm}
-<?lsmb end shiptocontact ?>
+<?lsmb END ?>
 
-<?lsmb if shiptophone ?>
+<?lsmb IF shiptophone ?>
 Tel: <?lsmb shiptophone ?>
-<?lsmb end shiptophone ?>
+<?lsmb END ?>
 
-<?lsmb if shiptofax ?>
+<?lsmb IF shiptofax ?>
 Fax: <?lsmb shiptofax ?>
-<?lsmb end shiptofax ?>
+<?lsmb END ?>
 
 <?lsmb shiptoemail ?>
 }
@@ -129,10 +130,17 @@
 ..hidden..@{}}
   \textbf{Item} & \textbf{Number} & \textbf{Description} & \textbf{Qt'y} &
   \textbf{Unit} & \textbf{Price} & \textbf{Disc \%} & \textbf{Amount} \\
-<?lsmb foreach number ?>
-  <?lsmb runningnumber ?> & <?lsmb number ?> & <?lsmb description ?> & <?lsmb qty ?> &
-  <?lsmb unit ?> & <?lsmb sellprice ?> & <?lsmb discountrate ?> & <?lsmb linetotal ?> \\
-<?lsmb end number ?>
+<?lsmb FOREACH number ?>
+<?lsmb lc = loop.count - 1 ?>
+  <?lsmb runningnumber.${lc} ?> &
+  <?lsmb number.${lc} ?> &
+  <?lsmb description.${lc} ?> &
+  <?lsmb qty.${lc} ?> &
+  <?lsmb unit.${lc} ?> &
+  <?lsmb sellprice.${lc} ?> &
+  <?lsmb discountrate.${lc} ?> &
+  <?lsmb linetotal.${lc} ?> \\
+<?lsmb END ?>
 \end{tabularx}
 
 
@@ -144,9 +152,10 @@
 \hfill
 ..hidden..@{}}
   & Subtotal & <?lsmb subtotal ?> \\
-<?lsmb foreach tax ?>
-  & <?lsmb taxdescription ?> on <?lsmb taxbase ?> & <?lsmb tax ?>\\
-<?lsmb end tax ?>
+<?lsmb FOREACH tax ?>
+<?lsmb lc = loop.count - 1 ?>
+  & <?lsmb taxdescription.${lc} ?> on <?lsmb taxbase.${lc} ?> & <?lsmb tax.${lc} ?>\\
+<?lsmb END ?>
   \hline
   & Total & <?lsmb ordtotal ?>\\
 \end{tabularx}
@@ -157,9 +166,9 @@
 \hfill
 All prices in \textbf{<?lsmb currency ?>}.
 
-<?lsmb if terms ?>
+<?lsmb IF terms ?>
 Terms: <?lsmb terms ?> days
-<?lsmb end terms ?>
+<?lsmb END ?>
 
 \vspace{12pt}
 

Modified: trunk/templates/demo/sales_quotation.tex
===================================================================
--- trunk/templates/demo/sales_quotation.tex	2007-05-25 18:08:01 UTC (rev 1240)
+++ trunk/templates/demo/sales_quotation.tex	2007-05-26 23:57:13 UTC (rev 1241)
@@ -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,30 +20,31 @@
   }
 }
 
-<?lsmb include letterhead.tex ?>
+<?lsmb INCLUDE letterhead.tex ?>
 
 
-<?lsmb pagebreak 65 27 48 ?>
-\end{tabularx}
+% Breaking old pagebreak directive
+%<?xlsmb pagebreak 65 27 48 ?>
+%\end{tabularx}
+%
+%  \rule{\textwidth}{2pt}
+%  
+%  \hfill
+%  ..hidden..@{}}
+%  & \textbf{Subtotal} & \textbf{<?xlsmb sumcarriedforward ?>} \\
+%  \end{tabularx}
+%
+%\newpage
+%
+%\markboth{<?xlsmb company ?>\hfill <?xlsmb quonumber ?>}{<?xlsmb company ?>\hfill <?xlsmb quonumber ?>}
+%
..hidden..@{}}
+%  \textbf{Number} & \textbf{Description} & \textbf{Qt'y} &
+%    \textbf{Unit} & \textbf{Price} & \textbf{Disc \%} & \textbf{Amount} \\
+%  & carried forward from <?xlsmb lastpage ?> & & & & & <?xlsmb sumcarriedforward ?> \\
+%<?xlsmb end pagebreak ?>
 
-  \rule{\textwidth}{2pt}
-  
-  \hfill
-  ..hidden..@{}}
-  & \textbf{Subtotal} & \textbf{<?lsmb sumcarriedforward ?>} \\
-  \end{tabularx}
 
-\newpage
-
-\markboth{<?lsmb company ?>\hfill <?lsmb quonumber ?>}{<?lsmb company ?>\hfill <?lsmb quonumber ?>}
-
..hidden..@{}}
-  \textbf{Number} & \textbf{Description} & \textbf{Qt'y} &
-    \textbf{Unit} & \textbf{Price} & \textbf{Disc \%} & \textbf{Amount} \\
-  & carried forward from <?lsmb lastpage ?> & & & & & <?lsmb sumcarriedforward ?> \\
-<?lsmb end pagebreak ?>
-
-
 \vspace*{0.5cm}
 
 \parbox[t]{.5\textwidth}{
@@ -55,27 +56,27 @@
 <?lsmb address2 ?>
 
 <?lsmb city ?>
-<?lsmb if state ?>
+<?lsmb IF state ?>
 \hspace{-0.1cm}, <?lsmb state ?>
-<?lsmb end state ?>
+<?lsmb END ?>
 <?lsmb zipcode ?>
 
 <?lsmb country ?>
 
 \vspace{0.3cm}
 
-<?lsmb if contact ?>
+<?lsmb IF contact ?>
 <?lsmb contact ?>
 \vspace{0.2cm}
-<?lsmb end contact ?>
+<?lsmb END ?>
 
-<?lsmb if customerphone ?>
+<?lsmb IF customerphone ?>
 Tel: <?lsmb customerphone ?>
-<?lsmb end customerphone ?>
+<?lsmb END ?>
 
-<?lsmb if customerfax ?>
+<?lsmb IF customerfax ?>
 Fax: <?lsmb customerfax ?>
-<?lsmb end customerfax ?>
+<?lsmb END ?>
 
 <?lsmb email ?>
 }
@@ -99,10 +100,16 @@
 ..hidden..@{}}
   \textbf{Number} & \textbf{Description} & \textbf{Qt'y} &
     \textbf{Unit} & \textbf{Price} & \textbf{Disc \%} & \textbf{Amount} \\
-<?lsmb foreach number ?>
-  <?lsmb number ?> & <?lsmb description ?> & <?lsmb qty ?> &
-    <?lsmb unit ?> & <?lsmb sellprice ?> & <?lsmb discountrate ?> & <?lsmb linetotal ?> \\
-<?lsmb end number ?>
+<?lsmb FOREACH number ?>
+<?lsmb lc = loop.count - 1 ?>
+  <?lsmb number.${lc} ?> &
+  <?lsmb description.${lc} ?> &
+  <?lsmb qty.${lc} ?> &
+  <?lsmb unit.${lc} ?> &
+  <?lsmb sellprice.${lc} ?> &
+  <?lsmb discountrate.${lc} ?> &
+  <?lsmb linetotal.${lc} ?> \\
+<?lsmb END ?>
 \end{tabularx}
 
 
@@ -114,9 +121,10 @@
 \hfill
 ..hidden..@{}}
   & Subtotal & <?lsmb subtotal ?> \\
-<?lsmb foreach tax ?>
-  & <?lsmb taxdescription ?> on <?lsmb taxbase ?> & <?lsmb tax ?>\\
-<?lsmb end tax ?>
+<?lsmb FOREACH tax ?>
+<?lsmb lc = loop.count - 1 ?>
+  & <?lsmb taxdescription.${lc} ?> on <?lsmb taxbase.${lc} ?> & <?lsmb tax.${lc} ?>\\
+<?lsmb END ?>
   \hline
   & Total & <?lsmb quototal ?>\\
 \end{tabularx}
@@ -126,9 +134,9 @@
 \hfill
 All prices in \textbf{<?lsmb currency ?>}.
 
-<?lsmb if terms ?>
+<?lsmb IF terms ?>
 Terms: <?lsmb terms ?> days
-<?lsmb end terms ?>
+<?lsmb END ?>
 
 \vspace{12pt}
 

Modified: trunk/templates/demo/statement.tex
===================================================================
--- trunk/templates/demo/statement.tex	2007-05-25 18:08:01 UTC (rev 1240)
+++ trunk/templates/demo/statement.tex	2007-05-26 23:57:13 UTC (rev 1241)
@@ -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
 
-<?lsmb include letterhead.tex ?>
+<?lsmb INCLUDE letterhead.tex ?>
 
 \parbox[t]{.5\textwidth}{
 <?lsmb name ?>
@@ -21,21 +21,21 @@
 <?lsmb address2 ?>
 
 <?lsmb city ?>
-<?lsmb if state ?>
+<?lsmb IF state ?>
 \hspace{-0.1cm}, <?lsmb state ?>
-<?lsmb end state ?>
+<?lsmb END ?>
 <?lsmb zipcode ?>
 
 <?lsmb country ?>
 }
 \parbox[t]{.5\textwidth}{
-<?lsmb if customerphone ?>
+<?lsmb IF customerphone ?>
 Tel: <?lsmb customerphone ?>
-<?lsmb end customerphone ?>
+<?lsmb END ?>
 
-<?lsmb if customerfax ?>
+<?lsmb IF customerfax ?>
 Fax: <?lsmb customerfax ?>
-<?lsmb end customerfax ?>
+<?lsmb END ?>
 
 <?lsmb email ?>
 }
@@ -52,10 +52,17 @@
   \textbf{Invoice \#} & \textbf{Order \#} & \textbf{Date} & \textbf{Due} &
   \textbf{Current} & \textbf{30} & \textbf{60} & \textbf{90} \\
   \hline
-<?lsmb foreach invnumber ?>
-  <?lsmb invnumber ?> & <?lsmb ordnumber ?> & <?lsmb invdate ?> & <?lsmb duedate ?> &
-  <?lsmb c0 ?> & <?lsmb c30 ?> & <?lsmb c60 ?> & <?lsmb c90 ?> \\
-<?lsmb end invnumber ?>
+<?lsmb FOREACH invnumber ?>
+<?lsmb lc = loop.count - 1 ?>
+  <?lsmb invnumber.${lc} ?> &
+  <?lsmb ordnumber.${lc} ?> &
+  <?lsmb invdate.${lc} ?> &
+  <?lsmb duedate.${lc} ?> &
+  <?lsmb c0.${lc} ?> &
+  <?lsmb c30.${lc} ?> &
+  <?lsmb c60.${lc} ?> &
+  <?lsmb c90.${lc} ?> \\
+<?lsmb END ?>
   \multicolumn{8}{|l|}{\mbox{}} \\
   \hline
   \textbf{Subtotal} & & & & <?lsmb c0total ?> & <?lsmb c30total ?> & <?lsmb c60total ?> & <?lsmb c90total ?> \\

Modified: trunk/templates/demo/timecard.tex
===================================================================
--- trunk/templates/demo/timecard.tex	2007-05-25 18:08:01 UTC (rev 1240)
+++ trunk/templates/demo/timecard.tex	2007-05-26 23:57:13 UTC (rev 1241)
@@ -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
 
-<?lsmb include letterhead.tex ?>
+<?lsmb INCLUDE letterhead.tex ?>
 
 \centerline{\textbf{T I M E}\hspace{0.5cm}\textbf{C A R D}}
 

Modified: trunk/templates/demo/work_order.tex
===================================================================
--- trunk/templates/demo/work_order.tex	2007-05-25 18:08:01 UTC (rev 1240)
+++ trunk/templates/demo/work_order.tex	2007-05-26 23:57:13 UTC (rev 1241)
@@ -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,22 +11,23 @@
 
 \fontfamily{cmss}\fontsize{10pt}{12pt}\selectfont
 
-<?lsmb include letterhead.tex ?>
+<?lsmb INCLUDE letterhead.tex ?>
 
 
-<?lsmb pagebreak 65 27 48 ?>
-\end{tabularx}
+% Break old pagebreak directive
+%<?xlsmb pagebreak 65 27 48 ?>
+%\end{tabularx}
+%
+%\newpage
+%
+%\markboth{<?xlsmb company ?>\hfill <?xlsmb ordnumber ?>}{<?xlsmb company ?>\hfill <?xlsmb ordnumber ?>}
+%
..hidden..@{}}
+%  \textbf{Item} & \textbf{Number} & \textbf{Description} & \textbf{Qt'y} &
+%  & \textbf{Serial Number} \\
+%<?xlsmb end pagebreak ?>
 
-\newpage
 
-\markboth{<?lsmb company ?>\hfill <?lsmb ordnumber ?>}{<?lsmb company ?>\hfill <?lsmb ordnumber ?>}
-
..hidden..@{}}
-  \textbf{Item} & \textbf{Number} & \textbf{Description} & \textbf{Qt'y} &
-  & \textbf{Serial Number} \\
-<?lsmb end pagebreak ?>
-
-
 \vspace*{0.5cm}
 
 \parbox[t]{.5\textwidth}{
@@ -40,27 +41,27 @@
 <?lsmb address2 ?>
 
 <?lsmb city ?>
-<?lsmb if state ?>
+<?lsmb IF state ?>
 \hspace{-0.1cm}, <?lsmb state ?>
-<?lsmb end state ?>
+<?lsmb END ?>
 <?lsmb zipcode ?>
 
 <?lsmb country ?>
 
 \vspace{0.3cm}
 
-<?lsmb if contact ?>
+<?lsmb IF contact ?>
 <?lsmb contact ?>
 \vspace{0.2cm}
-<?lsmb end contact ?>
+<?lsmb END ?>
 
-<?lsmb if customerphone ?>
+<?lsmb IF customerphone ?>
 Tel: <?lsmb customerphone ?>
-<?lsmb end customerphone ?>
+<?lsmb END ?>
 
-<?lsmb if customerfax ?>
+<?lsmb IF customerfax ?>
 Fax: <?lsmb customerfax ?>
-<?lsmb end customerfax ?>
+<?lsmb END ?>
 
 <?lsmb email ?>
 }
@@ -75,27 +76,27 @@
 <?lsmb shiptoaddress2 ?>
 
 <?lsmb shiptocity ?>
-<?lsmb if shiptostate ?>
+<?lsmb IF shiptostate ?>
 \hspace{-0.1cm}, <?lsmb shiptostate ?>
-<?lsmb end shiptostate ?>
+<?lsmb END ?>
 <?lsmb shiptozipcode ?>
 
 <?lsmb shiptocountry ?>
 
 \vspace{0.3cm}
 
-<?lsmb if shiptocontact ?>
+<?lsmb IF shiptocontact ?>
 <?lsmb shiptocontact ?>
 \vspace{0.2cm}
-<?lsmb end shiptocontact ?>
+<?lsmb END ?>
 
-<?lsmb if shiptophone ?>
+<?lsmb IF shiptophone ?>
 Tel: <?lsmb shiptophone ?>
-<?lsmb end shiptophone ?>
+<?lsmb END ?>
 
-<?lsmb if shiptofax ?>
+<?lsmb IF shiptofax ?>
 Fax: <?lsmb shiptofax ?>
-<?lsmb end shiptofax ?>
+<?lsmb END ?>
 
 <?lsmb shiptoemail ?>
 }
@@ -120,10 +121,15 @@
 ..hidden..@{}}
   \textbf{Item} & \textbf{Number} & \textbf{Description} & \textbf{Qt'y} &
   & \textbf{Serial Number} \\
-<?lsmb foreach number ?>
-  <?lsmb runningnumber ?> & <?lsmb number ?> & <?lsmb description ?> & <?lsmb qty ?> &
-  <?lsmb unit ?> & <?lsmb serialnumber ?> \\
-<?lsmb end number ?>
+<?lsmb FOREACH number ?>
+<?lsmb lc = loop.count - 1 ?>
+  <?lsmb runningnumber.${lc} ?> &
+  <?lsmb number.${lc} ?> &
+  <?lsmb description.${lc} ?> &
+  <?lsmb qty.${lc} ?> &
+  <?lsmb unit.${lc} ?> &
+  <?lsmb serialnumber.${lc} ?> \\
+<?lsmb END ?>
 \end{tabularx}
 
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.