#!/usr/bin/perl #script to place reserves/requests #writen 2/1/00 by chris@katipo.oc.nz # Copyright 2000-2002 Katipo Communications # # This file is part of Koha. # # Koha is free software; you can redistribute it and/or modify it under the # terms of the GNU General Public License as published by the Free Software # Foundation; either version 2 of the License, or (at your option) any later # version. # # Koha is distributed in the hope that it will be useful, but WITHOUT ANY # 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 use strict; #use DBI; use C4::Search; use C4::Output; use C4::Reserves2; use C4::Acquisitions; use C4::Koha; use C4::Circulation::Circ2; use CGI; my $input = new CGI; # get biblio information.... my $bib = $input->param('bib'); my $dat = bibdata($bib); # get existing reserves ..... my ($count,$reserves) = FindReserves($bib); my $totalcount = $count; foreach my $res (@$reserves) { if ($res->{'found'} eq 'W') { $count--; } } # make priorities options my $num = $count + 1; my $priorityoptions = priorityoptions($num, $num); # get branch information my $branch = $input->cookie('branch'); ($branch) || ($branch = 'L'); my $branches = getbranches(); my $branchoptions = branchoptions($branch); # todays date my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =localtime(time); $year=$year+1900; $mon++; my $date="$mday/$mon/$year"; # get biblioitem information and build rows for form my ($count2,@data) = bibitems($bib); my $bibitemrows = ""; foreach my $dat (sort {$b->{'dateaccessioned'} cmp $a->{'dateaccessioned'}} @data) { my @barcodes = barcodes($dat->{'biblioitemnumber'}); my $barcodestext = ""; foreach my $num (@barcodes) { my $message = $num->{'itemlost'} == 1 ? "(lost)" : $num->{'itemlost'} == 2 ? "(long overdue)" : ""; $barcodestext .= "$num->{'barcode'} $message
"; } $barcodestext = substr($barcodestext, 0, -4); $dat->{'dewey'}="" if ($dat->{'dewey'} == 0); $dat->{'volumeddesc'} = " " unless $dat->{'volumeddesc'}; $dat->{'dewey'}=~ s/\.0000$//; $dat->{'dewey'}=~ s/00$//; my $class="$dat->{'classification'}$dat->{'dewey'}$dat->{'subclass'}"; my $select; if (($dat->{'notforloan'}) || ($dat->{'itemlost'} == 1)) { $select = "Cannot be reserved."; } else { $select = " {'biblioitemnumber'}>{'biblioitemnumber'}>"; } $bibitemrows .= <<"EOF"; $select $dat->{'description'} $class $dat->{'volumeddesc'} $dat->{'publicationyear'} $barcodestext EOF } my $existingreserves = ""; foreach my $res (sort {$a->{'found'} cmp $b->{'found'}} @$reserves){ my $prioropt = priorityoptions($totalcount, $res->{'priority'}); my $bropt = branchoptions($res->{'branchcode'}); my $bor=$res->{'borrowernumber'}; $date = slashifyDate($res->{'reservedate'}); my $type=$res->{'constrainttype'}; if ($type eq 'a'){ $type='Next Available'; } elsif ($type eq 'o'){ $type="This type only $res->{'volumeddesc'} $res->{'itemtype'}"; } my $notes = $res->{'reservenotes'}." "; my $rank; my $pickup; if ($res->{'found'} eq 'W') { my %env; my $item = $res->{'itemnumber'}; $item = getiteminformation(\%env,$item); $item = "{'biblionumber'} &type=intra onClick=\"openWindow(this, 'Item', 480, 640)\">$item->{'barcode'}"; my $wbrcd = $res->{'branchcode'}; my $wbra = $branches->{$wbrcd}->{'branchname'}; $type = $item; $rank = ""; $pickup = "Item waiting at ".$wbra." "; } else { $rank = ""; $pickup = ""; } $existingreserves .= <<"EOF"; {'borrowernumber'}> {'biblionumber'}> $rank $res->{'firstname'} $res->{'surname'} $notes $date $pickup $type EOF } sub priorityoptions { my ($count, $sel) = @_; my $out = ""; for (my $i=1; $i<=$count; $i++){ $out .= "\n"; } return $out; } #get the time for the form name... my $time = time(); # printout the page print $input->header(-expires=>'now'); #setup colours print startmenu('catalogue'); print < Requesting:
$dat->{'title'} ($dat->{'author'})

Rank Member Number Notes Date Pickup Request
$date Next Available,
(or choose from list below)
$bibitemrows
Request Item Type Classification Volume Pubdate Copies

 

$existingreserves
MODIFY EXISTING REQUESTS
Rank Member Notes Date Pickup Request
Delete a request by selecting "del" from the rank list.


printend ; print endmenu(); print endpage();