Lines 40-45
use Koha::DateUtils;
Link Here
|
40 |
use Koha::Calendar; |
40 |
use Koha::Calendar; |
41 |
use Koha::Database; |
41 |
use Koha::Database; |
42 |
use Koha::Hold; |
42 |
use Koha::Hold; |
|
|
43 |
use Koha::Old::Hold; |
43 |
use Koha::Holds; |
44 |
use Koha::Holds; |
44 |
use Koha::Libraries; |
45 |
use Koha::Libraries; |
45 |
use Koha::Items; |
46 |
use Koha::Items; |
Lines 1228-1283
whose keys are fields from the reserves table in the Koha database.
Link Here
|
1228 |
|
1229 |
|
1229 |
sub ModReserveFill { |
1230 |
sub ModReserveFill { |
1230 |
my ($res) = @_; |
1231 |
my ($res) = @_; |
1231 |
my $dbh = C4::Context->dbh; |
|
|
1232 |
# fill in a reserve record.... |
1233 |
my $reserve_id = $res->{'reserve_id'}; |
1232 |
my $reserve_id = $res->{'reserve_id'}; |
1234 |
my $biblionumber = $res->{'biblionumber'}; |
1233 |
|
1235 |
my $borrowernumber = $res->{'borrowernumber'}; |
1234 |
my $dbh = C4::Context->dbh; |
1236 |
my $resdate = $res->{'reservedate'}; |
1235 |
|
|
|
1236 |
my $hold = Koha::Holds->find($reserve_id); |
1237 |
|
1237 |
|
1238 |
# get the priority on this record.... |
1238 |
# get the priority on this record.... |
1239 |
my $priority; |
1239 |
my $priority = $hold->priority; |
1240 |
my $query = "SELECT priority |
|
|
1241 |
FROM reserves |
1242 |
WHERE biblionumber = ? |
1243 |
AND borrowernumber = ? |
1244 |
AND reservedate = ?"; |
1245 |
my $sth = $dbh->prepare($query); |
1246 |
$sth->execute( $biblionumber, $borrowernumber, $resdate ); |
1247 |
($priority) = $sth->fetchrow_array; |
1248 |
|
1240 |
|
1249 |
# update the database... |
1241 |
# update the hold statuses, no need to store it though, we will be deleting it anyway |
1250 |
$query = "UPDATE reserves |
1242 |
$hold->set( |
1251 |
SET found = 'F', |
1243 |
{ |
1252 |
priority = 0 |
1244 |
found => 'F', |
1253 |
WHERE biblionumber = ? |
1245 |
priority => 0, |
1254 |
AND reservedate = ? |
1246 |
} |
1255 |
AND borrowernumber = ? |
1247 |
); |
1256 |
"; |
1248 |
|
1257 |
$sth = $dbh->prepare($query); |
1249 |
my $old_hold = Koha::Old::Hold->new( $hold->unblessed() )->store(); |
1258 |
$sth->execute( $biblionumber, $resdate, $borrowernumber ); |
1250 |
|
1259 |
|
1251 |
$hold->delete(); |
1260 |
# move to old_reserves |
|
|
1261 |
$query = "INSERT INTO old_reserves |
1262 |
SELECT * FROM reserves |
1263 |
WHERE biblionumber = ? |
1264 |
AND reservedate = ? |
1265 |
AND borrowernumber = ? |
1266 |
"; |
1267 |
$sth = $dbh->prepare($query); |
1268 |
$sth->execute( $biblionumber, $resdate, $borrowernumber ); |
1269 |
$query = "DELETE FROM reserves |
1270 |
WHERE biblionumber = ? |
1271 |
AND reservedate = ? |
1272 |
AND borrowernumber = ? |
1273 |
"; |
1274 |
$sth = $dbh->prepare($query); |
1275 |
$sth->execute( $biblionumber, $resdate, $borrowernumber ); |
1276 |
|
1252 |
|
1277 |
# now fix the priority on the others (if the priority wasn't |
1253 |
# now fix the priority on the others (if the priority wasn't |
1278 |
# already sorted!).... |
1254 |
# already sorted!).... |
1279 |
unless ( $priority == 0 ) { |
1255 |
unless ( $priority == 0 ) { |
1280 |
_FixPriority({ reserve_id => $reserve_id, biblionumber => $biblionumber }); |
1256 |
_FixPriority( { reserve_id => $reserve_id, biblionumber => $hold->biblionumber } ); |
1281 |
} |
1257 |
} |
1282 |
} |
1258 |
} |
1283 |
|
1259 |
|