From 8b995f94d99d057db9ceea3ad46a4c2ed648d320 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 11 Jul 2016 22:06:46 +0100 Subject: [PATCH] Bug 16908: Koha::Patrons - Remove GetSortDetails This subroutine was only used in one script and its job is the same as GetAuthorisedValueByCode. It's better to use the AuthorisedValues TT plugin to retrieve AV descriptions. Test plan: Edit a patron with sort1 and/or sort2 defined. On the patron details page (members/moremember.pl) you should see the sort1 and/or sort2 info displayed. --- C4/Members.pm | 26 ---------------------- admin/aqbudgets.pl | 2 +- .../prog/en/modules/members/moremember.tt | 4 ++-- members/moremember.pl | 4 ---- t/db_dependent/Koha.t | 13 ++--------- 5 files changed, 5 insertions(+), 44 deletions(-) diff --git a/C4/Members.pm b/C4/Members.pm index f9b3942..eb45ee5 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -71,7 +71,6 @@ BEGIN { &GetNoticeEmailAddress &GetAge - &GetSortDetails &GetTitles &GetHideLostItemsPreference @@ -1599,31 +1598,6 @@ sub SetAge{ return $borrower; } # sub SetAge -=head2 GetSortDetails (OUEST-PROVENCE) - - ($lib) = &GetSortDetails($category,$sortvalue); - -Returns the authorized value details -C<&$lib>return value of authorized value details -C<&$sortvalue>this is the value of authorized value -C<&$category>this is the value of authorized value category - -=cut - -sub GetSortDetails { - my ( $category, $sortvalue ) = @_; - my $dbh = C4::Context->dbh; - my $query = qq|SELECT lib - FROM authorised_values - WHERE category=? - AND authorised_value=? |; - my $sth = $dbh->prepare($query); - $sth->execute( $category, $sortvalue ); - my $lib = $sth->fetchrow; - return ($lib) if ($lib); - return ($sortvalue) unless ($lib); -} - =head2 MoveMemberToDeleted $result = &MoveMemberToDeleted($borrowernumber); diff --git a/admin/aqbudgets.pl b/admin/aqbudgets.pl index 0e6b744..1968fa8 100755 --- a/admin/aqbudgets.pl +++ b/admin/aqbudgets.pl @@ -30,7 +30,7 @@ use C4::Branch; # GetBranches use C4::Auth; use C4::Acquisition; use C4::Budgets; -use C4::Members; # calls GetSortDetails() +use C4::Members; use C4::Context; use C4::Output; use C4::Koha; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt index 710cb16..0f34964 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt @@ -390,8 +390,8 @@ function validate1(date) { [% END %] - [% IF ( sort1 ) %]
  • Sort field 1:[% lib1 %]
  • [% END %] - [% IF ( sort2 ) %]
  • Sort field 2:[% lib2 %]
  • [% END %] + [% IF ( sort1 ) %]
  • Sort field 1:[% AuthorisedValues.GetByCode('Bsort1', sort1) %]
  • [% END %] + [% IF ( sort2 ) %]
  • Sort field 2:[% AuthorisedValues.GetByCode('Bsort2', sort2) %]
  • [% END %]
  • Username: [% userid %]
  • Password: [% IF ( password ) %] diff --git a/members/moremember.pl b/members/moremember.pl index e7c54f4..b94b0c2 100755 --- a/members/moremember.pl +++ b/members/moremember.pl @@ -209,10 +209,6 @@ my $library = Koha::Libraries->find( $data->{branchcode})->unblessed; @{$data}{keys %$library} = values %$library; # merge in all branch columns my ( $total, $accts, $numaccts) = GetMemberAccountRecords( $borrowernumber ); -my $lib1 = &GetSortDetails( "Bsort1", $data->{'sort1'} ); -my $lib2 = &GetSortDetails( "Bsort2", $data->{'sort2'} ); -$template->param( lib1 => $lib1 ) if ($lib1); -$template->param( lib2 => $lib2 ) if ($lib2); # If printing a page, send the account informations to the template if ($print eq "page") { diff --git a/t/db_dependent/Koha.t b/t/db_dependent/Koha.t index 82fdc5e..1fab9db 100644 --- a/t/db_dependent/Koha.t +++ b/t/db_dependent/Koha.t @@ -21,7 +21,7 @@ $dbh->{AutoCommit} = 0; $dbh->{RaiseError} = 1; subtest 'Authorized Values Tests' => sub { - plan tests => 7; + plan tests => 4; my $data = { category => 'CATEGORY', @@ -46,18 +46,9 @@ subtest 'Authorized Values Tests' => sub { # Tests SKIP: { - skip "INSERT failed", 4 unless $insert_success; + skip "INSERT failed", 1 unless $insert_success; is ( GetAuthorisedValueByCode($data->{category}, $data->{authorised_value}), $data->{lib}, "GetAuthorisedValueByCode" ); - - my $sortdet=C4::Members::GetSortDetails("lost", "3"); - is ($sortdet, "Lost and Paid For", "lost and paid works"); - - my $sortdet2=C4::Members::GetSortDetails("loc", "child"); - is ($sortdet2, "Children's Area", "Child area works"); - - my $sortdet3=C4::Members::GetSortDetails("withdrawn", "1"); - is ($sortdet3, "Withdrawn", "Withdrawn works"); } # Clean up -- 2.8.1