Bugzilla – Attachment 60915 Details for
Bug 17835
Move C4::Koha::GetItemTypes to Koha::ItemTypes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17835: Remove the subroutine GetItemTypes
Bug-17835-Remove-the-subroutine-GetItemTypes.patch (text/plain), 4.95 KB, created by
Jonathan Druart
on 2017-03-08 13:58:45 UTC
(
hide
)
Description:
Bug 17835: Remove the subroutine GetItemTypes
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2017-03-08 13:58:45 UTC
Size:
4.95 KB
patch
obsolete
>From 13b736ead80235554f4fb6c9b1bbb37c0b9071fd Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 3 Jan 2017 11:36:25 +0100 >Subject: [PATCH] Bug 17835: Remove the subroutine GetItemTypes > >At this point the subroutine is no longer in used. > >Signed-off-by: Josef Moravec <josef.moravec@gmail.com> >--- > C4/Koha.pm | 86 +-------------------------------------------------- > t/db_dependent/Koha.t | 11 +------ > 2 files changed, 2 insertions(+), 95 deletions(-) > >diff --git a/C4/Koha.pm b/C4/Koha.pm >index 9f06226..107d839 100644 >--- a/C4/Koha.pm >+++ b/C4/Koha.pm >@@ -41,7 +41,7 @@ BEGIN { > @ISA = qw(Exporter); > @EXPORT = qw( > &GetPrinters &GetPrinter >- &GetItemTypes &getitemtypeinfo >+ &getitemtypeinfo > &GetItemTypesCategorized > &getallthemes > &getFacets >@@ -86,90 +86,6 @@ Koha.pm provides many functions for Koha scripts. > > =cut > >-=head2 GetItemTypes >- >- $itemtypes = &GetItemTypes( style => $style ); >- >-Returns information about existing itemtypes. >- >-Params: >- style: either 'array' or 'hash', defaults to 'hash'. >- 'array' returns an arrayref, >- 'hash' return a hashref with the itemtype value as the key >- >-build a HTML select with the following code : >- >-=head3 in PERL SCRIPT >- >- my $itemtypes = GetItemTypes; >- my @itemtypesloop; >- foreach my $thisitemtype (sort keys %$itemtypes) { >- my $selected = 1 if $thisitemtype eq $itemtype; >- my %row =(value => $thisitemtype, >- selected => $selected, >- description => $itemtypes->{$thisitemtype}->{'description'}, >- ); >- push @itemtypesloop, \%row; >- } >- $template->param(itemtypeloop => \@itemtypesloop); >- >-=head3 in TEMPLATE >- >- <form action='<!-- TMPL_VAR name="script_name" -->' method=post> >- <select name="itemtype"> >- <option value="">Default</option> >- <!-- TMPL_LOOP name="itemtypeloop" --> >- <option value="<!-- TMPL_VAR name="value" -->" <!-- TMPL_IF name="selected" -->selected<!-- /TMPL_IF -->><!-- TMPL_VAR name="description" --></option> >- <!-- /TMPL_LOOP --> >- </select> >- <input type=text name=searchfield value="<!-- TMPL_VAR name="searchfield" -->"> >- <input type="submit" value="OK" class="button"> >- </form> >- >-=cut >- >-sub GetItemTypes { >- my ( %params ) = @_; >- my $style = defined( $params{'style'} ) ? $params{'style'} : 'hash'; >- >- require C4::Languages; >- my $language = C4::Languages::getlanguage(); >- # returns a reference to a hash of references to itemtypes... >- my $dbh = C4::Context->dbh; >- my $query = q| >- SELECT >- itemtypes.itemtype, >- itemtypes.description, >- itemtypes.rentalcharge, >- itemtypes.notforloan, >- itemtypes.imageurl, >- itemtypes.summary, >- itemtypes.checkinmsg, >- itemtypes.checkinmsgtype, >- itemtypes.sip_media_type, >- itemtypes.hideinopac, >- itemtypes.searchcategory, >- COALESCE( localization.translation, itemtypes.description ) AS translated_description >- FROM itemtypes >- LEFT JOIN localization ON itemtypes.itemtype = localization.code >- AND localization.entity = 'itemtypes' >- AND localization.lang = ? >- ORDER BY itemtype >- |; >- my $sth = $dbh->prepare($query); >- $sth->execute( $language ); >- >- if ( $style eq 'hash' ) { >- my %itemtypes; >- while ( my $IT = $sth->fetchrow_hashref ) { >- $itemtypes{ $IT->{'itemtype'} } = $IT; >- } >- return ( \%itemtypes ); >- } else { >- return [ sort { lc $a->{translated_description} cmp lc $b->{translated_description} } @{ $sth->fetchall_arrayref( {} ) } ]; >- } >-} >- > =head2 GetItemTypesCategorized > > $categories = GetItemTypesCategorized(); >diff --git a/t/db_dependent/Koha.t b/t/db_dependent/Koha.t >index feb4a1c..b3f51e0 100644 >--- a/t/db_dependent/Koha.t >+++ b/t/db_dependent/Koha.t >@@ -9,7 +9,7 @@ use Koha::DateUtils qw(dt_from_string); > use Koha::AuthorisedValue; > use Koha::AuthorisedValueCategories; > >-use Test::More tests => 8; >+use Test::More tests => 7; > use DateTime::Format::MySQL; > > BEGIN { >@@ -294,13 +294,4 @@ subtest 'GetItemTypesCategorized test' => sub{ > is_deeply(\@results,\@expected, 'GetItemTypesCategorized: grouped and ungrouped items returned as expected.'); > }; > >-subtest 'GetItemTypes test' => sub { >- plan tests => 1; >- $dbh->do(q|DELETE FROM itemtypes|); >- $dbh->do(q|INSERT INTO itemtypes(itemtype, description) VALUES ('a', 'aa desc'), ('b', 'zz desc'), ('d', 'dd desc'), ('c', 'yy desc')|); >- my $itemtypes = C4::Koha::GetItemTypes( style => 'array' ); >- $itemtypes = [ map { $_->{itemtype} } @$itemtypes ]; >- is_deeply( $itemtypes, [ 'a', 'd', 'c', 'b' ], 'GetItemTypes(array) should return itemtypes ordered by description'); >-}; >- > $dbh->rollback(); >-- >2.9.3
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 17835
:
58561
|
58562
|
58563
|
58564
|
58565
|
58600
|
60033
|
60046
|
60048
|
60049
|
60050
|
60051
|
60052
|
60053
|
60914
|
60915
|
60916
|
60917
|
61695
|
61696
|
61697
|
61698
|
61699
|
61700
|
61966
|
61967
|
61968
|
61969
|
61970
|
61971
|
62156
|
62157
|
62158
|
62159
|
62160
|
62161
|
62162
|
62370
|
62470