Lines 120-126
sub new {
Link Here
|
120 |
$self->{'staff_searchable'} = 0; |
120 |
$self->{'staff_searchable'} = 0; |
121 |
$self->{'display_checkout'} = 0; |
121 |
$self->{'display_checkout'} = 0; |
122 |
$self->{'authorised_value_category'} = ''; |
122 |
$self->{'authorised_value_category'} = ''; |
123 |
$self->{'category_type'} = ''; |
123 |
$self->{'category_code'} = ''; |
|
|
124 |
$self->{'category_description'} = ''; |
124 |
$self->{'class'} = ''; |
125 |
$self->{'class'} = ''; |
125 |
|
126 |
|
126 |
bless $self, $class; |
127 |
bless $self, $class; |
Lines 142-152
sub fetch {
Link Here
|
142 |
my $self = {}; |
143 |
my $self = {}; |
143 |
my $dbh = C4::Context->dbh(); |
144 |
my $dbh = C4::Context->dbh(); |
144 |
|
145 |
|
145 |
my $sth = $dbh->prepare_cached("SELECT * FROM borrower_attribute_types WHERE code = ?"); |
146 |
my $sth = $dbh->prepare_cached(" |
|
|
147 |
SELECT borrower_attribute_types.*, categories.description AS category_description |
148 |
FROM borrower_attribute_types |
149 |
LEFT JOIN categories ON borrower_attribute_types.category_code=categories.categorycode |
150 |
WHERE code =?"); |
146 |
$sth->execute($code); |
151 |
$sth->execute($code); |
147 |
my $row = $sth->fetchrow_hashref; |
152 |
my $row = $sth->fetchrow_hashref; |
148 |
$sth->finish(); |
153 |
$sth->finish(); |
149 |
return undef unless defined $row; |
154 |
return undef unless defined $row; |
150 |
|
155 |
|
151 |
$self->{'code'} = $row->{'code'}; |
156 |
$self->{'code'} = $row->{'code'}; |
152 |
$self->{'description'} = $row->{'description'}; |
157 |
$self->{'description'} = $row->{'description'}; |
Lines 157-163
sub fetch {
Link Here
|
157 |
$self->{'staff_searchable'} = $row->{'staff_searchable'}; |
162 |
$self->{'staff_searchable'} = $row->{'staff_searchable'}; |
158 |
$self->{'display_checkout'} = $row->{'display_checkout'}; |
163 |
$self->{'display_checkout'} = $row->{'display_checkout'}; |
159 |
$self->{'authorised_value_category'} = $row->{'authorised_value_category'}; |
164 |
$self->{'authorised_value_category'} = $row->{'authorised_value_category'}; |
160 |
$self->{'category_type'} = $row->{'category_type'}; |
165 |
$self->{'category_code'} = $row->{'category_code'}; |
|
|
166 |
$self->{'category_description'} = $row->{'category_description'}; |
161 |
$self->{'class'} = $row->{'class'}; |
167 |
$self->{'class'} = $row->{'class'}; |
162 |
|
168 |
|
163 |
bless $self, $class; |
169 |
bless $self, $class; |
Lines 190-202
sub store {
Link Here
|
190 |
staff_searchable = ?, |
196 |
staff_searchable = ?, |
191 |
authorised_value_category = ?, |
197 |
authorised_value_category = ?, |
192 |
display_checkout = ?, |
198 |
display_checkout = ?, |
193 |
category_type = ?, |
199 |
category_code = ?, |
194 |
class = ? |
200 |
class = ? |
195 |
WHERE code = ?"); |
201 |
WHERE code = ?"); |
196 |
} else { |
202 |
} else { |
197 |
$sth = $dbh->prepare_cached("INSERT INTO borrower_attribute_types |
203 |
$sth = $dbh->prepare_cached("INSERT INTO borrower_attribute_types |
198 |
(description, repeatable, unique_id, opac_display, password_allowed, |
204 |
(description, repeatable, unique_id, opac_display, password_allowed, |
199 |
staff_searchable, authorised_value_category, display_checkout, category_type, class, code) |
205 |
staff_searchable, authorised_value_category, display_checkout, category_code, class, code) |
200 |
VALUES (?, ?, ?, ?, ?, |
206 |
VALUES (?, ?, ?, ?, ?, |
201 |
?, ?, ?, ?, ?, ?)"); |
207 |
?, ?, ?, ?, ?, ?)"); |
202 |
} |
208 |
} |
Lines 208-214
sub store {
Link Here
|
208 |
$sth->bind_param(6, $self->{'staff_searchable'}); |
214 |
$sth->bind_param(6, $self->{'staff_searchable'}); |
209 |
$sth->bind_param(7, $self->{'authorised_value_category'}); |
215 |
$sth->bind_param(7, $self->{'authorised_value_category'}); |
210 |
$sth->bind_param(8, $self->{'display_checkout'}); |
216 |
$sth->bind_param(8, $self->{'display_checkout'}); |
211 |
$sth->bind_param(9, $self->{'category_type'}); |
217 |
$sth->bind_param(9, $self->{'category_code'} || undef); |
212 |
$sth->bind_param(10, $self->{'class'}); |
218 |
$sth->bind_param(10, $self->{'class'}); |
213 |
$sth->bind_param(11, $self->{'code'}); |
219 |
$sth->bind_param(11, $self->{'code'}); |
214 |
$sth->execute; |
220 |
$sth->execute; |
Lines 349-360
sub authorised_value_category {
Link Here
|
349 |
@_ ? $self->{'authorised_value_category'} = shift : $self->{'authorised_value_category'}; |
355 |
@_ ? $self->{'authorised_value_category'} = shift : $self->{'authorised_value_category'}; |
350 |
} |
356 |
} |
351 |
|
357 |
|
352 |
=head2 category_type |
358 |
=head2 category_code |
353 |
|
359 |
|
354 |
=over 4 |
360 |
=over 4 |
355 |
|
361 |
|
356 |
my $category_type = $attr_type->category_type(); |
362 |
my $category_code = $attr_type->category_code(); |
357 |
$attr_type->category_type($category_type); |
363 |
$attr_type->category_code($category_code); |
358 |
|
364 |
|
359 |
=back |
365 |
=back |
360 |
|
366 |
|
Lines 362-377
Accessor.
Link Here
|
362 |
|
368 |
|
363 |
=cut |
369 |
=cut |
364 |
|
370 |
|
365 |
sub category_type { |
371 |
sub category_code { |
366 |
my $self = shift; |
372 |
my $self = shift; |
367 |
@_ ? $self->{'category_type'} = shift : $self->{'category_type'}; |
373 |
@_ ? $self->{'category_code'} = shift : $self->{'category_code'}; |
|
|
374 |
} |
375 |
|
376 |
=head2 category_description |
377 |
|
378 |
=over 4 |
379 |
|
380 |
my $category_description = $attr_type->category_description(); |
381 |
$attr_type->category_description($category_description); |
382 |
|
383 |
=back |
384 |
|
385 |
Accessor. |
386 |
|
387 |
=cut |
388 |
|
389 |
sub category_description { |
390 |
my $self = shift; |
391 |
@_ ? $self->{'category_description'} = shift : $self->{'category_description'}; |
368 |
} |
392 |
} |
369 |
|
393 |
|
370 |
=head2 class |
394 |
=head2 class |
371 |
|
395 |
|
372 |
=over 4 |
396 |
=over 4 |
373 |
|
397 |
|
374 |
my $category_type = $attr_type->class(); |
398 |
my $class = $attr_type->class(); |
375 |
$attr_type->class($class); |
399 |
$attr_type->class($class); |
376 |
|
400 |
|
377 |
=back |
401 |
=back |