Lines 25-31
use C4::Members::Messaging;
Link Here
|
25 |
use Koha::Database; |
25 |
use Koha::Database; |
26 |
use Koha::DateUtils; |
26 |
use Koha::DateUtils; |
27 |
|
27 |
|
28 |
use base qw(Koha::Object); |
28 |
use base qw(Koha::Object Koha::Object::Limit::Library); |
29 |
|
29 |
|
30 |
=head1 NAME |
30 |
=head1 NAME |
31 |
|
31 |
|
Lines 103-219
sub default_messaging {
Link Here
|
103 |
return \@messaging; |
103 |
return \@messaging; |
104 |
} |
104 |
} |
105 |
|
105 |
|
106 |
=head3 branch_limitations |
|
|
107 |
|
108 |
my $limitations = $category->branch_limitations(); |
109 |
|
110 |
$category->branch_limitations( \@branchcodes ); |
111 |
|
112 |
=cut |
113 |
|
114 |
sub branch_limitations { |
115 |
my ( $self, $branchcodes ) = @_; |
116 |
|
117 |
if ($branchcodes) { |
118 |
return $self->replace_branch_limitations($branchcodes); |
119 |
} |
120 |
else { |
121 |
return $self->get_branch_limitations(); |
122 |
} |
123 |
|
124 |
} |
125 |
|
126 |
=head3 get_branch_limitations |
127 |
|
128 |
my $limitations = $category->get_branch_limitations(); |
129 |
|
130 |
=cut |
131 |
|
132 |
sub get_branch_limitations { |
133 |
my ($self) = @_; |
134 |
|
135 |
my @branchcodes = |
136 |
$self->_catb_resultset->search( { categorycode => $self->categorycode } ) |
137 |
->get_column('branchcode')->all(); |
138 |
|
139 |
return \@branchcodes; |
140 |
} |
141 |
|
142 |
=head3 add_branch_limitation |
143 |
|
144 |
$category->add_branch_limitation( $branchcode ); |
145 |
|
146 |
=cut |
147 |
|
148 |
sub add_branch_limitation { |
149 |
my ( $self, $branchcode ) = @_; |
150 |
|
151 |
croak("No branchcode passed in!") unless $branchcode; |
152 |
|
153 |
my $limitation = $self->_catb_resultset->update_or_create( |
154 |
{ categorycode => $self->categorycode, branchcode => $branchcode } ); |
155 |
|
156 |
return $limitation ? 1 : undef; |
157 |
} |
158 |
|
159 |
=head3 del_branch_limitation |
160 |
|
161 |
$category->del_branch_limitation( $branchcode ); |
162 |
|
163 |
=cut |
164 |
|
165 |
sub del_branch_limitation { |
166 |
my ( $self, $branchcode ) = @_; |
167 |
|
168 |
croak("No branchcode passed in!") unless $branchcode; |
169 |
|
170 |
my $limitation = |
171 |
$self->_catb_resultset->find( |
172 |
{ categorycode => $self->categorycode, branchcode => $branchcode } ); |
173 |
|
174 |
unless ($limitation) { |
175 |
my $categorycode = $self->categorycode; |
176 |
carp( |
177 |
"No branch limit for branch $branchcode found for categorycode $categorycode to delete!" |
178 |
); |
179 |
return; |
180 |
} |
181 |
|
182 |
return $limitation->delete(); |
183 |
} |
184 |
|
185 |
=head3 replace_branch_limitations |
186 |
|
187 |
$category->replace_branch_limitations( \@branchcodes ); |
188 |
|
189 |
=cut |
190 |
|
191 |
sub replace_branch_limitations { |
192 |
my ( $self, $branchcodes ) = @_; |
193 |
|
194 |
$self->_catb_resultset->search( { categorycode => $self->categorycode } )->delete; |
195 |
|
196 |
my @return_values = |
197 |
map { $self->add_branch_limitation($_) } @$branchcodes; |
198 |
|
199 |
return \@return_values; |
200 |
} |
201 |
|
202 |
=head3 Koha::Objects->_catb_resultset |
203 |
|
204 |
Returns the internal resultset or creates it if undefined |
205 |
|
206 |
=cut |
207 |
|
208 |
sub _catb_resultset { |
209 |
my ($self) = @_; |
210 |
|
211 |
$self->{_catb_resultset} ||= |
212 |
Koha::Database->new->schema->resultset('CategoriesBranch'); |
213 |
|
214 |
return $self->{_catb_resultset}; |
215 |
} |
216 |
|
217 |
sub get_expiry_date { |
106 |
sub get_expiry_date { |
218 |
my ($self, $date ) = @_; |
107 |
my ($self, $date ) = @_; |
219 |
if ( $self->enrolmentperiod ) { |
108 |
if ( $self->enrolmentperiod ) { |
Lines 275-280
sub override_hidden_items {
Link Here
|
275 |
|
164 |
|
276 |
=head2 Internal methods |
165 |
=head2 Internal methods |
277 |
|
166 |
|
|
|
167 |
=head3 _library_limits |
168 |
|
169 |
configure library limits |
170 |
|
171 |
=cut |
172 |
|
173 |
sub _library_limits { |
174 |
return { |
175 |
class => "CategoriesBranch", |
176 |
id => "categorycode", |
177 |
library => "branchcode", |
178 |
}; |
179 |
} |
180 |
|
278 |
=head3 type |
181 |
=head3 type |
279 |
|
182 |
|
280 |
=cut |
183 |
=cut |