|
Lines 32-38
use Modern::Perl;
Link Here
|
| 32 |
|
32 |
|
| 33 |
use CGI qw ( -utf8 ); |
33 |
use CGI qw ( -utf8 ); |
| 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; |
| 38 |
use C4::Output qw( output_html_with_http_headers ); |
38 |
use C4::Output qw( output_html_with_http_headers ); |
|
Lines 49-87
use Koha::CookieManager;
Link Here
|
| 49 |
|
49 |
|
| 50 |
my $query = CGI->new; |
50 |
my $query = CGI->new; |
| 51 |
|
51 |
|
| 52 |
unless (C4::Context->preference('WebBasedSelfCheck')) { |
52 |
unless ( C4::Context->preference('WebBasedSelfCheck') ) { |
|
|
53 |
|
| 53 |
# redirect to OPAC home if self-check is not enabled |
54 |
# redirect to OPAC home if self-check is not enabled |
| 54 |
print $query->redirect("/cgi-bin/koha/opac-main.pl"); |
55 |
print $query->redirect("/cgi-bin/koha/opac-main.pl"); |
| 55 |
exit; |
56 |
exit; |
| 56 |
} |
57 |
} |
| 57 |
|
58 |
|
| 58 |
unless ( in_iprange(C4::Context->preference('SelfCheckAllowByIPRanges')) ) { |
59 |
unless ( in_iprange( C4::Context->preference('SelfCheckAllowByIPRanges') ) ) { |
|
|
60 |
|
| 59 |
# redirect to OPAC home if self-checkout not permitted from current IP |
61 |
# redirect to OPAC home if self-checkout not permitted from current IP |
| 60 |
print $query->redirect("/cgi-bin/koha/opac-main.pl"); |
62 |
print $query->redirect("/cgi-bin/koha/opac-main.pl"); |
| 61 |
exit; |
63 |
exit; |
| 62 |
} |
64 |
} |
| 63 |
|
65 |
|
| 64 |
$query->param(-name=>'sco_user_login',-values=>[1]); |
66 |
$query->param( -name => 'sco_user_login', -values => [1] ); |
| 65 |
|
67 |
|
| 66 |
my ( $template, $loggedinuser, $cookie ) = get_template_and_user( |
68 |
my ( $template, $loggedinuser, $cookie ) = get_template_and_user( |
| 67 |
{ |
69 |
{ |
| 68 |
template_name => "sco/sco-main.tt", |
70 |
template_name => "sco/sco-main.tt", |
| 69 |
flagsrequired => { self_check => "self_checkout_module" }, |
71 |
flagsrequired => { self_check => "self_checkout_module" }, |
| 70 |
query => $query, |
72 |
query => $query, |
| 71 |
type => "opac", |
73 |
type => "opac", |
| 72 |
} |
74 |
} |
| 73 |
); |
75 |
); |
| 74 |
|
76 |
|
| 75 |
# Get the self checkout timeout preference, or use 120 seconds as a default |
77 |
# Get the self checkout timeout preference, or use 120 seconds as a default |
| 76 |
my $selfchecktimeout = 120000; |
78 |
my $selfchecktimeout = 120000; |
| 77 |
if (C4::Context->preference('SelfCheckTimeout')) { |
79 |
if ( C4::Context->preference('SelfCheckTimeout') ) { |
| 78 |
$selfchecktimeout = C4::Context->preference('SelfCheckTimeout') * 1000; |
80 |
$selfchecktimeout = C4::Context->preference('SelfCheckTimeout') * 1000; |
| 79 |
} |
81 |
} |
| 80 |
$template->param( SelfCheckTimeout => $selfchecktimeout ); |
82 |
$template->param( SelfCheckTimeout => $selfchecktimeout ); |
| 81 |
|
83 |
|
| 82 |
# Checks policy laid out by SCOAllowCheckin, defaults to 'on' if preference is undefined |
84 |
# Checks policy laid out by SCOAllowCheckin, defaults to 'on' if preference is undefined |
| 83 |
my $allowselfcheckreturns = 1; |
85 |
my $allowselfcheckreturns = 1; |
| 84 |
if (defined C4::Context->preference('SCOAllowCheckin')) { |
86 |
if ( defined C4::Context->preference('SCOAllowCheckin') ) { |
| 85 |
$allowselfcheckreturns = C4::Context->preference('SCOAllowCheckin'); |
87 |
$allowselfcheckreturns = C4::Context->preference('SCOAllowCheckin'); |
| 86 |
} |
88 |
} |
| 87 |
|
89 |
|
|
Lines 97-147
my ( $op, $patronlogin, $patronpw, $barcodestr, $confirmed, $newissues, $load_ch
Link Here
|
| 97 |
); |
99 |
); |
| 98 |
|
100 |
|
| 99 |
my $jwt = $query->cookie('JWT'); |
101 |
my $jwt = $query->cookie('JWT'); |
|
|
102 |
|
| 100 |
#FIXME: This needs to be changed to a POSTed logout... |
103 |
#FIXME: This needs to be changed to a POSTed logout... |
| 101 |
if ($op eq "logout") { |
104 |
if ( $op eq "logout" ) { |
| 102 |
$template->param( loggedout => 1 ); |
105 |
$template->param( loggedout => 1 ); |
| 103 |
$query->param( patronlogin => undef, patronpw => undef ); |
106 |
$query->param( patronlogin => undef, patronpw => undef ); |
| 104 |
undef $jwt; |
107 |
undef $jwt; |
| 105 |
} |
108 |
} |
| 106 |
|
109 |
|
| 107 |
my $barcodes = []; |
110 |
my $barcodes = []; |
| 108 |
if ( $barcodestr ) { |
111 |
if ($barcodestr) { |
| 109 |
push @$barcodes, split( /\s\n/, $barcodestr ); |
112 |
push @$barcodes, split( /\s\n/, $barcodestr ); |
| 110 |
$barcodes = [ map { $_ =~ /^\s*$/ ? () : barcodedecode( $_ ) } @$barcodes ]; |
113 |
$barcodes = [ map { $_ =~ /^\s*$/ ? () : barcodedecode($_) } @$barcodes ]; |
| 111 |
} |
114 |
} |
| 112 |
|
115 |
|
| 113 |
my @newissueslist = split /,/, $newissues; |
116 |
my @newissueslist = split /,/, $newissues; |
| 114 |
my $issuenoconfirm = 1; #don't need to confirm on issue. |
117 |
my $issuenoconfirm = 1; #don't need to confirm on issue. |
| 115 |
my $issuer = Koha::Patrons->find( $issuerid )->unblessed; |
118 |
my $issuer = Koha::Patrons->find($issuerid)->unblessed; |
| 116 |
|
119 |
|
| 117 |
my $patronid = $jwt ? Koha::Token->new->decode_jwt({ token => $jwt }) : undef; |
120 |
my $patronid = $jwt ? Koha::Token->new->decode_jwt( { token => $jwt } ) : undef; |
| 118 |
unless ( $patronid ) { |
121 |
unless ($patronid) { |
| 119 |
if ( C4::Context->preference('SelfCheckoutByLogin') ) { |
122 |
if ( C4::Context->preference('SelfCheckoutByLogin') ) { |
| 120 |
( undef, $patronid ) = checkpw( $patronlogin, $patronpw ); |
123 |
( undef, $patronid ) = checkpw( $patronlogin, $patronpw ); |
| 121 |
} |
124 |
} else { # People should not do that unless they know what they are doing! |
| 122 |
else { # People should not do that unless they know what they are doing! |
125 |
# SelfCheckAllowByIPRanges MUST be configured |
| 123 |
# SelfCheckAllowByIPRanges MUST be configured |
|
|
| 124 |
$patronid = $query->param('patronid'); |
126 |
$patronid = $query->param('patronid'); |
| 125 |
} |
127 |
} |
| 126 |
$jwt = Koha::Token->new->generate_jwt({ id => $patronid }) if $patronid; |
128 |
$jwt = Koha::Token->new->generate_jwt( { id => $patronid } ) if $patronid; |
| 127 |
} |
129 |
} |
| 128 |
|
130 |
|
| 129 |
my $patron; |
131 |
my $patron; |
| 130 |
if ( $patronid ) { |
132 |
if ($patronid) { |
| 131 |
Koha::Plugins->call( 'patron_barcode_transform', \$patronid ); |
133 |
Koha::Plugins->call( 'patron_barcode_transform', \$patronid ); |
| 132 |
$patron = Koha::Patrons->find( { cardnumber => $patronid } ); |
134 |
$patron = Koha::Patrons->find( { cardnumber => $patronid } ); |
| 133 |
} |
135 |
} |
| 134 |
|
136 |
|
| 135 |
undef $jwt unless $patron; |
137 |
undef $jwt unless $patron; |
| 136 |
|
138 |
|
| 137 |
my $branch = $issuer->{branchcode}; |
139 |
my $branch = $issuer->{branchcode}; |
| 138 |
my $confirm_required = 0; |
140 |
my $confirm_required = 0; |
| 139 |
my $return_only = 0; |
141 |
my $return_only = 0; |
| 140 |
|
142 |
|
| 141 |
my $batch_checkouts_allowed; |
143 |
my $batch_checkouts_allowed; |
| 142 |
if ( C4::Context->preference('BatchCheckouts') and $patron ) { |
144 |
if ( C4::Context->preference('BatchCheckouts') and $patron ) { |
| 143 |
my @batch_category_codes = split ',', C4::Context->preference('BatchCheckoutsValidCategories'); |
145 |
my @batch_category_codes = split ',', C4::Context->preference('BatchCheckoutsValidCategories'); |
| 144 |
my $categorycode = $patron->categorycode; |
146 |
my $categorycode = $patron->categorycode; |
| 145 |
if ( $categorycode && grep { $_ eq $categorycode } @batch_category_codes ) { |
147 |
if ( $categorycode && grep { $_ eq $categorycode } @batch_category_codes ) { |
| 146 |
$batch_checkouts_allowed = 1; |
148 |
$batch_checkouts_allowed = 1; |
| 147 |
} |
149 |
} |
|
Lines 150-336
if ( C4::Context->preference('BatchCheckouts') and $patron ) {
Link Here
|
| 150 |
if ( $patron && $op eq "cud-returnbook" && $allowselfcheckreturns ) { |
152 |
if ( $patron && $op eq "cud-returnbook" && $allowselfcheckreturns ) { |
| 151 |
my $success = 1; |
153 |
my $success = 1; |
| 152 |
|
154 |
|
| 153 |
foreach my $barcode ( @$barcodes ) { |
155 |
foreach my $barcode (@$barcodes) { |
| 154 |
my $item = Koha::Items->find( { barcode => $barcode } ); |
156 |
my $item = Koha::Items->find( { barcode => $barcode } ); |
| 155 |
if ( $success && C4::Context->preference("CircConfirmItemParts") ) { |
157 |
if ( $success && C4::Context->preference("CircConfirmItemParts") ) { |
| 156 |
if ( defined($item) |
158 |
if ( defined($item) |
| 157 |
&& $item->materials ) |
159 |
&& $item->materials ) |
| 158 |
{ |
160 |
{ |
| 159 |
$success = 0; |
161 |
$success = 0; |
| 160 |
} |
|
|
| 161 |
} |
| 162 |
|
| 163 |
if ($success) { |
| 164 |
# Patron cannot checkin an item they don't own |
| 165 |
$success = 0 |
| 166 |
unless $patron->checkouts->find( { itemnumber => $item->itemnumber } ); |
| 167 |
} |
| 168 |
|
| 169 |
if ( $success ) { |
| 170 |
($success) = AddReturn( $barcode, $branch ) |
| 171 |
} |
| 172 |
|
| 173 |
$template->param( |
| 174 |
returned => $success, |
| 175 |
barcode => $barcode |
| 176 |
); |
| 177 |
} # foreach barcode in barcodes |
| 178 |
} |
| 179 |
|
| 180 |
elsif ( $patron && ( $op eq 'cud-checkout' ) ) { |
| 181 |
my @failed_checkouts; |
| 182 |
my @confirm_checkouts; |
| 183 |
foreach my $barcode ( @$barcodes ) { |
| 184 |
my $item = Koha::Items->find( { barcode => $barcode } ); |
| 185 |
my $impossible = {}; |
| 186 |
my $needconfirm = {}; |
| 187 |
( $impossible, $needconfirm ) = CanBookBeIssued( |
| 188 |
$patron, |
| 189 |
$barcode, |
| 190 |
undef, |
| 191 |
0, |
| 192 |
C4::Context->preference("AllowItemsOnHoldCheckoutSCO") |
| 193 |
); |
| 194 |
my $issue_error; |
| 195 |
if ( $confirm_required = scalar keys %$needconfirm ) { |
| 196 |
for my $error ( qw( UNKNOWN_BARCODE max_loans_allowed ISSUED_TO_ANOTHER NO_MORE_RENEWALS NOT_FOR_LOAN DEBT WTHDRAWN RESTRICTED RESERVED ITEMNOTSAMEBRANCH EXPIRED DEBARRED CARD_LOST GNA INVALID_DATE UNKNOWN_BARCODE TOO_MANY DEBT_GUARANTEES DEBT_GUARANTORS USERBLOCKEDOVERDUE PATRON_CANT PREVISSUE NOT_FOR_LOAN_FORCING ITEM_LOST ADDITIONAL_MATERIALS ) ) { |
| 197 |
if ( $needconfirm->{$error} ) { |
| 198 |
$issue_error = $error; |
| 199 |
$confirmed = 0; |
| 200 |
last; |
| 201 |
} |
162 |
} |
| 202 |
} |
163 |
} |
| 203 |
} |
|
|
| 204 |
|
164 |
|
| 205 |
if (scalar keys %$impossible) { |
165 |
if ($success) { |
| 206 |
my $issue_error = (keys %$impossible)[0]; # FIXME This is wrong, we assume only one error and keys are not ordered |
|
|
| 207 |
my $title = ( $item ) ? $item->biblio->title : ''; |
| 208 |
|
166 |
|
| 209 |
my $failed_checkout = { |
167 |
# Patron cannot checkin an item they don't own |
| 210 |
"circ_error_$issue_error" => 1, |
168 |
$success = 0 |
| 211 |
title => $title, |
169 |
unless $patron->checkouts->find( { itemnumber => $item->itemnumber } ); |
| 212 |
}; |
|
|
| 213 |
|
| 214 |
if ($issue_error eq 'DEBT') { |
| 215 |
$failed_checkout->{DEBT} = $impossible->{DEBT}; |
| 216 |
} |
| 217 |
if ( $issue_error eq "NO_MORE_RENEWALS" ) { |
| 218 |
$return_only = 1; |
| 219 |
$failed_checkout->{barcode} = $barcode; |
| 220 |
$failed_checkout->{returnitem} = 1; |
| 221 |
} |
170 |
} |
| 222 |
|
171 |
|
| 223 |
push @failed_checkouts, $failed_checkout; |
172 |
if ($success) { |
|
|
173 |
($success) = AddReturn( $barcode, $branch ); |
| 174 |
} |
| 224 |
|
175 |
|
| 225 |
$template->param( |
176 |
$template->param( |
| 226 |
hide_main => 1, |
177 |
returned => $success, |
|
|
178 |
barcode => $barcode |
| 227 |
); |
179 |
); |
| 228 |
} elsif ( $needconfirm->{RENEW_ISSUE} ) { |
180 |
} # foreach barcode in barcodes |
| 229 |
my $confirm_checkout = { |
181 |
|
| 230 |
renew => 1, |
182 |
} elsif ( $patron && ( $op eq 'cud-checkout' ) ) { |
| 231 |
barcode => $barcode, |
183 |
my @failed_checkouts; |
| 232 |
confirm => $item->biblio->title, |
184 |
my @confirm_checkouts; |
| 233 |
confirm_renew_issue => 1, |
185 |
foreach my $barcode (@$barcodes) { |
| 234 |
}; |
186 |
my $item = Koha::Items->find( { barcode => $barcode } ); |
| 235 |
push @confirm_checkouts, $confirm_checkout; |
187 |
my $impossible = {}; |
| 236 |
$template->param( |
188 |
my $needconfirm = {}; |
| 237 |
hide_main => 1, |
189 |
( $impossible, $needconfirm ) = CanBookBeIssued( |
|
|
190 |
$patron, |
| 191 |
$barcode, |
| 192 |
undef, |
| 193 |
0, |
| 194 |
C4::Context->preference("AllowItemsOnHoldCheckoutSCO") |
| 238 |
); |
195 |
); |
| 239 |
} elsif ( $confirm_required && !$confirmed ) { |
196 |
my $issue_error; |
| 240 |
my $failed_checkout = { |
197 |
if ( $confirm_required = scalar keys %$needconfirm ) { |
| 241 |
"circ_error_$issue_error" => 1, |
198 |
for my $error ( |
| 242 |
}; |
199 |
qw( UNKNOWN_BARCODE max_loans_allowed ISSUED_TO_ANOTHER NO_MORE_RENEWALS NOT_FOR_LOAN DEBT WTHDRAWN RESTRICTED RESERVED ITEMNOTSAMEBRANCH EXPIRED DEBARRED CARD_LOST GNA INVALID_DATE UNKNOWN_BARCODE TOO_MANY DEBT_GUARANTEES DEBT_GUARANTORS USERBLOCKEDOVERDUE PATRON_CANT PREVISSUE NOT_FOR_LOAN_FORCING ITEM_LOST ADDITIONAL_MATERIALS ) |
| 243 |
if ($issue_error eq 'DEBT') { |
200 |
) |
| 244 |
$failed_checkout->{DEBT} = $needconfirm->{DEBT}; |
201 |
{ |
| 245 |
} |
202 |
if ( $needconfirm->{$error} ) { |
| 246 |
push @failed_checkouts, $failed_checkout; |
203 |
$issue_error = $error; |
| 247 |
} else { |
204 |
$confirmed = 0; |
| 248 |
if ( $confirmed || $issuenoconfirm ) { # we'll want to call getpatroninfo again to get updated issues. |
205 |
last; |
| 249 |
my ( $hold_existed, $item ); |
206 |
} |
| 250 |
if ( C4::Context->preference('HoldFeeMode') eq 'any_time_is_collected' ) { |
|
|
| 251 |
# There is no easy way to know if the patron has been charged for this item. |
| 252 |
# So we check if a hold existed for this item before the check in |
| 253 |
$item = Koha::Items->find({ barcode => $barcode }); |
| 254 |
$hold_existed = Koha::Holds->search( |
| 255 |
{ |
| 256 |
-and => { |
| 257 |
borrowernumber => $patron->borrowernumber, |
| 258 |
-or => { |
| 259 |
biblionumber => $item->biblionumber, |
| 260 |
itemnumber => $item->itemnumber |
| 261 |
} |
| 262 |
} |
| 263 |
} |
| 264 |
)->count; |
| 265 |
} |
207 |
} |
|
|
208 |
} |
| 266 |
|
209 |
|
| 267 |
my $new_issue = AddIssue( $patron, $barcode ); |
210 |
if ( scalar keys %$impossible ) { |
| 268 |
$template->param( issued => 1, new_issue => $new_issue ); |
211 |
my $issue_error = |
| 269 |
push @newissueslist, $barcode unless ( grep /^$barcode$/, @newissueslist ); |
212 |
( keys %$impossible )[0]; # FIXME This is wrong, we assume only one error and keys are not ordered |
|
|
213 |
my $title = ($item) ? $item->biblio->title : ''; |
| 270 |
|
214 |
|
| 271 |
if ( $hold_existed ) { |
215 |
my $failed_checkout = { |
| 272 |
my $dtf = Koha::Database->new->schema->storage->datetime_parser; |
216 |
"circ_error_$issue_error" => 1, |
| 273 |
$template->param( |
217 |
title => $title, |
| 274 |
# If the hold existed before the check in, let's confirm that the charge line exists |
218 |
}; |
| 275 |
# Note that this should not be needed but since we do not have proper exception handling here we do it this way |
219 |
|
| 276 |
patron_has_hold_fee => Koha::Account::Lines->search( |
220 |
if ( $issue_error eq 'DEBT' ) { |
| 277 |
{ |
221 |
$failed_checkout->{DEBT} = $impossible->{DEBT}; |
| 278 |
borrowernumber => $patron->borrowernumber, |
|
|
| 279 |
debit_type_code => 'RESERVE', |
| 280 |
description => $item->biblio->title, |
| 281 |
date => $dtf->format_date(dt_from_string) |
| 282 |
} |
| 283 |
)->count, |
| 284 |
); |
| 285 |
} |
222 |
} |
| 286 |
} else { |
223 |
if ( $issue_error eq "NO_MORE_RENEWALS" ) { |
| 287 |
$confirm_required = 1; |
224 |
$return_only = 1; |
|
|
225 |
$failed_checkout->{barcode} = $barcode; |
| 226 |
$failed_checkout->{returnitem} = 1; |
| 227 |
} |
| 228 |
|
| 229 |
push @failed_checkouts, $failed_checkout; |
| 230 |
|
| 231 |
$template->param( |
| 232 |
hide_main => 1, |
| 233 |
); |
| 234 |
} elsif ( $needconfirm->{RENEW_ISSUE} ) { |
| 288 |
my $confirm_checkout = { |
235 |
my $confirm_checkout = { |
| 289 |
confirm => "Issuing title: " . $item->biblio->title, |
236 |
renew => 1, |
| 290 |
barcode => $barcode, |
237 |
barcode => $barcode, |
|
|
238 |
confirm => $item->biblio->title, |
| 239 |
confirm_renew_issue => 1, |
| 291 |
}; |
240 |
}; |
| 292 |
push @confirm_checkouts, $confirm_checkout; |
241 |
push @confirm_checkouts, $confirm_checkout; |
| 293 |
$template->param( |
242 |
$template->param( |
| 294 |
hide_main => 1, |
243 |
hide_main => 1, |
| 295 |
); |
244 |
); |
|
|
245 |
} elsif ( $confirm_required && !$confirmed ) { |
| 246 |
my $failed_checkout = { |
| 247 |
"circ_error_$issue_error" => 1, |
| 248 |
}; |
| 249 |
if ( $issue_error eq 'DEBT' ) { |
| 250 |
$failed_checkout->{DEBT} = $needconfirm->{DEBT}; |
| 251 |
} |
| 252 |
push @failed_checkouts, $failed_checkout; |
| 253 |
} else { |
| 254 |
if ( $confirmed || $issuenoconfirm ) { # we'll want to call getpatroninfo again to get updated issues. |
| 255 |
my ( $hold_existed, $item ); |
| 256 |
if ( C4::Context->preference('HoldFeeMode') eq 'any_time_is_collected' ) { |
| 257 |
|
| 258 |
# There is no easy way to know if the patron has been charged for this item. |
| 259 |
# So we check if a hold existed for this item before the check in |
| 260 |
$item = Koha::Items->find( { barcode => $barcode } ); |
| 261 |
$hold_existed = Koha::Holds->search( |
| 262 |
{ |
| 263 |
-and => { |
| 264 |
borrowernumber => $patron->borrowernumber, |
| 265 |
-or => { |
| 266 |
biblionumber => $item->biblionumber, |
| 267 |
itemnumber => $item->itemnumber |
| 268 |
} |
| 269 |
} |
| 270 |
} |
| 271 |
)->count; |
| 272 |
} |
| 273 |
|
| 274 |
my $new_issue = AddIssue( $patron, $barcode ); |
| 275 |
$template->param( issued => 1, new_issue => $new_issue ); |
| 276 |
push @newissueslist, $barcode unless ( grep /^$barcode$/, @newissueslist ); |
| 277 |
|
| 278 |
if ($hold_existed) { |
| 279 |
my $dtf = Koha::Database->new->schema->storage->datetime_parser; |
| 280 |
$template->param( |
| 281 |
|
| 282 |
# If the hold existed before the check in, let's confirm that the charge line exists |
| 283 |
# Note that this should not be needed but since we do not have proper exception handling here we do it this way |
| 284 |
patron_has_hold_fee => Koha::Account::Lines->search( |
| 285 |
{ |
| 286 |
borrowernumber => $patron->borrowernumber, |
| 287 |
debit_type_code => 'RESERVE', |
| 288 |
description => $item->biblio->title, |
| 289 |
date => $dtf->format_date(dt_from_string) |
| 290 |
} |
| 291 |
)->count, |
| 292 |
); |
| 293 |
} |
| 294 |
} else { |
| 295 |
$confirm_required = 1; |
| 296 |
my $confirm_checkout = { |
| 297 |
confirm => "Issuing title: " . $item->biblio->title, |
| 298 |
barcode => $barcode, |
| 299 |
}; |
| 300 |
push @confirm_checkouts, $confirm_checkout; |
| 301 |
$template->param( |
| 302 |
hide_main => 1, |
| 303 |
); |
| 304 |
} |
| 296 |
} |
305 |
} |
| 297 |
} |
306 |
} # foreach barcode in barcodes |
| 298 |
} # foreach barcode in barcodes |
|
|
| 299 |
|
307 |
|
| 300 |
$template->param( |
308 |
$template->param( |
| 301 |
impossible => \@failed_checkouts, |
309 |
impossible => \@failed_checkouts, |
| 302 |
confirm => \@confirm_checkouts, |
310 |
confirm => \@confirm_checkouts, |
| 303 |
); |
311 |
); |
| 304 |
} # $op |
312 |
} # $op |
| 305 |
|
313 |
|
| 306 |
if ( $patron && ( $op eq 'cud-renew' ) ) { |
314 |
if ( $patron && ( $op eq 'cud-renew' ) ) { |
| 307 |
foreach my $barcode ( @$barcodes ) { |
315 |
foreach my $barcode (@$barcodes) { |
| 308 |
my $item = Koha::Items->find({ barcode => $barcode }); |
316 |
my $item = Koha::Items->find( { barcode => $barcode } ); |
| 309 |
|
317 |
|
| 310 |
if ( $patron->checkouts->find( { itemnumber => $item->itemnumber } ) ) { |
318 |
if ( $patron->checkouts->find( { itemnumber => $item->itemnumber } ) ) { |
| 311 |
my ($status,$renewerror) = CanBookBeRenewed( $patron, $item->checkout ); |
319 |
my ( $status, $renewerror ) = CanBookBeRenewed( $patron, $item->checkout ); |
| 312 |
if ($status) { |
320 |
if ($status) { |
| 313 |
AddRenewal( |
321 |
AddRenewal( |
| 314 |
{ |
322 |
{ |
| 315 |
borrowernumber => $patron->borrowernumber, |
323 |
borrowernumber => $patron->borrowernumber, |
| 316 |
itemnumber => $item->itemnumber, |
324 |
itemnumber => $item->itemnumber, |
| 317 |
seen => 1 |
325 |
seen => 1 |
| 318 |
} |
326 |
} |
| 319 |
); |
327 |
); |
| 320 |
push @newissueslist, $barcode; |
328 |
push @newissueslist, $barcode; |
| 321 |
$template->param( |
329 |
$template->param( |
| 322 |
renewed => 1, |
330 |
renewed => 1, |
| 323 |
barcode => $barcode |
331 |
barcode => $barcode |
| 324 |
); |
332 |
); |
|
|
333 |
} |
| 334 |
} else { |
| 335 |
$template->param( renewed => 0 ); |
| 325 |
} |
336 |
} |
| 326 |
} else { |
337 |
} # foreach barcode in barcodes |
| 327 |
$template->param( renewed => 0 ); |
|
|
| 328 |
} |
| 329 |
} # foreach barcode in barcodes |
| 330 |
} |
338 |
} |
| 331 |
|
339 |
|
| 332 |
if ( $patron) { |
340 |
if ($patron) { |
| 333 |
my $borrowername = sprintf "%s %s", ($patron->firstname || ''), ($patron->surname || ''); |
341 |
my $borrowername = sprintf "%s %s", ( $patron->firstname || '' ), ( $patron->surname || '' ); |
| 334 |
my @checkouts; |
342 |
my @checkouts; |
| 335 |
my $pending_checkouts = $patron->pending_checkouts; |
343 |
my $pending_checkouts = $patron->pending_checkouts; |
| 336 |
if ( C4::Context->preference('SCOLoadCheckoutsByDefault') || $load_checkouts ) { |
344 |
if ( C4::Context->preference('SCOLoadCheckoutsByDefault') || $load_checkouts ) { |
|
Lines 349-402
if ( $patron) {
Link Here
|
| 349 |
m/priority/ and $show_priority = 1; |
357 |
m/priority/ and $show_priority = 1; |
| 350 |
} |
358 |
} |
| 351 |
|
359 |
|
| 352 |
my $account = $patron->account; |
360 |
my $account = $patron->account; |
| 353 |
my $total = $account->balance; |
361 |
my $total = $account->balance; |
| 354 |
my $accountlines = $account->lines; |
362 |
my $accountlines = $account->lines; |
| 355 |
|
363 |
|
| 356 |
my $holds = $patron->holds; |
364 |
my $holds = $patron->holds; |
| 357 |
my $waiting_holds_count = 0; |
365 |
my $waiting_holds_count = 0; |
| 358 |
|
366 |
|
| 359 |
while(my $hold = $holds->next) { |
367 |
while ( my $hold = $holds->next ) { |
| 360 |
$waiting_holds_count++ if $hold->is_waiting; |
368 |
$waiting_holds_count++ if $hold->is_waiting; |
| 361 |
} |
369 |
} |
| 362 |
|
370 |
|
| 363 |
$template->param( |
371 |
$template->param( |
| 364 |
validuser => 1, |
372 |
validuser => 1, |
| 365 |
borrowername => $borrowername, |
373 |
borrowername => $borrowername, |
| 366 |
issues_count => scalar(@checkouts) || $pending_checkouts->count(), |
374 |
issues_count => scalar(@checkouts) || $pending_checkouts->count(), |
| 367 |
ISSUES => \@checkouts, |
375 |
ISSUES => \@checkouts, |
| 368 |
HOLDS => $holds, |
376 |
HOLDS => $holds, |
| 369 |
newissues => join(',',@newissueslist), |
377 |
newissues => join( ',', @newissueslist ), |
| 370 |
patronlogin => $patronlogin, |
378 |
patronlogin => $patronlogin, |
| 371 |
patronpw => $patronpw, |
379 |
patronpw => $patronpw, |
| 372 |
waiting_holds_count => $waiting_holds_count, |
380 |
waiting_holds_count => $waiting_holds_count, |
| 373 |
noitemlinks => 1 , |
381 |
noitemlinks => 1, |
| 374 |
load_checkouts => $load_checkouts, |
382 |
load_checkouts => $load_checkouts, |
| 375 |
borrowernumber => $patron->borrowernumber, |
383 |
borrowernumber => $patron->borrowernumber, |
| 376 |
SuspendHoldsOpac => C4::Context->preference('SuspendHoldsOpac'), |
384 |
SuspendHoldsOpac => C4::Context->preference('SuspendHoldsOpac'), |
| 377 |
AutoResumeSuspendedHolds => C4::Context->preference('AutoResumeSuspendedHolds'), |
385 |
AutoResumeSuspendedHolds => C4::Context->preference('AutoResumeSuspendedHolds'), |
| 378 |
howpriority => $show_priority, |
386 |
howpriority => $show_priority, |
| 379 |
ACCOUNT_LINES => $accountlines, |
387 |
ACCOUNT_LINES => $accountlines, |
| 380 |
total => $total, |
388 |
total => $total, |
| 381 |
batch_checkouts_allowed => $batch_checkouts_allowed, |
389 |
batch_checkouts_allowed => $batch_checkouts_allowed, |
| 382 |
); |
390 |
); |
| 383 |
|
391 |
|
| 384 |
my $patron_messages = Koha::Patron::Messages->search( |
392 |
my $patron_messages = Koha::Patron::Messages->search( |
| 385 |
{ |
393 |
{ |
| 386 |
borrowernumber => $patron->borrowernumber, |
394 |
borrowernumber => $patron->borrowernumber, |
| 387 |
message_type => 'B', |
395 |
message_type => 'B', |
| 388 |
} |
396 |
} |
| 389 |
); |
397 |
); |
| 390 |
$template->param( |
398 |
$template->param( |
| 391 |
patron_messages => $patron_messages, |
399 |
patron_messages => $patron_messages, |
| 392 |
opacnote => $patron->opacnote, |
400 |
opacnote => $patron->opacnote, |
| 393 |
); |
401 |
); |
| 394 |
|
402 |
|
| 395 |
$template->param( |
403 |
$template->param( |
| 396 |
nofines => 1, |
404 |
nofines => 1, |
| 397 |
|
405 |
|
| 398 |
); |
406 |
); |
| 399 |
if (C4::Context->preference('ShowPatronImageInWebBasedSelfCheck')) { |
407 |
if ( C4::Context->preference('ShowPatronImageInWebBasedSelfCheck') ) { |
| 400 |
my $patron_image = $patron->image; |
408 |
my $patron_image = $patron->image; |
| 401 |
$template->param( |
409 |
$template->param( |
| 402 |
display_patron_image => 1, |
410 |
display_patron_image => 1, |
|
Lines 404-421
if ( $patron) {
Link Here
|
| 404 |
} |
412 |
} |
| 405 |
} else { |
413 |
} else { |
| 406 |
$template->param( |
414 |
$template->param( |
| 407 |
nouser => $patronid, |
415 |
nouser => $patronid, |
| 408 |
); |
416 |
); |
| 409 |
} |
417 |
} |
| 410 |
my $cookie_mgr = Koha::CookieManager->new; |
418 |
my $cookie_mgr = Koha::CookieManager->new; |
| 411 |
$cookie = $cookie_mgr->replace_in_list( $cookie, $query->cookie( |
419 |
$cookie = $cookie_mgr->replace_in_list( |
| 412 |
-name => 'JWT', |
420 |
$cookie, |
| 413 |
-value => $jwt // '', |
421 |
$query->cookie( |
| 414 |
-expires => $jwt ? '+1d' : '', |
422 |
-name => 'JWT', |
| 415 |
-HttpOnly => 1, |
423 |
-value => $jwt // '', |
| 416 |
-secure => ( C4::Context->https_enabled() ? 1 : 0 ), |
424 |
-expires => $jwt ? '+1d' : '', |
| 417 |
-sameSite => 'Lax' |
425 |
-HttpOnly => 1, |
| 418 |
)); |
426 |
-secure => ( C4::Context->https_enabled() ? 1 : 0 ), |
| 419 |
$template->param(patronid => $patronid); |
427 |
-sameSite => 'Lax' |
|
|
428 |
) |
| 429 |
); |
| 430 |
$template->param( patronid => $patronid ); |
| 420 |
|
431 |
|
| 421 |
output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 }; |
432 |
output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 }; |
| 422 |
- |
|
|