| File: | C4/Print.pm |
| Coverage: | 47.2% |
| line | stmt | bran | cond | sub | time | code |
|---|---|---|---|---|---|---|
| 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 | 2 2 2 | 613 7 52 | use strict; | |||
| 21 | #use warnings; FIXME - Bug 2505 | |||||
| 22 | 2 2 2 | 184 8 24 | use C4::Context; | |||
| 23 | ||||||
| 24 | 2 2 2 | 25 16 245 | use vars qw($VERSION @ISA @EXPORT); | |||
| 25 | ||||||
| 26 | BEGIN { | |||||
| 27 | # set the version for version checking | |||||
| 28 | 2 | 19 | $VERSION = 3.01; | |||
| 29 | 2 | 38 | require Exporter; | |||
| 30 | 2 | 62 | @ISA = qw(Exporter); | |||
| 31 | 2 | 365 | @EXPORT = qw(&printslip); | |||
| 32 | } | |||||
| 33 | ||||||
| 34 - 48 | =head1 NAME C4::Print - Koha module dealing with printing =head1 SYNOPSIS use C4::Print; =head1 DESCRIPTION The functions in this module handle sending text to a printer. =head1 FUNCTIONS =cut | |||||
| 49 | ||||||
| 50 - 73 | =for comment
my $slip = <<"EOF";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Date: $todaysdate;
ITEM RESERVED:
$itemdata->{'title'} ($itemdata->{'author'})
barcode: $itemdata->{'barcode'}
COLLECT AT: $branchname
BORROWER:
$bordata->{'surname'}, $bordata->{'firstname'}
card number: $bordata->{'cardnumber'}
Phone: $bordata->{'phone'}
$bordata->{'streetaddress'}
$bordata->{'suburb'}
$bordata->{'town'}
$bordata->{'emailaddress'}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
EOF
=cut | |||||
| 74 | ||||||
| 75 - 81 | =head2 printslip &printslip($slip) print a slip for the given $borrowernumber and $branchcode =cut | |||||
| 82 | ||||||
| 83 | sub printslip ($) { | |||||
| 84 | 0 | my ($slip) = @_; | ||||
| 85 | ||||||
| 86 | 0 | return unless ( C4::Context->boolean_preference('printcirculationslips') ); | ||||
| 87 | ||||||
| 88 | # FIXME - It'd be nifty if this could generate pretty PostScript. | |||||
| 89 | ||||||
| 90 | 0 | my $queue = ''; | ||||
| 91 | ||||||
| 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 | 0 | if ( $queue eq "" || $queue eq 'nulllp' ) { | ||||
| 100 | 0 | return; | ||||
| 101 | #open( PRINTER, ">/tmp/kohaiss" ); | |||||
| 102 | } | |||||
| 103 | else { | |||||
| 104 | ||||||
| 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 | 0 | open( PRINTER, "| lpr -P $queue > /dev/null" ) | ||||
| 110 | or die "Couldn't write to queue:$queue!\n"; | |||||
| 111 | } | |||||
| 112 | ||||||
| 113 | # print $queue; | |||||
| 114 | #open (FILE,">/tmp/$file"); | |||||
| 115 | 0 | print PRINTER $slip; | ||||
| 116 | 0 | print PRINTER "\r\n" x 7 ; | ||||
| 117 | 0 | close PRINTER; | ||||
| 118 | ||||||
| 119 | #system("lpr /tmp/$file"); | |||||
| 120 | } | |||||
| 121 | ||||||
| 122 | 1; | |||||