View | Details | Raw Unified | Return to bug 21946
Collapse All | Expand All

(-)a/Koha/ItemType.pm (+14 lines)
Lines 139-144 sub _library_limits { Link Here
139
    };
139
    };
140
}
140
}
141
141
142
=head3 parent
143
144
    Returns the ItemType object of the parent_type or undef.
145
146
=cut
147
148
sub parent {
149
    my ( $self ) = @_;
150
    my $parent_rs = $self->_result->parent_type;
151
    return unless $parent_rs;
152
    return Koha::ItemType->_new_from_dbic( $parent_rs );
153
154
}
155
142
=head3 type
156
=head3 type
143
157
144
=cut
158
=cut
(-)a/admin/itemtypes.pl (+8 lines)
Lines 71-81 if ( $op eq 'add_form' ) { Link Here
71
        };
71
        };
72
    }
72
    }
73
73
74
    my $parent_type = $itemtype ? $itemtype->parent_type : undef;
75
    my $parent_types = Koha::ItemTypes->search({parent_type=>undef,itemtype => {'!='=>$itemtype_code}});
74
    my $imagesets = C4::Koha::getImageSets( checked => ( $itemtype ? $itemtype->imageurl : undef ) );
76
    my $imagesets = C4::Koha::getImageSets( checked => ( $itemtype ? $itemtype->imageurl : undef ) );
75
    my $searchcategory = GetAuthorisedValues("ITEMTYPECAT");
77
    my $searchcategory = GetAuthorisedValues("ITEMTYPECAT");
76
    my $translated_languages = C4::Languages::getTranslatedLanguages( undef , C4::Context->preference('template') );
78
    my $translated_languages = C4::Languages::getTranslatedLanguages( undef , C4::Context->preference('template') );
77
    $template->param(
79
    $template->param(
78
        itemtype  => $itemtype,
80
        itemtype  => $itemtype,
81
        parent_type => $parent_type,
82
        parent_types => $parent_types,
83
        is_a_parent => $itemtype ? Koha::ItemTypes->search({parent_type=>$itemtype_code})->count : 0,
79
        imagesets => $imagesets,
84
        imagesets => $imagesets,
80
        searchcategory => $searchcategory,
85
        searchcategory => $searchcategory,
81
        can_be_translated => ( scalar(@$translated_languages) > 1 ? 1 : 0 ),
86
        can_be_translated => ( scalar(@$translated_languages) > 1 ? 1 : 0 ),
Lines 84-89 if ( $op eq 'add_form' ) { Link Here
84
} elsif ( $op eq 'add_validate' ) {
89
} elsif ( $op eq 'add_validate' ) {
85
    my $is_a_modif   = $input->param('is_a_modif');
90
    my $is_a_modif   = $input->param('is_a_modif');
86
    my $itemtype     = Koha::ItemTypes->find($itemtype_code);
91
    my $itemtype     = Koha::ItemTypes->find($itemtype_code);
92
    my $parent_type  = $input->param('parent_type') || undef;
87
    my $description  = $input->param('description');
93
    my $description  = $input->param('description');
88
    my $rentalcharge = $input->param('rentalcharge');
94
    my $rentalcharge = $input->param('rentalcharge');
89
    my $rentalcharge_daily = $input->param('rentalcharge_daily');
95
    my $rentalcharge_daily = $input->param('rentalcharge_daily');
Lines 110-115 if ( $op eq 'add_form' ) { Link Here
110
116
111
    if ( $itemtype and $is_a_modif ) {    # it's a modification
117
    if ( $itemtype and $is_a_modif ) {    # it's a modification
112
        $itemtype->description($description);
118
        $itemtype->description($description);
119
        $itemtype->parent_type($parent_type);
113
        $itemtype->rentalcharge($rentalcharge);
120
        $itemtype->rentalcharge($rentalcharge);
114
        $itemtype->rentalcharge_daily($rentalcharge_daily);
121
        $itemtype->rentalcharge_daily($rentalcharge_daily);
115
        $itemtype->rentalcharge_hourly($rentalcharge_hourly);
122
        $itemtype->rentalcharge_hourly($rentalcharge_hourly);
Lines 141-146 if ( $op eq 'add_form' ) { Link Here
141
            {
148
            {
142
                itemtype            => $itemtype_code,
149
                itemtype            => $itemtype_code,
143
                description         => $description,
150
                description         => $description,
151
                parent_type         => $parent_type,
144
                rentalcharge        => $rentalcharge,
152
                rentalcharge        => $rentalcharge,
145
                rentalcharge_daily  => $rentalcharge_daily,
153
                rentalcharge_daily  => $rentalcharge_daily,
146
                rentalcharge_hourly => $rentalcharge_hourly,
154
                rentalcharge_hourly => $rentalcharge_hourly,
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt (-16 / +62 lines)
Lines 115-120 Item types administration Link Here
115
                        <input type="text" id="itemtype" name="itemtype" size="10" maxlength="10" required="required" /> <span class="required">Required</span>
115
                        <input type="text" id="itemtype" name="itemtype" size="10" maxlength="10" required="required" /> <span class="required">Required</span>
116
                    </li>
116
                    </li>
117
                [% END %]
117
                [% END %]
118
                <li>
119
                    <label for="parent_type">Parent item type: </label>
120
                    [% IF !is_a_parent && parent_types %]
121
                    <select name="parent_type" id="parent_type">
122
                        <option value="">None</option>
123
                        [% FOREACH pt IN parent_types %]
124
                            [% IF parent_type == pt.itemtype %]
125
                                <option value="[% pt.itemtype | html %]" selected="selected">[% pt.description | html %]</option>
126
                            [% ELSE %]
127
                                <option value="[% pt.itemtype | html %]">[% pt.description | html %]</option>
128
                            [% END %]
129
                        [% END %]
130
                    </select>
131
                    [% ELSIF is_a_parent %]
132
                    <input type="text" id="parent_type" value="[% parent_type | html %]" name="parent_type" size="10" maxlength="10" disabled/>
133
                    <p>Is a parent to another type, cannot have a parent</p>
134
                    [% ELSE %]
135
                    <input type="text" id="parent_type" value="[% parent_type | html %]" name="parent_type" size="10" maxlength="10" disabled/>
136
                    <p>No available parent types</p>
137
                    [% END %]
138
                </li>
118
                <li>
139
                <li>
119
                    <label for="description" class="required">Description: </label>
140
                    <label for="description" class="required">Description: </label>
120
                    <input type="text" id="description" name="description" size="48" value="[% itemtype.description | html %]" required="required" /> <span class="required">Required</span>
141
                    <input type="text" id="description" name="description" size="48" value="[% itemtype.description | html %]" required="required" /> <span class="required">Required</span>
Lines 369-376 Item types administration Link Here
369
        <table id="table_item_type">
390
        <table id="table_item_type">
370
          <thead>
391
          <thead>
371
            [% UNLESS Koha.Preference('noItemTypeImages') && Koha.Preference('OpacNoItemTypeImages') %]<th class="noExport">Image</th>[% END %]
392
            [% UNLESS Koha.Preference('noItemTypeImages') && Koha.Preference('OpacNoItemTypeImages') %]<th class="noExport">Image</th>[% END %]
372
            <th>Code</th>
373
            <th>Description</th>
393
            <th>Description</th>
394
            <th>Code</th>
395
            <th>Parent code</th>
374
            <th>Search category</th>
396
            <th>Search category</th>
375
            <th>Not for loan</th>
397
            <th>Not for loan</th>
376
            <th>Hide in OPAC</th>
398
            <th>Hide in OPAC</th>
Lines 391-415 Item types administration Link Here
391
                        [% IF image_location %]<img src="[% image_location | html %]" alt="" />[% ELSE %]&nbsp;[% END %]
413
                        [% IF image_location %]<img src="[% image_location | html %]" alt="" />[% ELSE %]&nbsp;[% END %]
392
                    </td>
414
                    </td>
393
                [% END %]
415
                [% END %]
416
            <td>
417
                [% IF itemtype.parent_type %]
418
                    [% IF itemtype.parent.translated_descriptions.size %]
419
                        [% itemtype.parent.description | html %] (default)<br/>
420
                    [% ELSE %]
421
                        [% itemtype.parent.description | html %]
422
                    [% END %]
423
                    </br>
424
                    [% IF itemtype.translated_descriptions.size %]
425
                        [% itemtype.description | html %] (default)<br/>
426
                        [% FOR description IN itemtype.translated_descriptions %]
427
                            [% IF description.translation == itemtype.translated_description %]
428
                            --    <b>[% description.translation | html %]</b>
429
                            [% ELSE %]
430
                            --    [% description.translation | html %] ([% description.lang | html %])
431
                            [% END %]
432
                            <br/>
433
                        [% END %]
434
                    [% ELSE %]
435
                    --    [% itemtype.description | html %]
436
                    [% END %]
437
                [% ELSE %]
438
                    [% IF itemtype.translated_descriptions.size %]
439
                        [% itemtype.description | html %] (default)<br/>
440
                        [% FOR description IN itemtype.translated_descriptions %]
441
                            [% IF description.translation == itemtype.translated_description %]
442
                                <b>[% description.translation | html %]</b>
443
                            [% ELSE %]
444
                                [% description.translation | html %] ([% description.lang | html %])
445
                            [% END %]
446
                            <br/>
447
                        [% END %]
448
                    [% ELSE %]
449
                        [% itemtype.description | html %]
450
                    [% END %]
451
                [% END %]
452
            </td>
394
            <td>
453
            <td>
395
              <a href="/cgi-bin/koha/admin/itemtypes.pl?op=add_form&amp;itemtype=[% itemtype.itemtype | uri %]">
454
              <a href="/cgi-bin/koha/admin/itemtypes.pl?op=add_form&amp;itemtype=[% itemtype.itemtype | uri %]">
396
                [% itemtype.itemtype | html %]
455
                [% itemtype.itemtype | html %]
397
              </a>
456
              </a>
398
            </td>
457
            </td>
399
            <td>
458
            <td>
400
                [% IF itemtype.translated_descriptions.size %]
459
                [% itemtype.parent_type | html %]
401
                    [% itemtype.description | html %] (default)<br/>
402
                    [% FOR description IN itemtype.translated_descriptions %]
403
                        [% IF description.translation == itemtype.translated_description %]
404
                            <b>[% description.translation | html %]</b>
405
                        [% ELSE %]
406
                            [% description.translation | html %] ([% description.lang | html %])
407
                        [% END %]
408
                        <br/>
409
                    [% END %]
410
                [% ELSE %]
411
                    [% itemtype.description | html %]
412
                [% END %]
413
            </td>
460
            </td>
414
            <td>[% itemtype.searchcategory | html %]</td>
461
            <td>[% itemtype.searchcategory | html %]</td>
415
            <td>[% IF ( itemtype.notforloan ) %]Yes[% ELSE %]&nbsp;[% END %]</td>
462
            <td>[% IF ( itemtype.notforloan ) %]Yes[% ELSE %]&nbsp;[% END %]</td>
Lines 493-499 Item types administration Link Here
493
                    "aoColumnDefs": [
540
                    "aoColumnDefs": [
494
                        { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },
541
                        { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },
495
                    ],
542
                    ],
496
                "aaSorting": [[ 2, "asc" ]],
543
                "aaSorting": [[ 1, "asc" ]],
497
                "iDisplayLength": 10,
544
                "iDisplayLength": 10,
498
                "sPaginationType": "full"
545
                "sPaginationType": "full"
499
                }, columns_settings);
546
                }, columns_settings);
500
- 

Return to bug 21946