Bug 22650: Prevent multiple holds on individual items
[koha.git] / Koha / Patron / HouseboundVisits.pm
blob5a31f6066fd3735e0f1633644794f1555dea74e8
1 package Koha::Patron::HouseboundVisits;
3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it under the
6 # terms of the GNU General Public License as published by the Free Software
7 # Foundation; either version 3 of the License, or (at your option) any later
8 # version.
10 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License along
15 # with Koha; if not, write to the Free Software Foundation, Inc.,
16 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 use Modern::Perl;
20 use Koha::Database;
21 use Koha::Patron::HouseboundVisit;
23 use base qw(Koha::Objects);
25 =head1 NAME
27 Koha::Patron::HouseboundVisits - Koha Patron HouseboundVisits Object class
29 =head1 SYNOPSIS
31 HouseboundVisits class used primarily by members/housebound.pl.
33 =head1 DESCRIPTION
35 Standard Koha::Objects definitions, and additional methods.
37 =head1 API
39 =head2 Class Methods
41 =cut
43 =head3 special_search;
45 my @houseboundVisits = Koha::HouseboundVisits->special_search($params, $attributes);
47 Perform a search for housebound visits. This method overrides standard search
48 to prefetch deliverers and choosers as we always need them anyway.
50 If $attributes contains a prefetch entry, we defer to it, otherwise we add the
51 prefetch attribute and also augment $params with explicit 'me.' prefixes.
53 This is intended to make search behave as most people would expect it to
54 behave.
56 Should the user want to do complicated searches involving joins, without
57 specifying their own prefetch, the naive 'me.' augmentation will break in
58 hilarious ways. In this case the user should supply their own prefetch
59 clause.
61 =cut
63 sub special_search {
64 my ( $self, $params, $attributes ) = @_;
65 unless (exists $attributes->{prefetch}) {
66 # No explicit prefetch has been passed in -> automatic optimisation.
67 $attributes->{prefetch} = [
68 'chooser_brwnumber', 'deliverer_brwnumber'
70 # So we must ensure our $params use the 'me.' prefix.
71 my $oldparams = $params;
72 $params = {};
73 while (my ($k, $v) = each %{$oldparams}) {
74 if ($k =~ /^me\..*/) {
75 $params->{$k} = $v;
76 } else {
77 $params->{"me." . $k} = $v;
81 $self->SUPER::search($params, $attributes);
84 =head3 _type
86 =cut
88 sub _type {
89 return 'HouseboundVisit';
92 sub object_class {
93 return 'Koha::Patron::HouseboundVisit';
98 =head1 AUTHOR
100 Alex Sassmannshausen <alex.sassmannshausen@ptfs-europe.com>
102 =cut