Lines 113-131
BEGIN {
Link Here
|
113 |
&CancelReserve |
113 |
&CancelReserve |
114 |
|
114 |
|
115 |
&IsAvailableForItemLevelRequest |
115 |
&IsAvailableForItemLevelRequest |
|
|
116 |
|
117 |
&AlterPriority |
118 |
&ToggleLowestPriority |
116 |
); |
119 |
); |
117 |
} |
120 |
} |
118 |
|
121 |
|
119 |
=item AddReserve |
122 |
=item AddReserve |
120 |
|
123 |
|
121 |
AddReserve($branch,$borrowernumber,$biblionumber,$constraint,$bibitems,$priority,$notes,$title,$checkitem,$found) |
124 |
AddReserve($branch,$borrowernumber,$biblionumber,$constraint,$bibitems,$priority,$resdate,$expdate,$notes,$title,$checkitem,$found) |
122 |
|
125 |
|
123 |
=cut |
126 |
=cut |
124 |
|
127 |
|
125 |
sub AddReserve { |
128 |
sub AddReserve { |
126 |
my ( |
129 |
my ( |
127 |
$branch, $borrowernumber, $biblionumber, |
130 |
$branch, $borrowernumber, $biblionumber, |
128 |
$constraint, $bibitems, $priority, $resdate, $notes, |
131 |
$constraint, $bibitems, $priority, $resdate, $expdate, $notes, |
129 |
$title, $checkitem, $found |
132 |
$title, $checkitem, $found |
130 |
) = @_; |
133 |
) = @_; |
131 |
my $fee = |
134 |
my $fee = |
Lines 135-140
sub AddReserve {
Link Here
|
135 |
my $const = lc substr( $constraint, 0, 1 ); |
138 |
my $const = lc substr( $constraint, 0, 1 ); |
136 |
$resdate = format_date_in_iso( $resdate ) if ( $resdate ); |
139 |
$resdate = format_date_in_iso( $resdate ) if ( $resdate ); |
137 |
$resdate = C4::Dates->today( 'iso' ) unless ( $resdate ); |
140 |
$resdate = C4::Dates->today( 'iso' ) unless ( $resdate ); |
|
|
141 |
$expdate = format_date_in_iso( $expdate ) if ( $expdate ); |
138 |
if ( C4::Context->preference( 'AllowHoldDateInFuture' ) ) { |
142 |
if ( C4::Context->preference( 'AllowHoldDateInFuture' ) ) { |
139 |
# Make room in reserves for this before those of a later reserve date |
143 |
# Make room in reserves for this before those of a later reserve date |
140 |
$priority = _ShiftPriorityByDateAndPriority( $biblionumber, $resdate, $priority ); |
144 |
$priority = _ShiftPriorityByDateAndPriority( $biblionumber, $resdate, $priority ); |
Lines 165-180
sub AddReserve {
Link Here
|
165 |
my $query = qq/ |
169 |
my $query = qq/ |
166 |
INSERT INTO reserves |
170 |
INSERT INTO reserves |
167 |
(borrowernumber,biblionumber,reservedate,branchcode,constrainttype, |
171 |
(borrowernumber,biblionumber,reservedate,branchcode,constrainttype, |
168 |
priority,reservenotes,itemnumber,found,waitingdate) |
172 |
priority,reservenotes,itemnumber,found,waitingdate,expirationdate) |
169 |
VALUES |
173 |
VALUES |
170 |
(?,?,?,?,?, |
174 |
(?,?,?,?,?, |
171 |
?,?,?,?,?) |
175 |
?,?,?,?,?,?) |
172 |
/; |
176 |
/; |
173 |
my $sth = $dbh->prepare($query); |
177 |
my $sth = $dbh->prepare($query); |
174 |
$sth->execute( |
178 |
$sth->execute( |
175 |
$borrowernumber, $biblionumber, $resdate, $branch, |
179 |
$borrowernumber, $biblionumber, $resdate, $branch, |
176 |
$const, $priority, $notes, $checkitem, |
180 |
$const, $priority, $notes, $checkitem, |
177 |
$found, $waitingdate |
181 |
$found, $waitingdate, $expdate |
178 |
); |
182 |
); |
179 |
|
183 |
|
180 |
#} |
184 |
#} |
Lines 217-223
sub GetReservesFromBiblionumber {
Link Here
|
217 |
constrainttype, |
221 |
constrainttype, |
218 |
found, |
222 |
found, |
219 |
itemnumber, |
223 |
itemnumber, |
220 |
reservenotes |
224 |
reservenotes, |
|
|
225 |
expirationdate, |
226 |
lowestPriority |
221 |
FROM reserves |
227 |
FROM reserves |
222 |
WHERE biblionumber = ? "; |
228 |
WHERE biblionumber = ? "; |
223 |
unless ( $all_dates ) { |
229 |
unless ( $all_dates ) { |
Lines 660-665
sub CheckReserves {
Link Here
|
660 |
} |
666 |
} |
661 |
} |
667 |
} |
662 |
|
668 |
|
|
|
669 |
=item CancelExpiredReserves |
670 |
|
671 |
CancelExpiredReserves(); |
672 |
|
673 |
Cancels all reserves with an expiration date from before today. |
674 |
|
675 |
=cut |
676 |
|
677 |
sub CancelExpiredReserves { |
678 |
|
679 |
my $dbh = C4::Context->dbh; |
680 |
my $sth = $dbh->prepare( "SELECT * FROM reserves WHERE DATE(expirationdate) < DATE( CURDATE() ) AND expirationdate != '0000-00-00'" ); |
681 |
$sth->execute(); |
682 |
|
683 |
while ( my $res = $sth->fetchrow_hashref() ) { |
684 |
CancelReserve( $res->{'biblionumber'}, '', $res->{'borrowernumber'} ); |
685 |
} |
686 |
|
687 |
} |
688 |
|
663 |
=item CancelReserve |
689 |
=item CancelReserve |
664 |
|
690 |
|
665 |
&CancelReserve($biblionumber, $itemnumber, $borrowernumber); |
691 |
&CancelReserve($biblionumber, $itemnumber, $borrowernumber); |
Lines 1165-1173
sub IsAvailableForItemLevelRequest {
Link Here
|
1165 |
} |
1191 |
} |
1166 |
} |
1192 |
} |
1167 |
|
1193 |
|
|
|
1194 |
=item AlterPriority |
1195 |
AlterPriority( $where, $borrowernumber, $biblionumber, $reservedate ); |
1196 |
|
1197 |
This function changes a reserve's priority up, down, to the top, or to the bottom. |
1198 |
Input: $where is 'up', 'down', 'top' or 'bottom'. Biblionumber, Date reserve was placed |
1199 |
Output: None on success, -1 on failure |
1200 |
|
1201 |
=cut |
1202 |
sub AlterPriority { |
1203 |
my ( $where, $borrowernumber, $biblionumber ) = @_; |
1204 |
|
1205 |
my $newPriority = -1; |
1206 |
|
1207 |
my $dbh = C4::Context->dbh; |
1208 |
|
1209 |
## Find this reserve |
1210 |
my $sth = $dbh->prepare('SELECT * FROM reserves WHERE biblionumber = ? AND borrowernumber = ? AND cancellationdate IS NULL'); |
1211 |
$sth->execute( $biblionumber, $borrowernumber ); |
1212 |
my $reserve = $sth->fetchrow_hashref(); |
1213 |
$sth->finish(); |
1214 |
|
1215 |
if ( $where eq 'up' || $where eq 'down' ) { |
1216 |
|
1217 |
my $priority = $reserve->{'priority'}; |
1218 |
$priority = $where eq 'up' ? $priority - 1 : $priority + 1; |
1219 |
_FixPriority( $biblionumber, $borrowernumber, $priority ) |
1220 |
|
1221 |
} elsif ( $where eq 'top' ) { |
1222 |
|
1223 |
_FixPriority( $biblionumber, $borrowernumber, '1' ) |
1224 |
|
1225 |
} elsif ( $where eq 'bottom' ) { |
1226 |
|
1227 |
_FixPriority( $biblionumber, $borrowernumber, '999999' ) |
1228 |
|
1229 |
} |
1230 |
|
1231 |
return $newPriority; |
1232 |
|
1233 |
} |
1234 |
|
1235 |
=item ToggleLowestPriority |
1236 |
ToggleLowestPriority( $borrowernumber, $biblionumber ); |
1237 |
|
1238 |
This function sets the lowestPriority field to true if is false, and false if it is true. |
1239 |
=cut |
1240 |
|
1241 |
sub ToggleLowestPriority { |
1242 |
my ( $borrowernumber, $biblionumber ) = @_; |
1243 |
|
1244 |
my $dbh = C4::Context->dbh; |
1245 |
|
1246 |
my $sth = $dbh->prepare( |
1247 |
"UPDATE reserves SET lowestPriority = NOT lowestPriority |
1248 |
WHERE biblionumber = ? |
1249 |
AND borrowernumber = ?" |
1250 |
); |
1251 |
$sth->execute( |
1252 |
$biblionumber, |
1253 |
$borrowernumber, |
1254 |
); |
1255 |
$sth->finish; |
1256 |
|
1257 |
_FixPriority( $biblionumber, $borrowernumber, '999999' ); |
1258 |
} |
1259 |
|
1168 |
=item _FixPriority |
1260 |
=item _FixPriority |
1169 |
|
1261 |
|
1170 |
&_FixPriority($biblio,$borrowernumber,$rank); |
1262 |
&_FixPriority($biblio,$borrowernumber,$rank,$ignoreSetLowestRank); |
1171 |
|
1263 |
|
1172 |
Only used internally (so don't export it) |
1264 |
Only used internally (so don't export it) |
1173 |
Changed how this functions works # |
1265 |
Changed how this functions works # |
Lines 1179-1185
sub IsAvailableForItemLevelRequest {
Link Here
|
1179 |
=cut |
1271 |
=cut |
1180 |
|
1272 |
|
1181 |
sub _FixPriority { |
1273 |
sub _FixPriority { |
1182 |
my ( $biblio, $borrowernumber, $rank ) = @_; |
1274 |
my ( $biblio, $borrowernumber, $rank, $ignoreSetLowestRank ) = @_; |
1183 |
my $dbh = C4::Context->dbh; |
1275 |
my $dbh = C4::Context->dbh; |
1184 |
if ( $rank eq "del" ) { |
1276 |
if ( $rank eq "del" ) { |
1185 |
CancelReserve( $biblio, undef, $borrowernumber ); |
1277 |
CancelReserve( $biblio, undef, $borrowernumber ); |
Lines 1255-1260
sub _FixPriority {
Link Here
|
1255 |
); |
1347 |
); |
1256 |
$sth->finish; |
1348 |
$sth->finish; |
1257 |
} |
1349 |
} |
|
|
1350 |
|
1351 |
$sth = $dbh->prepare( "SELECT borrowernumber FROM reserves WHERE lowestPriority = 1 ORDER BY priority" ); |
1352 |
$sth->execute(); |
1353 |
|
1354 |
unless ( $ignoreSetLowestRank ) { |
1355 |
while ( my $res = $sth->fetchrow_hashref() ) { |
1356 |
_FixPriority( $biblio, $res->{'borrowernumber'}, '999999', 1 ); |
1357 |
} |
1358 |
} |
1258 |
} |
1359 |
} |
1259 |
|
1360 |
|
1260 |
=item _Findgroupreserve |
1361 |
=item _Findgroupreserve |