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

(-)a/C4/Circulation.pm (-32 / +28 lines)
Lines 1104-1150 sub CanBookBeIssued { Link Here
1104
                {
1104
                {
1105
                    # The item is on reserve and waiting, but has been
1105
                    # The item is on reserve and waiting, but has been
1106
                    # reserved by some other patron.
1106
                    # reserved by some other patron.
1107
                    $needsconfirmation{RESERVE_WAITING} = 1;
1107
                    $needsconfirmation{RESERVE_WAITING}     = 1;
1108
                    $needsconfirmation{'resfirstname'} = $patron->firstname;
1108
                    $needsconfirmation{'resfirstname'}      = $patron->firstname;
1109
                    $needsconfirmation{'ressurname'} = $patron->surname;
1109
                    $needsconfirmation{'ressurname'}        = $patron->surname;
1110
                    $needsconfirmation{'rescardnumber'} = $patron->cardnumber;
1110
                    $needsconfirmation{'rescardnumber'}     = $patron->cardnumber;
1111
                    $needsconfirmation{'resborrowernumber'} = $patron->borrowernumber;
1111
                    $needsconfirmation{'resborrowernumber'} = $patron->borrowernumber;
1112
                    $needsconfirmation{'resbranchcode'} = $res->{pickup_library_id};
1112
                    $needsconfirmation{'resbranchcode'}     = $res->{pickup_library_id};
1113
                    $needsconfirmation{'reswaitingdate'} = $res->{waiting_date};
1113
                    $needsconfirmation{'reswaitingdate'}    = $res->{waiting_date};
1114
                    $needsconfirmation{'reserve_id'} = $res->{id};
1114
                    $needsconfirmation{'reserve_id'}        = $res->{hold_id};
1115
                }
1115
                }
1116
                elsif ( $restype eq "Reserved" ) {
1116
                elsif ( $restype eq "Reserved" ) {
1117
                    # The item is on reserve for someone else.
1117
                    # The item is on reserve for someone else.
1118
                    $needsconfirmation{RESERVED} = 1;
1118
                    $needsconfirmation{RESERVED}            = 1;
1119
                    $needsconfirmation{'resfirstname'} = $patron->firstname;
1119
                    $needsconfirmation{'resfirstname'}      = $patron->firstname;
1120
                    $needsconfirmation{'ressurname'} = $patron->surname;
1120
                    $needsconfirmation{'ressurname'}        = $patron->surname;
1121
                    $needsconfirmation{'rescardnumber'} = $patron->cardnumber;
1121
                    $needsconfirmation{'rescardnumber'}     = $patron->cardnumber;
1122
                    $needsconfirmation{'resborrowernumber'} = $patron->borrowernumber;
1122
                    $needsconfirmation{'resborrowernumber'} = $patron->borrowernumber;
1123
                    $needsconfirmation{'resbranchcode'} = $patron->branchcode;
1123
                    $needsconfirmation{'resbranchcode'}     = $patron->branchcode;
1124
                    $needsconfirmation{'resreservedate'} = $res->{created_date};
1124
                    $needsconfirmation{'resreservedate'}    = $res->{created_date};
1125
                    $needsconfirmation{'reserve_id'} = $res->{id};
1125
                    $needsconfirmation{'reserve_id'}        = $res->{hold_id};
1126
                }
1126
                }
1127
                elsif ( $restype eq "Transferred" ) {
1127
                elsif ( $restype eq "Transferred" ) {
1128
                    # The item is determined hold being transferred for someone else.
1128
                    # The item is determined hold being transferred for someone else.
1129
                    $needsconfirmation{TRANSFERRED} = 1;
1129
                    $needsconfirmation{TRANSFERRED}         = 1;
1130
                    $needsconfirmation{'resfirstname'} = $patron->firstname;
1130
                    $needsconfirmation{'resfirstname'}      = $patron->firstname;
1131
                    $needsconfirmation{'ressurname'} = $patron->surname;
1131
                    $needsconfirmation{'ressurname'}        = $patron->surname;
1132
                    $needsconfirmation{'rescardnumber'} = $patron->cardnumber;
1132
                    $needsconfirmation{'rescardnumber'}     = $patron->cardnumber;
1133
                    $needsconfirmation{'resborrowernumber'} = $patron->borrowernumber;
1133
                    $needsconfirmation{'resborrowernumber'} = $patron->borrowernumber;
1134
                    $needsconfirmation{'resbranchcode'} = $patron->branchcode;
1134
                    $needsconfirmation{'resbranchcode'}     = $patron->branchcode;
1135
                    $needsconfirmation{'resreservedate'} = $res->{created_date};
1135
                    $needsconfirmation{'resreservedate'}    = $res->{created_date};
1136
                    $needsconfirmation{'reserve_id'} = $res->{id};
1136
                    $needsconfirmation{'reserve_id'}        = $res->{hold_id};
1137
                }
1137
                }
1138
                elsif ( $restype eq "Processing" ) {
1138
                elsif ( $restype eq "Processing" ) {
1139
                    # The item is determined hold being processed for someone else.
1139
                    # The item is determined hold being processed for someone else.
1140
                    $needsconfirmation{PROCESSING} = 1;
1140
                    $needsconfirmation{PROCESSING}          = 1;
1141
                    $needsconfirmation{'resfirstname'} = $patron->firstname;
1141
                    $needsconfirmation{'resfirstname'}      = $patron->firstname;
1142
                    $needsconfirmation{'ressurname'} = $patron->surname;
1142
                    $needsconfirmation{'ressurname'}        = $patron->surname;
1143
                    $needsconfirmation{'rescardnumber'} = $patron->cardnumber;
1143
                    $needsconfirmation{'rescardnumber'}     = $patron->cardnumber;
1144
                    $needsconfirmation{'resborrowernumber'} = $patron->borrowernumber;
1144
                    $needsconfirmation{'resborrowernumber'} = $patron->borrowernumber;
1145
                    $needsconfirmation{'resbranchcode'} = $patron->branchcode;
1145
                    $needsconfirmation{'resbranchcode'}     = $patron->branchcode;
1146
                    $needsconfirmation{'resreservedate'} = $res->{created_date};
1146
                    $needsconfirmation{'resreservedate'}    = $res->{created_date};
1147
                    $needsconfirmation{'reserve_id'} = $res->{id};
1147
                    $needsconfirmation{'reserve_id'}        = $res->{hold_id};
1148
                }
1148
                }
1149
            }
1149
            }
1150
        }
1150
        }
Lines 2864-2873 sub CanBookBeRenewed { Link Here
2864
    }
2864
    }
2865
2865
2866
    my ( $resfound, $resrec, $possible_reserves ) = C4::Reserves::CheckReserves($itemnumber);
2866
    my ( $resfound, $resrec, $possible_reserves ) = C4::Reserves::CheckReserves($itemnumber);
2867
    use Data::Printer colored => 1;
2868
    p( $resfound );
2869
    p( $resrec );
2870
    p( $possible_reserves );
2871
2867
2872
    # If next hold is non priority, then check if any hold with priority (non_priority = 0) exists for the same biblionumber.
2868
    # If next hold is non priority, then check if any hold with priority (non_priority = 0) exists for the same biblionumber.
2873
    if ( $resfound && $resrec->{non_priority} ) {
2869
    if ( $resfound && $resrec->{non_priority} ) {
(-)a/C4/Letters.pm (-1 / +1 lines)
Lines 1669-1675 sub _get_tt_params { Link Here
1669
            module   => 'Koha::Holds',
1669
            module   => 'Koha::Holds',
1670
            singular => 'hold',
1670
            singular => 'hold',
1671
            plural   => 'holds',
1671
            plural   => 'holds',
1672
            pk       => 'id',
1672
            pk       => 'hold_id',
1673
        },
1673
        },
1674
        serial => {
1674
        serial => {
1675
            module   => 'Koha::Serials',
1675
            module   => 'Koha::Serials',
(-)a/C4/Reserves.pm (-28 / +33 lines)
Lines 633-639 sub GetOtherReserves { Link Here
633
            #minus priorities of others reservs
633
            #minus priorities of others reservs
634
            ModReserveMinusPriority(
634
            ModReserveMinusPriority(
635
                $itemnumber,
635
                $itemnumber,
636
                $checkreserves->{id},
636
                $checkreserves->{hold_id},
637
            );
637
            );
638
638
639
            #launch the subroutine dotransfer
639
            #launch the subroutine dotransfer
Lines 651-657 sub GetOtherReserves { Link Here
651
            $messages->{'waiting'} = 1;
651
            $messages->{'waiting'} = 1;
652
            ModReserveMinusPriority(
652
            ModReserveMinusPriority(
653
                $itemnumber,
653
                $itemnumber,
654
                $checkreserves->{id},
654
                $checkreserves->{hold_id},
655
            );
655
            );
656
            ModReserveStatus($itemnumber,'waiting');
656
            ModReserveStatus($itemnumber,'waiting');
657
        }
657
        }
Lines 1094-1100 whose keys are fields from the reserves table in the Koha database. Link Here
1094
1094
1095
sub ModReserveFill {
1095
sub ModReserveFill {
1096
    my ($res) = @_;
1096
    my ($res) = @_;
1097
    my $reserve_id = $res->{'id'};
1097
    my $reserve_id = $res->{hold_id};
1098
1098
1099
    my $hold = Koha::Holds->find($reserve_id);
1099
    my $hold = Koha::Holds->find($reserve_id);
1100
    # get the priority on this record....
1100
    # get the priority on this record....
Lines 1210-1216 sub ModReserveAffect { Link Here
1210
        $hold->set_processing();
1210
        $hold->set_processing();
1211
    } else {
1211
    } else {
1212
        $hold->set_waiting($desk_id);
1212
        $hold->set_waiting($desk_id);
1213
        _koha_notify_reserve( $hold->id ) unless $already_on_shelf;
1213
        _koha_notify_reserve( $hold->hold_id ) unless $already_on_shelf;
1214
        # Complete transfer if one exists
1214
        # Complete transfer if one exists
1215
        my $transfer = $hold->item->get_transfer;
1215
        my $transfer = $hold->item->get_transfer;
1216
        $transfer->receive if $transfer;
1216
        $transfer->receive if $transfer;
Lines 1282-1288 sub ModReserveMinusPriority { Link Here
1282
    my $query = "
1282
    my $query = "
1283
        UPDATE holds
1283
        UPDATE holds
1284
        SET    priority = 0 , item_id = ?
1284
        SET    priority = 0 , item_id = ?
1285
        WHERE  id = ?
1285
        WHERE  hold_id = ?
1286
    ";
1286
    ";
1287
    my $sth_upd = $dbh->prepare($query);
1287
    my $sth_upd = $dbh->prepare($query);
1288
    $sth_upd->execute( $item_id, $reserve_id );
1288
    $sth_upd->execute( $item_id, $reserve_id );
Lines 1462-1468 sub ToggleLowestPriority { Link Here
1462
1462
1463
    my $dbh = C4::Context->dbh;
1463
    my $dbh = C4::Context->dbh;
1464
1464
1465
    my $sth = $dbh->prepare( "UPDATE holds SET lowest_priority = NOT lowest_priority WHERE id = ?");
1465
    my $sth = $dbh->prepare( "UPDATE holds SET lowest_priority = NOT lowest_priority WHERE hold_id = ?");
1466
    $sth->execute( $reserve_id );
1466
    $sth->execute( $reserve_id );
1467
1467
1468
    _FixPriority({ reserve_id => $reserve_id, rank => '999999' });
1468
    _FixPriority({ reserve_id => $reserve_id, rank => '999999' });
Lines 1600-1606 sub _FixPriority { Link Here
1600
        my $query = "
1600
        my $query = "
1601
            UPDATE holds
1601
            UPDATE holds
1602
            SET    priority = 0
1602
            SET    priority = 0
1603
            WHERE  id = ?
1603
            WHERE  hold_id = ?
1604
            AND status IN ('waiting', 'in_transit', 'processing')
1604
            AND status IN ('waiting', 'in_transit', 'processing')
1605
        ";
1605
        ";
1606
        my $sth = $dbh->prepare($query);
1606
        my $sth = $dbh->prepare($query);
Lines 1610-1616 sub _FixPriority { Link Here
1610
1610
1611
    # get whats left
1611
    # get whats left
1612
    my $query = "
1612
    my $query = "
1613
        SELECT id
1613
        SELECT hold_id
1614
        FROM   holds
1614
        FROM   holds
1615
        WHERE  biblio_id   = ?
1615
        WHERE  biblio_id   = ?
1616
          AND  completed = 0
1616
          AND  completed = 0
Lines 1628-1634 sub _FixPriority { Link Here
1628
    my $i;
1628
    my $i;
1629
    my $key = -1;    # to allow for 0 to be a valid result
1629
    my $key = -1;    # to allow for 0 to be a valid result
1630
    for ( $i = 0 ; $i < @priority ; $i++ ) {
1630
    for ( $i = 0 ; $i < @priority ; $i++ ) {
1631
        if ( $reserve_id && $reserve_id == $priority[$i]->{'id'} ) {
1631
        if ( $reserve_id && $reserve_id == $priority[$i]->{hold_id} ) {
1632
            $key = $i;    # save the index
1632
            $key = $i;    # save the index
1633
            last;
1633
            last;
1634
        }
1634
        }
Lines 1646-1668 sub _FixPriority { Link Here
1646
    $query = "
1646
    $query = "
1647
        UPDATE holds
1647
        UPDATE holds
1648
        SET    priority = ?
1648
        SET    priority = ?
1649
        WHERE  id = ?
1649
        WHERE  hold_id = ?
1650
    ";
1650
    ";
1651
    $sth = $dbh->prepare($query);
1651
    $sth = $dbh->prepare($query);
1652
    for ( my $j = 0 ; $j < @priority ; $j++ ) {
1652
    for ( my $j = 0 ; $j < @priority ; $j++ ) {
1653
        $sth->execute(
1653
        $sth->execute(
1654
            $j + 1,
1654
            $j + 1,
1655
            $priority[$j]->{'id'}
1655
            $priority[$j]->{hold_id}
1656
        );
1656
        );
1657
    }
1657
    }
1658
1658
1659
    $sth = $dbh->prepare( "SELECT id FROM holds WHERE lowest_priority = 1 ORDER BY priority" );
1659
    $sth = $dbh->prepare( "SELECT hold_id FROM holds WHERE lowest_priority = 1 ORDER BY priority" );
1660
    $sth->execute();
1660
    $sth->execute();
1661
1661
1662
    unless ( $ignoreSetLowestRank ) {
1662
    unless ( $ignoreSetLowestRank ) {
1663
      while ( my $res = $sth->fetchrow_hashref() ) {
1663
      while ( my $res = $sth->fetchrow_hashref() ) {
1664
        _FixPriority({
1664
        _FixPriority({
1665
            reserve_id => $res->{'id'},
1665
            reserve_id => $res->{hold_id},
1666
            rank => '999999',
1666
            rank => '999999',
1667
            ignoreSetLowestRank => 1
1667
            ignoreSetLowestRank => 1
1668
        });
1668
        });
Lines 1710-1721 sub _Findgroupreserve { Link Here
1710
               holds.timestamp         AS timestamp,
1710
               holds.timestamp         AS timestamp,
1711
               biblioitems.biblioitemnumber AS biblioitemnumber,
1711
               biblioitems.biblioitemnumber AS biblioitemnumber,
1712
               holds.item_id           AS item_id,
1712
               holds.item_id           AS item_id,
1713
               holds.id                AS id,
1713
               holds.hold_id           AS hold_id,
1714
               holds.item_type         AS item_type,
1714
               holds.item_type         AS item_type,
1715
               holds.non_priority      AS non_priority
1715
               holds.non_priority      AS non_priority
1716
        FROM holds
1716
        FROM holds
1717
        JOIN biblioitems ON (holds.biblio_id=biblioitems.biblionumber)
1717
        JOIN biblioitems ON (holds.biblio_id=biblioitems.biblionumber)
1718
        JOIN hold_fill_targets ON (holds.id=hold_fill_targets.reserve_id)
1718
        JOIN hold_fill_targets ON (holds.hold_id=hold_fill_targets.reserve_id)
1719
        WHERE status='placed'
1719
        WHERE status='placed'
1720
        AND priority > 0
1720
        AND priority > 0
1721
        AND completed = 0
1721
        AND completed = 0
Lines 1740-1758 sub _Findgroupreserve { Link Here
1740
               holds.patron_id         AS patron_id,
1740
               holds.patron_id         AS patron_id,
1741
               holds.created_date      AS created_date,
1741
               holds.created_date      AS created_date,
1742
               holds.pickup_library_id AS pickup_library_id,
1742
               holds.pickup_library_id AS pickup_library_id,
1743
               holds.completed_date   AS completed_date,
1743
               holds.completed_date    AS completed_date,
1744
               holds.status            AS status,
1744
               holds.status            AS status,
1745
               holds.notes             AS notes,
1745
               holds.notes             AS notes,
1746
               holds.priority          AS priority,
1746
               holds.priority          AS priority,
1747
               holds.timestamp         AS timestamp,
1747
               holds.timestamp         AS timestamp,
1748
               biblioitems.biblioitemnumber AS biblioitemnumber,
1748
               biblioitems.biblioitemnumber AS biblioitemnumber,
1749
               holds.item_id           AS item_id,
1749
               holds.item_id           AS item_id,
1750
               holds.id                AS id,
1750
               holds.hold_id           AS hold_id,
1751
               holds.item_type         AS item_type,
1751
               holds.item_type         AS item_type,
1752
               holds.non_priority      AS non_priority
1752
               holds.non_priority      AS non_priority
1753
        FROM holds
1753
        FROM holds
1754
        JOIN biblioitems ON (holds.biblio_id=biblioitems.biblionumber)
1754
        JOIN biblioitems ON (holds.biblio_id=biblioitems.biblionumber)
1755
        JOIN hold_fill_targets ON (holds.id=hold_fill_targets.reserve_id)
1755
        JOIN hold_fill_targets ON (holds.hold_id=hold_fill_targets.reserve_id)
1756
        WHERE status='placed'
1756
        WHERE status='placed'
1757
        AND priority > 0
1757
        AND priority > 0
1758
        AND completed = 0
1758
        AND completed = 0
Lines 1783-1789 sub _Findgroupreserve { Link Here
1783
               holds.priority                   AS priority,
1783
               holds.priority                   AS priority,
1784
               holds.timestamp                  AS timestamp,
1784
               holds.timestamp                  AS timestamp,
1785
               holds.item_id                    AS item_id,
1785
               holds.item_id                    AS item_id,
1786
               holds.id                         AS id,
1786
               holds.hold_id                    AS hold_id,
1787
               holds.item_type                  AS item_type,
1787
               holds.item_type                  AS item_type,
1788
               holds.non_priority               AS non_priority
1788
               holds.non_priority               AS non_priority
1789
        FROM holds
1789
        FROM holds
Lines 1996-2002 sub MoveReserve { Link Here
1996
            RevertWaitingStatus({ itemnumber => $itemnumber });
1996
            RevertWaitingStatus({ itemnumber => $itemnumber });
1997
        }
1997
        }
1998
        elsif ( $cancelreserve eq 'cancel' || $cancelreserve ) { # cancel reserves on this item
1998
        elsif ( $cancelreserve eq 'cancel' || $cancelreserve ) { # cancel reserves on this item
1999
            my $hold = Koha::Holds->find( $res->{id} );
1999
            my $hold = Koha::Holds->find( $res->{hold_id} );
2000
            $hold->cancel;
2000
            $hold->cancel;
2001
        }
2001
        }
2002
    }
2002
    }
Lines 2026-2043 sub MergeHolds { Link Here
2026
        # Reorder by date
2026
        # Reorder by date
2027
        # don't reorder those already waiting
2027
        # don't reorder those already waiting
2028
2028
2029
        $sth = $dbh->prepare(
2029
        $sth = $dbh->prepare(q{
2030
            "SELECT id FROM holds WHERE biblio_id = ? AND status = 'placed' AND completed = 0 ORDER BY created_date ASC"
2030
            SELECT hold_id
2031
        );
2031
            FROM holds
2032
        my $upd_sth = $dbh->prepare(
2032
            WHERE biblio_id = ? AND status = 'placed' AND completed = 0
2033
            "UPDATE holds SET priority = ? WHERE id = ? "
2033
            ORDER BY created_date ASC
2034
        );
2034
        });
2035
        my $upd_sth = $dbh->prepare(q{
2036
            UPDATE holds
2037
            SET priority = ?
2038
            WHERE hold_id = ?
2039
        });
2035
        $sth->execute( $to_biblio );
2040
        $sth->execute( $to_biblio );
2036
        my $priority = 1;
2041
        my $priority = 1;
2037
        while ( my $reserve = $sth->fetchrow_hashref() ) {
2042
        while ( my $reserve = $sth->fetchrow_hashref() ) {
2038
            $upd_sth->execute(
2043
            $upd_sth->execute(
2039
                $priority,
2044
                $priority,
2040
                $reserve->{'id'}
2045
                $reserve->{hold_id}
2041
            );
2046
            );
2042
            $priority++;
2047
            $priority++;
2043
        }
2048
        }
Lines 2068-2074 sub RevertWaitingStatus { Link Here
2068
    my $hold = Koha::Holds->search(
2073
    my $hold = Koha::Holds->search(
2069
        {
2074
        {
2070
            item_id => $item_id,
2075
            item_id => $item_id,
2071
            status => 'waiting',
2076
            status  => 'waiting',
2072
        }
2077
        }
2073
    )->next;
2078
    )->next;
2074
2079
(-)a/Koha/Hold.pm (-13 lines)
Lines 632-650 sub _set_default_expiration_date { Link Here
632
        dt_from_string( $self->created_date )->add( $timeunit => $period ) );
632
        dt_from_string( $self->created_date )->add( $timeunit => $period ) );
633
}
633
}
634
634
635
=head3 to_api_mapping
636
637
This method returns the mapping for representing a Koha::Hold object
638
on the API.
639
640
=cut
641
642
sub to_api_mapping {
643
    return {
644
        id => 'hold_id'
645
    };
646
}
647
648
=head2 Internal methods
635
=head2 Internal methods
649
636
650
=head3 _type
637
=head3 _type
(-)a/Koha/REST/V1/Holds.pm (-5 / +5 lines)
Lines 248-254 sub edit { Link Here
248
248
249
    return try {
249
    return try {
250
        my $hold_id = $c->validation->param('hold_id');
250
        my $hold_id = $c->validation->param('hold_id');
251
        my $hold    = Koha::Holds->search({id=>$hold_id, completed=>0})->next;
251
        my $hold    = Koha::Holds->search({hold_id=>$hold_id, completed=>0})->next;
252
252
253
        unless ($hold) {
253
        unless ($hold) {
254
            return $c->render(
254
            return $c->render(
Lines 313-319 sub delete { Link Here
313
    my $c = shift->openapi->valid_input or return;
313
    my $c = shift->openapi->valid_input or return;
314
314
315
    my $hold_id = $c->validation->param('hold_id');
315
    my $hold_id = $c->validation->param('hold_id');
316
    my $hold    = Koha::Holds->search({id=>$hold_id, completed=>0})->next;
316
    my $hold    = Koha::Holds->search({hold_id=>$hold_id, completed=>0})->next;
317
317
318
    unless ($hold) {
318
    unless ($hold) {
319
        return $c->render( status => 404, openapi => { error => "Hold not found." } );
319
        return $c->render( status => 404, openapi => { error => "Hold not found." } );
Lines 342-348 sub suspend { Link Here
342
    my $c = shift->openapi->valid_input or return;
342
    my $c = shift->openapi->valid_input or return;
343
343
344
    my $hold_id  = $c->validation->param('hold_id');
344
    my $hold_id  = $c->validation->param('hold_id');
345
    my $hold     = Koha::Holds->search({id=>$hold_id, completed=>0})->next;
345
    my $hold     = Koha::Holds->search({hold_id=>$hold_id, completed=>0})->next;
346
    my $body     = $c->req->json;
346
    my $body     = $c->req->json;
347
    my $end_date = ($body) ? $body->{end_date} : undef;
347
    my $end_date = ($body) ? $body->{end_date} : undef;
348
348
Lines 390-396 sub resume { Link Here
390
    my $c = shift->openapi->valid_input or return;
390
    my $c = shift->openapi->valid_input or return;
391
391
392
    my $hold_id = $c->validation->param('hold_id');
392
    my $hold_id = $c->validation->param('hold_id');
393
    my $hold    = Koha::Holds->search({id=>$hold_id, completed=>0})->next;
393
    my $hold    = Koha::Holds->search({hold_id=>$hold_id, completed=>0})->next;
394
    my $body    = $c->req->json;
394
    my $body    = $c->req->json;
395
395
396
    unless ($hold) {
396
    unless ($hold) {
Lines 416-422 sub update_priority { Link Here
416
    my $c = shift->openapi->valid_input or return;
416
    my $c = shift->openapi->valid_input or return;
417
417
418
    my $hold_id = $c->validation->param('hold_id');
418
    my $hold_id = $c->validation->param('hold_id');
419
    my $hold = Koha::Holds->search({id=>$hold_id, completed=>0})->next;
419
    my $hold = Koha::Holds->search({hold_id=>$hold_id, completed=>0})->next;
420
420
421
    unless ($hold) {
421
    unless ($hold) {
422
        return $c->render(
422
        return $c->render(
(-)a/Koha/Schema/Result/ClubHoldsToPatronHold.pm (-3 / +3 lines)
Lines 135-141 Related object: L<Koha::Schema::Result::Hold> Link Here
135
__PACKAGE__->belongs_to(
135
__PACKAGE__->belongs_to(
136
  "hold",
136
  "hold",
137
  "Koha::Schema::Result::Hold",
137
  "Koha::Schema::Result::Hold",
138
  { id => "hold_id" },
138
  { hold_id => "hold_id" },
139
  {
139
  {
140
    is_deferrable => 1,
140
    is_deferrable => 1,
141
    join_type     => "LEFT",
141
    join_type     => "LEFT",
Lines 160-167 __PACKAGE__->belongs_to( Link Here
160
);
160
);
161
161
162
162
163
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2021-07-12 11:40:08
163
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2021-07-22 15:29:24
164
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:7BEtGibjktT8MUPfLlY9Lw
164
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:DqyCOIzzWIX3X6KBkr72zQ
165
165
166
sub koha_objects_class {
166
sub koha_objects_class {
167
    'Koha::Club::Hold::PatronHolds';
167
    'Koha::Club::Hold::PatronHolds';
(-)a/Koha/Schema/Result/Hold.pm (-7 / +7 lines)
Lines 23-29 __PACKAGE__->table("holds"); Link Here
23
23
24
=head1 ACCESSORS
24
=head1 ACCESSORS
25
25
26
=head2 id
26
=head2 hold_id
27
27
28
  data_type: 'integer'
28
  data_type: 'integer'
29
  is_auto_increment: 1
29
  is_auto_increment: 1
Lines 205-211 optional authorised value CANCELLATION_REASON Link Here
205
=cut
205
=cut
206
206
207
__PACKAGE__->add_columns(
207
__PACKAGE__->add_columns(
208
  "id",
208
  "hold_id",
209
  { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
209
  { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
210
  "patron_id",
210
  "patron_id",
211
  { data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
211
  { data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
Lines 278-290 __PACKAGE__->add_columns( Link Here
278
278
279
=over 4
279
=over 4
280
280
281
=item * L</id>
281
=item * L</hold_id>
282
282
283
=back
283
=back
284
284
285
=cut
285
=cut
286
286
287
__PACKAGE__->set_primary_key("id");
287
__PACKAGE__->set_primary_key("hold_id");
288
288
289
=head1 RELATIONS
289
=head1 RELATIONS
290
290
Lines 319-325 Related object: L<Koha::Schema::Result::ClubHoldsToPatronHold> Link Here
319
__PACKAGE__->has_many(
319
__PACKAGE__->has_many(
320
  "club_holds_to_patron_holds",
320
  "club_holds_to_patron_holds",
321
  "Koha::Schema::Result::ClubHoldsToPatronHold",
321
  "Koha::Schema::Result::ClubHoldsToPatronHold",
322
  { "foreign.hold_id" => "self.id" },
322
  { "foreign.hold_id" => "self.hold_id" },
323
  { cascade_copy => 0, cascade_delete => 0 },
323
  { cascade_copy => 0, cascade_delete => 0 },
324
);
324
);
325
325
Lines 424-431 __PACKAGE__->belongs_to( Link Here
424
);
424
);
425
425
426
426
427
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2021-01-27 19:43:42
427
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2021-07-22 15:29:24
428
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:EjBk5LQLG2761uSkk/35Sw
428
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:5iq7d1ACqLGnEBAwWtbaTw
429
429
430
__PACKAGE__->add_columns(
430
__PACKAGE__->add_columns(
431
    '+completed'  => { is_boolean => 1 },
431
    '+completed'  => { is_boolean => 1 },
(-)a/installer/data/mysql/atomicupdate/bug_25260_holds_table.perl (-8 / +8 lines)
Lines 4-10 if( CheckVersion( $DBversion ) ) { Link Here
4
    if( !TableExists( 'holds' ) ) {
4
    if( !TableExists( 'holds' ) ) {
5
        $dbh->do( q|
5
        $dbh->do( q|
6
            CREATE TABLE `holds` (
6
            CREATE TABLE `holds` (
7
                `id` INT(11) NOT NULL AUTO_INCREMENT COMMENT 'internal hold identifier',
7
                `hold_id` INT(11) NOT NULL AUTO_INCREMENT COMMENT 'internal hold identifier',
8
                `patron_id` INT(11) DEFAULT NULL COMMENT 'foreign key from the borrowers table defining which patron this hold is for',
8
                `patron_id` INT(11) DEFAULT NULL COMMENT 'foreign key from the borrowers table defining which patron this hold is for',
9
                `pickup_library_id` VARCHAR(10) DEFAULT NULL COMMENT 'foreign key from the branches table defining which branch the patron wishes to pick this hold up at',
9
                `pickup_library_id` VARCHAR(10) DEFAULT NULL COMMENT 'foreign key from the branches table defining which branch the patron wishes to pick this hold up at',
10
                `desk_id` INT(11) DEFAULT NULL COMMENT 'foreign key from the desks table defining which desk the patron should pick this hold up at',
10
                `desk_id` INT(11) DEFAULT NULL COMMENT 'foreign key from the desks table defining which desk the patron should pick this hold up at',
Lines 26-32 if( CheckVersion( $DBversion ) ) { Link Here
26
                `suspended_until_date` DATETIME NULL DEFAULT NULL COMMENT 'Date until it is suspended',
26
                `suspended_until_date` DATETIME NULL DEFAULT NULL COMMENT 'Date until it is suspended',
27
                `completed` TINYINT(1) NOT NULL DEFAULT 0 COMMENT "If it has been completed (i.e. either 'fulfilled' or 'cancelled')",
27
                `completed` TINYINT(1) NOT NULL DEFAULT 0 COMMENT "If it has been completed (i.e. either 'fulfilled' or 'cancelled')",
28
                `cancellation_reason` VARCHAR(80) NULL DEFAULT NULL COMMENT 'optional authorised value CANCELLATION_REASON',
28
                `cancellation_reason` VARCHAR(80) NULL DEFAULT NULL COMMENT 'optional authorised value CANCELLATION_REASON',
29
                PRIMARY KEY (`id`),
29
                PRIMARY KEY (`hold_id`),
30
                KEY `priority_status_idx` (`priority`, `status`),
30
                KEY `priority_status_idx` (`priority`, `status`),
31
                KEY `patron_id` (`patron_id`),
31
                KEY `patron_id` (`patron_id`),
32
                KEY `biblio_id` (`biblio_id`),
32
                KEY `biblio_id` (`biblio_id`),
Lines 49-55 if( CheckVersion( $DBversion ) ) { Link Here
49
        # migrate 'reserves' and 'old_reserves' into 'holds'
49
        # migrate 'reserves' and 'old_reserves' into 'holds'
50
        $dbh->do(q|
50
        $dbh->do(q|
51
            INSERT INTO holds (
51
            INSERT INTO holds (
52
                id,
52
                hold_id,
53
                patron_id,
53
                patron_id,
54
                created_date,
54
                created_date,
55
                biblio_id,
55
                biblio_id,
Lines 147-160 if( CheckVersion( $DBversion ) ) { Link Here
147
147
148
        $dbh->do(q|
148
        $dbh->do(q|
149
            ALTER TABLE club_holds_to_patron_holds
149
            ALTER TABLE club_holds_to_patron_holds
150
            ADD CONSTRAINT clubs_holds_paton_holds_ibfk_3 FOREIGN KEY (hold_id) REFERENCES holds (id) ON DELETE CASCADE ON UPDATE CASCADE
150
            ADD CONSTRAINT clubs_holds_paton_holds_ibfk_3 FOREIGN KEY (hold_id) REFERENCES holds (hold_id) ON DELETE CASCADE ON UPDATE CASCADE
151
        |);
151
        |);
152
152
153
    }
153
    }
154
154
155
    if ( TableExists('holds') && TableExists('reserves') && !table_is_view('reserves') ) {
155
    if ( TableExists('holds') && TableExists('reserves') && !table_is_view('reserves') ) {
156
        $dbh->do(q|
156
        $dbh->do(q|
157
            DELETE FROM res USING `reserves` as res INNER JOIN `holds` as h ON h.id = res.reserve_id
157
            DELETE FROM res USING `reserves` as res INNER JOIN `holds` as h ON h.hold_id = res.reserve_id
158
        |);
158
        |);
159
159
160
        $sth = $dbh->prepare("SELECT COUNT(*) AS count FROM reserves");
160
        $sth = $dbh->prepare("SELECT COUNT(*) AS count FROM reserves");
Lines 173-179 if( CheckVersion( $DBversion ) ) { Link Here
173
        CREATE VIEW `reserves`
173
        CREATE VIEW `reserves`
174
        AS
174
        AS
175
            SELECT
175
            SELECT
176
                `id` AS `reserve_id`,
176
                `hold_id` AS `reserve_id`,
177
                `patron_id` AS `borrowernumber`,
177
                `patron_id` AS `borrowernumber`,
178
                `created_date` AS `reservedate`,
178
                `created_date` AS `reservedate`,
179
                `biblio_id` AS `biblionumber`,
179
                `biblio_id` AS `biblionumber`,
Lines 207-213 if( CheckVersion( $DBversion ) ) { Link Here
207
207
208
    if ( TableExists('holds') && TableExists('old_reserves') && !table_is_view('old_reserves') ) {
208
    if ( TableExists('holds') && TableExists('old_reserves') && !table_is_view('old_reserves') ) {
209
        $dbh->do(q|
209
        $dbh->do(q|
210
            DELETE FROM res USING `old_reserves` as res INNER JOIN `holds` as h ON h.id = res.reserve_id
210
            DELETE FROM res USING `old_reserves` as res INNER JOIN `holds` as h ON h.hold_id = res.reserve_id
211
        |);
211
        |);
212
212
213
        $sth = $dbh->prepare("SELECT COUNT(*) AS count FROM old_reserves");
213
        $sth = $dbh->prepare("SELECT COUNT(*) AS count FROM old_reserves");
Lines 226-232 if( CheckVersion( $DBversion ) ) { Link Here
226
        CREATE VIEW `old_reserves`
226
        CREATE VIEW `old_reserves`
227
        AS
227
        AS
228
            SELECT
228
            SELECT
229
                `id` AS `reserve_id`,
229
                `hold_id` AS `reserve_id`,
230
                `patron_id` AS `borrowernumber`,
230
                `patron_id` AS `borrowernumber`,
231
                `created_date` AS `reservedate`,
231
                `created_date` AS `reservedate`,
232
                `biblio_id` AS `biblionumber`,
232
                `biblio_id` AS `biblionumber`,
(-)a/installer/data/mysql/kohastructure.sql (-5 / +5 lines)
Lines 1865-1871 CREATE TABLE `club_holds_to_patron_holds` ( Link Here
1865
  KEY `clubs_holds_paton_holds_ibfk_3` (`hold_id`),
1865
  KEY `clubs_holds_paton_holds_ibfk_3` (`hold_id`),
1866
  CONSTRAINT `clubs_holds_paton_holds_ibfk_1` FOREIGN KEY (`club_hold_id`) REFERENCES `club_holds` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
1866
  CONSTRAINT `clubs_holds_paton_holds_ibfk_1` FOREIGN KEY (`club_hold_id`) REFERENCES `club_holds` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
1867
  CONSTRAINT `clubs_holds_paton_holds_ibfk_2` FOREIGN KEY (`patron_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
1867
  CONSTRAINT `clubs_holds_paton_holds_ibfk_2` FOREIGN KEY (`patron_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
1868
  CONSTRAINT `clubs_holds_paton_holds_ibfk_3` FOREIGN KEY (`hold_id`) REFERENCES `holds` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
1868
  CONSTRAINT `clubs_holds_paton_holds_ibfk_3` FOREIGN KEY (`hold_id`) REFERENCES `holds` (`hold_id`) ON DELETE CASCADE ON UPDATE CASCADE
1869
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1869
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1870
/*!40101 SET character_set_client = @saved_cs_client */;
1870
/*!40101 SET character_set_client = @saved_cs_client */;
1871
1871
Lines 2653-2659 DROP TABLE IF EXISTS `holds`; Link Here
2653
/*!40101 SET @saved_cs_client     = @@character_set_client */;
2653
/*!40101 SET @saved_cs_client     = @@character_set_client */;
2654
/*!40101 SET character_set_client = utf8 */;
2654
/*!40101 SET character_set_client = utf8 */;
2655
CREATE TABLE `holds` (
2655
CREATE TABLE `holds` (
2656
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'internal hold identifier',
2656
  `hold_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'internal hold identifier',
2657
  `patron_id` int(11) DEFAULT NULL COMMENT 'foreign key from the borrowers table defining which patron this hold is for',
2657
  `patron_id` int(11) DEFAULT NULL COMMENT 'foreign key from the borrowers table defining which patron this hold is for',
2658
  `pickup_library_id` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'foreign key from the branches table defining which branch the patron wishes to pick this hold up at',
2658
  `pickup_library_id` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'foreign key from the branches table defining which branch the patron wishes to pick this hold up at',
2659
  `desk_id` int(11) DEFAULT NULL COMMENT 'foreign key from the desks table defining which desk the patron should pick this hold up at',
2659
  `desk_id` int(11) DEFAULT NULL COMMENT 'foreign key from the desks table defining which desk the patron should pick this hold up at',
Lines 2675-2681 CREATE TABLE `holds` ( Link Here
2675
  `suspended_until_date` datetime DEFAULT NULL COMMENT 'Date until it is suspended',
2675
  `suspended_until_date` datetime DEFAULT NULL COMMENT 'Date until it is suspended',
2676
  `completed` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'If it has been completed (i.e. either ''fulfilled'' or ''cancelled'')',
2676
  `completed` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'If it has been completed (i.e. either ''fulfilled'' or ''cancelled'')',
2677
  `cancellation_reason` varchar(80) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'optional authorised value CANCELLATION_REASON',
2677
  `cancellation_reason` varchar(80) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'optional authorised value CANCELLATION_REASON',
2678
  PRIMARY KEY (`id`),
2678
  PRIMARY KEY (`hold_id`),
2679
  KEY `priority_status_idx` (`priority`,`status`),
2679
  KEY `priority_status_idx` (`priority`,`status`),
2680
  KEY `patron_id` (`patron_id`),
2680
  KEY `patron_id` (`patron_id`),
2681
  KEY `biblio_id` (`biblio_id`),
2681
  KEY `biblio_id` (`biblio_id`),
Lines 5368-5374 CREATE TABLE `zebraqueue` ( Link Here
5368
CREATE VIEW `reserves`
5368
CREATE VIEW `reserves`
5369
AS
5369
AS
5370
    SELECT
5370
    SELECT
5371
        `id` AS `reserve_id`,
5371
        `hold_id` AS `reserve_id`,
5372
        `patron_id` AS `borrowernumber`,
5372
        `patron_id` AS `borrowernumber`,
5373
        `created_date` AS `reservedate`,
5373
        `created_date` AS `reservedate`,
5374
        `biblio_id` AS `biblionumber`,
5374
        `biblio_id` AS `biblionumber`,
Lines 5406-5412 AS Link Here
5406
CREATE VIEW `old_reserves`
5406
CREATE VIEW `old_reserves`
5407
AS
5407
AS
5408
    SELECT
5408
    SELECT
5409
        `id` AS `reserve_id`,
5409
        `hold_id` AS `reserve_id`,
5410
        `patron_id` AS `borrowernumber`,
5410
        `patron_id` AS `borrowernumber`,
5411
        `created_date` AS `reservedate`,
5411
        `created_date` AS `reservedate`,
5412
        `biblio_id` AS `biblionumber`,
5412
        `biblio_id` AS `biblionumber`,
(-)a/t/db_dependent/Circulation.t (-2 / +2 lines)
Lines 604-614 subtest "CanBookBeRenewed tests" => sub { Link Here
604
    is( $renewokay, 0, '(Bug 10663) Cannot renew, reserved');
604
    is( $renewokay, 0, '(Bug 10663) Cannot renew, reserved');
605
    is( $error, 'on_reserve', '(Bug 10663) Cannot renew, reserved (returned error is on_reserve)');
605
    is( $error, 'on_reserve', '(Bug 10663) Cannot renew, reserved (returned error is on_reserve)');
606
606
607
    my $reserveid = Koha::Holds->search({ biblio_id => $biblio->biblionumber, patron_id => $reserving_borrowernumber })->next->id;
607
    my $reserveid = Koha::Holds->search({ biblio_id => $biblio->biblionumber, patron_id => $reserving_borrowernumber })->next->hold_id;
608
    my $reserving_borrower = Koha::Patrons->find( $reserving_borrowernumber )->unblessed;
608
    my $reserving_borrower = Koha::Patrons->find( $reserving_borrowernumber )->unblessed;
609
    AddIssue($reserving_borrower, $item_3->barcode);
609
    AddIssue($reserving_borrower, $item_3->barcode);
610
    my $reserve = $dbh->selectrow_hashref(
610
    my $reserve = $dbh->selectrow_hashref(
611
        'SELECT * FROM holds WHERE id = ? AND completed = 1',
611
        'SELECT * FROM holds WHERE hold_id = ? AND completed = 1',
612
        { Slice => {} },
612
        { Slice => {} },
613
        $reserveid
613
        $reserveid
614
    );
614
    );
(-)a/t/db_dependent/Hold.t (-2 / +2 lines)
Lines 238-244 subtest "delete() tests" => sub { Link Here
238
    my $deleted = $hold->delete;
238
    my $deleted = $hold->delete;
239
239
240
    is( ref($deleted), 'Koha::Hold', 'Koha::Hold->delete should return the Koha::Hold object if the hold has been correctly deleted' );
240
    is( ref($deleted), 'Koha::Hold', 'Koha::Hold->delete should return the Koha::Hold object if the hold has been correctly deleted' );
241
    is( Koha::Holds->search({ id => $hold_id })->count, 0,
241
    is( Koha::Holds->search({ hold_id => $hold_id })->count, 0,
242
        "Koha::Hold->delete should have deleted the hold" );
242
        "Koha::Hold->delete should have deleted the hold" );
243
243
244
    my $number_of_logs = $schema->resultset('ActionLog')->search(
244
    my $number_of_logs = $schema->resultset('ActionLog')->search(
Lines 253-259 subtest "delete() tests" => sub { Link Here
253
    $deleted = $hold->delete;
253
    $deleted = $hold->delete;
254
254
255
    is( ref($deleted), 'Koha::Hold', 'Koha::Hold->delete should return a Koha::Hold object if the hold has been correctly deleted' );
255
    is( ref($deleted), 'Koha::Hold', 'Koha::Hold->delete should return a Koha::Hold object if the hold has been correctly deleted' );
256
    is( Koha::Holds->search({ id => $hold_id })->count, 0,
256
    is( Koha::Holds->search({ hold_id => $hold_id })->count, 0,
257
        "Koha::Hold->delete should have deleted the hold" );
257
        "Koha::Hold->delete should have deleted the hold" );
258
258
259
    $number_of_logs = $schema->resultset('ActionLog')->search(
259
    $number_of_logs = $schema->resultset('ActionLog')->search(
(-)a/t/db_dependent/Items/MoveItemFromBiblio.t (-3 / +3 lines)
Lines 73-81 is( $get_item2->biblionumber, $to_biblio->biblionumber, 'The item2 should have b Link Here
73
my $get_item3 = Koha::Items->find( $item3->itemnumber );
73
my $get_item3 = Koha::Items->find( $item3->itemnumber );
74
is( $get_item3->biblionumber, $to_biblio->biblionumber, 'The item3 should not have been moved' );
74
is( $get_item3->biblionumber, $to_biblio->biblionumber, 'The item3 should not have been moved' );
75
75
76
my $get_bib_level_hold    = Koha::Holds->find( $bib_level_hold_not_to_move->{id} );
76
my $get_bib_level_hold    = Koha::Holds->find( $bib_level_hold_not_to_move->{hold_id} );
77
my $get_item_level_hold_1 = Koha::Holds->find( $item_level_hold_not_to_move->{id} );
77
my $get_item_level_hold_1 = Koha::Holds->find( $item_level_hold_not_to_move->{hold_id} );
78
my $get_item_level_hold_2 = Koha::Holds->find( $item_level_hold_to_move->{id} );
78
my $get_item_level_hold_2 = Koha::Holds->find( $item_level_hold_to_move->{hold_id} );
79
79
80
is( $get_bib_level_hold->biblio_id,    $from_biblio->biblionumber, 'MoveItemFromBiblio should not have moved the biblio-level hold' );
80
is( $get_bib_level_hold->biblio_id,    $from_biblio->biblionumber, 'MoveItemFromBiblio should not have moved the biblio-level hold' );
81
is( $get_item_level_hold_1->biblio_id, $from_biblio->biblionumber, 'MoveItemFromBiblio should not have moved the item-level hold placed on item 1' );
81
is( $get_item_level_hold_1->biblio_id, $from_biblio->biblionumber, 'MoveItemFromBiblio should not have moved the item-level hold placed on item 1' );
(-)a/t/db_dependent/Koha/Holds.t (-1 / +1 lines)
Lines 440-446 subtest 'get_items_that_can_fill' => sub { Link Here
440
440
441
    my $holds = Koha::Holds->search(
441
    my $holds = Koha::Holds->search(
442
        {
442
        {
443
            id => [ $reserve_id_1, $reserve_id_2, $waiting_reserve_id, ]
443
            hold_id => [ $reserve_id_1, $reserve_id_2, $waiting_reserve_id, ]
444
        }
444
        }
445
    );
445
    );
446
446
(-)a/t/db_dependent/Koha/Patrons.t (-1 / +1 lines)
Lines 485-491 subtest "delete" => sub { Link Here
485
485
486
    is( Koha::Patrons->find( $patron->{borrowernumber} ), undef, 'Koha::Patron->delete should have deleted the patron' );
486
    is( Koha::Patrons->find( $patron->{borrowernumber} ), undef, 'Koha::Patron->delete should have deleted the patron' );
487
487
488
    is (Koha::Holds->search( { id => $hold->{id}, status => 'cancelled' } )->count, 1, q|Koha::Patron->delete should have cancelled patron's holds| );
488
    is (Koha::Holds->search( { hold_id => $hold->{hold_id}, status => 'cancelled' } )->count, 1, q|Koha::Patron->delete should have cancelled patron's holds| );
489
489
490
    is( Koha::Holds->search( { patron_id => $patron->{borrowernumber}, completed => 0 } )->count, 0, q|Koha::Patron->delete should have cancelled patron's holds 2| );
490
    is( Koha::Holds->search( { patron_id => $patron->{borrowernumber}, completed => 0 } )->count, 0, q|Koha::Patron->delete should have cancelled patron's holds 2| );
491
491
(-)a/t/db_dependent/Letters/TemplateToolkit.t (-2 / +2 lines)
Lines 575-581 You have [% count %] items due Link Here
575
   <li><<holds.waiting_date>></li>
575
   <li><<holds.waiting_date>></li>
576
</ul>
576
</ul>
577
<p>Notes:
577
<p>Notes:
578
<pre><<holds.id>>=<<holds.notes>></pre>
578
<pre><<holds.hold_id>>=<<holds.notes>></pre>
579
</p>
579
</p>
580
EOF
580
EOF
581
581
Lines 609-615 EOF Link Here
609
   <li>[% hold.waiting_date | \$KohaDates %]</li>
609
   <li>[% hold.waiting_date | \$KohaDates %]</li>
610
</ul>
610
</ul>
611
<p>Notes:
611
<p>Notes:
612
<pre>[% hold.id %]=[% hold.notes %]</pre>
612
<pre>[% hold.hold_id %]=[% hold.notes %]</pre>
613
</p>
613
</p>
614
EOF
614
EOF
615
615
(-)a/t/db_dependent/Reserves.t (-12 / +11 lines)
Lines 123-129 my ($status, $reserve, $all_reserves) = CheckReserves($item->itemnumber, $barcod Link Here
123
123
124
is($status, "Reserved", "CheckReserves Test 1");
124
is($status, "Reserved", "CheckReserves Test 1");
125
125
126
ok(exists($reserve->{id}), 'CheckReserves() include reserve_id in its response');
126
ok(exists($reserve->{hold_id}), 'CheckReserves() include reserve_id in its response');
127
127
128
($status, $reserve, $all_reserves) = CheckReserves($item->itemnumber);
128
($status, $reserve, $all_reserves) = CheckReserves($item->itemnumber);
129
is($status, "Reserved", "CheckReserves Test 2");
129
is($status, "Reserved", "CheckReserves Test 2");
Lines 238-244 $itemnum_fpl = $builder->build_sample_item( Link Here
238
238
239
# Ensure that priorities are numbered correcly when a hold is moved to waiting
239
# Ensure that priorities are numbered correcly when a hold is moved to waiting
240
# (bug 11947)
240
# (bug 11947)
241
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum2));
241
$dbh->do("DELETE FROM holds WHERE biblio_id=?",undef,($bibnum2));
242
AddReserve(
242
AddReserve(
243
    {
243
    {
244
        branchcode     => $branch_3,
244
        branchcode     => $branch_3,
Lines 267-273 ModReserveAffect($itemnum_cpl, $requesters{$branch_3}, 0); Link Here
267
267
268
# Now it should have different priorities.
268
# Now it should have different priorities.
269
my $biblio = Koha::Biblios->find( $bibnum2 );
269
my $biblio = Koha::Biblios->find( $bibnum2 );
270
my $holds = $biblio->holds({ completed => 0 }, { order_by => 'id' });;
270
my $holds = $biblio->holds({ completed => 0 }, { order_by => 'hold_id' });;
271
is($holds->next->priority, 0, 'Item is correctly waiting');
271
is($holds->next->priority, 0, 'Item is correctly waiting');
272
is($holds->next->priority, 1, 'Item is correctly priority 1');
272
is($holds->next->priority, 1, 'Item is correctly priority 1');
273
is($holds->next->priority, 2, 'Item is correctly priority 2');
273
is($holds->next->priority, 2, 'Item is correctly priority 2');
Lines 277-283 is( @reserves, 1, 'GetWaiting got only the waiting reserve' ); Link Here
277
is( $reserves[0]->patron_id(), $requesters{$branch_3}, 'GetWaiting got the reserve for the correct borrower' );
277
is( $reserves[0]->patron_id(), $requesters{$branch_3}, 'GetWaiting got the reserve for the correct borrower' );
278
278
279
279
280
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum2));
280
$dbh->do("DELETE FROM holds WHERE biblio_id=?",undef,($bibnum2));
281
AddReserve(
281
AddReserve(
282
    {
282
    {
283
        branchcode     => $branch_3,
283
        branchcode     => $branch_3,
Lines 533-539 is( CanReserveBeCanceledFromOpac(), undef, Link Here
533
    'CanReserveBeCanceledFromOpac should return undef if called without any parameter'
533
    'CanReserveBeCanceledFromOpac should return undef if called without any parameter'
534
);
534
);
535
is(
535
is(
536
    CanReserveBeCanceledFromOpac( $canres->{id} ),
536
    CanReserveBeCanceledFromOpac( $canres->{hold_id} ),
537
    undef,
537
    undef,
538
    'CanReserveBeCanceledFromOpac should return undef if called without the id'
538
    'CanReserveBeCanceledFromOpac should return undef if called without the id'
539
);
539
);
Lines 543-560 is( Link Here
543
    'CanReserveBeCanceledFromOpac should return undef if called without borrowernumber'
543
    'CanReserveBeCanceledFromOpac should return undef if called without borrowernumber'
544
);
544
);
545
545
546
my $cancancel = CanReserveBeCanceledFromOpac($canres->{id}, $requesters{$branch_1});
546
my $cancancel = CanReserveBeCanceledFromOpac($canres->{hold_id}, $requesters{$branch_1});
547
is($cancancel, 1, 'Can user cancel its own reserve');
547
is($cancancel, 1, 'Can user cancel its own reserve');
548
548
549
$cancancel = CanReserveBeCanceledFromOpac($canres->{id}, $requesters{$branch_2});
549
$cancancel = CanReserveBeCanceledFromOpac($canres->{hold_id}, $requesters{$branch_2});
550
is($cancancel, 0, 'Other user cant cancel reserve');
550
is($cancancel, 0, 'Other user cant cancel reserve');
551
551
552
ModReserveAffect($item->itemnumber, $requesters{$branch_1}, 1);
552
ModReserveAffect($item->itemnumber, $requesters{$branch_1}, 1);
553
$cancancel = CanReserveBeCanceledFromOpac($canres->{id}, $requesters{$branch_1});
553
$cancancel = CanReserveBeCanceledFromOpac($canres->{hold_id}, $requesters{$branch_1});
554
is($cancancel, 0, 'Reserve in transfer status cant be canceled');
554
is($cancancel, 0, 'Reserve in transfer status cant be canceled');
555
555
556
$dbh->do('DELETE FROM holds', undef, ($bibnum));
556
$dbh->do('DELETE FROM holds', undef, ($bibnum));
557
is( CanReserveBeCanceledFromOpac($canres->{id}, $requesters{$branch_1}), undef,
557
is( CanReserveBeCanceledFromOpac($canres->{hold_id}, $requesters{$branch_1}), undef,
558
    'Cannot cancel a deleted hold' );
558
    'Cannot cancel a deleted hold' );
559
559
560
AddReserve(
560
AddReserve(
Lines 568-574 AddReserve( Link Here
568
(undef, $canres, undef) = CheckReserves($item->itemnumber);
568
(undef, $canres, undef) = CheckReserves($item->itemnumber);
569
569
570
ModReserveAffect($item->itemnumber, $requesters{$branch_1}, 0);
570
ModReserveAffect($item->itemnumber, $requesters{$branch_1}, 0);
571
$cancancel = CanReserveBeCanceledFromOpac($canres->{id}, $requesters{$branch_1});
571
$cancancel = CanReserveBeCanceledFromOpac($canres->{hold_id}, $requesters{$branch_1});
572
is($cancancel, 0, 'Reserve in waiting status cant be canceled');
572
is($cancancel, 0, 'Reserve in waiting status cant be canceled');
573
573
574
# End of tests for bug 12876
574
# End of tests for bug 12876
Lines 1140-1146 subtest 'CheckReserves additional tests' => sub { Link Here
1140
    my ( $status, $matched_reserve, $possible_reserves ) = CheckReserves( $item->itemnumber );
1140
    my ( $status, $matched_reserve, $possible_reserves ) = CheckReserves( $item->itemnumber );
1141
1141
1142
    is( $status, 'Transferred', "We found a reserve" );
1142
    is( $status, 'Transferred', "We found a reserve" );
1143
    is( $matched_reserve->{id}, $reserve1->id, 'We got the Transit reserve' );
1143
    is( $matched_reserve->{hold_id}, $reserve1->id, 'We got the Transit reserve' );
1144
    is( scalar @$possible_reserves, 2,         'We do get both reserves' );
1144
    is( scalar @$possible_reserves, 2,         'We do get both reserves' );
1145
1145
1146
    my $patron_B = $builder->build_object({ class => "Koha::Patrons" });
1146
    my $patron_B = $builder->build_object({ class => "Koha::Patrons" });
1147
- 

Return to bug 25260