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

(-)a/C4/Circulation.pm (-7 / +8 lines)
Lines 412-418 sub TooMany { Link Here
412
    if (defined($maxissueqty_rule) and $maxissueqty_rule->rule_value ne '') {
412
    if (defined($maxissueqty_rule) and $maxissueqty_rule->rule_value ne '') {
413
        my @bind_params;
413
        my @bind_params;
414
        my $count_query = q|
414
        my $count_query = q|
415
            SELECT COUNT(*) AS total, COALESCE(SUM(onsite_checkout), 0) AS onsite_checkouts
415
            SELECT COUNT(*) AS total, COALESCE(SUM(CASE WHEN checkout_type = 'OS' THEN 1 ELSE 0 END), 0) AS onsite_checkouts
416
            FROM issues
416
            FROM issues
417
            JOIN items USING (itemnumber)
417
            JOIN items USING (itemnumber)
418
        |;
418
        |;
Lines 509-515 sub TooMany { Link Here
509
    if (defined($branch_borrower_circ_rule->{patron_maxissueqty}) and $branch_borrower_circ_rule->{patron_maxissueqty} ne '') {
509
    if (defined($branch_borrower_circ_rule->{patron_maxissueqty}) and $branch_borrower_circ_rule->{patron_maxissueqty} ne '') {
510
        my @bind_params = ();
510
        my @bind_params = ();
511
        my $branch_count_query = q|
511
        my $branch_count_query = q|
512
            SELECT COUNT(*) AS total, COALESCE(SUM(onsite_checkout), 0) AS onsite_checkouts
512
            SELECT COUNT(*) AS total, COALESCE(SUM(CASE WHEN checkout_type = 'OS' THEN 1 ELSE 0 END), 0) AS onsite_checkouts
513
            FROM issues
513
            FROM issues
514
            JOIN items USING (itemnumber)
514
            JOIN items USING (itemnumber)
515
            WHERE borrowernumber = ?
515
            WHERE borrowernumber = ?
Lines 852-858 sub CanBookBeIssued { Link Here
852
        # If it is an on-site checkout if it can be switched to a normal checkout
852
        # If it is an on-site checkout if it can be switched to a normal checkout
853
        # or ask whether the loan should be renewed
853
        # or ask whether the loan should be renewed
854
854
855
        if ( $issue->onsite_checkout
855
        if ( defined $issue->checkout_type && $issue->checkout_type eq 'OS'
856
                and C4::Context->preference('SwitchOnSiteCheckouts') ) {
856
                and C4::Context->preference('SwitchOnSiteCheckouts') ) {
857
            $messages{ONSITE_CHECKOUT_WILL_BE_SWITCHED} = 1;
857
            $messages{ONSITE_CHECKOUT_WILL_BE_SWITCHED} = 1;
858
        } else {
858
        } else {
Lines 902-908 sub CanBookBeIssued { Link Here
902
    my $switch_onsite_checkout = (
902
    my $switch_onsite_checkout = (
903
          C4::Context->preference('SwitchOnSiteCheckouts')
903
          C4::Context->preference('SwitchOnSiteCheckouts')
904
      and $issue
904
      and $issue
905
      and $issue->onsite_checkout
905
      and defined $issue->checkout_type
906
      and $issue->checkout_type eq 'OS'
906
      and $issue->borrowernumber == $patron->borrowernumber ? 1 : 0 );
907
      and $issue->borrowernumber == $patron->borrowernumber ? 1 : 0 );
907
    my $toomany = TooMany( $patron_unblessed, $item_object, { onsite_checkout => $onsite_checkout, switch_onsite_checkout => $switch_onsite_checkout, } );
908
    my $toomany = TooMany( $patron_unblessed, $item_object, { onsite_checkout => $onsite_checkout, switch_onsite_checkout => $switch_onsite_checkout, } );
908
    # if TooMany max_allowed returns 0 the user doesn't have permission to check out this book
909
    # if TooMany max_allowed returns 0 the user doesn't have permission to check out this book
Lines 1419-1425 sub AddIssue { Link Here
1419
                issuedate       => $issuedate->strftime('%Y-%m-%d %H:%M:%S'),
1420
                issuedate       => $issuedate->strftime('%Y-%m-%d %H:%M:%S'),
1420
                date_due        => $datedue->strftime('%Y-%m-%d %H:%M:%S'),
1421
                date_due        => $datedue->strftime('%Y-%m-%d %H:%M:%S'),
1421
                branchcode      => C4::Context->userenv->{'branch'},
1422
                branchcode      => C4::Context->userenv->{'branch'},
1422
                onsite_checkout => $onsite_checkout,
1423
                checkout_type   => $onsite_checkout ? 'OS' : undef,
1423
                auto_renew      => $auto_renew ? 1 : 0,
1424
                auto_renew      => $auto_renew ? 1 : 0,
1424
            };
1425
            };
1425
1426
Lines 2713-2719 sub CanBookBeRenewed { Link Here
2713
2714
2714
    my $item      = Koha::Items->find($itemnumber)      or return ( 0, 'no_item' );
2715
    my $item      = Koha::Items->find($itemnumber)      or return ( 0, 'no_item' );
2715
    my $issue = $item->checkout or return ( 0, 'no_checkout' );
2716
    my $issue = $item->checkout or return ( 0, 'no_checkout' );
2716
    return ( 0, 'onsite_checkout' ) if $issue->onsite_checkout;
2717
    return ( 0, 'onsite_checkout' ) if defined $issue->checkout_type && $issue->checkout_type eq 'OS';
2717
    return ( 0, 'item_denied_renewal') if _item_denied_renewal({ item => $item });
2718
    return ( 0, 'item_denied_renewal') if _item_denied_renewal({ item => $item });
2718
2719
2719
    my $patron = $issue->patron or return;
2720
    my $patron = $issue->patron or return;
Lines 4119-4125 sub GetPendingOnSiteCheckouts { Link Here
4119
        LEFT JOIN issues ON items.itemnumber = issues.itemnumber
4120
        LEFT JOIN issues ON items.itemnumber = issues.itemnumber
4120
        LEFT JOIN biblio ON items.biblionumber = biblio.biblionumber
4121
        LEFT JOIN biblio ON items.biblionumber = biblio.biblionumber
4121
        LEFT JOIN borrowers ON issues.borrowernumber = borrowers.borrowernumber
4122
        LEFT JOIN borrowers ON issues.borrowernumber = borrowers.borrowernumber
4122
        WHERE issues.onsite_checkout = 1
4123
        WHERE issues.checkout_type = 'OS'
4123
    |, { Slice => {} } );
4124
    |, { Slice => {} } );
4124
}
4125
}
4125
4126
(-)a/C4/Items.pm (-1 / +1 lines)
Lines 660-666 sub GetItemsInfo { Link Here
660
           items.notforloan as itemnotforloan,
660
           items.notforloan as itemnotforloan,
661
           issues.borrowernumber,
661
           issues.borrowernumber,
662
           issues.date_due as datedue,
662
           issues.date_due as datedue,
663
           issues.onsite_checkout,
663
           issues.checkout_type,
664
           borrowers.cardnumber,
664
           borrowers.cardnumber,
665
           borrowers.surname,
665
           borrowers.surname,
666
           borrowers.firstname,
666
           borrowers.firstname,
(-)a/api/v1/swagger/definitions/checkout.json (-3 / +3 lines)
Lines 52-60 Link Here
52
      "format": "date-time",
52
      "format": "date-time",
53
      "description": "Date the item was issued"
53
      "description": "Date the item was issued"
54
    },
54
    },
55
    "onsite_checkout": {
55
    "checkout_type": {
56
      "type": "boolean",
56
      "type": ["string", "null"],
57
      "description": "On site checkout"
57
      "description": "Checkout type, an authorised value under CHECKOUT_TYPE category"
58
    },
58
    },
59
    "note": {
59
    "note": {
60
      "type": ["string", "null"],
60
      "type": ["string", "null"],
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt (-2 / +2 lines)
Lines 315-327 Note that permanent location is a code, and location may be an authval. Link Here
315
                    <td class="status">
315
                    <td class="status">
316
316
317
                        [% IF item.CheckedOutFor %]
317
                        [% IF item.CheckedOutFor %]
318
                          [% IF item.onsite_checkout %]
318
                          [% IF ( item.checkout_type && item.checkout_type == 'OS' )%]
319
                            <span>Currently in local use
319
                            <span>Currently in local use
320
                          [% ELSE %]
320
                          [% ELSE %]
321
                            <span class="datedue">Checked out
321
                            <span class="datedue">Checked out
322
                          [% END %]
322
                          [% END %]
323
                                [% UNLESS ( item.NOTSAMEBRANCH ) %]
323
                                [% UNLESS ( item.NOTSAMEBRANCH ) %]
324
                                  [% IF item.onsite_checkout %]
324
                                  [% IF ( item.checkout_type && item.checkout_type == 'OS' ) %]
325
                                    by
325
                                    by
326
                                  [% ELSE %]
326
                                  [% ELSE %]
327
                                    to
327
                                    to
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/readingrec.tt (-1 / +1 lines)
Lines 66-72 Link Here
66
      [% FOREACH issue IN loop_reading %]
66
      [% FOREACH issue IN loop_reading %]
67
        [% IF  issue.returndate  %]<tr>[% ELSE %]<tr class="onissue">[% END %]
67
        [% IF  issue.returndate  %]<tr>[% ELSE %]<tr class="onissue">[% END %]
68
          <td style="display:none;">
68
          <td style="display:none;">
69
            [% IF issue.onsite_checkout %][% issuetype = 'onsite_checkout' | html %]
69
            [% IF ( issue.checkout_type && issue.checkout_type == 'OS' ) %][% issuetype = 'onsite_checkout' | html %]
70
            [% ELSE %][% issuetype = 'standard_checkout' | html %]
70
            [% ELSE %][% issuetype = 'standard_checkout' | html %]
71
            [% END %]
71
            [% END %]
72
            [% issuetype | html %]
72
            [% issuetype | html %]
(-)a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js (-3 / +3 lines)
Lines 327-333 $(document).ready(function() { Link Here
327
                        }
327
                        }
328
328
329
                        var onsite_checkout = '';
329
                        var onsite_checkout = '';
330
                        if ( oObj.onsite_checkout == 1 ) {
330
                        if ( oObj.checkout_type === "OS" ) {
331
                            onsite_checkout += " <span class='onsite_checkout'>(" + INHOUSE_USE + ")</span>";
331
                            onsite_checkout += " <span class='onsite_checkout'>(" + INHOUSE_USE + ")</span>";
332
                        }
332
                        }
333
333
Lines 507-513 $(document).ready(function() { Link Here
507
                            span_class = "renewals-allowed";
507
                            span_class = "renewals-allowed";
508
                        }
508
                        }
509
509
510
                        var can_force_renew = ( oObj.onsite_checkout == 0 ) &&
510
                        var can_force_renew = ( oObj.checkout_type !== 'OS' ) &&
511
                            ( oObj.can_renew_error != "on_reserve" || (oObj.can_renew_error == "on_reserve" && AllowRenewalOnHoldOverride))
511
                            ( oObj.can_renew_error != "on_reserve" || (oObj.can_renew_error == "on_reserve" && AllowRenewalOnHoldOverride))
512
                            ? true : false;
512
                            ? true : false;
513
                        var can_renew = ( oObj.renewals_remaining > 0  && !oObj.can_renew_error );
513
                        var can_renew = ( oObj.renewals_remaining > 0  && !oObj.can_renew_error );
Lines 701-707 $(document).ready(function() { Link Here
701
                            }
701
                            }
702
702
703
                            var onsite_checkout = '';
703
                            var onsite_checkout = '';
704
                            if ( oObj.onsite_checkout == 1 ) {
704
                            if ( oObj.checkout_type === 'OS' ) {
705
                                onsite_checkout += " <span class='onsite_checkout'>(" + INHOUSE_USE + ")</span>";
705
                                onsite_checkout += " <span class='onsite_checkout'>(" + INHOUSE_USE + ")</span>";
706
                            }
706
                            }
707
707
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/item-status.inc (-2 / +2 lines)
Lines 18-27 Link Here
18
18
19
[% IF item.isa('Koha::Item') %]
19
[% IF item.isa('Koha::Item') %]
20
    [% SET datedue = issue.date_due %]
20
    [% SET datedue = issue.date_due %]
21
    [% SET onsite_checkout = issue.onsite_checkout %]
21
    [% SET onsite_checkout = ( issue.checkout_type && issue.checkout_type == 'OS' ) ? 1 : 0 %]
22
[% ELSE %]
22
[% ELSE %]
23
    [% SET datedue = item.datedue || issue.date_due %]
23
    [% SET datedue = item.datedue || issue.date_due %]
24
    [% SET onsite_checkout = item.onsite_checkout %]
24
    [% SET onsite_checkout = ( item.checkout_type && item.checkout_type == 'OS' ) ? 1 : 0 %]
25
[% END %]
25
[% END %]
26
[% IF datedue %]
26
[% IF datedue %]
27
    [% SET itemavailable = 0 %]
27
    [% SET itemavailable = 0 %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-readingrecord.tt (-1 / +1 lines)
Lines 90-96 Link Here
90
                                            [% FOREACH issue IN READING_RECORD %]
90
                                            [% FOREACH issue IN READING_RECORD %]
91
                                                <tr>
91
                                                <tr>
92
                                                    <td style="display:none;">
92
                                                    <td style="display:none;">
93
                                                      [% IF issue.onsite_checkout %][% issuetype = 'onsite_checkout' %]
93
                                                      [% IF ( issue.checkout_type && issue.checkout_type == 'OS' ) %][% issuetype = 'onsite_checkout' %]
94
                                                      [% ELSE %][% issuetype = 'standard_checkout' %]
94
                                                      [% ELSE %][% issuetype = 'standard_checkout' %]
95
                                                      [% END %]
95
                                                      [% END %]
96
                                                      [% issuetype | html %]
96
                                                      [% issuetype | html %]
(-)a/svc/checkouts (-2 / +2 lines)
Lines 69-75 my $sql = ' Link Here
69
        issues.date_due < now() as date_due_overdue,
69
        issues.date_due < now() as date_due_overdue,
70
        issues.timestamp,
70
        issues.timestamp,
71
71
72
        issues.onsite_checkout,
72
        issues.checkout_type,
73
73
74
        biblio.biblionumber,
74
        biblio.biblionumber,
75
        biblio.title,
75
        biblio.title,
Lines 220-226 while ( my $c = $sth->fetchrow_hashref() ) { Link Here
220
        date_due            => $c->{date_due},
220
        date_due            => $c->{date_due},
221
        date_due_overdue    => $c->{date_due_overdue} ? JSON::true : JSON::false,
221
        date_due_overdue    => $c->{date_due_overdue} ? JSON::true : JSON::false,
222
        timestamp           => $c->{timestamp},
222
        timestamp           => $c->{timestamp},
223
        onsite_checkout     => $c->{onsite_checkout},
223
        onsite_checkout     => $c->{checkout_type} ? ( $c->{checkout_type} eq 'OS' ? 1 : 0 ) : 0,
224
        enumchron           => $c->{enumchron},
224
        enumchron           => $c->{enumchron},
225
        renewals_count      => $renewals_count,
225
        renewals_count      => $renewals_count,
226
        renewals_allowed    => $renewals_allowed,
226
        renewals_allowed    => $renewals_allowed,
(-)a/t/db_dependent/Circulation.t (-2 / +2 lines)
Lines 3134-3140 subtest 'ItemsDeniedRenewal preference' => sub { Link Here
3134
        auto_renew => 0,
3134
        auto_renew => 0,
3135
        borrowernumber => $idr_borrower->borrowernumber,
3135
        borrowernumber => $idr_borrower->borrowernumber,
3136
        itemnumber => $deny_book->itemnumber,
3136
        itemnumber => $deny_book->itemnumber,
3137
        onsite_checkout => 0,
3137
        checkout_type => undef,
3138
        date_due => $future,
3138
        date_due => $future,
3139
        }
3139
        }
3140
    });
3140
    });
Lines 3144-3150 subtest 'ItemsDeniedRenewal preference' => sub { Link Here
3144
        auto_renew => 0,
3144
        auto_renew => 0,
3145
        borrowernumber => $idr_borrower->borrowernumber,
3145
        borrowernumber => $idr_borrower->borrowernumber,
3146
        itemnumber => $allow_book->itemnumber,
3146
        itemnumber => $allow_book->itemnumber,
3147
        onsite_checkout => 0,
3147
        checkout_type => undef,
3148
        date_due => $future,
3148
        date_due => $future,
3149
        }
3149
        }
3150
    });
3150
    });
(-)a/t/db_dependent/Circulation/SwitchOnSiteCheckouts.t (-1 / +1 lines)
Lines 116-122 is( $messages->{ONSITE_CHECKOUT_WILL_BE_SWITCHED}, 1, 'If SwitchOnSiteCheckouts, Link Here
116
is( exists $impossible->{TOO_MANY}, '', 'If SwitchOnSiteCheckouts, switch the on-site checkout' );
116
is( exists $impossible->{TOO_MANY}, '', 'If SwitchOnSiteCheckouts, switch the on-site checkout' );
117
C4::Circulation::AddIssue( $patron_unblessed, $item->{barcode}, undef, undef, undef, undef, { switch_onsite_checkout => 1 } );
117
C4::Circulation::AddIssue( $patron_unblessed, $item->{barcode}, undef, undef, undef, undef, { switch_onsite_checkout => 1 } );
118
my $issue = Koha::Checkouts->find( { itemnumber => $item->{itemnumber} } );
118
my $issue = Koha::Checkouts->find( { itemnumber => $item->{itemnumber} } );
119
is( $issue->onsite_checkout, 0, 'The issue should have been switched to a regular checkout' );
119
is( $issue->checkout_type, undef, 'The issue should have been switched to a regular checkout' );
120
my $five_days_after = dt_from_string->add( days => 5 )->set( hour => 23, minute => 59, second => 0 );
120
my $five_days_after = dt_from_string->add( days => 5 )->set( hour => 23, minute => 59, second => 0 );
121
is( dt_from_string($issue->date_due, 'sql'), $five_days_after, 'The date_due should have been set depending on the circ rules when the on-site checkout has been switched' );
121
is( dt_from_string($issue->date_due, 'sql'), $five_days_after, 'The date_due should have been set depending on the circ rules when the on-site checkout has been switched' );
122
122
(-)a/t/db_dependent/Items.t (-2 / +2 lines)
Lines 368-375 subtest 'GetItemsInfo tests' => sub { Link Here
368
        'GetItemsInfo returns the correct home branch OPAC info notice' );
368
        'GetItemsInfo returns the correct home branch OPAC info notice' );
369
    is( $results[0]->{ holding_branch_opac_info }, "holdingbranch OPAC info",
369
    is( $results[0]->{ holding_branch_opac_info }, "holdingbranch OPAC info",
370
        'GetItemsInfo returns the correct holding branch OPAC info notice' );
370
        'GetItemsInfo returns the correct holding branch OPAC info notice' );
371
    is( exists( $results[0]->{ onsite_checkout } ), 1,
371
    is( exists( $results[0]->{ checkout_type } ), 1,
372
        'GetItemsInfo returns a onsite_checkout key' );
372
        'GetItemsInfo returns a checkout_type key' );
373
    is( $results[0]->{ restricted }, 1,
373
    is( $results[0]->{ restricted }, 1,
374
        'GetItemsInfo returns a restricted value code' );
374
        'GetItemsInfo returns a restricted value code' );
375
    is( $results[0]->{ restrictedvalue }, "Restricted Access",
375
    is( $results[0]->{ restrictedvalue }, "Restricted Access",
(-)a/t/db_dependent/Koha/Account/Line.t (-3 / +2 lines)
Lines 360-366 subtest 'Renewal related tests' => sub { Link Here
360
            class => 'Koha::Checkouts',
360
            class => 'Koha::Checkouts',
361
            value => {
361
            value => {
362
                itemnumber      => $item->itemnumber,
362
                itemnumber      => $item->itemnumber,
363
                onsite_checkout => 0,
363
                checkout_type   => undef,
364
                renewals        => 99,
364
                renewals        => 99,
365
                auto_renew      => 0
365
                auto_renew      => 0
366
            }
366
            }
Lines 406-412 subtest 'Renewal related tests' => sub { Link Here
406
            class => 'Koha::Checkouts',
406
            class => 'Koha::Checkouts',
407
            value => {
407
            value => {
408
                itemnumber      => $item->itemnumber,
408
                itemnumber      => $item->itemnumber,
409
                onsite_checkout => 0,
409
                checkout_type   => undef,
410
                renewals        => 0,
410
                renewals        => 0,
411
                auto_renew      => 0
411
                auto_renew      => 0
412
            }
412
            }
413
- 

Return to bug 25037