# This file is part of Koha.
#
-# Koha is free software; you can redistribute it and/or modify it under the
-# terms of the GNU General Public License as published by the Free Software
-# Foundation; either version 3 of the License, or (at your option) any later
-# version.
+# Koha is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
#
-# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+# Koha is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
#
-# You should have received a copy of the GNU General Public License along
-# with Koha; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
use Koha::Database;
use Koha::Exceptions::Patron::Attribute;
use Koha::Patron::Attribute::Types;
+use Koha::AuthorisedValues;
use base qw(Koha::Object);
return Koha::Patron::Attribute::Types->find( $self->code )->opac_editable;
}
+=head3 display_checkout
+
+ my $attribute = Koha::Patron::Attribute->new({ code => 'a_code', ... });
+ if ( $attribute->display_checkout ) { ... }
+
+=cut
+
+sub display_checkout {
+
+ my $self = shift;
+
+ return $self->type->display_checkout;
+}
+
+=head3 value_description
+
+ my $description = $attribute->value_description
+
+ Return authorised value description or free text based on attribute type settings
+
+=cut
+
+sub value_description {
+
+ my $self = shift;
+
+ if ( $self->type->authorised_value_category ) {
+ my $av = Koha::AuthorisedValues->search({
+ category => $self->type->authorised_value_category,
+ authorised_value => $self->attribute,
+ });
+ return $av->next->lib if $av->count;
+ }
+ return $self->attribute;
+}
+
+=head3 type_description
+
+ my $description = $attribute->type_description
+
+ Return description of attribute type
+
+=cut
+
+sub type_description {
+
+ my $self = shift;
+
+ return $self->type->description;
+}
+
=head3 type
my $attribute_type = $attribute->type;
Koha::Exceptions::Patron::Attribute::UniqueIDConstraint->throw()
if $unique_count > 0;
}
+
+ return $self;
}
=head3 _type