From a61eb3a6ec2fd10c1333479a17ca193dbe3a84ec Mon Sep 17 00:00:00 2001 From: Christopher Brannon Date: Tue, 11 Sep 2018 23:03:48 +0000 Subject: [PATCH] Bug 18355: Modifies location on detail pages. TEST PLAN 1) Make sure ReturnToShelvingCart is set to Move. 2) Check in an item. 3) View the item in detail.pl and opac-detail.pl and see that only the cart location shows. 4) Apply patch and view the item again in check detail and opac-detail.pl. You should now see the permanent location, and the cart location in parenthesis. 5) Try removing descriptions from locations. Codes should replace descriptions when not available. Nothing should show if a value (code is missing. 6) Check another item that was not checked in. You should see the permanent location and not a secondary location. Signed-off-by: Spencer --- catalogue/detail.pl | 63 ++++++++++++++------------- opac/opac-detail.pl | 122 ++++++++++++++++++++++++++-------------------------- 2 files changed, 92 insertions(+), 93 deletions(-) diff --git a/catalogue/detail.pl b/catalogue/detail.pl index fe59fa12cc..a9ec604f75 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -145,8 +145,8 @@ my $hostrecords; # adding items linked via host biblios my @hostitems = GetHostItemsInfo($record); if (@hostitems){ - $hostrecords =1; - push (@items,@hostitems); + $hostrecords =1; + push (@items,@hostitems); } my $dat = &GetBiblioData($biblionumber); @@ -158,7 +158,7 @@ my @subs; foreach my $subscription (@subscriptions) { my %cell; - my $serials_to_display; + my $serials_to_display; $cell{subscriptionid} = $subscription->{subscriptionid}; $cell{subscriptionnotes} = $subscription->{internalnotes}; $cell{missinglist} = $subscription->{missinglist}; @@ -168,9 +168,9 @@ foreach my $subscription (@subscriptions) { $cell{callnumber} = $subscription->{callnumber}; $cell{closed} = $subscription->{closed}; #get the three latest serials. - $serials_to_display = $subscription->{staffdisplaycount}; - $serials_to_display = C4::Context->preference('StaffSerialIssueDisplayCount') unless $serials_to_display; - $cell{staffdisplaycount} = $serials_to_display; + $serials_to_display = $subscription->{staffdisplaycount}; + $serials_to_display = C4::Context->preference('StaffSerialIssueDisplayCount') unless $serials_to_display; + $cell{staffdisplaycount} = $serials_to_display; $cell{latestserials} = GetLatestSerials( $subscription->{subscriptionid}, $serials_to_display ); push @subs, \%cell; @@ -254,9 +254,11 @@ foreach my $item (@items) { #get shelf location and collection code description if they are authorised value. # same thing for copy number my $shelfcode = $item->{'location'}; - $item->{'location'} = $shelflocations->{$shelfcode} if ( defined( $shelfcode ) && defined($shelflocations) && exists( $shelflocations->{$shelfcode} ) ); + my $permshelfcode = $item->{'permanent_location'}; + $item->{'location'} = ( $shelflocations->{$permshelfcode} ne '' ) ? $shelflocations->{$permshelfcode} : ( $permshelfcode ) ? $permshelfcode : undef; + $item->{'location'} .= ( ( $shelflocations->{$shelfcode} ne '' ) && ( $shelfcode ne $permshelfcode ) ) ? ' (' . $shelflocations->{$shelfcode} . ')' : ( ( $shelfcode ) && ( $shelfcode ne $permshelfcode ) ) ? ' (' . $shelfcode . ')' : undef; my $ccode = $item->{'ccode'}; - $item->{'ccode'} = $collections->{$ccode} if ( defined( $ccode ) && defined($collections) && exists( $collections->{$ccode} ) ); + $item->{'ccode'} = $collections->{$ccode} if ( defined( $ccode ) && defined($collections) && exists( $collections->{$ccode} ) ); my $copynumber = $item->{'copynumber'}; $item->{'copynumber'} = $copynumbers->{$copynumber} if ( defined($copynumber) && defined($copynumbers) && exists( $copynumbers->{$copynumber} ) ); foreach (qw(ccode enumchron copynumber stocknumber itemnotes itemnotes_nonpublic uri)) { @@ -280,7 +282,7 @@ foreach my $item (@items) { $item->{CheckedOutFor} = $checkout->patron; } - # Check the transit status + # Check the transit status my ( $transfertwhen, $transfertfrom, $transfertto ) = GetTransfers($item->{itemnumber}); if ( defined( $transfertwhen ) && ( $transfertwhen ne '' ) ) { $item->{transfertwhen} = $transfertwhen; @@ -300,9 +302,8 @@ foreach my $item (@items) { if ($item->{biblionumber} ne $biblionumber){ $item->{hostbiblionumber} = $item->{biblionumber}; - $item->{hosttitle} = GetBiblioData($item->{biblionumber})->{title}; + $item->{hosttitle} = GetBiblioData($item->{biblionumber})->{title}; } - if ( $analyze ) { # count if item is used in analytical bibliorecords @@ -355,27 +356,27 @@ if (scalar(@itemloop) == 0 || scalar(@otheritemloop) == 0) { $template->param( norequests => $norequests ); $template->param( - MARCNOTES => $marcnotesarray, - MARCSUBJCTS => $marcsubjctsarray, - MARCAUTHORS => $marcauthorsarray, - MARCSERIES => $marcseriesarray, - MARCURLS => $marcurlsarray, + MARCNOTES => $marcnotesarray, + MARCSUBJCTS => $marcsubjctsarray, + MARCAUTHORS => $marcauthorsarray, + MARCSERIES => $marcseriesarray, + MARCURLS => $marcurlsarray, MARCISBNS => $marcisbnsarray, - MARCHOSTS => $marchostsarray, - subtitle => $subtitle, - itemdata_ccode => $itemfields{ccode}, - itemdata_enumchron => $itemfields{enumchron}, - itemdata_uri => $itemfields{uri}, - itemdata_copynumber => $itemfields{copynumber}, - itemdata_stocknumber => $itemfields{stocknumber}, - volinfo => $itemfields{enumchron}, - itemdata_itemnotes => $itemfields{itemnotes}, - itemdata_nonpublicnotes => $itemfields{itemnotes_nonpublic}, - z3950_search_params => C4::Search::z3950_search_args($dat), - hostrecords => $hostrecords, - analytics_flag => $analytics_flag, - C4::Search::enabled_staff_search_views, - materials => $materials_flag, + MARCHOSTS => $marchostsarray, + subtitle => $subtitle, + itemdata_ccode => $itemfields{ccode}, + itemdata_enumchron => $itemfields{enumchron}, + itemdata_uri => $itemfields{uri}, + itemdata_copynumber => $itemfields{copynumber}, + itemdata_stocknumber => $itemfields{stocknumber}, + volinfo => $itemfields{enumchron}, + itemdata_itemnotes => $itemfields{itemnotes}, + itemdata_nonpublicnotes => $itemfields{itemnotes_nonpublic}, + z3950_search_params => C4::Search::z3950_search_args($dat), + hostrecords => $hostrecords, + analytics_flag => $analytics_flag, + C4::Search::enabled_staff_search_views, + materials => $materials_flag, ); if (C4::Context->preference("AlternateHoldingsField") && scalar @items == 0) { diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index 6f10c6bde3..8f8ef02dbc 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -62,10 +62,10 @@ use Koha::Ratings; use Koha::Reviews; BEGIN { - if (C4::Context->preference('BakerTaylorEnabled')) { - require C4::External::BakerTaylor; - import C4::External::BakerTaylor qw(&image_url &link_url); - } + if (C4::Context->preference('BakerTaylorEnabled')) { + require C4::External::BakerTaylor; + import C4::External::BakerTaylor qw(&image_url &link_url); + } } my $query = new CGI; @@ -495,10 +495,10 @@ $hideitems = 1 if C4::Context->preference('hidelostitems') or scalar(@hiddenitem # Hide items if ($hideitems) { for my $itm (@all_items) { - if ( C4::Context->preference('hidelostitems') ) { - push @items, $itm unless $itm->{itemlost} or any { $itm->{'itemnumber'} eq $_ } @hiddenitems; - } else { - push @items, $itm unless any { $itm->{'itemnumber'} eq $_ } @hiddenitems; + if ( C4::Context->preference('hidelostitems') ) { + push @items, $itm unless $itm->{itemlost} or any { $itm->{'itemnumber'} eq $_ } @hiddenitems; + } else { + push @items, $itm unless any { $itm->{'itemnumber'} eq $_ } @hiddenitems; } } } else { @@ -585,7 +585,7 @@ foreach my $subscription (@subscriptions) { #get the three latest serials. $serials_to_display = $subscription->{opacdisplaycount}; $serials_to_display = C4::Context->preference('OPACSerialIssueDisplayCount') unless $serials_to_display; - $cell{opacdisplaycount} = $serials_to_display; + $cell{opacdisplaycount} = $serials_to_display; $cell{latestserials} = GetLatestSerials( $subscription->{subscriptionid}, $serials_to_display ); if ( $borrowernumber ) { @@ -598,7 +598,6 @@ foreach my $subscription (@subscriptions) { $dat->{'count'} = scalar(@items); - my (%item_reserves, %priority); my ($show_holds_count, $show_priority); for ( C4::Context->preference("OPACShowHoldQueueDetails") ) { @@ -682,9 +681,10 @@ if ( not $viewallitems and @items > $max_items_to_display ) { $itm->{'ccode'} = $collections->{$ccode} if defined($ccode) && $collections && exists( $collections->{$ccode} ); my $copynumber = $itm->{'copynumber'}; $itm->{'copynumber'} = $copynumbers->{$copynumber} if ( defined($copynumbers) && defined($copynumber) && exists( $copynumbers->{$copynumber} ) ); - if ( defined $itm->{'location'} ) { - $itm->{'location_description'} = $shelflocations->{ $itm->{'location'} }; - } + my $shelfcode = $itm->{'location'}; + my $permshelfcode = $itm->{'permanent_location'}; + $itm->{'location_description'} = ( $shelflocations->{$permshelfcode} ne '' ) ? $shelflocations->{$permshelfcode} : ( $permshelfcode ) ? $permshelfcode : undef; + $itm->{'location_description'} .= ( ( $shelflocations->{$shelfcode} ne '' ) && ( $shelfcode ne $permshelfcode ) ) ? ' (' . $shelflocations->{$shelfcode} . ')' : ( ( $shelfcode ) && ( $shelfcode ne $permshelfcode ) ) ? ' (' . $shelfcode . ')' : undef; if (exists $itm->{itype} && defined($itm->{itype}) && exists $itemtypes->{ $itm->{itype} }) { $itm->{'imageurl'} = getitemtypeimagelocation( 'opac', $itemtypes->{ $itm->{itype} }->{'imageurl'} ); $itm->{'description'} = $itemtypes->{ $itm->{itype} }->{translated_description}; @@ -822,11 +822,11 @@ if ( $isbn or $ean or $oclc or $upc ) { $content_identifier_exists = 1; } $template->param( - normalized_upc => $upc, - normalized_ean => $ean, - normalized_oclc => $oclc, - normalized_isbn => $isbn, - content_identifier_exists => $content_identifier_exists, + normalized_upc => $upc, + normalized_ean => $ean, + normalized_oclc => $oclc, + normalized_isbn => $isbn, + content_identifier_exists => $content_identifier_exists, ); # COinS format FIXME: for books Only @@ -936,13 +936,13 @@ foreach my $sc_field (@sc_fields) { if (scalar(@serialcollections) > 0) { $template->param( - serialcollection => 1, - serialcollections => \@serialcollections); + serialcollection => 1, + serialcollections => \@serialcollections); } # Local cover Images stuff if (C4::Context->preference("OPACLocalCoverImages")){ - $template->param(OPACLocalCoverImages => 1); + $template->param(OPACLocalCoverImages => 1); } # HTML5 Media @@ -955,12 +955,12 @@ my $syndetics_elements; if ( C4::Context->preference("SyndeticsEnabled") ) { $template->param("SyndeticsEnabled" => 1); $template->param("SyndeticsClientCode" => C4::Context->preference("SyndeticsClientCode")); - eval { - $syndetics_elements = &get_syndetics_index($isbn,$upc,$oclc); - for my $element (values %$syndetics_elements) { - $template->param("Syndetics$element"."Exists" => 1 ); - #warn "Exists: "."Syndetics$element"."Exists"; - } + eval { + $syndetics_elements = &get_syndetics_index($isbn,$upc,$oclc); + for my $element (values %$syndetics_elements) { + $template->param("Syndetics$element"."Exists" => 1 ); + #warn "Exists: "."Syndetics$element"."Exists"; + } }; warn $@ if $@; } @@ -968,22 +968,21 @@ if ( C4::Context->preference("SyndeticsEnabled") ) { if ( C4::Context->preference("SyndeticsEnabled") && C4::Context->preference("SyndeticsSummary") && ( exists($syndetics_elements->{'SUMMARY'}) || exists($syndetics_elements->{'AVSUMMARY'}) ) ) { - eval { - my $syndetics_summary = &get_syndetics_summary($isbn,$upc,$oclc, $syndetics_elements); - $template->param( SYNDETICS_SUMMARY => $syndetics_summary ); - }; - warn $@ if $@; - + eval { + my $syndetics_summary = &get_syndetics_summary($isbn,$upc,$oclc, $syndetics_elements); + $template->param( SYNDETICS_SUMMARY => $syndetics_summary ); + }; + warn $@ if $@; } if ( C4::Context->preference("SyndeticsEnabled") && C4::Context->preference("SyndeticsTOC") && exists($syndetics_elements->{'TOC'}) ) { - eval { + eval { my $syndetics_toc = &get_syndetics_toc($isbn,$upc,$oclc); $template->param( SYNDETICS_TOC => $syndetics_toc ); - }; - warn $@ if $@; + }; + warn $@ if $@; } if ( C4::Context->preference("SyndeticsEnabled") @@ -993,7 +992,7 @@ if ( C4::Context->preference("SyndeticsEnabled") my $syndetics_excerpt = &get_syndetics_excerpt($isbn,$upc,$oclc); $template->param( SYNDETICS_EXCERPT => $syndetics_excerpt ); }; - warn $@ if $@; + warn $@ if $@; } if ( C4::Context->preference("SyndeticsEnabled") @@ -1002,12 +1001,12 @@ if ( C4::Context->preference("SyndeticsEnabled") my $syndetics_reviews = &get_syndetics_reviews($isbn,$upc,$oclc,$syndetics_elements); $template->param( SYNDETICS_REVIEWS => $syndetics_reviews ); }; - warn $@ if $@; + warn $@ if $@; } if ( C4::Context->preference("SyndeticsEnabled") && C4::Context->preference("SyndeticsAuthorNotes") - && exists($syndetics_elements->{'ANOTES'}) ) { + && exists($syndetics_elements->{'ANOTES'}) ) { eval { my $syndetics_anotes = &get_syndetics_anotes($isbn,$upc,$oclc); $template->param( SYNDETICS_ANOTES => $syndetics_anotes ); @@ -1076,34 +1075,33 @@ if (C4::Context->preference("OPACShelfBrowser")) { $template->param( AmazonTld => get_amazon_tld() ) if ( C4::Context->preference("OPACAmazonCoverImages")); if (C4::Context->preference("BakerTaylorEnabled")) { - $template->param( - BakerTaylorEnabled => 1, - BakerTaylorImageURL => &image_url(), - BakerTaylorLinkURL => &link_url(), - BakerTaylorBookstoreURL => C4::Context->preference('BakerTaylorBookstoreURL'), - ); - my ($bt_user, $bt_pass); - if ($isbn and - $bt_user = C4::Context->preference('BakerTaylorUsername') and - $bt_pass = C4::Context->preference('BakerTaylorPassword') ) - { - $template->param( - BakerTaylorContentURL => + $template->param( + BakerTaylorEnabled => 1, + BakerTaylorImageURL => &image_url(), + BakerTaylorLinkURL => &link_url(), + BakerTaylorBookstoreURL => C4::Context->preference('BakerTaylorBookstoreURL'), + ); + my ($bt_user, $bt_pass); + if ($isbn and + $bt_user = C4::Context->preference('BakerTaylorUsername') and + $bt_pass = C4::Context->preference('BakerTaylorPassword') ) + { + $template->param( + BakerTaylorContentURL => sprintf("https://contentcafe2.btol.com/ContentCafeClient/ContentCafe.aspx?UserID=%s&Password=%s&ItemKey=%s&Options=Y", - $bt_user,$bt_pass,$isbn) - ); - } + $bt_user,$bt_pass,$isbn) + ); + } } my $tag_quantity; if (C4::Context->preference('TagsEnabled') and $tag_quantity = C4::Context->preference('TagsShowOnDetail')) { - $template->param( - TagsEnabled => 1, - TagsShowOnDetail => $tag_quantity, - TagsInputOnDetail => C4::Context->preference('TagsInputOnDetail') - ); - $template->param(TagLoop => get_tags({biblionumber=>$biblionumber, approved=>1, - 'sort'=>'-weight', limit=>$tag_quantity})); + $template->param( + TagsEnabled => 1, + TagsShowOnDetail => $tag_quantity, + TagsInputOnDetail => C4::Context->preference('TagsInputOnDetail') + ); + $template->param(TagLoop => get_tags({biblionumber=>$biblionumber, approved=>1, 'sort'=>'-weight', limit=>$tag_quantity})); } if (C4::Context->preference("OPACURLOpenInNewWindow")) { -- 2.11.0