Continuing on with the work
authorChris Cormack <chrisc@catalyst.net.nz>
Sun, 12 Jan 2014 19:25:20 +0000 (08:25 +1300)
committerChris Cormack <chrisc@catalyst.net.nz>
Sun, 12 Jan 2014 19:25:20 +0000 (08:25 +1300)
lib/NCIP/Handler/CheckInItem.pm
lib/NCIP/ILS/Koha.pm
templates/includes/CheckOutItemResponse.inc [new file with mode: 0644]
templates/problem.tt

index 89581d2..88cd8bc 100644 (file)
@@ -32,11 +32,20 @@ sub handle {
 
         # checkin the item
         my $checkin = $self->ils->checkin( $userid, $itemid );
+        my $output;
         my $vars;
         $vars->{'messagetype'} = 'CheckInItemResponse';
-        $vars->{'elements'}    = \@elements;
-        $vars->{'checkin'}     = $checkin;
-        my $output = $self->render_output( 'response.tt', $vars );
+
+        if ( !$checkin->{success} ) {
+
+            $output = $self->render_output( 'problem.tt', $vars );
+        }
+        else {
+
+            $vars->{'elements'} = \@elements;
+            $vars->{'checkin'}  = $checkin;
+            $output = $self->render_output( 'response.tt', $vars );
+        }
         return $output;
     }
 }
index da1276c..38a4342 100644 (file)
@@ -37,7 +37,9 @@ sub userdata {
 sub checkin {
     my $self    = shift;
     my $barcode = shift;
-    my $result  = AddReturn( $barcode, $branch, $exemptfine, $dropbox );
+    my ($success, $messages, $issue, $borrower)  = AddReturn( $barcode, $branch, $exemptfine, $dropbox );
+    my $result = { success => $success, messages  => $messages, iteminformation => $issue, borrower=> $borrower};
+    return $result;
 }
 
 sub checkout {
diff --git a/templates/includes/CheckOutItemResponse.inc b/templates/includes/CheckOutItemResponse.inc
new file mode 100644 (file)
index 0000000..9659b3f
--- /dev/null
@@ -0,0 +1,3 @@
+<DateDue>[% date_due %]</DateDue>
+<UserOptionalFields>
+</UserOptionalFields>
index a626a74..4da5935 100644 (file)
@@ -1,8 +1,19 @@
 [% INCLUDE 'includes/header.inc' %]
 <NCIPMessage>
-  <Problem>
-    <ProblemDetail>[% error_detail %]</ProblemDetail>
-  </Problem>
-
+  <[% messagetype %]>
+    [% IF processingerror %]
+    <Problem>
+      <ProcessingError>
+        <ProcessingErrorType>
+          <Value>[% processingerrortype %]</Value>
+        </ProcessingErrorType>
+        <ProcessingErrorElement>
+          <ElementName>[% processingerrorelement %]</ElementName>
+          <ProcessingErrorValue>[% processingerrorvalue %]</ProcessingErrorValue>
+        </ProcessingErrorElement>
+      </ProcessingError> 
+      <ProblemDetail>[% error_detail %]</ProblemDetail>
+    </Problem>
+  </[% messagetype %]>
 </NCIPMessage>