use C4::Koha;
use C4::Members;
use C4::Reserves;
-use C4::Items qw( GetBarcodeFromItemnumber GetItemnumbersForBiblio);
use C4::Auth qw(checkpw);
+use Koha::Items;
use Koha::Libraries;
use Koha::Patrons;
our $kp; # koha patron
+=head1 Methods
+
+=cut
+
sub new {
my ($class, $patron_id) = @_;
my $type = ref($class) || $class;
my $self;
- $kp = Koha::Patrons->find( { cardnumber => $patron_id } )
+ my $patron = Koha::Patrons->find( { cardnumber => $patron_id } )
|| Koha::Patrons->find( { userid => $patron_id } );
- $debug and warn "new Patron: " . Dumper($kp->unblessed) if $kp;
- unless ($kp) {
+ $debug and warn "new Patron: " . Dumper($patron->unblessed) if $patron;
+ unless ($patron) {
syslog("LOG_DEBUG", "new ILS::Patron(%s): no such patron", $patron_id);
return;
}
- $kp = $kp->unblessed;
+ $kp = $patron->unblessed;
my $pw = $kp->{password};
my $flags = C4::Members::patronflags( $kp );
- my $debarred = defined($flags->{DBARRED});
- $debug and warn sprintf("Debarred = %s : ", ($debarred||'undef')) . Dumper(%$flags);
+ my $debarred = $patron->is_debarred;
+ $debug and warn sprintf("Debarred = %s : ", ($debarred||'undef')); # Do we need more debug info here?
my ($day, $month, $year) = (localtime)[3,4,5];
my $today = sprintf '%04d-%02d-%02d', $year+1900, $month+1, $day;
my $expired = ($today gt $kp->{dateexpiry}) ? 1 : 0;
$dob and $dob =~ s/-//g; # YYYYMMDD
my $dexpiry = $kp->{dateexpiry};
$dexpiry and $dexpiry =~ s/-//g; # YYYYMMDD
- my $fines_amount = $flags->{CHARGES}->{amount};
+ my $fines_amount = $patron->account->balance;
$fines_amount = ($fines_amount and $fines_amount > 0) ? $fines_amount : 0;
my $fee_limit = _fee_limit();
my $fine_blocked = $fines_amount > $fee_limit;
);
}
$debug and warn "patron fines: $ilspatron{fines} ... amountoutstanding: $kp->{amountoutstanding} ... CHARGES->amount: $flags->{CHARGES}->{amount}";
+
+ if ( $patron->is_debarred and $patron->debarredcomment ) {
+ $ilspatron{screen_msg} .= " -- " . $patron->debarredcomment;
+ }
for (qw(EXPIRED CHARGES CREDITS GNA LOST DBARRED NOTES)) {
($flags->{$_}) or next;
if ($_ ne 'NOTES' and $flags->{$_}->{message}) {
# FIXME: populate fine_items recall_items
$ilspatron{unavail_holds} = _get_outstanding_holds($kp->{borrowernumber});
- $ilspatron{items} = GetPendingIssues($kp->{borrowernumber});
+ $ilspatron{items} = $patron->pending_checkouts->unblessed;
$self = \%ilspatron;
$debug and warn Dumper($self);
syslog("LOG_DEBUG", "new ILS::Patron(%s): found patron '%s'", $patron_id,$self->{id});
my $self = shift;
my $item_arr = $self->x_items('hold_items', @_);
foreach my $item (@{$item_arr}) {
- $item->{barcode} = GetBarcodeFromItemnumber($item->{itemnumber});
+ my $item_obj = Koha::Items->find($item->{itemnumber});
+ $item->{barcode} = $item_obj ? $item_obj->barcode : undef;
}
return $item_arr;
}
return "Please contact library staff";
}
+=head2 update_lastseen
+
+ $patron->update_lastseen();
+
+ Patron method to update lastseen field in borrower
+ to record that patron has been seen via sip connection
+
+=cut
+
+sub update_lastseen {
+ my $self = shift;
+ my $kohaobj = Koha::Patrons->find( $self->{borrowernumber} );
+ $kohaobj->track_login if $kohaobj; # track_login checks the pref
+}
+
sub _get_address {
my $patron = shift;
while ( my $hold = $holds->next ) {
my $item;
if ($hold->itemnumber) {
- $item = $hold->itemnumber;
+ $item = $hold->item;
}
else {
# We need to return a barcode for the biblio so the client
# can request the biblio info
- $item = ( GetItemnumbersForBiblio($hold->biblionumber) )->[0];
+ my $items = $hold->biblio->items;
+ $item = $items->count ? $item->next : undef;
}
my $unblessed_hold = $hold->unblessed;
- $unblessed_hold->{barcode} = GetBarcodeFromItemnumber($item);
+
+ $unblessed_hold->{barcode} = $item ? $item->barcode : undef;
+
push @holds, $unblessed_hold;
}
return \@holds;
}
+=head2 build_patron_attributes_string
+
+This method builds the part of the sip message for extended patron
+attributes as defined in the sip config
+
+=cut
+
sub build_patron_attributes_string {
my ( $self, $server ) = @_;