package ILS::Transaction;
-use Exporter;
+use Carp;
use strict;
use warnings;
-our @ISA = qw(Exporter);
+my %fields = (
+ ok => 0,
+ patron => undef,
+ item => undef,
+ desensitize => 0,
+ alert => '',
+ transation_id => undef,
+ sip_fee_type => '01', # Other/Unknown
+ fee_amount => undef,
+ sip_currency => 'CAD',
+ screen_msg => '',
+ print_line => '',
+ );
+
+our $AUTOLOAD;
sub new {
- my ($class, $obj) = @_;
- my $type = ref($class) || $class;
+ my $class = shift;
+ my $self = {
+ _permitted => \%fields,
+ %fields,
+ };
- return bless {}, $type;
+ return bless $self, $class;
}
-sub ok {
- my $self = shift;
-
- return $self->{ok} ? 1 : 0; # normalize, just because
-}
-
-sub alert {
- my $self = shift;
-
- return $self->{alert} || 0;
-}
-
-sub screen_msg {
- my $self = shift;
-
- return ($self->{screen_msg} || "");
-}
-
-sub print_line {
- my $self = shift;
-
- return ($self->{print_line} || "");
-}
-
-sub patron {
- my $self = shift;
-
- return $self->{patron};
-}
-
-sub item {
- my $self = shift;
-
- return $self->{item};
+sub DESTROY {
+ # be cool
}
-sub permanent_location {
+sub AUTOLOAD {
my $self = shift;
+ my $class = ref($self) or croak "$self is not an object";
+ my $name = $AUTOLOAD;
- return $self->item->permanent_location || '';
-}
-
-sub sort_bin {
- my $self = shift;
-
- return $self->{sort_bin} || '';
-}
-
-sub fee_amount {
- return 0;
-}
-
-sub transaction_id {
- my $self = shift;
-
- return $self->{transaction_id};
-}
+ $name =~ s/.*://;
-sub sip_currency {
- return 'CAD'; # ;-)
-}
-
-sub sip_fee_type {
- my $self = shift;
-
- return $self->{sip_fee_type} || '01'; # "Other/Unknown"
-}
-
-sub available {
- my $self = shift;
-
- return $self->{available} || 'N'; # Assume that it's not available
-}
-
-sub desensitize {
- my $self = shift;
+ unless (exists $self->{_permitted}->{$name}) {
+ croak "Can't access '$name' field of class '$class'";
+ }
- return $self->{desensitize};
+ if (@_) {
+ return $self->{$name} = shift;
+ } else {
+ return $self->{$name};
+ }
}
1;
package ILS::Transaction::Checkin;
-use Exporter;
use warnings;
use strict;
use ILS;
use ILS::Transaction;
-our @ISA = qw(Exporter ILS::Transaction);
+our @ISA = qw(ILS::Transaction);
+
+my %fields = (
+ magnetic => 0,
+ sort_bin => undef,
+ );
sub new {
- my ($class, $obj) = @_;
- my $type = ref($class) || $class;
- my ($item, $patron);
+ my $class = shift;;
+ my $self = $class->SUPER::new();
+ my $element;
+
+ foreach $element (keys %fields) {
+ $self->{_permitted}->{$element} = $fields{$element};
+ }
- $obj = {};
+ @{$self}{keys %fields} = values %fields;
- return bless $obj, $type;
+ return bless $self, $class;
}
sub resensitize {
return !$self->{item}->magnetic;
}
-sub magnetic_media {
- my $self = shift;
-
- return $self->{item}->magnetic;
-}
-
1;
package ILS::Transaction::Checkout;
-use Exporter;
use warnings;
use strict;
use ILS;
use ILS::Transaction;
-our @ISA = qw(Exporter ILS::Transaction);
+our @ISA = qw(ILS::Transaction);
# Most fields are handled by the Transaction superclass
+my %fields = (
+ security_inhibit => 0,
+ due => undef,
+ );
sub new {
- my ($class, $obj) = @_;
- my $type = ref($class) || $class;
-
- $obj = {};
-
- $obj->{'due'} = time() + (60*60*24*14); # two weeks hence
-
- return bless $obj, $type;
-}
-
-sub security_inhibit {
- return 0;
-}
-
-sub due_date {
- my $self = shift;
- return(strftime("%F %H:%M:%S", localtime($self->{due})));
+ my $class = shift;;
+ my $self = $class->SUPER::new();
+ my $element;
+
+ foreach $element (keys %fields) {
+ $self->{_permitted}->{$element} = $fields{$element};
+ }
+
+ @{$self}{keys %fields} = values %fields;
+ $self->{'due'} = time() + (60*60*24*14); # two weeks hence
+
+ return bless $self, $class;
}
sub renew_ok {
return ($item->{patron} eq $patron->{id});
}
+
1;
our @ISA = qw(ILS::Transaction);
-# Most fields are handled by the Transaction superclass
+my %fields = (
+ expiration_date => 0,
+ pickup_location => undef,
+ );
-sub expiration_date {
- my $self = shift;
+sub new {
+ my $class = shift;;
+ my $self = $class->SUPER::new();
+ my $element;
+
+ foreach $element (keys %fields) {
+ $self->{_permitted}->{$element} = $fields{$element};
+ }
+
+ @{$self}{keys %fields} = values %fields;
- return $self->{expiration_date} || 0;
+ return bless $self, $class;
}
sub queue_position {
return $self->item->hold_queue_position($self->patron->id);
}
-sub pickup_location {
- my $self = shift;
-
- return $self->{pickup_location};
-}
1;
our @ISA = qw(ILS::Transaction);
-# most fields are handled by the Transaction superclass
+my %fields = (
+ renewal_ok => 0,
+ );
-sub renewal_ok {
- my $self = shift;
+sub new {
+ my $class = shift;;
+ my $self = $class->SUPER::new();
+ my $element;
- return $self->{renewal_ok} || 0;
+ foreach $element (keys %fields) {
+ $self->{_permitted}->{$element} = $fields{$element};
+ }
+
+ @{$self}{keys %fields} = values %fields;
+
+ return bless $self, $class;
}
1;
--- /dev/null
+#
+# RenewAll: class to manage status of "Renew All" transaction
+
+package ILS::Transaction::RenewAll;
+
+use strict;
+use warnings;
+
+our @ISA = qw(ILS::Transaction);
+
+my %fields = (
+ renewed => [],
+ unrenewed => [],
+ );
+sub new {
+ my $class = shift;;
+ my $self = $class->SUPER::new();
+ my $element;
+
+ foreach $element (keys %fields) {
+ $self->{_permitted}->{$element} = $fields{$element};
+ }
+
+ @{$self}{keys %fields} = values %fields;
+
+ return bless $self, $class;
+}
+
+1;