Lines 252-257
sub AddReserve {
Link Here
|
252 |
|
252 |
|
253 |
$res = GetReserve( $reserve_id ); |
253 |
$res = GetReserve( $reserve_id ); |
254 |
|
254 |
|
|
|
255 |
Return the current reserve or the old reserve. |
256 |
|
255 |
=cut |
257 |
=cut |
256 |
|
258 |
|
257 |
sub GetReserve { |
259 |
sub GetReserve { |
Lines 261-268
sub GetReserve {
Link Here
|
261 |
my $query = "SELECT * FROM reserves WHERE reserve_id = ?"; |
263 |
my $query = "SELECT * FROM reserves WHERE reserve_id = ?"; |
262 |
my $sth = $dbh->prepare( $query ); |
264 |
my $sth = $dbh->prepare( $query ); |
263 |
$sth->execute( $reserve_id ); |
265 |
$sth->execute( $reserve_id ); |
264 |
my $res = $sth->fetchrow_hashref(); |
266 |
return $sth->fetchrow_hashref(); |
265 |
return $res; |
|
|
266 |
} |
267 |
} |
267 |
|
268 |
|
268 |
=head2 GetReservesFromBiblionumber |
269 |
=head2 GetReservesFromBiblionumber |
Lines 1008-1013
sub CancelReserve {
Link Here
|
1008 |
|
1009 |
|
1009 |
my $dbh = C4::Context->dbh; |
1010 |
my $dbh = C4::Context->dbh; |
1010 |
|
1011 |
|
|
|
1012 |
my $reserve = GetReserve( $reserve_id ); |
1013 |
|
1011 |
my $query = " |
1014 |
my $query = " |
1012 |
UPDATE reserves |
1015 |
UPDATE reserves |
1013 |
SET cancellationdate = now(), |
1016 |
SET cancellationdate = now(), |
Lines 1034-1040
sub CancelReserve {
Link Here
|
1034 |
$sth->execute( $reserve_id ); |
1037 |
$sth->execute( $reserve_id ); |
1035 |
|
1038 |
|
1036 |
# now fix the priority on the others.... |
1039 |
# now fix the priority on the others.... |
1037 |
_FixPriority( $reserve_id ); |
1040 |
_FixPriority({ |
|
|
1041 |
reserve_id => $reserve_id, |
1042 |
biblionumber => $reserve->{biblionumber}, |
1043 |
}); |
1038 |
} |
1044 |
} |
1039 |
|
1045 |
|
1040 |
=head2 ModReserve |
1046 |
=head2 ModReserve |
Lines 1092-1119
sub ModReserve {
Link Here
|
1092 |
|
1098 |
|
1093 |
my $dbh = C4::Context->dbh; |
1099 |
my $dbh = C4::Context->dbh; |
1094 |
if ( $rank eq "del" ) { |
1100 |
if ( $rank eq "del" ) { |
1095 |
my $query = " |
1101 |
CancelReserve({ reserve_id => $reserve_id }); |
1096 |
UPDATE reserves |
|
|
1097 |
SET cancellationdate=now() |
1098 |
WHERE reserve_id = ? |
1099 |
"; |
1100 |
my $sth = $dbh->prepare($query); |
1101 |
$sth->execute( $reserve_id ); |
1102 |
$query = " |
1103 |
INSERT INTO old_reserves |
1104 |
SELECT * |
1105 |
FROM reserves |
1106 |
WHERE reserve_id = ? |
1107 |
"; |
1108 |
$sth = $dbh->prepare($query); |
1109 |
$sth->execute( $reserve_id ); |
1110 |
$query = " |
1111 |
DELETE FROM reserves |
1112 |
WHERE reserve_id = ? |
1113 |
"; |
1114 |
$sth = $dbh->prepare($query); |
1115 |
$sth->execute( $reserve_id ); |
1116 |
|
1117 |
} |
1102 |
} |
1118 |
elsif ($rank =~ /^\d+/ and $rank > 0) { |
1103 |
elsif ($rank =~ /^\d+/ and $rank > 0) { |
1119 |
my $query = " |
1104 |
my $query = " |
Lines 1132-1138
sub ModReserve {
Link Here
|
1132 |
} |
1117 |
} |
1133 |
} |
1118 |
} |
1134 |
|
1119 |
|
1135 |
_FixPriority( $reserve_id, $rank ); |
1120 |
_FixPriority({ reserve_id => $reserve_id, rank =>$rank }); |
1136 |
} |
1121 |
} |
1137 |
} |
1122 |
} |
1138 |
|
1123 |
|
Lines 1199-1205
sub ModReserveFill {
Link Here
|
1199 |
# now fix the priority on the others (if the priority wasn't |
1184 |
# now fix the priority on the others (if the priority wasn't |
1200 |
# already sorted!).... |
1185 |
# already sorted!).... |
1201 |
unless ( $priority == 0 ) { |
1186 |
unless ( $priority == 0 ) { |
1202 |
_FixPriority( $reserve_id ); |
1187 |
_FixPriority({ reserve_id => $reserve_id }); |
1203 |
} |
1188 |
} |
1204 |
} |
1189 |
} |
1205 |
|
1190 |
|
Lines 1338-1344
sub ModReserveMinusPriority {
Link Here
|
1338 |
my $sth_upd = $dbh->prepare($query); |
1323 |
my $sth_upd = $dbh->prepare($query); |
1339 |
$sth_upd->execute( $itemnumber, $reserve_id ); |
1324 |
$sth_upd->execute( $itemnumber, $reserve_id ); |
1340 |
# second step update all others reservs |
1325 |
# second step update all others reservs |
1341 |
_FixPriority( $reserve_id, '0'); |
1326 |
_FixPriority({ reserve_id => $reserve_id, rank => '0' }); |
1342 |
} |
1327 |
} |
1343 |
|
1328 |
|
1344 |
=head2 GetReserveInfo |
1329 |
=head2 GetReserveInfo |
Lines 1491-1505
sub AlterPriority {
Link Here
|
1491 |
|
1476 |
|
1492 |
my $priority = $reserve->{'priority'}; |
1477 |
my $priority = $reserve->{'priority'}; |
1493 |
$priority = $where eq 'up' ? $priority - 1 : $priority + 1; |
1478 |
$priority = $where eq 'up' ? $priority - 1 : $priority + 1; |
1494 |
_FixPriority( $reserve_id, $priority ) |
1479 |
_FixPriority({ reserve_id => $reserve_id, rank => $priority }) |
1495 |
|
1480 |
|
1496 |
} elsif ( $where eq 'top' ) { |
1481 |
} elsif ( $where eq 'top' ) { |
1497 |
|
1482 |
|
1498 |
_FixPriority( $reserve_id, '1' ) |
1483 |
_FixPriority({ reserve_id => $reserve_id, rank => '1' }) |
1499 |
|
1484 |
|
1500 |
} elsif ( $where eq 'bottom' ) { |
1485 |
} elsif ( $where eq 'bottom' ) { |
1501 |
|
1486 |
|
1502 |
_FixPriority( $reserve_id, '999999' ) |
1487 |
_FixPriority({ reserve_id => $reserve_id, rank => '999999' }); |
1503 |
|
1488 |
|
1504 |
} |
1489 |
} |
1505 |
} |
1490 |
} |
Lines 1520-1526
sub ToggleLowestPriority {
Link Here
|
1520 |
my $sth = $dbh->prepare( "UPDATE reserves SET lowestPriority = NOT lowestPriority WHERE reserve_id = ?"); |
1505 |
my $sth = $dbh->prepare( "UPDATE reserves SET lowestPriority = NOT lowestPriority WHERE reserve_id = ?"); |
1521 |
$sth->execute( $reserve_id ); |
1506 |
$sth->execute( $reserve_id ); |
1522 |
|
1507 |
|
1523 |
_FixPriority( $reserve_id, '999999' ); |
1508 |
_FixPriority({ reserve_id => $reserve_id, rank => '999999' }); |
1524 |
} |
1509 |
} |
1525 |
|
1510 |
|
1526 |
=head2 ToggleSuspend |
1511 |
=head2 ToggleSuspend |
Lines 1613-1619
sub SuspendAll {
Link Here
|
1613 |
|
1598 |
|
1614 |
=head2 _FixPriority |
1599 |
=head2 _FixPriority |
1615 |
|
1600 |
|
1616 |
&_FixPriority( $reserve_id, $rank, $ignoreSetLowestRank); |
1601 |
&_FixPriority({ reserve_id => $reserve_id, rank => $rank, ignoreSetLowestRank => $ignoreSetLowestRank }); |
1617 |
|
1602 |
|
1618 |
Only used internally (so don't export it) |
1603 |
Only used internally (so don't export it) |
1619 |
Changed how this functions works # |
1604 |
Changed how this functions works # |
Lines 1625-1634
in new priority rank
Link Here
|
1625 |
=cut |
1610 |
=cut |
1626 |
|
1611 |
|
1627 |
sub _FixPriority { |
1612 |
sub _FixPriority { |
1628 |
my ( $reserve_id, $rank, $ignoreSetLowestRank ) = @_; |
1613 |
my ( $params ) = @_; |
|
|
1614 |
my $reserve_id = $params->{reserve_id}; |
1615 |
my $rank = $params->{rank}; |
1616 |
my $ignoreSetLowestRank = $params->{ignoreSetLowestRank}; |
1617 |
my $biblionumber = $params->{biblionumber}; |
1618 |
|
1629 |
my $dbh = C4::Context->dbh; |
1619 |
my $dbh = C4::Context->dbh; |
1630 |
|
1620 |
|
1631 |
my $res = GetReserve( $reserve_id ); |
1621 |
unless ( $biblionumber ) { |
|
|
1622 |
my $res = GetReserve( $reserve_id ); |
1623 |
$biblionumber = $res->{biblionumber}; |
1624 |
} |
1632 |
|
1625 |
|
1633 |
if ( $rank eq "del" ) { |
1626 |
if ( $rank eq "del" ) { |
1634 |
CancelReserve({ reserve_id => $reserve_id }); |
1627 |
CancelReserve({ reserve_id => $reserve_id }); |
Lines 1656-1662
sub _FixPriority {
Link Here
|
1656 |
ORDER BY priority ASC |
1649 |
ORDER BY priority ASC |
1657 |
"; |
1650 |
"; |
1658 |
my $sth = $dbh->prepare($query); |
1651 |
my $sth = $dbh->prepare($query); |
1659 |
$sth->execute( $res->{'biblionumber'} ); |
1652 |
$sth->execute( $biblionumber ); |
1660 |
while ( my $line = $sth->fetchrow_hashref ) { |
1653 |
while ( my $line = $sth->fetchrow_hashref ) { |
1661 |
push( @priority, $line ); |
1654 |
push( @priority, $line ); |
1662 |
} |
1655 |
} |
Lines 1698-1704
sub _FixPriority {
Link Here
|
1698 |
|
1691 |
|
1699 |
unless ( $ignoreSetLowestRank ) { |
1692 |
unless ( $ignoreSetLowestRank ) { |
1700 |
while ( my $res = $sth->fetchrow_hashref() ) { |
1693 |
while ( my $res = $sth->fetchrow_hashref() ) { |
1701 |
_FixPriority( $res->{'reserve_id'}, '999999', 1 ); |
1694 |
_FixPriority({ |
|
|
1695 |
reserve_id => $res->{'reserve_id'}, |
1696 |
rank => '999999', |
1697 |
ignoreSetLowestRank => 1 |
1698 |
}); |
1702 |
} |
1699 |
} |
1703 |
} |
1700 |
} |
1704 |
} |
1701 |
} |