@@ -, +, @@ smart-rules.pl 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 --- 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(-) --- a/Koha/ItemType.pm +++ a/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 --- a/Koha/Template/Plugin/ItemTypes.pm +++ a/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 { --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt @@ -57,6 +57,10 @@
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.
Patron category | +Item type | Actions | Note | @@ -162,6 +168,7 @@ [% IF show_rule %] [% SET row_count = row_count + 1 %]||
---|---|---|---|---|---|
[% 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 | @@ -432,7 +451,9 @@ | ||
Patron category | +Item type | Note | @@ -943,8 +964,20 @@ [% MACRO jsinclude BLOCK %] [% Asset.js("js/admin-menu.js") | $raw %] + [% INCLUDE 'datatables.inc' %] [% INCLUDE 'calendar.inc' %]