use strict;
use warnings;
use C4::Context;
use C4::Circulation qw( GetItemIssue );
use Koha::DateUtils;
my %fields = (
ok => 0,
return bless $self, $class;
}
sub duedatefromissue {
my ($self, $iss, $itemnum) = @_;
my $due_dt;
if (defined $iss ) {
$due_dt = dt_from_string( $iss->date_due() );
} # renew from AddIssue ??
else {
# need to reread the issue to get due date
$iss = GetItemIssue($itemnum);
if ($iss && $iss->{date_due} ) {
$due_dt = dt_from_string( $iss->{date_due} );
return $due_dt;
sub DESTROY {
# be cool
# . "w/ \$borrower: " . Dumper($borrower)
. "w/ C4::Context->userenv: " . Dumper(C4::Context->userenv);
my $issue = AddIssue( $borrower, $barcode, $overridden_duedate, 0 );
my $due_dt = dt_from_string( $issue->date_due() );
$self->{due} = $self->duedatefromissue($issue, $itemnumber);
if ($due_dt) {
$self->{due} = $due_dt->clone();
} else {
$self->{due} = undef;
#$self->{item}->due_date($due);
$self->ok(1);
return $self;
if ($renewokay){
my $issue = AddIssue( $borrower, $self->{item}->id, undef, 0 );
my $due_date = dt_from_string( $issue->date_due() );
$self->{due} = $self->duedatefromissue($issue, $self->{item}->{itemnumber});
if ($due_date) {
$self->{due} = $due_date;
$self->renewal_ok(1);
$renewerror=~s/on_reserve/Item unavailable due to outstanding holds/;
-