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

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



Revision: 1248
          http://svn.sourceforge.net/ledger-smb/?rev=1248&view=rev
Author:   tetragon
Date:     2007-06-01 07:13:33 -0700 (Fri, 01 Jun 2007)

Log Message:
-----------
Templating updates for output handling

Modified Paths:
--------------
    trunk/LedgerSMB/AM.pm
    trunk/LedgerSMB/Mailer.pm
    trunk/LedgerSMB/Template/PDF.pm
    trunk/LedgerSMB/Template/PS.pm
    trunk/LedgerSMB/Template.pm
    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/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

Modified: trunk/LedgerSMB/AM.pm
===================================================================
--- trunk/LedgerSMB/AM.pm	2007-06-01 01:25:09 UTC (rev 1247)
+++ trunk/LedgerSMB/AM.pm	2007-06-01 14:13:33 UTC (rev 1248)
@@ -1628,7 +1628,7 @@
 qx(PGPASSWORD="$myconfig->{dbpasswd}" pg_dump -U $myconfig->{dbuser} -h $myconfig->{dbhost} -Fc -p $myconfig->{dbport} $myconfig->{dbname});
         close OUT;
         use LedgerSMB::Mailer;
-        $mail = new Mailer;
+        $mail = new LedgerSMB::Mailer;
 
         $mail->{to}   = qq|"$myconfig->{name}" <$myconfig->{email}>|;
         $mail->{from} = qq|"$myconfig->{name}" <$myconfig->{email}>|;

Modified: trunk/LedgerSMB/Mailer.pm
===================================================================
--- trunk/LedgerSMB/Mailer.pm	2007-06-01 01:25:09 UTC (rev 1247)
+++ trunk/LedgerSMB/Mailer.pm	2007-06-01 14:13:33 UTC (rev 1248)
@@ -33,7 +33,7 @@
 #
 #======================================================================
 
-package Mailer;
+package LedgerSMB::Mailer;
 
 use MIME::Lite;
 use MIME::Base64;

Modified: trunk/LedgerSMB/Template/PDF.pm
===================================================================
--- trunk/LedgerSMB/Template/PDF.pm	2007-06-01 01:25:09 UTC (rev 1247)
+++ trunk/LedgerSMB/Template/PDF.pm	2007-06-01 14:13:33 UTC (rev 1248)
@@ -49,7 +49,8 @@
 	my $rawvars = shift;
 	my $vars;
 	my $type = ref $rawvars;
-	return $vars;
+	#XXX Fix escaping
+	return $rawvars;
 }
 
 sub process {

Modified: trunk/LedgerSMB/Template/PS.pm
===================================================================
--- trunk/LedgerSMB/Template/PS.pm	2007-06-01 01:25:09 UTC (rev 1247)
+++ trunk/LedgerSMB/Template/PS.pm	2007-06-01 14:13:33 UTC (rev 1248)
@@ -50,7 +50,8 @@
 	my $rawvars = shift;
 	my $vars;
 	my $type = ref $rawvars;
-	return $vars;
+	#XXX fix escaping
+	return $rawvars;
 }
 
 sub process {

Modified: trunk/LedgerSMB/Template.pm
===================================================================
--- trunk/LedgerSMB/Template.pm	2007-06-01 01:25:09 UTC (rev 1247)
+++ trunk/LedgerSMB/Template.pm	2007-06-01 14:13:33 UTC (rev 1248)
@@ -47,6 +47,7 @@
 
 use Error qw(:try);
 use LedgerSMB::Sysconfig;
+use LedgerSMB::Mailer;
 
 sub new {
 	my $class = shift;
@@ -115,14 +116,13 @@
 
 sub output {
 	my $self = shift;
-	my $method = shift;
+	my %args = @_;
+	my $method = $args{method} || $args{media};
 
-	if ('mail' eq lc $method) {
-		#XXX do something
-		$self->_http_output;
+	if ('email' eq lc $method) {
+		$self->_email_output;
 	} elsif ('print' eq lc $method) {
-		#XXX do something
-		$self->_http_output;
+		$self->_lpr_output;
 	} else {
 		$self->_http_output;
 	}
@@ -148,4 +148,14 @@
 	exit;
 }
 
+sub _email_output {
+	my $self = shift;
+	my $mail = new LedgerSMB::Mailer;
+	#TODO stub
+}
+
+sub _lpr_output {
+	my $self = shift;
+	#TODO stub
+}
 1;

Modified: trunk/bin/arapprn.pl
===================================================================
--- trunk/bin/arapprn.pl	2007-06-01 01:25:09 UTC (rev 1247)
+++ trunk/bin/arapprn.pl	2007-06-01 14:13:33 UTC (rev 1248)
@@ -290,7 +290,7 @@
         format => uc $form->{'format'} );
     try {
         $template->render($form);
-        $template->output($form->{'media'});
+        $template->output(%{$form});
     }
     catch Error::Simple with {
         my $E = shift;
@@ -558,7 +558,7 @@
         format => uc $form->{format} );
     try {
         $template->render($form);
-        $template->output($form->{media});
+        $template->output(%{$form});
     }
     catch Error::Simple with {
         my $E = shift;

Modified: trunk/bin/cp.pl
===================================================================
--- trunk/bin/cp.pl	2007-06-01 01:25:09 UTC (rev 1247)
+++ trunk/bin/cp.pl	2007-06-01 14:13:33 UTC (rev 1248)
@@ -1477,7 +1477,7 @@
       template => $form->{'formname'}, format => uc $form->{format} );
     try {
         $template->render($form);
-        $template->output($form->{media});
+        $template->output(%{$form});
     }
     catch Error::Simple with {
         my $E = shift;

Modified: trunk/bin/io.pl
===================================================================
--- trunk/bin/io.pl	2007-06-01 01:25:09 UTC (rev 1247)
+++ trunk/bin/io.pl	2007-06-01 14:13:33 UTC (rev 1248)
@@ -1771,7 +1771,7 @@
       template => $form->{'formname'}, format => uc $form->{format} );
     try {
         $template->render($form);
-        $template->output($form->{media});
+        $template->output(%{$form});
     }
     catch Error::Simple with {
         my $E = shift;

Modified: trunk/bin/jc.pl
===================================================================
--- trunk/bin/jc.pl	2007-06-01 01:25:09 UTC (rev 1247)
+++ trunk/bin/jc.pl	2007-06-01 14:13:33 UTC (rev 1248)
@@ -2209,7 +2209,7 @@
       template => $form->{'formname'}, format => uc $form->{format} );
     try {
         $template->render($form);
-        $template->output($form->{media});
+        $template->output(%{$form});
     }
     catch Error::Simple with {
         my $E = shift;

Modified: trunk/bin/pos.pl
===================================================================
--- trunk/bin/pos.pl	2007-06-01 01:25:09 UTC (rev 1247)
+++ trunk/bin/pos.pl	2007-06-01 14:13:33 UTC (rev 1248)
@@ -1005,7 +1005,7 @@
         template => $form->{'formname'}, format => uc $form->{format} );
     try {
         $template->render($form);
-        $template->output($form->{media});
+        $template->output(%{$form});
     }
     catch Error::Simple with {
         my $E = shift;

Modified: trunk/bin/rp.pl
===================================================================
--- trunk/bin/rp.pl	2007-06-01 01:25:09 UTC (rev 1247)
+++ trunk/bin/rp.pl	2007-06-01 14:13:33 UTC (rev 1248)
@@ -1084,7 +1084,7 @@
          template => $form->{'formname'}, format => uc $form->{format} );
     try {
         $template->render($form);
-        $template->output($form->{media});
+        $template->output(%{$form});
     }
     catch Error::Simple with {
         my $E = shift;
@@ -1134,7 +1134,7 @@
          template => $form->{'formname'}, format => uc $form->{format} );
     try {
         $template->render($form);
-        $template->output($form->{media});
+        $template->output(%{$form});
     }
     catch Error::Simple with {
         my $E = shift;
@@ -2282,7 +2282,7 @@
 		    format => uc $form->{format} );
                 try {
                     $template->render($form);
-                    $template->output($form->{media});
+                    $template->output(%{$form});
                 }
                 catch Error::Simple with {
                     my $E = shift;

Modified: trunk/t/04-template-handling.t
===================================================================
--- trunk/t/04-template-handling.t	2007-06-01 01:25:09 UTC (rev 1247)
+++ trunk/t/04-template-handling.t	2007-06-01 14:13:33 UTC (rev 1248)
@@ -3,13 +3,14 @@
 use strict;
 use warnings;
 
-$ENV{TMPDIR} = 't/var';
+#$ENV{TMPDIR} = 't/var';
+$ENV{TMPDIR} = '/Users/seneca/sourceforge-svn/ledger-smb/trunk/t/var';
 
 use Test::More 'no_plan';
 use Test::Trap qw(trap $trap);
 use Test::Exception;
 
-use Error qw(:try);
+use Error qw(:try :warndie);
 
 use LedgerSMB::AM;
 use LedgerSMB::Form;
@@ -212,3 +213,40 @@
 	'Template, new: Object creation with non-existent format');
 throws_ok{$template->render({'login' => 'foo'})} qr/Can't locate/,
 	'Template, render: Invalid format caught';
+
+$template = undef;
+$template = new LedgerSMB::Template('user' => $myconfig, 'format' => 'PDF', 
+	'template' => '04-template');
+ok(defined $template, 
+	'Template, new: Object creation with format and template');
+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\&bar'}), 't/var/04-template-output.pdf',
+	'Template, render: Simple PDF template, default filename');
+ok(-e 't/var/04-template-output.pdf', 'Template, render (PDF): File created');
+
+$template = undef;
+$template = new LedgerSMB::Template('user' => $myconfig, 'format' => 'PS', 
+	'template' => '04-template');
+ok(defined $template, 
+	'Template, new: Object creation with format and template');
+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\&bar'}), 't/var/04-template-output.ps',
+	'Template, render: Simple Postscript template, default filename');
+ok(-e 't/var/04-template-output.ps', 'Template, render (PS): 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');
+

Modified: trunk/templates/demo/ap_transaction.tex
===================================================================
--- trunk/templates/demo/ap_transaction.tex	2007-06-01 01:25:09 UTC (rev 1247)
+++ trunk/templates/demo/ap_transaction.tex	2007-06-01 14:13:33 UTC (rev 1248)
@@ -1,3 +1,4 @@
+<?lsmb FILTER latex -?>
 \documentclass{scrartcl}
 \usepackage[utf8]{inputenc}
 \usepackage{tabularx}
@@ -115,4 +116,4 @@
 <?lsmb END ?>
 
 \end{document}
-
+<?lsmb END ?>

Modified: trunk/templates/demo/ar_transaction.tex
===================================================================
--- trunk/templates/demo/ar_transaction.tex	2007-06-01 01:25:09 UTC (rev 1247)
+++ trunk/templates/demo/ar_transaction.tex	2007-06-01 14:13:33 UTC (rev 1248)
@@ -1,3 +1,4 @@
+<?lsmb FILTER latex -?>
 \documentclass{scrartcl}
 \usepackage[utf8]{inputenc}
 \usepackage{tabularx}
@@ -138,4 +139,4 @@
 <?lsmb END ?>
   
 \end{document}
-
+<?lsmb END ?>

Modified: trunk/templates/demo/bin_list.tex
===================================================================
--- trunk/templates/demo/bin_list.tex	2007-06-01 01:25:09 UTC (rev 1247)
+++ trunk/templates/demo/bin_list.tex	2007-06-01 14:13:33 UTC (rev 1248)
@@ -1,3 +1,4 @@
+<?lsmb FILTER latex -?>
 \documentclass{scrartcl}
 \usepackage[utf8]{inputenc}
 \usepackage{tabularx}
@@ -120,4 +121,4 @@
 \rule{\textwidth}{2pt}
 
 \end{document}
-
+<?lsmb END ?>

Modified: trunk/templates/demo/check.tex
===================================================================
--- trunk/templates/demo/check.tex	2007-06-01 01:25:09 UTC (rev 1247)
+++ trunk/templates/demo/check.tex	2007-06-01 14:13:33 UTC (rev 1248)
@@ -1,3 +1,4 @@
+<?lsmb FILTER latex -?>
 \documentclass{scrartcl}
 \usepackage[utf8]{inputenc}
 \usepackage{tabularx}
@@ -75,4 +76,4 @@
 \vfill
 
 \end{document}
-
+<?lsmb END ?>

Modified: trunk/templates/demo/invoice.tex
===================================================================
--- trunk/templates/demo/invoice.tex	2007-06-01 01:25:09 UTC (rev 1247)
+++ trunk/templates/demo/invoice.tex	2007-06-01 14:13:33 UTC (rev 1248)
@@ -1,3 +1,4 @@
+<?lsmb FILTER latex -?>
 \documentclass{scrartcl}
 \usepackage[utf8]{inputenc}
 \usepackage{tabularx}
@@ -215,4 +216,4 @@
 \usebox{\ftr}
 
 \end{document}
-
+<?lsmb END ?>

Modified: trunk/templates/demo/packing_list.tex
===================================================================
--- trunk/templates/demo/packing_list.tex	2007-06-01 01:25:09 UTC (rev 1247)
+++ trunk/templates/demo/packing_list.tex	2007-06-01 14:13:33 UTC (rev 1248)
@@ -1,3 +1,4 @@
+<?lsmb FILTER latex -?>
 \documentclass{scrartcl}
 \usepackage[utf8]{inputenc}
 \usepackage{tabularx}
@@ -140,4 +141,4 @@
 \usebox{\ftr}
 
 \end{document}
-
+<?lsmb END ?>

Modified: trunk/templates/demo/pick_list.tex
===================================================================
--- trunk/templates/demo/pick_list.tex	2007-06-01 01:25:09 UTC (rev 1247)
+++ trunk/templates/demo/pick_list.tex	2007-06-01 14:13:33 UTC (rev 1248)
@@ -1,3 +1,4 @@
+<?lsmb FILTER latex -?>
 \documentclass{scrartcl}
 \usepackage[utf8]{inputenc}
 \usepackage{tabularx}
@@ -109,4 +110,4 @@
 }
 
 \end{document}
-
+<?lsmb END ?>

Modified: trunk/templates/demo/purchase_order.tex
===================================================================
--- trunk/templates/demo/purchase_order.tex	2007-06-01 01:25:09 UTC (rev 1247)
+++ trunk/templates/demo/purchase_order.tex	2007-06-01 14:13:33 UTC (rev 1248)
@@ -1,3 +1,4 @@
+<?lsmb FILTER latex -?>
 \documentclass{scrartcl}
 \usepackage[utf8]{inputenc}
 \usepackage{tabularx}
@@ -174,4 +175,4 @@
 %\footnotetext[1]{\tiny }
 
 \end{document}
-
+<?lsmb END ?>

Modified: trunk/templates/demo/receipt.tex
===================================================================
--- trunk/templates/demo/receipt.tex	2007-06-01 01:25:09 UTC (rev 1247)
+++ trunk/templates/demo/receipt.tex	2007-06-01 14:13:33 UTC (rev 1248)
@@ -1,3 +1,4 @@
+<?lsmb FILTER latex -?>
 \documentclass{scrartcl}
 \usepackage[utf8]{inputenc}
 \usepackage{tabularx}
@@ -75,4 +76,4 @@
 \vfill
 
 \end{document}
-
+<?lsmb END ?>

Modified: trunk/templates/demo/request_quotation.tex
===================================================================
--- trunk/templates/demo/request_quotation.tex	2007-06-01 01:25:09 UTC (rev 1247)
+++ trunk/templates/demo/request_quotation.tex	2007-06-01 14:13:33 UTC (rev 1248)
@@ -1,3 +1,4 @@
+<?lsmb FILTER latex -?>
 \documentclass{scrartcl}
 \usepackage[utf8]{inputenc}
 \usepackage{tabularx}
@@ -153,4 +154,4 @@
 }
 
 \end{document}
-
+<?lsmb END ?>

Modified: trunk/templates/demo/sales_order.tex
===================================================================
--- trunk/templates/demo/sales_order.tex	2007-06-01 01:25:09 UTC (rev 1247)
+++ trunk/templates/demo/sales_order.tex	2007-06-01 14:13:33 UTC (rev 1248)
@@ -1,3 +1,4 @@
+<?lsmb FILTER latex -?>
 \documentclass{scrartcl}
 \usepackage[utf8]{inputenc}
 \usepackage{tabularx}
@@ -183,4 +184,4 @@
 \rule{\textwidth}{0.5pt}
 
 \end{document}
-
+<?lsmb END ?>

Modified: trunk/templates/demo/sales_quotation.tex
===================================================================
--- trunk/templates/demo/sales_quotation.tex	2007-06-01 01:25:09 UTC (rev 1247)
+++ trunk/templates/demo/sales_quotation.tex	2007-06-01 14:13:33 UTC (rev 1248)
@@ -1,3 +1,4 @@
+<?lsmb FILTER latex -?>
 \documentclass{scrartcl}
 \usepackage[utf8]{inputenc}
 \usepackage{tabularx}
@@ -153,4 +154,4 @@
 \usebox{\ftr}
 
 \end{document}
-
+<?lsmb END ?>

Modified: trunk/templates/demo/statement.tex
===================================================================
--- trunk/templates/demo/statement.tex	2007-06-01 01:25:09 UTC (rev 1247)
+++ trunk/templates/demo/statement.tex	2007-06-01 14:13:33 UTC (rev 1248)
@@ -1,3 +1,4 @@
+<?lsmb FILTER latex -?>
 \documentclass{scrartcl}
 \usepackage[utf8]{inputenc}
 \usepackage{tabularx}
@@ -82,4 +83,4 @@
 Please make check payable to \textbf{<?lsmb company ?>}
 
 \end{document}
-
+<?lsmb END ?>

Modified: trunk/templates/demo/timecard.tex
===================================================================
--- trunk/templates/demo/timecard.tex	2007-06-01 01:25:09 UTC (rev 1247)
+++ trunk/templates/demo/timecard.tex	2007-06-01 14:13:33 UTC (rev 1248)
@@ -1,3 +1,4 @@
+<?lsmb FILTER latex -?>
 \documentclass{scrartcl}
 \usepackage[utf8]{inputenc}
 \usepackage{tabularx}
@@ -49,4 +50,4 @@
 <?lsmb notes ?>
  
 \end{document}
-
+<?lsmb END ?>

Modified: trunk/templates/demo/work_order.tex
===================================================================
--- trunk/templates/demo/work_order.tex	2007-06-01 01:25:09 UTC (rev 1247)
+++ trunk/templates/demo/work_order.tex	2007-06-01 14:13:33 UTC (rev 1248)
@@ -1,3 +1,4 @@
+<?lsmb FILTER latex -?>
 \documentclass{scrartcl}
 \usepackage[utf8]{inputenc}
 \usepackage{tabularx}
@@ -144,4 +145,4 @@
 \vfill
 
 \end{document}
-
+<?lsmb END ?>


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