From ec2692495fc4c6bf98c8922cb5fcf0863e2dbc66 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 22 Aug 2012 16:53:39 +0200 Subject: [PATCH 1/1] Bug 7919: Followup FIX several behaviours --- C4/Input.pm | 2 +- C4/Items.pm | 20 ++++++++++++++++++-- .../prog/en/modules/admin/authorised_values.tt | 2 +- .../prog/en/modules/admin/categorie.tt | 2 +- .../prog/en/modules/admin/patron-attr-types.tt | 4 ++-- 5 files changed, 23 insertions(+), 7 deletions(-) diff --git a/C4/Input.pm b/C4/Input.pm index 2262750..ba30460 100644 --- a/C4/Input.pm +++ b/C4/Input.pm @@ -137,7 +137,7 @@ sub buildCGIsort { $query .= qq{ GROUP BY lib ORDER BY lib}; my $sth=$dbh->prepare($query); - $sth->execute( $branch_limit ? $branch_limit : (), $name ); + $sth->execute( $name, $branch_limit ? $branch_limit : () ); my $CGISort; if ($sth->rows>0){ my @values; diff --git a/C4/Items.pm b/C4/Items.pm index a9c0a16..08234ce 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -2597,7 +2597,20 @@ sub PrepareItemrecordDisplay { $itemrecord = C4::Items::GetMarcItem( $bibnum, $itemnum ); } my @loop_data; - my $authorised_values_sth = $dbh->prepare( "SELECT authorised_value,lib FROM authorised_values WHERE category=? ORDER BY lib" ); + + my $branch_limit = C4::Context->userenv ? C4::Context->userenv->{"branch"} : ""; + my $query = qq{ + SELECT authorised_value,lib FROM authorised_values + }; + $query .= qq{ + LEFT JOIN authorised_values_branches ON ( id = av_id ) + } if $branch_limit; + $query .= qq{ + WHERE category = ? + }; + $query .= qq{ AND ( branchcode = ? OR branchcode IS NULL )} if $branch_limit; + $query .= qq{ ORDER BY lib}; + my $authorised_values_sth = $dbh->prepare( $query ); foreach my $tag ( sort keys %{$tagslib} ) { my $previous_tag = ''; if ( $tag ne '' ) { @@ -2726,7 +2739,10 @@ sub PrepareItemrecordDisplay { #---- "true" authorised value } else { - $authorised_values_sth->execute( $tagslib->{$tag}->{$subfield}->{authorised_value} ); + $authorised_values_sth->execute( + $tagslib->{$tag}->{$subfield}->{authorised_value}, + $branch_limit ? $branch_limit : () + ); push @authorised_values, "" unless ( $tagslib->{$tag}->{$subfield}->{mandatory} ); while ( my ( $value, $lib ) = $authorised_values_sth->fetchrow_array ) { 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 2b56f21..f6a69c6 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 @@ -270,7 +270,7 @@ [% FOREACH branch IN loo.branches %] [% branches_str = branches_str _ " " _ branch.branchname _ "(" _ branch.branchcode _ ")" %] [% END %] - [% loo.branches.size %] branches limitations + [% loo.branches.size %] branches limitations [% ELSE %] No limitation [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categorie.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categorie.tt index 0c7c5dd..9398ca6 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categorie.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categorie.tt @@ -371,7 +371,7 @@ Confirm deletion of category [% categorycode |html %][% END %] [% FOREACH branch IN loo.branches %] [% branches_str = branches_str _ " " _ branch.branchname _ "(" _ branch.branchcode _ ")" %] [% END %] - [% loo.branches.size %] branches limitations + [% loo.branches.size %] branches limitations [% ELSE %] No limitation [% END %] 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 5f63618..3fb9760 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 @@ -305,8 +305,8 @@ function CheckAttributeTypeForm(f) { Code Description - Actions Branches limitation + Actions @@ -320,7 +320,7 @@ function CheckAttributeTypeForm(f) { [% FOREACH branch IN item.branches %] [% branches_str = branches_str _ " " _ branch.branchname _ "(" _ branch.branchcode _ ")" %] [% END %] - [% item.branches.size %] branches limitations + [% item.branches.size %] branches limitations [% ELSE %] No limitation [% END %] -- 1.7.10.4