From c7ca45d0463099ac5cee8978d0f05960e3779c0f Mon Sep 17 00:00:00 2001 From: Bernardo Gonzalez Kriegel Date: Tue, 29 Jul 2014 15:49:44 -0300 Subject: [PATCH] Bug 12675: Remove CGI::scrolling_list from labeledMARCdetail.pl This patch removes only instance in this file. Also updates getframework POD on C4/Koha.pm, adds new GetFrameworksLoop() func on same file from suggested code, but with ordered result. To test: 1. Apply the patch 2. Enable viewLabeledMARC syspref 3. On staff, search for a record, goto detail view 4. Clic on Labeled MARC 5. Framework pulldown was replaced, check changing framework. A bug was fixed, because selecting any fw and then Default tries to load values from 'Default' fw code, which does not exists. Signed-off-by: Owen Leonard Signed-off-by: Katrin Fischer Works as described, passes tests and QA script. Signed-off-by: Tomas Cohen Arazi --- C4/Koha.pm | 71 ++++++++++++++++--- catalogue/labeledMARCdetail.pl | 27 +------ .../en/modules/catalogue/labeledMARCdetail.tt | 13 +++- 3 files changed, 78 insertions(+), 33 deletions(-) diff --git a/C4/Koha.pm b/C4/Koha.pm index 6f98ac6b09..ee4bd67d4d 100644 --- a/C4/Koha.pm +++ b/C4/Koha.pm @@ -46,6 +46,7 @@ BEGIN { &GetSupportName &GetSupportList &get_itemtypeinfos_of &getframeworks &getframeworkinfo + &GetFrameworksLoop &getauthtypes &getauthtype &getallthemes &getFacets @@ -363,12 +364,13 @@ build a HTML select with the following code : =head3 in PERL SCRIPT - my $frameworks = frameworks(); + my $frameworks = getframeworks(); my @frameworkloop; foreach my $thisframework (keys %$frameworks) { my $selected = 1 if $thisframework eq $frameworkcode; - my %row =(value => $thisframework, - selected => $selected, + my %row =( + value => $thisframework, + selected => $selected, description => $frameworks->{$thisframework}->{'frameworktext'}, ); push @frameworksloop, \%row; @@ -377,14 +379,18 @@ build a HTML select with the following code : =head3 in TEMPLATE -
+ - - - + [% FOREACH framework IN frameworkloop %] + [% IF ( framework.selected ) %] + + [% ELSE %] + + [% END %] + [% END %] - "> +
@@ -403,6 +409,55 @@ sub getframeworks { return ( \%itemtypes ); } +=head2 GetFrameworksLoop + + $frameworks = GetFrameworksLoop( $frameworkcode ); + +Returns the loop suggested on getframework(), but ordered by framework description. + +build a HTML select with the following code : + +=head3 in PERL SCRIPT + + $template->param( frameworkloop => GetFrameworksLoop( $frameworkcode ) ); + +=head3 in TEMPLATE + + Same as getframework() + +
+ + [% FOREACH framework IN frameworkloop %] + [% IF ( framework.selected ) %] + + [% ELSE %] + + [% END %] + [% END %] + + + +
+ +=cut + +sub GetFrameworksLoop { + my $frameworkcode = shift; + my $frameworks = getframeworks(); + my @frameworkloop; + foreach my $thisframework (sort { uc($frameworks->{$a}->{'frameworktext'}) cmp uc($frameworks->{$b}->{'frameworktext'}) } keys %$frameworks) { + my $selected = ( $thisframework eq $frameworkcode ) ? 1 : undef; + my %row = ( + value => $thisframework, + selected => $selected, + description => $frameworks->{$thisframework}->{'frameworktext'}, + ); + push @frameworkloop, \%row; + } + return \@frameworkloop; +} + =head2 getframeworkinfo $frameworkinfo = &getframeworkinfo($frameworkcode); diff --git a/catalogue/labeledMARCdetail.pl b/catalogue/labeledMARCdetail.pl index 66c0f745fa..11f8f8555e 100755 --- a/catalogue/labeledMARCdetail.pl +++ b/catalogue/labeledMARCdetail.pl @@ -29,6 +29,7 @@ use C4::Items; use C4::Members; # to use GetMember use C4::Search; # enabled_staff_search_views use C4::Acquisition qw(GetOrdersByBiblionumber); +use C4::Koha qw( GetFrameworksLoop ); my $query = new CGI; my $dbh = C4::Context->dbh; @@ -79,30 +80,8 @@ my $itemcount = GetItemsCount($biblionumber); $template->param( count => $itemcount, bibliotitle => $biblio->{title}, ); -#Getting the list of all frameworks -my $queryfwk = - $dbh->prepare("select frameworktext, frameworkcode from biblio_framework"); -$queryfwk->execute; -my %select_fwk; -my @select_fwk; -my $curfwk; -push @select_fwk, "Default"; -$select_fwk{"Default"} = "Default"; - -while ( my ( $description, $fwk ) = $queryfwk->fetchrow ) { - push @select_fwk, $fwk; - $select_fwk{$fwk} = $description; -} -$curfwk=$frameworkcode; -my $framework=CGI::scrolling_list( -name => 'Frameworks', - -id => 'Frameworks', - -default => $curfwk, - -OnChange => 'Changefwk(this);', - -values => \@select_fwk, - -labels => \%select_fwk, - -size => 1, - -multiple => 0 ); -$template->param(framework => $framework); +#Getting framework loop +$template->param(frameworkloop => GetFrameworksLoop( $frameworkcode ) ); my @marc_data; my $prevlabel = ''; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/labeledMARCdetail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/labeledMARCdetail.tt index 882a90cd81..957f6cec46 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/labeledMARCdetail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/labeledMARCdetail.tt @@ -57,7 +57,18 @@ [% UNLESS ( popup ) %]

Labeled MARC biblio : [% biblionumber %] ( [% bibliotitle %] )

[% END %] -

With framework :[% framework %]

+

With framework: + +

-- 2.39.5