|
Lines 141-149
BEGIN {
Link Here
|
| 141 |
|
141 |
|
| 142 |
GetMaxPatronHoldsForRecord |
142 |
GetMaxPatronHoldsForRecord |
| 143 |
|
143 |
|
| 144 |
&AddReserveGroup |
144 |
&AddHoldGroup |
| 145 |
&DeleteReserveGroup |
145 |
&DeleteHoldGroup |
| 146 |
&GetReserveGroupReserves |
146 |
&GetHoldGroupHolds |
| 147 |
); |
147 |
); |
| 148 |
@EXPORT_OK = qw( MergeHolds ); |
148 |
@EXPORT_OK = qw( MergeHolds ); |
| 149 |
} |
149 |
} |
|
Lines 193-199
sub AddReserve {
Link Here
|
| 193 |
my $found = $params->{found}; |
193 |
my $found = $params->{found}; |
| 194 |
my $itemtype = $params->{itemtype}; |
194 |
my $itemtype = $params->{itemtype}; |
| 195 |
my $non_priority = $params->{non_priority}; |
195 |
my $non_priority = $params->{non_priority}; |
| 196 |
my $reserve_group_id = $params->{reserve_group_id}; |
196 |
my $hold_group_id = $params->{hold_group_id}; |
| 197 |
|
197 |
|
| 198 |
$resdate = output_pref( { str => dt_from_string( $resdate ), dateonly => 1, dateformat => 'iso' }) |
198 |
$resdate = output_pref( { str => dt_from_string( $resdate ), dateonly => 1, dateformat => 'iso' }) |
| 199 |
or output_pref({ dt => dt_from_string, dateonly => 1, dateformat => 'iso' }); |
199 |
or output_pref({ dt => dt_from_string, dateonly => 1, dateformat => 'iso' }); |
|
Lines 258-264
sub AddReserve {
Link Here
|
| 258 |
itemtype => $itemtype, |
258 |
itemtype => $itemtype, |
| 259 |
item_level_hold => $checkitem ? 1 : 0, |
259 |
item_level_hold => $checkitem ? 1 : 0, |
| 260 |
non_priority => $non_priority ? 1 : 0, |
260 |
non_priority => $non_priority ? 1 : 0, |
| 261 |
reserve_group_id => $reserve_group_id, |
261 |
hold_group_id => $hold_group_id, |
| 262 |
} |
262 |
} |
| 263 |
)->store(); |
263 |
)->store(); |
| 264 |
$hold->set_waiting() if $found && $found eq 'W'; |
264 |
$hold->set_waiting() if $found && $found eq 'W'; |
|
Lines 623-629
sub GetHoldCount {
Link Here
|
| 623 |
SELECT COUNT(*) AS counter |
623 |
SELECT COUNT(*) AS counter |
| 624 |
FROM reserves |
624 |
FROM reserves |
| 625 |
WHERE borrowernumber = ? |
625 |
WHERE borrowernumber = ? |
| 626 |
AND reserve_group_id is NULL"; #added by 15516 |
626 |
AND hold_group_id is NULL"; #added by 15516 |
| 627 |
my $sth = $dbh->prepare($query); |
627 |
my $sth = $dbh->prepare($query); |
| 628 |
$sth->execute($borrowernumber); |
628 |
$sth->execute($borrowernumber); |
| 629 |
my $row = $sth->fetchrow_hashref; |
629 |
my $row = $sth->fetchrow_hashref; |
|
Lines 632-641
sub GetHoldCount {
Link Here
|
| 632 |
$count += $row->{counter}; |
632 |
$count += $row->{counter}; |
| 633 |
|
633 |
|
| 634 |
$query = " |
634 |
$query = " |
| 635 |
SELECT COUNT(DISTINCT reserve_group_id) AS counter |
635 |
SELECT COUNT(DISTINCT hold_group_id) AS counter |
| 636 |
FROM reserves |
636 |
FROM reserves |
| 637 |
WHERE borrowernumber = ? |
637 |
WHERE borrowernumber = ? |
| 638 |
AND reserve_group_id is not NULL |
638 |
AND hold_group_id is not NULL |
| 639 |
"; |
639 |
"; |
| 640 |
$sth = $dbh->prepare($query); |
640 |
$sth = $dbh->prepare($query); |
| 641 |
$sth->execute($borrowernumber); |
641 |
$sth->execute($borrowernumber); |
|
Lines 1257-1270
sub ModReserveAffect {
Link Here
|
| 1257 |
}; |
1257 |
}; |
| 1258 |
} |
1258 |
} |
| 1259 |
|
1259 |
|
| 1260 |
if ($hold->reserve_group_id) { |
1260 |
if ($hold->hold_group_id) { |
| 1261 |
# Delete other reserves from same group |
1261 |
# Delete other reserves from same group |
| 1262 |
$dbh->do(q{ |
1262 |
$dbh->do(q{ |
| 1263 |
DELETE FROM reserves |
1263 |
DELETE FROM reserves |
| 1264 |
WHERE reserve_group_id = ? |
1264 |
WHERE hold_group_id = ? |
| 1265 |
AND reserve_id != ? |
1265 |
AND reserve_id != ? |
| 1266 |
}, undef, $hold->reserve_group_id, $hold->reserve_id); |
1266 |
}, undef, $hold->hold_group_id, $hold->reserve_id); |
| 1267 |
DeleteReserveGroup($hold->reserve_group_id); |
1267 |
DeleteHoldGroup($hold->hold_group_id); |
| 1268 |
} |
1268 |
} |
| 1269 |
|
1269 |
|
| 1270 |
_FixPriority( { biblionumber => $biblionumber } ); |
1270 |
_FixPriority( { biblionumber => $biblionumber } ); |
|
Lines 2325-2378
sub GetMaxPatronHoldsForRecord {
Link Here
|
| 2325 |
return $max; |
2325 |
return $max; |
| 2326 |
} |
2326 |
} |
| 2327 |
|
2327 |
|
| 2328 |
=head2 AddReserveGroup |
2328 |
=head2 AddHoldGroup |
| 2329 |
|
2329 |
|
| 2330 |
my $reserve_group_id = AddReserveGroup(); |
2330 |
my $hold_group_id = AddHoldGroup(); |
| 2331 |
|
2331 |
|
| 2332 |
Creates a new reserve group and returns its ID |
2332 |
Creates a new hold group and returns its ID |
| 2333 |
|
2333 |
|
| 2334 |
=cut |
2334 |
=cut |
| 2335 |
|
2335 |
|
| 2336 |
sub AddReserveGroup { |
2336 |
sub AddHoldGroup { |
| 2337 |
my $dbh = C4::Context->dbh; |
2337 |
my $dbh = C4::Context->dbh; |
| 2338 |
|
2338 |
|
| 2339 |
$dbh->do('INSERT INTO reserve_group VALUES ()'); |
2339 |
$dbh->do('INSERT INTO hold_group VALUES ()'); |
| 2340 |
return $dbh->last_insert_id(undef, undef, 'reserve_group', undef); |
2340 |
return $dbh->last_insert_id(undef, undef, 'hold_group', undef); |
| 2341 |
} |
2341 |
} |
| 2342 |
|
2342 |
|
| 2343 |
=head2 DeleteReserveGroup |
2343 |
=head2 DeleteHoldGroup |
| 2344 |
|
2344 |
|
| 2345 |
DeleteReserveGroup($reserve_group_id); |
2345 |
DeleteHoldGroup($hold_group_id); |
| 2346 |
|
2346 |
|
| 2347 |
Delete a reserve group. Reserves that belong to this group are not removed. |
2347 |
Delete a hold group. Reserves that belong to this group are not removed. |
| 2348 |
|
2348 |
|
| 2349 |
=cut |
2349 |
=cut |
| 2350 |
|
2350 |
|
| 2351 |
sub DeleteReserveGroup { |
2351 |
sub DeleteHoldGroup { |
| 2352 |
my ($reserve_group_id) = @_; |
2352 |
my ($hold_group_id) = @_; |
| 2353 |
|
2353 |
|
| 2354 |
my $dbh = C4::Context->dbh; |
2354 |
my $dbh = C4::Context->dbh; |
| 2355 |
my $query = 'DELETE FROM reserve_group WHERE reserve_group_id = ?'; |
2355 |
my $query = 'DELETE FROM hold_group WHERE hold_group_id = ?'; |
| 2356 |
$dbh->do($query, undef, $reserve_group_id); |
2356 |
$dbh->do($query, undef, $hold_group_id); |
| 2357 |
} |
2357 |
} |
| 2358 |
|
2358 |
|
| 2359 |
=head2 GetReserveGroupReserves |
2359 |
=head2 GetHoldGroupHolds |
| 2360 |
|
2360 |
|
| 2361 |
my @reserves = GetReserveGroupReserves($reserve_group_id); |
2361 |
my @reserves = GetHoldGroupHolds($hold_group_id); |
| 2362 |
|
2362 |
|
| 2363 |
Fetch all reserve from a reserve group. |
2363 |
Fetch all reserve from a hold group. |
| 2364 |
|
2364 |
|
| 2365 |
=cut |
2365 |
=cut |
| 2366 |
|
2366 |
|
| 2367 |
sub GetReserveGroupReserves { |
2367 |
sub GetHoldGroupHolds { |
| 2368 |
my ($reserve_group_id) = @_; |
2368 |
my ($hold_group_id) = @_; |
| 2369 |
|
2369 |
|
| 2370 |
my $dbh = C4::Context->dbh; |
2370 |
my $dbh = C4::Context->dbh; |
| 2371 |
|
2371 |
|
| 2372 |
my $reserves = $dbh->selectall_arrayref(q{ |
2372 |
my $reserves = $dbh->selectall_arrayref(q{ |
| 2373 |
SELECT * FROM reserves |
2373 |
SELECT * FROM reserves |
| 2374 |
WHERE reserve_group_id = ? |
2374 |
WHERE hold_group_id = ? |
| 2375 |
}, { Slice => {} }, $reserve_group_id); |
2375 |
}, { Slice => {} }, $hold_group_id); |
| 2376 |
|
2376 |
|
| 2377 |
return () unless defined $reserves; |
2377 |
return () unless defined $reserves; |
| 2378 |
|
2378 |
|