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