@@ -, +, @@
C4::Koha::GetAuthorisedValueCategories
---
C4/Koha.pm | 21 ------------------
Koha/Template/Plugin/AuthorisedValues.pm | 15 +++++++++++++
admin/aqbudgets.pl | 25 ++++++----------------
admin/auth_subfields_structure.pl | 19 ++++++++--------
admin/auth_tag_structure.pl | 9 +-------
admin/items_search_field.pl | 3 ---
admin/items_search_fields.pl | 3 ---
admin/marctagstructure.pl | 10 ++-------
admin/patron-attr-types.pl | 19 ++--------------
.../en/includes/admin-items-search-field-form.inc | 8 +------
.../prog/en/includes/doc-head-close.inc | 1 +
.../prog/en/includes/html_helpers.inc | 9 ++++++++
.../prog/en/modules/admin/aqbudgets.tt | 25 +++-------------------
.../prog/en/modules/admin/auth_tag_structure.tt | 10 +++------
.../prog/en/modules/admin/items_search_field.tt | 1 +
.../prog/en/modules/admin/items_search_fields.tt | 1 +
.../prog/en/modules/admin/marctagstructure.tt | 14 +++++-------
.../prog/en/modules/admin/patron-attr-types.tt | 13 ++---------
.../prog/en/modules/serials/add_fields.tt | 9 ++------
serials/add_fields.pl | 2 --
20 files changed, 64 insertions(+), 153 deletions(-)
create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc
--- a/C4/Koha.pm
+++ a/C4/Koha.pm
@@ -56,7 +56,6 @@ BEGIN {
&getitemtypeimagesrc
&getitemtypeimagelocation
&GetAuthorisedValues
- &GetAuthorisedValueCategories
&IsAuthorisedValueCategory
&GetKohaAuthorisedValues
&GetKohaAuthorisedValuesFromField
@@ -1100,26 +1099,6 @@ sub GetAuthorisedValues {
return \@results;
}
-=head2 GetAuthorisedValueCategories
-
- $auth_categories = GetAuthorisedValueCategories();
-
-Return an arrayref of all of the available authorised
-value categories.
-
-=cut
-
-sub GetAuthorisedValueCategories {
- my $dbh = C4::Context->dbh;
- my $sth = $dbh->prepare("SELECT DISTINCT category FROM authorised_values ORDER BY category");
- $sth->execute;
- my @results;
- while (defined (my $category = $sth->fetchrow_array) ) {
- push @results, $category;
- }
- return \@results;
-}
-
=head2 IsAuthorisedValueCategory
$is_auth_val_category = IsAuthorisedValueCategory($category);
--- a/Koha/Template/Plugin/AuthorisedValues.pm
+++ a/Koha/Template/Plugin/AuthorisedValues.pm
@@ -22,6 +22,7 @@ use Template::Plugin;
use base qw( Template::Plugin );
use C4::Koha;
+use Koha::AuthorisedValues;
sub GetByCode {
my ( $self, $category, $code, $opac ) = @_;
@@ -38,6 +39,20 @@ sub GetAuthValueDropbox {
return C4::Koha::GetAuthvalueDropbox($category, $default);
}
+sub GetCategories {
+ my ( $self, $params ) = @_;
+ my $selected = $params->{selected};
+ my @categories = Koha::AuthorisedValues->new->categories;
+ return [
+ map {
+ {
+ category => $_,
+ ( ( $selected and $selected eq $_ ) ? ( selected => 1 ) : () ),
+ }
+ } @categories
+ ];
+}
+
1;
=head1 NAME
--- a/admin/aqbudgets.pl
+++ a/admin/aqbudgets.pl
@@ -152,25 +152,12 @@ if ($op eq 'add_form') {
$row{selected} = 1 if $budget and $thisbranch eq $budget->{'budget_branchcode'};
push @branchloop_select, \%row;
}
-
- # populates the YUI planning button
- my $categories = GetAuthorisedValueCategories();
- my @auth_cats_loop1 = ();
- foreach my $category (@$categories) {
- my $entry = { category => $category,
- selected => ( $budget and $budget->{sort1_authcat} eq $category ? 1 : 0 ),
- };
- push @auth_cats_loop1, $entry;
- }
- my @auth_cats_loop2 = ();
- foreach my $category (@$categories) {
- my $entry = { category => $category,
- selected => ( $budget and $budget->{sort2_authcat} eq $category ? 1 : 0 ),
- };
- push @auth_cats_loop2, $entry;
- }
- $template->param(authorised_value_categories1 => \@auth_cats_loop1);
- $template->param(authorised_value_categories2 => \@auth_cats_loop2);
+
+ # populates the planning button
+ $template->param(
+ sort1_auth => $budget->{sort1_authcat},
+ sort2_auth => $budget->{sort2_authcat},
+ );
if($budget->{'budget_permission'}){
my $budget_permission = "budget_perm_".$budget->{'budget_permission'};
--- a/admin/auth_subfields_structure.pl
+++ a/admin/auth_subfields_structure.pl
@@ -26,6 +26,7 @@ use C4::Context;
use C4::Koha;
use Koha::Authority::Types;
+use Koha::AuthorisedValues;
use List::MoreUtils qw( uniq );
@@ -95,11 +96,11 @@ if ($op eq 'add_form') {
push @kohafields, "auth_header.".$field;
}
- # build authorised value list
- my $authorised_values = C4::Koha::GetAuthorisedValueCategories;
- unshift @$authorised_values, '';
- push @$authorised_values, 'branches';
- push @$authorised_values, 'itemtypes';
+ # build authorised value category list
+ my @authorised_value_categories = Koha::AuthorisedValues->new->categories;
+ unshift @authorised_value_categories, '';
+ push @authorised_value_categories, 'branches';
+ push @authorised_value_categories, 'itemtypes';
# build thesaurus categories list
my @authtypes = uniq( "", map { $_->authtypecode } Koha::Authority::Types->search );
@@ -154,7 +155,7 @@ if ($op eq 'add_form') {
};
$row_data{authorised_value} = {
id => "authorised_value$i",
- values => $authorised_values,
+ values => \@authorised_value_categories,
default => $data->{'authorised_value'},
};
$row_data{frameworkcode} = {
@@ -233,7 +234,7 @@ if ($op eq 'add_form') {
};
$row_data{authorised_value} = {
id => "authorised_value",
- values => $authorised_values,
+ values => \@authorised_value_categories,
default => "",
};
$row_data{frameworkcode} = {
@@ -279,7 +280,7 @@ if ($op eq 'add_form') {
my @ohidden = $input->param('ohidden');
#my @ihidden = $input->param('ihidden');
#my @ehidden = $input->param('ehidden');
- my @authorised_values = $input->param('authorised_value');
+ my @authorised_value_categories = $input->param('authorised_value');
my $authtypecode = $input->param('authtypecode');
my @frameworkcodes = $input->param('frameworkcode');
my @value_builder =$input->param('value_builder');
@@ -295,7 +296,7 @@ if ($op eq 'add_form') {
my $kohafield =$kohafield[$i];
my $tab =$tab[$i];
my $seealso =$seealso[$i];
- my $authorised_value =$authorised_values[$i];
+ my $authorised_value = $authorised_value_categories[$i];
my $frameworkcode =$frameworkcodes[$i];
my $value_builder=$value_builder[$i];
my $defaultvalue = $defaultvalue[$i];
--- a/admin/auth_tag_structure.pl
+++ a/admin/auth_tag_structure.pl
@@ -92,13 +92,6 @@ if ($op eq 'add_form') {
$data=$sth->fetchrow_hashref;
}
- my @authorised_values = @{C4::Koha::GetAuthorisedValueCategories()}; # function returns array ref, dereferencing
- unshift @authorised_values, ""; # put empty value first
- my $authorised_value = {
- values => \@authorised_values,
- default => $data->{'authorised_value'},
- };
-
if ($searchfield) {
$template->param('searchfield' => $searchfield);
$template->param('heading_modify_tag_p' => 1);
@@ -110,7 +103,7 @@ if ($op eq 'add_form') {
libopac => $data->{'libopac'},
repeatable => "".$data->{'repeatable'},
mandatory => "".$data->{'mandatory'},
- authorised_value => $authorised_value,
+ authorised_value => $data->{authorised_value},
authtypecode => $authtypecode,
);
# END $OP eq ADD_FORM
--- a/admin/items_search_field.pl
+++ a/admin/items_search_field.pl
@@ -21,7 +21,6 @@ use CGI;
use C4::Auth;
use C4::Output;
-use C4::Koha;
use Koha::Item::Search::Field qw(GetItemSearchField ModItemSearchField);
@@ -53,11 +52,9 @@ if ($op eq 'mod') {
}
my $field = GetItemSearchField($name);
-my $authorised_values_categories = C4::Koha::GetAuthorisedValueCategories();
$template->param(
field => $field,
- authorised_values_categories => $authorised_values_categories,
);
output_html_with_http_headers $cgi, $cookie, $template->output;
--- a/admin/items_search_fields.pl
+++ a/admin/items_search_fields.pl
@@ -21,7 +21,6 @@ use CGI;
use C4::Auth;
use C4::Output;
-use C4::Koha;
use Koha::Item::Search::Field qw(AddItemSearchField GetItemSearchFields DelItemSearchField);
@@ -71,11 +70,9 @@ if ($op eq 'add') {
}
my @fields = GetItemSearchFields();
-my $authorised_values_categories = C4::Koha::GetAuthorisedValueCategories();
$template->param(
fields => \@fields,
- authorised_values_categories => $authorised_values_categories,
);
output_html_with_http_headers $cgi, $cookie, $template->output;
--- a/admin/marctagstructure.pl
+++ a/admin/marctagstructure.pl
@@ -29,6 +29,7 @@ use C4::Context;
use Koha::Cache;
use Koha::BiblioFrameworks;
+use Koha::AuthorisedValues;
# retrieve parameters
my $input = new CGI;
@@ -94,13 +95,6 @@ if ($op eq 'add_form') {
$data=$sth->fetchrow_hashref;
}
- my @authorised_values = @{C4::Koha::GetAuthorisedValueCategories()}; # function returns array ref, dereferencing
- unshift @authorised_values, ""; # put empty value first
- my $authorised_value = {
- values => \@authorised_values,
- default => $data->{'authorised_value'},
- };
-
if ($searchfield) {
$template->param(searchfield => $searchfield);
$template->param(action => "Modify tag");
@@ -114,7 +108,7 @@ if ($op eq 'add_form') {
libopac => $data->{'libopac'},
repeatable => $data->{'repeatable'},
mandatory => $data->{'mandatory'},
- authorised_value => $authorised_value,
+ authorised_value => $data->{authorised_value},
frameworkcode => $frameworkcode,
); # FIXME: move checkboxes to presentation layer
# END $OP eq ADD_FORM
--- a/admin/patron-attr-types.pl
+++ a/admin/patron-attr-types.pl
@@ -98,7 +98,6 @@ sub add_attribute_type_form {
categories => GetBorrowercategoryList,
branches_loop => \@branches_loop,
);
- authorised_value_category_list($template);
pa_classes($template);
}
@@ -132,8 +131,8 @@ sub error_add_attribute_type_form {
$template->param(
attribute_type_form => 1,
confirm_op => 'add_attribute_type_confirmed',
+ authorised_value_category => $input->param('authorised_value_category'),
);
- authorised_value_category_list($template, $input->param('authorised_value_category'));
}
sub add_update_attribute_type {
@@ -254,7 +253,7 @@ sub edit_attribute_type_form {
if ($attr_type->display_checkout()) {
$template->param(display_checkout_checked => 'checked="checked"');
}
- authorised_value_category_list($template, $attr_type->authorised_value_category());
+ $template->param( authorised_value_category => $attr_type->authorised_value_category() );
pa_classes( $template, $attr_type->class );
@@ -312,20 +311,6 @@ sub patron_attribute_type_list {
$template->param(display_list => 1);
}
-sub authorised_value_category_list {
- my $template = shift;
- my $selected = @_ ? shift : '';
-
- my $categories = GetAuthorisedValueCategories();
- my @list = ();
- foreach my $category (@$categories) {
- my $entry = { category => $category };
- $entry->{selected} = 1 if $category eq $selected;
- push @list, $entry;
- }
- $template->param(authorised_value_categories => \@list);
-}
-
sub pa_classes {
my $template = shift;
my $selected = @_ ? shift : '';
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/admin-items-search-field-form.inc
+++ a/koha-tmpl/intranet-tmpl/prog/en/includes/admin-items-search-field-form.inc
@@ -46,13 +46,7 @@
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc
+++ a/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc
@@ -28,6 +28,7 @@
[% INCLUDE 'validator-strings.inc' %]
+[% PROCESS 'html_helpers.inc' %]
[% IF ( IntranetUserJS ) %]