From 9a98b43f3663a56a5575def9076b8d9fdf9a5d64 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Tue, 9 Apr 2019 20:00:16 +0000 Subject: [PATCH] Bug 21946: Display parent-child relationship on smart-rules.pl To test: 1 - Set some itemtypes to have a parent 2 - Browse to Administration -> Circulation and fines rules 3 - Note new description of parent/child relationships at top of page 4 - Note that itemtype dropdown for circ rules shows child types under parents 5 - Set a rule for a child type 6 - Note it displays as Parent->Child 7 - Have three child types under a parent 8 - Set the parent 'Current checkouts allowed' to 3 9 - Set the children 'Current checkouts allowed' to: type1 = 2 type2 = 1 type3 = 1 10 - Create some items of the type above 11 - Note you can checkout 2 of type 1, and not 3 12 - Note you can checkout 1 of type 2, but not 2 13 - Note that you now cannot checkout any of type3 14 - Note you cannot checkout any of the parent type 15 - Return one of the other items and note you can now checkout an item of type3 16 - Return another item and note you can checkout an item of the parent type 17 - Return all 18 - Set the parent type to 1 19 - Now note you can only checkout 1 of any of the children 20 - Set the parent to 0 21 - Note you cannot checkout any of the child types Signed-off-by: Liz Rea Signed-off-by: Lisette Scheer Signed-off-by: Alex Arnaud --- Koha/ItemType.pm | 11 ++ Koha/Template/Plugin/ItemTypes.pm | 7 +- .../prog/en/modules/admin/smart-rules.tt | 36 +++++- t/db_dependent/Koha/ItemTypes.t | 108 +++++++----------- 4 files changed, 94 insertions(+), 68 deletions(-) diff --git a/Koha/ItemType.pm b/Koha/ItemType.pm index f15c00e023..939c97704e 100644 --- a/Koha/ItemType.pm +++ b/Koha/ItemType.pm @@ -153,6 +153,17 @@ sub parent { } +=head3 children_with_localization + + Returns the ItemType objects of the children of this type or undef. + +=cut + +sub children_with_localization { + my ( $self ) = @_; + return Koha::ItemTypes->search_with_localization({ parent_type => $self->itemtype }); +} + =head3 type =cut diff --git a/Koha/Template/Plugin/ItemTypes.pm b/Koha/Template/Plugin/ItemTypes.pm index 20910562b0..5b3cf1edeb 100644 --- a/Koha/Template/Plugin/ItemTypes.pm +++ b/Koha/Template/Plugin/ItemTypes.pm @@ -25,9 +25,12 @@ use base qw( Template::Plugin ); use Koha::ItemTypes; sub GetDescription { - my ( $self, $itemtypecode ) = @_; + my ( $self, $itemtypecode, $want_parent ) = @_; my $itemtype = Koha::ItemTypes->find( $itemtypecode ); - return $itemtype ? $itemtype->translated_description : q{}; + return q{} unless $itemtype; + my $parent; + $parent = $itemtype->parent if $want_parent; + return $parent ? $parent->translated_description . "->" . $itemtype->translated_description : $itemtype->translated_description; } sub Get { diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt index 2b9f4513b2..a36daf5f4a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt @@ -57,6 +57,10 @@
  • default (all libraries), all patron categories, same item type
  • default (all libraries), all patron categories, all item types
  • + +

    Where an itemtype has a parent, the rule will display as "Parent->Child" and the number of + current checkouts allowed will be limited to either the maximum for the parent (counting sibling types) + or the specific rule's type, whichever is less.

    To modify a rule, create a new one with the same patron category and item type.

    @@ -86,7 +90,9 @@ + + @@ -162,6 +168,7 @@ [% IF show_rule %] [% SET row_count = row_count + 1 %] + + + + @@ -432,7 +451,9 @@ + + @@ -943,8 +964,20 @@ [% MACRO jsinclude BLOCK %] [% Asset.js("js/admin-menu.js") | $raw %] + [% INCLUDE 'datatables.inc' %] [% INCLUDE 'calendar.inc' %]
      Patron category  Item type Actions Note
    [% IF ( c == undef ) %]1[% ELSE %]0[% END %] [% IF c == undef %] All @@ -169,11 +176,12 @@ [% Categories.GetName(c) | html %] [% END %] [% IF ( i == undef ) %]1[% ELSE %]0[% END %] [% IF i == undef %] All [% ELSE %] - [% ItemTypes.GetDescription(i) | html %] + [% ItemTypes.GetDescription(i,1) | html %] [% END %] @@ -321,6 +329,7 @@ [% END %] [% END %]
    2 0
      Patron category  Item type   Note