Lines 39-44
use Koha::DateUtils;
Link Here
|
39 |
use Koha::Calendar; |
39 |
use Koha::Calendar; |
40 |
use Koha::Database; |
40 |
use Koha::Database; |
41 |
use Koha::Hold; |
41 |
use Koha::Hold; |
|
|
42 |
use Koha::Old::Hold; |
42 |
use Koha::Holds; |
43 |
use Koha::Holds; |
43 |
use Koha::Libraries; |
44 |
use Koha::Libraries; |
44 |
use Koha::Patrons; |
45 |
use Koha::Patrons; |
Lines 1207-1262
whose keys are fields from the reserves table in the Koha database.
Link Here
|
1207 |
|
1208 |
|
1208 |
sub ModReserveFill { |
1209 |
sub ModReserveFill { |
1209 |
my ($res) = @_; |
1210 |
my ($res) = @_; |
1210 |
my $dbh = C4::Context->dbh; |
|
|
1211 |
# fill in a reserve record.... |
1212 |
my $reserve_id = $res->{'reserve_id'}; |
1211 |
my $reserve_id = $res->{'reserve_id'}; |
1213 |
my $biblionumber = $res->{'biblionumber'}; |
1212 |
|
1214 |
my $borrowernumber = $res->{'borrowernumber'}; |
1213 |
my $dbh = C4::Context->dbh; |
1215 |
my $resdate = $res->{'reservedate'}; |
1214 |
|
|
|
1215 |
my $hold = Koha::Holds->find($reserve_id); |
1216 |
|
1216 |
|
1217 |
# get the priority on this record.... |
1217 |
# get the priority on this record.... |
1218 |
my $priority; |
1218 |
my $priority = $hold->priority; |
1219 |
my $query = "SELECT priority |
|
|
1220 |
FROM reserves |
1221 |
WHERE biblionumber = ? |
1222 |
AND borrowernumber = ? |
1223 |
AND reservedate = ?"; |
1224 |
my $sth = $dbh->prepare($query); |
1225 |
$sth->execute( $biblionumber, $borrowernumber, $resdate ); |
1226 |
($priority) = $sth->fetchrow_array; |
1227 |
|
1219 |
|
1228 |
# update the database... |
1220 |
# update the hold statuses, no need to store it though, we will be deleting it anyway |
1229 |
$query = "UPDATE reserves |
1221 |
$hold->set( |
1230 |
SET found = 'F', |
1222 |
{ |
1231 |
priority = 0 |
1223 |
found => 'F', |
1232 |
WHERE biblionumber = ? |
1224 |
priority => 0, |
1233 |
AND reservedate = ? |
1225 |
} |
1234 |
AND borrowernumber = ? |
1226 |
); |
1235 |
"; |
1227 |
|
1236 |
$sth = $dbh->prepare($query); |
1228 |
my $old_hold = Koha::Old::Hold->new( $hold->unblessed() )->store(); |
1237 |
$sth->execute( $biblionumber, $resdate, $borrowernumber ); |
1229 |
|
1238 |
|
1230 |
$hold->delete(); |
1239 |
# move to old_reserves |
|
|
1240 |
$query = "INSERT INTO old_reserves |
1241 |
SELECT * FROM reserves |
1242 |
WHERE biblionumber = ? |
1243 |
AND reservedate = ? |
1244 |
AND borrowernumber = ? |
1245 |
"; |
1246 |
$sth = $dbh->prepare($query); |
1247 |
$sth->execute( $biblionumber, $resdate, $borrowernumber ); |
1248 |
$query = "DELETE FROM reserves |
1249 |
WHERE biblionumber = ? |
1250 |
AND reservedate = ? |
1251 |
AND borrowernumber = ? |
1252 |
"; |
1253 |
$sth = $dbh->prepare($query); |
1254 |
$sth->execute( $biblionumber, $resdate, $borrowernumber ); |
1255 |
|
1231 |
|
1256 |
# now fix the priority on the others (if the priority wasn't |
1232 |
# now fix the priority on the others (if the priority wasn't |
1257 |
# already sorted!).... |
1233 |
# already sorted!).... |
1258 |
unless ( $priority == 0 ) { |
1234 |
unless ( $priority == 0 ) { |
1259 |
_FixPriority({ reserve_id => $reserve_id, biblionumber => $biblionumber }); |
1235 |
_FixPriority( { reserve_id => $reserve_id, biblionumber => $hold->biblionumber } ); |
1260 |
} |
1236 |
} |
1261 |
} |
1237 |
} |
1262 |
|
1238 |
|