From b426ecb4f267507fe0286950583e7a45bd795d91 Mon Sep 17 00:00:00 2001 From: Paul POULAIN Date: Sun, 14 Oct 2007 16:20:51 -0500 Subject: [PATCH] BUGfixes in availability management - the availability status was not available on result list. This patch reintroduces that - notforloan as itemtype was not properly managed : an itemtype that was notforloan resulted in nothing in detail. Not, the user can't place a reserve anymore, and the status is correctly displayed the fix is for OPAC as well as staff (owen, pls, validate cat-toolbar.inc & catalogue/detail.tmpl) Signed-off-by: Chris Cormack Signed-off-by: Joshua Ferraro --- C4/Biblio.pm | 2 +- C4/Search.pm | 114 ++++++------------ .../prog/en/includes/cat-toolbar.inc | 3 +- .../prog/en/modules/catalogue/detail.tmpl | 35 +++--- koha-tmpl/opac-tmpl/prog/en/opac-detail.tmpl | 42 ++++--- koha-tmpl/opac-tmpl/prog/en/opac-results.tmpl | 12 +- 6 files changed, 96 insertions(+), 112 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index f99ca5dd94..11df070c40 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -697,7 +697,7 @@ sub GetBiblioData { my $dbh = C4::Context->dbh; my $query = " - SELECT * , biblioitems.notes AS bnotes, biblio.notes + SELECT * , biblioitems.notes AS bnotes, itemtypes.notforloan as bi_notforloan, biblio.notes FROM biblio LEFT JOIN biblioitems ON biblio.biblionumber = biblioitems.biblionumber LEFT JOIN itemtypes ON biblioitems.itemtype = itemtypes.itemtype diff --git a/C4/Search.pm b/C4/Search.pm index 391f6f3c62..3f07e2030e 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -21,6 +21,7 @@ use C4::Context; use C4::Biblio; # GetMarcFromKohaField use C4::Koha; # getFacets use Lingua::Stem; +use C4::Date; use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); @@ -832,13 +833,14 @@ sub searchResults { #find itemtype & itemtype image my %itemtypes; $bsth = - $dbh->prepare("SELECT itemtype,description,imageurl,summary FROM itemtypes"); + $dbh->prepare("SELECT itemtype,description,imageurl,summary,notforloan FROM itemtypes"); $bsth->execute(); while ( my $bdata = $bsth->fetchrow_hashref ) { $itemtypes{ $bdata->{'itemtype'} }->{description} = $bdata->{'description'}; $itemtypes{ $bdata->{'itemtype'} }->{imageurl} = $bdata->{'imageurl'}; $itemtypes{ $bdata->{'itemtype'} }->{summary} = $bdata->{'summary'}; + $itemtypes{ $bdata->{'itemtype'} }->{notforloan} = $bdata->{'notforloan'}; } #search item field code @@ -948,41 +950,58 @@ sub searchResults { my $itemlost_count = 0; my $norequests = 1; + # + # check the loan status of the item : + # it is not stored in the MARC record, for pref (zebra reindexing) + # reason. Thus, we have to get the status from a specific SQL query + # + my $sth_issue = $dbh->prepare(" + SELECT date_due,returndate + FROM issues + WHERE itemnumber=? AND returndate IS NULL"); + foreach my $field (@fields) { my $item; foreach my $code ( keys %subfieldstosearch ) { $item->{$code} = $field->subfield( $subfieldstosearch{$code} ); } + $sth_issue->execute($item->{itemnumber}); + $item->{due_date} = format_date($sth_issue->fetchrow); + $item->{onloan} = 1 if $item->{due_date}; + # at least one item can be reserved : suppose no + $norequests = 1; if ( $item->{wthdrawn} ) { $wthdrawn_count++; } - elsif ( $item->{notforloan} == -1 ) { - $ordered_count++; - $norequests = 0; - } elsif ( $item->{itemlost} ) { $itemlost_count++; } - elsif ( ( $item->{onloan} ) && ( $item->{onloan} != '0000-00-00' ) ) + unless ( $item->{notforloan}) { + # OK, this one can be issued, so at least one can be reserved + $norequests = 0; + } + if ( ( $item->{onloan} ) && ( $item->{onloan} != '0000-00-00' ) ) { + $items->{ $item->{'homebranch'}.'--'.$item->{'itemcallnumber'} }->{onloancount} = 1; + $items->{ $item->{'homebranch'}.'--'.$item->{'itemcallnumber'} }->{due_date} = $item->{due_date}; $onloan_count++; - $norequests = 0; } - else { - $norequests = 0; - if ( $item->{'homebranch'} ) { - $items->{ $item->{'homebranch'}.'--'.$item->{'itemcallnumber'} }->{count}++; - } + if ( $item->{'homebranch'} ) { + $items->{ $item->{'homebranch'}.'--'.$item->{'itemcallnumber'} }->{count}++; + } - # Last resort - elsif ( $item->{'holdingbranch'} ) { - $items->{ $item->{'holdingbranch'} }->{count}++; - } - $items->{ $item->{'homebranch'}.'--'.$item->{'itemcallnumber'} }->{itemcallnumber} = $item->{itemcallnumber}; - $items->{ $item->{'homebranch'}.'--'.$item->{'itemcallnumber'} }->{location} = $item->{location}; - $items->{ $item->{'homebranch'}.'--'.$item->{'itemcallnumber'} }->{branchcode} = $item->{homebranch}; + # Last resort + elsif ( $item->{'holdingbranch'} ) { + $items->{ $item->{'holdingbranch'} }->{count}++; } + $items->{ $item->{'homebranch'}.'--'.$item->{'itemcallnumber'} }->{itemcallnumber} = $item->{itemcallnumber}; + $items->{ $item->{'homebranch'}.'--'.$item->{'itemcallnumber'} }->{location} = $item->{location}; + $items->{ $item->{'homebranch'}.'--'.$item->{'itemcallnumber'} }->{branchcode} = $item->{homebranch}; } # notforloan, item level and biblioitem level + + # last check for norequest : if itemtype is notforloan, it can't be reserved either, whatever the items + $norequests = 1 if $itemtypes{$oldbiblio->{itemtype}}->{notforloan}; + for my $key ( sort keys %$items ) { my $this_item = { branchname => $branches{$items->{$key}->{branchcode}}, @@ -990,6 +1009,8 @@ sub searchResults { count => $items->{$key}->{count}==1 ?"":$items->{$key}->{count}, itemcallnumber => $items->{$key}->{itemcallnumber}, location => $items->{$key}->{location}, + onloancount => $items->{$key}->{onloancount}, + due_date => $items->{$key}->{due_date}, }; push @items_loop, $this_item; } @@ -1000,61 +1021,6 @@ sub searchResults { $oldbiblio->{itemlostcount} = $itemlost_count; $oldbiblio->{orderedcount} = $ordered_count; $oldbiblio->{isbn} =~ s/-//g; # deleting - in isbn to enable amazon content - -# FIXME -# Ugh ... this is ugly, I'll re-write it better above then delete it -# my $norequests = 1; -# my $noitems = 1; -# if (@items) { -# $noitems = 0; -# foreach my $itm (@items) { -# $norequests = 0 unless $itm->{'itemnotforloan'}; -# } -# } -# $oldbiblio->{'noitems'} = $noitems; -# $oldbiblio->{'norequests'} = $norequests; -# $oldbiblio->{'even'} = $even = not $even; -# $oldbiblio->{'itemcount'} = $counts{'total'}; -# my $totalitemcounts = 0; -# foreach my $key (keys %counts){ -# if ($key ne 'total'){ -# $totalitemcounts+= $counts{$key}; -# $oldbiblio->{'locationhash'}->{$key}=$counts{$key}; -# } -# } -# my ($locationtext, $locationtextonly, $notavailabletext) = ('','',''); -# foreach (sort keys %{$oldbiblio->{'locationhash'}}) { -# if ($_ eq 'notavailable') { -# $notavailabletext="Not available"; -# my $c=$oldbiblio->{'locationhash'}->{$_}; -# $oldbiblio->{'not-available-p'}=$c; -# } else { -# $locationtext.="$_"; -# my $c=$oldbiblio->{'locationhash'}->{$_}; -# if ($_ eq 'Item Lost') { -# $oldbiblio->{'lost-p'} = $c; -# } elsif ($_ eq 'Withdrawn') { -# $oldbiblio->{'withdrawn-p'} = $c; -# } elsif ($_ eq 'On Loan') { -# $oldbiblio->{'on-loan-p'} = $c; -# } else { -# $locationtextonly.= $_; -# $locationtextonly.= " ($c)
" if $totalitemcounts > 1; -# } -# if ($totalitemcounts>1) { -# $locationtext.=" ($c)
"; -# } -# } -# } -# if ($notavailabletext) { -# $locationtext.= $notavailabletext; -# } else { -# $locationtext=~s/, $//; -# } -# $oldbiblio->{'location'} = $locationtext; -# $oldbiblio->{'location-only'} = $locationtextonly; -# $oldbiblio->{'use-location-flags-p'} = 1; - push( @newresults, $oldbiblio ); } return @newresults; diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc index d03a5b2564..0e785f4f59 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc @@ -8,5 +8,6 @@
  • )">Delete
  • ','Add_to_virtualshelf','width=500,height=400,toolbar=false,scrollbars=yes'); return false;">Add to shelf
  • ">Print
  • -
  • ">Place Hold
  • + +
  • ">Place Hold
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tmpl index c568a75487..9324069c73 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tmpl @@ -69,14 +69,16 @@ function confirm_deletion(count) { function yuiToolbar(){ YAHOO.toolbar.init = function () { - var oAddbiblio = new YAHOO.widget.Button("addbiblio"); - var oEditbiblio = new YAHOO.widget.Button("editbiblio"); - var oEdititems = new YAHOO.widget.Button("edititems"); - var oDuplicatebiblio = new YAHOO.widget.Button("duplicatebiblio"); - var oDeletebiblio = new YAHOO.widget.Button("deletebiblio"); - var oAddtoshelf = new YAHOO.widget.Button("addtoshelf"); - var oPrintbiblio = new YAHOO.widget.Button("printbiblio"); - var oPlacehold = new YAHOO.widget.Button("placehold"); + var oAddbiblio = new YAHOO.widget.Button("addbiblio"); + var oEditbiblio = new YAHOO.widget.Button("editbiblio"); + var oEdititems = new YAHOO.widget.Button("edititems"); + var oDuplicatebiblio = new YAHOO.widget.Button("duplicatebiblio"); + var oDeletebiblio = new YAHOO.widget.Button("deletebiblio"); + var oAddtoshelf = new YAHOO.widget.Button("addtoshelf"); + var oPrintbiblio = new YAHOO.widget.Button("printbiblio"); + + var oPlacehold = new YAHOO.widget.Button("placehold"); + } (); } @@ -236,16 +238,21 @@ function yuiToolbar(){ On issue to "> - - + + Not For loan (itemtype) - - Item lost + + - Item CancelledAvailable + + Item lost + + Item CancelledAvailable + - + + &item=&biblionumber=&bi="> diff --git a/koha-tmpl/opac-tmpl/prog/en/opac-detail.tmpl b/koha-tmpl/opac-tmpl/prog/en/opac-detail.tmpl index e31277d15b..8497f72ce8 100644 --- a/koha-tmpl/opac-tmpl/prog/en/opac-detail.tmpl +++ b/koha-tmpl/opac-tmpl/prog/en/opac-detail.tmpl @@ -7,11 +7,13 @@