X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=C4%2FPrint.pm;h=c0b37c8a12f992db66fe525536773d52f94e90d0;hb=53a7fb7ba383e6925198fb1a69bdcabd3b8d858c;hp=cca633b744cdedf965c1812ccc8bcdeb4d408998;hpb=c596d553740ebb6299b133fc6b71ca47ed0ff2e7;p=koha_gimpoz diff --git a/C4/Print.pm b/C4/Print.pm index cca633b744..c0b37c8a12 100644 --- a/C4/Print.pm +++ b/C4/Print.pm @@ -13,25 +13,23 @@ package C4::Print; # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR # A PARTICULAR PURPOSE. See the GNU General Public License for more details. # -# You should have received a copy of the GNU General Public License along with -# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, -# Suite 330, Boston, MA 02111-1307 USA - -# $Id$ +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. use strict; -require Exporter; - +#use warnings; FIXME - Bug 2505 use C4::Context; -use C4::Circulation; use vars qw($VERSION @ISA @EXPORT); -# set the version for version checking -# set the version for version checking -$VERSION = do { my @v = '$Revision$' =~ /\d+/g; - shift(@v) . "." . join( "_", map { sprintf "%03d", $_ } @v ); -}; +BEGIN { + # set the version for version checking + $VERSION = 3.01; + require Exporter; + @ISA = qw(Exporter); + @EXPORT = qw(&printslip); +} =head1 NAME @@ -47,41 +45,49 @@ The functions in this module handle sending text to a printer. =head1 FUNCTIONS -=over 2 - =cut -@ISA = qw(Exporter); -@EXPORT = qw(&remoteprint &printreserve &printslip); +=for comment + my $slip = <<"EOF"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Date: $todaysdate; -=item remoteprint +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'} - &remoteprint($env, $items, $borrower); -Prints the list of items in C<$items> to a printer. +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +EOF +=cut -C<$env> is a reference-to-hash. C<$env-E{queue}> specifies the -queue to print to; if it is empty or has the special value C, -C<&remoteprint> will print to the file F. +=head2 printslip -C<$borrower> is a reference-to-hash giving information about a patron. -This may be gotten from C<&GetMemberDetails>. The patron's name -will be printed in the output. + &printslip($slip) -C<$items> is a reference-to-list, where each element is a -reference-to-hash describing a borrowed item. C<$items> may be gotten -from C<&GetBorrowerIssues>. +print a slip for the given $borrowernumber and $branchcode =cut -#' +sub printslip ($) { + my ($slip) = @_; + + return unless ( C4::Context->boolean_preference('printcirculationslips') ); + # FIXME - It'd be nifty if this could generate pretty PostScript. -sub remoteprint { - my ( $env, $items, $borrower ) = @_; - (return) - unless ( C4::Context->boolean_preference('printcirculationslips') ); - my $queue = $env->{'queue'}; + my $queue = ''; # FIXME - If 'queue' is undefined or empty, then presumably it should # mean "use the default queue", whatever the default is. Presumably @@ -91,7 +97,8 @@ sub remoteprint { # to have spaces in them). Or perhaps if $queue eq "" and # $env->{file} ne "", then that should mean "print to $env->{file}". if ( $queue eq "" || $queue eq 'nulllp' ) { - open( PRINTER, ">/tmp/kohaiss" ); + return; + #open( PRINTER, ">/tmp/kohaiss" ); } else { @@ -105,141 +112,19 @@ sub remoteprint { # print $queue; #open (FILE,">/tmp/$file"); - my $i = 0; - my $brdata = $env->{'brdata'}; # FIXME - Not used - # FIXME - This is HLT-specific. Put this stuff in a customizable - # site-specific file somewhere. - print PRINTER "Horowhenua Library Trust\r\n"; - - # print PRINTER "$brdata->{'branchname'}\r\n"; - print PRINTER "Phone: 368-1953\r\n"; - print PRINTER "Fax: 367-9218\r\n"; - print PRINTER "Email: renewals\@library.org.nz\r\n\r\n\r\n"; - print PRINTER "$borrower->{'cardnumber'}\r\n"; - print PRINTER - "$borrower->{'title'} $borrower->{'initials'} $borrower->{'surname'}\r\n"; - - # FIXME - Use for ($i = 0; $items->[$i]; $i++) - # Or better yet, foreach $item (@{$items}) - while ( $items->[$i] ) { - - # print $i; - my $itemdata = $items->[$i]; - - # FIXME - This is just begging for a Perl format. - print PRINTER "$i $itemdata->{'title'}\r\n"; - print PRINTER "$itemdata->{'barcode'}"; - print PRINTER " " x 15; - print PRINTER "$itemdata->{'date_due'}\r\n"; - $i++; - } - print PRINTER "\r\n\r\n\r\n\r\n\r\n\r\n\r\n"; - if ( $env->{'printtype'} eq "docket" ) { - - #print chr(27).chr(105); - } - close PRINTER; - - #system("lpr /tmp/$file"); -} - -sub printreserve { - my ( $env, $branchname, $bordata, $itemdata ) = @_; - my $file = time; - my $printer = $env->{'printer'}; - (return) unless ( C4::Context->boolean_preference('printreserveslips') ); - if ( $printer eq "" || $printer eq 'nulllp' ) { - open( PRINTER, ">>/tmp/kohares" ); - } - else { - open( PRINTER, "| lpr -P $printer >/dev/null" ) - or die "Couldn't write to queue:$!\n"; - } - my @da = localtime( time() ); - my $todaysdate = "$da[2]:$da[1] $da[3]/$da[4]/$da[5]"; - -#(1900+$datearr[5]).sprintf ("%0.2d", ($datearr[4]+1)).sprintf ("%0.2d", $datearr[3]); - 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 print PRINTER $slip; + print PRINTER "\r\n" x 7 ; close PRINTER; - return $slip; -} - -=item printslip - &printslip($env, $borrowernumber) - - print a slip for the given $borrowernumber - -=cut - -#' -sub printslip { - my ( $env, $borrowernumber ) = @_; - my ( $borrower, $flags ) = GetMemberDetails( $borrowernumber); - $env->{'todaysissues'} = 1; - my ($borrowerissues) = GetBorrowerIssues( $borrower ); - $env->{'nottodaysissues'} = 1; - $env->{'todaysissues'} = 0; - my ($borroweriss2) = GetBorrowerIssues( $borrower ); - $env->{'nottodaysissues'} = 0; - my $i = 0; - my @issues; - - foreach ( sort { $a <=> $b } keys %$borrowerissues ) { - $issues[$i] = $borrowerissues->{$_}; - my $dd = $issues[$i]->{'date_due'}; - - #convert to nz style dates - #this should be set with some kinda config variable - my @tempdate = split( /-/, $dd ); - $issues[$i]->{'date_due'} = "$tempdate[2]/$tempdate[1]/$tempdate[0]"; - $i++; - } - foreach ( sort { $a <=> $b } keys %$borroweriss2 ) { - $issues[$i] = $borroweriss2->{$_}; - my $dd = $issues[$i]->{'date_due'}; - - #convert to nz style dates - #this should be set with some kinda config variable - my @tempdate = split( /-/, $dd ); - $issues[$i]->{'date_due'} = "$tempdate[2]/$tempdate[1]/$tempdate[0]"; - $i++; - } - remoteprint( $env, \@issues, $borrower ); + #system("lpr /tmp/$file"); } -END { } # module clean-up code here (global destructor) - 1; __END__ -=back - =head1 AUTHOR -Koha Developement team +Koha Development Team =head1 SEE ALSO