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

(-)a/C4/Reserves.pm (-1 / +4 lines)
Lines 773-782 SELECT COUNT(*) FROM reserves WHERE biblionumber=? AND borrowernumber<>? Link Here
773
        my ( $notissued, $reserved );
773
        my ( $notissued, $reserved );
774
        ( $notissued ) = $dbh->selectrow_array( $issue_qry, undef,
774
        ( $notissued ) = $dbh->selectrow_array( $issue_qry, undef,
775
            ( $biblionumber ) );
775
            ( $biblionumber ) );
776
        if( $notissued ) {
776
        if( $notissued == 0 ) {
777
            # all items are issued
777
            ( $reserved ) = $dbh->selectrow_array( $holds_qry, undef,
778
            ( $reserved ) = $dbh->selectrow_array( $holds_qry, undef,
778
                ( $biblionumber, $borrowernumber ) );
779
                ( $biblionumber, $borrowernumber ) );
779
            $fee = 0 if $reserved == 0;
780
            $fee = 0 if $reserved == 0;
781
        } else {
782
            $fee = 0;
780
        }
783
        }
781
    }
784
    }
782
    return $fee;
785
    return $fee;
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt (-10 / +11 lines)
Lines 141-156 Link Here
141
                    <h2>Confirm holds for:[% INCLUDE 'patron-title.inc' patron = logged_in_user %] ([% logged_in_user.cardnumber | html %])</h2>
141
                    <h2>Confirm holds for:[% INCLUDE 'patron-title.inc' patron = logged_in_user %] ([% logged_in_user.cardnumber | html %])</h2>
142
                [% END # / UNLESS none_available %]
142
                [% END # / UNLESS none_available %]
143
143
144
                [% IF (RESERVE_CHARGE) %]
145
                    <div class="alert" id="reserve_fee">
146
                        [% IF Koha.Preference('HoldFeeMode') == 'any_time_is_collected' %]
147
                            <span>You will be charged a hold fee of [% RESERVE_CHARGE | $Price %] when you collect this item</span>
148
                        [% ELSE %]
149
                            <span>You will be charged a hold fee of [% RESERVE_CHARGE | $Price %] for placing this hold</span>
150
                        [% END %]
151
                    </div>
152
                [% END %]
153
154
                [% IF ( new_reserves_allowed ) %]
144
                [% IF ( new_reserves_allowed ) %]
155
                    <div id="new_reserves_allowed" class="alert">
145
                    <div id="new_reserves_allowed" class="alert">
156
                        <strong>Sorry,</strong> you can only place [% new_reserves_allowed | html %] more holds. Please uncheck the checkboxes for the items you wish to not place holds on.
146
                        <strong>Sorry,</strong> you can only place [% new_reserves_allowed | html %] more holds. Please uncheck the checkboxes for the items you wish to not place holds on.
Lines 178-183 Link Here
178
                                        [% END %]
168
                                        [% END %]
179
                                    </div>
169
                                    </div>
180
                                [% END %]
170
                                [% END %]
171
172
                                [% IF ( bibitemloo.reserve_charge ) %]
173
                                    <div class="alert" id="reserve_fee">
174
                                        [% IF Koha.Preference('HoldFeeMode') == 'any_time_is_collected' %]
175
                                            <span>You will be charged a hold fee of [% bibitemloo.reserve_charge | $Price %] when you collect this item</span>
176
                                        [% ELSE %]
177
                                            <span>You will be charged a hold fee of [% bibitemloo.reserve_charge | $Price %] for placing this hold</span>
178
                                        [% END %]
179
                                    </div>
180
                                [% END %]
181
181
                                <p>
182
                                <p>
182
                                    [% IF ( bibitemloo.holdable ) %]
183
                                    [% IF ( bibitemloo.holdable ) %]
183
                                        <input class="reserve_mode" name="reserve_mode" type="hidden" value="single"/>
184
                                        <input class="reserve_mode" name="reserve_mode" type="hidden" value="single"/>
(-)a/opac/opac-reserve.pl (-7 / +3 lines)
Lines 25-31 use CGI qw ( -utf8 ); Link Here
25
use C4::Auth qw( get_template_and_user );
25
use C4::Auth qw( get_template_and_user );
26
use C4::Koha qw( getitemtypeimagelocation getitemtypeimagesrc );
26
use C4::Koha qw( getitemtypeimagelocation getitemtypeimagesrc );
27
use C4::Circulation qw( GetBranchItemRule );
27
use C4::Circulation qw( GetBranchItemRule );
28
use C4::Reserves qw( CanItemBeReserved CanBookBeReserved AddReserve GetReservesControlBranch ItemsAnyAvailableAndNotRestricted IsAvailableForItemLevelRequest );
28
use C4::Reserves qw( CanItemBeReserved CanBookBeReserved AddReserve GetReservesControlBranch ItemsAnyAvailableAndNotRestricted IsAvailableForItemLevelRequest GetReserveFee );
29
use C4::Biblio qw( GetBiblioData GetFrameworkCode );
29
use C4::Biblio qw( GetBiblioData GetFrameworkCode );
30
use C4::Output qw( output_html_with_http_headers );
30
use C4::Output qw( output_html_with_http_headers );
31
use C4::Context;
31
use C4::Context;
Lines 72-83 unless ( $can_place_hold_if_available_at_pickup ) { Link Here
72
    }
72
    }
73
}
73
}
74
74
75
# Pass through any reserve charge
76
my $reservefee = $category->reservefee;
77
if ( $reservefee > 0){
78
    $template->param( RESERVE_CHARGE => $reservefee);
79
}
80
81
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
75
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
82
76
83
# There are two ways of calling this script, with a single biblio num
77
# There are two ways of calling this script, with a single biblio num
Lines 575-580 foreach my $biblioNum (@biblionumbers) { Link Here
575
        $biblioLoopIter{forced_hold_level} = $forced_hold_level;
569
        $biblioLoopIter{forced_hold_level} = $forced_hold_level;
576
    }
570
    }
577
571
572
    # Pass through any reserve charge
573
    $biblioLoopIter{reserve_charge} = GetReserveFee( $patron->id, $biblioNum );
578
574
579
    push @$biblioLoop, \%biblioLoopIter;
575
    push @$biblioLoop, \%biblioLoopIter;
580
576
(-)a/t/db_dependent/Reserves/GetReserveFee.t (-5 / +12 lines)
Lines 87-92 subtest 'GetReserveFee' => sub { Link Here
87
    plan tests => 5;
87
    plan tests => 5;
88
88
89
    C4::Circulation::AddIssue( $patron1, $item1->barcode, '2015-12-31', 0, undef, 0, {} ); # the date does not really matter
89
    C4::Circulation::AddIssue( $patron1, $item1->barcode, '2015-12-31', 0, undef, 0, {} ); # the date does not really matter
90
    C4::Circulation::AddIssue( $patron3, $item2->barcode, '2015-12-31', 0, undef, 0, {} ); # the date does not really matter
90
    my $acc2 = acctlines( $patron2->{borrowernumber} );
91
    my $acc2 = acctlines( $patron2->{borrowernumber} );
91
    my $res1 = addreserve( $patron1->{borrowernumber} );
92
    my $res1 = addreserve( $patron1->{borrowernumber} );
92
93
Lines 138-145 subtest 'Integration with AddReserve' => sub { Link Here
138
    };
139
    };
139
140
140
    subtest 'Items are issued' => sub {
141
    subtest 'Items are issued' => sub {
141
        plan tests => 3;
142
        plan tests => 4;
142
143
144
        $dbh->do( "DELETE FROM issues       WHERE itemnumber=?", undef, $item1->itemnumber);
145
        $dbh->do( "DELETE FROM issues       WHERE itemnumber=?", undef, $item2->itemnumber);
143
        C4::Circulation::AddIssue( $patron2, $item1->barcode, '2015-12-31', 0, undef, 0, {} );
146
        C4::Circulation::AddIssue( $patron2, $item1->barcode, '2015-12-31', 0, undef, 0, {} );
144
147
145
        t::lib::Mocks::mock_preference('HoldFeeMode', 'not_always');
148
        t::lib::Mocks::mock_preference('HoldFeeMode', 'not_always');
Lines 152-165 subtest 'Integration with AddReserve' => sub { Link Here
152
        $dbh->do( "DELETE FROM accountlines WHERE borrowernumber=?", undef, $patron1->{borrowernumber} );
155
        $dbh->do( "DELETE FROM accountlines WHERE borrowernumber=?", undef, $patron1->{borrowernumber} );
153
        addreserve( $patron3->{borrowernumber} );
156
        addreserve( $patron3->{borrowernumber} );
154
        addreserve( $patron1->{borrowernumber} );
157
        addreserve( $patron1->{borrowernumber} );
155
        # FIXME Are we sure it's the expected behavior?
158
        is( acctlines( $patron1->{borrowernumber} ), 0, 'not_always - Patron should not be charged if all the items are not checked out, even if 1 hold is already placed' );
156
        is( acctlines( $patron1->{borrowernumber} ), 1, 'not_always - Patron should be charged if all the items are not checked out and at least 1 hold is already placed' );
157
159
158
        C4::Circulation::AddIssue( $patron3, $item2->barcode, '2015-12-31', 0, undef, 0, {} );
160
        C4::Circulation::AddIssue( $patron3, $item2->barcode, '2015-12-31', 0, undef, 0, {} );
159
        $dbh->do( "DELETE FROM reserves     WHERE biblionumber=?", undef, $biblio->biblionumber );
161
        $dbh->do( "DELETE FROM reserves     WHERE biblionumber=?", undef, $biblio->biblionumber );
160
        $dbh->do( "DELETE FROM accountlines WHERE borrowernumber=?", undef, $patron1->{borrowernumber} );
162
        $dbh->do( "DELETE FROM accountlines WHERE borrowernumber=?", undef, $patron1->{borrowernumber} );
161
        addreserve( $patron1->{borrowernumber} );
163
        addreserve( $patron1->{borrowernumber} );
162
        is( acctlines( $patron1->{borrowernumber} ), 1, 'not_always - Patron should be charged if all items are checked out' );
164
        is( acctlines( $patron1->{borrowernumber} ), 0, 'not_always - Patron should not be charged if all items are checked out but no holds are placed' );
165
166
        $dbh->do( "DELETE FROM reserves     WHERE biblionumber=?", undef, $biblio->biblionumber );
167
        $dbh->do( "DELETE FROM accountlines WHERE borrowernumber=?", undef, $patron1->{borrowernumber} );
168
        addreserve( $patron3->{borrowernumber} );
169
        addreserve( $patron1->{borrowernumber} );
170
        is( acctlines( $patron1->{borrowernumber} ), 1, 'not_always - Patron should only be charged if all items are checked out and at least 1 hold is already placed' );
163
    };
171
    };
164
};
172
};
165
173
166
- 

Return to bug 31963