@@ -, +, @@ --- 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(-) --- a/C4/Input.pm +++ a/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; --- a/C4/Items.pm +++ a/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 ) { --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt +++ a/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 %] --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categorie.tt +++ a/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 %] --- 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 @@ -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 %] --