From b86c48f8d1b78ca738b1bfebd693c95a69d9d65d Mon Sep 17 00:00:00 2001 From: Chris Cormack Date: Wed, 9 Apr 2014 09:29:45 +1200 Subject: [PATCH] Continuing work on RequestItem handler --- lib/NCIP/Handler/RequestItem.pm | 5 +++-- lib/NCIP/ILS/Koha.pm | 19 +++++++++++++------ templates/problem.tt | 4 ++++ 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/lib/NCIP/Handler/RequestItem.pm b/lib/NCIP/Handler/RequestItem.pm index f7e5ab2..4fe5f3f 100644 --- a/lib/NCIP/Handler/RequestItem.pm +++ b/lib/NCIP/Handler/RequestItem.pm @@ -33,9 +33,10 @@ sub handle { my $itemid = $xpc->findnodes( 'ns:RequestItem/UniqueItemId/ItemIdentifierValue', $root ); - + my $biblionumber = $xpc->findnodes( 'ns://BibliographicRecordIdentifier', + $root ); # request the item - my ( $error, $messages ) = $self->ils->request( $userid, $itemid ); + my ( $error, $messages ) = $self->ils->request( $userid, $itemid, $biblionumber ); my $vars; my $output; my $vars->{'barcode'} = $itemid; diff --git a/lib/NCIP/ILS/Koha.pm b/lib/NCIP/ILS/Koha.pm index 0773d09..38e2ccc 100644 --- a/lib/NCIP/ILS/Koha.pm +++ b/lib/NCIP/ILS/Koha.pm @@ -28,7 +28,7 @@ use C4::Context; use C4::Items qw { GetItem }; use C4::Reserves qw {CanBookBeReserved AddReserve GetReservesFromItemnumber CancelReserve}; -use C4::Biblio qw {AddBiblio GetMarcFromKohaField}; +use C4::Biblio qw {AddBiblio GetMarcFromKohaField GetBiblioData}; use C4::Barcodes::ValueBuilder; use C4::Items qw{AddItem}; @@ -141,16 +141,23 @@ sub renew { } sub request { - my $self = shift; - my $cardnumber = shift; - my $barcode = shift; - my $borrower = GetMemberDetails( undef, $cardnumber ); + my $self = shift; + my $cardnumber = shift; + my $barcode = shift; + my $biblionumber = shift; + my $borrower = GetMemberDetails( undef, $cardnumber ); my $result; unless ($borrower) { $result = { success => 0, messages => { 'BORROWER_NOT_FOUND' => 1 } }; return $result; } - my $itemdata = GetItem( undef, $barcode ); + my $itemdata; + if ($barcode) { + $itemdata = GetItem( undef, $barcode ); + } + else { + $itemdata = GetBiblioData($biblionumber); + } unless ($itemdata) { $result = { success => 0, messages => {'ITEM_NOT_FOUND'} }; return $result; diff --git a/templates/problem.tt b/templates/problem.tt index 6127e51..0898fd4 100644 --- a/templates/problem.tt +++ b/templates/problem.tt @@ -21,6 +21,10 @@ We can not place a hold, we have no borrower information [% CASE 'Wrongbranch' %] We are trying to check this item in at the wrong branch + [% CASE 'BORROWER_NOT_FOUND' %] + We can not place a request, we have no borrower information + [% CASE 'ITEM_NOT_FOUND' %] + We can not place a request, we have no item information [% END %] -- 2.43.2