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

(-)a/C4/Reserves.pm (-5 / +2 lines)
Lines 130-135 BEGIN { Link Here
130
        &AlterPriority
130
        &AlterPriority
131
        &ToggleLowestPriority
131
        &ToggleLowestPriority
132
132
133
        &RevertWaitingStatus
134
        &RevertItemLevelHoldToBibLevelHold
133
        &ReserveSlip
135
        &ReserveSlip
134
        &ToggleSuspend
136
        &ToggleSuspend
135
        &SuspendAll
137
        &SuspendAll
Lines 1403-1409 when _FixPriority calls itself. Link Here
1403
1405
1404
sub _FixPriority {
1406
sub _FixPriority {
1405
    my ( $params ) = @_;
1407
    my ( $params ) = @_;
1406
    warn Dumper($params);
1407
    my $reserve_id = $params->{reserve_id};
1408
    my $reserve_id = $params->{reserve_id};
1408
    my $rank = $params->{rank} // '';
1409
    my $rank = $params->{rank} // '';
1409
    my $ignoreSetLowestRank = $params->{ignoreSetLowestRank};
1410
    my $ignoreSetLowestRank = $params->{ignoreSetLowestRank};
Lines 1412-1427 sub _FixPriority { Link Here
1412
    my $dbh = C4::Context->dbh;
1413
    my $dbh = C4::Context->dbh;
1413
1414
1414
    my $hold;
1415
    my $hold;
1415
    warn $reserve_id;
1416
    if ( $reserve_id ) {
1416
    if ( $reserve_id ) {
1417
        $hold = Koha::Holds->find( $reserve_id );
1417
        $hold = Koha::Holds->find( $reserve_id );
1418
        return unless $hold;
1418
        return unless $hold;
1419
    }
1419
    }
1420
    warn Dumper($hold);
1421
    unless ( $biblionumber ) { # FIXME This is a very weird API
1420
    unless ( $biblionumber ) { # FIXME This is a very weird API
1422
        $biblionumber = $hold->biblionumber;
1421
        $biblionumber = $hold->biblionumber;
1423
    }
1422
    }
1424
1425
    if ( $rank eq "del" ) { # FIXME will crash if called without $hold
1423
    if ( $rank eq "del" ) { # FIXME will crash if called without $hold
1426
        $hold->cancel;
1424
        $hold->cancel;
1427
    }
1425
    }
Lines 1922-1928 sub RevertWaitingStatus { Link Here
1922
    ";
1920
    ";
1923
    $sth = $dbh->prepare( $query );
1921
    $sth = $dbh->prepare( $query );
1924
    $sth->execute( $reserve->{'reserve_id'} );
1922
    $sth->execute( $reserve->{'reserve_id'} );
1925
    warn $reserve->{reserve_id};
1926
    _FixPriority( { biblionumber => $reserve->{biblionumber} } );
1923
    _FixPriority( { biblionumber => $reserve->{biblionumber} } );
1927
}
1924
}
1928
1925
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt (-1 / +1 lines)
Lines 264-270 function confirm_deletion() { Link Here
264
        <div class="alert alert-warning">
264
        <div class="alert alert-warning">
265
            <form id="DeallocateLostItemLevelHold" method="post" action="/cgi-bin/koha/cataloguing/additem.pl" name="DeallocateLostItemLevelHold">
265
            <form id="DeallocateLostItemLevelHold" method="post" action="/cgi-bin/koha/cataloguing/additem.pl" name="DeallocateLostItemLevelHold">
266
                <input type="hidden" id="itemnumber" name="itemnumber" value="[% lostitemnumber | html %]"/>
266
                <input type="hidden" id="itemnumber" name="itemnumber" value="[% lostitemnumber | html %]"/>
267
                This item has an item-level hold on [% itemnumber | html %] it:
267
                This item has an item-level hold on it:
268
                <input type="submit" name="RetainHold" value="Retain Hold"/>
268
                <input type="submit" name="RetainHold" value="Retain Hold"/>
269
                <input type="submit" name="CancelHold" value="Cancel hold"/>
269
                <input type="submit" name="CancelHold" value="Cancel hold"/>
270
            </form>
270
            </form>
(-)a/t/db_dependent/Holds/RevertWaitingStatus.t (-2 / +63 lines)
Lines 16-22 Link Here
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
use Test::More tests => 3;
19
use Test::More tests => 12;
20
use MARC::Record;
20
use MARC::Record;
21
21
22
use Koha::Libraries;
22
use Koha::Libraries;
Lines 109-114 ok( scalar @$priorities == 2, 'Only 2 holds remain in the reserves table' ); Link Here
109
ok( $priorities->[0]->[0] == 1, 'First hold has a priority of 1' );
109
ok( $priorities->[0]->[0] == 1, 'First hold has a priority of 1' );
110
ok( $priorities->[1]->[0] == 2, 'Second hold has a priority of 2' );
110
ok( $priorities->[1]->[0] == 2, 'Second hold has a priority of 2' );
111
111
112
#Bug 20844
113
#Test reverting the waiting status of holds when the reserved items are set to lost
114
115
#Create bib-level hold and test what happens when the item an allocated bib-level hold is allocated on is lost when the LostBibLevelHoldsRevert syspref is enabled
116
my $hold_id = C4::Reserves::AddReserve(
117
    $branchcode,
118
    4,
119
    $biblionumber,
120
    my $bibitems   = q{},
121
    my $priority,
122
    my $resdate,
123
    my $expdate,
124
    my $notes = q{},
125
    $title,
126
    my $checkitem,
127
    my $found,
128
);
129
130
my $hold = Koha::Holds->find($hold_id);
131
is( $hold->originalholdtype, 'B', 'Holds originalholdtype is "B" which is correct' );
132
ModReserveAffect($itemnumber, 4, 0); #Confirm the hold - now it's an allocated bib-level hold on $itemnumber and has status is 'W'
133
$hold = Koha::Holds->find($hold_id);
134
is( $hold->found, 'W', 'Hold status is "W" (waiting) which is correct' );
135
is( $hold->itemnumber, $itemnumber, 'Bib-level hold is allocated and has an itemnumber' );
136
t::lib::Mocks::mock_preference( 'LostBibLevelHoldsRevert', 1 );
137
138
if (C4::Context->preference('LostBibLevelHoldsRevert') ) {
139
    #When item is set to lost revert hold to bib-level (i.e. remove the itemnumber in hold record) and change reserves.found to ''
140
    RevertWaitingStatus({ itemnumber => $itemnumber });
141
    RevertItemLevelHoldToBibLevelHold({ reserveid => $hold_id });
142
}
143
$hold = Koha::Holds->find($hold_id);
144
is( $hold->found, undef, 'reserve.found reverted to undef now item is lost' );
145
is( $hold->itemnumber, undef, 'Hold reverted back to unallocated bib level hold' );
146
147
#Create item-level hold and test what happens when the reserved item is set to lost
148
$hold_id = C4::Reserves::AddReserve(
149
     $branchcode,
150
     4,
151
     $biblionumber,
152
     $bibitems   = q{},
153
     $priority,
154
     $resdate,
155
     $expdate,
156
     $notes = q{},
157
     $title,
158
     $itemnumber,
159
     $found,
160
);
161
162
$hold = Koha::Holds->find($hold_id);
163
is( $hold->itemnumber, $itemnumber, 'This is an item-level hold' );
164
165
is( $hold->originalholdtype, 'I', 'Holds originalholdtype is correct' );
166
ModReserveAffect($itemnumber, 4, 0); #Confirm the hold - now it's a waiting item-level hold with a reserves.found value of 'W'
167
$hold = Koha::Holds->find($hold_id);
168
is( $hold->found, 'W', 'Hold status is waiting' );
169
170
RevertWaitingStatus({ itemnumber => $itemnumber });
171
$hold = Koha::Holds->find($hold_id);
172
is( $hold->found, undef, 'Reserves found value is reverted to undef as the reserved item has been lost' );
173
112
$schema->storage->txn_rollback;
174
$schema->storage->txn_rollback;
113
175
114
# Helper method to set up a Biblio.
176
# Helper method to set up a Biblio.
115
- 

Return to bug 20844