Bugzilla – Attachment 7074 Details for
Bug 7154
Group borrower attributes and link between patron category and attribute
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 7154: Followup: Change link to patron category
0001-Bug-7154-Followup-Change-link-to-patron-category.patch (text/plain), 14.70 KB, created by
Jonathan Druart
on 2012-01-06 17:11:18 UTC
(
hide
)
Description:
Bug 7154: Followup: Change link to patron category
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2012-01-06 17:11:18 UTC
Size:
14.70 KB
patch
obsolete
>From 2c8a51b054402aad2776548d1957f17158617695 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Fri, 6 Jan 2012 17:58:38 +0100 >Subject: [PATCH 1/1] Bug 7154: Followup: Change link to patron category > >--- > 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(-) > >diff --git a/C4/Members/AttributeTypes.pm b/C4/Members/AttributeTypes.pm >index 6a6b16d..8c96e54 100644 >--- a/C4/Members/AttributeTypes.pm >+++ b/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 >diff --git a/admin/patron-attr-types.pl b/admin/patron-attr-types.pl >index 5011bcb..13b92ee 100755 >--- a/admin/patron-attr-types.pl >+++ b/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; >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index 1a7ed24..25b2223 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/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); > } >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt >index 968791d..f6f76c4 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt >@@ -187,15 +187,12 @@ function CheckAttributeTypeForm(f) { > enforced during batch patron import.</span> > </li> > <li> >- <label for="category_type">Category type: </label> >- <select name="category_type" id="category_type"> >+ <label for="category">Category: </label> >+ <select name="category_code" id="category"> > <option value=""></option> >- [% IF category_type == 'A' %]<option value="A" selected="selected">Adult</option>[% ELSE %]<option value="A">Adult</option>[% END %] >- [% IF category_type == 'C' %]<option value="C" selected="selected">Child</option>[% ELSE %]<option value="C">Child</option>[% END %] >- [% IF category_type == 'S' %]<option value="S" selected="selected">Staff</option>[% ELSE %]<option value="S">Staff</option>[% END %] >- [% IF category_type == 'I' %]<option value="I" selected="selected">Organization</option>[% ELSE %]<option value="I">Organization</option>[% END %] >- [% IF category_type == 'P' %]<option value="P" selected="selected">Professional</option>[% ELSE %]<option value="P">Professional</option>[% END %] >- [% IF category_type == 'X' %]<option value="X" selected="selected">Statistical</option>[% ELSE %]<option value="X">Statistical</option>[% END %] >+ [% FOREACH cat IN categories %] >+ [% IF ( cat.categorycode == category_code ) %]<option value="[% cat.categorycode %]" selected="selected">[% cat.description %]</option>[% ELSE %]<option value="[% cat.categorycode %]">[% cat.description %]</option>[% END %] >+ [% END %] > </select> > <span>Please let blank if you want these attributs to be for all types of patron. Else, select one type.</span> > </li> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >index d355111..8c83eb2 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >@@ -24,12 +24,12 @@ > document.form.country.value=RegExp.$4; > }); > >- [% IF category_type %] >- update_category_code( "[% category_type %]" ); >+ [% IF categorycode %] >+ update_category_code( "[% categorycode %]" ); > [% ELSE %] > if ( $("#categorycode").length > 0 ){ >- var category_type = $("#categorycode").find("option:selected").attr("data-typename"); >- update_category_code( category_type ); >+ var category_code = $("#categorycode").find("option:selected").val(); >+ update_category_code( category_code ); > } > [% END %] > >@@ -62,9 +62,9 @@ > original.parentNode.insertBefore(clone, original.nextSibling); > } > >- function update_category_code(category_type) { >- if ( $(category_type).is("select") ) { >- category_type = $("#categorycode").find("option:selected").attr("data-typename"); >+ function update_category_code(category_code) { >+ if ( $(category_code).is("select") ) { >+ category_code = $("#categorycode").find("option:selected").val(); > } > var mytables = $(".attributes_table>tbody"); > >@@ -72,10 +72,10 @@ > $(this).hide() > }); > >- mytables.find("tr[data-category_type="+category_type+"]").each(function(){ >+ mytables.find("tr[data-category_code="+category_code+"]").each(function(){ > $(this).show(); > }); >- mytables.find("tr[data-category_type='']").each(function(){ >+ mytables.find("tr[data-category_code='']").each(function(){ > $(this).show(); > }); > >@@ -1225,7 +1225,7 @@ > </thead> > <tbody> > [% FOREACH patron_attribute IN pa_loo.items %] >- <tr data-category_type="[% patron_attribute.category_type %]"> >+ <tr data-category_code="[% patron_attribute.category_code %]"> > <td> > [% patron_attribute.code %] ([% patron_attribute.description %]) > </td> >diff --git a/members/memberentry.pl b/members/memberentry.pl >index 8211880..9febd84 100755 >--- a/members/memberentry.pl >+++ b/members/memberentry.pl >@@ -752,7 +752,8 @@ sub patron_attributes_form { > return; > } > my $attributes = C4::Members::Attributes::GetBorrowerAttributes($borrowernumber); >- my @classes = sort uniq( map {$_->{class}} @$attributes ); >+ my @classes = uniq( map {$_->{class}} @$attributes ); >+ @classes = sort @classes; > > # map patron's attributes into a more convenient structure > my %attr_hash = (); >@@ -772,7 +773,7 @@ sub patron_attributes_form { > repeatable => $attr_type->repeatable(), > password_allowed => $attr_type->password_allowed(), > category => $attr_type->authorised_value_category(), >- category_type => $attr_type->category_type(), >+ category_code => $attr_type->category_code(), > password => '', > }; > if (exists $attr_hash{$attr_type->code()}) { >diff --git a/members/moremember.pl b/members/moremember.pl >index d12203e..0985a04 100755 >--- a/members/moremember.pl >+++ b/members/moremember.pl >@@ -432,7 +432,9 @@ $template->param(%$data); > > if (C4::Context->preference('ExtendedPatronAttributes')) { > my $attributes = C4::Members::Attributes::GetBorrowerAttributes($borrowernumber); >- my @classes = sort uniq( map {$_->{class}} @$attributes ); >+ my @classes = uniq( map {$_->{class}} @$attributes ); >+ @classes = sort @classes; >+ > my @attributes_loop; > for my $class (@classes) { > my @items; >-- >1.7.7.3 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 7154
:
6202
|
6536
|
6575
|
6909
|
7066
|
7067
|
7070
|
7074
|
7559
|
8337
|
8350
|
8351
|
8353
|
8389
|
8397
|
8407