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

(-)a/admin/columns_settings.yml (+4 lines)
Lines 358-363 modules: Link Here
358
              columnname: holdings_homebranch
358
              columnname: holdings_homebranch
359
            -
359
            -
360
              columnname: holdings_ccode
360
              columnname: holdings_ccode
361
            -
362
              columnname: holdings_volume
361
            -
363
            -
362
              columnname: holdings_itemcallnumber
364
              columnname: holdings_itemcallnumber
363
            -
365
            -
Lines 421-426 modules: Link Here
421
              columnname: otherholdings_homebranch
423
              columnname: otherholdings_homebranch
422
            -
424
            -
423
              columnname: otherholdings_ccode
425
              columnname: otherholdings_ccode
426
            -
427
              columnname: otherholdings_volume
424
            -
428
            -
425
              columnname: otherholdings_itemcallnumber
429
              columnname: otherholdings_itemcallnumber
426
            -
430
            -
(-)a/catalogue/detail.pl (+37 lines)
Lines 47-53 use C4::HTML5Media; Link Here
47
use C4::CourseReserves qw( GetItemCourseReservesInfo );
47
use C4::CourseReserves qw( GetItemCourseReservesInfo );
48
use Koha::AuthorisedValues;
48
use Koha::AuthorisedValues;
49
use Koha::Biblios;
49
use Koha::Biblios;
50
use Koha::Biblio::ItemGroup::Items;
51
use Koha::Biblio::ItemGroups;
50
use Koha::CoverImages;
52
use Koha::CoverImages;
53
use Koha::DateUtils;
51
use Koha::Illrequests;
54
use Koha::Illrequests;
52
use Koha::Items;
55
use Koha::Items;
53
use Koha::ItemTypes;
56
use Koha::ItemTypes;
Lines 99-104 if ( not defined $record ) { Link Here
99
my $marc_record = eval { $biblio->metadata->record };
102
my $marc_record = eval { $biblio->metadata->record };
100
$template->param( decoding_error => $@ );
103
$template->param( decoding_error => $@ );
101
104
105
my $op = $query->param('op') || q{};
106
if ( $op eq 'set_item_group' ) {
107
    my $item_group_id = $query->param('item_group_id');
108
    my @itemnumbers   = $query->multi_param('itemnumber');
109
110
    foreach my $item_id (@itemnumbers) {
111
        my $item_group_item = Koha::Biblio::ItemGroup::Items->find( { item_id => $item_id } );
112
113
        if ($item_group_item) {
114
            $item_group_item->item_group_id($item_group_id);
115
        }
116
        else {
117
            $item_group_item = Koha::Biblio::ItemGroup::Item->new(
118
                {
119
                    item_id        => $item_id,
120
                    item_group_id  => $item_group_id,
121
                }
122
            );
123
        }
124
125
        $item_group_item->store();
126
    }
127
}
128
elsif ( $op eq 'unset_item_group' ) {
129
    my $item_group_id   = $query->param('item_group_id');
130
    my @itemnumbers = $query->multi_param('itemnumber');
131
132
    foreach my $item_id (@itemnumbers) {
133
        my $item_group_item = Koha::Biblio::ItemGroup::Items->find( { item_id => $item_id } );
134
        $item_group_item->delete() if $item_group_item;
135
    }
136
}
137
102
if($query->cookie("holdfor")){
138
if($query->cookie("holdfor")){
103
    my $holdfor_patron = Koha::Patrons->find( $query->cookie("holdfor") );
139
    my $holdfor_patron = Koha::Patrons->find( $query->cookie("holdfor") );
104
    if ( $holdfor_patron ) {
140
    if ( $holdfor_patron ) {
Lines 340-345 foreach my $item (@items) { Link Here
340
376
341
    # checking for holds
377
    # checking for holds
342
    my $item_object = Koha::Items->find( $item->{itemnumber} );
378
    my $item_object = Koha::Items->find( $item->{itemnumber} );
379
    $item->{object} = $item_object;
343
    my $holds = $item_object->current_holds;
380
    my $holds = $item_object->current_holds;
344
    if ( my $first_hold = $holds->next ) {
381
    if ( my $first_hold = $holds->next ) {
345
        $item->{first_hold} = $first_hold;
382
        $item->{first_hold} = $first_hold;
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc (-12 / +12 lines)
Lines 101-112 Link Here
101
101
102
                    [% SET mv = subfield.marc_value %]
102
                    [% SET mv = subfield.marc_value %]
103
                    [% IF ( mv.type == 'hidden' ) %]
103
                    [% IF ( mv.type == 'hidden' ) %]
104
                        <input type="hidden" id="[%- mv.id | html -%]" name="[% kohafield | html %]" class="input_marceditor" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]">
104
                        <input type="hidden" id="[%- mv.id | html -%]" name="[% kohafield | html %]" class="input_marceditor [% kohafield | html %]" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]">
105
                    [% ELSIF ( mv.type == 'select' ) %]
105
                    [% ELSIF ( mv.type == 'select' ) %]
106
                        [% IF ( mv.readonly || subfield.IS_RETURN_CLAIM ) %]
106
                        [% IF ( mv.readonly || subfield.IS_RETURN_CLAIM ) %]
107
                            <select name="[% kohafield | html %]" id="[%- mv.id | html -%]" class="input_marceditor" readonly="readonly" disabled="disabled" data-width="50%">
107
                            <select name="[% kohafield | html %]" id="[%- mv.id | html -%]" class="input_marceditor [% kohafield | html %]" readonly="readonly" disabled="disabled" data-width="50%">
108
                        [% ELSE %]
108
                        [% ELSE %]
109
                            <select name="[% kohafield | html %]" id="[%- mv.id | html -%]" class="input_marceditor select2" data-category="[% mv.category | html %]" data-width="50%">
109
                            <select name="[% kohafield | html %]" id="[%- mv.id | html -%]" class="input_marceditor select2 [% kohafield | html %]" data-category="[% mv.category | html %]" data-width="50%">
110
                        [% END %]
110
                        [% END %]
111
111
112
                        [% FOREACH aval IN mv.values %]
112
                        [% FOREACH aval IN mv.values %]
Lines 123-141 Link Here
123
                        </select>
123
                        </select>
124
                    [% ELSIF ( mv.type == 'text_auth' ) %]
124
                    [% ELSIF ( mv.type == 'text_auth' ) %]
125
                        [% IF mv.readonly %]
125
                        [% IF mv.readonly %]
126
                            <input type="text" id="[%- mv.id | html -%]" name="[% kohafield | html %]" class="input_marceditor" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" readonly="readonly" />
126
                            <input type="text" id="[%- mv.id | html -%]" name="[% kohafield | html %]" class="input_marceditor [% kohafield | html %]" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" readonly="readonly" />
127
                        [% ELSE %]
127
                        [% ELSE %]
128
                            <input type="text" id="[%- mv.id | html -%]" name="[% kohafield | html %]" class="input_marceditor" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" />
128
                            <input type="text" id="[%- mv.id | html -%]" name="[% kohafield | html %]" class="input_marceditor [% kohafield | html %]" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" />
129
                            [% SET dopop = "Dopop('/cgi-bin/koha/authorities/auth_finder.pl?authtypecode=\"${mv.authtypecode}\"&index=${mv.id}','${mv.id}')" %]
129
                            [% SET dopop = "Dopop('/cgi-bin/koha/authorities/auth_finder.pl?authtypecode=\"${mv.authtypecode}\"&index=${mv.id}','${mv.id}')" %]
130
                            <a href="#" class="buttonDot"  onclick="[%- dopop | html -%]; return false;" title="Tag editor">...</a>
130
                            <a href="#" class="buttonDot"  onclick="[%- dopop | html -%]; return false;" title="Tag editor">...</a>
131
                        [% END %]
131
                        [% END %]
132
                    [% ELSIF ( mv.type == 'text_plugin' ) %]
132
                    [% ELSIF ( mv.type == 'text_plugin' ) %]
133
                        [% IF mv.readonly %]
133
                        [% IF mv.readonly %]
134
                            <input type="text" id="[%- mv.id | html -%]" name="[% kohafield | html %]" class="input_marceditor" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" readonly="readonly" />
134
                            <input type="text" id="[%- mv.id | html -%]" name="[% kohafield | html %]" class="input_marceditor [% kohafield | html %]" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" readonly="readonly" />
135
                        [% ELSE %]
135
                        [% ELSE %]
136
                            <input type="text" id="[%- mv.id | html -%]" name="[% kohafield | html %]" class="input_marceditor" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" />
136
                            <input type="text" id="[%- mv.id | html -%]" name="[% kohafield | html %]" class="input_marceditor [% kohafield | html %]" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" />
137
                            [% IF ( mv.nopopup ) %]
137
                            [% IF ( mv.nopopup ) %]
138
                                <a href="#" id="buttonDot_[%- mv.id | html -%]" class="[%- mv.class | html -%]" title="No popup">...</a>
138
                                <a href="#" id="buttonDot_[%- mv.id | html -%]" class="[%- mv.class | html -%]" title="No  popup">...</a>
139
                            [% ELSE  %]
139
                            [% ELSE  %]
140
                                <a href="#" id="buttonDot_[%- mv.id | html -%]" class="[%- mv.class | html -%]" title="Tag editor">...</a>
140
                                <a href="#" id="buttonDot_[%- mv.id | html -%]" class="[%- mv.class | html -%]" title="Tag editor">...</a>
141
                            [% END %]
141
                            [% END %]
Lines 145-159 Link Here
145
                        [% END %]
145
                        [% END %]
146
                    [% ELSIF ( mv.type == 'text' ) %]
146
                    [% ELSIF ( mv.type == 'text' ) %]
147
                        [% IF mv.readonly %]
147
                        [% IF mv.readonly %]
148
                            <input type="text" id="[%- mv.id | html -%]" name="[% kohafield | html %]" class="input_marceditor" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" readonly="readonly" />
148
                            <input type="text" id="[%- mv.id | html -%]" name="[% kohafield | html %]" class="input_marceditor [% kohafield | html %]" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" readonly="readonly" />
149
                        [% ELSE %]
149
                        [% ELSE %]
150
                            <input type="text" id="[%- mv.id | html -%]" name="[% kohafield | html %]" class="input_marceditor" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" />
150
                            <input type="text" id="[%- mv.id | html -%]" name="[% kohafield | html %]" class="input_marceditor [% kohafield | html %]" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" />
151
                        [% END %]
151
                        [% END %]
152
                    [% ELSIF ( mv.type == 'textarea' ) %]
152
                    [% ELSIF ( mv.type == 'textarea' ) %]
153
                        [% IF mv.readonly %]
153
                        [% IF mv.readonly %]
154
                            <textarea id="[%- mv.id | html -%]" name="[% kohafield | html %]" class="input_marceditor" rows="5" cols="64" readonly="readonly" >[% mv.value | html %]</textarea>
154
                            <textarea id="[%- mv.id | html -%]" name="[% kohafield | html %]" class="input_marceditor [% kohafield | html %]" rows="5" cols="64" readonly="readonly" >[% mv.value | html %]</textarea>
155
                        [% ELSE %]
155
                        [% ELSE %]
156
                            <textarea id="[%- mv.id | html -%]" name="[% kohafield | html %]" class="input_marceditor" rows="5" cols="64" >[% mv.value | html %]</textarea>
156
                            <textarea id="[%- mv.id | html -%]" name="[% kohafield | html %]" class="input_marceditor [% kohafield | html %]" rows="5" cols="64" >[% mv.value | html %]</textarea>
157
                        [% END %]
157
                        [% END %]
158
                    [% END %]
158
                    [% END %]
159
159
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt (-2 / +409 lines)
Lines 283-289 Link Here
283
            <a href="#holdings" aria-controls="holdings" role="tab" data-toggle="tab">Holdings ([% itemloop.size() || 0 | html %])</a>
283
            <a href="#holdings" aria-controls="holdings" role="tab" data-toggle="tab">Holdings ([% itemloop.size() || 0 | html %])</a>
284
        </li>
284
        </li>
285
    [% END %]
285
    [% END %]
286
[% IF ( MARCNOTES ) %]<li role="presentation"><a href="#description"  aria-controls="description" role="tab" data-toggle="tab">Descriptions ([% ( MARCNOTES.size || 1 ) | html %])</a></li>[% END %]
286
    [% IF Koha.Preference('EnableItemGroups') %]
287
        <li role="presentation">
288
            <a href="#item_groups" aria-controls="item_groups" role="tab" data-toggle="tab">Item groups</a>
289
        </li>
290
    [% END %]
291
[% IF ( MARCNOTES || notes ) %]<li role="presentation"><a href="#description" aria-controls="description" role="tab" data-toggle="tab">Descriptions ([% ( MARCNOTES.size || 1 ) | html %])</a></li>[% END %]
287
[% IF ComponentParts && ComponentParts.size %]<li id="components_tab" role="presentation"><a href="#components"  aria-controls="components" role="tab" data-toggle="tab">Components ([% ComponentParts.size | html %])</a></li>[% END %]
292
[% IF ComponentParts && ComponentParts.size %]<li id="components_tab" role="presentation"><a href="#components"  aria-controls="components" role="tab" data-toggle="tab">Components ([% ComponentParts.size | html %])</a></li>[% END %]
288
[% IF ( subscriptionsnumber ) %]<li role="presentation"><a href="#subscriptions"  aria-controls="subscriptions" role="tab" data-toggle="tab">Subscriptions</a></li>[% END %]
293
[% IF ( subscriptionsnumber ) %]<li role="presentation"><a href="#subscriptions"  aria-controls="subscriptions" role="tab" data-toggle="tab">Subscriptions</a></li>[% END %]
289
[% IF Koha.Preference('AcquisitionDetails') %]<li role="presentation"><a href="#acq_details"  aria-controls="acq_details" role="tab" data-toggle="tab">Acquisition details</a></li>[% END %]
294
[% IF Koha.Preference('AcquisitionDetails') %]<li role="presentation"><a href="#acq_details"  aria-controls="acq_details" role="tab" data-toggle="tab">Acquisition details</a></li>[% END %]
Lines 321-326 Link Here
321
              [% IF CAN_user_tools_items_batchmod %]
326
              [% IF CAN_user_tools_items_batchmod %]
322
                <a class="itemselection_action_modify"><i class="fa fa-pencil"></i> Modify selected items</a>
327
                <a class="itemselection_action_modify"><i class="fa fa-pencil"></i> Modify selected items</a>
323
              [% END %]
328
              [% END %]
329
              [% IF CAN_user_editcatalogue_manage_item_groups && biblio.item_groups.count %]
330
                <a class="itemselection_action_item_group_set" href="#"><i class="fa fa-book"></i> Add/move to item group</a>
331
                <a class="itemselection_action_item_group_unset" href="#"><i class="fa fa-unlink"></i> Remove from item group</a>
332
              [% END %]
324
            </span>
333
            </span>
325
        [% END %]
334
        [% END %]
326
    </div>
335
    </div>
Lines 335-340 Link Here
335
                <th id="[% tab | html %]_holdingbranch" data-colname="[% tab | html %]_holdingbranch">Current library</th>
344
                <th id="[% tab | html %]_holdingbranch" data-colname="[% tab | html %]_holdingbranch">Current library</th>
336
                <th id="[% tab | html %]_homebranch" data-colname="[% tab | html %]_homebranch">Home library</th>
345
                <th id="[% tab | html %]_homebranch" data-colname="[% tab | html %]_homebranch">Home library</th>
337
                [% IF ( itemdata_ccode ) %]<th id="[% tab | html %]_ccode" data-colname="[% tab | html %]_ccode">Collection</th>[% END %]
346
                [% IF ( itemdata_ccode ) %]<th id="[% tab | html %]_ccode" data-colname="[% tab | html %]_ccode">Collection</th>[% END %]
347
                [% IF Koha.Preference('EnableItemGroups') %]
348
                    <th id="[% tab | html %]_item_group" data-colname="[% tab | html %]_item_group">Item group</th>
349
                [% END %]
338
                <th id="[% tab | html %]_itemcallnumber" data-colname="[% tab | html %]_itemcallnumber">Call number</th>
350
                <th id="[% tab | html %]_itemcallnumber" data-colname="[% tab | html %]_itemcallnumber">Call number</th>
339
                [% IF volinfo %]
351
                [% IF volinfo %]
340
                    <th id="[% tab | html %]_enumchron" data-colname="[% tab | html %]_enumchron">Serial enumeration / chronology</th>
352
                    <th id="[% tab | html %]_enumchron" data-colname="[% tab | html %]_enumchron">Serial enumeration / chronology</th>
Lines 411-416 Note that permanent location is a code, and location may be an authval. Link Here
411
                        </span>
423
                        </span>
412
                    </td>
424
                    </td>
413
                    [% IF ( itemdata_ccode ) %]<td>[% item.ccode | html %]</td>[% END %]
425
                    [% IF ( itemdata_ccode ) %]<td>[% item.ccode | html %]</td>[% END %]
426
                    [% IF Koha.Preference('EnableItemGroups') %]<td class="item_group">[% item.object.item_group.description | html %]</td>[% END %]
414
                    <td class="itemcallnumber">[% IF ( item.itemcallnumber ) %] [% item.itemcallnumber | html %][% END %]</td>
427
                    <td class="itemcallnumber">[% IF ( item.itemcallnumber ) %] [% item.itemcallnumber | html %][% END %]</td>
415
                    [% IF ( volinfo ) %]
428
                    [% IF ( volinfo ) %]
416
                        [% IF itemdata_publisheddate #If there is at least one published date, use it for sorting %]
429
                        [% IF itemdata_publisheddate #If there is at least one published date, use it for sorting %]
Lines 627-632 Note that permanent location is a code, and location may be an authval. Link Here
627
640
628
[% END %][%# end of block items_table %]
641
[% END %][%# end of block items_table %]
629
642
643
[% IF Koha.Preference('EnableItemGroups') %]
644
    <div role="tabpanel" class="tab-pane" id="item_groups">
645
        [% IF CAN_user_editcatalogue_manage_item_groups %]
646
            <div class="item_groups_table_table_controls">
647
                <a href="#" class="item-group-create btn btn-default btn-xs"><i class="fa fa-plus"></i> New item group</a>
648
            </div>
649
        [% END %]
650
        <table class="items-group-table" id="items-group-table">
651
            <thead>
652
                <tr>
653
                    <td>Display Order</td>
654
                    <td>Description</td>
655
                    <td>&nbsp;</td>
656
                </tr>
657
            </thead>
658
        </table>
659
    </div>
660
[% END %]
661
662
630
<div role="tabpanel" class="tab-pane" id="holdings">
663
<div role="tabpanel" class="tab-pane" id="holdings">
631
664
632
[% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectStaffProfile') && Koha.Preference('NovelistSelectStaffView') == 'above' ) %]
665
[% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectStaffProfile') && Koha.Preference('NovelistSelectStaffView') == 'above' ) %]
Lines 1059-1064 Note that permanent location is a code, and location may be an authval. Link Here
1059
1092
1060
[% END %]
1093
[% END %]
1061
1094
1095
<div class="modal fade" id="modal-item-group-create" tabindex="-1" role="dialog" aria-labelledby="modal-item-group-create-label">
1096
    <div class="modal-dialog">
1097
        <div class="modal-content">
1098
            <div class="modal-header">
1099
                <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
1100
                <h3 id="modal-item-group-create-label"><i class="fa fa-plus"></i> Create a new item group</h3>
1101
            </div>
1102
            <form id="modal-item-group-create-form" class="validated">
1103
                <div class="modal-body">
1104
                    <fieldset>
1105
                        <p>
1106
                            <label for="item_group_description" class="required">Name: </label>
1107
                            <input name="description" id="modal-item-group-create-form-description" type="text" size="30" required="required" class="required" />
1108
                            <span class="required">Required</span>
1109
                        </p>
1110
                        <p>
1111
                            <label for="item_group_display_order" class="required">Display order: </label>
1112
                            <input name="display_order" id="modal-item-group-create-form-display_order" value="0" size="5" required="required" class="required" />
1113
                            <span class="required">Required</span>
1114
                            <br/>
1115
                            <span class="hint">Numbers only, item groups will be displayed in counting order</span>
1116
                        </p>
1117
                    </fieldset>
1118
                </div>
1119
                <div class="modal-footer">
1120
                    <button id="modal-item-group-create-submit" class="btn btn-default"><i class="fa fa-plus"></i> Submit</button>
1121
                    <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button>
1122
                </div>
1123
            </form>
1124
        </div>
1125
    </div>
1126
</div>
1127
1128
<div class="modal fade" id="modal-item-group-edit" tabindex="-1" role="dialog" aria-labelledby="modal-item-group-edit-label">
1129
    <div class="modal-dialog">
1130
        <div class="modal-content">
1131
            <div class="modal-header">
1132
                <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
1133
                <h3 id="modal-item-group-edit-label"><i class='fa fa-edit'></i> Edit item group</h3>
1134
            </div>
1135
            <form id="modal-item-group-edit-form" class="validated">
1136
                <div class="modal-body">
1137
                    <fieldset>
1138
                        <p>
1139
                            <label for="item_group_description" class="required">Name: </label>
1140
                            <input name="description" id="modal-item-group-edit-form-description" type="text" size="30" required="required" class="required" />
1141
                            <span class="required">Required</span>
1142
                        </p>
1143
                        <p>
1144
                            <label for="item_group_display_order" class="required">Sort order: </label>
1145
                            <input name="display_order" id="modal-item-group-edit-form-display_order" size="5" />
1146
                            <span class="hint">Numbers only, item groups will be displayed in counting order</span>
1147
                        </p>
1148
                    </fieldset>
1149
                </div>
1150
                <div class="modal-footer">
1151
                    <button id="modal-item-group-edit-submit" class="btn btn-default"><i class='fa fa-edit'></i> Submit</button>
1152
                    <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button>
1153
                </div>
1154
            </form>
1155
        </div>
1156
    </div>
1157
</div>
1158
1159
<div class="modal fade" id="modal-item-group-delete" tabindex="-1" role="dialog" aria-labelledby="modal-item-group-delete-label">
1160
    <div class="modal-dialog">
1161
        <div class="modal-content">
1162
            <div class="modal-header">
1163
                <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
1164
                <h3 id="modal-item-group-delete-label"><i class='fa fa-trash'></i> Delete item group</h3>
1165
            </div>
1166
            <div class="modal-body">
1167
                Are you sure you want to delete this item group?
1168
            </div>
1169
            <div class="modal-footer">
1170
                <button id="modal-item-group-delete-submit" class="btn btn-danger"><i class='fa fa-trash'></i> Delete</button>
1171
                <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button>
1172
            </div>
1173
        </div>
1174
    </div>
1175
</div>
1176
1177
<div class="modal fade" id="modal-item-group-set" tabindex="-1" role="dialog" aria-labelledby="modal-item-group-set-label">
1178
    <div class="modal-dialog">
1179
        <div class="modal-content">
1180
            <div class="modal-header">
1181
                <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
1182
                <h3 id="modal-item-group-set-label"><i class='fa fa-book'></i> Set item group for items</h3>
1183
            </div>
1184
            <form id="modal-item-group-set-form" class="validated">
1185
                <div class="modal-body">
1186
                    <fieldset>
1187
                        <p>
1188
                            <label for="item_group" class="required">Item group: </label>
1189
                            <select name="item_group" id="item-group-add-form-select">
1190
                                [% FOREACH ig IN biblio.item_groups %]
1191
                                    <option value="[% ig.id | html %]">[% ig.description | html %]</option>
1192
                                [% END %]
1193
                            </select>
1194
                            <span class="required">Required</span>
1195
                        </p>
1196
                    </fieldset>
1197
                </div>
1198
                <div class="modal-footer">
1199
                    <button id="modal-item-group-set-submit" class="btn btn-default"><i class='fa fa-book'></i> Set item group</button>
1200
                    <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button>
1201
                </div>
1202
            </form>
1203
        </div>
1204
    </div>
1205
</div>
1206
1207
<div class="modal fade" id="modal-item-group-unset" tabindex="-1" role="dialog" aria-labelledby="modal-item-group-unset-label">
1208
    <div class="modal-dialog">
1209
        <div class="modal-content">
1210
            <div class="modal-header">
1211
                <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
1212
                <h3 id="modal-item-group-unset-label"><i class='fa fa-unlink'></i> Remove item from item group</h3>
1213
            </div>
1214
            <div class="modal-body">
1215
                Are you sure you want to remove these item(s) from their item group(s)?
1216
            </div>
1217
            <div class="modal-footer">
1218
                <button id="modal-item-group-unset-submit" class="btn btn-danger"><i class='fa fa-unlink'></i> Remove</button>
1219
                <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button>
1220
            </div>
1221
        </div>
1222
    </div>
1223
</div>
1224
1062
[% MACRO jsinclude BLOCK %]
1225
[% MACRO jsinclude BLOCK %]
1063
    [% INCLUDE 'catalog-strings.inc' %]
1226
    [% INCLUDE 'catalog-strings.inc' %]
1064
    [% Asset.js("js/catalog.js") | $raw %]
1227
    [% Asset.js("js/catalog.js") | $raw %]
Lines 1419-1424 Note that permanent location is a code, and location may be an authval. Link Here
1419
                if ( search_value ){ $('#cat-search-block #search-form').val(search_value)};
1582
                if ( search_value ){ $('#cat-search-block #search-form').val(search_value)};
1420
            });
1583
            });
1421
        [% END %]
1584
        [% END %]
1585
1586
        [% IF Koha.Preference('EnableItemGroups') %]
1587
            // Load item groups table
1588
            var itemGroupsTable = KohaTable("items-group-table", {
1589
                "bAutoWidth": false,
1590
                'sDom': '<"top pager"ilp>t<"bottom pager"ip>r',
1591
                "aoColumns": [
1592
                    {
1593
                        "mDataProp": function( oObj ) {
1594
                            return oObj.display_order;
1595
                        },
1596
                    },
1597
                    {
1598
                        "mDataProp": function( oObj ) {
1599
                            return oObj.description;
1600
                        },
1601
                    },
1602
                    {
1603
                        "mDataProp": function( oObj ) {
1604
                            [% IF CAN_user_editcatalogue_manage_item_groups %]
1605
                                return `<button class='item-group-edit btn btn-default btn-xs' data-item-group-id='${oObj.item_group_id}'>
1606
                                    <i class='fa fa-edit'></i> ${_("Edit")}
1607
                                </button>`
1608
                                + '&nbsp'
1609
                                + `<button class='item-group-delete btn btn-default btn-xs' data-item-group-id='${oObj.item_group_id}'>
1610
                                    <i class='fa fa-trash'></i> ${('Delete')}
1611
                                </button>`;
1612
                            [% ELSE %]
1613
                                return "";
1614
                            [% END %]
1615
                        },
1616
                    },
1617
                ],
1618
                "bPaginate": false,
1619
                "bProcessing": true,
1620
                "bServerSide": false,
1621
                "sAjaxSource": `/api/v1/biblios/${biblionumber}/item_groups?_per_page=-1`,
1622
                "sAjaxDataProp": "",
1623
                "fnServerData": function ( sSource, aoData, fnCallback ) {
1624
                    $.getJSON( sSource, aoData, function (json) {
1625
                        fnCallback(json)
1626
                    } );
1627
                },
1628
            });
1629
1630
            // Create new item groups
1631
            $('.item-group-create').on('click', function(){
1632
                $('#modal-item-group-create-form-description').val("");
1633
                $('#modal-item-group-create-submit').removeAttr('disabled');
1634
                $('#modal-item-group-create').modal('show');
1635
            });
1636
1637
            $("#modal-item-group-create-form").validate({
1638
                submitHandler: function(form) {
1639
                    $.ajax({
1640
                        url: `/api/v1/biblios/${biblionumber}/item_groups`,
1641
                        headers: { "x-koha-embed": "items" },
1642
                        success: function(item_groups){
1643
                            $('#modal-item-group-create-submit').attr('disabled', 'disabled');
1644
1645
                            var settings = {
1646
                              "url": `/api/v1/biblios/${biblionumber}/item_groups`,
1647
                              "method": "POST",
1648
                              "headers": {
1649
                                "Content-Type": "application/json"
1650
                              },
1651
                              "data": JSON.stringify(
1652
                                  {
1653
                                      "description": $("#modal-item-group-create-form-description").val(),
1654
                                      "display_order": $("#modal-item-group-create-form-display_order").val(),
1655
                                  }
1656
                              ),
1657
                            };
1658
1659
                            $.ajax(settings)
1660
                            .done(function (response) {
1661
                                $('#item-group-add-form-select').append($('<option>', {
1662
                                    value: response.item_group_id,
1663
                                    text: response.description
1664
                                }));
1665
1666
                                $('#modal-item-group-create').modal('hide');
1667
                                if ( item_groups.length == 0 ) {
1668
                                    // This bib has no previous item groups, reload the page
1669
                                    window.location.replace(`/cgi-bin/koha/catalogue/detail.pl?biblionumber=${biblionumber}`);
1670
                                } else {
1671
                                    // Has other item groups, just reload the table
1672
                                    itemGroupsTable.api().ajax.reload();
1673
                                }
1674
                            })
1675
                            .fail(function(err) {
1676
                                var message = err.responseJSON.error;
1677
                                alert(message);
1678
                            });
1679
                        }
1680
                    });
1681
                }
1682
            });
1683
1684
            $('#modal-item-group-create').on('shown.bs.modal', function () {
1685
                $('#modal-item-group-create-form-description').focus();
1686
            })
1687
1688
            // Edit existing item groups
1689
            $('body').on( 'click', '.item-group-edit', function(){
1690
                const item_group_id = $(this).data('item-group-id');
1691
                const url = `/api/v1/biblios/${biblionumber}/item_groups/${item_group_id}`;
1692
                $.get( url, function( data ) {
1693
                    $('#modal-item-group-edit-form-description').val( data.description );
1694
                    $('#modal-item-group-edit-form-display_order').val( data.display_order );
1695
                    $('#modal-item-group-edit-submit').data('item-group-id', item_group_id );
1696
                    $('#modal-item-group-edit-submit').removeAttr('disabled');
1697
                    $('#modal-item-group-edit').modal('show');
1698
                });
1699
            });
1700
1701
            $("#modal-item-group-edit-form").validate({
1702
                submitHandler: function(form) {
1703
                    $('#modal-item-group-edit-submit').attr('disabled', 'disabled');
1704
1705
                    const item_group_id = $('#modal-item-group-edit-submit').data('item-group-id');
1706
                    const url = `/api/v1/biblios/${biblionumber}/item_groups/${item_group_id}`;
1707
1708
                    var settings = {
1709
                      "url": url,
1710
                      "method": "PUT",
1711
                      "headers": {
1712
                        "Content-Type": "application/json"
1713
                      },
1714
                      "data": JSON.stringify(
1715
                          {
1716
                              "description": $("#modal-item-group-edit-form-description").val(),
1717
                              "display_order": $("#modal-item-group-edit-form-display_order").val(),
1718
                          }
1719
                      ),
1720
                    };
1721
1722
                    $.ajax(settings)
1723
                    .done(function (response) {
1724
                        $('#modal-item-group-edit').modal('hide');
1725
                        itemGroupsTable.api().ajax.reload();
1726
                    })
1727
                    .fail(function(err) {
1728
                        var message = err.responseJSON.error;
1729
                        alert(message);
1730
                    });
1731
                }
1732
            });
1733
1734
            $('#modal-item-group-edit').on('shown.bs.modal', function () {
1735
                $('#modal-item-group-edit-form-description').focus();
1736
            })
1737
1738
            // Delete existing item groups
1739
            $('body').on( 'click', '.item-group-delete', function(){
1740
                const item_group_id = $(this).data('item-group-id');
1741
                $('#modal-item-group-delete-submit').data('item-group-id', item_group_id );
1742
                $('#modal-item-group-delete-submit').removeAttr('disabled');
1743
                $('#modal-item-group-delete').modal('show');
1744
            });
1745
            $("#modal-item-group-delete-submit").on('click', function(){
1746
                $('#modal-item-group-delete-submit').attr('disabled', 'disabled');
1747
                const item_group_id = $("#modal-item-group-delete-submit").data('item-group-id');
1748
1749
                $.ajax({
1750
                    url: `/api/v1/biblios/${biblionumber}/item_groups/${item_group_id}`,
1751
                    headers: { "x-koha-embed": "items" },
1752
                    success: function(item_group_data){
1753
                        $.ajax({
1754
                          "url": `/api/v1/biblios/${biblionumber}/item_groups/${item_group_id}`,
1755
                          "method": "DELETE",
1756
                        })
1757
                        .done(function (response) {
1758
                            $('#modal-item-group-delete').modal('hide');
1759
                            $(`#item-group-add-form-select option[value='${item_group_id}']`).remove();
1760
                            if ( item_group_data.items === null ) {
1761
                                // No items for this item group, we can just refresh the table
1762
                                itemGroupsTable.api().ajax.reload();
1763
                            } else {
1764
                                // This item group had items attached to it, we need to reload the page
1765
                                window.location.replace(`/cgi-bin/koha/catalogue/detail.pl?biblionumber=${biblionumber}`);
1766
                            }
1767
                        })
1768
                        .fail(function(err) {
1769
                            var message = err.responseJSON.error;
1770
                            alert(message);
1771
                        });
1772
                    }
1773
                });
1774
            });
1775
1776
            // Add item(s) to a item group
1777
            $('.itemselection_action_item_group_set').on('click', function(){
1778
                $('#modal-item-group-set').modal('show');
1779
            });
1780
1781
            $("#modal-item-group-set-form").validate({
1782
                submitHandler: function(form) {
1783
                    $('#modal-item-group-set-submit').attr('disabled', 'disabled');
1784
1785
                    const item_group_id = $('#item-group-add-form-select').val();
1786
1787
                    let itemnumbers = new Array();
1788
                    $("input[name='itemnumber'][type='checkbox']:checked").each(function() {
1789
                        const itemnumber = $(this).val();
1790
                        itemnumbers.push( itemnumber );
1791
                    });
1792
                    if (itemnumbers.length > 0) {
1793
                        let url = '/cgi-bin/koha/catalogue/detail.pl?op=set_item_group';
1794
                        url += '&itemnumber=' + itemnumbers.join('&itemnumber=');
1795
                        url += '&biblionumber=[% biblionumber | uri %]';
1796
                        url += `&item_group_id=${item_group_id}`;
1797
1798
                        window.location.replace(url);
1799
                    }
1800
1801
                    $('#modal-item-group-set').modal('hide');
1802
                }
1803
            });
1804
1805
            // Remove item(s) from an item group
1806
            $('.itemselection_action_item_group_unset').on('click', function(){
1807
                $('#modal-item-group-unset').modal('show');
1808
            });
1809
1810
            $("#modal-item-group-unset-submit").on('click', function(){
1811
                $('#modal-item-group-unset-submit').attr('disabled', 'disabled');
1812
1813
                let itemnumbers = new Array();
1814
                $("input[name='itemnumber'][type='checkbox']:checked").each(function() {
1815
                    const itemnumber = $(this).val();
1816
                    itemnumbers.push( itemnumber );
1817
                });
1818
                if (itemnumbers.length > 0) {
1819
                    let url = '/cgi-bin/koha/catalogue/detail.pl?op=unset_item_group';
1820
                    url += '&itemnumber=' + itemnumbers.join('&itemnumber=');
1821
                    url += '&biblionumber=[% biblionumber | uri %]';
1822
1823
                    window.location.replace(url);
1824
                }
1825
1826
                $('#modal-item-group-unset').modal('hide');
1827
1828
            });
1829
        [% END %]
1422
    </script>
1830
    </script>
1423
[% END %]
1831
[% END %]
1424
[% INCLUDE 'intranet-bottom.inc' %]
1832
[% INCLUDE 'intranet-bottom.inc' %]
1425
- 

Return to bug 24857