Lines 93-99
BEGIN {
Link Here
|
93 |
@ISA = qw(Exporter); |
93 |
@ISA = qw(Exporter); |
94 |
@EXPORT = qw( |
94 |
@EXPORT = qw( |
95 |
&AddReserve |
95 |
&AddReserve |
96 |
|
96 |
|
|
|
97 |
&GetReserve |
97 |
&GetReservesFromItemnumber |
98 |
&GetReservesFromItemnumber |
98 |
&GetReservesFromBiblionumber |
99 |
&GetReservesFromBiblionumber |
99 |
&GetReservesFromBorrowernumber |
100 |
&GetReservesFromBorrowernumber |
Lines 244-252
sub AddReserve {
Link Here
|
244 |
return; # FIXME: why not have a useful return value? |
245 |
return; # FIXME: why not have a useful return value? |
245 |
} |
246 |
} |
246 |
|
247 |
|
|
|
248 |
=head2 GetReserve |
249 |
|
250 |
$res = GetReserve( $reserve_id ); |
251 |
|
252 |
=cut |
253 |
|
254 |
sub GetReserve { |
255 |
my ($reserve_id) = @_; |
256 |
#warn "C4::Reserves::GetReserve( $reserve_id )"; |
257 |
|
258 |
my $dbh = C4::Context->dbh; |
259 |
my $query = "SELECT * FROM reserves WHERE reserve_id = ?"; |
260 |
my $sth = $dbh->prepare( $query ); |
261 |
$sth->execute( $reserve_id ); |
262 |
my $res = $sth->fetchrow_hashref(); |
263 |
return $res; |
264 |
} |
265 |
|
247 |
=head2 GetReservesFromBiblionumber |
266 |
=head2 GetReservesFromBiblionumber |
248 |
|
267 |
|
249 |
($count, $title_reserves) = &GetReserves($biblionumber); |
268 |
($count, $title_reserves) = GetReservesFromBiblionumber($biblionumber); |
250 |
|
269 |
|
251 |
This function gets the list of reservations for one C<$biblionumber>, returning a count |
270 |
This function gets the list of reservations for one C<$biblionumber>, returning a count |
252 |
of the reserves and an arrayref pointing to the reserves for C<$biblionumber>. |
271 |
of the reserves and an arrayref pointing to the reserves for C<$biblionumber>. |
Lines 260-266
sub GetReservesFromBiblionumber {
Link Here
|
260 |
|
279 |
|
261 |
# Find the desired items in the reserves |
280 |
# Find the desired items in the reserves |
262 |
my $query = " |
281 |
my $query = " |
263 |
SELECT branchcode, |
282 |
SELECT reserve_id, |
|
|
283 |
branchcode, |
264 |
timestamp AS rtimestamp, |
284 |
timestamp AS rtimestamp, |
265 |
priority, |
285 |
priority, |
266 |
biblionumber, |
286 |
biblionumber, |
Lines 328-334
sub GetReservesFromBiblionumber {
Link Here
|
328 |
|
348 |
|
329 |
=head2 GetReservesFromItemnumber |
349 |
=head2 GetReservesFromItemnumber |
330 |
|
350 |
|
331 |
( $reservedate, $borrowernumber, $branchcode ) = GetReservesFromItemnumber($itemnumber); |
351 |
( $reservedate, $borrowernumber, $branchcode, $reserve_id ) = GetReservesFromItemnumber($itemnumber); |
332 |
|
352 |
|
333 |
TODO :: Description here |
353 |
TODO :: Description here |
334 |
|
354 |
|
Lines 338-344
sub GetReservesFromItemnumber {
Link Here
|
338 |
my ( $itemnumber, $all_dates ) = @_; |
358 |
my ( $itemnumber, $all_dates ) = @_; |
339 |
my $dbh = C4::Context->dbh; |
359 |
my $dbh = C4::Context->dbh; |
340 |
my $query = " |
360 |
my $query = " |
341 |
SELECT reservedate,borrowernumber,branchcode |
361 |
SELECT reservedate,borrowernumber,branchcode,reserve_id |
342 |
FROM reserves |
362 |
FROM reserves |
343 |
WHERE itemnumber=? |
363 |
WHERE itemnumber=? |
344 |
"; |
364 |
"; |
Lines 347-354
sub GetReservesFromItemnumber {
Link Here
|
347 |
} |
367 |
} |
348 |
my $sth_res = $dbh->prepare($query); |
368 |
my $sth_res = $dbh->prepare($query); |
349 |
$sth_res->execute($itemnumber); |
369 |
$sth_res->execute($itemnumber); |
350 |
my ( $reservedate, $borrowernumber,$branchcode ) = $sth_res->fetchrow_array; |
370 |
my ( $reservedate, $borrowernumber, $branchcode, $reserve_id ) = $sth_res->fetchrow_array; |
351 |
return ( $reservedate, $borrowernumber, $branchcode ); |
371 |
return ( $reservedate, $borrowernumber, $branchcode, $reserve_id ); |
352 |
} |
372 |
} |
353 |
|
373 |
|
354 |
=head2 GetReservesFromBorrowernumber |
374 |
=head2 GetReservesFromBorrowernumber |
Lines 511-521
sub GetReserveCount {
Link Here
|
511 |
|
531 |
|
512 |
my $dbh = C4::Context->dbh; |
532 |
my $dbh = C4::Context->dbh; |
513 |
|
533 |
|
514 |
my $query = ' |
534 |
my $query = " |
515 |
SELECT COUNT(*) AS counter |
535 |
SELECT COUNT(*) AS counter |
516 |
FROM reserves |
536 |
FROM reserves |
517 |
WHERE borrowernumber = ? |
537 |
WHERE borrowernumber = ? |
518 |
'; |
538 |
"; |
519 |
my $sth = $dbh->prepare($query); |
539 |
my $sth = $dbh->prepare($query); |
520 |
$sth->execute($borrowernumber); |
540 |
$sth->execute($borrowernumber); |
521 |
my $row = $sth->fetchrow_hashref; |
541 |
my $row = $sth->fetchrow_hashref; |
Lines 542-549
sub GetOtherReserves {
Link Here
|
542 |
#minus priorities of others reservs |
562 |
#minus priorities of others reservs |
543 |
ModReserveMinusPriority( |
563 |
ModReserveMinusPriority( |
544 |
$itemnumber, |
564 |
$itemnumber, |
545 |
$checkreserves->{'borrowernumber'}, |
565 |
$checkreserves->{'reserve_id'}, |
546 |
$iteminfo->{'biblionumber'} |
|
|
547 |
); |
566 |
); |
548 |
|
567 |
|
549 |
#launch the subroutine dotransfer |
568 |
#launch the subroutine dotransfer |
Lines 560-567
sub GetOtherReserves {
Link Here
|
560 |
$messages->{'waiting'} = 1; |
579 |
$messages->{'waiting'} = 1; |
561 |
ModReserveMinusPriority( |
580 |
ModReserveMinusPriority( |
562 |
$itemnumber, |
581 |
$itemnumber, |
563 |
$checkreserves->{'borrowernumber'}, |
582 |
$checkreserves->{'reserve_id'}, |
564 |
$iteminfo->{'biblionumber'} |
|
|
565 |
); |
583 |
); |
566 |
ModReserveStatus($itemnumber,'W'); |
584 |
ModReserveStatus($itemnumber,'W'); |
567 |
} |
585 |
} |
Lines 687-693
sub GetReservesToBranch {
Link Here
|
687 |
my ( $frombranch ) = @_; |
705 |
my ( $frombranch ) = @_; |
688 |
my $dbh = C4::Context->dbh; |
706 |
my $dbh = C4::Context->dbh; |
689 |
my $sth = $dbh->prepare( |
707 |
my $sth = $dbh->prepare( |
690 |
"SELECT borrowernumber,reservedate,itemnumber,timestamp |
708 |
"SELECT reserve_id,borrowernumber,reservedate,itemnumber,timestamp |
691 |
FROM reserves |
709 |
FROM reserves |
692 |
WHERE priority='0' |
710 |
WHERE priority='0' |
693 |
AND branchcode=?" |
711 |
AND branchcode=?" |
Lines 710-731
sub GetReservesToBranch {
Link Here
|
710 |
|
728 |
|
711 |
sub GetReservesForBranch { |
729 |
sub GetReservesForBranch { |
712 |
my ($frombranch) = @_; |
730 |
my ($frombranch) = @_; |
713 |
my $dbh = C4::Context->dbh; |
731 |
my $dbh = C4::Context->dbh; |
714 |
my $query = "SELECT borrowernumber,reservedate,itemnumber,waitingdate |
732 |
|
|
|
733 |
my $query = " |
734 |
SELECT reserve_id,borrowernumber,reservedate,itemnumber,waitingdate |
715 |
FROM reserves |
735 |
FROM reserves |
716 |
WHERE priority='0' |
736 |
WHERE priority='0' |
717 |
AND found='W' "; |
737 |
AND found='W' |
718 |
if ($frombranch){ |
738 |
"; |
719 |
$query .= " AND branchcode=? "; |
739 |
$query .= " AND branchcode=? " if ( $frombranch ); |
720 |
} |
|
|
721 |
$query .= "ORDER BY waitingdate" ; |
740 |
$query .= "ORDER BY waitingdate" ; |
|
|
741 |
|
722 |
my $sth = $dbh->prepare($query); |
742 |
my $sth = $dbh->prepare($query); |
723 |
if ($frombranch){ |
743 |
if ($frombranch){ |
724 |
$sth->execute($frombranch); |
744 |
$sth->execute($frombranch); |
725 |
} |
745 |
} else { |
726 |
else { |
746 |
$sth->execute(); |
727 |
$sth->execute(); |
747 |
} |
728 |
} |
748 |
|
729 |
my @transreserv; |
749 |
my @transreserv; |
730 |
my $i = 0; |
750 |
my $i = 0; |
731 |
while ( my $data = $sth->fetchrow_hashref ) { |
751 |
while ( my $data = $sth->fetchrow_hashref ) { |
Lines 744-749
If several reserves exist, the reserve with the lower priority is given.
Link Here
|
744 |
|
764 |
|
745 |
=cut |
765 |
=cut |
746 |
|
766 |
|
|
|
767 |
## FIXME: I don't think this does what it thinks it does. |
768 |
## It only ever checks the first reserve result, even though |
769 |
## multiple reserves for that bib can have the itemnumber set |
770 |
## the sub is only used once in the codebase. |
747 |
sub GetReserveStatus { |
771 |
sub GetReserveStatus { |
748 |
my ($itemnumber, $biblionumber) = @_; |
772 |
my ($itemnumber, $biblionumber) = @_; |
749 |
|
773 |
|
Lines 904-910
sub CancelExpiredReserves {
Link Here
|
904 |
$sth->execute(); |
928 |
$sth->execute(); |
905 |
|
929 |
|
906 |
while ( my $res = $sth->fetchrow_hashref() ) { |
930 |
while ( my $res = $sth->fetchrow_hashref() ) { |
907 |
CancelReserve( $res->{'biblionumber'}, '', $res->{'borrowernumber'} ); |
931 |
CancelReserve({ reserve_id => $res->{'reserve_id'} }); |
908 |
} |
932 |
} |
909 |
|
933 |
|
910 |
# Cancel reserves that have been waiting too long |
934 |
# Cancel reserves that have been waiting too long |
Lines 921-927
sub CancelExpiredReserves {
Link Here
|
921 |
manualinvoice($res->{'borrowernumber'}, $res->{'itemnumber'}, 'Hold waiting too long', 'F', $charge); |
945 |
manualinvoice($res->{'borrowernumber'}, $res->{'itemnumber'}, 'Hold waiting too long', 'F', $charge); |
922 |
} |
946 |
} |
923 |
|
947 |
|
924 |
CancelReserve( $res->{'biblionumber'}, '', $res->{'borrowernumber'} ); |
948 |
CancelReserve({ reserve_id => $res->{'reserve_id'} }); |
925 |
} |
949 |
} |
926 |
} |
950 |
} |
927 |
|
951 |
|
Lines 947-1055
sub AutoUnsuspendReserves {
Link Here
|
947 |
|
971 |
|
948 |
=head2 CancelReserve |
972 |
=head2 CancelReserve |
949 |
|
973 |
|
950 |
&CancelReserve($biblionumber, $itemnumber, $borrowernumber); |
974 |
CancelReserve({ reserve_id => $reserve_id, [ biblionumber => $biblionumber, borrowernumber => $borrrowernumber, itemnumber => $itemnumber ] }); |
951 |
|
975 |
|
952 |
Cancels a reserve. |
976 |
Cancels a reserve. |
953 |
|
977 |
|
954 |
Use either C<$biblionumber> or C<$itemnumber> to specify the item to |
978 |
=cut |
955 |
cancel, but not both: if both are given, C<&CancelReserve> uses |
|
|
956 |
C<$itemnumber>. |
957 |
|
979 |
|
958 |
C<$borrowernumber> is the borrower number of the patron on whose |
980 |
sub CancelReserve { |
959 |
behalf the book was reserved. |
981 |
my ( $params ) = @_; |
960 |
|
982 |
|
961 |
If C<$biblionumber> was given, C<&CancelReserve> also adjusts the |
983 |
my $reserve_id = $params->{'reserve_id'}; |
962 |
priorities of the other people who are waiting on the book. |
984 |
$reserve_id = GetReserveId( $params ) unless ( $reserve_id ); |
963 |
|
985 |
|
964 |
=cut |
986 |
return unless ( $reserve_id ); |
965 |
|
987 |
|
966 |
sub CancelReserve { |
|
|
967 |
my ( $biblio, $item, $borr ) = @_; |
968 |
my $dbh = C4::Context->dbh; |
988 |
my $dbh = C4::Context->dbh; |
969 |
if ( $item and $borr ) { |
|
|
970 |
# removing a waiting reserve record.... |
971 |
# update the database... |
972 |
my $query = " |
973 |
UPDATE reserves |
974 |
SET cancellationdate = now(), |
975 |
found = Null, |
976 |
priority = 0 |
977 |
WHERE itemnumber = ? |
978 |
AND borrowernumber = ? |
979 |
"; |
980 |
my $sth = $dbh->prepare($query); |
981 |
$sth->execute( $item, $borr ); |
982 |
$sth->finish; |
983 |
$query = " |
984 |
INSERT INTO old_reserves |
985 |
SELECT * FROM reserves |
986 |
WHERE itemnumber = ? |
987 |
AND borrowernumber = ? |
988 |
"; |
989 |
$sth = $dbh->prepare($query); |
990 |
$sth->execute( $item, $borr ); |
991 |
$query = " |
992 |
DELETE FROM reserves |
993 |
WHERE itemnumber = ? |
994 |
AND borrowernumber = ? |
995 |
"; |
996 |
$sth = $dbh->prepare($query); |
997 |
$sth->execute( $item, $borr ); |
998 |
} |
999 |
else { |
1000 |
# removing a reserve record.... |
1001 |
# get the prioritiy on this record.... |
1002 |
my $priority; |
1003 |
my $query = qq/ |
1004 |
SELECT priority FROM reserves |
1005 |
WHERE biblionumber = ? |
1006 |
AND borrowernumber = ? |
1007 |
AND cancellationdate IS NULL |
1008 |
AND itemnumber IS NULL |
1009 |
/; |
1010 |
my $sth = $dbh->prepare($query); |
1011 |
$sth->execute( $biblio, $borr ); |
1012 |
($priority) = $sth->fetchrow_array; |
1013 |
$sth->finish; |
1014 |
$query = qq/ |
1015 |
UPDATE reserves |
1016 |
SET cancellationdate = now(), |
1017 |
found = Null, |
1018 |
priority = 0 |
1019 |
WHERE biblionumber = ? |
1020 |
AND borrowernumber = ? |
1021 |
/; |
1022 |
|
1023 |
# update the database, removing the record... |
1024 |
$sth = $dbh->prepare($query); |
1025 |
$sth->execute( $biblio, $borr ); |
1026 |
$sth->finish; |
1027 |
|
989 |
|
1028 |
$query = qq/ |
990 |
my $query = " |
1029 |
INSERT INTO old_reserves |
991 |
UPDATE reserves |
1030 |
SELECT * FROM reserves |
992 |
SET cancellationdate = now(), |
1031 |
WHERE biblionumber = ? |
993 |
found = Null, |
1032 |
AND borrowernumber = ? |
994 |
priority = 0 |
1033 |
/; |
995 |
WHERE reserve_id = ? |
1034 |
$sth = $dbh->prepare($query); |
996 |
"; |
1035 |
$sth->execute( $biblio, $borr ); |
997 |
my $sth = $dbh->prepare($query); |
|
|
998 |
$sth->execute( $reserve_id ); |
999 |
$sth->finish; |
1036 |
|
1000 |
|
1037 |
$query = qq/ |
1001 |
$query = " |
1038 |
DELETE FROM reserves |
1002 |
INSERT INTO old_reserves |
1039 |
WHERE biblionumber = ? |
1003 |
SELECT * FROM reserves |
1040 |
AND borrowernumber = ? |
1004 |
WHERE reserve_id = ? |
1041 |
/; |
1005 |
"; |
1042 |
$sth = $dbh->prepare($query); |
1006 |
$sth = $dbh->prepare($query); |
1043 |
$sth->execute( $biblio, $borr ); |
1007 |
$sth->execute( $reserve_id ); |
1044 |
|
1008 |
|
1045 |
# now fix the priority on the others.... |
1009 |
$query = " |
1046 |
_FixPriority( $biblio, $borr ); |
1010 |
DELETE FROM reserves |
1047 |
} |
1011 |
WHERE reserve_id = ? |
|
|
1012 |
"; |
1013 |
$sth = $dbh->prepare($query); |
1014 |
$sth->execute( $reserve_id ); |
1015 |
|
1016 |
# now fix the priority on the others.... |
1017 |
_FixPriority( $reserve_id ); |
1048 |
} |
1018 |
} |
1049 |
|
1019 |
|
1050 |
=head2 ModReserve |
1020 |
=head2 ModReserve |
1051 |
|
1021 |
|
1052 |
ModReserve($rank, $biblio, $borrower, $branch[, $itemnumber]) |
1022 |
ModReserve({ rank => $rank, |
|
|
1023 |
reserve_id => $reserve_id, |
1024 |
branchcode => $branchcode |
1025 |
[, itemnumber => $itemnumber ] |
1026 |
[, biblionumber => $biblionumber, $borrowernumber => $borrowernumber ] |
1027 |
}); |
1053 |
|
1028 |
|
1054 |
Change a hold request's priority or cancel it. |
1029 |
Change a hold request's priority or cancel it. |
1055 |
|
1030 |
|
Lines 1079-1137
itemnumber and supplying itemnumber.
Link Here
|
1079 |
=cut |
1054 |
=cut |
1080 |
|
1055 |
|
1081 |
sub ModReserve { |
1056 |
sub ModReserve { |
1082 |
#subroutine to update a reserve |
1057 |
my ( $params ) = @_; |
1083 |
my ( $rank, $biblio, $borrower, $branch , $itemnumber, $suspend_until) = @_; |
1058 |
|
1084 |
return if $rank eq "W"; |
1059 |
my $rank = $params->{'rank'}; |
1085 |
return if $rank eq "n"; |
1060 |
my $reserve_id = $params->{'reserve_id'}; |
|
|
1061 |
my $branchcode = $params->{'branchcode'}; |
1062 |
my $itemnumber = $params->{'itemnumber'}; |
1063 |
my $suspend_until = $params->{'suspend_until'}; |
1064 |
my $borrowernumber = $params->{'borrowernumber'}; |
1065 |
my $biblionumber = $params->{'biblionumber'}; |
1066 |
|
1067 |
return if $rank eq "W"; |
1068 |
return if $rank eq "n"; |
1069 |
|
1070 |
return unless ( $reserve_id || ( $borrowernumber && ( $biblionumber || $itemnumber ) ) ); |
1071 |
$reserve_id = GetReserveId({ biblionumber => $biblionumber, borrowernumber => $borrowernumber, itemnumber => $itemnumber }) unless ( $reserve_id ); |
1072 |
|
1086 |
my $dbh = C4::Context->dbh; |
1073 |
my $dbh = C4::Context->dbh; |
1087 |
if ( $rank eq "del" ) { |
1074 |
if ( $rank eq "del" ) { |
1088 |
my $query = qq/ |
1075 |
my $query = " |
1089 |
UPDATE reserves |
1076 |
UPDATE reserves |
1090 |
SET cancellationdate=now() |
1077 |
SET cancellationdate=now() |
1091 |
WHERE biblionumber = ? |
1078 |
WHERE reserve_id = ? |
1092 |
AND borrowernumber = ? |
1079 |
"; |
1093 |
/; |
|
|
1094 |
my $sth = $dbh->prepare($query); |
1080 |
my $sth = $dbh->prepare($query); |
1095 |
$sth->execute( $biblio, $borrower ); |
1081 |
$sth->execute( $reserve_id ); |
1096 |
$sth->finish; |
1082 |
$sth->finish; |
1097 |
$query = qq/ |
1083 |
$query = " |
1098 |
INSERT INTO old_reserves |
1084 |
INSERT INTO old_reserves |
1099 |
SELECT * |
1085 |
SELECT * |
1100 |
FROM reserves |
1086 |
FROM reserves |
1101 |
WHERE biblionumber = ? |
1087 |
WHERE reserve_id = ? |
1102 |
AND borrowernumber = ? |
1088 |
"; |
1103 |
/; |
|
|
1104 |
$sth = $dbh->prepare($query); |
1089 |
$sth = $dbh->prepare($query); |
1105 |
$sth->execute( $biblio, $borrower ); |
1090 |
$sth->execute( $reserve_id ); |
1106 |
$query = qq/ |
1091 |
$query = " |
1107 |
DELETE FROM reserves |
1092 |
DELETE FROM reserves |
1108 |
WHERE biblionumber = ? |
1093 |
WHERE reserve_id = ? |
1109 |
AND borrowernumber = ? |
1094 |
"; |
1110 |
/; |
|
|
1111 |
$sth = $dbh->prepare($query); |
1095 |
$sth = $dbh->prepare($query); |
1112 |
$sth->execute( $biblio, $borrower ); |
1096 |
$sth->execute( $reserve_id ); |
1113 |
|
1097 |
|
1114 |
} |
1098 |
} |
1115 |
elsif ($rank =~ /^\d+/ and $rank > 0) { |
1099 |
elsif ($rank =~ /^\d+/ and $rank > 0) { |
1116 |
my $query = " |
1100 |
my $query = " |
1117 |
UPDATE reserves SET priority = ? ,branchcode = ?, itemnumber = ?, found = NULL, waitingdate = NULL |
1101 |
UPDATE reserves SET priority = ? ,branchcode = ?, itemnumber = ?, found = NULL, waitingdate = NULL |
1118 |
WHERE biblionumber = ? |
1102 |
WHERE reserve_id = ? |
1119 |
AND borrowernumber = ? |
|
|
1120 |
"; |
1103 |
"; |
1121 |
my $sth = $dbh->prepare($query); |
1104 |
my $sth = $dbh->prepare($query); |
1122 |
$sth->execute( $rank, $branch,$itemnumber, $biblio, $borrower); |
1105 |
$sth->execute( $rank, $branchcode, $itemnumber, $reserve_id ); |
1123 |
$sth->finish; |
1106 |
$sth->finish; |
1124 |
|
1107 |
|
1125 |
if ( defined( $suspend_until ) ) { |
1108 |
if ( defined( $suspend_until ) ) { |
1126 |
if ( $suspend_until ) { |
1109 |
if ( $suspend_until ) { |
1127 |
$suspend_until = C4::Dates->new( $suspend_until )->output("iso"); |
1110 |
$suspend_until = C4::Dates->new( $suspend_until )->output("iso"); |
1128 |
$dbh->do("UPDATE reserves SET suspend = 1, suspend_until = ? WHERE biblionumber = ? AND borrowernumber = ?", undef, ( $suspend_until, $biblio, $borrower ) ); |
1111 |
$dbh->do("UPDATE reserves SET suspend = 1, suspend_until = ? WHERE reserve_id = ?", undef, ( $suspend_until, $reserve_id ) ); |
1129 |
} else { |
1112 |
} else { |
1130 |
$dbh->do("UPDATE reserves SET suspend_until = NULL WHERE biblionumber = ? AND borrowernumber = ?", undef, ( $biblio, $borrower ) ); |
1113 |
$dbh->do("UPDATE reserves SET suspend_until = NULL WHERE reserve_id = ?", undef, ( $reserve_id ) ); |
1131 |
} |
1114 |
} |
1132 |
} |
1115 |
} |
1133 |
|
1116 |
|
1134 |
_FixPriority( $biblio, $borrower, $rank); |
1117 |
_FixPriority( $reserve_id, $rank ); |
1135 |
} |
1118 |
} |
1136 |
} |
1119 |
} |
1137 |
|
1120 |
|
Lines 1151-1156
sub ModReserveFill {
Link Here
|
1151 |
my ($res) = @_; |
1134 |
my ($res) = @_; |
1152 |
my $dbh = C4::Context->dbh; |
1135 |
my $dbh = C4::Context->dbh; |
1153 |
# fill in a reserve record.... |
1136 |
# fill in a reserve record.... |
|
|
1137 |
my $reserve_id = $res->{'reserve_id'}; |
1154 |
my $biblionumber = $res->{'biblionumber'}; |
1138 |
my $biblionumber = $res->{'biblionumber'}; |
1155 |
my $borrowernumber = $res->{'borrowernumber'}; |
1139 |
my $borrowernumber = $res->{'borrowernumber'}; |
1156 |
my $resdate = $res->{'reservedate'}; |
1140 |
my $resdate = $res->{'reservedate'}; |
Lines 1199-1205
sub ModReserveFill {
Link Here
|
1199 |
# now fix the priority on the others (if the priority wasn't |
1183 |
# now fix the priority on the others (if the priority wasn't |
1200 |
# already sorted!).... |
1184 |
# already sorted!).... |
1201 |
unless ( $priority == 0 ) { |
1185 |
unless ( $priority == 0 ) { |
1202 |
_FixPriority( $biblionumber, $borrowernumber ); |
1186 |
_FixPriority( $reserve_id ); |
1203 |
} |
1187 |
} |
1204 |
} |
1188 |
} |
1205 |
|
1189 |
|
Lines 1309-1315
sub ModReserveCancelAll {
Link Here
|
1309 |
my ( $itemnumber, $borrowernumber ) = @_; |
1293 |
my ( $itemnumber, $borrowernumber ) = @_; |
1310 |
|
1294 |
|
1311 |
#step 1 : cancel the reservation |
1295 |
#step 1 : cancel the reservation |
1312 |
my $CancelReserve = CancelReserve( undef, $itemnumber, $borrowernumber ); |
1296 |
my $CancelReserve = CancelReserve({ itemnumber => $itemnumber, borrowernumber => $borrowernumber }); |
1313 |
|
1297 |
|
1314 |
#step 2 launch the subroutine of the others reserves |
1298 |
#step 2 launch the subroutine of the others reserves |
1315 |
( $messages, $nextreservinfo ) = GetOtherReserves($itemnumber); |
1299 |
( $messages, $nextreservinfo ) = GetOtherReserves($itemnumber); |
Lines 1321-1350
sub ModReserveCancelAll {
Link Here
|
1321 |
|
1305 |
|
1322 |
&ModReserveMinusPriority($itemnumber,$borrowernumber,$biblionumber) |
1306 |
&ModReserveMinusPriority($itemnumber,$borrowernumber,$biblionumber) |
1323 |
|
1307 |
|
1324 |
Reduce the values of queuded list |
1308 |
Reduce the values of queued list |
1325 |
|
1309 |
|
1326 |
=cut |
1310 |
=cut |
1327 |
|
1311 |
|
1328 |
sub ModReserveMinusPriority { |
1312 |
sub ModReserveMinusPriority { |
1329 |
my ( $itemnumber, $borrowernumber, $biblionumber ) = @_; |
1313 |
my ( $itemnumber, $reserve_id ) = @_; |
1330 |
|
1314 |
|
1331 |
#first step update the value of the first person on reserv |
1315 |
#first step update the value of the first person on reserv |
1332 |
my $dbh = C4::Context->dbh; |
1316 |
my $dbh = C4::Context->dbh; |
1333 |
my $query = " |
1317 |
my $query = " |
1334 |
UPDATE reserves |
1318 |
UPDATE reserves |
1335 |
SET priority = 0 , itemnumber = ? |
1319 |
SET priority = 0 , itemnumber = ? |
1336 |
WHERE borrowernumber=? |
1320 |
WHERE reserve_id = ? |
1337 |
AND biblionumber=? |
|
|
1338 |
"; |
1321 |
"; |
1339 |
my $sth_upd = $dbh->prepare($query); |
1322 |
my $sth_upd = $dbh->prepare($query); |
1340 |
$sth_upd->execute( $itemnumber, $borrowernumber, $biblionumber ); |
1323 |
$sth_upd->execute( $itemnumber, $reserve_id ); |
1341 |
# second step update all others reservs |
1324 |
# second step update all others reservs |
1342 |
_FixPriority($biblionumber, $borrowernumber, '0'); |
1325 |
_FixPriority( $reserve_id, '0'); |
1343 |
} |
1326 |
} |
1344 |
|
1327 |
|
1345 |
=head2 GetReserveInfo |
1328 |
=head2 GetReserveInfo |
1346 |
|
1329 |
|
1347 |
&GetReserveInfo($borrowernumber,$biblionumber); |
1330 |
&GetReserveInfo($reserve_id); |
1348 |
|
1331 |
|
1349 |
Get item and borrower details for a current hold. |
1332 |
Get item and borrower details for a current hold. |
1350 |
Current implementation this query should have a single result. |
1333 |
Current implementation this query should have a single result. |
Lines 1352-1400
Current implementation this query should have a single result.
Link Here
|
1352 |
=cut |
1335 |
=cut |
1353 |
|
1336 |
|
1354 |
sub GetReserveInfo { |
1337 |
sub GetReserveInfo { |
1355 |
my ( $borrowernumber, $biblionumber ) = @_; |
1338 |
my ( $reserve_id ) = @_; |
1356 |
my $dbh = C4::Context->dbh; |
1339 |
my $dbh = C4::Context->dbh; |
1357 |
my $strsth="SELECT |
1340 |
my $strsth="SELECT |
1358 |
reservedate, |
1341 |
reserve_id, |
1359 |
reservenotes, |
1342 |
reservedate, |
1360 |
reserves.borrowernumber, |
1343 |
reservenotes, |
1361 |
reserves.biblionumber, |
1344 |
reserves.borrowernumber, |
1362 |
reserves.branchcode, |
1345 |
reserves.biblionumber, |
1363 |
reserves.waitingdate, |
1346 |
reserves.branchcode, |
1364 |
notificationdate, |
1347 |
reserves.waitingdate, |
1365 |
reminderdate, |
1348 |
notificationdate, |
1366 |
priority, |
1349 |
reminderdate, |
1367 |
found, |
1350 |
priority, |
1368 |
firstname, |
1351 |
found, |
1369 |
surname, |
1352 |
firstname, |
1370 |
phone, |
1353 |
surname, |
1371 |
email, |
1354 |
phone, |
1372 |
address, |
1355 |
email, |
1373 |
address2, |
1356 |
address, |
1374 |
cardnumber, |
1357 |
address2, |
1375 |
city, |
1358 |
cardnumber, |
1376 |
zipcode, |
1359 |
city, |
1377 |
biblio.title, |
1360 |
zipcode, |
1378 |
biblio.author, |
1361 |
biblio.title, |
1379 |
items.holdingbranch, |
1362 |
biblio.author, |
1380 |
items.itemcallnumber, |
1363 |
items.holdingbranch, |
1381 |
items.itemnumber, |
1364 |
items.itemcallnumber, |
1382 |
items.location, |
1365 |
items.itemnumber, |
1383 |
barcode, |
1366 |
items.location, |
1384 |
notes |
1367 |
barcode, |
1385 |
FROM reserves |
1368 |
notes |
1386 |
LEFT JOIN items USING(itemnumber) |
1369 |
FROM reserves |
1387 |
LEFT JOIN borrowers USING(borrowernumber) |
1370 |
LEFT JOIN items USING(itemnumber) |
1388 |
LEFT JOIN biblio ON (reserves.biblionumber=biblio.biblionumber) |
1371 |
LEFT JOIN borrowers USING(borrowernumber) |
1389 |
WHERE |
1372 |
LEFT JOIN biblio ON (reserves.biblionumber=biblio.biblionumber) |
1390 |
reserves.borrowernumber=? |
1373 |
WHERE reserves.reserve_id = ?"; |
1391 |
AND reserves.biblionumber=?"; |
1374 |
my $sth = $dbh->prepare($strsth); |
1392 |
my $sth = $dbh->prepare($strsth); |
1375 |
$sth->execute($reserve_id); |
1393 |
$sth->execute($borrowernumber,$biblionumber); |
|
|
1394 |
|
1395 |
my $data = $sth->fetchrow_hashref; |
1396 |
return $data; |
1397 |
|
1376 |
|
|
|
1377 |
my $data = $sth->fetchrow_hashref; |
1378 |
return $data; |
1398 |
} |
1379 |
} |
1399 |
|
1380 |
|
1400 |
=head2 IsAvailableForItemLevelRequest |
1381 |
=head2 IsAvailableForItemLevelRequest |
Lines 1471-1477
sub IsAvailableForItemLevelRequest {
Link Here
|
1471 |
|
1452 |
|
1472 |
=head2 AlterPriority |
1453 |
=head2 AlterPriority |
1473 |
|
1454 |
|
1474 |
AlterPriority( $where, $borrowernumber, $biblionumber, $reservedate ); |
1455 |
AlterPriority( $where, $reserve_id ); |
1475 |
|
1456 |
|
1476 |
This function changes a reserve's priority up, down, to the top, or to the bottom. |
1457 |
This function changes a reserve's priority up, down, to the top, or to the bottom. |
1477 |
Input: $where is 'up', 'down', 'top' or 'bottom'. Biblionumber, Date reserve was placed |
1458 |
Input: $where is 'up', 'down', 'top' or 'bottom'. Biblionumber, Date reserve was placed |
Lines 1479-1507
Input: $where is 'up', 'down', 'top' or 'bottom'. Biblionumber, Date reserve was
Link Here
|
1479 |
=cut |
1460 |
=cut |
1480 |
|
1461 |
|
1481 |
sub AlterPriority { |
1462 |
sub AlterPriority { |
1482 |
my ( $where, $borrowernumber, $biblionumber ) = @_; |
1463 |
my ( $where, $reserve_id ) = @_; |
1483 |
|
1464 |
|
1484 |
my $dbh = C4::Context->dbh; |
1465 |
my $dbh = C4::Context->dbh; |
1485 |
|
1466 |
|
1486 |
## Find this reserve |
1467 |
my $reserve = GetReserve( $reserve_id ); |
1487 |
my $sth = $dbh->prepare('SELECT * FROM reserves WHERE biblionumber = ? AND borrowernumber = ? AND cancellationdate IS NULL'); |
|
|
1488 |
$sth->execute( $biblionumber, $borrowernumber ); |
1489 |
my $reserve = $sth->fetchrow_hashref(); |
1490 |
$sth->finish(); |
1491 |
|
1468 |
|
1492 |
if ( $where eq 'up' || $where eq 'down' ) { |
1469 |
if ( $where eq 'up' || $where eq 'down' ) { |
1493 |
|
1470 |
|
1494 |
my $priority = $reserve->{'priority'}; |
1471 |
my $priority = $reserve->{'priority'}; |
1495 |
$priority = $where eq 'up' ? $priority - 1 : $priority + 1; |
1472 |
$priority = $where eq 'up' ? $priority - 1 : $priority + 1; |
1496 |
_FixPriority( $biblionumber, $borrowernumber, $priority ) |
1473 |
_FixPriority( $reserve_id, $priority ) |
1497 |
|
1474 |
|
1498 |
} elsif ( $where eq 'top' ) { |
1475 |
} elsif ( $where eq 'top' ) { |
1499 |
|
1476 |
|
1500 |
_FixPriority( $biblionumber, $borrowernumber, '1' ) |
1477 |
_FixPriority( $reserve_id, '1' ) |
1501 |
|
1478 |
|
1502 |
} elsif ( $where eq 'bottom' ) { |
1479 |
} elsif ( $where eq 'bottom' ) { |
1503 |
|
1480 |
|
1504 |
_FixPriority( $biblionumber, $borrowernumber, '999999' ) |
1481 |
_FixPriority( $reserve_id, '999999' ) |
1505 |
|
1482 |
|
1506 |
} |
1483 |
} |
1507 |
} |
1484 |
} |
Lines 1515-1541
This function sets the lowestPriority field to true if is false, and false if it
Link Here
|
1515 |
=cut |
1492 |
=cut |
1516 |
|
1493 |
|
1517 |
sub ToggleLowestPriority { |
1494 |
sub ToggleLowestPriority { |
1518 |
my ( $borrowernumber, $biblionumber ) = @_; |
1495 |
my ( $reserve_id ) = @_; |
1519 |
|
1496 |
|
1520 |
my $dbh = C4::Context->dbh; |
1497 |
my $dbh = C4::Context->dbh; |
1521 |
|
1498 |
|
1522 |
my $sth = $dbh->prepare( |
1499 |
my $sth = $dbh->prepare( "UPDATE reserves SET lowestPriority = NOT lowestPriority WHERE reserve_id = ?"); |
1523 |
"UPDATE reserves SET lowestPriority = NOT lowestPriority |
1500 |
$sth->execute( $reserve_id ); |
1524 |
WHERE biblionumber = ? |
|
|
1525 |
AND borrowernumber = ?" |
1526 |
); |
1527 |
$sth->execute( |
1528 |
$biblionumber, |
1529 |
$borrowernumber, |
1530 |
); |
1531 |
$sth->finish; |
1501 |
$sth->finish; |
1532 |
|
1502 |
|
1533 |
_FixPriority( $biblionumber, $borrowernumber, '999999' ); |
1503 |
_FixPriority( $reserve_id, '999999' ); |
1534 |
} |
1504 |
} |
1535 |
|
1505 |
|
1536 |
=head2 ToggleSuspend |
1506 |
=head2 ToggleSuspend |
1537 |
|
1507 |
|
1538 |
ToggleSuspend( $borrowernumber, $biblionumber ); |
1508 |
ToggleSuspend( $reserve_id ); |
1539 |
|
1509 |
|
1540 |
This function sets the suspend field to true if is false, and false if it is true. |
1510 |
This function sets the suspend field to true if is false, and false if it is true. |
1541 |
If the reserve is currently suspended with a suspend_until date, that date will |
1511 |
If the reserve is currently suspended with a suspend_until date, that date will |
Lines 1544-1550
be cleared when it is unsuspended.
Link Here
|
1544 |
=cut |
1514 |
=cut |
1545 |
|
1515 |
|
1546 |
sub ToggleSuspend { |
1516 |
sub ToggleSuspend { |
1547 |
my ( $borrowernumber, $biblionumber, $suspend_until ) = @_; |
1517 |
my ( $reserve_id, $suspend_until ) = @_; |
1548 |
|
1518 |
|
1549 |
$suspend_until = output_pref( dt_from_string( $suspend_until ), 'iso' ) if ( $suspend_until ); |
1519 |
$suspend_until = output_pref( dt_from_string( $suspend_until ), 'iso' ) if ( $suspend_until ); |
1550 |
|
1520 |
|
Lines 1555-1568
sub ToggleSuspend {
Link Here
|
1555 |
my $sth = $dbh->prepare( |
1525 |
my $sth = $dbh->prepare( |
1556 |
"UPDATE reserves SET suspend = NOT suspend, |
1526 |
"UPDATE reserves SET suspend = NOT suspend, |
1557 |
suspend_until = CASE WHEN suspend = 0 THEN NULL ELSE $do_until END |
1527 |
suspend_until = CASE WHEN suspend = 0 THEN NULL ELSE $do_until END |
1558 |
WHERE biblionumber = ? |
1528 |
WHERE reserve_id = ? |
1559 |
AND borrowernumber = ? |
|
|
1560 |
"); |
1529 |
"); |
1561 |
|
1530 |
|
1562 |
my @params; |
1531 |
my @params; |
1563 |
push( @params, $suspend_until ) if ( $suspend_until ); |
1532 |
push( @params, $suspend_until ) if ( $suspend_until ); |
1564 |
push( @params, $biblionumber ); |
1533 |
push( @params, $reserve_id ); |
1565 |
push( @params, $borrowernumber ); |
|
|
1566 |
|
1534 |
|
1567 |
$sth->execute( @params ); |
1535 |
$sth->execute( @params ); |
1568 |
$sth->finish; |
1536 |
$sth->finish; |
Lines 1627-1633
sub SuspendAll {
Link Here
|
1627 |
|
1595 |
|
1628 |
=head2 _FixPriority |
1596 |
=head2 _FixPriority |
1629 |
|
1597 |
|
1630 |
&_FixPriority($biblio,$borrowernumber,$rank,$ignoreSetLowestRank); |
1598 |
&_FixPriority( $reserve_id, $rank, $ignoreSetLowestRank); |
1631 |
|
1599 |
|
1632 |
Only used internally (so don't export it) |
1600 |
Only used internally (so don't export it) |
1633 |
Changed how this functions works # |
1601 |
Changed how this functions works # |
Lines 1639-1679
in new priority rank
Link Here
|
1639 |
=cut |
1607 |
=cut |
1640 |
|
1608 |
|
1641 |
sub _FixPriority { |
1609 |
sub _FixPriority { |
1642 |
my ( $biblio, $borrowernumber, $rank, $ignoreSetLowestRank ) = @_; |
1610 |
my ( $reserve_id, $rank, $ignoreSetLowestRank ) = @_; |
1643 |
my $dbh = C4::Context->dbh; |
1611 |
my $dbh = C4::Context->dbh; |
1644 |
if ( $rank eq "del" ) { |
1612 |
|
1645 |
CancelReserve( $biblio, undef, $borrowernumber ); |
1613 |
my $res = GetReserve( $reserve_id ); |
1646 |
} |
1614 |
|
1647 |
if ( $rank eq "W" || $rank eq "0" ) { |
1615 |
if ( $rank eq "del" ) { |
|
|
1616 |
CancelReserve({ reserve_id => $reserve_id }); |
1617 |
} |
1618 |
elsif ( $rank eq "W" || $rank eq "0" ) { |
1648 |
|
1619 |
|
1649 |
# make sure priority for waiting or in-transit items is 0 |
1620 |
# make sure priority for waiting or in-transit items is 0 |
1650 |
my $query = qq/ |
1621 |
my $query = " |
1651 |
UPDATE reserves |
1622 |
UPDATE reserves |
1652 |
SET priority = 0 |
1623 |
SET priority = 0 |
1653 |
WHERE biblionumber = ? |
1624 |
WHERE reserve_id = ? |
1654 |
AND borrowernumber = ? |
1625 |
AND found IN ('W', 'T') |
1655 |
AND found IN ('W', 'T') |
1626 |
"; |
1656 |
/; |
|
|
1657 |
my $sth = $dbh->prepare($query); |
1627 |
my $sth = $dbh->prepare($query); |
1658 |
$sth->execute( $biblio, $borrowernumber ); |
1628 |
$sth->execute( $reserve_id ); |
1659 |
} |
1629 |
} |
1660 |
my @priority; |
1630 |
my @priority; |
1661 |
my @reservedates; |
1631 |
my @reservedates; |
1662 |
|
1632 |
|
1663 |
# get whats left |
1633 |
# get whats left |
1664 |
# FIXME adding a new security in returned elements for changing priority, |
1634 |
my $query = " |
1665 |
# now, we don't care anymore any reservations with itemnumber linked (suppose a waiting reserve) |
1635 |
SELECT reserve_id, borrowernumber, reservedate, constrainttype |
1666 |
# This is wrong a waiting reserve has W set |
|
|
1667 |
# The assumption that having an itemnumber set means waiting is wrong and should be corrected any place it occurs |
1668 |
my $query = qq/ |
1669 |
SELECT borrowernumber, reservedate, constrainttype |
1670 |
FROM reserves |
1636 |
FROM reserves |
1671 |
WHERE biblionumber = ? |
1637 |
WHERE biblionumber = ? |
1672 |
AND ((found <> 'W' AND found <> 'T') or found is NULL) |
1638 |
AND ((found <> 'W' AND found <> 'T') OR found IS NULL) |
1673 |
ORDER BY priority ASC |
1639 |
ORDER BY priority ASC |
1674 |
/; |
1640 |
"; |
1675 |
my $sth = $dbh->prepare($query); |
1641 |
my $sth = $dbh->prepare($query); |
1676 |
$sth->execute($biblio); |
1642 |
$sth->execute( $res->{'biblionumber'} ); |
1677 |
while ( my $line = $sth->fetchrow_hashref ) { |
1643 |
while ( my $line = $sth->fetchrow_hashref ) { |
1678 |
push( @reservedates, $line ); |
1644 |
push( @reservedates, $line ); |
1679 |
push( @priority, $line ); |
1645 |
push( @priority, $line ); |
Lines 1683-1689
sub _FixPriority {
Link Here
|
1683 |
my $i; |
1649 |
my $i; |
1684 |
my $key = -1; # to allow for 0 to be a valid result |
1650 |
my $key = -1; # to allow for 0 to be a valid result |
1685 |
for ( $i = 0 ; $i < @priority ; $i++ ) { |
1651 |
for ( $i = 0 ; $i < @priority ; $i++ ) { |
1686 |
if ( $borrowernumber == $priority[$i]->{'borrowernumber'} ) { |
1652 |
if ( $reserve_id == $priority[$i]->{'reserve_id'} ) { |
1687 |
$key = $i; # save the index |
1653 |
$key = $i; # save the index |
1688 |
last; |
1654 |
last; |
1689 |
} |
1655 |
} |
Lines 1699-1727
sub _FixPriority {
Link Here
|
1699 |
|
1665 |
|
1700 |
# now fix the priority on those that are left.... |
1666 |
# now fix the priority on those that are left.... |
1701 |
$query = " |
1667 |
$query = " |
1702 |
UPDATE reserves |
1668 |
UPDATE reserves |
1703 |
SET priority = ? |
1669 |
SET priority = ? |
1704 |
WHERE biblionumber = ? |
1670 |
WHERE reserve_id = ? |
1705 |
AND borrowernumber = ? |
|
|
1706 |
AND reservedate = ? |
1707 |
AND found IS NULL |
1708 |
"; |
1671 |
"; |
1709 |
$sth = $dbh->prepare($query); |
1672 |
$sth = $dbh->prepare($query); |
1710 |
for ( my $j = 0 ; $j < @priority ; $j++ ) { |
1673 |
for ( my $j = 0 ; $j < @priority ; $j++ ) { |
1711 |
$sth->execute( |
1674 |
$sth->execute( |
1712 |
$j + 1, $biblio, |
1675 |
$j + 1, |
1713 |
$priority[$j]->{'borrowernumber'}, |
1676 |
$priority[$j]->{'reserve_id'} |
1714 |
$priority[$j]->{'reservedate'} |
|
|
1715 |
); |
1677 |
); |
1716 |
$sth->finish; |
1678 |
$sth->finish; |
1717 |
} |
1679 |
} |
1718 |
|
1680 |
|
1719 |
$sth = $dbh->prepare( "SELECT borrowernumber FROM reserves WHERE lowestPriority = 1 ORDER BY priority" ); |
1681 |
$sth = $dbh->prepare( "SELECT reserve_id FROM reserves WHERE lowestPriority = 1 ORDER BY priority" ); |
1720 |
$sth->execute(); |
1682 |
$sth->execute(); |
1721 |
|
1683 |
|
1722 |
unless ( $ignoreSetLowestRank ) { |
1684 |
unless ( $ignoreSetLowestRank ) { |
1723 |
while ( my $res = $sth->fetchrow_hashref() ) { |
1685 |
while ( my $res = $sth->fetchrow_hashref() ) { |
1724 |
_FixPriority( $biblio, $res->{'borrowernumber'}, '999999', 1 ); |
1686 |
_FixPriority( $res->{'reserve_id'}, '999999', 1 ); |
1725 |
} |
1687 |
} |
1726 |
} |
1688 |
} |
1727 |
} |
1689 |
} |
Lines 1760-1766
sub _Findgroupreserve {
Link Here
|
1760 |
reserves.priority AS priority, |
1722 |
reserves.priority AS priority, |
1761 |
reserves.timestamp AS timestamp, |
1723 |
reserves.timestamp AS timestamp, |
1762 |
biblioitems.biblioitemnumber AS biblioitemnumber, |
1724 |
biblioitems.biblioitemnumber AS biblioitemnumber, |
1763 |
reserves.itemnumber AS itemnumber |
1725 |
reserves.itemnumber AS itemnumber, |
|
|
1726 |
reserves.reserve_id AS reserve_id |
1764 |
FROM reserves |
1727 |
FROM reserves |
1765 |
JOIN biblioitems USING (biblionumber) |
1728 |
JOIN biblioitems USING (biblionumber) |
1766 |
JOIN hold_fill_targets USING (biblionumber, borrowernumber, itemnumber) |
1729 |
JOIN hold_fill_targets USING (biblionumber, borrowernumber, itemnumber) |
Lines 2028-2035
sub MoveReserve {
Link Here
|
2028 |
RevertWaitingStatus({ itemnumber => $itemnumber }); |
1991 |
RevertWaitingStatus({ itemnumber => $itemnumber }); |
2029 |
} |
1992 |
} |
2030 |
elsif ( $cancelreserve eq 'cancel' || $cancelreserve ) { # cancel reserves on this item |
1993 |
elsif ( $cancelreserve eq 'cancel' || $cancelreserve ) { # cancel reserves on this item |
2031 |
CancelReserve(0, $res->{'itemnumber'}, $res->{'borrowernumber'}); |
1994 |
CancelReserve({ |
2032 |
CancelReserve($res->{'biblionumber'}, 0, $res->{'borrowernumber'}); |
1995 |
biblionumber => $res->{'biblionumber'}, |
|
|
1996 |
itemnumber => $res->{'itemnumber'}, |
1997 |
borrowernumber => $res->{'borrowernumber'} |
1998 |
}); |
2033 |
} |
1999 |
} |
2034 |
} |
2000 |
} |
2035 |
} |
2001 |
} |
Lines 2045-2051
This shifts the holds from C<$from_biblio> to C<$to_biblio> and reorders them by
Link Here
|
2045 |
sub MergeHolds { |
2011 |
sub MergeHolds { |
2046 |
my ( $dbh, $to_biblio, $from_biblio ) = @_; |
2012 |
my ( $dbh, $to_biblio, $from_biblio ) = @_; |
2047 |
my $sth = $dbh->prepare( |
2013 |
my $sth = $dbh->prepare( |
2048 |
"SELECT count(*) as reservenumber FROM reserves WHERE biblionumber = ?" |
2014 |
"SELECT count(*) as reserve_id FROM reserves WHERE biblionumber = ?" |
2049 |
); |
2015 |
); |
2050 |
$sth->execute($from_biblio); |
2016 |
$sth->execute($from_biblio); |
2051 |
if ( my $data = $sth->fetchrow_hashref() ) { |
2017 |
if ( my $data = $sth->fetchrow_hashref() ) { |
Lines 2138-2143
sub RevertWaitingStatus {
Link Here
|
2138 |
return $sth->execute( $reserve->{'reserve_id'} ); |
2104 |
return $sth->execute( $reserve->{'reserve_id'} ); |
2139 |
} |
2105 |
} |
2140 |
|
2106 |
|
|
|
2107 |
=head2 GetReserveId |
2108 |
|
2109 |
$reserve_id = GetReserveId({ biblionumber => $biblionumber, borrowernumber => $borrowernumber [, itemnumber => $itemnumber ] }); |
2110 |
|
2111 |
Returnes the first reserve id that matches the given criteria |
2112 |
|
2113 |
=cut |
2114 |
|
2115 |
sub GetReserveId { |
2116 |
my ( $params ) = @_; |
2117 |
|
2118 |
return unless ( ( $params->{'biblionumber'} || $params->{'itemnumber'} ) && $params->{'borrowernumber'} ); |
2119 |
|
2120 |
my $dbh = C4::Context->dbh(); |
2121 |
|
2122 |
my $sql = "SELECT reserve_id FROM reserves WHERE "; |
2123 |
|
2124 |
my @params; |
2125 |
my @limits; |
2126 |
foreach my $key ( keys %$params ) { |
2127 |
if ( defined( $params->{$key} ) ) { |
2128 |
push( @limits, "$key = ?" ); |
2129 |
push( @params, $params->{$key} ); |
2130 |
} |
2131 |
} |
2132 |
|
2133 |
$sql .= join( " AND ", @limits ); |
2134 |
|
2135 |
my $sth = $dbh->prepare( $sql ); |
2136 |
$sth->execute( @params ); |
2137 |
my $row = $sth->fetchrow_hashref(); |
2138 |
|
2139 |
return $row->{'reserve_id'}; |
2140 |
} |
2141 |
|
2141 |
=head2 ReserveSlip |
2142 |
=head2 ReserveSlip |
2142 |
|
2143 |
|
2143 |
ReserveSlip($branchcode, $borrowernumber, $biblionumber) |
2144 |
ReserveSlip($branchcode, $borrowernumber, $biblionumber) |