|
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 611-617
sub GetHoldCount {
Link Here
|
| 611 |
SELECT COUNT(*) AS counter |
611 |
SELECT COUNT(*) AS counter |
| 612 |
FROM reserves |
612 |
FROM reserves |
| 613 |
WHERE borrowernumber = ? |
613 |
WHERE borrowernumber = ? |
| 614 |
AND reserve_group_id is NULL"; #added by 15516 |
614 |
AND hold_group_id is NULL"; #added by 15516 |
| 615 |
my $sth = $dbh->prepare($query); |
615 |
my $sth = $dbh->prepare($query); |
| 616 |
$sth->execute($borrowernumber); |
616 |
$sth->execute($borrowernumber); |
| 617 |
my $row = $sth->fetchrow_hashref; |
617 |
my $row = $sth->fetchrow_hashref; |
|
Lines 620-629
sub GetHoldCount {
Link Here
|
| 620 |
$count += $row->{counter}; |
620 |
$count += $row->{counter}; |
| 621 |
|
621 |
|
| 622 |
$query = " |
622 |
$query = " |
| 623 |
SELECT COUNT(DISTINCT reserve_group_id) AS counter |
623 |
SELECT COUNT(DISTINCT hold_group_id) AS counter |
| 624 |
FROM reserves |
624 |
FROM reserves |
| 625 |
WHERE borrowernumber = ? |
625 |
WHERE borrowernumber = ? |
| 626 |
AND reserve_group_id is not NULL |
626 |
AND hold_group_id is not NULL |
| 627 |
"; |
627 |
"; |
| 628 |
$sth = $dbh->prepare($query); |
628 |
$sth = $dbh->prepare($query); |
| 629 |
$sth->execute($borrowernumber); |
629 |
$sth->execute($borrowernumber); |
|
Lines 1245-1258
sub ModReserveAffect {
Link Here
|
| 1245 |
}; |
1245 |
}; |
| 1246 |
} |
1246 |
} |
| 1247 |
|
1247 |
|
| 1248 |
if ($hold->reserve_group_id) { |
1248 |
if ($hold->hold_group_id) { |
| 1249 |
# Delete other reserves from same group |
1249 |
# Delete other reserves from same group |
| 1250 |
$dbh->do(q{ |
1250 |
$dbh->do(q{ |
| 1251 |
DELETE FROM reserves |
1251 |
DELETE FROM reserves |
| 1252 |
WHERE reserve_group_id = ? |
1252 |
WHERE hold_group_id = ? |
| 1253 |
AND reserve_id != ? |
1253 |
AND reserve_id != ? |
| 1254 |
}, undef, $hold->reserve_group_id, $hold->reserve_id); |
1254 |
}, undef, $hold->hold_group_id, $hold->reserve_id); |
| 1255 |
DeleteReserveGroup($hold->reserve_group_id); |
1255 |
DeleteHoldGroup($hold->hold_group_id); |
| 1256 |
} |
1256 |
} |
| 1257 |
|
1257 |
|
| 1258 |
_FixPriority( { biblionumber => $biblionumber } ); |
1258 |
_FixPriority( { biblionumber => $biblionumber } ); |
|
Lines 2357-2410
sub GetHoldRule {
Link Here
|
| 2357 |
return $rules; |
2357 |
return $rules; |
| 2358 |
} |
2358 |
} |
| 2359 |
|
2359 |
|
| 2360 |
=head2 AddReserveGroup |
2360 |
=head2 AddHoldGroup |
| 2361 |
|
2361 |
|
| 2362 |
my $reserve_group_id = AddReserveGroup(); |
2362 |
my $hold_group_id = AddHoldGroup(); |
| 2363 |
|
2363 |
|
| 2364 |
Creates a new reserve group and returns its ID |
2364 |
Creates a new hold group and returns its ID |
| 2365 |
|
2365 |
|
| 2366 |
=cut |
2366 |
=cut |
| 2367 |
|
2367 |
|
| 2368 |
sub AddReserveGroup { |
2368 |
sub AddHoldGroup { |
| 2369 |
my $dbh = C4::Context->dbh; |
2369 |
my $dbh = C4::Context->dbh; |
| 2370 |
|
2370 |
|
| 2371 |
$dbh->do('INSERT INTO reserve_group VALUES ()'); |
2371 |
$dbh->do('INSERT INTO hold_group VALUES ()'); |
| 2372 |
return $dbh->last_insert_id(undef, undef, 'reserve_group', undef); |
2372 |
return $dbh->last_insert_id(undef, undef, 'hold_group', undef); |
| 2373 |
} |
2373 |
} |
| 2374 |
|
2374 |
|
| 2375 |
=head2 DeleteReserveGroup |
2375 |
=head2 DeleteHoldGroup |
| 2376 |
|
2376 |
|
| 2377 |
DeleteReserveGroup($reserve_group_id); |
2377 |
DeleteHoldGroup($hold_group_id); |
| 2378 |
|
2378 |
|
| 2379 |
Delete a reserve group. Reserves that belong to this group are not removed. |
2379 |
Delete a hold group. Reserves that belong to this group are not removed. |
| 2380 |
|
2380 |
|
| 2381 |
=cut |
2381 |
=cut |
| 2382 |
|
2382 |
|
| 2383 |
sub DeleteReserveGroup { |
2383 |
sub DeleteHoldGroup { |
| 2384 |
my ($reserve_group_id) = @_; |
2384 |
my ($hold_group_id) = @_; |
| 2385 |
|
2385 |
|
| 2386 |
my $dbh = C4::Context->dbh; |
2386 |
my $dbh = C4::Context->dbh; |
| 2387 |
my $query = 'DELETE FROM reserve_group WHERE reserve_group_id = ?'; |
2387 |
my $query = 'DELETE FROM hold_group WHERE hold_group_id = ?'; |
| 2388 |
$dbh->do($query, undef, $reserve_group_id); |
2388 |
$dbh->do($query, undef, $hold_group_id); |
| 2389 |
} |
2389 |
} |
| 2390 |
|
2390 |
|
| 2391 |
=head2 GetReserveGroupReserves |
2391 |
=head2 GetHoldGroupHolds |
| 2392 |
|
2392 |
|
| 2393 |
my @reserves = GetReserveGroupReserves($reserve_group_id); |
2393 |
my @reserves = GetHoldGroupHolds($hold_group_id); |
| 2394 |
|
2394 |
|
| 2395 |
Fetch all reserve from a reserve group. |
2395 |
Fetch all reserve from a hold group. |
| 2396 |
|
2396 |
|
| 2397 |
=cut |
2397 |
=cut |
| 2398 |
|
2398 |
|
| 2399 |
sub GetReserveGroupReserves { |
2399 |
sub GetHoldGroupHolds { |
| 2400 |
my ($reserve_group_id) = @_; |
2400 |
my ($hold_group_id) = @_; |
| 2401 |
|
2401 |
|
| 2402 |
my $dbh = C4::Context->dbh; |
2402 |
my $dbh = C4::Context->dbh; |
| 2403 |
|
2403 |
|
| 2404 |
my $reserves = $dbh->selectall_arrayref(q{ |
2404 |
my $reserves = $dbh->selectall_arrayref(q{ |
| 2405 |
SELECT * FROM reserves |
2405 |
SELECT * FROM reserves |
| 2406 |
WHERE reserve_group_id = ? |
2406 |
WHERE hold_group_id = ? |
| 2407 |
}, { Slice => {} }, $reserve_group_id); |
2407 |
}, { Slice => {} }, $hold_group_id); |
| 2408 |
|
2408 |
|
| 2409 |
return () unless defined $reserves; |
2409 |
return () unless defined $reserves; |
| 2410 |
|
2410 |
|