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