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