From 816520a4a1d224219175397394eec7930e8f31f1 Mon Sep 17 00:00:00 2001 From: finlayt Date: Thu, 22 Aug 2002 02:31:58 +0000 Subject: [PATCH] Fixed up the display of bibitems, implemented some restrictions on which items can be reserved. --- C4/Search.pm | 56 +++++++++++++++++++++++----------------------------- request.pl | 38 ++++++++++++++++------------------- 2 files changed, 42 insertions(+), 52 deletions(-) diff --git a/C4/Search.pm b/C4/Search.pm index 44e12483af..5d3b263b3f 100755 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -1437,49 +1437,43 @@ sub ItemType { sub bibitems { my ($bibnum) = @_; my $dbh = C4Connect; - my $query = "Select * from biblioitems, itemtypes, items -where biblioitems.biblionumber = '$bibnum' -and biblioitems.itemtype = itemtypes.itemtype -and biblioitems.biblioitemnumber = items.biblioitemnumber -group by items.biblioitemnumber"; + my $query = "SELECT biblioitems.*, itemtypes.*, MIN(items.itemlost) as itemlost + FROM biblioitems, itemtypes, items + WHERE biblioitems.biblionumber = ? + AND biblioitems.itemtype = itemtypes.itemtype + AND biblioitems.biblioitemnumber = items.biblioitemnumber + GROUP BY items.biblioitemnumber"; my $sth = $dbh->prepare($query); my $count = 0; my @results; - - $sth->execute; - + $sth->execute($bibnum); while (my $data = $sth->fetchrow_hashref) { $results[$count] = $data; $count++; - } # while - + } # while $sth->finish; $dbh->disconnect; return($count, @results); } # sub bibitems - sub barcodes{ - #called from request.pl - my ($biblioitemnumber)=@_; - my $dbh=C4Connect; - my $query="Select barcode from items where - biblioitemnumber='$biblioitemnumber' - and ((itemlost <> 1 and itemlost <> 2) or itemlost is NULL) and - (wthdrawn <> 1 or wthdrawn is NULL)"; - - my $sth=$dbh->prepare($query); - $sth->execute; - my @barcodes; - my $i=0; - while (my $data=$sth->fetchrow_hashref){ - $barcodes[$i]=$data->{'barcode'}; - $i++; - } - $sth->finish; - $dbh->disconnect; - return(@barcodes); - + #called from request.pl + my ($biblioitemnumber)=@_; + my $dbh=C4Connect; + my $query="SELECT barcode, itemlost FROM items + WHERE biblioitemnumber = ? + AND (wthdrawn <> 1 OR wthdrawn IS NULL)"; + my $sth=$dbh->prepare($query); + $sth->execute($biblioitemnumber); + my @barcodes; + my $i=0; + while (my $data=$sth->fetchrow_hashref){ + $barcodes[$i]=$data; + $i++; + } + $sth->finish; + $dbh->disconnect; + return(@barcodes); } diff --git a/request.pl b/request.pl index 5542b06d57..e392f75e85 100755 --- a/request.pl +++ b/request.pl @@ -69,24 +69,30 @@ my $date="$mday/$mon/$year"; # get biblioitem information and build rows for form my ($count2,@data) = bibitems($bib); my $bibitemrows = ""; + + for (my $i=0; $i<$count2; $i++) { my @barcodes = barcodes($data[$i]->{'biblioitemnumber'}); - if ($data[$i]->{'dewey'} == 0){ - $data[$i]->{'dewey'}=""; + 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); + + $data[$i]->{'dewey'}="" if ($data[$i]->{'dewey'} == 0); + + warn "Itemlost: $data[$i]->{itemlost} \n"; $data[$i]->{'volumeddesc'} = " " unless $data[$i]->{'volumeddesc'}; $data[$i]->{'dewey'}=~ s/\.0000$//; $data[$i]->{'dewey'}=~ s/00$//; my $class="$data[$i]->{'classification'}$data[$i]->{'dewey'}$data[$i]->{'subclass'}"; my $select; - if ($data[$i]->{'notforloan'}) { - $select = "Reference Item."; - } elsif ($data[$i]->{'itemlost'} == 1) { - $select = "Item Lost"; - } elsif ($data[$i]->{'itemlost'} == 2) { - $select = "Long Overdue"; - } elsif ($data[$i]->{'wthdrawn'}) { - $select = "Item Cancelled"; + if (($data[$i]->{'notforloan'}) + || ($data[$i]->{'itemlost'} == 1) + || ($data[$i]->{'itemlost'} == 2)) { + $select = "Cannot be reserved."; } else { $select = " {'biblioitemnumber'}>{'biblioitemnumber'}>"; } @@ -96,10 +102,8 @@ for (my $i=0; $i<$count2; $i++) { $data[$i]->{'description'} $class $data[$i]->{'volumeddesc'} -$data[$i]->{'isbn'} -$dat->{'copyrightdate'} $data[$i]->{'publicationyear'} -@barcodes +$barcodestext EOF } @@ -138,10 +142,6 @@ foreach my $res (sort {$a->{'found'} cmp $b->{'found'}} @$reserves){ } else { $rank = ""; $pickup = ""; - $change = ""; } $existingreserves .= <<"EOF"; {'borrowernumber'}> @@ -155,7 +155,6 @@ foreach my $res (sort {$a->{'found'} cmp $b->{'found'}} @$reserves){ $date $pickup $type -$change EOF } @@ -253,8 +252,6 @@ $branchoptions Item Type Classification Volume -ISBN -Copyright Pubdate Copies @@ -283,7 +280,6 @@ $bibitemrows Date Pickup Request -Change To $existingreserves -- 2.39.5