[open-ils-commits] r15372 - in branches/rel_1_6/Open-ILS/src/perlmods/OpenILS: . SIP/Transaction (dbs)
svn at svn.open-ils.org
svn at svn.open-ils.org
Fri Jan 22 19:45:39 EST 2010
Author: dbs
Date: 2010-01-22 19:45:39 -0500 (Fri, 22 Jan 2010)
New Revision: 15372
Modified:
branches/rel_1_6/Open-ILS/src/perlmods/OpenILS/SIP.pm
branches/rel_1_6/Open-ILS/src/perlmods/OpenILS/SIP/Transaction/Checkout.pm
Log:
Backport r15371 from trunk: Add the ability to renew via SIP 1 method used by 3M self-checks
Modified: branches/rel_1_6/Open-ILS/src/perlmods/OpenILS/SIP/Transaction/Checkout.pm
===================================================================
--- branches/rel_1_6/Open-ILS/src/perlmods/OpenILS/SIP/Transaction/Checkout.pm 2010-01-23 00:44:06 UTC (rev 15371)
+++ branches/rel_1_6/Open-ILS/src/perlmods/OpenILS/SIP/Transaction/Checkout.pm 2010-01-23 00:45:39 UTC (rev 15372)
@@ -51,7 +51,7 @@
# XXX Set $self->ok(0) on any errors
sub do_checkout {
my $self = shift;
- syslog('LOG_DEBUG', "OILS: performing checkout...");
+ my $is_renew = shift || 0;
$self->ok(0);
@@ -60,59 +60,67 @@
patron_barcode => $self->{patron}->id
};
- my $resp = $U->simplereq(
- 'open-ils.circ',
- 'open-ils.circ.checkout.permit',
- $self->{authtoken}, $args );
+ my $resp;
- $resp = [$resp] unless ref $resp eq 'ARRAY';
+ if ($is_renew) {
+ $resp = $U->simplereq(
+ 'open-ils.circ',
+ 'open-ils.circ.renew', $self->{authtoken},
+ { barcode => $self->item->id, patron_barcode => $self->patron->id });
+ } else {
+ $resp = $U->simplereq(
+ 'open-ils.circ',
+ 'open-ils.circ.checkout.permit',
+ $self->{authtoken}, $args );
- my $key;
+ $resp = [$resp] unless ref $resp eq 'ARRAY';
- syslog('LOG_DEBUG', "OILS: Checkout permit returned event: " . OpenSRF::Utils::JSON->perl2JSON($resp));
+ my $key;
- if( @$resp == 1 and ! $U->event_code($$resp[0]) ) {
- $key = $$resp[0]->{payload};
- syslog('LOG_INFO', "OILS: circ permit key => $key");
+ syslog('LOG_DEBUG', "OILS: Checkout permit returned event: " . OpenSRF::Utils::JSON->perl2JSON($resp));
- } else {
+ if( @$resp == 1 and ! $U->event_code($$resp[0]) ) {
+ $key = $$resp[0]->{payload};
+ syslog('LOG_INFO', "OILS: circ permit key => $key");
- # We got one or more non-success events
- $self->screen_msg('');
- for my $r (@$resp) {
+ } else {
- if( my $code = $U->event_code($resp) ) {
- my $txt = $resp->{textcode};
- syslog('LOG_INFO', "OILS: Checkout permit failed with event $code : $txt");
+ # We got one or more non-success events
+ $self->screen_msg('');
+ for my $r (@$resp) {
- 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);
+ 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;
}
- return 0;
- }
- # --------------------------------------------------------------------
- # Now do the actual checkout
- # --------------------------------------------------------------------
+ # --------------------------------------------------------------------
+ # Now do the actual checkout
+ # --------------------------------------------------------------------
- $args = {
- permit_key => $key,
- patron_barcode => $self->{patron}->id,
- barcode => $self->{item}->id
- };
+ $args = {
+ permit_key => $key,
+ patron_barcode => $self->{patron}->id,
+ barcode => $self->{item}->id
+ };
- $resp = $U->simplereq(
- 'open-ils.circ',
- 'open-ils.circ.checkout', $self->{authtoken}, $args );
+ $resp = $U->simplereq(
+ 'open-ils.circ',
+ 'open-ils.circ.checkout', $self->{authtoken}, $args );
+ }
+ syslog('LOG_INFO', "OILS: Checkout returned event: " . OpenSRF::Utils::JSON->perl2JSON($resp));
- syslog('LOG_DEBUG', "OILS: Checkout returned event: " . OpenSRF::Utils::JSON->perl2JSON($resp));
-
# XXX Check for events
if( $resp ) {
Modified: branches/rel_1_6/Open-ILS/src/perlmods/OpenILS/SIP.pm
===================================================================
--- branches/rel_1_6/Open-ILS/src/perlmods/OpenILS/SIP.pm 2010-01-23 00:44:06 UTC (rev 15371)
+++ branches/rel_1_6/Open-ILS/src/perlmods/OpenILS/SIP.pm 2010-01-23 00:45:39 UTC (rev 15372)
@@ -164,14 +164,17 @@
my $year = $time[5]+1900;
my $mon = $time[4]+1;
my $day = $time[3];
+ my $hour = $time[2];
+ my $minute = $time[1];
+ my $second = $time[0];
+
+ $date = sprintf("%04d-%02d-%02d", $year, $mon, $day);
+
+ # Due dates need time of day as well
+ if ($type eq 'due') {
+ $date .= sprintf(" %02d:%02d:%02d", $hour, $minute, $second);
+ }
- $mon =~ s/^(\d)$/0$1/;
- $day =~ s/^(\d)$/0$1/;
- $date = "$year$mon$day";
-
- $date = $year.'-'.$mon.'-'.$day .' 00:00:00' if $type eq 'due';
- #$date = $year.'-'.$mon.'-'.$day if $type eq 'due';
-
syslog('LOG_DEBUG', "OILS: formatted date [type=$type]: $date");
return $date;
}
@@ -275,6 +278,7 @@
sub checkout {
my ($self, $patron_id, $item_id, $sc_renew) = @_;
+ $sc_renew = 0;
$self->verify_session;
@@ -303,15 +307,18 @@
}
syslog('LOG_DEBUG', "OILS: OpenILS::Checkout data loaded OK, checking out...");
- $xact->do_checkout();
- if ($item->{patron} && ($item->{patron} ne $patron_id)) {
+ if ($item->{patron} && ($item->{patron} eq $patron_id)) {
+ syslog('LOG_INFO', "OILS: OpenILS::Checkout data loaded OK, doing renew...");
+ $sc_renew = 1;
+ } elsif ($item->{patron} && ($item->{patron} ne $patron_id)) {
# I can't deal with this right now
# XXX check in then check out?
$xact->screen_msg("Item checked out to another patron");
$xact->ok(0);
}
+ $xact->do_checkout($sc_renew);
$xact->desensitize(!$item->magnetic);
if( $xact->ok ) {
More information about the open-ils-commits
mailing list