@@ -, +, @@
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 | 15 ++-
t/db_dependent/Koha/ItemTypes.t | 108 ++++++++-------------
4 files changed, 73 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
@@ -50,6 +50,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.
@@ -167,7 +171,7 @@
[% IF rule.itemtype == '*' %]
All
[% ELSE %]
- [% ItemTypes.GetDescription(rule.itemtype) | html %]
+ [% ItemTypes.GetDescription(rule.itemtype,1) | html %]
[% END %]