<li>default (all libraries), all patron categories, same item type</li>
<li>default (all libraries), all patron categories, all item types</li>
</ul>
+
+ <p>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.</p>
<p>To modify a rule, create a new one with the same patron category and item type.</p>
</div>
<div>
<table id="default-circulation-rules">
<thead>
<tr>
+ <th> </th>
<th>Patron category</th>
+ <th> </th>
<th>Item type</th>
<th>Actions</th>
<th>Note</th>
[% IF show_rule %]
[% SET row_count = row_count + 1 %]
<tr row_countd="row_[% row_count | html %]">
+ <td>[% IF ( c == undef ) %]1[% ELSE %]0[% END %]</td>
<td>
[% IF c == undef %]
<em>All</em>
[% Categories.GetName(c) | html %]
[% END %]
</td>
+ <td>[% IF ( i == undef ) %]1[% ELSE %]0[% END %]</td>
<td>
[% IF i == undef %]
<em>All</em>
[% ELSE %]
- [% ItemTypes.GetDescription(i) | html %]
+ [% ItemTypes.GetDescription(i,1) | html %]
[% END %]
</td>
<td class="actions">
[% END %]
[% END %]
<tr id="edit_row">
+ <td>2</td>
<td>
<select name="categorycode" id="categorycode">
<option value="*">All</option>
[% END %]
</select>
</td>
+ <td>0</td>
<td>
<select name="itemtype" id="matrixitemtype" style="width:13em;">
<option value="*">All</option>
[% FOREACH itemtypeloo IN itemtypeloop %]
+ [% NEXT IF itemtypeloo.parent_type %]
<option value="[% itemtypeloo.itemtype | html %]">[% itemtypeloo.translated_description | html %]</option>
+ [% SET children = itemtypeloo.children_with_localization %]
+ [% IF children %]
+ <optgroup>
+ [% FOREACH child IN children %]
+ <option value="[% child.itemtype | html %]">[% child.translated_description | html %]</option>
+ [% END %]
+ </optgroup>
+ [% END %]
[% END %]
</select>
</td>
</tr>
<tfoot>
<tr>
+ <th> </th>
<th>Patron category</th>
+ <th> </th>
<th>Item type</th>
<th> </th>
<th>Note</th>
[% MACRO jsinclude BLOCK %]
[% Asset.js("js/admin-menu.js") | $raw %]
+ [% INCLUDE 'datatables.inc' %]
[% INCLUDE 'calendar.inc' %]
<script>
+ $(document).ready(function() {
+ $("#default-circulation-rules").dataTable($.extend(true,{},dataTablesDefaults, {
+ "aoColumnDefs": [
+ { "bVisible": false, "aTargets": [ 0,2 ] },
+ { "bSortable": false, "aTargets": ["_all"] }
+ ],
+ "aaSortingFixed": [ [0,'asc'], [1,'asc'], [2,'asc'], [3,'asc'] ],
+ "bPaginate": false,
+ "bAutoWidth": false
+ }));
+ });
function clear_edit(){
var cancel = confirm(_("Are you sure you want to cancel your changes?"));
// select the corresponding option
$(current_column).find("select option").each(function(){
opt = $(this).text().toLowerCase();
+ itm = itm.replace(/.*->(.*)/,"$1"); //If item type is part of a group we need to clear the parent description
opt = opt.replace(/^\s*|\s*$/g,'');
if ( opt == itm.toLowerCase() ) {
$(this).attr('selected', 'selected');
use Modern::Perl;
use Data::Dumper;
-use Test::More tests => 24;
+use Test::More tests => 13;
use t::lib::Mocks;
use t::lib::TestBuilder;
my $database = Koha::Database->new();
my $schema = $database->schema();
$schema->txn_begin;
-Koha::ItemTypes->delete;
-Koha::ItemType->new(
- {
- itemtype => 'type1',
- description => 'description',
- rentalcharge => '0.00',
- imageurl => 'imageurl',
- summary => 'summary',
- checkinmsg => 'checkinmsg',
- checkinmsgtype => 'checkinmsgtype',
- processfee => '0.00',
- defaultreplacecost => '0.00',
- }
-)->store;
-
-Koha::ItemType->new(
- {
- itemtype => 'type2',
- description => 'description',
- rentalcharge => '0.00',
- imageurl => 'imageurl',
- summary => 'summary',
- checkinmsg => 'checkinmsg',
- checkinmsgtype => 'checkinmsgtype',
- processfee => '0.00',
- defaultreplacecost => '0.00',
- }
-)->store;
-
-Koha::ItemType->new(
- {
- itemtype => 'type3',
- description => 'description',
- rentalcharge => '0.00',
- imageurl => 'imageurl',
- summary => 'summary',
- checkinmsg => 'checkinmsg',
- checkinmsgtype => 'checkinmsgtype',
- processfee => '0.00',
- defaultreplacecost => '0.00',
- }
-)->store;
+my $builder = t::lib::TestBuilder->new;
+my $initial_count = Koha::ItemTypes->search->count;
+
+my $parent1 = $builder->build_object({ class => 'Koha::ItemTypes', value => { description => 'description' } });
+my $child1 = $builder->build_object({
+ class => 'Koha::ItemTypes',
+ value => {
+ parent_type => $parent1->itemtype,
+ description => 'description',
+ }
+ });
+my $child2 = $builder->build_object({
+ class => 'Koha::ItemTypes',
+ value => {
+ parent_type => $parent1->itemtype,
+ description => 'description',
+ }
+ });
+my $child3 = $builder->build_object({
+ class => 'Koha::ItemTypes',
+ value => {
+ parent_type => $parent1->itemtype,
+ description => 'description',
+ }
+ });
Koha::Localization->new(
{
entity => 'itemtypes',
- code => 'type1',
+ code => $child1->itemtype,
lang => 'en',
translation => 'b translated itemtype desc'
}
Koha::Localization->new(
{
entity => 'itemtypes',
- code => 'type2',
+ code => $child2->itemtype,
lang => 'en',
translation => 'a translated itemtype desc'
}
Koha::Localization->new(
{
entity => 'something_else',
- code => 'type2',
+ code => $child2->itemtype,
lang => 'en',
translation => 'another thing'
}
)->store;
-my $type = Koha::ItemTypes->find('type1');
+my $type = Koha::ItemTypes->find($child1->itemtype);
ok( defined($type), 'first result' );
-is( $type->itemtype, 'type1', 'itemtype/code' );
-is( $type->description, 'description', 'description' );
-is( $type->rentalcharge+0, 0, 'rentalcharge' );
-is( $type->imageurl, 'imageurl', 'imageurl' );
-is( $type->summary, 'summary', 'summary' );
-is( $type->checkinmsg, 'checkinmsg', 'checkinmsg' );
-is( $type->checkinmsgtype, 'checkinmsgtype', 'checkinmsgtype' );
-
-$type = Koha::ItemTypes->find('type2');
+is_deeply( $type->unblessed, $child1->unblessed, "We got back the same object" );
+
+$type = Koha::ItemTypes->find($child2->itemtype);
ok( defined($type), 'second result' );
-is( $type->itemtype, 'type2', 'itemtype/code' );
-is( $type->description, 'description', 'description' );
-is( $type->rentalcharge+0, 0, 'rentalcharge' );
-is( $type->imageurl, 'imageurl', 'imageurl' );
-is( $type->summary, 'summary', 'summary' );
-is( $type->checkinmsg, 'checkinmsg', 'checkinmsg' );
-is( $type->checkinmsgtype, 'checkinmsgtype', 'checkinmsgtype' );
+is_deeply( $type->unblessed, $child2->unblessed, "We got back the same object" );
t::lib::Mocks::mock_preference('language', 'en');
t::lib::Mocks::mock_preference('opaclanguages', 'en');
my $itemtypes = Koha::ItemTypes->search_with_localization;
-is( $itemtypes->count, 3, 'There are 3 item types' );
+is( $itemtypes->count, $initial_count + 4, 'We added 4 item types' );
my $first_itemtype = $itemtypes->next;
is(
$first_itemtype->translated_description,
'item types should be sorted by translated description'
);
-my $builder = t::lib::TestBuilder->new;
+my $children = $parent1->children_with_localization;
+my $first_child = $children->next;
+is(
+ $first_child->translated_description,
+ 'a translated itemtype desc',
+ 'item types should be sorted by translated description'
+);
+
my $item_type = $builder->build_object({ class => 'Koha::ItemTypes' });
is( $item_type->can_be_deleted, 1, 'An item type that is not used can be deleted');