Lines 25-43
Link Here
|
25 |
# FIXME There are too many calls to Koha::Patrons->find in this script |
25 |
# FIXME There are too many calls to Koha::Patrons->find in this script |
26 |
|
26 |
|
27 |
use Modern::Perl; |
27 |
use Modern::Perl; |
28 |
use CGI qw ( -utf8 ); |
28 |
use CGI qw ( -utf8 ); |
29 |
use URI::Escape qw( uri_escape_utf8 ); |
29 |
use URI::Escape qw( uri_escape_utf8 ); |
30 |
use DateTime; |
30 |
use DateTime; |
31 |
use DateTime::Duration; |
31 |
use DateTime::Duration; |
32 |
use Scalar::Util qw( blessed looks_like_number ); |
32 |
use Scalar::Util qw( blessed looks_like_number ); |
33 |
use Try::Tiny; |
33 |
use Try::Tiny; |
34 |
use C4::Output qw( output_and_exit_if_error output_and_exit output_html_with_http_headers ); |
34 |
use C4::Output qw( output_and_exit_if_error output_and_exit output_html_with_http_headers ); |
35 |
use C4::Auth qw( get_session get_template_and_user ); |
35 |
use C4::Auth qw( get_session get_template_and_user ); |
36 |
use C4::Koha; |
36 |
use C4::Koha; |
37 |
use C4::Circulation qw( barcodedecode CanBookBeIssued AddIssue AddReturn ); |
37 |
use C4::Circulation qw( barcodedecode CanBookBeIssued AddIssue AddReturn ); |
38 |
use C4::Members; |
38 |
use C4::Members; |
39 |
use C4::Biblio qw( TransformMarcToKoha ); |
39 |
use C4::Biblio qw( TransformMarcToKoha ); |
40 |
use C4::Search qw( new_record_from_zebra ); |
40 |
use C4::Search qw( new_record_from_zebra ); |
41 |
use C4::Reserves qw( ModReserveAffect ); |
41 |
use C4::Reserves qw( ModReserveAffect ); |
42 |
use Koha::Holds; |
42 |
use Koha::Holds; |
43 |
use C4::Context; |
43 |
use C4::Context; |
Lines 69-81
my $borrowernumber = $query->param('borrowernumber');
Link Here
|
69 |
my $barcodes = []; |
69 |
my $barcodes = []; |
70 |
my $barcode = $query->param('barcode'); |
70 |
my $barcode = $query->param('barcode'); |
71 |
|
71 |
|
72 |
|
|
|
73 |
# Barcode given by user could be '0' |
72 |
# Barcode given by user could be '0' |
74 |
if ( $barcode || ( defined($barcode) && $barcode eq '0' ) ) { |
73 |
if ( $barcode || ( defined($barcode) && $barcode eq '0' ) ) { |
75 |
$barcodes = [ $barcode ]; |
74 |
$barcodes = [$barcode]; |
76 |
} else { |
75 |
} else { |
77 |
my $filefh = $query->upload('uploadfile'); |
76 |
my $filefh = $query->upload('uploadfile'); |
78 |
if ( $filefh ) { |
77 |
if ($filefh) { |
79 |
while ( my $content = <$filefh> ) { |
78 |
while ( my $content = <$filefh> ) { |
80 |
$content =~ s/[\r\n]*$//g; |
79 |
$content =~ s/[\r\n]*$//g; |
81 |
push @$barcodes, $content if $content; |
80 |
push @$barcodes, $content if $content; |
Lines 90-102
if ( $barcode || ( defined($barcode) && $barcode eq '0' ) ) {
Link Here
|
90 |
$barcodes = [ uniq @$barcodes ]; |
89 |
$barcodes = [ uniq @$barcodes ]; |
91 |
|
90 |
|
92 |
my $template_name = q|circ/circulation.tt|; |
91 |
my $template_name = q|circ/circulation.tt|; |
93 |
my $patron = $borrowernumber ? Koha::Patrons->find( $borrowernumber ) : undef; |
92 |
my $patron = $borrowernumber ? Koha::Patrons->find($borrowernumber) : undef; |
94 |
my $batch = $query->param('batch'); |
93 |
my $batch = $query->param('batch'); |
95 |
my $batch_allowed = 0; |
94 |
my $batch_allowed = 0; |
96 |
if ( $batch && C4::Context->preference('BatchCheckouts') ) { |
95 |
if ( $batch && C4::Context->preference('BatchCheckouts') ) { |
97 |
$template_name = q|circ/circulation_batch_checkouts.tt|; |
96 |
$template_name = q|circ/circulation_batch_checkouts.tt|; |
98 |
my @batch_category_codes = split ',', C4::Context->preference('BatchCheckoutsValidCategories'); |
97 |
my @batch_category_codes = split ',', C4::Context->preference('BatchCheckoutsValidCategories'); |
99 |
my $categorycode = $patron->categorycode; |
98 |
my $categorycode = $patron->categorycode; |
100 |
if ( $categorycode && grep { $_ eq $categorycode } @batch_category_codes ) { |
99 |
if ( $categorycode && grep { $_ eq $categorycode } @batch_category_codes ) { |
101 |
$batch_allowed = 1; |
100 |
$batch_allowed = 1; |
102 |
} else { |
101 |
} else { |
Lines 104-115
if ( $batch && C4::Context->preference('BatchCheckouts') ) {
Link Here
|
104 |
} |
103 |
} |
105 |
} |
104 |
} |
106 |
|
105 |
|
107 |
my ( $template, $loggedinuser, $cookie ) = get_template_and_user ( |
106 |
my ( $template, $loggedinuser, $cookie ) = get_template_and_user( |
108 |
{ |
107 |
{ |
109 |
template_name => $template_name, |
108 |
template_name => $template_name, |
110 |
query => $query, |
109 |
query => $query, |
111 |
type => "intranet", |
110 |
type => "intranet", |
112 |
flagsrequired => { circulate => 'circulate_remaining_permissions' }, |
111 |
flagsrequired => { circulate => 'circulate_remaining_permissions' }, |
113 |
} |
112 |
} |
114 |
); |
113 |
); |
115 |
|
114 |
|
Lines 135-141
if ( C4::Context->preference("AutoSwitchPatron") && $barcode ) {
Link Here
|
135 |
undef $barcode; |
134 |
undef $barcode; |
136 |
undef $borrowernumber; |
135 |
undef $borrowernumber; |
137 |
undef $patron; |
136 |
undef $patron; |
138 |
$barcodes = []; |
137 |
$barcodes = []; |
139 |
$autoswitched = 1; |
138 |
$autoswitched = 1; |
140 |
} |
139 |
} |
141 |
} |
140 |
} |
Lines 154-170
if ( $op eq 'cud-confirm_hold' && $query->param('confirm_hold') ) {
Link Here
|
154 |
ModReserveAffect( $hold_itemnumber, $hold_borrowernumber, $diffBranchSend, $reserve_id, $desk_id ); |
153 |
ModReserveAffect( $hold_itemnumber, $hold_borrowernumber, $diffBranchSend, $reserve_id, $desk_id ); |
155 |
} |
154 |
} |
156 |
|
155 |
|
157 |
|
156 |
my $logged_in_user = Koha::Patrons->find($loggedinuser); |
158 |
my $logged_in_user = Koha::Patrons->find( $loggedinuser ); |
|
|
159 |
|
157 |
|
160 |
my $force_allow_issue = $query->param('forceallow') || 0; |
158 |
my $force_allow_issue = $query->param('forceallow') || 0; |
161 |
if (!C4::Auth::haspermission( $userenv->{id} , { circulate => 'force_checkout' } )) { |
159 |
if ( !C4::Auth::haspermission( $userenv->{id}, { circulate => 'force_checkout' } ) ) { |
162 |
$force_allow_issue = 0; |
160 |
$force_allow_issue = 0; |
163 |
} |
161 |
} |
164 |
my $onsite_checkout = $query->param('onsite_checkout'); |
162 |
my $onsite_checkout = $query->param('onsite_checkout'); |
165 |
|
163 |
|
166 |
if (C4::Context->preference("OnSiteCheckoutAutoCheck") && $onsite_checkout eq "on") { |
164 |
if ( C4::Context->preference("OnSiteCheckoutAutoCheck") && $onsite_checkout eq "on" ) { |
167 |
$template->param(onsite_checkout => $onsite_checkout); |
165 |
$template->param( onsite_checkout => $onsite_checkout ); |
168 |
} |
166 |
} |
169 |
|
167 |
|
170 |
my @failedrenews = $query->multi_param('failedrenew'); # expected to be itemnumbers |
168 |
my @failedrenews = $query->multi_param('failedrenew'); # expected to be itemnumbers |
Lines 175-187
my @failedreturns = $query->multi_param('failedreturn');
Link Here
|
175 |
our %return_failed = (); |
173 |
our %return_failed = (); |
176 |
for (@failedreturns) { $return_failed{$_} = 1; } |
174 |
for (@failedreturns) { $return_failed{$_} = 1; } |
177 |
|
175 |
|
178 |
for my $barcode ( @$barcodes ) { |
176 |
for my $barcode (@$barcodes) { |
179 |
$barcode = barcodedecode( $barcode ) if $barcode; |
177 |
$barcode = barcodedecode($barcode) if $barcode; |
180 |
} |
178 |
} |
181 |
|
179 |
|
182 |
my $stickyduedate = $query->param('stickyduedate') || $session->param('stickyduedate'); |
180 |
my $stickyduedate = $query->param('stickyduedate') || $session->param('stickyduedate'); |
183 |
my $duedatespec = $query->param('duedatespec') || $session->param('stickyduedate'); |
181 |
my $duedatespec = $query->param('duedatespec') || $session->param('stickyduedate'); |
184 |
my $restoreduedatespec = $query->param('restoreduedatespec') || $duedatespec || $session->param('stickyduedate'); |
182 |
my $restoreduedatespec = $query->param('restoreduedatespec') || $duedatespec || $session->param('stickyduedate'); |
185 |
if ( $restoreduedatespec && $restoreduedatespec eq "highholds_empty" ) { |
183 |
if ( $restoreduedatespec && $restoreduedatespec eq "highholds_empty" ) { |
186 |
undef $restoreduedatespec; |
184 |
undef $restoreduedatespec; |
187 |
} |
185 |
} |
Lines 189-235
my $issueconfirmed = $query->param('issueconfirmed');
Link Here
|
189 |
my $cancelreserve = $query->param('cancelreserve'); |
187 |
my $cancelreserve = $query->param('cancelreserve'); |
190 |
my $cancel_recall = $query->param('cancel_recall'); |
188 |
my $cancel_recall = $query->param('cancel_recall'); |
191 |
my $recall_id = $query->param('recall_id'); |
189 |
my $recall_id = $query->param('recall_id'); |
192 |
my $debt_confirmed = $query->param('debt_confirmed') || 0; # Don't show the debt error dialog twice |
190 |
my $debt_confirmed = $query->param('debt_confirmed') || 0; # Don't show the debt error dialog twice |
193 |
my $charges = $query->param('charges') || q{}; |
191 |
my $charges = $query->param('charges') || q{}; |
194 |
|
192 |
|
195 |
# Check if stickyduedate is turned off |
193 |
# Check if stickyduedate is turned off |
196 |
if ( @$barcodes ) { |
194 |
if (@$barcodes) { |
|
|
195 |
|
197 |
# was stickyduedate loaded from session? |
196 |
# was stickyduedate loaded from session? |
198 |
if ( $stickyduedate && ! $query->param("stickyduedate") ) { |
197 |
if ( $stickyduedate && !$query->param("stickyduedate") ) { |
199 |
$session->clear( 'stickyduedate' ); |
198 |
$session->clear('stickyduedate'); |
200 |
$stickyduedate = $query->param('stickyduedate'); |
199 |
$stickyduedate = $query->param('stickyduedate'); |
201 |
$duedatespec = $query->param('duedatespec'); |
200 |
$duedatespec = $query->param('duedatespec'); |
202 |
} |
201 |
} |
203 |
$session->param('auto_renew', scalar $query->param('auto_renew')); |
202 |
$session->param( 'auto_renew', scalar $query->param('auto_renew') ); |
204 |
} |
203 |
} else { |
205 |
else { |
|
|
206 |
$session->clear('auto_renew'); |
204 |
$session->clear('auto_renew'); |
207 |
} |
205 |
} |
208 |
|
206 |
|
209 |
$template->param( auto_renew => $session->param('auto_renew') ); |
207 |
$template->param( auto_renew => $session->param('auto_renew') ); |
210 |
|
208 |
|
211 |
my ($datedue,$invalidduedate); |
209 |
my ( $datedue, $invalidduedate ); |
212 |
|
210 |
|
213 |
my $duedatespec_allow = C4::Context->preference('SpecifyDueDate'); |
211 |
my $duedatespec_allow = C4::Context->preference('SpecifyDueDate'); |
214 |
if( $onsite_checkout && !$duedatespec_allow ) { |
212 |
if ( $onsite_checkout && !$duedatespec_allow ) { |
215 |
$datedue = dt_from_string()->truncate(to => 'day'); |
213 |
$datedue = dt_from_string()->truncate( to => 'day' ); |
216 |
$datedue->set_hour(23); |
214 |
$datedue->set_hour(23); |
217 |
$datedue->set_minute(59); |
215 |
$datedue->set_minute(59); |
218 |
} elsif( $duedatespec_allow ) { |
216 |
} elsif ($duedatespec_allow) { |
219 |
if ( $duedatespec ) { |
217 |
if ($duedatespec) { |
220 |
$datedue = eval { dt_from_string( $duedatespec ) }; |
218 |
$datedue = eval { dt_from_string($duedatespec) }; |
221 |
if (! $datedue ) { |
219 |
if ( !$datedue ) { |
222 |
$invalidduedate = 1; |
220 |
$invalidduedate = 1; |
223 |
$template->param( IMPOSSIBLE=>1, INVALID_DATE=>$duedatespec ); |
221 |
$template->param( IMPOSSIBLE => 1, INVALID_DATE => $duedatespec ); |
224 |
} |
222 |
} |
225 |
} |
223 |
} |
226 |
} |
224 |
} |
227 |
my $reduced_datedue = $query->param('reduceddue'); |
225 |
my $reduced_datedue = $query->param('reduceddue'); |
228 |
if ( $reduced_datedue ) { |
226 |
if ($reduced_datedue) { |
229 |
$datedue = dt_from_string( $reduced_datedue ); |
227 |
$datedue = dt_from_string($reduced_datedue); |
230 |
} |
228 |
} |
231 |
|
229 |
|
232 |
my $inprocess = (@$barcodes == 0) ? '' : $query->param('inprocess'); |
230 |
my $inprocess = ( @$barcodes == 0 ) ? '' : $query->param('inprocess'); |
233 |
if ( @$barcodes == 0 && $charges eq 'yes' ) { |
231 |
if ( @$barcodes == 0 && $charges eq 'yes' ) { |
234 |
$template->param( |
232 |
$template->param( |
235 |
PAYCHARGES => 'yes', |
233 |
PAYCHARGES => 'yes', |
Lines 245-287
my $message;
Link Here
|
245 |
if ($findborrower) { |
243 |
if ($findborrower) { |
246 |
Koha::Plugins->call( 'patron_barcode_transform', \$findborrower ); |
244 |
Koha::Plugins->call( 'patron_barcode_transform', \$findborrower ); |
247 |
my $patron = Koha::Patrons->find( { cardnumber => $findborrower } ); |
245 |
my $patron = Koha::Patrons->find( { cardnumber => $findborrower } ); |
248 |
if ( $patron ) { |
246 |
if ($patron) { |
249 |
$borrowernumber = $patron->borrowernumber; |
247 |
$borrowernumber = $patron->borrowernumber; |
250 |
} else { |
248 |
} else { |
251 |
print $query->redirect( "/cgi-bin/koha/members/member.pl?quicksearch=1&circsearch=1&searchmember=" . uri_escape_utf8($findborrower) ); |
249 |
print $query->redirect( "/cgi-bin/koha/members/member.pl?quicksearch=1&circsearch=1&searchmember=" |
|
|
250 |
. uri_escape_utf8($findborrower) ); |
252 |
exit; |
251 |
exit; |
253 |
} |
252 |
} |
254 |
} |
253 |
} |
255 |
|
254 |
|
256 |
# get the borrower information..... |
255 |
# get the borrower information..... |
257 |
my $balance = 0; |
256 |
my $balance = 0; |
258 |
$patron ||= Koha::Patrons->find( $borrowernumber ) if $borrowernumber; |
257 |
$patron ||= Koha::Patrons->find($borrowernumber) if $borrowernumber; |
259 |
if ($patron) { |
258 |
if ($patron) { |
260 |
|
259 |
|
261 |
$template->param( borrowernumber => $patron->borrowernumber ); |
260 |
$template->param( borrowernumber => $patron->borrowernumber ); |
262 |
output_and_exit_if_error( $query, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } ); |
261 |
output_and_exit_if_error( |
|
|
262 |
$query, $cookie, $template, |
263 |
{ module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } |
264 |
); |
263 |
|
265 |
|
264 |
my $overdues = $patron->overdues; |
266 |
my $overdues = $patron->overdues; |
265 |
my $issues = $patron->checkouts; |
267 |
my $issues = $patron->checkouts; |
266 |
$balance = $patron->account->balance; |
268 |
$balance = $patron->account->balance; |
267 |
|
269 |
|
268 |
|
|
|
269 |
# if the expiry date is before today ie they have expired |
270 |
# if the expiry date is before today ie they have expired |
270 |
if ( $patron->is_expired ) { |
271 |
if ( $patron->is_expired ) { |
|
|
272 |
|
271 |
#borrowercard expired, no issues |
273 |
#borrowercard expired, no issues |
272 |
$template->param( |
274 |
$template->param( |
273 |
noissues => ($force_allow_issue) ? 0 : "1", |
275 |
noissues => ($force_allow_issue) ? 0 : "1", |
274 |
forceallow => $force_allow_issue, |
276 |
forceallow => $force_allow_issue, |
275 |
expired => "1", |
277 |
expired => "1", |
276 |
); |
278 |
); |
277 |
} |
279 |
} |
|
|
280 |
|
278 |
# check for NotifyBorrowerDeparture |
281 |
# check for NotifyBorrowerDeparture |
279 |
elsif ( $patron->is_going_to_expire ) { |
282 |
elsif ( $patron->is_going_to_expire ) { |
|
|
283 |
|
280 |
# borrower card soon to expire warn librarian |
284 |
# borrower card soon to expire warn librarian |
281 |
$template->param( "warndeparture" => $patron->dateexpiry , |
285 |
$template->param( |
282 |
); |
286 |
"warndeparture" => $patron->dateexpiry, |
283 |
if (C4::Context->preference('ReturnBeforeExpiry')){ |
287 |
); |
284 |
$template->param("returnbeforeexpiry" => 1); |
288 |
if ( C4::Context->preference('ReturnBeforeExpiry') ) { |
|
|
289 |
$template->param( "returnbeforeexpiry" => 1 ); |
285 |
} |
290 |
} |
286 |
} |
291 |
} |
287 |
$template->param( |
292 |
$template->param( |
Lines 305-312
if ($patron) {
Link Here
|
305 |
# Calculate and display patron's age |
310 |
# Calculate and display patron's age |
306 |
if ( !$patron->is_valid_age ) { |
311 |
if ( !$patron->is_valid_age ) { |
307 |
$template->param( age_limitations => 1 ); |
312 |
$template->param( age_limitations => 1 ); |
308 |
$template->param( age_low => $patron->category->dateofbirthrequired ); |
313 |
$template->param( age_low => $patron->category->dateofbirthrequired ); |
309 |
$template->param( age_high => $patron->category->upperagelimit ); |
314 |
$template->param( age_high => $patron->category->upperagelimit ); |
310 |
} |
315 |
} |
311 |
|
316 |
|
312 |
unless ( |
317 |
unless ( |
Lines 320-328
if ($patron) {
Link Here
|
320 |
# STEP 3 : ISSUING |
325 |
# STEP 3 : ISSUING |
321 |
# |
326 |
# |
322 |
# |
327 |
# |
323 |
if (@$barcodes && $op eq 'cud-checkout') { |
328 |
if ( @$barcodes && $op eq 'cud-checkout' ) { |
324 |
my $checkout_infos; |
329 |
my $checkout_infos; |
325 |
for my $barcode ( @$barcodes ) { |
330 |
for my $barcode (@$barcodes) { |
326 |
|
331 |
|
327 |
my $template_params = { |
332 |
my $template_params = { |
328 |
barcode => $barcode, |
333 |
barcode => $barcode, |
Lines 352-584
if (@$barcodes && $op eq 'cud-checkout') {
Link Here
|
352 |
} |
357 |
} |
353 |
}; |
358 |
}; |
354 |
|
359 |
|
355 |
my $blocker = $invalidduedate ? 1 : 0; |
360 |
my $blocker = $invalidduedate ? 1 : 0; |
356 |
|
361 |
|
357 |
$template_params->{alert} = $alerts; |
362 |
$template_params->{alert} = $alerts; |
358 |
$template_params->{messages} = $messages; |
363 |
$template_params->{messages} = $messages; |
359 |
|
364 |
|
360 |
my $item = Koha::Items->find({ barcode => $barcode }); |
365 |
my $item = Koha::Items->find( { barcode => $barcode } ); |
361 |
|
366 |
|
362 |
my $biblio; |
367 |
my $biblio; |
363 |
if ( $item ) { |
368 |
if ($item) { |
364 |
$biblio = $item->biblio; |
369 |
$biblio = $item->biblio; |
365 |
} |
370 |
} |
366 |
|
371 |
|
367 |
if ( $issuingimpossible->{'STATS'} ) { |
372 |
if ( $issuingimpossible->{'STATS'} ) { |
368 |
my ( $stats_return, $stats_messages, $stats_iteminformation, $stats_borrower ) = |
373 |
my ( $stats_return, $stats_messages, $stats_iteminformation, $stats_borrower ) = |
369 |
AddReturn( $item->barcode, C4::Context->userenv->{'branch'}, undef, undef, 1 ); |
374 |
AddReturn( $item->barcode, C4::Context->userenv->{'branch'}, undef, undef, 1 ); |
370 |
|
375 |
|
371 |
$template->param( |
376 |
$template->param( |
372 |
STATS => 1, |
377 |
STATS => 1, |
373 |
CHECKEDIN => $stats_return, |
378 |
CHECKEDIN => $stats_return, |
374 |
MESSAGES => $stats_messages, |
379 |
MESSAGES => $stats_messages, |
375 |
ITEM => $stats_iteminformation, |
380 |
ITEM => $stats_iteminformation, |
376 |
BORROWER => $stats_borrower, |
381 |
BORROWER => $stats_borrower, |
377 |
); |
382 |
); |
378 |
|
383 |
|
379 |
#increment items.localuse |
384 |
#increment items.localuse |
380 |
my $localuse_count = $item->localuse; |
385 |
my $localuse_count = $item->localuse; |
381 |
$localuse_count++; |
386 |
$localuse_count++; |
382 |
$item->localuse($localuse_count)->store; |
387 |
$item->localuse($localuse_count)->store; |
383 |
} |
388 |
} |
384 |
|
389 |
|
385 |
# Fix for bug 7494: optional checkout-time fallback search for a book |
390 |
# Fix for bug 7494: optional checkout-time fallback search for a book |
386 |
|
391 |
|
387 |
if ( $issuingimpossible->{'UNKNOWN_BARCODE'} |
392 |
if ( $issuingimpossible->{'UNKNOWN_BARCODE'} |
388 |
&& C4::Context->preference("itemBarcodeFallbackSearch") |
393 |
&& C4::Context->preference("itemBarcodeFallbackSearch") |
389 |
&& not $batch |
394 |
&& not $batch ) |
390 |
) |
395 |
{ |
391 |
{ |
396 |
$template_params->{FALLBACK} = 1; |
392 |
$template_params->{FALLBACK} = 1; |
397 |
|
393 |
|
398 |
my $searcher = Koha::SearchEngine::Search->new( { index => $Koha::SearchEngine::BIBLIOS_INDEX } ); |
394 |
my $searcher = Koha::SearchEngine::Search->new({index => $Koha::SearchEngine::BIBLIOS_INDEX}); |
399 |
my $query = "kw=" . $barcode; |
395 |
my $query = "kw=" . $barcode; |
400 |
my ( $searcherror, $results, $total_hits ) = $searcher->simple_search_compat( $query, 0, 10 ); |
396 |
my ( $searcherror, $results, $total_hits ) = $searcher->simple_search_compat($query, 0, 10); |
401 |
|
397 |
|
402 |
# if multiple hits, offer options to librarian |
398 |
# if multiple hits, offer options to librarian |
403 |
if ( $total_hits > 0 ) { |
399 |
if ( $total_hits > 0 ) { |
404 |
my @barcodes; |
400 |
my @barcodes; |
405 |
foreach my $hit ( @{$results} ) { |
401 |
foreach my $hit ( @{$results} ) { |
406 |
my $chosen = # Maybe easier to retrieve the itemnumber from $hit? |
402 |
my $chosen = # Maybe easier to retrieve the itemnumber from $hit? |
407 |
TransformMarcToKoha( { record => C4::Search::new_record_from_zebra( 'biblioserver', $hit ) } ); |
403 |
TransformMarcToKoha({ record => C4::Search::new_record_from_zebra('biblioserver',$hit) }); |
408 |
|
404 |
|
409 |
# offer all barcodes individually |
405 |
# offer all barcodes individually |
410 |
if ( $chosen->{barcode} ) { |
406 |
if ( $chosen->{barcode} ) { |
411 |
push @barcodes, sort split( /\s*\|\s*/, $chosen->{barcode} ); |
407 |
push @barcodes, sort split(/\s*\|\s*/, $chosen->{barcode}); |
412 |
} |
408 |
} |
413 |
} |
|
|
414 |
my $items = Koha::Items->search( { barcode => { -in => \@barcodes } } ); |
415 |
$template_params->{options} = $items; |
409 |
} |
416 |
} |
410 |
my $items = Koha::Items->search({ barcode => {-in => \@barcodes}}); |
|
|
411 |
$template_params->{options} = $items; |
412 |
} |
417 |
} |
413 |
} |
|
|
414 |
|
418 |
|
415 |
# Only some errors will block when performing forced onsite checkout, |
419 |
# Only some errors will block when performing forced onsite checkout, |
416 |
# for other cases all errors will block |
420 |
# for other cases all errors will block |
417 |
my @blocking_error_codes = |
421 |
my @blocking_error_codes = |
418 |
( $onsite_checkout and C4::Context->preference("OnSiteCheckoutsForce") ) |
422 |
( $onsite_checkout and C4::Context->preference("OnSiteCheckoutsForce") ) |
419 |
? qw( UNKNOWN_BARCODE NO_OPEN_DAYS ) |
423 |
? qw( UNKNOWN_BARCODE NO_OPEN_DAYS ) |
420 |
: ( keys %$issuingimpossible ); |
424 |
: ( keys %$issuingimpossible ); |
421 |
|
425 |
|
422 |
if ( $issuingimpossible->{BOOKED_TO_ANOTHER} ) { |
426 |
if ( $issuingimpossible->{BOOKED_TO_ANOTHER} ) { |
423 |
$template_params->{BOOKED_TO_ANOTHER} = $issuingimpossible->{BOOKED_TO_ANOTHER}; |
427 |
$template_params->{BOOKED_TO_ANOTHER} = $issuingimpossible->{BOOKED_TO_ANOTHER}; |
424 |
$template_params->{IMPOSSIBLE} = 1; |
428 |
$template_params->{IMPOSSIBLE} = 1; |
425 |
$blocker = 1; |
429 |
$blocker = 1; |
426 |
} |
430 |
} |
427 |
|
431 |
|
428 |
foreach my $code ( @blocking_error_codes ) { |
432 |
foreach my $code (@blocking_error_codes) { |
429 |
if ($issuingimpossible->{$code}) { |
433 |
if ( $issuingimpossible->{$code} ) { |
430 |
$template_params->{$code} = $issuingimpossible->{$code}; |
434 |
$template_params->{$code} = $issuingimpossible->{$code}; |
431 |
|
435 |
|
432 |
$template_params->{IMPOSSIBLE} = 1; |
436 |
$template_params->{IMPOSSIBLE} = 1; |
433 |
$blocker = 1; |
437 |
$blocker = 1; |
|
|
438 |
} |
434 |
} |
439 |
} |
435 |
} |
|
|
436 |
|
440 |
|
437 |
delete $needsconfirmation->{'DEBT'} if ($debt_confirmed); |
441 |
delete $needsconfirmation->{'DEBT'} if ($debt_confirmed); |
438 |
|
442 |
|
439 |
if ( $item && C4::Context->preference('ClaimReturnedLostValue') ) { |
443 |
if ( $item && C4::Context->preference('ClaimReturnedLostValue') ) { |
440 |
my $autoClaimReturnCheckout = C4::Context->preference('AutoClaimReturnStatusOnCheckout'); |
444 |
my $autoClaimReturnCheckout = C4::Context->preference('AutoClaimReturnStatusOnCheckout'); |
441 |
|
445 |
|
442 |
my $claims = Koha::Checkouts::ReturnClaims->search( |
446 |
my $claims = Koha::Checkouts::ReturnClaims->search( |
443 |
{ |
447 |
{ |
444 |
itemnumber => $item->id, |
448 |
itemnumber => $item->id, |
|
|
449 |
} |
450 |
); |
451 |
if ( $claims->count ) { |
452 |
if ($autoClaimReturnCheckout) { |
453 |
my $claim = $claims->next; |
454 |
|
455 |
my $patron_id = $logged_in_user->borrowernumber; |
456 |
my $resolution = $autoClaimReturnCheckout; |
457 |
|
458 |
$claim->resolve( |
459 |
{ |
460 |
resolution => $resolution, |
461 |
resolved_by => $patron_id, |
462 |
} |
463 |
); |
464 |
$template_params->{CLAIM_RESOLUTION} = $claim; |
465 |
} |
445 |
} |
466 |
} |
446 |
); |
467 |
} |
447 |
if ( $claims->count ) { |
|
|
448 |
if ($autoClaimReturnCheckout) { |
449 |
my $claim = $claims->next; |
450 |
|
468 |
|
451 |
my $patron_id = $logged_in_user->borrowernumber; |
469 |
if ( $item and ( !$blocker or $force_allow_issue ) ) { |
452 |
my $resolution = $autoClaimReturnCheckout; |
470 |
my $confirm_required = 0; |
|
|
471 |
unless ($issueconfirmed) { |
453 |
|
472 |
|
454 |
$claim->resolve( |
473 |
# Get the item title for more information |
|
|
474 |
my $materials = $item->materials; |
475 |
my $descriptions = Koha::AuthorisedValues->get_description_by_koha_field( |
455 |
{ |
476 |
{ |
456 |
resolution => $resolution, |
477 |
frameworkcode => $biblio->frameworkcode, kohafield => 'items.materials', |
457 |
resolved_by => $patron_id, |
478 |
authorised_value => $materials |
458 |
} |
479 |
} |
459 |
); |
480 |
); |
460 |
$template_params->{CLAIM_RESOLUTION} = $claim; |
481 |
$materials = $descriptions->{lib} // $materials; |
461 |
} |
482 |
$template_params->{ADDITIONAL_MATERIALS} = $materials; |
462 |
} |
483 |
$template_params->{itemhomebranch} = $item->homebranch; |
463 |
} |
484 |
|
|
|
485 |
my $patron_session_confirmation = $query->cookie('patronSessionConfirmation') || undef; |
486 |
my ( $patron_for_session, $session_confirmations ) = split( /:/, $patron_session_confirmation, 2 ); |
487 |
my $patron_match = $borrowernumber == $patron_for_session; |
488 |
my @conf_keys = split( /\|/, $session_confirmations ); |
489 |
$template_params->{sessionConfirmationKeys} = (); |
490 |
|
491 |
# pass needsconfirmation to template if issuing is possible and user hasn't yet confirmed. |
492 |
foreach my $needsconfirmation_key ( keys %$needsconfirmation ) { |
493 |
if ( $needsconfirmation_key eq 'BOOKED_TO_ANOTHER' ) { |
494 |
my $rule = Koha::CirculationRules->get_effective_rule( |
495 |
{ |
496 |
rule_name => 'bookings_lead_period', |
497 |
itemtype => $item->effective_itemtype, |
498 |
branchcode => "*" |
499 |
} |
500 |
); |
501 |
my $preparation_period = $rule ? $rule->rule_value : 1; |
502 |
my $reduceddue = dt_from_string( $$needsconfirmation{$needsconfirmation_key}->start_date ) |
464 |
|
503 |
|
465 |
if( $item and ( !$blocker or $force_allow_issue ) ){ |
504 |
->subtract( days => $preparation_period ); |
466 |
my $confirm_required = 0; |
505 |
$template_params->{reduceddue} = $reduceddue; |
467 |
unless($issueconfirmed){ |
506 |
} |
468 |
# Get the item title for more information |
507 |
next |
469 |
my $materials = $item->materials; |
508 |
if $patron_match |
470 |
my $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({ frameworkcode => $biblio->frameworkcode, kohafield => 'items.materials', authorised_value => $materials }); |
509 |
&& scalar(@conf_keys) > 0 |
471 |
$materials = $descriptions->{lib} // $materials; |
510 |
&& grep( { $needsconfirmation_key eq $_ } @conf_keys ); |
472 |
$template_params->{ADDITIONAL_MATERIALS} = $materials; |
511 |
|
473 |
$template_params->{itemhomebranch} = $item->homebranch; |
512 |
$template_params->{$needsconfirmation_key} = $needsconfirmation->{$needsconfirmation_key}; |
474 |
|
513 |
$template_params->{getTitleMessageIteminfo} = $biblio->title; |
475 |
my $patron_session_confirmation = $query->cookie('patronSessionConfirmation') || undef; |
514 |
$template_params->{getBarcodeMessageIteminfo} = $item->barcode; |
476 |
my ( $patron_for_session, $session_confirmations ) = split( /:/, $patron_session_confirmation, 2 ); |
515 |
$template_params->{NEEDSCONFIRMATION} = 1; |
477 |
my $patron_match = $borrowernumber == $patron_for_session; |
516 |
$confirm_required = 1; |
478 |
my @conf_keys = split( /\|/, $session_confirmations ); |
517 |
push( @{ $template_params->{sessionConfirmationKeys} }, $needsconfirmation_key ); |
479 |
$template_params->{sessionConfirmationKeys} = (); |
518 |
} |
480 |
|
519 |
} |
481 |
# pass needsconfirmation to template if issuing is possible and user hasn't yet confirmed. |
520 |
unless ($confirm_required) { |
482 |
foreach my $needsconfirmation_key ( keys %$needsconfirmation ) { |
521 |
my $switch_onsite_checkout = exists $messages->{ONSITE_CHECKOUT_WILL_BE_SWITCHED}; |
483 |
if ( $needsconfirmation_key eq 'BOOKED_TO_ANOTHER' ) { |
522 |
if ( C4::Context->preference('UseRecalls') && !$recall_id ) { |
484 |
my $rule = Koha::CirculationRules->get_effective_rule( |
523 |
my $recall = Koha::Recalls->find( |
485 |
{ |
524 |
{ |
486 |
rule_name => 'bookings_lead_period', |
525 |
biblio_id => $item->biblionumber, |
487 |
itemtype => $item->effective_itemtype, |
526 |
item_id => [ undef, $item->itemnumber ], |
488 |
branchcode => "*" |
527 |
status => [ 'requested', 'waiting' ], |
|
|
528 |
completed => 0, |
529 |
patron_id => $patron->borrowernumber, |
489 |
} |
530 |
} |
490 |
); |
531 |
); |
491 |
my $preparation_period = $rule ? $rule->rule_value : 1; |
532 |
$recall_id = ( $recall and $recall->id ) ? $recall->id : undef; |
492 |
my $reduceddue = |
|
|
493 |
dt_from_string( $$needsconfirmation{$needsconfirmation_key}->start_date ) |
494 |
->subtract( days => $preparation_period ); |
495 |
$template_params->{reduceddue} = $reduceddue; |
496 |
} |
533 |
} |
497 |
next |
534 |
|
498 |
if $patron_match |
535 |
# If booked (alerts or confirmation) update datedue to end of booking |
499 |
&& scalar(@conf_keys) > 0 |
536 |
if ( my $booked = $needsconfirmation->{BOOKED_EARLY} // $alerts->{BOOKED} ) { |
500 |
&& grep( { $needsconfirmation_key eq $_ } @conf_keys ); |
537 |
$datedue = $booked->end_date; |
501 |
|
538 |
} |
502 |
$template_params->{$needsconfirmation_key} = $needsconfirmation->{$needsconfirmation_key}; |
539 |
my $issue = AddIssue( |
503 |
$template_params->{getTitleMessageIteminfo} = $biblio->title; |
540 |
$patron, $barcode, $datedue, |
504 |
$template_params->{getBarcodeMessageIteminfo} = $item->barcode; |
541 |
$cancelreserve, |
505 |
$template_params->{NEEDSCONFIRMATION} = 1; |
542 |
undef, undef, |
506 |
$confirm_required = 1; |
|
|
507 |
push( @{ $template_params->{sessionConfirmationKeys} }, $needsconfirmation_key ); |
508 |
} |
509 |
} |
510 |
unless ($confirm_required) { |
511 |
my $switch_onsite_checkout = exists $messages->{ONSITE_CHECKOUT_WILL_BE_SWITCHED}; |
512 |
if ( C4::Context->preference('UseRecalls') && !$recall_id ) { |
513 |
my $recall = Koha::Recalls->find( |
514 |
{ |
543 |
{ |
515 |
biblio_id => $item->biblionumber, |
544 |
onsite_checkout => $onsite_checkout, auto_renew => $session->param('auto_renew'), |
516 |
item_id => [ undef, $item->itemnumber ], |
545 |
switch_onsite_checkout => $switch_onsite_checkout, cancel_recall => $cancel_recall, |
517 |
status => [ 'requested', 'waiting' ], |
546 |
recall_id => $recall_id, |
518 |
completed => 0, |
|
|
519 |
patron_id => $patron->borrowernumber, |
520 |
} |
547 |
} |
521 |
); |
548 |
); |
522 |
$recall_id = ( $recall and $recall->id ) ? $recall->id : undef; |
549 |
$template_params->{issue} = $issue; |
|
|
550 |
$session->clear('auto_renew'); |
551 |
$inprocess = 1; |
523 |
} |
552 |
} |
|
|
553 |
} |
524 |
|
554 |
|
525 |
# If booked (alerts or confirmation) update datedue to end of booking |
555 |
if ( $needsconfirmation->{RESERVE_WAITING} |
526 |
if ( my $booked = $needsconfirmation->{BOOKED_EARLY} // $alerts->{BOOKED} ) { |
556 |
or $needsconfirmation->{RESERVED} |
527 |
$datedue = $booked->end_date; |
557 |
or $needsconfirmation->{TRANSFERRED} |
528 |
} |
558 |
or $needsconfirmation->{PROCESSING} ) |
529 |
my $issue = AddIssue( |
559 |
{ |
530 |
$patron, $barcode, $datedue, |
560 |
$template->param( |
531 |
$cancelreserve, |
561 |
reserveborrowernumber => $needsconfirmation->{'resborrowernumber'}, |
532 |
undef, undef, |
562 |
reserve_id => $needsconfirmation->{reserve_id}, |
533 |
{ |
|
|
534 |
onsite_checkout => $onsite_checkout, auto_renew => $session->param('auto_renew'), |
535 |
switch_onsite_checkout => $switch_onsite_checkout, cancel_recall => $cancel_recall, |
536 |
recall_id => $recall_id, |
537 |
} |
538 |
); |
563 |
); |
539 |
$template_params->{issue} = $issue; |
|
|
540 |
$session->clear('auto_renew'); |
541 |
$inprocess = 1; |
542 |
} |
564 |
} |
543 |
} |
|
|
544 |
|
565 |
|
545 |
if ($needsconfirmation->{RESERVE_WAITING} or $needsconfirmation->{RESERVED} or $needsconfirmation->{TRANSFERRED} or $needsconfirmation->{PROCESSING}){ |
566 |
# FIXME If the issue is confirmed, we launch another time checkouts->count, now display the issue count after issue |
|
|
567 |
$patron = Koha::Patrons->find($borrowernumber); |
568 |
$template_params->{issuecount} = $patron->checkouts->count; |
569 |
|
570 |
if ($item) { |
571 |
$template_params->{item} = $item; |
572 |
$template_params->{biblio} = $biblio; |
573 |
$template_params->{itembiblionumber} = $biblio->biblionumber; |
574 |
} |
575 |
push @$checkout_infos, $template_params; |
576 |
} |
577 |
unless ($batch) { |
578 |
$template->param( %{ $checkout_infos->[0] } ); |
579 |
$template->param( barcode => $barcodes->[0] ); |
580 |
} else { |
581 |
my $confirmation_needed = grep { $_->{NEEDSCONFIRMATION} } @$checkout_infos; |
546 |
$template->param( |
582 |
$template->param( |
547 |
reserveborrowernumber => $needsconfirmation->{'resborrowernumber'}, |
583 |
checkout_infos => $checkout_infos, |
548 |
reserve_id => $needsconfirmation->{reserve_id}, |
584 |
onsite_checkout => $onsite_checkout, |
|
|
585 |
confirmation_needed => $confirmation_needed, |
549 |
); |
586 |
); |
550 |
} |
587 |
} |
551 |
|
|
|
552 |
|
553 |
# FIXME If the issue is confirmed, we launch another time checkouts->count, now display the issue count after issue |
554 |
$patron = Koha::Patrons->find( $borrowernumber ); |
555 |
$template_params->{issuecount} = $patron->checkouts->count; |
556 |
|
557 |
if ( $item ) { |
558 |
$template_params->{item} = $item; |
559 |
$template_params->{biblio} = $biblio; |
560 |
$template_params->{itembiblionumber} = $biblio->biblionumber; |
561 |
} |
562 |
push @$checkout_infos, $template_params; |
563 |
} |
564 |
unless ( $batch ) { |
565 |
$template->param( %{$checkout_infos->[0]} ); |
566 |
$template->param( barcode => $barcodes->[0] ); |
567 |
} else { |
568 |
my $confirmation_needed = grep { $_->{NEEDSCONFIRMATION} } @$checkout_infos; |
569 |
$template->param( |
570 |
checkout_infos => $checkout_infos, |
571 |
onsite_checkout => $onsite_checkout, |
572 |
confirmation_needed => $confirmation_needed, |
573 |
); |
574 |
} |
575 |
} |
588 |
} |
576 |
|
589 |
|
577 |
################################################################################## |
590 |
################################################################################## |
578 |
# BUILD HTML |
591 |
# BUILD HTML |
579 |
# show all reserves of this borrower, and the position of the reservation .... |
592 |
# show all reserves of this borrower, and the position of the reservation .... |
580 |
if ($patron) { |
593 |
if ($patron) { |
581 |
my $holds = Koha::Holds->search( { borrowernumber => $borrowernumber } ); # FIXME must be Koha::Patron->holds |
594 |
my $holds = Koha::Holds->search( { borrowernumber => $borrowernumber } ); # FIXME must be Koha::Patron->holds |
582 |
my $waiting_holds = $holds->waiting; |
595 |
my $waiting_holds = $holds->waiting; |
583 |
$template->param( |
596 |
$template->param( |
584 |
holds_count => $holds->count(), |
597 |
holds_count => $holds->count(), |
Lines 586-612
if ($patron) {
Link Here
|
586 |
); |
599 |
); |
587 |
|
600 |
|
588 |
if ( C4::Context->preference('UseRecalls') ) { |
601 |
if ( C4::Context->preference('UseRecalls') ) { |
589 |
my $waiting_recalls = $patron->recalls->search({ status => 'waiting' }); |
602 |
my $waiting_recalls = $patron->recalls->search( { status => 'waiting' } ); |
590 |
$template->param( |
603 |
$template->param( |
591 |
recalls => $patron->recalls->filter_by_current->search({},{ order_by => { -asc => 'created_date' } }), |
604 |
recalls => $patron->recalls->filter_by_current->search( {}, { order_by => { -asc => 'created_date' } } ), |
592 |
specific_patron => 1, |
605 |
specific_patron => 1, |
593 |
waiting_recalls => $waiting_recalls, |
606 |
waiting_recalls => $waiting_recalls, |
594 |
); |
607 |
); |
595 |
} |
608 |
} |
596 |
} |
609 |
} |
597 |
|
610 |
|
598 |
if ( $patron ) { |
611 |
if ($patron) { |
599 |
my $noissues; |
612 |
my $noissues; |
600 |
if ( $patron->gonenoaddress ) { |
613 |
if ( $patron->gonenoaddress ) { |
601 |
$template->param( gonenoaddress => 1 ); |
614 |
$template->param( gonenoaddress => 1 ); |
602 |
$noissues = 1; |
615 |
$noissues = 1; |
603 |
} |
616 |
} |
604 |
if ( $patron->lost ) { |
617 |
if ( $patron->lost ) { |
605 |
$template->param( lost=> 1 ); |
618 |
$template->param( lost => 1 ); |
606 |
$noissues = 1; |
619 |
$noissues = 1; |
607 |
} |
620 |
} |
608 |
if ( $patron->is_debarred ) { |
621 |
if ( $patron->is_debarred ) { |
609 |
$template->param( is_debarred=> 1 ); |
622 |
$template->param( is_debarred => 1 ); |
610 |
$noissues = 1; |
623 |
$noissues = 1; |
611 |
} |
624 |
} |
612 |
if ( $patron->borrowernumber eq C4::Context->preference("AnonymousPatron") ) { |
625 |
if ( $patron->borrowernumber eq C4::Context->preference("AnonymousPatron") ) { |
Lines 614-629
if ( $patron ) {
Link Here
|
614 |
$noissues = 1; |
627 |
$noissues = 1; |
615 |
} |
628 |
} |
616 |
my $patron_charge_limits = $patron->is_patron_inside_charge_limits(); |
629 |
my $patron_charge_limits = $patron->is_patron_inside_charge_limits(); |
617 |
if( $patron_charge_limits->{noissuescharge}->{charge} > 0 ) { |
630 |
if ( $patron_charge_limits->{noissuescharge}->{charge} > 0 ) { |
618 |
my $noissuescharge = $patron_charge_limits->{noissuescharge}->{limit} || 5; # FIXME If noissuescharge == 0 then 5, why?? |
631 |
my $noissuescharge = |
619 |
$noissues ||= ( not C4::Context->preference("AllowFineOverride") and $patron_charge_limits->{noissuescharge}->{overlimit} ); |
632 |
$patron_charge_limits->{noissuescharge}->{limit} || 5; # FIXME If noissuescharge == 0 then 5, why?? |
|
|
633 |
$noissues ||= ( not C4::Context->preference("AllowFineOverride") |
634 |
and $patron_charge_limits->{noissuescharge}->{overlimit} ); |
620 |
$template->param( |
635 |
$template->param( |
621 |
charges => 1, |
636 |
charges => 1, |
622 |
chargesamount => $patron_charge_limits->{noissuescharge}->{charge}, |
637 |
chargesamount => $patron_charge_limits->{noissuescharge}->{charge}, |
623 |
) |
638 |
); |
624 |
} elsif ( $balance < 0 ) { |
639 |
} elsif ( $balance < 0 ) { |
625 |
$template->param( |
640 |
$template->param( |
626 |
credits => 1, |
641 |
credits => 1, |
627 |
creditsamount => -$balance, |
642 |
creditsamount => -$balance, |
628 |
); |
643 |
); |
629 |
} |
644 |
} |
Lines 632-640
if ( $patron ) {
Link Here
|
632 |
my $no_issues_charge_guarantors = $patron_charge_limits->{NoIssuesChargeGuarantorsWithGuarantees}->{limit}; |
647 |
my $no_issues_charge_guarantors = $patron_charge_limits->{NoIssuesChargeGuarantorsWithGuarantees}->{limit}; |
633 |
if ($no_issues_charge_guarantors) { |
648 |
if ($no_issues_charge_guarantors) { |
634 |
if ( $patron_charge_limits->{NoIssuesChargeGuarantorsWithGuarantees}->{overlimit} ) { |
649 |
if ( $patron_charge_limits->{NoIssuesChargeGuarantorsWithGuarantees}->{overlimit} ) { |
635 |
$template->param( |
650 |
$template->param( charges_guarantors_guarantees => |
636 |
charges_guarantors_guarantees => $patron_charge_limits->{NoIssuesChargeGuarantorsWithGuarantees}->{charge} |
651 |
$patron_charge_limits->{NoIssuesChargeGuarantorsWithGuarantees}->{charge} ); |
637 |
); |
|
|
638 |
$noissues = 1 unless C4::Context->preference("allowfineoverride"); |
652 |
$noissues = 1 unless C4::Context->preference("allowfineoverride"); |
639 |
} |
653 |
} |
640 |
} |
654 |
} |
Lines 643-649
if ( $patron ) {
Link Here
|
643 |
if ( defined $no_issues_charge_guarantees ) { |
657 |
if ( defined $no_issues_charge_guarantees ) { |
644 |
if ( $patron_charge_limits->{NoIssuesChargeGuarantees}->{overlimit} ) { |
658 |
if ( $patron_charge_limits->{NoIssuesChargeGuarantees}->{overlimit} ) { |
645 |
$template->param( |
659 |
$template->param( |
646 |
charges_guarantees => 1, |
660 |
charges_guarantees => 1, |
647 |
chargesamount_guarantees => $patron_charge_limits->{NoIssuesChargeGuarantees}->{charge}, |
661 |
chargesamount_guarantees => $patron_charge_limits->{NoIssuesChargeGuarantees}->{charge}, |
648 |
); |
662 |
); |
649 |
$noissues = 1 unless C4::Context->preference("allowfineoverride"); |
663 |
$noissues = 1 unless C4::Context->preference("allowfineoverride"); |
Lines 658-671
if ( $patron ) {
Link Here
|
658 |
my $borrowernotes = $patron->borrowernotes; |
672 |
my $borrowernotes = $patron->borrowernotes; |
659 |
$borrowernotes =~ s#\n#<br />#g; |
673 |
$borrowernotes =~ s#\n#<br />#g; |
660 |
$template->param( |
674 |
$template->param( |
661 |
notes =>1, |
675 |
notes => 1, |
662 |
notesmsg => $borrowernotes, |
676 |
notesmsg => $borrowernotes, |
663 |
) |
677 |
); |
664 |
} |
678 |
} |
665 |
|
679 |
|
666 |
if ( $noissues ) { |
680 |
if ($noissues) { |
667 |
$template->param( |
681 |
$template->param( |
668 |
noissues => ($force_allow_issue) ? 0 : 'true', |
682 |
noissues => ($force_allow_issue) ? 0 : 'true', |
669 |
forceallow => $force_allow_issue, |
683 |
forceallow => $force_allow_issue, |
670 |
); |
684 |
); |
671 |
} |
685 |
} |
Lines 673-681
if ( $patron ) {
Link Here
|
673 |
my $patron_messages = $patron->messages->search( |
687 |
my $patron_messages = $patron->messages->search( |
674 |
{}, |
688 |
{}, |
675 |
{ |
689 |
{ |
676 |
join => 'manager', |
690 |
join => 'manager', |
677 |
'+select' => ['manager.surname', 'manager.firstname' ], |
691 |
'+select' => [ 'manager.surname', 'manager.firstname' ], |
678 |
'+as' => ['manager_surname', 'manager_firstname'], |
692 |
'+as' => [ 'manager_surname', 'manager_firstname' ], |
679 |
} |
693 |
} |
680 |
); |
694 |
); |
681 |
$template->param( patron_messages => $patron_messages ); |
695 |
$template->param( patron_messages => $patron_messages ); |
Lines 688-702
if ( $patron ) {
Link Here
|
688 |
|
702 |
|
689 |
my $fast_cataloging = 0; |
703 |
my $fast_cataloging = 0; |
690 |
if ( Koha::BiblioFrameworks->find('FA') ) { |
704 |
if ( Koha::BiblioFrameworks->find('FA') ) { |
691 |
$fast_cataloging = 1 |
705 |
$fast_cataloging = 1; |
692 |
} |
706 |
} |
693 |
|
707 |
|
694 |
my $view = $batch |
708 |
my $view = |
695 |
?'batch_checkout_view' |
709 |
$batch |
|
|
710 |
? 'batch_checkout_view' |
696 |
: 'circview'; |
711 |
: 'circview'; |
697 |
|
712 |
|
698 |
my @relatives; |
713 |
my @relatives; |
699 |
if ( $patron ) { |
714 |
if ($patron) { |
700 |
if ( my @guarantors = $patron->guarantor_relationships()->guarantors->as_list ) { |
715 |
if ( my @guarantors = $patron->guarantor_relationships()->guarantors->as_list ) { |
701 |
push( @relatives, $_->id ) for @guarantors; |
716 |
push( @relatives, $_->id ) for @guarantors; |
702 |
push( @relatives, $_->id ) for $patron->siblings->as_list; |
717 |
push( @relatives, $_->id ) for $patron->siblings->as_list; |
Lines 705-779
if ( $patron ) {
Link Here
|
705 |
} |
720 |
} |
706 |
} |
721 |
} |
707 |
my $relatives_issues_count = |
722 |
my $relatives_issues_count = |
708 |
Koha::Database->new()->schema()->resultset('Issue') |
723 |
Koha::Database->new()->schema()->resultset('Issue')->count( { borrowernumber => \@relatives } ); |
709 |
->count( { borrowernumber => \@relatives } ); |
|
|
710 |
|
724 |
|
711 |
if ( $patron ) { |
725 |
if ($patron) { |
712 |
my $av = Koha::AuthorisedValues->search({ category => 'ROADTYPE', authorised_value => $patron->streettype }); |
726 |
my $av = Koha::AuthorisedValues->search( { category => 'ROADTYPE', authorised_value => $patron->streettype } ); |
713 |
my $roadtype = $av->count ? $av->next->lib : ''; |
727 |
my $roadtype = $av->count ? $av->next->lib : ''; |
714 |
$template->param( |
728 |
$template->param( |
715 |
roadtype => $roadtype, |
729 |
roadtype => $roadtype, |
716 |
patron => $patron, |
730 |
patron => $patron, |
717 |
categoryname => $patron->category->description, |
731 |
categoryname => $patron->category->description, |
718 |
expiry => $patron->dateexpiry, |
732 |
expiry => $patron->dateexpiry, |
719 |
); |
733 |
); |
720 |
} |
734 |
} |
721 |
|
735 |
|
722 |
# Restore date if changed by holds and/or save stickyduedate to session |
736 |
# Restore date if changed by holds and/or save stickyduedate to session |
723 |
if ($restoreduedatespec || $stickyduedate) { |
737 |
if ( $restoreduedatespec || $stickyduedate ) { |
724 |
$duedatespec = $restoreduedatespec || $duedatespec; |
738 |
$duedatespec = $restoreduedatespec || $duedatespec; |
725 |
|
739 |
|
726 |
if ($stickyduedate) { |
740 |
if ($stickyduedate) { |
727 |
$session->param( 'stickyduedate', $duedatespec ); |
741 |
$session->param( 'stickyduedate', $duedatespec ); |
728 |
} |
742 |
} |
729 |
} elsif (defined($duedatespec) && !defined($restoreduedatespec)) { |
743 |
} elsif ( defined($duedatespec) && !defined($restoreduedatespec) ) { |
730 |
undef $duedatespec; |
744 |
undef $duedatespec; |
731 |
} |
745 |
} |
732 |
|
746 |
|
733 |
$template->param( |
747 |
$template->param( |
734 |
borrowernumber => $borrowernumber, |
748 |
borrowernumber => $borrowernumber, |
735 |
branch => $branch, |
749 |
branch => $branch, |
736 |
was_renewed => scalar $query->param('was_renewed') ? 1 : 0, |
750 |
was_renewed => scalar $query->param('was_renewed') ? 1 : 0, |
737 |
barcodes => $barcodes, |
751 |
barcodes => $barcodes, |
738 |
stickyduedate => $stickyduedate, |
752 |
stickyduedate => $stickyduedate, |
739 |
duedatespec => $duedatespec, |
753 |
duedatespec => $duedatespec, |
740 |
restoreduedatespec => $restoreduedatespec, |
754 |
restoreduedatespec => $restoreduedatespec, |
741 |
message => $message, |
755 |
message => $message, |
742 |
totaldue => sprintf('%.2f', $balance), # FIXME not used in template? |
756 |
totaldue => sprintf( '%.2f', $balance ), # FIXME not used in template? |
743 |
inprocess => $inprocess, |
757 |
inprocess => $inprocess, |
744 |
$view => 1, |
758 |
$view => 1, |
745 |
batch_allowed => $batch_allowed, |
759 |
batch_allowed => $batch_allowed, |
746 |
batch => $batch, |
760 |
batch => $batch, |
747 |
AudioAlerts => C4::Context->preference("AudioAlerts"), |
761 |
AudioAlerts => C4::Context->preference("AudioAlerts"), |
748 |
fast_cataloging => $fast_cataloging, |
762 |
fast_cataloging => $fast_cataloging, |
749 |
CircAutoPrintQuickSlip => C4::Context->preference("CircAutoPrintQuickSlip"), |
763 |
CircAutoPrintQuickSlip => C4::Context->preference("CircAutoPrintQuickSlip"), |
750 |
RoutingSerials => C4::Context->preference('RoutingSerials'), |
764 |
RoutingSerials => C4::Context->preference('RoutingSerials'), |
751 |
relatives_issues_count => $relatives_issues_count, |
765 |
relatives_issues_count => $relatives_issues_count, |
752 |
relatives_borrowernumbers => \@relatives, |
766 |
relatives_borrowernumbers => \@relatives, |
753 |
); |
767 |
); |
754 |
|
768 |
|
755 |
|
|
|
756 |
if ( C4::Context->preference("ExportCircHistory") ) { |
769 |
if ( C4::Context->preference("ExportCircHistory") ) { |
757 |
$template->param(csv_profiles => Koha::CsvProfiles->search({ type => 'marc' })); |
770 |
$template->param( csv_profiles => Koha::CsvProfiles->search( { type => 'marc' } ) ); |
758 |
} |
771 |
} |
759 |
|
772 |
|
760 |
my ( $has_modifications, $patron_lists_count); |
773 |
my ( $has_modifications, $patron_lists_count ); |
761 |
if ( $patron ) { |
774 |
if ($patron) { |
762 |
$has_modifications = Koha::Patron::Modifications->search( { borrowernumber => $borrowernumber } )->count; |
775 |
$has_modifications = Koha::Patron::Modifications->search( { borrowernumber => $borrowernumber } )->count; |
763 |
$patron_lists_count = $patron->get_lists_with_patron->count(); |
776 |
$patron_lists_count = $patron->get_lists_with_patron->count(); |
764 |
} |
777 |
} |
765 |
$template->param( |
778 |
$template->param( |
766 |
debt_confirmed => $debt_confirmed, |
779 |
debt_confirmed => $debt_confirmed, |
767 |
SpecifyDueDate => $duedatespec_allow, |
780 |
SpecifyDueDate => $duedatespec_allow, |
768 |
PatronAutoComplete => C4::Context->preference("PatronAutoComplete"), |
781 |
PatronAutoComplete => C4::Context->preference("PatronAutoComplete"), |
769 |
today_due_date_and_time => dt_from_string()->set(hour => 23)->set(minute => 59), |
782 |
today_due_date_and_time => dt_from_string()->set( hour => 23 )->set( minute => 59 ), |
770 |
restriction_types => scalar Koha::Patron::Restriction::Types->search(), |
783 |
restriction_types => scalar Koha::Patron::Restriction::Types->search(), |
771 |
has_modifications => $has_modifications, |
784 |
has_modifications => $has_modifications, |
772 |
patron_lists_count => $patron_lists_count, |
785 |
patron_lists_count => $patron_lists_count, |
773 |
override_high_holds => $override_high_holds, |
786 |
override_high_holds => $override_high_holds, |
774 |
nopermission => scalar $query->param('nopermission'), |
787 |
nopermission => scalar $query->param('nopermission'), |
775 |
autoswitched => $autoswitched, |
788 |
autoswitched => $autoswitched, |
776 |
logged_in_user => $logged_in_user, |
789 |
logged_in_user => $logged_in_user, |
777 |
); |
790 |
); |
778 |
|
791 |
|
779 |
output_html_with_http_headers $query, $cookie, $template->output; |
792 |
output_html_with_http_headers $query, $cookie, $template->output; |
780 |
- |
|
|