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 108-113 if ( $op eq 'add_form' ) { Link Here
108
114
109
    if ( $itemtype and $is_a_modif ) {    # it's a modification
115
    if ( $itemtype and $is_a_modif ) {    # it's a modification
110
        $itemtype->description($description);
116
        $itemtype->description($description);
117
        $itemtype->parent_type($parent_type);
111
        $itemtype->rentalcharge($rentalcharge);
118
        $itemtype->rentalcharge($rentalcharge);
112
        $itemtype->rentalcharge_daily($rentalcharge_daily);
119
        $itemtype->rentalcharge_daily($rentalcharge_daily);
113
        $itemtype->rentalcharge_hourly($rentalcharge_hourly);
120
        $itemtype->rentalcharge_hourly($rentalcharge_hourly);
Lines 137-142 if ( $op eq 'add_form' ) { Link Here
137
            {
144
            {
138
                itemtype            => $itemtype_code,
145
                itemtype            => $itemtype_code,
139
                description         => $description,
146
                description         => $description,
147
                parent_type         => $parent_type,
140
                rentalcharge        => $rentalcharge,
148
                rentalcharge        => $rentalcharge,
141
                rentalcharge_daily  => $rentalcharge_daily,
149
                rentalcharge_daily  => $rentalcharge_daily,
142
                rentalcharge_hourly => $rentalcharge_hourly,
150
                rentalcharge_hourly => $rentalcharge_hourly,
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt (-16 / +62 lines)
Lines 116-121 Item types administration Link Here
116
                    </li>
116
                    </li>
117
                [% END %]
117
                [% END %]
118
                <li>
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>
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>
121
                    [% IF can_be_translated %]
142
                    [% IF can_be_translated %]
Lines 351-358 Item types administration Link Here
351
        <table id="table_item_type">
372
        <table id="table_item_type">
352
          <thead>
373
          <thead>
353
            [% UNLESS Koha.Preference('noItemTypeImages') %]<th class="noExport">Image</th>[% END %]
374
            [% UNLESS Koha.Preference('noItemTypeImages') %]<th class="noExport">Image</th>[% END %]
354
            <th>Code</th>
355
            <th>Description</th>
375
            <th>Description</th>
376
            <th>Code</th>
377
            <th>Parent code</th>
356
            <th>Search category</th>
378
            <th>Search category</th>
357
            <th>Not for loan</th>
379
            <th>Not for loan</th>
358
            <th>Hide in OPAC</th>
380
            <th>Hide in OPAC</th>
Lines 374-397 Item types administration Link Here
374
                    </td>
396
                    </td>
375
                [% END %]
397
                [% END %]
376
            <td>
398
            <td>
399
                [% IF itemtype.parent_type %]
400
                    [% IF itemtype.parent.translated_descriptions.size %]
401
                        [% itemtype.parent.description | html %] (default)<br/>
402
                    [% ELSE %]
403
                        [% itemtype.parent.description | html %]
404
                    [% END %]
405
                    </br>
406
                    [% IF itemtype.translated_descriptions.size %]
407
                        [% itemtype.description | html %] (default)<br/>
408
                        [% FOR description IN itemtype.translated_descriptions %]
409
                            [% IF description.translation == itemtype.translated_description %]
410
                            --    <b>[% description.translation | html %]</b>
411
                            [% ELSE %]
412
                            --    [% description.translation | html %] ([% description.lang | html %])
413
                            [% END %]
414
                            <br/>
415
                        [% END %]
416
                    [% ELSE %]
417
                    --    [% itemtype.description | html %]
418
                    [% END %]
419
                [% ELSE %]
420
                    [% IF itemtype.translated_descriptions.size %]
421
                        [% itemtype.description | html %] (default)<br/>
422
                        [% FOR description IN itemtype.translated_descriptions %]
423
                            [% IF description.translation == itemtype.translated_description %]
424
                                <b>[% description.translation | html %]</b>
425
                            [% ELSE %]
426
                                [% description.translation | html %] ([% description.lang | html %])
427
                            [% END %]
428
                            <br/>
429
                        [% END %]
430
                    [% ELSE %]
431
                        [% itemtype.description | html %]
432
                    [% END %]
433
                [% END %]
434
            </td>
435
            <td>
377
              <a href="/cgi-bin/koha/admin/itemtypes.pl?op=add_form&amp;itemtype=[% itemtype.itemtype | uri %]">
436
              <a href="/cgi-bin/koha/admin/itemtypes.pl?op=add_form&amp;itemtype=[% itemtype.itemtype | uri %]">
378
                [% itemtype.itemtype | html %]
437
                [% itemtype.itemtype | html %]
379
              </a>
438
              </a>
380
            </td>
439
            </td>
381
            <td>
440
            <td>
382
                [% IF itemtype.translated_descriptions.size %]
441
                [% itemtype.parent_type | html %]
383
                    [% itemtype.description | html %] (default)<br/>
384
                    [% FOR description IN itemtype.translated_descriptions %]
385
                        [% IF description.translation == itemtype.translated_description %]
386
                            <b>[% description.translation | html %]</b>
387
                        [% ELSE %]
388
                            [% description.translation | html %] ([% description.lang | html %])
389
                        [% END %]
390
                        <br/>
391
                    [% END %]
392
                [% ELSE %]
393
                    [% itemtype.description | html %]
394
                [% END %]
395
            </td>
442
            </td>
396
            <td>[% itemtype.searchcategory | html %]</td>
443
            <td>[% itemtype.searchcategory | html %]</td>
397
            <td>[% IF ( itemtype.notforloan ) %]Yes[% ELSE %]&nbsp;[% END %]</td>
444
            <td>[% IF ( itemtype.notforloan ) %]Yes[% ELSE %]&nbsp;[% END %]</td>
Lines 475-481 Item types administration Link Here
475
                    "aoColumnDefs": [
522
                    "aoColumnDefs": [
476
                        { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },
523
                        { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },
477
                    ],
524
                    ],
478
                "aaSorting": [[ 2, "asc" ]],
525
                "aaSorting": [[ 1, "asc" ]],
479
                "iDisplayLength": 10,
526
                "iDisplayLength": 10,
480
                "sPaginationType": "full"
527
                "sPaginationType": "full"
481
                }, columns_settings);
528
                }, columns_settings);
482
- 

Return to bug 21946