From 97e71d1a528076f4bf8b61b2fb7e2a8f61118fc3 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 10 Feb 2016 10:20:01 +0000 Subject: [PATCH] Bug 15783: AddAuthorisedValue - Replace existing calls MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The C4::Koha::AddAuthorisedValue is only called twice from reports/guided_reports.pl and insert an authorised value. This job can be achieve easily using the Koha::AuthorisedValue module. Test plan: 1/ Create a new guided report 2/ Use an existing group and/or subgroup of reports 3/ Save 4/ Update an existing report 5/ Use an existing group and/or subgroup of reports 6/ Save 7/ Create or update an existing report 8/ Remove its assigned group and subgroup 9/ Save Signed-off-by: Marc VĂ©ron --- reports/guided_reports.pl | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/reports/guided_reports.pl b/reports/guided_reports.pl index 6a03e11..8701085 100755 --- a/reports/guided_reports.pl +++ b/reports/guided_reports.pl @@ -33,6 +33,7 @@ use C4::Koha qw/IsAuthorisedValueCategory GetFrameworksLoop/; use C4::Context; use C4::Log; use Koha::DateUtils qw/dt_from_string output_pref/; +use Koha::AuthorisedValue; =head1 NAME @@ -998,12 +999,21 @@ sub create_non_existing_group_and_subgroup { my $report_groups = C4::Reports::Guided::get_report_groups; if (not exists $report_groups->{$group}) { my $groupdesc = $input->param('groupdesc') // $group; - C4::Koha::AddAuthorisedValue('REPORT_GROUP', $group, $groupdesc); + Koha::AuthorisedValue->new({ + category => 'REPORT_GROUP', + authorised_value => $group, + lib => $groupdesc, + })->store; } if (defined $subgroup and $subgroup ne '') { if (not exists $report_groups->{$group}->{subgroups}->{$subgroup}) { my $subgroupdesc = $input->param('subgroupdesc') // $subgroup; - C4::Koha::AddAuthorisedValue('REPORT_SUBGROUP', $subgroup, $subgroupdesc, $group); + Koha::AuthorisedValue->new({ + category => 'REPORT_SUBGROUP', + authorised_value => $subgroup, + lib => $subgroupdesc, + lib_opac => $group, + })->store; } } } -- 1.7.10.4