Lines 38-45
use Koha::Calendar;
Link Here
|
38 |
use Koha::CirculationRules; |
38 |
use Koha::CirculationRules; |
39 |
use Koha::Database; |
39 |
use Koha::Database; |
40 |
use Koha::DateUtils; |
40 |
use Koha::DateUtils; |
41 |
use Koha::Hold; |
|
|
42 |
use Koha::Holds; |
41 |
use Koha::Holds; |
|
|
42 |
use Koha::HoldGroups; |
43 |
use Koha::ItemTypes; |
43 |
use Koha::ItemTypes; |
44 |
use Koha::Items; |
44 |
use Koha::Items; |
45 |
use Koha::Libraries; |
45 |
use Koha::Libraries; |
Lines 140-149
BEGIN {
Link Here
|
140 |
IsItemOnHoldAndFound |
140 |
IsItemOnHoldAndFound |
141 |
|
141 |
|
142 |
GetMaxPatronHoldsForRecord |
142 |
GetMaxPatronHoldsForRecord |
143 |
|
|
|
144 |
&AddHoldGroup |
145 |
&DeleteHoldGroup |
146 |
&GetHoldGroupHolds |
147 |
); |
143 |
); |
148 |
@EXPORT_OK = qw( MergeHolds ); |
144 |
@EXPORT_OK = qw( MergeHolds ); |
149 |
} |
145 |
} |
Lines 603-650
sub CanReserveBeCanceledFromOpac {
Link Here
|
603 |
return $reserve->is_cancelable_from_opac; |
599 |
return $reserve->is_cancelable_from_opac; |
604 |
} |
600 |
} |
605 |
|
601 |
|
606 |
# TODO: Should be moved to Koha::Objects |
|
|
607 |
|
608 |
=head2 GetHoldCount |
609 |
|
610 |
$number = &GetHoldCount($borrowernumber); |
611 |
|
612 |
this function returns the number of reservation for a borrower given on input arg. |
613 |
|
614 |
=cut |
615 |
|
616 |
sub GetHoldCount { |
617 |
my ($borrowernumber) = @_; |
618 |
|
619 |
my $dbh = C4::Context->dbh; |
620 |
|
621 |
my $count = 0; #added by 15516 |
622 |
my $query = " |
623 |
SELECT COUNT(*) AS counter |
624 |
FROM reserves |
625 |
WHERE borrowernumber = ? |
626 |
AND hold_group_id is NULL"; #added by 15516 |
627 |
my $sth = $dbh->prepare($query); |
628 |
$sth->execute($borrowernumber); |
629 |
my $row = $sth->fetchrow_hashref; |
630 |
|
631 |
# section added by 15516 |
632 |
$count += $row->{counter}; |
633 |
|
634 |
$query = " |
635 |
SELECT COUNT(DISTINCT hold_group_id) AS counter |
636 |
FROM reserves |
637 |
WHERE borrowernumber = ? |
638 |
AND hold_group_id is not NULL |
639 |
"; |
640 |
$sth = $dbh->prepare($query); |
641 |
$sth->execute($borrowernumber); |
642 |
$row = $sth->fetchrow_hashref; |
643 |
$count += $row->{counter}; |
644 |
# end of section added by 15516 |
645 |
return $count; |
646 |
} |
647 |
|
648 |
=head2 GetOtherReserves |
602 |
=head2 GetOtherReserves |
649 |
|
603 |
|
650 |
($messages,$nextreservinfo)=$GetOtherReserves(itemnumber); |
604 |
($messages,$nextreservinfo)=$GetOtherReserves(itemnumber); |
Lines 1264-1270
sub ModReserveAffect {
Link Here
|
1264 |
WHERE hold_group_id = ? |
1218 |
WHERE hold_group_id = ? |
1265 |
AND reserve_id != ? |
1219 |
AND reserve_id != ? |
1266 |
}, undef, $hold->hold_group_id, $hold->reserve_id); |
1220 |
}, undef, $hold->hold_group_id, $hold->reserve_id); |
1267 |
DeleteHoldGroup($hold->hold_group_id); |
1221 |
Koha::HoldGroups->find($hold->hold_group_id)->delete; |
1268 |
} |
1222 |
} |
1269 |
|
1223 |
|
1270 |
_FixPriority( { biblionumber => $biblionumber } ); |
1224 |
_FixPriority( { biblionumber => $biblionumber } ); |
Lines 2325-2384
sub GetMaxPatronHoldsForRecord {
Link Here
|
2325 |
return $max; |
2279 |
return $max; |
2326 |
} |
2280 |
} |
2327 |
|
2281 |
|
2328 |
=head2 AddHoldGroup |
|
|
2329 |
|
2330 |
my $hold_group_id = AddHoldGroup(); |
2331 |
|
2332 |
Creates a new hold group and returns its ID |
2333 |
|
2334 |
=cut |
2335 |
|
2336 |
sub AddHoldGroup { |
2337 |
my $dbh = C4::Context->dbh; |
2338 |
|
2339 |
$dbh->do('INSERT INTO hold_group VALUES ()'); |
2340 |
return $dbh->last_insert_id(undef, undef, 'hold_group', undef); |
2341 |
} |
2342 |
|
2343 |
=head2 DeleteHoldGroup |
2344 |
|
2345 |
DeleteHoldGroup($hold_group_id); |
2346 |
|
2347 |
Delete a hold group. Reserves that belong to this group are not removed. |
2348 |
|
2349 |
=cut |
2350 |
|
2351 |
sub DeleteHoldGroup { |
2352 |
my ($hold_group_id) = @_; |
2353 |
|
2354 |
my $dbh = C4::Context->dbh; |
2355 |
my $query = 'DELETE FROM hold_group WHERE hold_group_id = ?'; |
2356 |
$dbh->do($query, undef, $hold_group_id); |
2357 |
} |
2358 |
|
2359 |
=head2 GetHoldGroupHolds |
2360 |
|
2361 |
my @reserves = GetHoldGroupHolds($hold_group_id); |
2362 |
|
2363 |
Fetch all reserve from a hold group. |
2364 |
|
2365 |
=cut |
2366 |
|
2367 |
sub GetHoldGroupHolds { |
2368 |
my ($hold_group_id) = @_; |
2369 |
|
2370 |
my $dbh = C4::Context->dbh; |
2371 |
|
2372 |
my $reserves = $dbh->selectall_arrayref(q{ |
2373 |
SELECT * FROM reserves |
2374 |
WHERE hold_group_id = ? |
2375 |
}, { Slice => {} }, $hold_group_id); |
2376 |
|
2377 |
return () unless defined $reserves; |
2378 |
|
2379 |
return @$reserves; |
2380 |
} |
2381 |
|
2382 |
=head1 AUTHOR |
2282 |
=head1 AUTHOR |
2383 |
|
2283 |
|
2384 |
Koha Development Team <http://koha-community.org/> |
2284 |
Koha Development Team <http://koha-community.org/> |