|
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 81-94
if ( defined C4::Context->preference('SCOAllowCheckin') ) {
Link Here
|
| 81 |
} |
82 |
} |
| 82 |
|
83 |
|
| 83 |
my $issuerid = $loggedinuser; |
84 |
my $issuerid = $loggedinuser; |
| 84 |
my ( $op, $patronlogin, $patronpw, $barcodestr, $confirmed, $newissues, $load_checkouts ) = ( |
85 |
my ( $op, $patronlogin, $patronpw, $barcodestr, $confirmed, $newissues, $load_checkouts, $sco_entry_barcode ) = ( |
| 85 |
$query->param("op") || '', |
86 |
$query->param("op") || '', |
| 86 |
$query->param("patronlogin") || '', |
87 |
$query->param("patronlogin") || '', |
| 87 |
$query->param("patronpw") || '', |
88 |
$query->param("patronpw") || '', |
| 88 |
$query->param("barcode") || '', |
89 |
$query->param("barcode") || '', |
| 89 |
$query->param("confirmed") || '', |
90 |
$query->param("confirmed") || '', |
| 90 |
$query->param("newissues") || '', |
91 |
$query->param("newissues") || '', |
| 91 |
$query->param("load_checkouts") || '', |
92 |
$query->param("load_checkouts") || '', |
|
|
93 |
$query->param("sco_entry_barcode") || '', |
| 92 |
); |
94 |
); |
| 93 |
|
95 |
|
| 94 |
my $jwt = $query->cookie('JWT'); |
96 |
my $jwt = $query->cookie('JWT'); |
|
Lines 101-108
if ( $op eq "logout" ) {
Link Here
|
| 101 |
} |
103 |
} |
| 102 |
|
104 |
|
| 103 |
my $barcodes = []; |
105 |
my $barcodes = []; |
| 104 |
if ($barcodestr) { |
106 |
if ( $barcodestr || $sco_entry_barcode ) { |
| 105 |
push @$barcodes, split( /\s\n/, $barcodestr ); |
107 |
push @$barcodes, split( /\s\n/, $barcodestr ? $barcodestr : $sco_entry_barcode ); |
| 106 |
$barcodes = [ map { $_ =~ /^\s*$/ ? () : barcodedecode($_) } @$barcodes ]; |
108 |
$barcodes = [ map { $_ =~ /^\s*$/ ? () : barcodedecode($_) } @$barcodes ]; |
| 107 |
} |
109 |
} |
| 108 |
|
110 |
|
|
Lines 149-159
if ($patron) {
Link Here
|
| 149 |
} |
151 |
} |
| 150 |
} |
152 |
} |
| 151 |
|
153 |
|
| 152 |
if ( $patron && $op eq "cud-returnbook" && $allowselfcheckreturns ) { |
154 |
if ( ( $op eq "cud-sco_entry_checkin" ) || ( $patron && $op eq "cud-returnbook" && $allowselfcheckreturns ) ) { |
| 153 |
my $success = 1; |
155 |
my $success = 1; |
| 154 |
|
156 |
|
|
|
157 |
if ( !@$barcodes ) { |
| 158 |
$template->param( empty_return => 1 ); |
| 159 |
} |
| 160 |
|
| 155 |
foreach my $barcode (@$barcodes) { |
161 |
foreach my $barcode (@$barcodes) { |
| 156 |
my $item = Koha::Items->find( { barcode => $barcode } ); |
162 |
my $item = Koha::Items->find( { barcode => $barcode } ); |
|
|
163 |
|
| 164 |
my $title = $item ? Koha::Biblios->find( { biblionumber => $item->biblionumber } )->title : undef; |
| 165 |
my $checkinlibrary = $issuer && $branch ? Koha::Libraries->find($branch)->branchname : undef; |
| 166 |
|
| 167 |
if ( !$item ) { |
| 168 |
$success = 0; |
| 169 |
} |
| 170 |
|
| 157 |
if ( $success && C4::Context->preference("CircConfirmItemParts") ) { |
171 |
if ( $success && C4::Context->preference("CircConfirmItemParts") ) { |
| 158 |
if ( defined($item) |
172 |
if ( defined($item) |
| 159 |
&& $item->materials ) |
173 |
&& $item->materials ) |
|
Lines 162-168
if ( $patron && $op eq "cud-returnbook" && $allowselfcheckreturns ) {
Link Here
|
| 162 |
} |
176 |
} |
| 163 |
} |
177 |
} |
| 164 |
|
178 |
|
| 165 |
if ($success) { |
179 |
if ( $success && ( $op ne "cud-sco_entry_checkin" ) ) { |
| 166 |
|
180 |
|
| 167 |
# Patron cannot checkin an item they don't own |
181 |
# Patron cannot checkin an item they don't own |
| 168 |
$success = 0 |
182 |
$success = 0 |
|
Lines 170-181
if ( $patron && $op eq "cud-returnbook" && $allowselfcheckreturns ) {
Link Here
|
| 170 |
} |
184 |
} |
| 171 |
|
185 |
|
| 172 |
if ($success) { |
186 |
if ($success) { |
| 173 |
($success) = AddReturn( $barcode, $branch ); |
187 |
|
|
|
188 |
my $to_branch = $item->homebranch; |
| 189 |
my $messages; |
| 190 |
|
| 191 |
( $success, $messages ) = AddReturn( $barcode, $branch ); |
| 192 |
|
| 193 |
if ( $messages->{'ResFound'} ) { |
| 194 |
my $reserve = $messages->{'ResFound'}; |
| 195 |
my $reserve_id = $reserve->{'reserve_id'}; |
| 196 |
my $resborrower = $reserve->{'borrowernumber'}; |
| 197 |
my $resbranch = $reserve->{'branchcode'}; |
| 198 |
my $itemnumber = $item->itemnumber; |
| 199 |
my $diff_branch_send = ( $branch ne $resbranch ) ? $resbranch : undef; |
| 200 |
|
| 201 |
if ($diff_branch_send) { |
| 202 |
ModReserveAffect( $itemnumber, $resborrower, $diff_branch_send, $reserve_id ); |
| 203 |
ModItemTransfer( $itemnumber, $branch, $resbranch, 'ResFound' ); |
| 204 |
} else { |
| 205 |
my $set_transit = C4::Context->preference('RequireSCCheckInBeforeNotifyingPickups'); |
| 206 |
ModReserveAffect( $itemnumber, $resborrower, $set_transit, $reserve_id ); |
| 207 |
} |
| 208 |
} elsif ( $messages->{'NeedsTransfer'} ) { |
| 209 |
ModItemTransfer( $item->itemnumber, $branch, $to_branch, 'NeedsTransfer' ); |
| 210 |
} |
| 211 |
|
| 212 |
if ( $messages->{'WrongTransfer'} ) { |
| 213 |
my $item = Koha::Items->find( $messages->{'WrongTransferItem'} ); |
| 214 |
my $old_transfer = $item->get_transfer; |
| 215 |
my $new_transfer = $item->request_transfer( |
| 216 |
{ to => $old_transfer->tobranch, reason => $old_transfer->reason, replace => 'WrongTransfer' } ); |
| 217 |
} |
| 218 |
|
| 174 |
} |
219 |
} |
| 175 |
|
220 |
|
| 176 |
$template->param( |
221 |
$template->param( |
| 177 |
returned => $success, |
222 |
SelfCheckTimeout => 10000, #don't show returns long |
| 178 |
barcode => $barcode |
223 |
returned => $success, |
|
|
224 |
barcode => $barcode, |
| 225 |
title => $title, |
| 226 |
library => $checkinlibrary |
| 179 |
); |
227 |
); |
| 180 |
} # foreach barcode in barcodes |
228 |
} # foreach barcode in barcodes |
| 181 |
|
229 |
|
| 182 |
- |
|
|