From: djfiander Date: Tue, 21 Mar 2006 00:26:55 +0000 (+0000) Subject: Implement Checkout operation stub using the Transaction and X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=0fd1ca1d3ac2fed2154c5b7d9d6efeee690790bb;p=working%2FSIPServer.git Implement Checkout operation stub using the Transaction and Transaction::Checkout modules. --- diff --git a/ILS.pm b/ILS.pm index 52759fb..d97569a 100644 --- a/ILS.pm +++ b/ILS.pm @@ -9,8 +9,71 @@ use warnings; use strict; use Sys::Syslog qw(syslog); +use ILS::Item; +use ILS::Patron; +use ILS::Transaction; +use ILS::Transaction::Checkout; + our (@ISA, @EXPORT_OK); @ISA = qw(Exporter); +my %supports = ( + 'magnetic media' => 1, + 'security inhibit' => 0, + 'offline operation' => 0 + ); + +sub new { + my ($class, $institution) = @_; + my $type = ref($class) || $class; + my $self = {}; + + syslog("DEBUG", "new ILS '$institution'"); + $self->{institution} = $institution; + + return bless $self, $type; +} + +sub institution { + my $self = shift; + + return $self->{institution}; +} + +sub supports { + my ($self, $op) = @_; + + return exists($supports{$op}) ? $supports{$op} : 0; +} + +# +# Checkout(patron_id, item_id, sc_renew): +# patron_id & item_id are the identifiers send by the terminal +# sc_renew is the renewal policy configured on the terminal +# returns a status opject that can be queried for the various bits +# of information that the protocol (SIP or NCIP) needs to generate +# the response. +# +sub checkout { + my ($self, $patron_id, $item_id, $sc_renew) = @_; + my ($patron, $item, $circ); + + $circ = new ILS::Transaction::Checkout; + + # BEGIN TRANSACTION + $circ->{patron} = $patron = new ILS::Patron $patron_id; + $circ->{item} = $item = new ILS::Item $item_id; + + $circ->{ok} = ($circ->{patron} && $circ->{item}) ? 1 : 0; + + if ($circ->{ok}) { + $item->{patron} = $patron_id; + push(@{$patron->{items}}, $item_id); + $circ->{desensitize} = !$item->magnetic; + } + + return $circ; +} + 1;