|
Lines 138-146
BEGIN {
Link Here
|
| 138 |
|
138 |
|
| 139 |
GetMaxPatronHoldsForRecord |
139 |
GetMaxPatronHoldsForRecord |
| 140 |
|
140 |
|
| 141 |
&AddReserveGroup |
141 |
&AddHoldGroup |
| 142 |
&DeleteReserveGroup |
142 |
&DeleteHoldGroup |
| 143 |
&GetReserveGroupReserves |
143 |
&GetHoldGroupHolds |
| 144 |
); |
144 |
); |
| 145 |
@EXPORT_OK = qw( MergeHolds ); |
145 |
@EXPORT_OK = qw( MergeHolds ); |
| 146 |
} |
146 |
} |
|
Lines 167-173
sub AddReserve {
Link Here
|
| 167 |
$branch, $borrowernumber, $biblionumber, $bibitems, |
167 |
$branch, $borrowernumber, $biblionumber, $bibitems, |
| 168 |
$priority, $resdate, $expdate, $notes, |
168 |
$priority, $resdate, $expdate, $notes, |
| 169 |
$title, $checkitem, $found, $itemtype, |
169 |
$title, $checkitem, $found, $itemtype, |
| 170 |
$reserve_group_id |
170 |
$hold_group_id |
| 171 |
) = @_; |
171 |
) = @_; |
| 172 |
|
172 |
|
| 173 |
$resdate = output_pref( { str => dt_from_string( $resdate ), dateonly => 1, dateformat => 'iso' }) |
173 |
$resdate = output_pref( { str => dt_from_string( $resdate ), dateonly => 1, dateformat => 'iso' }) |
|
Lines 216-222
sub AddReserve {
Link Here
|
| 216 |
expirationdate => $expdate, |
216 |
expirationdate => $expdate, |
| 217 |
itemtype => $itemtype, |
217 |
itemtype => $itemtype, |
| 218 |
item_level_hold => $checkitem ? 1 : 0, |
218 |
item_level_hold => $checkitem ? 1 : 0, |
| 219 |
reserve_group_id => $reserve_group_id, |
219 |
hold_group_id => $hold_group_id, |
| 220 |
} |
220 |
} |
| 221 |
)->store(); |
221 |
)->store(); |
| 222 |
$hold->set_waiting() if $found eq 'W'; |
222 |
$hold->set_waiting() if $found eq 'W'; |
|
Lines 535-541
sub GetReserveCount {
Link Here
|
| 535 |
SELECT COUNT(*) AS counter |
535 |
SELECT COUNT(*) AS counter |
| 536 |
FROM reserves |
536 |
FROM reserves |
| 537 |
WHERE borrowernumber = ? |
537 |
WHERE borrowernumber = ? |
| 538 |
AND reserve_group_id is NULL"; #added by 15516 |
538 |
AND hold_group_id is NULL"; #added by 15516 |
| 539 |
my $sth = $dbh->prepare($query); |
539 |
my $sth = $dbh->prepare($query); |
| 540 |
$sth->execute($borrowernumber); |
540 |
$sth->execute($borrowernumber); |
| 541 |
my $row = $sth->fetchrow_hashref; |
541 |
my $row = $sth->fetchrow_hashref; |
|
Lines 544-553
sub GetReserveCount {
Link Here
|
| 544 |
$count += $row->{counter}; |
544 |
$count += $row->{counter}; |
| 545 |
|
545 |
|
| 546 |
$query = " |
546 |
$query = " |
| 547 |
SELECT COUNT(DISTINCT reserve_group_id) AS counter |
547 |
SELECT COUNT(DISTINCT hold_group_id) AS counter |
| 548 |
FROM reserves |
548 |
FROM reserves |
| 549 |
WHERE borrowernumber = ? |
549 |
WHERE borrowernumber = ? |
| 550 |
AND reserve_group_id is not NULL |
550 |
AND hold_group_id is not NULL |
| 551 |
"; |
551 |
"; |
| 552 |
$sth = $dbh->prepare($query); |
552 |
$sth = $dbh->prepare($query); |
| 553 |
$sth->execute($borrowernumber); |
553 |
$sth->execute($borrowernumber); |
|
Lines 1122-1135
sub ModReserveAffect {
Link Here
|
| 1122 |
$hold->itemnumber($itemnumber); |
1122 |
$hold->itemnumber($itemnumber); |
| 1123 |
$hold->set_waiting($transferToDo); |
1123 |
$hold->set_waiting($transferToDo); |
| 1124 |
|
1124 |
|
| 1125 |
if ($hold->reserve_group_id) { |
1125 |
if ($hold->hold_group_id) { |
| 1126 |
# Delete other reserves from same group |
1126 |
# Delete other reserves from same group |
| 1127 |
$dbh->do(q{ |
1127 |
$dbh->do(q{ |
| 1128 |
DELETE FROM reserves |
1128 |
DELETE FROM reserves |
| 1129 |
WHERE reserve_group_id = ? |
1129 |
WHERE hold_group_id = ? |
| 1130 |
AND reserve_id != ? |
1130 |
AND reserve_id != ? |
| 1131 |
}, undef, $hold->reserve_group_id, $hold->reserve_id); |
1131 |
}, undef, $hold->hold_group_id, $hold->reserve_id); |
| 1132 |
DeleteReserveGroup($hold->reserve_group_id); |
1132 |
DeleteHoldGroup($hold->hold_group_id); |
| 1133 |
} |
1133 |
} |
| 1134 |
|
1134 |
|
| 1135 |
_koha_notify_reserve( $hold->reserve_id ) |
1135 |
_koha_notify_reserve( $hold->reserve_id ) |
|
Lines 2231-2284
sub GetHoldRule {
Link Here
|
| 2231 |
return $sth->fetchrow_hashref(); |
2231 |
return $sth->fetchrow_hashref(); |
| 2232 |
} |
2232 |
} |
| 2233 |
|
2233 |
|
| 2234 |
=head2 AddReserveGroup |
2234 |
=head2 AddHoldGroup |
| 2235 |
|
2235 |
|
| 2236 |
my $reserve_group_id = AddReserveGroup(); |
2236 |
my $hold_group_id = AddHoldGroup(); |
| 2237 |
|
2237 |
|
| 2238 |
Creates a new reserve group and returns its ID |
2238 |
Creates a new hold group and returns its ID |
| 2239 |
|
2239 |
|
| 2240 |
=cut |
2240 |
=cut |
| 2241 |
|
2241 |
|
| 2242 |
sub AddReserveGroup { |
2242 |
sub AddHoldGroup { |
| 2243 |
my $dbh = C4::Context->dbh; |
2243 |
my $dbh = C4::Context->dbh; |
| 2244 |
|
2244 |
|
| 2245 |
$dbh->do('INSERT INTO reserve_group VALUES ()'); |
2245 |
$dbh->do('INSERT INTO hold_group VALUES ()'); |
| 2246 |
return $dbh->last_insert_id(undef, undef, 'reserve_group', undef); |
2246 |
return $dbh->last_insert_id(undef, undef, 'hold_group', undef); |
| 2247 |
} |
2247 |
} |
| 2248 |
|
2248 |
|
| 2249 |
=head2 DeleteReserveGroup |
2249 |
=head2 DeleteHoldGroup |
| 2250 |
|
2250 |
|
| 2251 |
DeleteReserveGroup($reserve_group_id); |
2251 |
DeleteHoldGroup($hold_group_id); |
| 2252 |
|
2252 |
|
| 2253 |
Delete a reserve group. Reserves that belong to this group are not removed. |
2253 |
Delete a hold group. Reserves that belong to this group are not removed. |
| 2254 |
|
2254 |
|
| 2255 |
=cut |
2255 |
=cut |
| 2256 |
|
2256 |
|
| 2257 |
sub DeleteReserveGroup { |
2257 |
sub DeleteHoldGroup { |
| 2258 |
my ($reserve_group_id) = @_; |
2258 |
my ($hold_group_id) = @_; |
| 2259 |
|
2259 |
|
| 2260 |
my $dbh = C4::Context->dbh; |
2260 |
my $dbh = C4::Context->dbh; |
| 2261 |
my $query = 'DELETE FROM reserve_group WHERE reserve_group_id = ?'; |
2261 |
my $query = 'DELETE FROM hold_group WHERE hold_group_id = ?'; |
| 2262 |
$dbh->do($query, undef, $reserve_group_id); |
2262 |
$dbh->do($query, undef, $hold_group_id); |
| 2263 |
} |
2263 |
} |
| 2264 |
|
2264 |
|
| 2265 |
=head2 GetReserveGroupReserves |
2265 |
=head2 GetHoldGroupHolds |
| 2266 |
|
2266 |
|
| 2267 |
my @reserves = GetReserveGroupReserves($reserve_group_id); |
2267 |
my @reserves = GetHoldGroupHolds($hold_group_id); |
| 2268 |
|
2268 |
|
| 2269 |
Fetch all reserve from a reserve group. |
2269 |
Fetch all reserve from a hold group. |
| 2270 |
|
2270 |
|
| 2271 |
=cut |
2271 |
=cut |
| 2272 |
|
2272 |
|
| 2273 |
sub GetReserveGroupReserves { |
2273 |
sub GetHoldGroupHolds { |
| 2274 |
my ($reserve_group_id) = @_; |
2274 |
my ($hold_group_id) = @_; |
| 2275 |
|
2275 |
|
| 2276 |
my $dbh = C4::Context->dbh; |
2276 |
my $dbh = C4::Context->dbh; |
| 2277 |
|
2277 |
|
| 2278 |
my $reserves = $dbh->selectall_arrayref(q{ |
2278 |
my $reserves = $dbh->selectall_arrayref(q{ |
| 2279 |
SELECT * FROM reserves |
2279 |
SELECT * FROM reserves |
| 2280 |
WHERE reserve_group_id = ? |
2280 |
WHERE hold_group_id = ? |
| 2281 |
}, { Slice => {} }, $reserve_group_id); |
2281 |
}, { Slice => {} }, $hold_group_id); |
| 2282 |
|
2282 |
|
| 2283 |
return () unless defined $reserves; |
2283 |
return () unless defined $reserves; |
| 2284 |
|
2284 |
|