From: Chris Cormack Date: Sun, 13 Jul 2014 22:45:05 +0000 (+1200) Subject: Starting work on the CancelRequestItem handler X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=975725e2c95e95636eb30fab62229780cf65b312;p=working%2FNCIPServer.git Starting work on the CancelRequestItem handler --- diff --git a/lib/NCIP/Handler/CancelRequestItem.pm b/lib/NCIP/Handler/CancelRequestItem.pm index 2cc984f..8cce605 100644 --- a/lib/NCIP/Handler/CancelRequestItem.pm +++ b/lib/NCIP/Handler/CancelRequestItem.pm @@ -1,8 +1,8 @@ -package NCIP::Handler::LookupUser; +package NCIP::Handler::CancelRequestItem; =head1 - NCIP::Handler::LookupUser + NCIP::Handler::CancelRequestItem =head1 SYNOPSIS @@ -24,21 +24,23 @@ sub handle { my $self = shift; my $xmldoc = shift; if ($xmldoc) { - - # Given our xml document, lets find the itemid - my ($user_id) = - $xmldoc->getElementsByTagNameNS( $self->namespace(), - 'UserIdentifierValue' ); - - my $user = NCIP::User->new( - { userid => $user_id->textContent(), ils => $self->ils } ); - $user->initialise(); - my $vars; - $vars->{'messagetype'} = 'LookupUserResponse'; - $vars->{'user'} = $user; - my $output = $self->render_output('response.tt',$vars); + my $root = $xmldoc->documentElement(); + my $xpc = $self->xpc(); + my $userid = $xpc->findnodes( '//ns:UserIdentifierValue', $root ); + my $requestid = $xpc->findnodes( '//ns:RequestIdentifierValue', $root ); + my ( $error, $messages ) = $self->ils->cancelrequest($requestid); + if ($error) { + $vars->{'processingerror'} = 1; + $vars->{'processingerrortype'} = $messages; + $vars->{'processingerrorelement'} = 'UniqueRequestIdentifier'; + $output = $self->render_output( 'problem.tt', $vars ); + } + else { + my $elements = $self->get_user_elements($xmldoc); + $vars->{'elements'} = $elements; + $output = $self->render_output( 'response.tt', $vars ); + } return $output; - } } diff --git a/templates/problem.tt b/templates/problem.tt index 0898fd4..f51c82f 100644 --- a/templates/problem.tt +++ b/templates/problem.tt @@ -25,6 +25,8 @@ 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 + [% CASE 'ITEMNOTSAMEBRANCH' %] + Circulation rules stop this borrower from checking out this item, the borrower and item are not from the same branch [% END %]