Msg is just a message repository - will likely load strings from an
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sat, 2 Sep 2006 16:02:22 +0000 (16:02 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sat, 2 Sep 2006 16:02:22 +0000 (16:02 +0000)
external source at some point

better checkout handling

git-svn-id: svn://svn.open-ils.org/ILS/trunk@5859 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/SIP/Item.pm
Open-ILS/src/perlmods/OpenILS/SIP/Msg.pm [new file with mode: 0644]
Open-ILS/src/perlmods/OpenILS/SIP/Transaction.pm
Open-ILS/src/perlmods/OpenILS/SIP/Transaction/Checkout.pm

index 2c1a4fd..a24a716 100644 (file)
@@ -1,9 +1,3 @@
-#
-#
-# A Class for hiding the ILS's concept of the item from the OpenSIP
-# system
-#
-
 package OpenILS::SIP::Item;
 use strict; use warnings;
 
diff --git a/Open-ILS/src/perlmods/OpenILS/SIP/Msg.pm b/Open-ILS/src/perlmods/OpenILS/SIP/Msg.pm
new file mode 100644 (file)
index 0000000..620a9ba
--- /dev/null
@@ -0,0 +1,31 @@
+package OpenILS::SIP::Msg;
+use strict; use warnings;
+# -------------------------------------------------------
+# Defines the various screen messages
+# Currently they are just constants.. they need to be
+# moved to an external lang-specific source
+# -------------------------------------------------------
+use vars qw(@EXPORT_OK %EXPORT_TAGS);
+use Exporter;
+use base qw/Exporter/;
+
+
+# ---------------------------------------------------------------------
+# Shoves defined constants into the export array
+# so they don't have to be listed twice in the code
+# ---------------------------------------------------------------------
+sub econst {
+   my($name, $value) = @_;
+   my $caller = caller;
+   no strict;
+   *{$name} = sub () { $value };
+   push @{$caller.'::EXPORT_OK'}, $name;
+}
+
+
+econst OILS_SIP_MSG_CIRC_EXISTS => 'This item is already checked out';
+econst OILS_SIP_MSG_CIRC_PERMIT_FAILED => 'Patron is not allowed to check out the selected item';
+
+%EXPORT_TAGS = ( const => [ @EXPORT_OK ] );
+
+
index 84b6101..3d91dd2 100644 (file)
@@ -9,6 +9,7 @@ use strict; use warnings;
 use Sys::Syslog qw(syslog);
 
 use OpenILS::SIP;
+use OpenILS::SIP::Msg qw/:const/;
 
 
 my %fields = (
index 1ae77ca..e2cc1ab 100644 (file)
@@ -11,6 +11,7 @@ use POSIX qw(strftime);
 
 use OpenILS::SIP;
 use OpenILS::SIP::Transaction;
+use OpenILS::SIP::Msg qw/:const/;
 use Sys::Syslog qw(syslog);
 
 use OpenILS::Application::AppUtils;
@@ -64,33 +65,38 @@ sub do_checkout {
                'open-ils.circ.checkout.permit', 
                $self->{authtoken}, $args );
 
-       if( ref($resp) eq 'ARRAY' ) {
-               my @e;
-               push( @e, $_->{textcode} ) for @$resp;
-               syslog('LOG_INFO', "OILS: Checkout permit failed with events: @e");
-               $self->screen_msg('Patron is not allowed to check out the selected item');
-               return 0;
-       }
-
-       if( my $code = $U->event_code($resp) ) {
-               my $txt = $resp->{textcode};
-               syslog('LOG_INFO', "OILS: Checkout permit failed with event $code : $txt");
-               $self->screen_msg('Patron is not allowed to check out the selected item');
-               return 0; 
-       }
+       $resp = [$resp] unless ref $resp eq 'ARRAY';
 
        my $key;
 
-       if( $key = $resp->{payload} ) {
+       if( @$resp == 1 and ! $U->event_code($$resp[0]) ) {
+               $key = $$resp[0]->{payload};
                syslog('LOG_INFO', "OILS: circ permit key => $key");
 
        } else {
-               syslog('LOG_WARN', "OILS: Circ permit failed :\n" . Dumper($resp) );
-               $self->screen_msg('Patron is not allowed to check out the selected item');
+
+               # We got one or more non-success events
+               $self->screen_msg('');
+               for my $r (@$resp) {
+
+                       if( my $code = $U->event_code($resp) ) {
+                               my $txt = $resp->{textcode};
+                               syslog('LOG_INFO', "OILS: Checkout permit failed with event $code : $txt");
+
+                               if( $txt eq 'OPEN_CIRCULATION_EXISTS' ) {
+                                       $self->screen_msg(OILS_SIP_MSG_CIRC_EXISTS);
+                                       return 0;
+                               } else {
+                                       $self->screen_msg(OILS_SIP_MSG_CIRC_PERMIT_FAILED);
+                               }
+                       }
+               }
                return 0;
        }
 
+       # --------------------------------------------------------------------
        # Now do the actual checkout
+       # --------------------------------------------------------------------
 
        $args = { 
                permit_key              => $key,