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 |
|