Bug 7821 - {langcode} will be replaced with current interface language
[koha.git] / C4 / Print.pm
blobc0b37c8a12f992db66fe525536773d52f94e90d0
1 package C4::Print;
3 # Copyright 2000-2002 Katipo Communications
5 # This file is part of Koha.
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.
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.
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.
20 use strict;
21 #use warnings; FIXME - Bug 2505
22 use C4::Context;
24 use vars qw($VERSION @ISA @EXPORT);
26 BEGIN {
27 # set the version for version checking
28 $VERSION = 3.01;
29 require Exporter;
30 @ISA = qw(Exporter);
31 @EXPORT = qw(&printslip);
34 =head1 NAME
36 C4::Print - Koha module dealing with printing
38 =head1 SYNOPSIS
40 use C4::Print;
42 =head1 DESCRIPTION
44 The functions in this module handle sending text to a printer.
46 =head1 FUNCTIONS
48 =cut
50 =for comment
51 my $slip = <<"EOF";
52 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
53 Date: $todaysdate;
55 ITEM RESERVED:
56 $itemdata->{'title'} ($itemdata->{'author'})
57 barcode: $itemdata->{'barcode'}
59 COLLECT AT: $branchname
61 BORROWER:
62 $bordata->{'surname'}, $bordata->{'firstname'}
63 card number: $bordata->{'cardnumber'}
64 Phone: $bordata->{'phone'}
65 $bordata->{'streetaddress'}
66 $bordata->{'suburb'}
67 $bordata->{'town'}
68 $bordata->{'emailaddress'}
71 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
72 EOF
73 =cut
75 =head2 printslip
77 &printslip($slip)
79 print a slip for the given $borrowernumber and $branchcode
81 =cut
83 sub printslip ($) {
84 my ($slip) = @_;
86 return unless ( C4::Context->boolean_preference('printcirculationslips') );
88 # FIXME - It'd be nifty if this could generate pretty PostScript.
90 my $queue = '';
92 # FIXME - If 'queue' is undefined or empty, then presumably it should
93 # mean "use the default queue", whatever the default is. Presumably
94 # the default depends on the physical location of the machine.
95 # FIXME - Perhaps "print to file" should be a supported option. Just
96 # set the queue to "file" (or " file", if real queues aren't allowed
97 # to have spaces in them). Or perhaps if $queue eq "" and
98 # $env->{file} ne "", then that should mean "print to $env->{file}".
99 if ( $queue eq "" || $queue eq 'nulllp' ) {
100 return;
101 #open( PRINTER, ">/tmp/kohaiss" );
103 else {
105 # FIXME - This assumes that 'lpr' exists, and works as expected.
106 # This is a reasonable assumption, but only because every other
107 # printing package has a wrapper script called 'lpr'. It'd still
108 # be better to be able to customize this.
109 open( PRINTER, "| lpr -P $queue > /dev/null" )
110 or die "Couldn't write to queue:$queue!\n";
113 # print $queue;
114 #open (FILE,">/tmp/$file");
115 print PRINTER $slip;
116 print PRINTER "\r\n" x 7 ;
117 close PRINTER;
119 #system("lpr /tmp/$file");
123 __END__
125 =head1 AUTHOR
127 Koha Development Team <http://koha-community.org/>
129 =head1 SEE ALSO
131 C4::Circulation::Circ2(3)
133 =cut