|
Lines 148-156
BEGIN {
Link Here
|
| 148 |
|
148 |
|
| 149 |
GetMaxPatronHoldsForRecord |
149 |
GetMaxPatronHoldsForRecord |
| 150 |
|
150 |
|
| 151 |
&AddReserveGroup |
151 |
&AddHoldGroup |
| 152 |
&DeleteReserveGroup |
152 |
&DeleteHoldGroup |
| 153 |
&GetReserveGroupReserves |
153 |
&GetHoldGroupHolds |
| 154 |
); |
154 |
); |
| 155 |
@EXPORT_OK = qw( MergeHolds ); |
155 |
@EXPORT_OK = qw( MergeHolds ); |
| 156 |
} |
156 |
} |
|
Lines 176-182
sub AddReserve {
Link Here
|
| 176 |
$branch, $borrowernumber, $biblionumber, $bibitems, |
176 |
$branch, $borrowernumber, $biblionumber, $bibitems, |
| 177 |
$priority, $resdate, $expdate, $notes, |
177 |
$priority, $resdate, $expdate, $notes, |
| 178 |
$title, $checkitem, $found, $itemtype, |
178 |
$title, $checkitem, $found, $itemtype, |
| 179 |
$reserve_group_id |
179 |
$hold_group_id |
| 180 |
) = @_; |
180 |
) = @_; |
| 181 |
|
181 |
|
| 182 |
my $dbh = C4::Context->dbh; |
182 |
my $dbh = C4::Context->dbh; |
|
Lines 216-222
sub AddReserve {
Link Here
|
| 216 |
waitingdate => $waitingdate, |
216 |
waitingdate => $waitingdate, |
| 217 |
expirationdate => $expdate, |
217 |
expirationdate => $expdate, |
| 218 |
itemtype => $itemtype, |
218 |
itemtype => $itemtype, |
| 219 |
reserve_group_id => $reserve_group_id, |
219 |
hold_group_id => $hold_group_id, |
| 220 |
} |
220 |
} |
| 221 |
)->store(); |
221 |
)->store(); |
| 222 |
|
222 |
|
|
Lines 640-646
sub GetReserveCount {
Link Here
|
| 640 |
SELECT COUNT(*) AS counter |
640 |
SELECT COUNT(*) AS counter |
| 641 |
FROM reserves |
641 |
FROM reserves |
| 642 |
WHERE borrowernumber = ? |
642 |
WHERE borrowernumber = ? |
| 643 |
AND reserve_group_id is NULL |
643 |
AND hold_group_id is NULL |
| 644 |
"; |
644 |
"; |
| 645 |
my $sth = $dbh->prepare($query); |
645 |
my $sth = $dbh->prepare($query); |
| 646 |
$sth->execute($borrowernumber); |
646 |
$sth->execute($borrowernumber); |
|
Lines 648-657
sub GetReserveCount {
Link Here
|
| 648 |
$count += $row->{counter}; |
648 |
$count += $row->{counter}; |
| 649 |
|
649 |
|
| 650 |
$query = " |
650 |
$query = " |
| 651 |
SELECT COUNT(DISTINCT reserve_group_id) AS counter |
651 |
SELECT COUNT(DISTINCT hold_group_id) AS counter |
| 652 |
FROM reserves |
652 |
FROM reserves |
| 653 |
WHERE borrowernumber = ? |
653 |
WHERE borrowernumber = ? |
| 654 |
AND reserve_group_id is not NULL |
654 |
AND hold_group_id is not NULL |
| 655 |
"; |
655 |
"; |
| 656 |
$sth = $dbh->prepare($query); |
656 |
$sth = $dbh->prepare($query); |
| 657 |
$sth->execute($borrowernumber); |
657 |
$sth->execute($borrowernumber); |
|
Lines 1373-1386
sub ModReserveAffect {
Link Here
|
| 1373 |
} |
1373 |
} |
| 1374 |
$hold->store(); |
1374 |
$hold->store(); |
| 1375 |
|
1375 |
|
| 1376 |
if ($hold->reserve_group_id) { |
1376 |
if ($hold->hold_group_id) { |
| 1377 |
# Delete other reserves from same group |
1377 |
# Delete other reserves from same group |
| 1378 |
$dbh->do(q{ |
1378 |
$dbh->do(q{ |
| 1379 |
DELETE FROM reserves |
1379 |
DELETE FROM reserves |
| 1380 |
WHERE reserve_group_id = ? |
1380 |
WHERE hold_group_id = ? |
| 1381 |
AND reserve_id != ? |
1381 |
AND reserve_id != ? |
| 1382 |
}, undef, $hold->reserve_group_id, $hold->reserve_id); |
1382 |
}, undef, $hold->hold_group_id, $hold->reserve_id); |
| 1383 |
DeleteReserveGroup($hold->reserve_group_id); |
1383 |
DeleteReserveGroup($hold->hold_group_id); |
| 1384 |
} |
1384 |
} |
| 1385 |
|
1385 |
|
| 1386 |
_koha_notify_reserve( $itemnumber, $borrowernumber, $biblionumber ) |
1386 |
_koha_notify_reserve( $itemnumber, $borrowernumber, $biblionumber ) |
|
Lines 1465-1471
sub GetReserveInfo {
Link Here
|
| 1465 |
reminderdate, |
1465 |
reminderdate, |
| 1466 |
priority, |
1466 |
priority, |
| 1467 |
found, |
1467 |
found, |
| 1468 |
reserve_group_id, |
1468 |
hold_group_id, |
| 1469 |
firstname, |
1469 |
firstname, |
| 1470 |
surname, |
1470 |
surname, |
| 1471 |
phone, |
1471 |
phone, |
|
Lines 2580-2633
sub GetHoldRule {
Link Here
|
| 2580 |
return $sth->fetchrow_hashref(); |
2580 |
return $sth->fetchrow_hashref(); |
| 2581 |
} |
2581 |
} |
| 2582 |
|
2582 |
|
| 2583 |
=head2 AddReserveGroup |
2583 |
=head2 AddHoldGroup |
| 2584 |
|
2584 |
|
| 2585 |
my $reserve_group_id = AddReserveGroup(); |
2585 |
my $hold_group_id = AddHoldGroup(); |
| 2586 |
|
2586 |
|
| 2587 |
Creates a new reserve group and returns its ID |
2587 |
Creates a new hold group and returns its ID |
| 2588 |
|
2588 |
|
| 2589 |
=cut |
2589 |
=cut |
| 2590 |
|
2590 |
|
| 2591 |
sub AddReserveGroup { |
2591 |
sub AddHoldGroup { |
| 2592 |
my $dbh = C4::Context->dbh; |
2592 |
my $dbh = C4::Context->dbh; |
| 2593 |
|
2593 |
|
| 2594 |
$dbh->do('INSERT INTO reserve_group VALUES ()'); |
2594 |
$dbh->do('INSERT INTO hold_group VALUES ()'); |
| 2595 |
return $dbh->last_insert_id(undef, undef, 'reserve_group', undef); |
2595 |
return $dbh->last_insert_id(undef, undef, 'hold_group', undef); |
| 2596 |
} |
2596 |
} |
| 2597 |
|
2597 |
|
| 2598 |
=head2 DeleteReserveGroup |
2598 |
=head2 DeleteHoldGroup |
| 2599 |
|
2599 |
|
| 2600 |
DeleteReserveGroup($reserve_group_id); |
2600 |
DeleteHoldGroup($hold_group_id); |
| 2601 |
|
2601 |
|
| 2602 |
Delete a reserve group. Reserves that belong to this group are not removed. |
2602 |
Delete a hold group. Holds that belong to this group are not removed. |
| 2603 |
|
2603 |
|
| 2604 |
=cut |
2604 |
=cut |
| 2605 |
|
2605 |
|
| 2606 |
sub DeleteReserveGroup { |
2606 |
sub DeleteHoldGroup { |
| 2607 |
my ($reserve_group_id) = @_; |
2607 |
my ($hold_group_id) = @_; |
| 2608 |
|
2608 |
|
| 2609 |
my $dbh = C4::Context->dbh; |
2609 |
my $dbh = C4::Context->dbh; |
| 2610 |
my $query = 'DELETE FROM reserve_group WHERE reserve_group_id = ?'; |
2610 |
my $query = 'DELETE FROM hold_group WHERE hold_group_id = ?'; |
| 2611 |
$dbh->do($query, undef, $reserve_group_id); |
2611 |
$dbh->do($query, undef, $hold_group_id); |
| 2612 |
} |
2612 |
} |
| 2613 |
|
2613 |
|
| 2614 |
=head2 GetReserveGroupReserves |
2614 |
=head2 GetHoldGroupHolds |
| 2615 |
|
2615 |
|
| 2616 |
my @reserves = GetReserveGroupReserves($reserve_group_id); |
2616 |
my @holds = GetHoldGroupHolds($hold_group_id); |
| 2617 |
|
2617 |
|
| 2618 |
Fetch all reserve from a reserve group. |
2618 |
Fetch all holds from a hold group. |
| 2619 |
|
2619 |
|
| 2620 |
=cut |
2620 |
=cut |
| 2621 |
|
2621 |
|
| 2622 |
sub GetReserveGroupReserves { |
2622 |
sub GetHoldGroupHolds { |
| 2623 |
my ($reserve_group_id) = @_; |
2623 |
my ($hold_group_id) = @_; |
| 2624 |
|
2624 |
|
| 2625 |
my $dbh = C4::Context->dbh; |
2625 |
my $dbh = C4::Context->dbh; |
| 2626 |
|
2626 |
|
| 2627 |
my $reserves = $dbh->selectall_arrayref(q{ |
2627 |
my $reserves = $dbh->selectall_arrayref(q{ |
| 2628 |
SELECT * FROM reserves |
2628 |
SELECT * FROM reserves |
| 2629 |
WHERE reserve_group_id = ? |
2629 |
WHERE hold_group_id = ? |
| 2630 |
}, { Slice => {} }, $reserve_group_id); |
2630 |
}, { Slice => {} }, $hold_group_id); |
| 2631 |
|
2631 |
|
| 2632 |
return () unless defined $reserves; |
2632 |
return () unless defined $reserves; |
| 2633 |
|
2633 |
|