From 9110e9edef71eb2d09cbb3a3eeb892cb8d313451 Mon Sep 17 00:00:00 2001 From: tipaul Date: Mon, 28 Feb 2005 14:25:19 +0000 Subject: [PATCH] item status (opac & librarian interfaces) The item status has been improved : It now can be : - on order (= item has been ordered, but not yet arrived at the library) - not for loan : if the "notforloan" field is mapped to an authorised value list, the right value is shown. Thus, an item can be "lost" or "being repaired", or whatever you put in the authorised values list. (reminder : the "notforloan" field, when 0 means 'ok, book can be issued', and all other values means 'nok, book can't be issued' (whatever the reason, that can be in the authorised value table) --- C4/Search.pm | 18 +++++++++++++----- C4/SearchMarc.pm | 24 +++++++++++++++++++++++- 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/C4/Search.pm b/C4/Search.pm index a5cdf2e87c..1f1d4b2db8 100755 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -1317,9 +1317,11 @@ sub ItemInfo { my @results; while (my $data=$sth->fetchrow_hashref){ my $datedue = ''; - my $isth=$dbh->prepare("Select * from issues where itemnumber = ? and returndate is null"); + my $isth=$dbh->prepare("Select issues.*,borrowers.cardnumber from issues,borrowers where itemnumber = ? and returndate is null and issues.borrowernumber=borrowers.borrowernumber"); $isth->execute($data->{'itemnumber'}); if (my $idata=$isth->fetchrow_hashref){ + $data->{borrowernumber} = $idata->{borrowernumber}; + $data->{cardnumber} = $idata->{cardnumber}; $datedue = format_date($idata->{'date_due'}); } if ($data->{'itemlost'} eq '2'){ @@ -1345,13 +1347,19 @@ sub ItemInfo { if (my $bdata=$bsth->fetchrow_hashref){ $data->{'branchname'} = $bdata->{'branchname'}; } - # $results[$i]="$data->{'title'}\t$data->{'barcode'}\t$datedue\t$data->{'branchname'}\t$data->{'dewey'}"; - # FIXME - If $data->{'datelastseen'} is NULL, perhaps it'd be prettier - # to leave it empty, rather than convert it to "//". - # Also ideally this should use the local format for displaying dates. my $date=format_date($data->{'datelastseen'}); $data->{'datelastseen'}=$date; $data->{'datedue'}=$datedue; + # get notforloan complete status if applicable + my $sthnflstatus = $dbh->prepare('select authorised_value from marc_subfield_structure where kohafield="items.notforloan"'); + $sthnflstatus->execute; + my ($authorised_valuecode) = $sthnflstatus->fetchrow; + if ($authorised_valuecode) { + $sthnflstatus = $dbh->prepare("select lib from authorised_values where category=? and authorised_value=?"); + $sthnflstatus->execute($authorised_valuecode,$data->{itemnotforloan}); + my ($lib) = $sthnflstatus->fetchrow; + $data->{notforloan} = $lib; + } $results[$i]=$data; $i++; } diff --git a/C4/SearchMarc.pm b/C4/SearchMarc.pm index 0e8b8ce1a9..a42fb0e3c5 100644 --- a/C4/SearchMarc.pm +++ b/C4/SearchMarc.pm @@ -195,7 +195,21 @@ sub catalogsearch { # $_=~ s/\'/ /g; # $_=~ s/\,/ /g; # } - + +# the item.notforloan contains an integer. Every value <>0 means "book unavailable for loan". +# but each library can have it's own table of meaning for each value. Get them +# 1st search if there is a list of authorised values connected to items.notforloan + my $sth = $dbh->prepare('select authorised_value from marc_subfield_structure where kohafield="items.notforloan"'); + $sth->execute; + my %notforloanstatus; + my ($authorised_valuecode) = $sth->fetchrow; + if ($authorised_valuecode) { + $sth = $dbh->prepare("select authorised_value,lib from authorised_values where category=?"); + $sth->execute($authorised_valuecode); + while (my ($authorised_value,$lib) = $sth->fetchrow) { + $notforloanstatus{$authorised_value} = $lib?$lib:$authorised_value; + } + } for(my $i = 0 ; $i <= $#{$value} ; $i++) { # replace * by % @@ -374,6 +388,7 @@ sub catalogsearch { $lineCN{itemcallnumber} = $item->{itemcallnumber}; $lineCN{location} = $item->{location}; $lineCN{date_due} = format_date($date_due); + $lineCN{notforloan} = $notforloanstatus{$item->{notforloan}} if ($item->{notforloan}); $notforloan=0 unless ($item->{notforloan} or $item->{wthdrawn} or $item->{itemlost}); push @CNresults,\%lineCN; $totalitems++; @@ -382,6 +397,13 @@ sub catalogsearch { my %newline; %newline = %$line; $newline{totitem} = $totalitems; + # if $totalitems == 0, check if it's being ordered. + if ($totalitems == 0) { + my $sth = $dbh->prepare("select count(*) from aqorders where biblionumber=?"); + $sth->execute($biblionumber); + my ($ordered) = $sth->fetchrow; + $newline{onorder} = 1 if $ordered; + } $newline{biblionumber} = $biblionumber; $newline{norequests} = 0; $newline{norequests} = 1 if ($line->{notforloan}); # itemtype not issuable