From 570ee9574da2316ff833d87afd57548ea938a36c Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 6 Mar 2014 17:05:53 +0100 Subject: [PATCH] [SIGNED-OFF] Bug 766: Move GetAuthvalueDropbox to C4::Koha GetAuthvalueDropbox is in C4::Budgets, this does not make sense. Only acqui/fetch_sort_dropbox.pl call GetAuthvalueDropbox without using C4::Koha. Signed-off-by: Bernardo Gonzalez Kriegel --- C4/Budgets.pm | 40 ---------------------------------------- C4/Koha.pm | 38 ++++++++++++++++++++++++++++++++++++++ acqui/fetch_sort_dropbox.pl | 1 + 3 files changed, 39 insertions(+), 40 deletions(-) diff --git a/C4/Budgets.pm b/C4/Budgets.pm index 758e98f..1f4e11a 100644 --- a/C4/Budgets.pm +++ b/C4/Budgets.pm @@ -57,8 +57,6 @@ BEGIN { &AddBudgetPeriod &DelBudgetPeriod - &GetAuthvalueDropbox - &ModBudgetPlan &GetCurrency @@ -401,44 +399,6 @@ sub GetBudgetAuthCats { } # ------------------------------------------------------------------- -sub GetAuthvalueDropbox { - my ( $authcat, $default ) = @_; - my $branch_limit = C4::Context->userenv ? C4::Context->userenv->{"branch"} : ""; - my $dbh = C4::Context->dbh; - - my $query = qq{ - SELECT * - FROM authorised_values - }; - $query .= qq{ - LEFT JOIN authorised_values_branches ON ( id = av_id ) - } if $branch_limit; - $query .= qq{ - WHERE category = ? - }; - $query .= " AND ( branchcode = ? OR branchcode IS NULL )" if $branch_limit; - $query .= " GROUP BY lib ORDER BY category, lib, lib_opac"; - my $sth = $dbh->prepare($query); - $sth->execute( $authcat, $branch_limit ? $branch_limit : () ); - - - my $option_list = []; - my @authorised_values = ( q{} ); - while (my $av = $sth->fetchrow_hashref) { - push @{$option_list}, { - value => $av->{authorised_value}, - label => $av->{lib}, - default => ($default eq $av->{authorised_value}), - }; - } - - if ( @{$option_list} ) { - return $option_list; - } - return; -} - -# ------------------------------------------------------------------- sub GetBudgetPeriods { my ($filters,$orderby) = @_; return SearchInTable("aqbudgetperiods",$filters, $orderby, undef,undef, undef, "wide"); diff --git a/C4/Koha.pm b/C4/Koha.pm index 4202957..09214a5 100644 --- a/C4/Koha.pm +++ b/C4/Koha.pm @@ -1392,6 +1392,44 @@ sub GetNormalizedOCLCNumber { } } +sub GetAuthvalueDropbox { + my ( $authcat, $default ) = @_; + my $branch_limit = C4::Context->userenv ? C4::Context->userenv->{"branch"} : ""; + my $dbh = C4::Context->dbh; + + my $query = qq{ + SELECT * + FROM authorised_values + }; + $query .= qq{ + LEFT JOIN authorised_values_branches ON ( id = av_id ) + } if $branch_limit; + $query .= qq{ + WHERE category = ? + }; + $query .= " AND ( branchcode = ? OR branchcode IS NULL )" if $branch_limit; + $query .= " GROUP BY lib ORDER BY category, lib, lib_opac"; + my $sth = $dbh->prepare($query); + $sth->execute( $authcat, $branch_limit ? $branch_limit : () ); + + + my $option_list = []; + my @authorised_values = ( q{} ); + while (my $av = $sth->fetchrow_hashref) { + push @{$option_list}, { + value => $av->{authorised_value}, + label => $av->{lib}, + default => ($default eq $av->{authorised_value}), + }; + } + + if ( @{$option_list} ) { + return $option_list; + } + return; +} + + =head2 GetDailyQuote($opts) Takes a hashref of options diff --git a/acqui/fetch_sort_dropbox.pl b/acqui/fetch_sort_dropbox.pl index ce47fb7..ee43f98 100755 --- a/acqui/fetch_sort_dropbox.pl +++ b/acqui/fetch_sort_dropbox.pl @@ -24,6 +24,7 @@ use C4::Context; use C4::Output; use C4::Auth; use C4::Budgets; +use C4::Koha; =head1 NAME -- 1.7.9.5