@@ -, +, @@ defining parent types --- Koha/ItemType.pm | 14 ++++ admin/itemtypes.pl | 8 +++ .../prog/en/modules/admin/itemtypes.tt | 77 +++++++++++++++++----- 3 files changed, 84 insertions(+), 15 deletions(-) --- a/Koha/ItemType.pm +++ a/Koha/ItemType.pm @@ -139,6 +139,20 @@ sub _library_limits { }; } +=head3 parent + + Returns the ItemType object of the parent_type or undef. + +=cut + +sub parent { + my ( $self ) = @_; + my $parent_rs = $self->_result->parent_type; + return unless $parent_rs; + return Koha::ItemType->_new_from_dbic( $parent_rs ); + +} + =head3 type =cut --- a/admin/itemtypes.pl +++ a/admin/itemtypes.pl @@ -71,11 +71,16 @@ if ( $op eq 'add_form' ) { }; } + 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 ), @@ -84,6 +89,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') || undef; my $description = $input->param('description'); my $rentalcharge = $input->param('rentalcharge'); my $rentalcharge_daily = $input->param('rentalcharge_daily'); @@ -110,6 +116,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); @@ -141,6 +148,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, --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt @@ -116,6 +116,27 @@ Item types administration [% END %]
Is a parent to another type, cannot have a parent
+ [% ELSE %] + +No available parent types
+ [% END %] +Image | [% END %] -Code | Description | +Code | +Parent code | Search category | Not for loan | Hide in OPAC | @@ -392,24 +414,49 @@ Item types administration [% END %]
+ [% IF itemtype.parent_type %]
+ [% IF itemtype.parent.translated_descriptions.size %]
+ [% itemtype.parent.description | html %] (default) + [% ELSE %] + [% itemtype.parent.description | html %] + [% END %] + + [% IF itemtype.translated_descriptions.size %] + [% itemtype.description | html %] (default) + [% FOR description IN itemtype.translated_descriptions %] + [% IF description.translation == itemtype.translated_description %] + -- [% description.translation | html %] + [% ELSE %] + -- [% description.translation | html %] ([% description.lang | html %]) + [% END %] + + [% END %] + [% ELSE %] + -- [% itemtype.description | html %] + [% END %] + [% ELSE %] + [% IF itemtype.translated_descriptions.size %] + [% itemtype.description | html %] (default) + [% FOR description IN itemtype.translated_descriptions %] + [% IF description.translation == itemtype.translated_description %] + [% description.translation | html %] + [% ELSE %] + [% description.translation | html %] ([% description.lang | html %]) + [% END %] + + [% END %] + [% ELSE %] + [% itemtype.description | html %] + [% END %] + [% END %] + |
+ [% itemtype.itemtype | html %] |
- [% IF itemtype.translated_descriptions.size %]
- [% itemtype.description | html %] (default) - [% FOR description IN itemtype.translated_descriptions %] - [% IF description.translation == itemtype.translated_description %] - [% description.translation | html %] - [% ELSE %] - [% description.translation | html %] ([% description.lang | html %]) - [% END %] - - [% END %] - [% ELSE %] - [% itemtype.description | html %] - [% END %] + [% itemtype.parent_type | html %] |
[% itemtype.searchcategory | html %] | [% IF ( itemtype.notforloan ) %]Yes[% ELSE %] [% END %] | @@ -493,7 +540,7 @@ Item types administration "aoColumnDefs": [ { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false }, ], - "aaSorting": [[ 2, "asc" ]], + "aaSorting": [[ 1, "asc" ]], "iDisplayLength": 10, "sPaginationType": "full" }, columns_settings); --
---|