From 0458f625978caa4b6069a563cbdec577c9f5397d Mon Sep 17 00:00:00 2001 From: Chris Cormack Date: Tue, 28 Jan 2014 09:36:45 +1300 Subject: [PATCH] Finishing? the CheckInItem handler --- lib/NCIP.pm | 1 - lib/NCIP/Handler/CheckInItem.pm | 3 ++- lib/NCIP/ILS/Koha.pm | 39 +++++++++++++++++++++------------ templates/problem.tt | 20 ++++++++++------- 4 files changed, 39 insertions(+), 24 deletions(-) diff --git a/lib/NCIP.pm b/lib/NCIP.pm index e8eaf66..8bbdd1a 100644 --- a/lib/NCIP.pm +++ b/lib/NCIP.pm @@ -136,7 +136,6 @@ sub parse_request { my $nodes = $dom->getElementsByTagNameNS( $self->namespace(), 'NCIPMessage' ); if ($nodes) { - warn "got nodes"; my @childnodes = $nodes->[0]->childNodes(); if ( $childnodes[0] ) { return $childnodes[0]->localname(); diff --git a/lib/NCIP/Handler/CheckInItem.pm b/lib/NCIP/Handler/CheckInItem.pm index ab8b255..5a759fd 100644 --- a/lib/NCIP/Handler/CheckInItem.pm +++ b/lib/NCIP/Handler/CheckInItem.pm @@ -29,7 +29,8 @@ sub handle { my @elements = $root->findnodes('CheckInItem/ItemElementType/Value'); # checkin the item - my $checkin = $self->ils->checkin( $itemid ); + my $branch='AS'; # where the hell do we get this from??? + my $checkin = $self->ils->checkin( $itemid,$branch ); my $output; my $vars; $vars->{'messagetype'} = 'CheckInItemResponse'; diff --git a/lib/NCIP/ILS/Koha.pm b/lib/NCIP/ILS/Koha.pm index c6bc05a..cff9fed 100644 --- a/lib/NCIP/ILS/Koha.pm +++ b/lib/NCIP/ILS/Koha.pm @@ -20,9 +20,9 @@ use Modern::Perl; use Object::Tiny qw{ name }; use C4::Members qw{ GetMemberDetails }; -use C4::Circulation qw { AddReturned CanBookBeIssued AddIssue } +use C4::Circulation qw { AddReturn CanBookBeIssued AddIssue }; - sub itemdata { +sub itemdata { my $self = shift; return ( { barcode => '123', title => 'fish' }, undef ); } @@ -37,25 +37,36 @@ sub userdata { sub checkin { my $self = shift; my $barcode = shift; - my ($success, $messages, $issue, $borrower) = AddReturn( $barcode, $branch, $exemptfine, $dropbox ); - my $result = { success => $success, messages => $messages, iteminformation => $issue, borrower=> $borrower}; + my $branch = shift; + my $exemptfine = undef; + my $dropbox = undef; + my ( $success, $messages, $issue, $borrower ) = + AddReturn( $barcode, $branch, $exemptfine, $dropbox ); + my $result = { + success => $success, + messages => $messages, + iteminformation => $issue, + borrower => $borrower + }; return $result; } sub checkout { - my $self = shift; - my $userid = shift; + my $self = shift; + my $userid = shift; my $barcode = shift; - my ($error, $confirm) = CanBookBeIssued ( $userid, $barcode ); - #( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $borrower, - # $barcode, $duedatespec, $inprocess, $ignore_reserves ); - if ($error) { # plus the confirmation? -# Can't issue item, return error hash - return ( 1, $error); + my ( $error, $confirm ) = CanBookBeIssued( $userid, $barcode ); + + #( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $borrower, + # $barcode, $duedatespec, $inprocess, $ignore_reserves ); + if ( $error || $confirm ) { + + # Can't issue item, return error hash + return ( 1, $error || $confirm ); } else { - AddIssue($userid,$barcode); - return ( 0 ); + AddIssue( $userid, $barcode ); + return (0); #successfully issued } } diff --git a/templates/problem.tt b/templates/problem.tt index 6c89a82..18c779d 100644 --- a/templates/problem.tt +++ b/templates/problem.tt @@ -4,16 +4,20 @@ [% IF processingerror %] - - - [% SWITCH processingerrortype %] - [% CASE 'BadBarcode' %] - We could not find an item with that barcode - [% CASE 'NotIssued' %] - The item is not on loan - [% END %] + [% FOREACH errormessage IN processingerrortype.keys %] + + + [% SWITCH errormessage %] + [% CASE 'BadBarcode' %] + We could not find an item with that barcode + [% CASE 'NotIssued' %] + The item is not on loan + [% END %] + + [% END %] + [% END %] [% processingerrorelement %] [% barcode %] -- 2.43.2