Lines 54-70
Class (static) method that returns a new Koha::Club::Hold instance
Link Here
|
54 |
sub add { |
54 |
sub add { |
55 |
my ( $params ) = @_; |
55 |
my ( $params ) = @_; |
56 |
|
56 |
|
57 |
throw Koha::Exceptions::ClubHold unless $params->{club_id} && $params->{biblio_id}; |
57 |
Koha::Exceptions::ClubHold->throw() |
|
|
58 |
unless $params->{club_id} && $params->{biblio_id}; |
59 |
|
58 |
my $club = Koha::Clubs->find($params->{club_id}); |
60 |
my $club = Koha::Clubs->find($params->{club_id}); |
59 |
my @enrollments = $club->club_enrollments->as_list; |
61 |
my @enrollments = $club->club_enrollments->as_list; |
60 |
throw Koha::Exceptions::ClubHold::NoPatrons() unless scalar @enrollments; |
62 |
|
|
|
63 |
Koha::Exceptions::ClubHold::NoPatrons->throw() |
64 |
unless scalar @enrollments; |
61 |
|
65 |
|
62 |
my $biblio = Koha::Biblios->find($params->{biblio_id}); |
66 |
my $biblio = Koha::Biblios->find($params->{biblio_id}); |
63 |
|
67 |
|
64 |
my $club_params = { |
68 |
my $club_params = { |
65 |
club_id => $params->{club_id}, |
69 |
club_id => $params->{club_id}, |
66 |
biblio_id => $params->{biblio_id}, |
70 |
biblio_id => $params->{biblio_id}, |
67 |
item_id => $params->{item_id} |
71 |
item_id => $params->{item_id} |
68 |
}; |
72 |
}; |
69 |
|
73 |
|
70 |
my $club_hold = Koha::Club::Hold->new($club_params)->store(); |
74 |
my $club_hold = Koha::Club::Hold->new($club_params)->store(); |
71 |
- |
|
|