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