]> git.evergreen-ils.org Git - working/NCIPServer.git/blob - lib/NCIP/Handler/CheckInItem.pm
Removing debug statements, making the branch of the item be used if none sent in...
[working/NCIPServer.git] / lib / NCIP / Handler / CheckInItem.pm
1 package NCIP::Handler::CheckInItem;
2
3 =head1
4
5   NCIP::Handler::CheckInItem
6
7 =head1 SYNOPSIS
8
9     Not to be called directly, NCIP::Handler will pick the appropriate Handler 
10     object, given a message type
11
12 =head1 FUNCTIONS
13
14 =cut
15
16 use Modern::Perl;
17
18 use NCIP::Handler;
19
20 our @ISA = qw(NCIP::Handler);
21
22 sub handle {
23     my $self   = shift;
24     my $xmldoc = shift;
25     if ($xmldoc) {
26         my $root   = $xmldoc->documentElement();
27         my $xpc    = $self->xpc();
28         my $itemid = $xpc->findnodes( '//ns:ItemIdentifierValue', $root );
29
30         # checkin the item
31         my $branch = undef;    # where the hell do we get this from???
32         my $checkin = $self->ils->checkin( $itemid, $branch );
33         my $output;
34         my $vars;
35         $vars->{'messagetype'} = 'CheckInItemResponse';
36         $vars->{'barcode'}     = $itemid;
37         my ( $from, $to ) = $self->get_agencies($xmldoc);
38         $vars->{'fromagency'} = $to;
39         $vars->{'toagency'}   = $from;
40
41         if ( !$checkin->{success} ) {
42             $vars->{'processingerror'}        = 1;
43             $vars->{'processingerrortype'}    = $checkin->{'messages'};
44             $vars->{'processingerrorelement'} = 'UniqueItemIdentifier';
45             $output = $self->render_output( 'problem.tt', $vars );
46         }
47         else {
48
49             $vars->{'elements'} = $self->get_user_elements($xmldoc);
50             $vars->{'checkin'}  = $checkin;
51             $output = $self->render_output( 'response.tt', $vars );
52         }
53         return $output;
54     }
55 }
56
57 1;