Bugzilla – Attachment 62449 Details for
Bug 18433
Allow to select results to export in item search
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18433: Remove Koha::AuthorisedValueCategories::find_by_koha_field
Bug-18433-Remove-KohaAuthorisedValueCategoriesfind.patch (text/plain), 9.17 KB, created by
Julian Maurice
on 2017-04-20 09:07:08 UTC
(
hide
)
Description:
Bug 18433: Remove Koha::AuthorisedValueCategories::find_by_koha_field
Filename:
MIME Type:
Creator:
Julian Maurice
Created:
2017-04-20 09:07:08 UTC
Size:
9.17 KB
patch
obsolete
>From f2b90ba2ee9325cf57ad6cfb5de17ada5adf33fd Mon Sep 17 00:00:00 2001 >From: Julian Maurice <julian.maurice@biblibre.com> >Date: Thu, 20 Apr 2017 11:04:48 +0200 >Subject: [PATCH] Bug 18433: Remove > Koha::AuthorisedValueCategories::find_by_koha_field > >Use Koha::AuthorisedValues::*_by_koha_field instead >--- > Koha/AuthorisedValueCategories.pm | 22 -------- > Koha/Template/Plugin/AuthorisedValues.pm | 12 +++++ > catalogue/itemsearch.pl | 15 ++---- > .../en/includes/catalogue/itemsearch_item.csv.inc | 4 +- > .../prog/en/modules/catalogue/itemsearch.tt | 22 +++----- > t/db_dependent/Koha/AuthorisedValueCategories.t | 59 ---------------------- > 6 files changed, 26 insertions(+), 108 deletions(-) > delete mode 100755 t/db_dependent/Koha/AuthorisedValueCategories.t > >diff --git a/Koha/AuthorisedValueCategories.pm b/Koha/AuthorisedValueCategories.pm >index 767cb92408..cae1581fc4 100644 >--- a/Koha/AuthorisedValueCategories.pm >+++ b/Koha/AuthorisedValueCategories.pm >@@ -36,28 +36,6 @@ Koha::AuthorisedValueCategories - Koha AuthorisedValueCategory Object set class > > =cut > >-=head3 find_by_koha_field >- >- my $category = Koha::AuthorisedValueCategories->find_by_koha_field($kohafield, [$frameworkcode]); >- >-Returns the authorised value category linked to the given koha field >- >-=cut >- >-sub find_by_koha_field { >- my ($class, $kohafield, $frameworkcode) = @_; >- >- $frameworkcode //= ''; >- >- my ($subfield) = Koha::MarcSubfieldStructures->search({ >- frameworkcode => $frameworkcode, >- kohafield => $kohafield, >- authorised_value => { not => undef }, >- }); >- >- return $subfield ? $class->find($subfield->authorised_value) : undef; >-} >- > =head3 type > > =cut >diff --git a/Koha/Template/Plugin/AuthorisedValues.pm b/Koha/Template/Plugin/AuthorisedValues.pm >index 0ab30cb5e7..d59eb8f1fd 100644 >--- a/Koha/Template/Plugin/AuthorisedValues.pm >+++ b/Koha/Template/Plugin/AuthorisedValues.pm >@@ -84,6 +84,18 @@ sub GetDescriptionByKohaField { > return $description ? $description->{lib} : $authorised_value; > } > >+sub GetDescriptionsByKohaField { >+ my ( $self, $params ) = @_; >+ >+ my $frameworkcode = $params->{frameworkcode} || ''; >+ my $kohafield = $params->{kohafield}; >+ >+ return Koha::AuthorisedValues->get_descriptions_by_koha_field({ >+ frameworkcode => $frameworkcode, >+ kohafield => $kohafield, >+ }); >+} >+ > 1; > > =head1 NAME >diff --git a/catalogue/itemsearch.pl b/catalogue/itemsearch.pl >index bec0ff6b20..9c5b401a26 100755 >--- a/catalogue/itemsearch.pl >+++ b/catalogue/itemsearch.pl >@@ -27,7 +27,7 @@ use C4::Items; > use C4::Biblio; > use C4::Koha; > >-use Koha::AuthorisedValueCategories; >+use Koha::AuthorisedValues; > use Koha::Item::Search::Field qw(GetItemSearchFields); > use Koha::ItemTypes; > use Koha::Libraries; >@@ -247,15 +247,10 @@ foreach my $itemtype ( Koha::ItemTypes->search ) { > }; > } > >-my $ccode_avcategory = Koha::AuthorisedValueCategories->find_by_koha_field('items.ccode'); >-my $ccode_avcode = $ccode_avcategory ? $ccode_avcategory->category_name : 'CCODE'; >-my $ccodes = GetAuthorisedValues($ccode_avcode); >-my @ccodes; >-foreach my $ccode (@$ccodes) { >- push @ccodes, { >- value => $ccode->{authorised_value}, >- label => $ccode->{lib}, >- }; >+my @ccodes = Koha::AuthorisedValues->get_descriptions_by_koha_field({ kohafield => 'items.ccode' }); >+foreach my $ccode (@ccodes) { >+ $ccode->{value} = $ccode->{authorised_value}, >+ $ccode->{label} = $ccode->{lib}, > } > > my @items_search_fields = GetItemSearchFields(); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/catalogue/itemsearch_item.csv.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/catalogue/itemsearch_item.csv.inc >index aeef03ed14..10ec21a743 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/catalogue/itemsearch_item.csv.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/catalogue/itemsearch_item.csv.inc >@@ -3,6 +3,4 @@ > [%- USE AuthorisedValues -%] > [%- biblio = item.biblio -%] > [%- biblioitem = item.biblioitem -%] >-[%- notforloan_avcategory = AuthorisedValues.GetCategoryByKohaField('items.notforloan') -%] >-[%- location_avcategory = AuthorisedValues.GetCategoryByKohaField('items.location') -%] >-"[% biblio.title |html %] [% IF ( Koha.Preference( 'marcflavour' ) == 'UNIMARC' && biblio.author ) %]by [% END %][% biblio.author |html %]", "[% (biblioitem.publicationyear || biblio.copyrightdate) |html %]", "[% biblioitem.publishercode |html %]", "[% biblioitem.collectiontitle |html %]", "[% item.barcode |html %]", "[% item.itemcallnumber |html %]", "[% Branches.GetName(item.homebranch) |html %]", "[% Branches.GetName(item.holdingbranch) |html %]", "[% IF location_avcategory %][% AuthorisedValues.GetByCode(location_avcategory, item.location) |html %][% ELSE %][% item.location |html %][% END %]", "[% item.stocknumber |html %]", "[% IF notforloan_avcategory %][% AuthorisedValues.GetByCode(notforloan_avcategory, item.notforloan) |html %][% ELSE %][% item.notforloan |html %][% END %]", "[% (item.issues || 0) |html %]" >+"[% biblio.title |html %] [% IF ( Koha.Preference( 'marcflavour' ) == 'UNIMARC' && biblio.author ) %]by [% END %][% biblio.author |html %]", "[% (biblioitem.publicationyear || biblio.copyrightdate) |html %]", "[% biblioitem.publishercode |html %]", "[% biblioitem.collectiontitle |html %]", "[% item.barcode |html %]", "[% item.itemcallnumber |html %]", "[% Branches.GetName(item.homebranch) |html %]", "[% Branches.GetName(item.holdingbranch) |html %]", "[% AuthorisedValues.GetDescriptionByKohaField( frameworkcode => biblio.frameworkcode, kohafield => 'items.location', authorised_value => item.location) |html %]", "[% item.stocknumber |html %]", "[% AuthorisedValues.GetDescriptionByKohaField(frameworkcode => biblio.frameworkcode, kohafield => 'items.notforloan', authorised_value => item.notforloan) |html %]", "[% (item.issues || 0) |html %]" >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt >index e721da65d3..e572415e39 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt >@@ -156,22 +156,16 @@ > </div> > [% END %] > >-[% notforloan_avcategory = AuthorisedValues.GetCategoryByKohaField('items.notforloan') %] >-[% IF notforloan_avcategory %] >- [% notforloans = AuthorisedValues.Get(notforloan_avcategory) %] >- [% FOREACH nfl IN notforloans %] >- [% nfl.value = nfl.authorised_value %] >- [% nfl.label = nfl.lib %] >- [% END %] >+[% notforloans = AuthorisedValues.GetDescriptionsByKohaField({ kohafield = 'items.notforloan' }) %] >+[% FOREACH nfl IN notforloans %] >+ [% nfl.value = nfl.authorised_value %] >+ [% nfl.label = nfl.lib %] > [% END %] > >-[% location_avcategory = AuthorisedValues.GetCategoryByKohaField('items.location') %] >-[% IF location_avcategory %] >- [% locations = AuthorisedValues.Get(location_avcategory) %] >- [% FOREACH loc IN locations %] >- [% loc.value = loc.authorised_value %] >- [% loc.label = loc.lib %] >- [% END %] >+[% locations = AuthorisedValues.GetDescriptionsByKohaField({ kohafield = 'items.location' }) %] >+[% FOREACH loc IN locations %] >+ [% loc.value = loc.authorised_value %] >+ [% loc.label = loc.lib %] > [% END %] > > [%# Page starts here %] >diff --git a/t/db_dependent/Koha/AuthorisedValueCategories.t b/t/db_dependent/Koha/AuthorisedValueCategories.t >deleted file mode 100755 >index 99735ac24c..0000000000 >--- a/t/db_dependent/Koha/AuthorisedValueCategories.t >+++ /dev/null >@@ -1,59 +0,0 @@ >-#!/usr/bin/perl >- >-# Copyright 2017 BibLibre >-# >-# This file is part of Koha >-# >-# Koha is free software; you can redistribute it and/or modify it >-# under the terms of the GNU General Public License as published by >-# the Free Software Foundation; either version 3 of the License, or >-# (at your option) any later version. >-# >-# Koha is distributed in the hope that it will be useful, but >-# WITHOUT ANY WARRANTY; without even the implied warranty of >-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >-# GNU General Public License for more details. >-# >-# You should have received a copy of the GNU General Public License >-# along with Koha; if not, see <http://www.gnu.org/licenses>. >- >-use Modern::Perl; >- >-use Test::More tests => 3; >- >-use Koha::MarcSubfieldStructures; >-use Koha::Database; >- >-use t::lib::TestBuilder; >- >-BEGIN { >- use_ok('Koha::AuthorisedValueCategories'); >-} >- >-my $schema = Koha::Database->new->schema; >-$schema->storage->txn_begin; >- >-my $category = Koha::AuthorisedValueCategories->find_or_create({ >- category_name => 'TEST', >-}); >- >-Koha::MarcSubfieldStructures->search({ >- frameworkcode => '', >- kohafield => 'items.notforloan', >-})->delete(); >- >-my $subfield = Koha::MarcSubfieldStructures->find_or_create({ >- frameworkcode => '', >- tagfield => 999, >- tagsubfield => 9, >-}); >-$subfield->authorised_value($category->category_name) >- ->kohafield('items.notforloan') >- ->store(); >- >-my $result = Koha::AuthorisedValueCategories->find_by_koha_field('items.notforloan'); >- >-isa_ok($result, 'Koha::AuthorisedValueCategory', 'Result found'); >-is($result->category_name, $category->category_name, 'Result is correct'); >- >-$schema->storage->txn_rollback; >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 18433
:
62170
|
62181
|
62358
|
62388
|
62389
|
62390
|
62415
|
62416
|
62417
|
62449
|
62472
|
95380
|
97479
|
99123
|
99124
|
99159
|
99160
|
99161
|
99162