Lines 48-65
sub new {
Link Here
|
48 |
sub do_checkout { |
48 |
sub do_checkout { |
49 |
my $self = shift; |
49 |
my $self = shift; |
50 |
syslog('LOG_DEBUG', "ILS::Transaction::Checkout performing checkout..."); |
50 |
syslog('LOG_DEBUG', "ILS::Transaction::Checkout performing checkout..."); |
51 |
my $pending = $self->{item}->pending_queue; |
51 |
|
52 |
my $shelf = $self->{item}->hold_shelf; |
52 |
# BEG Core::Circulation OVERRIDE - Checkout |
53 |
my $barcode = $self->{item}->id; |
53 |
# NOTE: HAD TO ADD BRANCH TO MsgType::handle_checkout and ILS::checkout SINCE THERE IS NO BRANCH CONTEXT IN SIP |
54 |
my $patron_barcode = $self->{patron}->id; |
54 |
use Koha::Items; |
55 |
my $overridden_duedate; # usually passed as undef to AddIssue |
55 |
use Koha::Libraries; |
56 |
$debug and warn "do_checkout: patron (" . $patron_barcode . ")"; |
56 |
my $core = C4::Context->config("core_modules")->{sip} or die "Missing core_modules->sip config"; |
57 |
my $patron = Koha::Patrons->find( { cardnumber => $patron_barcode } ); |
57 |
my $class = load_optional_class($core) ? $core : "Core::Circulation::SIP"; |
58 |
my $borrower = $patron->unblessed; |
58 |
my $library = Koha::Libraries->find($self->{branch}); |
59 |
$debug and warn "do_checkout borrower: . " . Dumper $borrower; |
59 |
my $item = Koha::Items->find($self->{item}->{itemnumber}); |
60 |
my ($issuingimpossible, $needsconfirmation) = _can_we_issue($patron, $barcode, |
60 |
my $patron = Koha::Patrons->find({cardnumber => $self->{patron}->id}); |
61 |
C4::Context->preference("AllowItemsOnHoldCheckout") |
61 |
my $circ = $class->new({ |
62 |
); |
62 |
item => $item, |
|
|
63 |
library => $library, |
64 |
patron => $patron, |
65 |
}); |
66 |
$debug and warn "do_checkout: patron (" . $self->{patron}->id . ")"; |
67 |
my ($issuingimpossible, $needsconfirmation, $alerts, $messages) = $circ->canItemBeIssued(); |
68 |
my $pending = $self->{item}->pending_queue; |
69 |
my $shelf = $self->{item}->hold_shelf; |
70 |
my $overridden_duedate; # usually passed as undef to AddIssue |
71 |
#use Data::Dumper; warn Dumper($circ->{messages}); |
72 |
#use Data::Dumper; warn Dumper($issuingimpossible); |
73 |
#use Data::Dumper; warn Dumper($needsconfirmation); |
74 |
#use Data::Dumper; warn Dumper($messages); |
75 |
# END Core::Circulation OVERRIDE |
63 |
|
76 |
|
64 |
my $noerror=1; # If set to zero we block the issue |
77 |
my $noerror=1; # If set to zero we block the issue |
65 |
if (keys %{$issuingimpossible}) { |
78 |
if (keys %{$issuingimpossible}) { |
Lines 74-80
sub do_checkout {
Link Here
|
74 |
if ($confirmation eq 'RENEW_ISSUE'){ |
87 |
if ($confirmation eq 'RENEW_ISSUE'){ |
75 |
$self->screen_msg("Item already checked out to you: renewing item."); |
88 |
$self->screen_msg("Item already checked out to you: renewing item."); |
76 |
} elsif ($confirmation eq 'RESERVED' or $confirmation eq 'RESERVE_WAITING') { |
89 |
} elsif ($confirmation eq 'RESERVED' or $confirmation eq 'RESERVE_WAITING') { |
77 |
my $x = $self->{item}->available($patron_barcode); |
90 |
my $x = $self->{item}->available($self->{patron}->id); |
78 |
if ($x) { |
91 |
if ($x) { |
79 |
$self->screen_msg("Item was reserved for you."); |
92 |
$self->screen_msg("Item was reserved for you."); |
80 |
} else { |
93 |
} else { |
Lines 90-96
sub do_checkout {
Link Here
|
90 |
$noerror = 0; |
103 |
$noerror = 0; |
91 |
last; |
104 |
last; |
92 |
} elsif ($confirmation eq 'HIGHHOLDS') { |
105 |
} elsif ($confirmation eq 'HIGHHOLDS') { |
93 |
$overridden_duedate = $needsconfirmation->{$confirmation}->{returndate}; |
106 |
$overridden_duedate = $needsconfirmation->{HIGHHOLDS}->{returndate}; |
94 |
$self->screen_msg('Loan period reduced for high-demand item'); |
107 |
$self->screen_msg('Loan period reduced for high-demand item'); |
95 |
} elsif ($confirmation eq 'RENTALCHARGE') { |
108 |
} elsif ($confirmation eq 'RENTALCHARGE') { |
96 |
if ($self->{fee_ack} ne 'Y') { |
109 |
if ($self->{fee_ack} ne 'Y') { |
Lines 106-111
sub do_checkout {
Link Here
|
106 |
} |
119 |
} |
107 |
} |
120 |
} |
108 |
} |
121 |
} |
|
|
122 |
# TODO: THIS SHOULD NOT BE HANDLED HERE |
109 |
my $itemnumber = $self->{item}->{itemnumber}; |
123 |
my $itemnumber = $self->{item}->{itemnumber}; |
110 |
foreach (@$shelf) { |
124 |
foreach (@$shelf) { |
111 |
$debug and warn "shelf has ($_->{itemnumber} for $_->{borrowernumber}). this is ($itemnumber, $self->{patron}->{borrowernumber})"; |
125 |
$debug and warn "shelf has ($_->{itemnumber} for $_->{borrowernumber}). this is ($itemnumber, $self->{patron}->{borrowernumber})"; |
Lines 116-121
sub do_checkout {
Link Here
|
116 |
$self->screen_msg("Item is on hold shelf for another patron."); |
130 |
$self->screen_msg("Item is on hold shelf for another patron."); |
117 |
$noerror = 0; |
131 |
$noerror = 0; |
118 |
} |
132 |
} |
|
|
133 |
# TODO: WE DONT USE ISSUING CHARGES |
119 |
my ($fee, undef) = GetIssuingCharges($itemnumber, $self->{patron}->{borrowernumber}); |
134 |
my ($fee, undef) = GetIssuingCharges($itemnumber, $self->{patron}->{borrowernumber}); |
120 |
if ( $fee > 0 ) { |
135 |
if ( $fee > 0 ) { |
121 |
$self->{sip_fee_type} = '06'; |
136 |
$self->{sip_fee_type} = '06'; |
Lines 129-151
sub do_checkout {
Link Here
|
129 |
$self->ok(0); |
144 |
$self->ok(0); |
130 |
return $self; |
145 |
return $self; |
131 |
} |
146 |
} |
132 |
# Fill any reserves the patron had on the item. |
147 |
# BEG Core::Circulation OVERRIDE - Checkout |
133 |
# TODO: this logic should be pulled internal to AddIssue for all Koha. |
148 |
# Fill any reserves the patron had on the item. |
134 |
$debug and warn "pending_queue: " . (@$pending) ? Dumper($pending) : '[]'; |
149 |
# TODO: this logic should be pulled internal to AddIssue for all Koha. |
135 |
foreach (grep {$_->{borrowernumber} eq $self->{patron}->{borrowernumber}} @$pending) { |
150 |
#$debug and warn "pending_queue: " . (@$pending) ? Dumper($pending) : '[]'; |
136 |
$debug and warn "Filling reserve (borrowernumber,biblionumber,reservedate): " |
151 |
#foreach (grep {$_->{borrowernumber} eq $self->{patron}->{borrowernumber}} @$pending) { |
137 |
. sprintf("(%s,%s,%s)\n",$_->{borrowernumber},$_->{biblionumber},$_->{reservedate}); |
152 |
# $debug and warn "Filling reserve (borrowernumber,biblionumber,reservedate): " |
138 |
ModReserveFill($_); |
153 |
# . sprintf("(%s,%s,%s)\n",$_->{borrowernumber},$_->{biblionumber},$_->{reservedate}); |
139 |
# TODO: adjust representation in $self->item |
154 |
# ModReserveFill($_); |
140 |
} |
155 |
#} |
141 |
# can issue |
156 |
|
142 |
$debug and warn "do_checkout: calling AddIssue(\$borrower,$barcode, $overridden_duedate, 0)\n" |
157 |
#my $issue = AddIssue( $borrower, $barcode, $overridden_duedate, 0 ); |
143 |
# . "w/ \$borrower: " . Dumper($borrower) |
158 |
$circ->Checkout(); |
144 |
. "w/ C4::Context->userenv: " . Dumper(C4::Context->userenv); |
159 |
$self->{due} = $circ->{checkout}->date_due; |
145 |
my $issue = AddIssue( $borrower, $barcode, $overridden_duedate, 0 ); |
160 |
# END Core::Circulation OVERRIDE |
146 |
$self->{due} = $self->duedatefromissue($issue, $itemnumber); |
161 |
|
147 |
|
162 |
$self->ok(1); |
148 |
$self->ok(1); |
|
|
149 |
return $self; |
163 |
return $self; |
150 |
} |
164 |
} |
151 |
|
165 |
|