From 2143002750feff4659308ad338334247d30fa75a Mon Sep 17 00:00:00 2001 From: Joshua Ferraro Date: Mon, 24 Dec 2007 14:33:51 -0500 Subject: [PATCH] IMPORTANT: BUGFIXING STATUSES Major bugfixes: * Circulation status in moredetail.pl now correctly displays On loan status and Date due * Bugfixes on Status column in detail.pl * Removed hard-coded English strings from status column in detail.pl * Added missing auth values for lost and damaged statuses, sane defaults if those auth values don't exist * Added missing 'On hold' status and 'Hold waiting' status display Medium bugfixes: * Now correctly shows itemtype at level specified in systempreference * Uses itemtypeimage for display, image title is full itemtype description * Fixed Location column concatenation between branchname location and itemcallnumber * broke out Location (branch), Collection (items.location) Call Number (itemcallnumber) into their own columns * Added auth value display for items.location Minor fixes: * detail.pl didn't show dates correctly * nomenclature s/Checked out/On loan/ in opac-detail.tmpl * s/Book/Item/ in my $desc="Item Returned ".$iteminfo->{'barcode'}; in Circulation.pm * request.tmpl: s/date_due/onloan/ to display date due * Fixed SimilarItems, XISBNSimilarItems NOTE: Needs to be ported to OPAC Signed-off-by: Joshua Ferraro --- C4/Circulation.pm | 2 +- C4/XISBN.pm | 97 ++++---- catalogue/detail.pl | 113 ++++++--- catalogue/moredetail.pl | 4 +- .../prog/en/modules/catalogue/detail.tmpl | 229 ++++++++++-------- .../prog/en/modules/catalogue/moredetail.tmpl | 3 +- .../prog/en/modules/reserve/request.tmpl | 18 +- .../prog/en/modules/opac-detail.tmpl | 2 +- 8 files changed, 276 insertions(+), 192 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 117e0d04ce..6c31ddd5d9 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -1385,7 +1385,7 @@ sub FixAccountForLostAndReturned { if ($amountleft > 0){ $amountleft*=-1; } - my $desc="Book Returned ".$iteminfo->{'barcode'}; + my $desc="Item Returned ".$iteminfo->{'barcode'}; $usth = $dbh->prepare("INSERT INTO accountlines (borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding) VALUES (?,?,now(),?,?,'CR',?)"); diff --git a/C4/XISBN.pm b/C4/XISBN.pm index ab934a1e28..6288f5884d 100644 --- a/C4/XISBN.pm +++ b/C4/XISBN.pm @@ -47,18 +47,18 @@ This module provides facilities for retrieving XISBN, ThingISBN and XISBN conten ); sub get_biblio_from_xisbn { - my $xisbn = shift; - my $dbh = C4::Context->dbh; - my $query = "SELECT biblionumber FROM biblioitems WHERE isbn=?"; - my $sth = $dbh->prepare($query); - $sth->execute($xisbn); - my $xbib_data = $sth->fetchrow_hashref(); - my $xbiblio; - if ($xbib_data->{biblionumber}) { - $xbiblio = GetBiblioData($xbib_data->{biblionumber}); - $xbiblio->{items} = GetItemsByBiblioitemnumber($xbib_data->{biblionumber}); - } - return ($xbiblio); + my $xisbn = shift; + my $dbh = C4::Context->dbh; + my $query = "SELECT biblionumber FROM biblioitems WHERE isbn=?"; + my $sth = $dbh->prepare($query); + $sth->execute($xisbn); + my $xbib_data = $sth->fetchrow_hashref(); + my $xbiblio; + if ($xbib_data->{biblionumber}) { + $xbiblio = GetBiblioData($xbib_data->{biblionumber}); + $xbiblio->{items} = GetItemsByBiblioitemnumber($xbib_data->{biblionumber}); + } + return ($xbiblio); } =head1 get_xisbns($isbn); @@ -69,8 +69,8 @@ sub get_biblio_from_xisbn { sub get_xisbns { my ( $isbn ) = @_; - my ($response,$thing_response,$xisbn_response,$gapines_response); + # THINGISBN if ( C4::Context->preference('ThingISBN') ) { my $url = "http://www.librarything.com/api/thingISBN/".$isbn; @@ -80,54 +80,53 @@ sub get_xisbns { # XISBN if ( C4::Context->preference('XISBN') ) { my $affiliate_id=C4::Context->preference('OCLCAffiliateID'); - my $limit = C4::Context->preference('XISBNDailyLimit') || 499; + my $limit = C4::Context->preference('XISBNDailyLimit') || 499; my $reached_limit = _service_throttle('xisbn',$limit); my $url = "http://xisbn.worldcat.org/webservices/xid/isbn/".$isbn."?method=getEditions&format=xml&fl=form,year,lang,ed"; - $url.="&ai=".$affiliate_id if $affiliate_id; - unless ($reached_limit) { - $xisbn_response = _get_url($url,'xisbn'); - } + $url.="&ai=".$affiliate_id if $affiliate_id; + unless ($reached_limit) { + $xisbn_response = _get_url($url,'xisbn'); + } } - # PINES ISBN - if ( C4::Context->preference('PINESISBN') ) { - my $url = "http://www.librarything.com/api/thingISBN/".$isbn; - $gapines_response = _get_url($url,'thingisbn'); + # PINES ISBN (Experimental) + #if ( C4::Context->preference('PINESISBN') ) { + # my $url = "http://www.librarything.com/api/thingISBN/".$isbn; + # $gapines_response = _get_url($url,'thingisbn'); + #} + $response->{isbn} = [ @{ $xisbn_response->{isbn} or [] }, @{ $thing_response->{isbn} or [] }, @{ $gapines_response->{isbn} or [] } ]; + my @xisbns; + my $unique_xisbns; # a hashref + + # loop through each ISBN and scope to the local collection + for my $response_data( @{ $response->{ isbn } } ) { + next if $unique_xisbns->{ $response_data->{content} }; + $unique_xisbns->{ $response_data->{content} }++; + my $xbiblio= get_biblio_from_xisbn($response_data->{content}); + push @xisbns, $xbiblio if $xbiblio; #response_data->{xbiblio}; #->{biblionumber}; # if $xbiblionumber; } - $response->{isbn} = [ @{ $xisbn_response->{isbn} or [] }, @{ $thing_response->{isbn} or [] }, @{ $gapines_response->{isbn} or [] } ]; - my @xisbns; - my $unique_xisbns; # a hashref - # loop through each ISBN and scope to the local collection - for my $response_data( @{ $response->{ isbn } } ) { - next if $unique_xisbns->{ $response_data->{content} }; - $unique_xisbns->{ $response_data->{content} }++; - my $xbiblio= get_biblio_from_xisbn($response_data->{content}); - push @xisbns, $xbiblio if $xbiblio; #response_data->{xbiblio}; #->{biblionumber}; # if $xbiblionumber; - - } - return \@xisbns; - + return \@xisbns; } sub _get_url { my ($url,$service_type) = @_; - my $ua = LWP::UserAgent->new( - timeout => 2 - ); - - my $response = $ua->get($url); - if ($response->is_success) { - warn "WARNING could not retrieve $service_type $url" unless $response; - if ($response) { - my $xmlsimple = XML::Simple->new(); - my $content = $xmlsimple->XMLin( + my $ua = LWP::UserAgent->new( + timeout => 2 + ); + + my $response = $ua->get($url); + if ($response->is_success) { + warn "WARNING could not retrieve $service_type $url" unless $response; + if ($response) { + my $xmlsimple = XML::Simple->new(); + my $content = $xmlsimple->XMLin( $response->content, ForceArray => [ qw(isbn) ], ForceContent => 1, ); - return $content; - } - } else { + return $content; + } + } else { warn "WARNING: URL Request Failed " . $response->status_line . "\n"; } @@ -137,7 +136,7 @@ sub _get_url { # Throttle services to the specified amount sub _service_throttle { my ($service_type,$daily_limit) = @_; - my $dbh = C4::Context->dbh; + my $dbh = C4::Context->dbh; my $sth = $dbh->prepare("SELECT service_count FROM services_throttle WHERE service_type=?"); $sth->execute($service_type); my $count = 1; diff --git a/catalogue/detail.pl b/catalogue/detail.pl index 2a25379819..3e40f7cb93 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -20,9 +20,14 @@ use strict; require Exporter; use CGI; use C4::Auth; +use C4::Date qw/format_date/; +use C4::Koha; use C4::Serials; #uses getsubscriptionfrom biblionumber use C4::Output; use C4::Biblio; +use C4::Branch; +use C4::Reserves; +use C4::Members; use C4::Serials; use C4::XISBN qw(get_xisbns get_biblio_from_xisbn); use C4::Amazon; @@ -39,13 +44,27 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( ); my $biblionumber = $query->param('biblionumber'); +my $fw = GetFrameworkCode($biblionumber); + +# Get Branches, Itemtypes and Locations +my $branches = GetBranches(); +my $itemtypes = GetItemTypes(); + +my %locations; +# FIXME: move this to a pm, check waiting status for holds +my $dbh = C4::Context->dbh; +my $lsch = $dbh->prepare("SELECT authorised_value,lib FROM authorised_values WHERE category = 'SHELF_LOC'"); +$lsch->execute(); +while (my $ldata = $lsch->fetchrow_hashref ) { + $locations{ $ldata->{'authorised_value'} } = $ldata->{'lib'}; +} # change back when ive fixed request.pl my @items = &GetItemsInfo( $biblionumber, 'intra' ); my $dat = &GetBiblioData($biblionumber); if (!$dat) { - print $query->redirect("/cgi-bin/koha/koha-tmpl/errors/404.pl"); + print $query->redirect("/cgi-bin/koha/koha-tmpl/errors/404.pl"); } #coping with subscriptions @@ -63,15 +82,49 @@ foreach my $subscription (@subscriptions) { GetLatestSerials( $subscription->{subscriptionid}, 3 ); push @subs, \%cell; } - +$dat->{imageurl} = getitemtypeimagesrc() . "/".$itemtypes->{ $dat->{itemtype} }{imageurl}; $dat->{'count'} = @items; - +my @itemloop; my $norequests = 1; -foreach my $itm (@items) { - $norequests = 0 - unless ( ( $itm->{'notforloan'} > 0 ) - || ( $itm->{'itemnotforloan'} > 0 ) ); - $itm->{ $itm->{'publictype'} } = 1; +foreach my $item (@items) { + + # can place holds defaults to yes + $norequests = 0 unless ( ( $item->{'notforloan'} > 0 ) || ( $item->{'itemnotforloan'} > 0 ) ); + + # format some item fields for display + $item->{ $item->{'publictype'} } = 1; + $item->{imageurl} = getitemtypeimagesrc() . "/".$itemtypes->{ $item->{itype} }{imageurl}; + $item->{datedue} = format_date($item->{datedue}); + $item->{datelastseen} = format_date($item->{datelastseen}); + $item->{onloan} = format_date($item->{onloan}); + $item->{locationname} = $locations{$item->{location}}; + # item damaged, lost, withdrawn loops + $item->{itemlostloop}= GetAuthorisedValues(GetAuthValCode('items.itemlost',$fw),$item->{itemlost}) if GetAuthValCode('items.itemlost',$fw); + if ($item->{damaged}) { + $item->{itemdamagedloop}= GetAuthorisedValues(GetAuthValCode('items.damaged',$fw),$item->{damaged}) if GetAuthValCode('items.damaged',$fw); + } + + # checking for holds + my ($reservedate,$reservedfor,$expectedAt) = GetReservesFromItemnumber($item->{itemnumber}); + my $ItemBorrowerReserveInfo = GetMemberDetails( $reservedfor, 0); + + if ( defined $reservedate ) { + $item->{backgroundcolor} = 'reserved'; + $item->{reservedate} = format_date($reservedate); + $item->{ReservedForBorrowernumber} = $reservedfor; + $item->{ReservedForSurname} = $ItemBorrowerReserveInfo->{'surname'}; + $item->{ReservedForFirstname} = $ItemBorrowerReserveInfo->{'firstname'}; + $item->{ExpectedAtLibrary} = $branches->{$expectedAt}{branchname}; + } + + # FIXME: move this to a pm, check waiting status for holds + my $sth2 = $dbh->prepare("SELECT * FROM reserves WHERE borrowernumber=? AND itemnumber=? AND found='W' AND cancellationdate IS NULL"); + $sth2->execute($item->{ReservedForBorrowernumber},$item->{itemnumber}); + while (my $wait_hashref = $sth2->fetchrow_hashref) { + $item->{waitingdate} = format_date($wait_hashref->{waitingdate}); + } + + push @itemloop, $item; } $template->param( norequests => $norequests ); @@ -96,9 +149,9 @@ foreach ( keys %{$dat} ) { } $template->param( - ITEM_RESULTS => \@items, + itemloop => \@itemloop, biblionumber => $biblionumber, - detailview => 1, + detailview => 1, subscriptions => \@subs, subscriptionsnumber => $subscriptionsnumber, subscriptiontitle => $dat->{title}, @@ -109,13 +162,13 @@ my $xisbn=$dat->{'isbn'}; $xisbn =~ s/(p|-| |:)//g; $template->param(amazonisbn => $xisbn); if (C4::Context->preference("FRBRizeEditions")==1) { - eval { - $template->param( - xisbn => $xisbn, - XISBNS => get_xisbns($xisbn) - ); - }; - if ($@) { warn "XISBN Failed $@"; } + eval { + $template->param( + xisbn => $xisbn, + XISBNS => get_xisbns($xisbn) + ); + }; + if ($@) { warn "XISBN Failed $@"; } } if ( C4::Context->preference("AmazonContent") == 1 ) { my $amazon_details = &get_amazon_details( $xisbn ); @@ -129,21 +182,19 @@ if ( C4::Context->preference("AmazonContent") == 1 ) { my @products; my @reviews; for my $details ( @{ $amazon_details->{Details} } ) { + next unless $details->{SimilarProducts}; for my $product ( @{ $details->{SimilarProducts}->{Product} } ) { - if (C4::Context->preference("AmazonSimilarItems") ) { - my $xbiblios; - my @xisbns; - if (C4::Context->preference("XISBNAmazonSimilarItems") ) { - $xbiblios = get_xisbns($product); - } - else { - my $xbiblio = get_biblio_from_xisbn($product); - push @xisbns, $xbiblio ; - $xbiblios = \@xisbns; - } - push @products, +{ product => $xbiblios }; - } + if (C4::Context->preference("AmazonSimilarItems") ) { + my @xisbns; + if (C4::Context->preference("XISBNAmazonSimilarItems") ) { + @xisbns = @{get_xisbns($product)}; + } + else { + push @xisbns, get_biblio_from_xisbn($product); + } + push @products, +{ product => \@xisbns }; + } } next unless $details->{Reviews}; for my $product ( @{ $details->{Reviews}->{AvgCustomerRating} } ) { @@ -156,7 +207,7 @@ if ( C4::Context->preference("AmazonContent") == 1 ) { comment => $reviews->{Comment}, }; } - } use Data::Dumper; warn Dumper(@products); + } $template->param( SIMILAR_PRODUCTS => \@products ); $template->param( AMAZONREVIEWS => \@reviews ); } diff --git a/catalogue/moredetail.pl b/catalogue/moredetail.pl index 4f7a3e8fcd..21bfd5d93e 100755 --- a/catalogue/moredetail.pl +++ b/catalogue/moredetail.pl @@ -91,10 +91,10 @@ foreach my $item (@items){ $item->{'booksellerinvoicenumber'} = $order->{'booksellerinvoicenumber'}; $item->{'homebranchname'} = GetBranchName($item->{'homebranch'}); $item->{'holdingbranchname'} = GetBranchName($item->{'holdingbranch'}); - if ($item->{'date_due'} eq ''){ + if ($item->{'onloan'} eq ''){ $item->{'issue'}= 0; } else { - $item->{'date_due'} = format_date($item->{'date_due'}); + $item->{'onloan'} = format_date($item->{'onloan'}); $item->{'issue'}= 1; } } 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 047b847d7c..788f1d7e3b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tmpl @@ -4,26 +4,26 @@ //= 0) || (this.src.indexOf('g-images.amazon.com') >=0)) { + $("img").each(function(i){ + if ((this.src.indexOf('images.amazon.com') >= 0) || (this.src.indexOf('g-images.amazon.com') >=0)) { w = this.width; h = this.height; if ((w == 1) || (h == 1)) { - $("#bookcoverimg").remove(); - $(".yui-gb").attr("class","yui-g"); + $("#bookcoverimg").remove(); + $(".yui-gb").attr("class","yui-g"); } else if ((this.complete != null) && (!this.complete)) { - $("#bookcoverimg").remove(); - $(".yui-gb").attr("class","yui-g"); + $("#bookcoverimg").remove(); + $(".yui-gb").attr("class","yui-g"); } } - }); - } - $(document).ready(function() { - $('#bibliodetails').tabs(); - }); - $(window).load(function() { - verify_images(); - }); + }); + } + $(document).ready(function() { + $('#bibliodetails').tabs(); + }); + $(window).load(function() { + verify_images(); + }); //]]> @@ -38,37 +38,31 @@ function verify_images() {
-
-
+
+
-
- -

+
+ +

- [ - - - - - - ] : + " alt="" title=""> , - , - / By "> -

-
- + +
+ - -
-
    + +
    +
    • ISBN:
    • @@ -105,9 +99,9 @@ function verify_images() {
    • Subjects:
        -
      • +
      • -
      +
    @@ -127,7 +121,7 @@ function verify_images() { -
+
@@ -138,62 +132,104 @@ function verify_images() {
  • #holdings">Holdings
  • #description">Description
  • #editions">Editions
  • -
  • #related">Related Titles
  • +
  • #related">Related Titles
  • - + + + - + - - - + + + + + + + Unavailable (lost or missing) + + + + + Withdrawn + + + + + + + + + + + Damaged + + + + + Not for loan () + + + + In transit from , + to , since + + + + + WaitingOn hold + + for "> + + atexpected at + + since + + + + + + + Available + + + - - - + + + + +
    Item typeItem type LocationCollectionCall Number Status Date Due Last seen Barcode Volume
    - - Checked out to a borrower from another branch - - Checked out to "> - - - - Not For loan (itemtype) - - - - - - Item lost - - Item Cancelled - - - - - Available - - - - - + " alt="" title=""> + + + + On loan + + On loan to "> , due back on + + + + + + + + - &item=&biblionumber=&bi="> &item=">Fix Itemtype - &item=">Fix Itemtype
    @@ -201,11 +237,11 @@ function verify_images() {

    No physical items for this record

    - +
    - - -

    + + +

    @@ -221,10 +257,10 @@ function verify_images() {
  • .gif" title="" /> "> by ©
  • .01._AA75_PU_PU-5_.jpg" /> - - .gif" title="" /> - barcode: - + + .gif" title="" /> --> + --> +
    @@ -241,14 +277,13 @@ NAME="biblionumber" -->"> by .01._THUMBZZZ_PU_PU-5_.jpg" /> - .gif" -title="" /> - barcode: + .gif" title="" /> --> + --> -
    +
    +
    @@ -257,12 +292,12 @@ title="" /> + " />
    Save Record
    Select Download Format: -
    @@ -286,7 +321,7 @@ title="" /> Date Status Note - + diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tmpl index cd7484c226..b408742b18 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tmpl @@ -63,7 +63,7 @@
    • Current Location:  
    • -
    • Circulation Status: Checked out to ">Not Checked out
    • +
    • Circulation Status: Checked out to ">, Due back on Not Checked out
    • Lost Status:
      " /> @@ -129,7 +129,6 @@
    • Last seen:  
    • Last borrowed:  
    • -
    • Date Due:  
    • Last Borrower: "> 
    • Previous Borrower: "> 
    • Previous Borrower: "> 
    • diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tmpl index 90b12e5200..ba8812e944 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tmpl @@ -240,21 +240,21 @@ if (alreadyreserved > "0"){ - - Due - + + Due + - + Unavailable (lost or missing) - + - + Not for loan () - - + + In transit from , to , since - + diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl index 401cb02b7e..42944833f6 100755 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl @@ -217,7 +217,7 @@ Not for loan - Checked out + On loan -- 2.39.5