@@ -, +, @@ --- C4/Members/AttributeTypes.pm | 50 ++++++++++++++----- admin/patron-attr-types.pl | 14 ++++-- installer/data/mysql/updatedatabase.pl | 3 +- .../prog/en/modules/admin/patron-attr-types.tt | 13 ++--- .../prog/en/modules/members/memberentrygen.tt | 20 ++++---- members/memberentry.pl | 5 +- members/moremember.pl | 4 +- 7 files changed, 70 insertions(+), 39 deletions(-) --- a/C4/Members/AttributeTypes.pm +++ a/C4/Members/AttributeTypes.pm @@ -120,7 +120,8 @@ sub new { $self->{'staff_searchable'} = 0; $self->{'display_checkout'} = 0; $self->{'authorised_value_category'} = ''; - $self->{'category_type'} = ''; + $self->{'category_code'} = ''; + $self->{'category_description'} = ''; $self->{'class'} = ''; bless $self, $class; @@ -142,11 +143,15 @@ sub fetch { my $self = {}; my $dbh = C4::Context->dbh(); - my $sth = $dbh->prepare_cached("SELECT * FROM borrower_attribute_types WHERE code = ?"); + my $sth = $dbh->prepare_cached(" + SELECT borrower_attribute_types.*, categories.description AS category_description + FROM borrower_attribute_types + LEFT JOIN categories ON borrower_attribute_types.category_code=categories.categorycode + WHERE code =?"); $sth->execute($code); my $row = $sth->fetchrow_hashref; $sth->finish(); - return undef unless defined $row; + return undef unless defined $row; $self->{'code'} = $row->{'code'}; $self->{'description'} = $row->{'description'}; @@ -157,7 +162,8 @@ sub fetch { $self->{'staff_searchable'} = $row->{'staff_searchable'}; $self->{'display_checkout'} = $row->{'display_checkout'}; $self->{'authorised_value_category'} = $row->{'authorised_value_category'}; - $self->{'category_type'} = $row->{'category_type'}; + $self->{'category_code'} = $row->{'category_code'}; + $self->{'category_description'} = $row->{'category_description'}; $self->{'class'} = $row->{'class'}; bless $self, $class; @@ -190,13 +196,13 @@ sub store { staff_searchable = ?, authorised_value_category = ?, display_checkout = ?, - category_type = ?, + category_code = ?, class = ? WHERE code = ?"); } else { $sth = $dbh->prepare_cached("INSERT INTO borrower_attribute_types (description, repeatable, unique_id, opac_display, password_allowed, - staff_searchable, authorised_value_category, display_checkout, category_type, class, code) + staff_searchable, authorised_value_category, display_checkout, category_code, class, code) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); } @@ -208,7 +214,7 @@ sub store { $sth->bind_param(6, $self->{'staff_searchable'}); $sth->bind_param(7, $self->{'authorised_value_category'}); $sth->bind_param(8, $self->{'display_checkout'}); - $sth->bind_param(9, $self->{'category_type'}); + $sth->bind_param(9, $self->{'category_code'} || undef); $sth->bind_param(10, $self->{'class'}); $sth->bind_param(11, $self->{'code'}); $sth->execute; @@ -349,12 +355,12 @@ sub authorised_value_category { @_ ? $self->{'authorised_value_category'} = shift : $self->{'authorised_value_category'}; } -=head2 category_type +=head2 category_code =over 4 -my $category_type = $attr_type->category_type(); -$attr_type->category_type($category_type); +my $category_code = $attr_type->category_code(); +$attr_type->category_code($category_code); =back @@ -362,16 +368,34 @@ Accessor. =cut -sub category_type { +sub category_code { my $self = shift; - @_ ? $self->{'category_type'} = shift : $self->{'category_type'}; + @_ ? $self->{'category_code'} = shift : $self->{'category_code'}; +} + +=head2 category_description + +=over 4 + +my $category_description = $attr_type->category_description(); +$attr_type->category_description($category_description); + +=back + +Accessor. + +=cut + +sub category_description { + my $self = shift; + @_ ? $self->{'category_description'} = shift : $self->{'category_description'}; } =head2 class =over 4 -my $category_type = $attr_type->class(); +my $class = $attr_type->class(); $attr_type->class($class); =back --- a/admin/patron-attr-types.pl +++ a/admin/patron-attr-types.pl @@ -28,6 +28,7 @@ use C4::Auth; use C4::Context; use C4::Output; use C4::Koha; +use C4::Members qw/GetBorrowercategoryList/; use C4::Members::AttributeTypes; my $script_name = "/cgi-bin/koha/admin/patron-attr-types.pl"; @@ -84,6 +85,7 @@ sub add_attribute_type_form { $template->param( attribute_type_form => 1, confirm_op => 'add_attribute_type_confirmed', + categories => GetBorrowercategoryList, ); authorised_value_category_list($template); pa_classes($template); @@ -113,7 +115,7 @@ sub error_add_attribute_type_form { $template->param(display_checkout_checked => 'checked="checked"'); } - $template->param( category_type => $input->param('category_type') ); + $template->param( category_code => $input->param('category_code') ); $template->param( class => $input->param('class') ); $template->param( @@ -158,7 +160,7 @@ sub add_update_attribute_type { $attr_type->password_allowed($password_allowed); my $display_checkout = $input->param('display_checkout'); $attr_type->display_checkout($display_checkout); - $attr_type->category_type($input->param('category_type')); + $attr_type->category_code($input->param('category_code')); $attr_type->class($input->param('class')); if ($op eq 'edit') { @@ -242,12 +244,14 @@ sub edit_attribute_type_form { authorised_value_category_list($template, $attr_type->authorised_value_category()); pa_classes( $template, $attr_type->class ); - $template->param ( category_type => $attr_type->category_type ); + $template->param ( category_code => $attr_type->category_code ); + $template->param ( category_description => $attr_type->category_description ); $template->param( attribute_type_form => 1, edit_attribute_type => 1, confirm_op => 'edit_attribute_type_confirmed', + categories => GetBorrowercategoryList, ); } @@ -256,7 +260,9 @@ sub patron_attribute_type_list { my $template = shift; my @attr_types = C4::Members::AttributeTypes::GetAttributeTypes(); - my @classes = sort uniq( map {$_->{class}} @attr_types ); + my @classes = uniq( map {$_->{class}} @attr_types ); + @classes = sort @classes; + my @attributes_loop; for my $class (@classes) { my @items; --- a/installer/data/mysql/updatedatabase.pl +++ a/installer/data/mysql/updatedatabase.pl @@ -4587,8 +4587,9 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { $DBversion = "3.06.00.XXX"; if (C4::Context->preference("Version") < TransformToNum($DBversion)) { - $dbh->do("ALTER TABLE borrower_attribute_types ADD COLUMN category_type VARCHAR(1) NOT NULL DEFAULT '' AFTER `display_checkout`"); + $dbh->do("ALTER TABLE borrower_attribute_types ADD COLUMN category_code VARCHAR(10) NULL DEFAULT NULL AFTER `display_checkout`"); $dbh->do("ALTER TABLE borrower_attribute_types ADD COLUMN class VARCHAR(255) NOT NULL DEFAULT '' AFTER `category_type`"); + $dbh->do("ALTER TABLE borrower_attribute_types ADD CONSTRAINT category_code_fk FOREIGN KEY (category_code) REFERENCES categories(categorycode)"); print "Upgrade to $DBversion done (New fields category_type and class in borrower_attribute_types table)\n"; SetVersion($DBversion); } --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt @@ -187,15 +187,12 @@ function CheckAttributeTypeForm(f) { enforced during batch patron import.