1 package Koha::ERM::Agreement;
3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
22 use base qw(Koha::Object);
24 use Koha::ERM::Agreement::Periods;
25 use Koha::ERM::Agreement::UserRoles;
29 Koha::ERM::Agreement - Koha ErmAgreement Object class
39 Returns the periods for this agreement
44 my ( $self, $periods ) = @_;
47 my $schema = $self->_result->result_source->schema;
50 $self->periods->delete;
52 for my $period (@$periods) {
53 $self->_result->add_to_erm_agreement_periods($period);
59 my $periods_rs = $self->_result->erm_agreement_periods;
60 return Koha::ERM::Agreement::Periods->_new_from_dbic($periods_rs);
65 Returns the user roles for this agreement
70 my ( $self, $user_roles ) = @_;
73 my $schema = $self->_result->result_source->schema;
76 $self->user_roles->delete;
78 for my $user_role (@$user_roles) {
79 $self->_result->add_to_erm_agreement_user_roles($user_role);
84 my $user_roles_rs = $self->_result->erm_agreement_user_roles;
85 return Koha::ERM::Agreement::UserRoles->_new_from_dbic($user_roles_rs);
88 =head2 Internal methods
95 return 'ErmAgreement';