From ca2b4893675aae8595371ce29bb147009e2297e6 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 27 Jul 2012 16:42:56 +0200 Subject: [PATCH] Bug 7919: Followup: Add a column "Branches limitations" for the 3 pages --- admin/authorised_values.pl | 8 ++++++++ admin/categorie.pl | 11 ++++++++++- admin/patron-attr-types.pl | 8 ++++++-- .../prog/en/modules/admin/authorised_values.tt | 12 ++++++++++++ .../prog/en/modules/admin/categorie.tt | 12 ++++++++++++ .../prog/en/modules/admin/patron-attr-types.tt | 12 ++++++++++++ 6 files changed, 60 insertions(+), 3 deletions(-) diff --git a/admin/authorised_values.pl b/admin/authorised_values.pl index 06bb654..bf9ec5a 100755 --- a/admin/authorised_values.pl +++ b/admin/authorised_values.pl @@ -268,7 +268,14 @@ sub default_form { 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 = ?"); for (my $i=0; $i < $count; $i++){ + $sth->execute( $results->[$i]{id} ); + my @selected_branches; + while ( my $branch = $sth->fetchrow_hashref ) { + push @selected_branches, $branch; + } my %row_data; # get a fresh hash for the row data $row_data{category} = $results->[$i]{'category'}; $row_data{authorised_value} = $results->[$i]{'authorised_value'}; @@ -277,6 +284,7 @@ sub default_form { $row_data{imageurl} = getitemtypeimagelocation( 'intranet', $results->[$i]{'imageurl'} ); $row_data{edit} = "$script_name?op=add_form&id=".$results->[$i]{'id'}."&offset=$offset"; $row_data{delete} = "$script_name?op=delete_confirm&searchfield=$searchfield&id=".$results->[$i]{'id'}."&offset=$offset"; + $row_data{branches} = \@selected_branches; push(@loop_data, \%row_data); } diff --git a/admin/categorie.pl b/admin/categorie.pl index b2076d0..fed14ce 100755 --- a/admin/categorie.pl +++ b/admin/categorie.pl @@ -233,7 +233,14 @@ if ($op eq 'add_form') { $template->param(else => 1); my @loop; my ($count,$results)=StringSearch($searchfield,'web'); + my $dbh = C4::Context->dbh; + my $sth = $dbh->prepare("SELECT b.branchcode, b.branchname FROM categories_branches AS cb, branches AS b WHERE cb.branchcode = b.branchcode AND cb.categorycode = ?"); for (my $i=0; $i < $count; $i++){ + $sth->execute( $results->[$i]{'categorycode'} ); + my @selected_branches; + while ( my $branch = $sth->fetchrow_hashref ) { + push @selected_branches, $branch; + } my %row = ( categorycode => $results->[$i]{'categorycode'}, description => $results->[$i]{'description'}, @@ -247,7 +254,9 @@ if ($op eq 'add_form') { reservefee => sprintf("%.2f",$results->[$i]{'reservefee'}), hidelostitems => $results->[$i]{'hidelostitems'}, category_type => $results->[$i]{'category_type'}, - "type_".$results->[$i]{'category_type'} => 1); + "type_".$results->[$i]{'category_type'} => 1, + branches => \@selected_branches, + ); if (C4::Context->preference('EnhancedMessagingPreferences')) { my $brief_prefs = _get_brief_messaging_prefs($results->[$i]{'categorycode'}); $row{messaging_prefs} = $brief_prefs if @$brief_prefs; diff --git a/admin/patron-attr-types.pl b/admin/patron-attr-types.pl index 3fa7612..3935f40 100755 --- a/admin/patron-attr-types.pl +++ b/admin/patron-attr-types.pl @@ -293,15 +293,19 @@ sub patron_attribute_type_list { my @attributes_loop; for my $class (@classes) { - my @items; + my ( @items, $branches ); for my $attr (@attr_types) { - push @items, $attr if $attr->{class} eq $class + next if $attr->{class} ne $class; + my $attr_type = C4::Members::AttributeTypes->fetch($attr->{code}); + $attr->{branches} = $attr_type->branches; + push @items, $attr; } my $lib = GetAuthorisedValueByCode( 'PA_CLASS', $class ) || $class; push @attributes_loop, { class => $class, items => \@items, lib => $lib, + branches => $branches, }; } $template->param(available_attribute_types => \@attributes_loop); 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 03cb478..2b56f21 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 @@ -249,6 +249,7 @@ Description Description (OPAC) Icon + Branches limitations Edit Delete @@ -263,6 +264,17 @@ [% loo.lib %] [% loo.lib_opac %] [% IF ( loo.imageurl ) %][% ELSE %] [% END %] + + [% IF loo.branches.size > 0 %] + [% branches_str = "" %] + [% FOREACH branch IN loo.branches %] + [% branches_str = branches_str _ " " _ branch.branchname _ "(" _ branch.branchcode _ ")" %] + [% END %] + [% loo.branches.size %] branches limitations + [% ELSE %] + No limitation + [% END %] + Edit Delete 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 f9c1880..da1d41a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categorie.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categorie.tt @@ -303,6 +303,7 @@ Confirm deletion of category [% categorycode |html %][% END %] [% IF ( EnhancedMessagingPreferences ) %] Messaging [% END %] + Branches limitations   [% FOREACH loo IN loop %] @@ -356,6 +357,17 @@ Confirm deletion of category [% categorycode |html %][% END %] [% END %] [% END %] + + [% IF loo.branches.size > 0 %] + [% branches_str = "" %] + [% FOREACH branch IN loo.branches %] + [% branches_str = branches_str _ " " _ branch.branchname _ "(" _ branch.branchcode _ ")" %] + [% END %] + [% loo.branches.size %] branches limitations + [% ELSE %] + No limitation + [% END %] + Edit Delete 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 3804f93..5f63618 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 @@ -306,6 +306,7 @@ function CheckAttributeTypeForm(f) { Code Description Actions + Branches limitation @@ -314,6 +315,17 @@ function CheckAttributeTypeForm(f) { [% item.code |html %] [% item.description %] + [% IF item.branches > 0 %] + [% branches_str = "" %] + [% FOREACH branch IN item.branches %] + [% branches_str = branches_str _ " " _ branch.branchname _ "(" _ branch.branchcode _ ")" %] + [% END %] + [% item.branches.size %] branches limitations + [% ELSE %] + No limitation + [% END %] + + Edit Delete -- 1.7.7.3