From 13badf5f5317bad5eaa262951d0ba1e6cb6919e9 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Tue, 2 Apr 2019 14:47:16 +0000 Subject: [PATCH] Bug 21946: Update Administration->Item types to allow for defining parent types To test: 1 - Browse to Administration -> Item types 2 - Not a new colum for prent type 3 - Edit an existing type and not you can select any type (except the current) as a parent 4 - Select one 5 - Edit the type you selected as parent 6 - Note it cannot have a parent defined 7 - Edit a new type, note you can select a parent Signed-off-by: Liz Rea --- admin/itemtypes.pl | 8 +++++++ .../prog/en/modules/admin/itemtypes.tt | 26 +++++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/admin/itemtypes.pl b/admin/itemtypes.pl index 48ddbfaef1..79ee3f1a9d 100755 --- a/admin/itemtypes.pl +++ b/admin/itemtypes.pl @@ -58,11 +58,16 @@ undef($sip_media_type) if defined($sip_media_type) and $sip_media_type =~ /^\s*$ if ( $op eq 'add_form' ) { my $itemtype = Koha::ItemTypes->find($itemtype_code); + my $parent_type = $itemtype ? $itemtype->parent_type : undef; + my $parent_types = Koha::ItemTypes->search({parent_type=>undef,itemtype => {'!='=>$itemtype_code}}); my $imagesets = C4::Koha::getImageSets( checked => ( $itemtype ? $itemtype->imageurl : undef ) ); my $searchcategory = GetAuthorisedValues("ITEMTYPECAT"); my $translated_languages = C4::Languages::getTranslatedLanguages( undef , C4::Context->preference('template') ); $template->param( itemtype => $itemtype, + parent_type => $parent_type, + parent_types => $parent_types, + is_a_parent => $itemtype ? Koha::ItemTypes->search({parent_type=>$itemtype_code})->count : 0, imagesets => $imagesets, searchcategory => $searchcategory, can_be_translated => ( scalar(@$translated_languages) > 1 ? 1 : 0 ), @@ -70,6 +75,7 @@ if ( $op eq 'add_form' ) { } elsif ( $op eq 'add_validate' ) { my $is_a_modif = $input->param('is_a_modif'); my $itemtype = Koha::ItemTypes->find($itemtype_code); + my $parent_type = $input->param('parent_type'); my $description = $input->param('description'); my $rentalcharge = $input->param('rentalcharge'); my $rentalcharge_daily = $input->param('rentalcharge_daily'); @@ -93,6 +99,7 @@ if ( $op eq 'add_form' ) { if ( $itemtype and $is_a_modif ) { # it's a modification $itemtype->description($description); + $itemtype->parent_type($parent_type); $itemtype->rentalcharge($rentalcharge); $itemtype->rentalcharge_daily($rentalcharge_daily); $itemtype->rentalcharge_hourly($rentalcharge_hourly); @@ -119,6 +126,7 @@ if ( $op eq 'add_form' ) { { itemtype => $itemtype_code, description => $description, + parent_type => $parent_type, rentalcharge => $rentalcharge, rentalcharge_daily => $rentalcharge_daily, rentalcharge_hourly => $rentalcharge_hourly, diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt index 703f9ff7ba..2e8a06a3f2 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt @@ -96,7 +96,7 @@ Item types administration [% IF itemtype %]

Modify item type

[% ELSE %] -

Add item type

+ ]

Add item type

[% END %]
@@ -115,6 +115,26 @@ Item types administration [% END %]
  • + + [% IF !is_a_parent && parent_types %] + + [% ELSIF is_a_parent %] + +

    Is a parent to another type, cannot have a parent

    + [% ELSE %] + +

    No available parent types

    + [% END %] +
  • +
  • Required [% IF can_be_translated %] @@ -336,6 +356,7 @@ Item types administration [% UNLESS Koha.Preference('noItemTypeImages') %]Image[% END %] Code + Parent code Description Search category Not for loan @@ -362,6 +383,9 @@ Item types administration + [% itemtype.parent_type | html %] + + [% IF itemtype.translated_descriptions.size %] [% itemtype.description | html %] (default)
    [% FOR description IN itemtype.translated_descriptions %] -- 2.11.0