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

(-)a/circ/circulation.pl (-43 / +55 lines)
Lines 463-515 if (@$barcodes && $op eq 'cud-checkout') { Link Here
463
            }
463
            }
464
        }
464
        }
465
465
466
        if( $item and ( !$blocker or $force_allow_issue ) ){
466
    if( $item and ( !$blocker or $force_allow_issue ) ){
467
            my $confirm_required = 0;
467
        my $confirm_required = 0;
468
            unless($issueconfirmed){
468
        unless($issueconfirmed){
469
                #  Get the item title for more information
469
            #  Get the item title for more information
470
                my $materials = $item->materials;
470
            my $materials = $item->materials;
471
                my $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({ frameworkcode => $biblio->frameworkcode, kohafield => 'items.materials', authorised_value => $materials });
471
            my $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({ frameworkcode => $biblio->frameworkcode, kohafield => 'items.materials', authorised_value => $materials });
472
                $materials = $descriptions->{lib} // $materials;
472
            $materials = $descriptions->{lib} // $materials;
473
                $template_params->{ADDITIONAL_MATERIALS} = $materials;
473
            $template_params->{ADDITIONAL_MATERIALS} = $materials;
474
                $template_params->{itemhomebranch} = $item->homebranch;
474
            $template_params->{itemhomebranch} = $item->homebranch;
475
475
476
                # pass needsconfirmation to template if issuing is possible and user hasn't yet confirmed.
476
            my $patron_session_confirmation = $query->cookie('patronSessionConfirmation') || undef;
477
                foreach my $needsconfirmation_key ( keys %$needsconfirmation ) {
477
            my ( $patron_for_session, $session_confirmations ) = split( /:/, $patron_session_confirmation, 2 );
478
                    $template_params->{$needsconfirmation_key} = $needsconfirmation->{$needsconfirmation_key};
478
            my $patron_match = $borrowernumber == $patron_for_session;
479
                    $template_params->{getTitleMessageIteminfo} = $biblio->title;
479
            my @conf_keys    = split( /\|/, $session_confirmations );
480
                    $template_params->{getBarcodeMessageIteminfo} = $item->barcode;
480
            $template_params->{sessionConfirmationKeys} = ();
481
                    $template_params->{NEEDSCONFIRMATION} = 1;
481
482
                    $confirm_required = 1;
482
            # pass needsconfirmation to template if issuing is possible and user hasn't yet confirmed.
483
                    if ( $needsconfirmation_key eq 'BOOKED_TO_ANOTHER' ) {
483
            foreach my $needsconfirmation_key ( keys %$needsconfirmation ) {
484
                        my $rule = Koha::CirculationRules->get_effective_rule(
484
                if ( $needsconfirmation_key eq 'BOOKED_TO_ANOTHER' ) {
485
                            {
485
                    my $rule = Koha::CirculationRules->get_effective_rule(
486
                                rule_name  => 'bookings_lead_period',
487
                                itemtype   => $item->effective_itemtype,
488
                                branchcode => "*"
489
                            }
490
                        );
491
                        my $preparation_period = $rule ? $rule->rule_value : 1;
492
                        my $reduceddue =
493
                            dt_from_string( $$needsconfirmation{$needsconfirmation_key}->start_date )
494
                            ->subtract( days => $preparation_period );
495
                        $template_params->{reduceddue} = $reduceddue;
496
                    }
497
                }
498
            }
499
            unless ($confirm_required) {
500
                my $switch_onsite_checkout = exists $messages->{ONSITE_CHECKOUT_WILL_BE_SWITCHED};
501
                if ( C4::Context->preference('UseRecalls') && !$recall_id ) {
502
                    my $recall = Koha::Recalls->find(
503
                        {
486
                        {
504
                            biblio_id => $item->biblionumber,
487
                            rule_name  => 'bookings_lead_period',
505
                            item_id   => [ undef,       $item->itemnumber ],
488
                            itemtype   => $item->effective_itemtype,
506
                            status    => [ 'requested', 'waiting' ],
489
                            branchcode => "*"
507
                            completed => 0,
508
                            patron_id => $patron->borrowernumber,
509
                        }
490
                        }
510
                    );
491
                    );
511
                    $recall_id = ( $recall and $recall->id ) ? $recall->id : undef;
492
                    my $preparation_period = $rule ? $rule->rule_value : 1;
493
                    my $reduceddue =
494
                        dt_from_string( $$needsconfirmation{$needsconfirmation_key}->start_date )
495
                        ->subtract( days => $preparation_period );
496
                    $template_params->{reduceddue} = $reduceddue;
512
                }
497
                }
498
                next
499
                    if $patron_match
500
                    && scalar(@conf_keys) > 0
501
                    && grep( { $needsconfirmation_key eq $_ } @conf_keys );
502
503
                $template_params->{$needsconfirmation_key}    = $needsconfirmation->{$needsconfirmation_key};
504
                $template_params->{getTitleMessageIteminfo}   = $biblio->title;
505
                $template_params->{getBarcodeMessageIteminfo} = $item->barcode;
506
                $template_params->{NEEDSCONFIRMATION}         = 1;
507
                $confirm_required                             = 1;
508
                push( @{ $template_params->{sessionConfirmationKeys} }, $needsconfirmation_key );
509
            }
510
        }
511
        unless ($confirm_required) {
512
            my $switch_onsite_checkout = exists $messages->{ONSITE_CHECKOUT_WILL_BE_SWITCHED};
513
            if ( C4::Context->preference('UseRecalls') && !$recall_id ) {
514
                my $recall = Koha::Recalls->find(
515
                    {
516
                        biblio_id => $item->biblionumber,
517
                        item_id   => [ undef,       $item->itemnumber ],
518
                        status    => [ 'requested', 'waiting' ],
519
                        completed => 0,
520
                        patron_id => $patron->borrowernumber,
521
                    }
522
                );
523
                $recall_id = ( $recall and $recall->id ) ? $recall->id : undef;
524
            }
513
525
514
                # If booked (alerts or confirmation) update datedue to end of booking
526
                # If booked (alerts or confirmation) update datedue to end of booking
515
                if ( my $booked = $needsconfirmation->{BOOKED_EARLY} // $alerts->{BOOKED} ) {
527
                if ( my $booked = $needsconfirmation->{BOOKED_EARLY} // $alerts->{BOOKED} ) {
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt (-2 / +16 lines)
Lines 277-287 Link Here
277
                            </ul>
277
                            </ul>
278
278
279
                            [% IF CAN_user_circulate_force_checkout or HIGHHOLDS %]
279
                            [% IF CAN_user_circulate_force_checkout or HIGHHOLDS %]
280
                                <form method="post" action="/cgi-bin/koha/circ/circulation.pl" autocomplete="off">
280
                                <form method="post" action="/cgi-bin/koha/circ/circulation.pl" autocomplete="off" class="confirmation-required-form">
281
                                    [% INCLUDE 'csrf-token.inc' %]
281
                                    [% INCLUDE 'csrf-token.inc' %]
282
                                    <fieldset>
282
                                    <fieldset>
283
                                    <input type="hidden" name="restoreduedatespec" />
283
                                    <input type="hidden" name="restoreduedatespec" />
284
                                    <input type="hidden" name="op" value="cud-checkout" />
284
                                    <input type="hidden" name="op" value="cud-checkout" />
285
                                    [% FOREACH conf IN sessionConfirmationKeys %]
286
                                        <input type="hidden" name="session_confirmations" id="session_confirmations" value="[% conf | html %]" />
287
                                    [% END %]
285
288
286
                                    [% IF (forceallow) %]<input type="hidden" name="forceallow" value="1">[% END %]
289
                                    [% IF (forceallow) %]<input type="hidden" name="forceallow" value="1">[% END %]
287
290
Lines 376-381 Link Here
376
                                    [% IF ( RENEW_ISSUE ) %]
379
                                    [% IF ( RENEW_ISSUE ) %]
377
                                        <button type="submit" class="btn btn-default approve" accesskey="y"><i class="fa fa-check"></i> Yes, renew (Y)</button>
380
                                        <button type="submit" class="btn btn-default approve" accesskey="y"><i class="fa fa-check"></i> Yes, renew (Y)</button>
378
                                    [% ELSE %]
381
                                    [% ELSE %]
382
                                        <p>
383
                                            <label for="patron_session_confirmation">Remember for the session for this patron</label>
384
                                            <input type="checkbox" id="patron_session_confirmation" name="patron_session_confirmation" />
385
                                        </p>
379
                                        <button type="submit" class="btn btn-default approve" accesskey="y"><i class="fa fa-check"></i> Yes, check out (Y)</button>
386
                                        <button type="submit" class="btn btn-default approve" accesskey="y"><i class="fa fa-check"></i> Yes, check out (Y)</button>
380
                                    [% END %]
387
                                    [% END %]
381
388
Lines 386-395 Link Here
386
                            [% END # /IF CAN_user_circulate_force_checkout or HIGHHOLDS %]
393
                            [% END # /IF CAN_user_circulate_force_checkout or HIGHHOLDS %]
387
394
388
                            [% IF ADDITIONAL_MATERIALS && !CAN_user_circulate_force_checkout %]
395
                            [% IF ADDITIONAL_MATERIALS && !CAN_user_circulate_force_checkout %]
389
                                <form method="post" action="/cgi-bin/koha/circ/circulation.pl" autocomplete="off">
396
                                <form method="post" action="/cgi-bin/koha/circ/circulation.pl" autocomplete="off" class="confirmation-required-form">
390
                                    [% INCLUDE 'csrf-token.inc' %]
397
                                    [% INCLUDE 'csrf-token.inc' %]
391
                                    <input type="hidden" name="op" value="cud-checkout" />
398
                                    <input type="hidden" name="op" value="cud-checkout" />
392
                                    <input type="hidden" name="restoreduedatespec" />
399
                                    <input type="hidden" name="restoreduedatespec" />
400
                                    [% FOREACH conf IN sessionConfirmationKeys %]
401
                                        <input type="hidden" name="session_confirmations" id="session_confirmations" value="[% conf | html %]" />
402
                                    [% END %]
393
403
394
                                    [% IF (forceallow) %]<input type="hidden" name="forceallow" value="1">[% END %]
404
                                    [% IF (forceallow) %]<input type="hidden" name="forceallow" value="1">[% END %]
395
405
Lines 403-408 Link Here
403
                                    [% IF ( RENEW_ISSUE ) %]
413
                                    [% IF ( RENEW_ISSUE ) %]
404
                                        <button type="submit" class="btn btn-default approve" accesskey="y"><i class="fa fa-check"></i> Yes, renew (Y)</button>
414
                                        <button type="submit" class="btn btn-default approve" accesskey="y"><i class="fa fa-check"></i> Yes, renew (Y)</button>
405
                                    [% ELSE %]
415
                                    [% ELSE %]
416
                                        <p>
417
                                            <label for="patron_session_confirmation">Remember for the session for this patron</label>
418
                                            <input type="checkbox" id="patron_session_confirmation" name="patron_session_confirmation" />
419
                                        </p>
406
                                        <button type="submit" class="btn btn-default approve" accesskey="y"><i class="fa fa-check"></i> Yes, check out (Y)</button>
420
                                        <button type="submit" class="btn btn-default approve" accesskey="y"><i class="fa fa-check"></i> Yes, check out (Y)</button>
407
                                    [% END %]
421
                                    [% END %]
408
422
(-)a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js (-1 / +34 lines)
Lines 1308-1311 $(document).ready(function() { Link Here
1308
        $("#return-claims-table").DataTable().search("is_unresolved").draw();
1308
        $("#return-claims-table").DataTable().search("is_unresolved").draw();
1309
    });
1309
    });
1310
1310
1311
    $(".confirmation-required-form").on("submit", function (e) {
1312
1313
        var currentCookieValue = Cookies.get("patronSessionConfirmation") || '';
1314
        var currentPatron = currentCookieValue.split(':')[0] || null;
1315
1316
        var rememberForSession = $('#patron_session_confirmation').is(":checked");
1317
        var sessionConfirmations = []
1318
        $('input[name^=session_confirmations]').each(function() {
1319
            sessionConfirmations.push($(this).val());
1320
        });
1321
1322
        if(currentPatron != borrowernumber && !rememberForSession) {
1323
            Cookies.set("patronSessionConfirmation", borrowernumber + ':', { sameSite: 'Lax' });
1324
            return true
1325
        }
1326
1327
        if(currentPatron == borrowernumber && rememberForSession) {
1328
            sessionConfirmations.forEach(function(sessionConfirmation) {
1329
                currentCookieValue += sessionConfirmation + '|';
1330
            })
1331
            Cookies.set("patronSessionConfirmation", currentCookieValue, { sameSite: 'Lax' });
1332
            return true
1333
        }
1334
1335
        if(currentPatron != borrowernumber && rememberForSession) {
1336
            var newCookieValue = borrowernumber + ':';
1337
            sessionConfirmations.forEach(function(sessionConfirmation) {
1338
                newCookieValue += sessionConfirmation + '|';
1339
            })
1340
            Cookies.set("patronSessionConfirmation", newCookieValue, { sameSite: 'Lax' });
1341
            return true
1342
        }
1343
        return true
1344
    });
1311
 });
1345
 });
1312
- 

Return to bug 14787