Merge remote-tracking branch 'origin/new/bug_8233'
[koha.git] / C4 / Print.pm
1 package C4::Print;
2
3 # Copyright 2000-2002 Katipo Communications
4 #
5 # This file is part of Koha.
6 #
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
10 # version.
11 #
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License along
17 # with Koha; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20 use strict;
21 #use warnings; FIXME - Bug 2505
22 use C4::Context;
23
24 use vars qw($VERSION @ISA @EXPORT);
25
26 BEGIN {
27         # set the version for version checking
28     $VERSION = 3.07.00.049;
29         require Exporter;
30         @ISA    = qw(Exporter);
31     @EXPORT = qw(&NetworkPrint);
32 }
33
34 =head1 NAME
35
36 C4::Print - Koha module dealing with printing
37
38 =head1 SYNOPSIS
39
40   use C4::Print;
41
42 =head1 DESCRIPTION
43
44 The functions in this module handle sending text to a printer.
45
46 =head1 FUNCTIONS
47
48 =head2 NetworkPrint
49
50   &NetworkPrint($text)
51
52 Queue some text for printing on the selected branch printer
53
54 =cut
55
56 sub NetworkPrint {
57     my ($text) = @_;
58
59 # FIXME - It'd be nifty if this could generate pretty PostScript.
60
61     my $queue = '';
62
63     # FIXME - If 'queue' is undefined or empty, then presumably it should
64     # mean "use the default queue", whatever the default is. Presumably
65     # the default depends on the physical location of the machine.
66     # FIXME - Perhaps "print to file" should be a supported option. Just
67     # set the queue to "file" (or " file", if real queues aren't allowed
68     # to have spaces in them). Or perhaps if $queue eq "" and
69     # $env->{file} ne "", then that should mean "print to $env->{file}".
70
71     my $fh;
72     if ( $queue eq "" || $queue eq 'nulllp' ) {
73         return;
74         #open( $fh, ">/tmp/kohaiss" );
75     }
76     else {
77
78         # FIXME - This assumes that 'lpr' exists, and works as expected.
79         # This is a reasonable assumption, but only because every other
80         # printing package has a wrapper script called 'lpr'. It'd still
81         # be better to be able to customize this.
82         open( $fh, "-|", "lpr -P $queue > /dev/null" )
83           or die "Couldn't write to queue:$queue!\n";
84     }
85
86     #  print $queue;
87     #open (FILE,">/tmp/$file");
88     print $fh $text;
89     print $fh "\r\n" x 7 ;
90     close $fh;
91
92     #system("lpr /tmp/$file");
93 }
94
95 1;
96 __END__
97
98 =head1 AUTHOR
99
100 Koha Development Team <http://koha-community.org/>
101
102 =head1 SEE ALSO
103
104 C4::Circulation::Circ2(3)
105
106 =cut