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

SF.net SVN: ledger-smb:[6281] addons/1.3/wxPOS/WXPOS/Template.pm



Revision: 6281
          http://sourceforge.net/p/ledger-smb/code/6281
Author:   einhverfr
Date:     2013-11-11 10:09:06 +0000 (Mon, 11 Nov 2013)
Log Message:
-----------
Changing template system for printing pos invoices

Modified Paths:
--------------
    addons/1.3/wxPOS/WXPOS/Template.pm

Modified: addons/1.3/wxPOS/WXPOS/Template.pm
===================================================================
--- addons/1.3/wxPOS/WXPOS/Template.pm	2013-11-11 09:46:14 UTC (rev 6280)
+++ addons/1.3/wxPOS/WXPOS/Template.pm	2013-11-11 10:09:06 UTC (rev 6281)
@@ -287,16 +287,6 @@
 	#return $format->can('postprocess')->($self);
 	my $post = $format->can('postprocess')->($self);
         #$logger->debug("\$format=$format \$self->{'noauto'}=$self->{'noauto'} \$self->{rendered}=$self->{rendered}");
-	if (!$self->{'noauto'}) {
-		# Clean up
-                $logger->debug("before self output");
-		$self->output(%$vars);
-                $logger->debug("after self output,but does not seem to return here!");
-		if ($self->{rendered}) {
-			unlink($self->{rendered}) or
-				throw Error::Simple 'Unable to delete output file';
-		}
-	}
 	return $post;
 }
 
@@ -310,100 +300,25 @@
     }
 } 
 
-sub output {
+sub print {
 	my $self = shift;
 	my %args = @_;
 
         for ( keys %args ) { $self->{output_args}->{$_} = $args{$_}; };
 
-	my $method = $self->{method} || $args{method} || $args{media};
-        $method = '' if !defined $method;
-	if ('email' eq lc $method) {
-		$self->_email_output;
-        } elsif (defined $args{OUT} and $args{printmode} eq '>'){ # To file
-                cp($self->{rendered}, $args{OUT}); 
-	} elsif ('print' eq lc $method) {
-		$self->_lpr_output;
-	} elsif (defined $self->{output} or lc $method eq 'screen') {
-		$self->_http_output;
-		throw CancelFurtherProcessing();
-	} elsif (defined $method and $method ne '' ) {
-		$self->_lpr_output;
-	} else {
-		$self->_http_output_file;
-	}
-        binmode (STDOUT, ':utf8'); # Reset binmode *after* sending file to
-                                   # email, printer, or screen.  For screen
-                                   # this should have no effect.  For printer
-                                   # or email, this should fix bug 884. --CT 
+	$self->_lpr_output($args->{printer});
 }
 
-sub _http_output {
-	my ($self, $data) = @_;
-	$data ||= $self->{output};
-	if ($self->{format} !~ /^\p{IsAlnum}+$/) {
-		throw Error::Simple "Invalid format";
-	}
-
-	if (!defined $data and defined $self->{rendered}){
-		$data = "";
-                $logger->trace("begin DATA < self->{rendered}=$self->{rendered} \$self->{format}=$self->{format}");
-		open (DATA, '<', $self->{rendered});
-                binmode DATA, $self->{binmode};
-		while (my $line = <DATA>){
-			$data .= $line;
+sub _lpr_output {
+	my ($self, $printer) = @_;
+	my $lpr = $_[0];
+	if (ref $lpr){
+		open (FILE, '<', "$self->{rendered}");
+		while (my $line = <FILE>){
+			$lpr->print($line);
 		}
-                $logger->trace("end DATA < self->{rendered}");
-	        unlink($self->{rendered}) or throw Error::Simple 'Unable to delete output file';
+                $lpr->finalize if $lpr->can('finalize');
 	}
-
-	my $format = "WXPOS::Template::$self->{format}";
-	my $disposition = "";
-	my $name = $format->can('postprocess')->($self) || $self->{rendered};
-	if ($name) {
-		$name =~ s#^.*/##;
-		$disposition .= qq|\nContent-Disposition: attachment; filename="$name"|;
-	}
-        if (!$ENV{LSMB_NOHEAD}){
- 	    if ($self->{mimetype} =~ /^text/) {
-		print "Content-Type: $self->{mimetype}; charset=utf-8$disposition\n\n";
-	    } else {
-		print "Content-Type: $self->{mimetype}$disposition\n\n";
-	    }
-        }
-	binmode STDOUT, $self->{binmode};
-	print $data;
-        $logger->trace("end print to STDOUT");
-}
-
-sub _http_output_file {
-	my $self = shift;
-	my $FH;
-
-	open($FH, '<:bytes', $self->{rendered}) or
-		die 'Unable to open rendered file';
-	my $data;
-	{
-		local $/;
-		$data = <$FH>;
-	}
-	close($FH);
-	
-	$self->_http_output($data);
-	
-	unlink($self->{rendered}) or
-		throw Error::Simple 'Unable to delete output file';
-	throw CancelFurtherProcessing();
-}
-
-sub _lpr_output {
-	my ($self, $in_args) = shift;
-	my $args = $self->{output_args};
-	if ($self->{format} ne 'LaTeX') {
-		throw Error::Simple "Invalid Format";
-	}
-	my $lpr = $WXPOS::Sysconfig::printer{$args->{media}};
-
 	open (LPR, '|-', $lpr);
 
 	# Output is not defined here.  In the future we should consider

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


------------------------------------------------------------------------------
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models. Explore
techniques for threading, error checking, porting, and tuning. Get the most 
from the latest Intel processors and coprocessors. See abstracts and register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
_______________________________________________
Ledger-smb-commits mailing list
..hidden..
https://lists.sourceforge.net/lists/listinfo/ledger-smb-commits