From 28a5f8a94a1e9ade46027b297000dd34f3426870 Mon Sep 17 00:00:00 2001 From: Bernardo Gonzalez Kriegel Date: Sat, 19 Jul 2014 00:22:12 -0300 Subject: [PATCH] [PASSED QA] Bug 766: Remove CGI::scrollinglist from authorised_values.pl This patch removes the only instance in this file. Also fixes array sorting, removes some tabs, removes an unneeded $dbh handler (there is a global one). Makes use of C4::Koha::GetAuthorisedValueCategories. To test: 1. Apply the patch 2. Go to Administration > Authorised values 3. Replaced pulldown next to 'Show category' must show all (present & system) categories correctly ordered. 4. Select some and check for regressions, e.g. CCODE, Bsort2, YES_NO no changes must be observed Signed-off-by: Owen Leonard Signed-off-by: Katrin Fischer Works as described, no problems found. Passes tests and QA script. --- admin/authorised_values.pl | 32 ++++++++++------------ .../prog/en/modules/admin/authorised_values.tt | 14 +++++++++- 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/admin/authorised_values.pl b/admin/authorised_values.pl index 8a44256..35afaca 100755 --- a/admin/authorised_values.pl +++ b/admin/authorised_values.pl @@ -237,12 +237,10 @@ exit 0; sub default_form { # build categories list - my $sth = $dbh->prepare("select distinct category from authorised_values"); - $sth->execute; - my @category_list; + my $category_list = C4::Koha::GetAuthorisedValueCategories(); + my @category_list = @{$category_list}; my %categories; # a hash, to check that some hardcoded categories exist. - while ( my ($category) = $sth->fetchrow_array ) { - push( @category_list, $category ); + for my $category ( @category_list ) { $categories{$category} = 1; } @@ -252,23 +250,19 @@ sub default_form { } #reorder the list - @category_list = sort {$a cmp $b} @category_list; - my $tab_list = CGI::scrolling_list(-name=>'searchfield', - -id=>'searchfield', - -values=> \@category_list, - -default=>"", - -size=>1, - -multiple=>0, - ); + @category_list = sort {lc($a) cmp lc($b)} @category_list; if (!$searchfield) { $searchfield=$category_list[0]; } + my $tab_list = { + values => \@category_list, + default => $searchfield, + }; my ($results) = AuthorizedValuesForCategory($searchfield); my $count = scalar(@$results); my @loop_data = (); # builds value list - my $dbh = C4::Context->dbh; - $sth = $dbh->prepare("SELECT b.branchcode, b.branchname FROM authorised_values_branches AS avb, branches AS b WHERE avb.branchcode = b.branchcode AND avb.av_id = ?"); + my $sth = $dbh->prepare("SELECT b.branchcode, b.branchname FROM authorised_values_branches AS avb, branches AS b WHERE avb.branchcode = b.branchcode AND avb.av_id = ?"); for (my $i=0; $i < $count; $i++){ $sth->execute( $results->[$i]{id} ); my @selected_branches; @@ -287,8 +281,10 @@ sub default_form { push(@loop_data, \%row_data); } - $template->param( loop => \@loop_data, - tab_list => $tab_list, - category => $searchfield ); + $template->param( + loop => \@loop_data, + tab_list => $tab_list, + category => $searchfield, + ); } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt index 9e96c34..2549a0f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt @@ -194,7 +194,19 @@ $(document).ready(function() {
Could not add value "[% duplicate_value %]" for category "[% duplicate_category %]" — value already present.
[% END %] -
[% tab_list %]
+
+ + + +
[% IF ( category == 'Bsort1' ) %]

An authorized value attached to patrons, that can be used for stats purposes

[% END %] -- 1.9.1