View | Details | Raw Unified | Return to bug 14787
Collapse All | Expand All

(-)a/circ/circulation.pl (-317 / +329 lines)
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-587 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
        $template->param( STATS => 1 );
373
            $template->param( STATS => 1 );
369
374
370
        if ( $item->onloan ) {
375
            if ( $item->onloan ) {
371
            my ( $stats_return, $stats_messages, $stats_iteminformation, $stats_borrower ) =
376
                my ( $stats_return, $stats_messages, $stats_iteminformation, $stats_borrower ) =
372
                AddReturn( $item->barcode, C4::Context->userenv->{'branch'}, undef, undef, 1 );
377
                    AddReturn( $item->barcode, C4::Context->userenv->{'branch'}, undef, undef, 1 );
373
378
374
            $template->param(
379
                $template->param(
375
                CHECKEDIN => $stats_return,
380
                    CHECKEDIN => $stats_return,
376
                MESSAGES  => $stats_messages,
381
                    MESSAGES  => $stats_messages,
377
                ITEM      => $stats_iteminformation,
382
                    ITEM      => $stats_iteminformation,
378
                BORROWER  => $stats_borrower,
383
                    BORROWER  => $stats_borrower,
379
            );
384
                );
380
        }
385
            }
381
386
382
        #increment items.localuse
387
            #increment items.localuse
383
        my $localuse_count = $item->localuse;
388
            my $localuse_count = $item->localuse;
384
        $localuse_count++;
389
            $localuse_count++;
385
        $item->localuse($localuse_count)->store;
390
            $item->localuse($localuse_count)->store;
386
    }
391
        }
387
392
388
    # Fix for bug 7494: optional checkout-time fallback search for a book
393
        # Fix for bug 7494: optional checkout-time fallback search for a book
389
394
390
    if ( $issuingimpossible->{'UNKNOWN_BARCODE'}
395
        if (   $issuingimpossible->{'UNKNOWN_BARCODE'}
391
        && C4::Context->preference("itemBarcodeFallbackSearch")
396
            && C4::Context->preference("itemBarcodeFallbackSearch")
392
        && not $batch
397
            && not $batch )
393
    )
398
        {
394
    {
399
            $template_params->{FALLBACK} = 1;
395
     $template_params->{FALLBACK} = 1;
400
396
401
            my $searcher = Koha::SearchEngine::Search->new( { index => $Koha::SearchEngine::BIBLIOS_INDEX } );
397
        my $searcher = Koha::SearchEngine::Search->new({index => $Koha::SearchEngine::BIBLIOS_INDEX});
402
            my $query    = "kw=" . $barcode;
398
        my $query = "kw=" . $barcode;
403
            my ( $searcherror, $results, $total_hits ) = $searcher->simple_search_compat( $query, 0, 10 );
399
        my ( $searcherror, $results, $total_hits ) = $searcher->simple_search_compat($query, 0, 10);
404
400
405
            # if multiple hits, offer options to librarian
401
        # if multiple hits, offer options to librarian
406
            if ( $total_hits > 0 ) {
402
        if ( $total_hits > 0 ) {
407
                my @barcodes;
403
            my @barcodes;
408
                foreach my $hit ( @{$results} ) {
404
            foreach my $hit ( @{$results} ) {
409
                    my $chosen =    # Maybe easier to retrieve the itemnumber from $hit?
405
                my $chosen = # Maybe easier to retrieve the itemnumber from $hit?
410
                        TransformMarcToKoha( { record => C4::Search::new_record_from_zebra( 'biblioserver', $hit ) } );
406
                  TransformMarcToKoha({ record => C4::Search::new_record_from_zebra('biblioserver',$hit) });
411
407
412
                    # offer all barcodes individually
408
                # offer all barcodes individually
413
                    if ( $chosen->{barcode} ) {
409
                if ( $chosen->{barcode} ) {
414
                        push @barcodes, sort split( /\s*\|\s*/, $chosen->{barcode} );
410
                    push @barcodes, sort split(/\s*\|\s*/, $chosen->{barcode});
415
                    }
411
                }
416
                }
417
                my $items = Koha::Items->search( { barcode => { -in => \@barcodes } } );
418
                $template_params->{options} = $items;
412
            }
419
            }
413
            my $items = Koha::Items->search({ barcode => {-in => \@barcodes}});
414
            $template_params->{options} = $items;
415
        }
420
        }
416
    }
417
421
418
    # Only some errors will block when performing forced onsite checkout,
422
        # Only some errors will block when performing forced onsite checkout,
419
    # for other cases all errors will block
423
        # for other cases all errors will block
420
    my @blocking_error_codes =
424
        my @blocking_error_codes =
421
        ( $onsite_checkout and C4::Context->preference("OnSiteCheckoutsForce") )
425
            ( $onsite_checkout and C4::Context->preference("OnSiteCheckoutsForce") )
422
        ? qw( UNKNOWN_BARCODE NO_OPEN_DAYS )
426
            ? qw( UNKNOWN_BARCODE NO_OPEN_DAYS )
423
        : ( keys %$issuingimpossible );
427
            : ( keys %$issuingimpossible );
424
428
425
    if ( $issuingimpossible->{BOOKED_TO_ANOTHER} ) {
429
        if ( $issuingimpossible->{BOOKED_TO_ANOTHER} ) {
426
        $template_params->{BOOKED_TO_ANOTHER} = $issuingimpossible->{BOOKED_TO_ANOTHER};
430
            $template_params->{BOOKED_TO_ANOTHER} = $issuingimpossible->{BOOKED_TO_ANOTHER};
427
        $template_params->{IMPOSSIBLE}        = 1;
431
            $template_params->{IMPOSSIBLE}        = 1;
428
        $blocker                              = 1;
432
            $blocker                              = 1;
429
    }
433
        }
430
434
431
    foreach my $code ( @blocking_error_codes ) {
435
        foreach my $code (@blocking_error_codes) {
432
        if ($issuingimpossible->{$code}) {
436
            if ( $issuingimpossible->{$code} ) {
433
            $template_params->{$code} = $issuingimpossible->{$code};
437
                $template_params->{$code} = $issuingimpossible->{$code};
434
438
435
            $template_params->{IMPOSSIBLE} = 1;
439
                $template_params->{IMPOSSIBLE} = 1;
436
            $blocker = 1;
440
                $blocker = 1;
441
            }
437
        }
442
        }
438
    }
439
443
440
    delete $needsconfirmation->{'DEBT'} if ($debt_confirmed);
444
        delete $needsconfirmation->{'DEBT'} if ($debt_confirmed);
445
446
        if ( $item && C4::Context->preference('ClaimReturnedLostValue') ) {
447
            my $autoClaimReturnCheckout = C4::Context->preference('AutoClaimReturnStatusOnCheckout');
448
449
            my $claims = Koha::Checkouts::ReturnClaims->search(
450
                {
451
                    itemnumber => $item->id,
452
                }
453
            );
454
            if ( $claims->count ) {
455
                if ($autoClaimReturnCheckout) {
456
                    my $claim = $claims->next;
441
457
442
    if ( $item && C4::Context->preference('ClaimReturnedLostValue') ) {
458
                    my $patron_id  = $logged_in_user->borrowernumber;
443
        my $autoClaimReturnCheckout = C4::Context->preference('AutoClaimReturnStatusOnCheckout');
459
                    my $resolution = $autoClaimReturnCheckout;
444
460
445
        my $claims = Koha::Checkouts::ReturnClaims->search(
461
                    $claim->resolve(
446
            {
462
                        {
447
                itemnumber => $item->id,
463
                            resolution  => $resolution,
464
                            resolved_by => $patron_id,
465
                        }
466
                    );
467
                    $template_params->{CLAIM_RESOLUTION} = $claim;
468
                }
448
            }
469
            }
449
        );
470
        }
450
        if ( $claims->count ) {
451
            if ($autoClaimReturnCheckout) {
452
                my $claim = $claims->next;
453
471
454
                my $patron_id  = $logged_in_user->borrowernumber;
472
        if ( $item and ( !$blocker or $force_allow_issue ) ) {
455
                my $resolution = $autoClaimReturnCheckout;
473
            my $confirm_required = 0;
474
            unless ($issueconfirmed) {
456
475
457
                $claim->resolve(
476
                #  Get the item title for more information
477
                my $materials    = $item->materials;
478
                my $descriptions = Koha::AuthorisedValues->get_description_by_koha_field(
458
                    {
479
                    {
459
                        resolution  => $resolution,
480
                        frameworkcode    => $biblio->frameworkcode, kohafield => 'items.materials',
460
                        resolved_by => $patron_id,
481
                        authorised_value => $materials
461
                    }
482
                    }
462
                );
483
                );
463
                $template_params->{CLAIM_RESOLUTION} = $claim;
484
                $materials                               = $descriptions->{lib} // $materials;
464
            }
485
                $template_params->{ADDITIONAL_MATERIALS} = $materials;
465
        }
486
                $template_params->{itemhomebranch}       = $item->homebranch;
466
    }
487
488
                my $patron_session_confirmation = $query->cookie('patronSessionConfirmation') || undef;
489
                my ( $patron_for_session, $session_confirmations ) = split( /:/, $patron_session_confirmation, 2 );
490
                my $patron_match = $borrowernumber == $patron_for_session;
491
                my @conf_keys    = split( /\|/, $session_confirmations );
492
                $template_params->{sessionConfirmationKeys} = ();
493
494
                # pass needsconfirmation to template if issuing is possible and user hasn't yet confirmed.
495
                foreach my $needsconfirmation_key ( keys %$needsconfirmation ) {
496
                    if ( $needsconfirmation_key eq 'BOOKED_TO_ANOTHER' ) {
497
                        my $rule = Koha::CirculationRules->get_effective_rule(
498
                            {
499
                                rule_name  => 'bookings_lead_period',
500
                                itemtype   => $item->effective_itemtype,
501
                                branchcode => "*"
502
                            }
503
                        );
504
                        my $preparation_period = $rule ? $rule->rule_value : 1;
505
                        my $reduceddue = dt_from_string( $$needsconfirmation{$needsconfirmation_key}->start_date )
467
506
468
    if( $item and ( !$blocker or $force_allow_issue ) ){
507
                            ->subtract( days => $preparation_period );
469
        my $confirm_required = 0;
508
                        $template_params->{reduceddue} = $reduceddue;
470
        unless($issueconfirmed){
509
                    }
471
            #  Get the item title for more information
510
                    next
472
            my $materials = $item->materials;
511
                        if $patron_match
473
            my $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({ frameworkcode => $biblio->frameworkcode, kohafield => 'items.materials', authorised_value => $materials });
512
                        && scalar(@conf_keys) > 0
474
            $materials = $descriptions->{lib} // $materials;
513
                        && grep( { $needsconfirmation_key eq $_ } @conf_keys );
475
            $template_params->{ADDITIONAL_MATERIALS} = $materials;
514
476
            $template_params->{itemhomebranch} = $item->homebranch;
515
                    $template_params->{$needsconfirmation_key}    = $needsconfirmation->{$needsconfirmation_key};
477
516
                    $template_params->{getTitleMessageIteminfo}   = $biblio->title;
478
            my $patron_session_confirmation = $query->cookie('patronSessionConfirmation') || undef;
517
                    $template_params->{getBarcodeMessageIteminfo} = $item->barcode;
479
            my ( $patron_for_session, $session_confirmations ) = split( /:/, $patron_session_confirmation, 2 );
518
                    $template_params->{NEEDSCONFIRMATION}         = 1;
480
            my $patron_match = $borrowernumber == $patron_for_session;
519
                    $confirm_required                             = 1;
481
            my @conf_keys    = split( /\|/, $session_confirmations );
520
                    push( @{ $template_params->{sessionConfirmationKeys} }, $needsconfirmation_key );
482
            $template_params->{sessionConfirmationKeys} = ();
521
                }
483
522
            }
484
            # pass needsconfirmation to template if issuing is possible and user hasn't yet confirmed.
523
            unless ($confirm_required) {
485
            foreach my $needsconfirmation_key ( keys %$needsconfirmation ) {
524
                my $switch_onsite_checkout = exists $messages->{ONSITE_CHECKOUT_WILL_BE_SWITCHED};
486
                if ( $needsconfirmation_key eq 'BOOKED_TO_ANOTHER' ) {
525
                if ( C4::Context->preference('UseRecalls') && !$recall_id ) {
487
                    my $rule = Koha::CirculationRules->get_effective_rule(
526
                    my $recall = Koha::Recalls->find(
488
                        {
527
                        {
489
                            rule_name  => 'bookings_lead_period',
528
                            biblio_id => $item->biblionumber,
490
                            itemtype   => $item->effective_itemtype,
529
                            item_id   => [ undef,       $item->itemnumber ],
491
                            branchcode => "*"
530
                            status    => [ 'requested', 'waiting' ],
531
                            completed => 0,
532
                            patron_id => $patron->borrowernumber,
492
                        }
533
                        }
493
                    );
534
                    );
494
                    my $preparation_period = $rule ? $rule->rule_value : 1;
535
                    $recall_id = ( $recall and $recall->id ) ? $recall->id : undef;
495
                    my $reduceddue =
496
                        dt_from_string( $$needsconfirmation{$needsconfirmation_key}->start_date )
497
                        ->subtract( days => $preparation_period );
498
                    $template_params->{reduceddue} = $reduceddue;
499
                }
536
                }
500
                next
537
501
                    if $patron_match
538
                # If booked (alerts or confirmation) update datedue to end of booking
502
                    && scalar(@conf_keys) > 0
539
                if ( my $booked = $needsconfirmation->{BOOKED_EARLY} // $alerts->{BOOKED} ) {
503
                    && grep( { $needsconfirmation_key eq $_ } @conf_keys );
540
                    $datedue = $booked->end_date;
504
541
                }
505
                $template_params->{$needsconfirmation_key}    = $needsconfirmation->{$needsconfirmation_key};
542
                my $issue = AddIssue(
506
                $template_params->{getTitleMessageIteminfo}   = $biblio->title;
543
                    $patron, $barcode, $datedue,
507
                $template_params->{getBarcodeMessageIteminfo} = $item->barcode;
544
                    $cancelreserve,
508
                $template_params->{NEEDSCONFIRMATION}         = 1;
545
                    undef, undef,
509
                $confirm_required                             = 1;
510
                push( @{ $template_params->{sessionConfirmationKeys} }, $needsconfirmation_key );
511
            }
512
        }
513
        unless ($confirm_required) {
514
            my $switch_onsite_checkout = exists $messages->{ONSITE_CHECKOUT_WILL_BE_SWITCHED};
515
            if ( C4::Context->preference('UseRecalls') && !$recall_id ) {
516
                my $recall = Koha::Recalls->find(
517
                    {
546
                    {
518
                        biblio_id => $item->biblionumber,
547
                        onsite_checkout        => $onsite_checkout,        auto_renew => $session->param('auto_renew'),
519
                        item_id   => [ undef,       $item->itemnumber ],
548
                        switch_onsite_checkout => $switch_onsite_checkout, cancel_recall => $cancel_recall,
520
                        status    => [ 'requested', 'waiting' ],
549
                        recall_id              => $recall_id,
521
                        completed => 0,
522
                        patron_id => $patron->borrowernumber,
523
                    }
550
                    }
524
                );
551
                );
525
                $recall_id = ( $recall and $recall->id ) ? $recall->id : undef;
552
                $template_params->{issue} = $issue;
553
                $session->clear('auto_renew');
554
                $inprocess = 1;
526
            }
555
            }
556
        }
527
557
528
            # If booked (alerts or confirmation) update datedue to end of booking
558
        if (   $needsconfirmation->{RESERVE_WAITING}
529
            if ( my $booked = $needsconfirmation->{BOOKED_EARLY} // $alerts->{BOOKED} ) {
559
            or $needsconfirmation->{RESERVED}
530
                $datedue = $booked->end_date;
560
            or $needsconfirmation->{TRANSFERRED}
531
            }
561
            or $needsconfirmation->{PROCESSING} )
532
            my $issue = AddIssue(
562
        {
533
                $patron, $barcode, $datedue,
563
            $template->param(
534
                $cancelreserve,
564
                reserveborrowernumber => $needsconfirmation->{'resborrowernumber'},
535
                undef, undef,
565
                reserve_id            => $needsconfirmation->{reserve_id},
536
                {
537
                    onsite_checkout        => $onsite_checkout,        auto_renew    => $session->param('auto_renew'),
538
                    switch_onsite_checkout => $switch_onsite_checkout, cancel_recall => $cancel_recall,
539
                    recall_id              => $recall_id,
540
                }
541
            );
566
            );
542
            $template_params->{issue} = $issue;
543
            $session->clear('auto_renew');
544
            $inprocess = 1;
545
        }
567
        }
546
    }
547
568
548
    if ($needsconfirmation->{RESERVE_WAITING} or $needsconfirmation->{RESERVED} or $needsconfirmation->{TRANSFERRED} or $needsconfirmation->{PROCESSING}){
569
        # FIXME If the issue is confirmed, we launch another time checkouts->count, now display the issue count after issue
570
        $patron = Koha::Patrons->find($borrowernumber);
571
        $template_params->{issuecount} = $patron->checkouts->count;
572
573
        if ($item) {
574
            $template_params->{item}             = $item;
575
            $template_params->{biblio}           = $biblio;
576
            $template_params->{itembiblionumber} = $biblio->biblionumber;
577
        }
578
        push @$checkout_infos, $template_params;
579
    }
580
    unless ($batch) {
581
        $template->param( %{ $checkout_infos->[0] } );
582
        $template->param( barcode => $barcodes->[0] );
583
    } else {
584
        my $confirmation_needed = grep { $_->{NEEDSCONFIRMATION} } @$checkout_infos;
549
        $template->param(
585
        $template->param(
550
            reserveborrowernumber => $needsconfirmation->{'resborrowernumber'},
586
            checkout_infos      => $checkout_infos,
551
            reserve_id => $needsconfirmation->{reserve_id},
587
            onsite_checkout     => $onsite_checkout,
588
            confirmation_needed => $confirmation_needed,
552
        );
589
        );
553
    }
590
    }
554
555
556
    # FIXME If the issue is confirmed, we launch another time checkouts->count, now display the issue count after issue
557
    $patron = Koha::Patrons->find( $borrowernumber );
558
    $template_params->{issuecount} = $patron->checkouts->count;
559
560
    if ( $item ) {
561
        $template_params->{item} = $item;
562
        $template_params->{biblio} = $biblio;
563
        $template_params->{itembiblionumber} = $biblio->biblionumber;
564
    }
565
    push @$checkout_infos, $template_params;
566
  }
567
  unless ( $batch ) {
568
    $template->param( %{$checkout_infos->[0]} );
569
    $template->param( barcode => $barcodes->[0] );
570
  } else {
571
    my $confirmation_needed = grep { $_->{NEEDSCONFIRMATION} } @$checkout_infos;
572
    $template->param(
573
        checkout_infos      => $checkout_infos,
574
        onsite_checkout     => $onsite_checkout,
575
        confirmation_needed => $confirmation_needed,
576
    );
577
  }
578
}
591
}
579
592
580
##################################################################################
593
##################################################################################
581
# BUILD HTML
594
# BUILD HTML
582
# show all reserves of this borrower, and the position of the reservation ....
595
# show all reserves of this borrower, and the position of the reservation ....
583
if ($patron) {
596
if ($patron) {
584
    my $holds = Koha::Holds->search( { borrowernumber => $borrowernumber } ); # FIXME must be Koha::Patron->holds
597
    my $holds = Koha::Holds->search( { borrowernumber => $borrowernumber } );    # FIXME must be Koha::Patron->holds
585
    my $waiting_holds = $holds->waiting;
598
    my $waiting_holds = $holds->waiting;
586
    $template->param(
599
    $template->param(
587
        holds_count  => $holds->count(),
600
        holds_count  => $holds->count(),
Lines 589-615 if ($patron) { Link Here
589
    );
602
    );
590
603
591
    if ( C4::Context->preference('UseRecalls') ) {
604
    if ( C4::Context->preference('UseRecalls') ) {
592
        my $waiting_recalls = $patron->recalls->search({ status => 'waiting' });
605
        my $waiting_recalls = $patron->recalls->search( { status => 'waiting' } );
593
        $template->param(
606
        $template->param(
594
            recalls => $patron->recalls->filter_by_current->search({},{ order_by => { -asc => 'created_date' } }),
607
            recalls => $patron->recalls->filter_by_current->search( {}, { order_by => { -asc => 'created_date' } } ),
595
            specific_patron => 1,
608
            specific_patron => 1,
596
            waiting_recalls => $waiting_recalls,
609
            waiting_recalls => $waiting_recalls,
597
        );
610
        );
598
    }
611
    }
599
}
612
}
600
613
601
if ( $patron ) {
614
if ($patron) {
602
    my $noissues;
615
    my $noissues;
603
    if ( $patron->gonenoaddress ) {
616
    if ( $patron->gonenoaddress ) {
604
        $template->param( gonenoaddress => 1 );
617
        $template->param( gonenoaddress => 1 );
605
        $noissues = 1;
618
        $noissues = 1;
606
    }
619
    }
607
    if ( $patron->lost ) {
620
    if ( $patron->lost ) {
608
        $template->param( lost=> 1 );
621
        $template->param( lost => 1 );
609
        $noissues = 1;
622
        $noissues = 1;
610
    }
623
    }
611
    if ( $patron->is_debarred ) {
624
    if ( $patron->is_debarred ) {
612
        $template->param( is_debarred=> 1 );
625
        $template->param( is_debarred => 1 );
613
        $noissues = 1;
626
        $noissues = 1;
614
    }
627
    }
615
    if ( $patron->borrowernumber eq C4::Context->preference("AnonymousPatron") ) {
628
    if ( $patron->borrowernumber eq C4::Context->preference("AnonymousPatron") ) {
Lines 617-632 if ( $patron ) { Link Here
617
        $noissues = 1;
630
        $noissues = 1;
618
    }
631
    }
619
    my $patron_charge_limits = $patron->is_patron_inside_charge_limits();
632
    my $patron_charge_limits = $patron->is_patron_inside_charge_limits();
620
    if( $patron_charge_limits->{noissuescharge}->{charge} > 0 ) {
633
    if ( $patron_charge_limits->{noissuescharge}->{charge} > 0 ) {
621
        my $noissuescharge = $patron_charge_limits->{noissuescharge}->{limit} || 5; # FIXME If noissuescharge == 0 then 5, why??
634
        my $noissuescharge =
622
        $noissues ||= ( not C4::Context->preference("AllowFineOverride") and $patron_charge_limits->{noissuescharge}->{overlimit} );
635
            $patron_charge_limits->{noissuescharge}->{limit} || 5;    # FIXME If noissuescharge == 0 then 5, why??
636
        $noissues ||= ( not C4::Context->preference("AllowFineOverride")
637
                and $patron_charge_limits->{noissuescharge}->{overlimit} );
623
        $template->param(
638
        $template->param(
624
            charges => 1,
639
            charges       => 1,
625
            chargesamount => $patron_charge_limits->{noissuescharge}->{charge},
640
            chargesamount => $patron_charge_limits->{noissuescharge}->{charge},
626
        )
641
        );
627
    } elsif ( $balance < 0 ) {
642
    } elsif ( $balance < 0 ) {
628
        $template->param(
643
        $template->param(
629
            credits => 1,
644
            credits       => 1,
630
            creditsamount => -$balance,
645
            creditsamount => -$balance,
631
        );
646
        );
632
    }
647
    }
Lines 635-643 if ( $patron ) { Link Here
635
    my $no_issues_charge_guarantors = $patron_charge_limits->{NoIssuesChargeGuarantorsWithGuarantees}->{limit};
650
    my $no_issues_charge_guarantors = $patron_charge_limits->{NoIssuesChargeGuarantorsWithGuarantees}->{limit};
636
    if ($no_issues_charge_guarantors) {
651
    if ($no_issues_charge_guarantors) {
637
        if ( $patron_charge_limits->{NoIssuesChargeGuarantorsWithGuarantees}->{overlimit} ) {
652
        if ( $patron_charge_limits->{NoIssuesChargeGuarantorsWithGuarantees}->{overlimit} ) {
638
            $template->param(
653
            $template->param( charges_guarantors_guarantees =>
639
                charges_guarantors_guarantees => $patron_charge_limits->{NoIssuesChargeGuarantorsWithGuarantees}->{charge}
654
                    $patron_charge_limits->{NoIssuesChargeGuarantorsWithGuarantees}->{charge} );
640
            );
641
            $noissues = 1 unless C4::Context->preference("allowfineoverride");
655
            $noissues = 1 unless C4::Context->preference("allowfineoverride");
642
        }
656
        }
643
    }
657
    }
Lines 646-652 if ( $patron ) { Link Here
646
    if ( defined $no_issues_charge_guarantees ) {
660
    if ( defined $no_issues_charge_guarantees ) {
647
        if ( $patron_charge_limits->{NoIssuesChargeGuarantees}->{overlimit} ) {
661
        if ( $patron_charge_limits->{NoIssuesChargeGuarantees}->{overlimit} ) {
648
            $template->param(
662
            $template->param(
649
                charges_guarantees    => 1,
663
                charges_guarantees       => 1,
650
                chargesamount_guarantees => $patron_charge_limits->{NoIssuesChargeGuarantees}->{charge},
664
                chargesamount_guarantees => $patron_charge_limits->{NoIssuesChargeGuarantees}->{charge},
651
            );
665
            );
652
            $noissues = 1 unless C4::Context->preference("allowfineoverride");
666
            $noissues = 1 unless C4::Context->preference("allowfineoverride");
Lines 661-674 if ( $patron ) { Link Here
661
        my $borrowernotes = $patron->borrowernotes;
675
        my $borrowernotes = $patron->borrowernotes;
662
        $borrowernotes =~ s#\n#<br />#g;
676
        $borrowernotes =~ s#\n#<br />#g;
663
        $template->param(
677
        $template->param(
664
            notes =>1,
678
            notes    => 1,
665
            notesmsg => $borrowernotes,
679
            notesmsg => $borrowernotes,
666
        )
680
        );
667
    }
681
    }
668
682
669
    if ( $noissues ) {
683
    if ($noissues) {
670
        $template->param(
684
        $template->param(
671
            noissues => ($force_allow_issue) ? 0 : 'true',
685
            noissues   => ($force_allow_issue) ? 0 : 'true',
672
            forceallow => $force_allow_issue,
686
            forceallow => $force_allow_issue,
673
        );
687
        );
674
    }
688
    }
Lines 676-684 if ( $patron ) { Link Here
676
    my $patron_messages = $patron->messages->search(
690
    my $patron_messages = $patron->messages->search(
677
        {},
691
        {},
678
        {
692
        {
679
           join => 'manager',
693
            join      => 'manager',
680
           '+select' => ['manager.surname', 'manager.firstname' ],
694
            '+select' => [ 'manager.surname', 'manager.firstname' ],
681
           '+as' => ['manager_surname', 'manager_firstname'],
695
            '+as'     => [ 'manager_surname', 'manager_firstname' ],
682
        }
696
        }
683
    );
697
    );
684
    $template->param( patron_messages => $patron_messages );
698
    $template->param( patron_messages => $patron_messages );
Lines 691-705 if ( $patron ) { Link Here
691
705
692
my $fast_cataloging = 0;
706
my $fast_cataloging = 0;
693
if ( Koha::BiblioFrameworks->find('FA') ) {
707
if ( Koha::BiblioFrameworks->find('FA') ) {
694
    $fast_cataloging = 1 
708
    $fast_cataloging = 1;
695
}
709
}
696
710
697
my $view = $batch
711
my $view =
698
    ?'batch_checkout_view'
712
    $batch
713
    ? 'batch_checkout_view'
699
    : 'circview';
714
    : 'circview';
700
715
701
my @relatives;
716
my @relatives;
702
if ( $patron ) {
717
if ($patron) {
703
    if ( my @guarantors = $patron->guarantor_relationships()->guarantors->as_list ) {
718
    if ( my @guarantors = $patron->guarantor_relationships()->guarantors->as_list ) {
704
        push( @relatives, $_->id ) for @guarantors;
719
        push( @relatives, $_->id ) for @guarantors;
705
        push( @relatives, $_->id ) for $patron->siblings->as_list;
720
        push( @relatives, $_->id ) for $patron->siblings->as_list;
Lines 708-782 if ( $patron ) { Link Here
708
    }
723
    }
709
}
724
}
710
my $relatives_issues_count =
725
my $relatives_issues_count =
711
  Koha::Database->new()->schema()->resultset('Issue')
726
    Koha::Database->new()->schema()->resultset('Issue')->count( { borrowernumber => \@relatives } );
712
  ->count( { borrowernumber => \@relatives } );
713
727
714
if ( $patron ) {
728
if ($patron) {
715
    my $av = Koha::AuthorisedValues->search({ category => 'ROADTYPE', authorised_value => $patron->streettype });
729
    my $av = Koha::AuthorisedValues->search( { category => 'ROADTYPE', authorised_value => $patron->streettype } );
716
    my $roadtype = $av->count ? $av->next->lib : '';
730
    my $roadtype = $av->count ? $av->next->lib : '';
717
    $template->param(
731
    $template->param(
718
        roadtype          => $roadtype,
732
        roadtype     => $roadtype,
719
        patron            => $patron,
733
        patron       => $patron,
720
        categoryname      => $patron->category->description,
734
        categoryname => $patron->category->description,
721
        expiry            => $patron->dateexpiry,
735
        expiry       => $patron->dateexpiry,
722
    );
736
    );
723
}
737
}
724
738
725
# Restore date if changed by holds and/or save stickyduedate to session
739
# Restore date if changed by holds and/or save stickyduedate to session
726
if ($restoreduedatespec || $stickyduedate) {
740
if ( $restoreduedatespec || $stickyduedate ) {
727
    $duedatespec = $restoreduedatespec || $duedatespec;
741
    $duedatespec = $restoreduedatespec || $duedatespec;
728
742
729
    if ($stickyduedate) {
743
    if ($stickyduedate) {
730
        $session->param( 'stickyduedate', $duedatespec );
744
        $session->param( 'stickyduedate', $duedatespec );
731
    }
745
    }
732
} elsif (defined($duedatespec) && !defined($restoreduedatespec)) {
746
} elsif ( defined($duedatespec) && !defined($restoreduedatespec) ) {
733
    undef $duedatespec;
747
    undef $duedatespec;
734
}
748
}
735
749
736
$template->param(
750
$template->param(
737
    borrowernumber    => $borrowernumber,
751
    borrowernumber            => $borrowernumber,
738
    branch            => $branch,
752
    branch                    => $branch,
739
    was_renewed       => scalar $query->param('was_renewed') ? 1 : 0,
753
    was_renewed               => scalar $query->param('was_renewed') ? 1 : 0,
740
    barcodes          => $barcodes,
754
    barcodes                  => $barcodes,
741
    stickyduedate     => $stickyduedate,
755
    stickyduedate             => $stickyduedate,
742
    duedatespec       => $duedatespec,
756
    duedatespec               => $duedatespec,
743
    restoreduedatespec => $restoreduedatespec,
757
    restoreduedatespec        => $restoreduedatespec,
744
    message           => $message,
758
    message                   => $message,
745
    totaldue          => sprintf('%.2f', $balance), # FIXME not used in template?
759
    totaldue                  => sprintf( '%.2f', $balance ),                         # FIXME not used in template?
746
    inprocess         => $inprocess,
760
    inprocess                 => $inprocess,
747
    $view             => 1,
761
    $view                     => 1,
748
    batch_allowed     => $batch_allowed,
762
    batch_allowed             => $batch_allowed,
749
    batch             => $batch,
763
    batch                     => $batch,
750
    AudioAlerts           => C4::Context->preference("AudioAlerts"),
764
    AudioAlerts               => C4::Context->preference("AudioAlerts"),
751
    fast_cataloging   => $fast_cataloging,
765
    fast_cataloging           => $fast_cataloging,
752
    CircAutoPrintQuickSlip   => C4::Context->preference("CircAutoPrintQuickSlip"),
766
    CircAutoPrintQuickSlip    => C4::Context->preference("CircAutoPrintQuickSlip"),
753
    RoutingSerials => C4::Context->preference('RoutingSerials'),
767
    RoutingSerials            => C4::Context->preference('RoutingSerials'),
754
    relatives_issues_count => $relatives_issues_count,
768
    relatives_issues_count    => $relatives_issues_count,
755
    relatives_borrowernumbers => \@relatives,
769
    relatives_borrowernumbers => \@relatives,
756
);
770
);
757
771
758
759
if ( C4::Context->preference("ExportCircHistory") ) {
772
if ( C4::Context->preference("ExportCircHistory") ) {
760
    $template->param(csv_profiles => Koha::CsvProfiles->search({ type => 'marc' }));
773
    $template->param( csv_profiles => Koha::CsvProfiles->search( { type => 'marc' } ) );
761
}
774
}
762
775
763
my ( $has_modifications, $patron_lists_count);
776
my ( $has_modifications, $patron_lists_count );
764
if ( $patron ) {
777
if ($patron) {
765
    $has_modifications = Koha::Patron::Modifications->search( { borrowernumber => $borrowernumber } )->count;
778
    $has_modifications  = Koha::Patron::Modifications->search( { borrowernumber => $borrowernumber } )->count;
766
    $patron_lists_count = $patron->get_lists_with_patron->count();
779
    $patron_lists_count = $patron->get_lists_with_patron->count();
767
}
780
}
768
$template->param(
781
$template->param(
769
    debt_confirmed            => $debt_confirmed,
782
    debt_confirmed          => $debt_confirmed,
770
    SpecifyDueDate            => $duedatespec_allow,
783
    SpecifyDueDate          => $duedatespec_allow,
771
    PatronAutoComplete        => C4::Context->preference("PatronAutoComplete"),
784
    PatronAutoComplete      => C4::Context->preference("PatronAutoComplete"),
772
    today_due_date_and_time   => dt_from_string()->set(hour => 23)->set(minute => 59),
785
    today_due_date_and_time => dt_from_string()->set( hour => 23 )->set( minute => 59 ),
773
    restriction_types         => scalar Koha::Patron::Restriction::Types->search(),
786
    restriction_types       => scalar Koha::Patron::Restriction::Types->search(),
774
    has_modifications         => $has_modifications,
787
    has_modifications       => $has_modifications,
775
    patron_lists_count        => $patron_lists_count,
788
    patron_lists_count      => $patron_lists_count,
776
    override_high_holds       => $override_high_holds,
789
    override_high_holds     => $override_high_holds,
777
    nopermission              => scalar $query->param('nopermission'),
790
    nopermission            => scalar $query->param('nopermission'),
778
    autoswitched              => $autoswitched,
791
    autoswitched            => $autoswitched,
779
    logged_in_user            => $logged_in_user,
792
    logged_in_user          => $logged_in_user,
780
);
793
);
781
794
782
output_html_with_http_headers $query, $cookie, $template->output;
795
output_html_with_http_headers $query, $cookie, $template->output;
783
- 

Return to bug 14787