Lines 34-42
use CGI qw ( -utf8 );
Link Here
|
34 |
|
34 |
|
35 |
use C4::Auth qw( in_iprange get_template_and_user checkpw ); |
35 |
use C4::Auth qw( in_iprange get_template_and_user checkpw ); |
36 |
use C4::Circulation qw( barcodedecode AddReturn CanBookBeIssued AddIssue CanBookBeRenewed AddRenewal ); |
36 |
use C4::Circulation qw( barcodedecode AddReturn CanBookBeIssued AddIssue CanBookBeRenewed AddRenewal ); |
37 |
use C4::Reserves; |
37 |
use C4::Reserves qw ( ModReserveAffect ); |
38 |
use C4::Output qw( output_html_with_http_headers ); |
38 |
use C4::Output qw( output_html_with_http_headers ); |
39 |
use C4::Members; |
39 |
use C4::Members; |
|
|
40 |
use C4::Items qw( ModItemTransfer ); |
40 |
use Koha::DateUtils qw( dt_from_string ); |
41 |
use Koha::DateUtils qw( dt_from_string ); |
41 |
use Koha::Acquisition::Currencies; |
42 |
use Koha::Acquisition::Currencies; |
42 |
use Koha::Items; |
43 |
use Koha::Items; |
Lines 88-101
if ( defined C4::Context->preference('SCOAllowCheckin') ) {
Link Here
|
88 |
} |
89 |
} |
89 |
|
90 |
|
90 |
my $issuerid = $loggedinuser; |
91 |
my $issuerid = $loggedinuser; |
91 |
my ( $op, $patronlogin, $patronpw, $barcodestr, $confirmed, $newissues, $load_checkouts ) = ( |
92 |
my ( $op, $patronlogin, $patronpw, $barcodestr, $confirmed, $newissues, $load_checkouts, $sco_entry_barcode ) = ( |
92 |
$query->param("op") || '', |
93 |
$query->param("op") || '', |
93 |
$query->param("patronlogin") || '', |
94 |
$query->param("patronlogin") || '', |
94 |
$query->param("patronpw") || '', |
95 |
$query->param("patronpw") || '', |
95 |
$query->param("barcode") || '', |
96 |
$query->param("barcode") || '', |
96 |
$query->param("confirmed") || '', |
97 |
$query->param("confirmed") || '', |
97 |
$query->param("newissues") || '', |
98 |
$query->param("newissues") || '', |
98 |
$query->param("load_checkouts") || '', |
99 |
$query->param("load_checkouts") || '', |
|
|
100 |
$query->param("sco_entry_barcode") || '', |
99 |
); |
101 |
); |
100 |
|
102 |
|
101 |
my $jwt = $query->cookie('JWT'); |
103 |
my $jwt = $query->cookie('JWT'); |
Lines 108-115
if ( $op eq "logout" ) {
Link Here
|
108 |
} |
110 |
} |
109 |
|
111 |
|
110 |
my $barcodes = []; |
112 |
my $barcodes = []; |
111 |
if ($barcodestr) { |
113 |
if ( $barcodestr || $sco_entry_barcode ) { |
112 |
push @$barcodes, split( /\s\n/, $barcodestr ); |
114 |
push @$barcodes, split( /\s\n/, $barcodestr ? $barcodestr : $sco_entry_barcode ); |
113 |
$barcodes = [ map { $_ =~ /^\s*$/ ? () : barcodedecode($_) } @$barcodes ]; |
115 |
$barcodes = [ map { $_ =~ /^\s*$/ ? () : barcodedecode($_) } @$barcodes ]; |
114 |
} |
116 |
} |
115 |
|
117 |
|
Lines 156-166
if ($patron) {
Link Here
|
156 |
} |
158 |
} |
157 |
} |
159 |
} |
158 |
|
160 |
|
159 |
if ( $patron && $op eq "cud-returnbook" && $allowselfcheckreturns ) { |
161 |
if ( ( $op eq "cud-sco_entry_checkin" ) || ( $patron && $op eq "cud-returnbook" && $allowselfcheckreturns ) ) { |
160 |
my $success = 1; |
162 |
my $success = 1; |
161 |
|
163 |
|
|
|
164 |
if ( !@$barcodes ) { |
165 |
$template->param( empty_return => 1 ); |
166 |
} |
167 |
|
162 |
foreach my $barcode (@$barcodes) { |
168 |
foreach my $barcode (@$barcodes) { |
163 |
my $item = Koha::Items->find( { barcode => $barcode } ); |
169 |
my $item = Koha::Items->find( { barcode => $barcode } ); |
|
|
170 |
|
171 |
my $title = $item ? Koha::Biblios->find( { biblionumber => $item->biblionumber } )->title : undef; |
172 |
my $checkinlibrary = $issuer && $branch ? Koha::Libraries->find($branch)->branchname : undef; |
173 |
|
174 |
if ( !$item ) { |
175 |
$success = 0; |
176 |
} |
177 |
|
164 |
if ( $success && C4::Context->preference("CircConfirmItemParts") ) { |
178 |
if ( $success && C4::Context->preference("CircConfirmItemParts") ) { |
165 |
if ( defined($item) |
179 |
if ( defined($item) |
166 |
&& $item->materials ) |
180 |
&& $item->materials ) |
Lines 169-175
if ( $patron && $op eq "cud-returnbook" && $allowselfcheckreturns ) {
Link Here
|
169 |
} |
183 |
} |
170 |
} |
184 |
} |
171 |
|
185 |
|
172 |
if ($success) { |
186 |
if ( $success && ( $op ne "cud-sco_entry_checkin" ) ) { |
173 |
|
187 |
|
174 |
# Patron cannot checkin an item they don't own |
188 |
# Patron cannot checkin an item they don't own |
175 |
$success = 0 |
189 |
$success = 0 |
Lines 177-188
if ( $patron && $op eq "cud-returnbook" && $allowselfcheckreturns ) {
Link Here
|
177 |
} |
191 |
} |
178 |
|
192 |
|
179 |
if ($success) { |
193 |
if ($success) { |
180 |
($success) = AddReturn( $barcode, $branch ); |
194 |
|
|
|
195 |
my $to_branch = $item->homebranch; |
196 |
my $messages; |
197 |
|
198 |
( $success, $messages ) = AddReturn( $barcode, $branch ); |
199 |
|
200 |
if ( $messages->{'ResFound'} ) { |
201 |
my $reserve = $messages->{'ResFound'}; |
202 |
my $reserve_id = $reserve->{'reserve_id'}; |
203 |
my $resborrower = $reserve->{'borrowernumber'}; |
204 |
my $resbranch = $reserve->{'branchcode'}; |
205 |
my $itemnumber = $item->itemnumber; |
206 |
my $diff_branch_send = ( $branch ne $resbranch ) ? $resbranch : undef; |
207 |
|
208 |
if ($diff_branch_send) { |
209 |
ModReserveAffect( $itemnumber, $resborrower, $diff_branch_send, $reserve_id ); |
210 |
ModItemTransfer( $itemnumber, $branch, $resbranch, 'ResFound' ); |
211 |
} else { |
212 |
my $set_transit = C4::Context->preference('RequireSCCheckInBeforeNotifyingPickups'); |
213 |
ModReserveAffect( $itemnumber, $resborrower, $set_transit, $reserve_id ); |
214 |
} |
215 |
} elsif ( $messages->{'NeedsTransfer'} ) { |
216 |
ModItemTransfer( $item->itemnumber, $branch, $to_branch, 'NeedsTransfer' ); |
217 |
} |
218 |
|
219 |
if ( $messages->{'WrongTransfer'} ) { |
220 |
my $item = Koha::Items->find( $messages->{'WrongTransferItem'} ); |
221 |
my $old_transfer = $item->get_transfer; |
222 |
my $new_transfer = $item->request_transfer( |
223 |
{ to => $old_transfer->tobranch, reason => $old_transfer->reason, replace => 'WrongTransfer' } ); |
224 |
} |
225 |
|
181 |
} |
226 |
} |
182 |
|
227 |
|
183 |
$template->param( |
228 |
$template->param( |
184 |
returned => $success, |
229 |
SelfCheckTimeout => 10000, #don't show returns long |
185 |
barcode => $barcode |
230 |
returned => $success, |
|
|
231 |
barcode => $barcode, |
232 |
title => $title, |
233 |
library => $checkinlibrary |
186 |
); |
234 |
); |
187 |
} # foreach barcode in barcodes |
235 |
} # foreach barcode in barcodes |
188 |
|
236 |
|
189 |
- |
|
|