From a483c4fb951975bfbab660716402ff0ab3788a09 Mon Sep 17 00:00:00 2001
From: Owen Leonard <oleonard@myacpl.org>
Date: Mon, 14 Sep 2020 16:56:21 +0000
Subject: [PATCH] Bug 26458: Get item details using only itemnumber

This patch modifies moredetail.pl so that it can accept an itemnumber as
a single parameter.

To test, apply the patch and view a bibliographic record in the
catalog which has one or more items.

 - In the table showing holdings, click the barcode to view the item
   detail page for that item.
 - In the location bar, modify the URL so that it uses only the
   itemnumber parameter, e.g.

   /cgi-bin/koha/catalogue/moredetail.pl?itemnumber=1234

   The page should load correctly, showing information about just that
   item.

Signed-off-by: David Nind <david@davidnind.com>
---
 catalogue/moredetail.pl | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/catalogue/moredetail.pl b/catalogue/moredetail.pl
index 9bf2f58ae2..dd913b122f 100755
--- a/catalogue/moredetail.pl
+++ b/catalogue/moredetail.pl
@@ -72,13 +72,21 @@ if( $query->cookie("searchToOrder") ){
 }
 
 # get variables
+my $biblionumber;
+my $itemnumber;
+if( $query->param('itemnumber') && !$query->param('biblionumber') ){
+    $itemnumber = $query->param('itemnumber');
+    my $item = Koha::Items->find( $itemnumber );
+    $biblionumber = $item->biblionumber;
+} else {
+    $biblionumber = $query->param('biblionumber');
+}
 
-my $biblionumber=$query->param('biblionumber');
 $biblionumber = HTML::Entities::encode($biblionumber);
 my $title=$query->param('title');
 my $bi=$query->param('bi');
 $bi = $biblionumber unless $bi;
-my $itemnumber = $query->param('itemnumber');
+$itemnumber = $query->param('itemnumber');
 my $data = &GetBiblioData($biblionumber);
 my $dewey = $data->{'dewey'};
 my $showallitems = $query->param('showallitems');
-- 
2.11.0