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

(-)a/C4/Reserves.pm (-45 / +3 lines)
Lines 1717-1725 sub _Findgroupreserve { Link Here
1717
    my ( $biblionumber, $itemnumber, $lookahead, $ignore_borrowers) = @_;
1717
    my ( $biblionumber, $itemnumber, $lookahead, $ignore_borrowers) = @_;
1718
    my $dbh   = C4::Context->dbh;
1718
    my $dbh   = C4::Context->dbh;
1719
1719
1720
    # TODO: consolidate at least the SELECT portion of the first 2 queries to a common $select var.
1720
    # check for targeted match form the holds queue
1721
    # check for exact targeted match
1721
    my $hold_target_query = qq{
1722
    my $item_level_target_query = qq{
1723
        SELECT reserves.biblionumber        AS biblionumber,
1722
        SELECT reserves.biblionumber        AS biblionumber,
1724
               reserves.borrowernumber      AS borrowernumber,
1723
               reserves.borrowernumber      AS borrowernumber,
1725
               reserves.reservedate         AS reservedate,
1724
               reserves.reservedate         AS reservedate,
Lines 1740-1752 sub _Findgroupreserve { Link Here
1740
        JOIN hold_fill_targets USING (reserve_id)
1739
        JOIN hold_fill_targets USING (reserve_id)
1741
        WHERE found IS NULL
1740
        WHERE found IS NULL
1742
        AND priority > 0
1741
        AND priority > 0
1743
        AND item_level_request = 1
1744
        AND hold_fill_targets.itemnumber = ?
1742
        AND hold_fill_targets.itemnumber = ?
1745
        AND reservedate <= DATE_ADD(NOW(),INTERVAL ? DAY)
1743
        AND reservedate <= DATE_ADD(NOW(),INTERVAL ? DAY)
1746
        AND suspend = 0
1744
        AND suspend = 0
1747
        ORDER BY priority
1745
        ORDER BY priority
1748
    };
1746
    };
1749
    my $sth = $dbh->prepare($item_level_target_query);
1747
    my $sth = $dbh->prepare($hold_target_query);
1750
    $sth->execute($itemnumber, $lookahead||0);
1748
    $sth->execute($itemnumber, $lookahead||0);
1751
    my @results;
1749
    my @results;
1752
    if ( my $data = $sth->fetchrow_hashref ) {
1750
    if ( my $data = $sth->fetchrow_hashref ) {
Lines 1755-1799 sub _Findgroupreserve { Link Here
1755
    }
1753
    }
1756
    return @results if @results;
1754
    return @results if @results;
1757
1755
1758
    # check for title-level targeted match
1759
    my $title_level_target_query = qq{
1760
        SELECT reserves.biblionumber        AS biblionumber,
1761
               reserves.borrowernumber      AS borrowernumber,
1762
               reserves.reservedate         AS reservedate,
1763
               reserves.branchcode          AS branchcode,
1764
               reserves.cancellationdate    AS cancellationdate,
1765
               reserves.found               AS found,
1766
               reserves.reservenotes        AS reservenotes,
1767
               reserves.priority            AS priority,
1768
               reserves.timestamp           AS timestamp,
1769
               biblioitems.biblioitemnumber AS biblioitemnumber,
1770
               reserves.itemnumber          AS itemnumber,
1771
               reserves.reserve_id          AS reserve_id,
1772
               reserves.itemtype            AS itemtype,
1773
               reserves.non_priority        AS non_priority,
1774
               reserves.item_group_id           AS item_group_id
1775
        FROM reserves
1776
        JOIN biblioitems USING (biblionumber)
1777
        JOIN hold_fill_targets USING (reserve_id)
1778
        LEFT JOIN item_group_items ON ( item_group_items.item_id = hold_fill_targets.itemnumber )
1779
        WHERE found IS NULL
1780
        AND priority > 0
1781
        AND item_level_request = 0
1782
        AND hold_fill_targets.itemnumber = ?
1783
        AND reservedate <= DATE_ADD(NOW(),INTERVAL ? DAY)
1784
        AND suspend = 0
1785
        AND (reserves.item_group_id = item_group_items.item_group_id OR reserves.item_group_id IS NULL)
1786
        ORDER BY priority
1787
    };
1788
    $sth = $dbh->prepare($title_level_target_query);
1789
    $sth->execute($itemnumber, $lookahead||0);
1790
    @results = ();
1791
    if ( my $data = $sth->fetchrow_hashref ) {
1792
        push( @results, $data )
1793
          unless any{ $data->{borrowernumber} eq $_ } @$ignore_borrowers ;
1794
    }
1795
    return @results if @results;
1796
1797
    my $query = qq{
1756
    my $query = qq{
1798
        SELECT reserves.biblionumber               AS biblionumber,
1757
        SELECT reserves.biblionumber               AS biblionumber,
1799
               reserves.borrowernumber             AS borrowernumber,
1758
               reserves.borrowernumber             AS borrowernumber,
1800
- 

Return to bug 34666