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

(-)a/admin/columns_settings.yml (+4 lines)
Lines 316-321 modules: Link Here
316
              columnname: holdings_homebranch
316
              columnname: holdings_homebranch
317
            -
317
            -
318
              columnname: holdings_ccode
318
              columnname: holdings_ccode
319
            -
320
              columnname: holdings_volume
319
            -
321
            -
320
              columnname: holdings_itemcallnumber
322
              columnname: holdings_itemcallnumber
321
            -
323
            -
Lines 373-378 modules: Link Here
373
              columnname: otherholdings_homebranch
375
              columnname: otherholdings_homebranch
374
            -
376
            -
375
              columnname: otherholdings_ccode
377
              columnname: otherholdings_ccode
378
            -
379
              columnname: otherholdings_volume
376
            -
380
            -
377
              columnname: otherholdings_itemcallnumber
381
              columnname: otherholdings_itemcallnumber
378
            -
382
            -
(-)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 98-103 if ( not defined $record ) { Link Here
98
my $marc_record = eval { $biblio->metadata->record };
101
my $marc_record = eval { $biblio->metadata->record };
99
$template->param( decoding_error => $@ );
102
$template->param( decoding_error => $@ );
100
103
104
my $op = $query->param('op') || q{};
105
if ( $op eq 'set_item_group' ) {
106
    my $item_group_id = $query->param('item_group_id');
107
    my @itemnumbers   = $query->multi_param('itemnumber');
108
109
    foreach my $item_id (@itemnumbers) {
110
        my $item_group_item = Koha::Biblio::ItemGroup::Items->find( { item_id => $item_id } );
111
112
        if ($item_group_item) {
113
            $item_group_item->item_group_id($item_group_id);
114
        }
115
        else {
116
            $item_group_item = Koha::Biblio::ItemGroup::Item->new(
117
                {
118
                    item_id        => $item_id,
119
                    item_group_id  => $item_group_id,
120
                }
121
            );
122
        }
123
124
        $item_group_item->store();
125
    }
126
}
127
elsif ( $op eq 'unset_item_group' ) {
128
    my $item_group_id   = $query->param('item_group_id');
129
    my @itemnumbers = $query->multi_param('itemnumber');
130
131
    foreach my $item_id (@itemnumbers) {
132
        my $item_group_item = Koha::Biblio::ItemGroup::Items->find( { item_id => $item_id } );
133
        $item_group_item->delete() if $item_group_item;
134
    }
135
}
136
101
if($query->cookie("holdfor")){
137
if($query->cookie("holdfor")){
102
    my $holdfor_patron = Koha::Patrons->find( $query->cookie("holdfor") );
138
    my $holdfor_patron = Koha::Patrons->find( $query->cookie("holdfor") );
103
    if ( $holdfor_patron ) {
139
    if ( $holdfor_patron ) {
Lines 335-340 foreach my $item (@items) { Link Here
335
371
336
    # checking for holds
372
    # checking for holds
337
    my $item_object = Koha::Items->find( $item->{itemnumber} );
373
    my $item_object = Koha::Items->find( $item->{itemnumber} );
374
    $item->{object} = $item_object;
338
    my $holds = $item_object->current_holds;
375
    my $holds = $item_object->current_holds;
339
    if ( my $first_hold = $holds->next ) {
376
    if ( my $first_hold = $holds->next ) {
340
        $item->{first_hold} = $first_hold;
377
        $item->{first_hold} = $first_hold;
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc (-12 / +12 lines)
Lines 88-99 Link Here
88
88
89
                    [% SET mv = subfield.marc_value %]
89
                    [% SET mv = subfield.marc_value %]
90
                    [% IF ( mv.type == 'hidden' ) %]
90
                    [% IF ( mv.type == 'hidden' ) %]
91
                        <input type="hidden" id="[%- mv.id | html -%]" name="[% kohafield | html %]" class="input_marceditor" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]">
91
                        <input type="hidden" id="[%- mv.id | html -%]" name="[% kohafield | html %]" class="input_marceditor [% kohafield | html %]" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]">
92
                    [% ELSIF ( mv.type == 'select' ) %]
92
                    [% ELSIF ( mv.type == 'select' ) %]
93
                        [% IF ( mv.readonly || subfield.IS_RETURN_CLAIM ) %]
93
                        [% IF ( mv.readonly || subfield.IS_RETURN_CLAIM ) %]
94
                            <select name="[% kohafield | html %]" id="[%- mv.id | html -%]" class="input_marceditor" readonly="readonly" disabled="disabled" data-width="50%">
94
                            <select name="[% kohafield | html %]" id="[%- mv.id | html -%]" class="input_marceditor [% kohafield | html %]" readonly="readonly" disabled="disabled" data-width="50%">
95
                        [% ELSE %]
95
                        [% ELSE %]
96
                            <select name="[% kohafield | html %]" id="[%- mv.id | html -%]" class="input_marceditor select2" data-category="[% mv.category | html %]" data-width="50%">
96
                            <select name="[% kohafield | html %]" id="[%- mv.id | html -%]" class="input_marceditor select2 [% kohafield | html %]" data-category="[% mv.category | html %]" data-width="50%">
97
                        [% END %]
97
                        [% END %]
98
98
99
                        [% FOREACH aval IN mv.values %]
99
                        [% FOREACH aval IN mv.values %]
Lines 110-128 Link Here
110
                        </select>
110
                        </select>
111
                    [% ELSIF ( mv.type == 'text_auth' ) %]
111
                    [% ELSIF ( mv.type == 'text_auth' ) %]
112
                        [% IF mv.readonly %]
112
                        [% IF mv.readonly %]
113
                            <input type="text" id="[%- mv.id | html -%]" name="[% kohafield | html %]" class="input_marceditor" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" readonly="readonly" />
113
                            <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" />
114
                        [% ELSE %]
114
                        [% ELSE %]
115
                            <input type="text" id="[%- mv.id | html -%]" name="[% kohafield | html %]" class="input_marceditor" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" />
115
                            <input type="text" id="[%- mv.id | html -%]" name="[% kohafield | html %]" class="input_marceditor [% kohafield | html %]" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" />
116
                            [% SET dopop = "Dopop('/cgi-bin/koha/authorities/auth_finder.pl?authtypecode=\"${mv.authtypecode}\"&index=${mv.id}','${mv.id}')" %]
116
                            [% SET dopop = "Dopop('/cgi-bin/koha/authorities/auth_finder.pl?authtypecode=\"${mv.authtypecode}\"&index=${mv.id}','${mv.id}')" %]
117
                            <a href="#" class="buttonDot"  onclick="[%- dopop | html -%]; return false;" title="Tag editor">...</a>
117
                            <a href="#" class="buttonDot"  onclick="[%- dopop | html -%]; return false;" title="Tag editor">...</a>
118
                        [% END %]
118
                        [% END %]
119
                    [% ELSIF ( mv.type == 'text_plugin' ) %]
119
                    [% ELSIF ( mv.type == 'text_plugin' ) %]
120
                        [% IF mv.readonly %]
120
                        [% IF mv.readonly %]
121
                            <input type="text" id="[%- mv.id | html -%]" name="[% kohafield | html %]" class="input_marceditor" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" readonly="readonly" />
121
                            <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" />
122
                        [% ELSE %]
122
                        [% ELSE %]
123
                            <input type="text" id="[%- mv.id | html -%]" name="[% kohafield | html %]" class="input_marceditor" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" />
123
                            <input type="text" id="[%- mv.id | html -%]" name="[% kohafield | html %]" class="input_marceditor [% kohafield | html %]" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" />
124
                            [% IF ( mv.nopopup ) %]
124
                            [% IF ( mv.nopopup ) %]
125
                                <a href="#" id="buttonDot_[%- mv.id | html -%]" class="[%- mv.class | html -%]" title="No popup">...</a>
125
                                <a href="#" id="buttonDot_[%- mv.id | html -%]" class="[%- mv.class | html -%]" title="No  popup">...</a>
126
                            [% ELSE  %]
126
                            [% ELSE  %]
127
                                <a href="#" id="buttonDot_[%- mv.id | html -%]" class="[%- mv.class | html -%]" title="Tag editor">...</a>
127
                                <a href="#" id="buttonDot_[%- mv.id | html -%]" class="[%- mv.class | html -%]" title="Tag editor">...</a>
128
                            [% END %]
128
                            [% END %]
Lines 132-146 Link Here
132
                        [% END %]
132
                        [% END %]
133
                    [% ELSIF ( mv.type == 'text' ) %]
133
                    [% ELSIF ( mv.type == 'text' ) %]
134
                        [% IF mv.readonly %]
134
                        [% IF mv.readonly %]
135
                            <input type="text" id="[%- mv.id | html -%]" name="[% kohafield | html %]" class="input_marceditor" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" readonly="readonly" />
135
                            <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" />
136
                        [% ELSE %]
136
                        [% ELSE %]
137
                            <input type="text" id="[%- mv.id | html -%]" name="[% kohafield | html %]" class="input_marceditor" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" />
137
                            <input type="text" id="[%- mv.id | html -%]" name="[% kohafield | html %]" class="input_marceditor [% kohafield | html %]" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" />
138
                        [% END %]
138
                        [% END %]
139
                    [% ELSIF ( mv.type == 'textarea' ) %]
139
                    [% ELSIF ( mv.type == 'textarea' ) %]
140
                        [% IF mv.readonly %]
140
                        [% IF mv.readonly %]
141
                            <textarea id="[%- mv.id | html -%]" name="[% kohafield | html %]" class="input_marceditor" rows="5" cols="64" readonly="readonly" >[% mv.value | html %]</textarea>
141
                            <textarea id="[%- mv.id | html -%]" name="[% kohafield | html %]" class="input_marceditor [% kohafield | html %]" rows="5" cols="64" readonly="readonly" >[% mv.value | html %]</textarea>
142
                        [% ELSE %]
142
                        [% ELSE %]
143
                            <textarea id="[%- mv.id | html -%]" name="[% kohafield | html %]" class="input_marceditor" rows="5" cols="64" >[% mv.value | html %]</textarea>
143
                            <textarea id="[%- mv.id | html -%]" name="[% kohafield | html %]" class="input_marceditor [% kohafield | html %]" rows="5" cols="64" >[% mv.value | html %]</textarea>
144
                        [% END %]
144
                        [% END %]
145
                    [% END %]
145
                    [% END %]
146
146
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt (-2 / +403 lines)
Lines 268-274 Link Here
268
            <a href="#holdings">Holdings ([% itemloop.size() || 0 | html %])</a>
268
            <a href="#holdings">Holdings ([% itemloop.size() || 0 | html %])</a>
269
        </li>
269
        </li>
270
    [% END %]
270
    [% END %]
271
[% IF ( MARCNOTES ) %]<li><a href="#description">Descriptions ([% ( MARCNOTES.size || 1 ) | html %])</a></li>[% END %]
271
[% IF Koha.Preference('EnableItemGroups') %]<li><a href="#item_groups">Item Groups</a></li>[% END %]
272
[% IF ( MARCNOTES || notes ) %]<li><a href="#description">Descriptions ([% ( MARCNOTES.size || 1 ) | html %])</a></li>[% END %]
272
[% IF ComponentParts && ComponentParts.size %]<li id="components_tab"><a href="#components">Components ([% ComponentParts.size | html %])</a></li>[% END %]
273
[% IF ComponentParts && ComponentParts.size %]<li id="components_tab"><a href="#components">Components ([% ComponentParts.size | html %])</a></li>[% END %]
273
[% IF ( subscriptionsnumber ) %]<li><a href="#subscriptions">Subscriptions</a></li>[% END %]
274
[% IF ( subscriptionsnumber ) %]<li><a href="#subscriptions">Subscriptions</a></li>[% END %]
274
[% IF Koha.Preference('AcquisitionDetails') %]<li><a href="#acq_details">Acquisition details</a></li>[% END %]
275
[% IF Koha.Preference('AcquisitionDetails') %]<li><a href="#acq_details">Acquisition details</a></li>[% END %]
Lines 303-308 Link Here
303
              [% IF CAN_user_tools_items_batchmod %]
304
              [% IF CAN_user_tools_items_batchmod %]
304
                <a class="itemselection_action_modify"><i class="fa fa-pencil"></i> Modify selected items</a>
305
                <a class="itemselection_action_modify"><i class="fa fa-pencil"></i> Modify selected items</a>
305
              [% END %]
306
              [% END %]
307
              [% IF CAN_user_editcatalogue_manage_item_groups && biblio.item_groups.count %]
308
                <a class="itemselection_action_item_group_set" href="#"><i class="fa fa-book"></i> Add/move to item group</a>
309
                <a class="itemselection_action_item_group_unset" href="#"><i class="fa fa-unlink"></i> Remove from item group</a>
310
              [% END %]
306
            </span>
311
            </span>
307
        [% END %]
312
        [% END %]
308
    </div>
313
    </div>
Lines 317-322 Link Here
317
                <th id="[% tab | html %]_holdingbranch" data-colname="[% tab | html %]_holdingbranch">Current library</th>
322
                <th id="[% tab | html %]_holdingbranch" data-colname="[% tab | html %]_holdingbranch">Current library</th>
318
                <th id="[% tab | html %]_homebranch" data-colname="[% tab | html %]_homebranch">Home library</th>
323
                <th id="[% tab | html %]_homebranch" data-colname="[% tab | html %]_homebranch">Home library</th>
319
                [% IF ( itemdata_ccode ) %]<th id="[% tab | html %]_ccode" data-colname="[% tab | html %]_ccode">Collection</th>[% END %]
324
                [% IF ( itemdata_ccode ) %]<th id="[% tab | html %]_ccode" data-colname="[% tab | html %]_ccode">Collection</th>[% END %]
325
                [% IF Koha.Preference('EnableItemGroups') %]
326
                    <th id="[% tab | html %]_item_group" data-colname="[% tab | html %]_item_group">Item group</th>
327
                [% END %]
320
                <th id="[% tab | html %]_itemcallnumber" data-colname="[% tab | html %]_itemcallnumber">Call number</th>
328
                <th id="[% tab | html %]_itemcallnumber" data-colname="[% tab | html %]_itemcallnumber">Call number</th>
321
                [% IF volinfo %]
329
                [% IF volinfo %]
322
                    <th id="[% tab | html %]_enumchron" data-colname="[% tab | html %]_enumchron">Serial enumeration / chronology</th>
330
                    <th id="[% tab | html %]_enumchron" data-colname="[% tab | html %]_enumchron">Serial enumeration / chronology</th>
Lines 391-396 Note that permanent location is a code, and location may be an authval. Link Here
391
                        </span>
399
                        </span>
392
                    </td>
400
                    </td>
393
                    [% IF ( itemdata_ccode ) %]<td>[% item.ccode | html %]</td>[% END %]
401
                    [% IF ( itemdata_ccode ) %]<td>[% item.ccode | html %]</td>[% END %]
402
                    [% IF Koha.Preference('EnableItemGroups') %]<td class="item_group">[% item.object.item_group.description | html %]</td>[% END %]
394
                    <td class="itemcallnumber">[% IF ( item.itemcallnumber ) %] [% item.itemcallnumber | html %][% END %]</td>
403
                    <td class="itemcallnumber">[% IF ( item.itemcallnumber ) %] [% item.itemcallnumber | html %][% END %]</td>
395
                    [% IF ( volinfo ) %]
404
                    [% IF ( volinfo ) %]
396
                        [% IF itemdata_publisheddate #If there is at least one published date, use it for sorting %]
405
                        [% IF itemdata_publisheddate #If there is at least one published date, use it for sorting %]
Lines 596-601 Note that permanent location is a code, and location may be an authval. Link Here
596
605
597
[% END %][%# end of block items_table %]
606
[% END %][%# end of block items_table %]
598
607
608
[% IF Koha.Preference('EnableItemGroups') %]
609
    <div id="item_groups">
610
        [% IF CAN_user_editcatalogue_manage_item_groups %]
611
            <div class="item_groups_table_table_controls">
612
                <a href="#" class="item-group-create btn btn-default btn-xs"><i class="fa fa-plus"></i> New item group</a>
613
            </div>
614
        [% END %]
615
        <table class="items-group-table" id="items-group-table">
616
            <thead>
617
                <tr>
618
                    <td>Display Order</td>
619
                    <td>Description</td>
620
                    <td>&nbsp;</td>
621
                </tr>
622
            </thead>
623
        </table>
624
    </div>
625
[% END %]
626
599
<div id="holdings">
627
<div id="holdings">
600
628
601
[% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectStaffProfile') && Koha.Preference('NovelistSelectStaffView') == 'above' ) %]
629
[% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectStaffProfile') && Koha.Preference('NovelistSelectStaffView') == 'above' ) %]
Lines 1027-1032 Note that permanent location is a code, and location may be an authval. Link Here
1027
1055
1028
[% END %]
1056
[% END %]
1029
1057
1058
<div class="modal fade" id="modal-item-group-create" tabindex="-1" role="dialog" aria-labelledby="modal-item-group-create-label">
1059
    <div class="modal-dialog">
1060
        <div class="modal-content">
1061
            <div class="modal-header">
1062
                <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
1063
                <h3 id="modal-item-group-create-label"><i class="fa fa-plus"></i> Create a new item group</h3>
1064
            </div>
1065
            <form id="modal-item-group-create-form" class="validated">
1066
                <div class="modal-body">
1067
                    <fieldset>
1068
                        <p>
1069
                            <label for="item_group_description" class="required">Name: </label>
1070
                            <input name="description" id="modal-item-group-create-form-description" type="text" size="30" required="required" class="required" />
1071
                            <span class="required">Required</span>
1072
                        </p>
1073
                        <p>
1074
                            <label for="item_group_display_order" class="required">Display order: </label>
1075
                            <input name="display_order" id="modal-item-group-create-form-display_order" value="0" size="5" required="required" class="required" />
1076
                            <span class="required">Required</span>
1077
                            <br/>
1078
                            <span class="hint">Numbers only, item groups will be displayed in counting order</span>
1079
                        </p>
1080
                    </fieldset>
1081
                </div>
1082
                <div class="modal-footer">
1083
                    <button id="modal-item-group-create-submit" class="btn btn-default"><i class="fa fa-plus"></i> Submit</button>
1084
                    <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button>
1085
                </div>
1086
            </form>
1087
        </div>
1088
    </div>
1089
</div>
1090
1091
<div class="modal fade" id="modal-item-group-edit" tabindex="-1" role="dialog" aria-labelledby="modal-item-group-edit-label">
1092
    <div class="modal-dialog">
1093
        <div class="modal-content">
1094
            <div class="modal-header">
1095
                <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
1096
                <h3 id="modal-item-group-edit-label"><i class='fa fa-edit'></i> Edit item group</h3>
1097
            </div>
1098
            <form id="modal-item-group-edit-form" class="validated">
1099
                <div class="modal-body">
1100
                    <fieldset>
1101
                        <p>
1102
                            <label for="item_group_description" class="required">Name: </label>
1103
                            <input name="description" id="modal-item-group-edit-form-description" type="text" size="30" required="required" class="required" />
1104
                            <span class="required">Required</span>
1105
                        </p>
1106
                        <p>
1107
                            <label for="item_group_display_order" class="required">Sort order: </label>
1108
                            <input name="display_order" id="modal-item-group-edit-form-display_order" size="5" />
1109
                            <span class="hint">Numbers only, item groups will be displayed in counting order</span>
1110
                        </p>
1111
                    </fieldset>
1112
                </div>
1113
                <div class="modal-footer">
1114
                    <button id="modal-item-group-edit-submit" class="btn btn-default"><i class='fa fa-edit'></i> Submit</button>
1115
                    <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button>
1116
                </div>
1117
            </form>
1118
        </div>
1119
    </div>
1120
</div>
1121
1122
<div class="modal fade" id="modal-item-group-delete" tabindex="-1" role="dialog" aria-labelledby="modal-item-group-delete-label">
1123
    <div class="modal-dialog">
1124
        <div class="modal-content">
1125
            <div class="modal-header">
1126
                <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
1127
                <h3 id="modal-item-group-delete-label"><i class='fa fa-trash'></i> Delete item group</h3>
1128
            </div>
1129
            <div class="modal-body">
1130
                Are you sure you want to delete this item group?
1131
            </div>
1132
            <div class="modal-footer">
1133
                <button id="modal-item-group-delete-submit" class="btn btn-danger"><i class='fa fa-trash'></i> Delete</button>
1134
                <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button>
1135
            </div>
1136
        </div>
1137
    </div>
1138
</div>
1139
1140
<div class="modal fade" id="modal-item-group-set" tabindex="-1" role="dialog" aria-labelledby="modal-item-group-set-label">
1141
    <div class="modal-dialog">
1142
        <div class="modal-content">
1143
            <div class="modal-header">
1144
                <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
1145
                <h3 id="modal-item-group-set-label"><i class='fa fa-book'></i> Set item group for items</h3>
1146
            </div>
1147
            <form id="modal-item-group-set-form" class="validated">
1148
                <div class="modal-body">
1149
                    <fieldset>
1150
                        <p>
1151
                            <label for="item_group" class="required">Item group: </label>
1152
                            <select name="item_group" id="item-group-add-form-select">
1153
                                [% FOREACH ig IN biblio.item_groups %]
1154
                                    <option value="[% ig.id | html %]">[% ig.description | html %]</option>
1155
                                [% END %]
1156
                            </select>
1157
                            <span class="required">Required</span>
1158
                        </p>
1159
                    </fieldset>
1160
                </div>
1161
                <div class="modal-footer">
1162
                    <button id="modal-item-group-set-submit" class="btn btn-default"><i class='fa fa-book'></i> Set item group</button>
1163
                    <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button>
1164
                </div>
1165
            </form>
1166
        </div>
1167
    </div>
1168
</div>
1169
1170
<div class="modal fade" id="modal-item-group-unset" tabindex="-1" role="dialog" aria-labelledby="modal-item-group-unset-label">
1171
    <div class="modal-dialog">
1172
        <div class="modal-content">
1173
            <div class="modal-header">
1174
                <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
1175
                <h3 id="modal-item-group-unset-label"><i class='fa fa-unlink'></i> Remove item from item group</h3>
1176
            </div>
1177
            <div class="modal-body">
1178
                Are you sure you want to remove these item(s) from their item group(s)?
1179
            </div>
1180
            <div class="modal-footer">
1181
                <button id="modal-item-group-unset-submit" class="btn btn-danger"><i class='fa fa-unlink'></i> Remove</button>
1182
                <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button>
1183
            </div>
1184
        </div>
1185
    </div>
1186
</div>
1187
1030
[% MACRO jsinclude BLOCK %]
1188
[% MACRO jsinclude BLOCK %]
1031
    [% INCLUDE 'catalog-strings.inc' %]
1189
    [% INCLUDE 'catalog-strings.inc' %]
1032
    [% Asset.js("js/catalog.js") | $raw %]
1190
    [% Asset.js("js/catalog.js") | $raw %]
Lines 1378-1383 Note that permanent location is a code, and location may be an authval. Link Here
1378
            if ( search_index ){ $('#cat-search-block select.advsearch').val(search_index)};
1536
            if ( search_index ){ $('#cat-search-block select.advsearch').val(search_index)};
1379
            if ( search_value ){ $('#cat-search-block #search-form').val(search_value)};
1537
            if ( search_value ){ $('#cat-search-block #search-form').val(search_value)};
1380
        });
1538
        });
1539
1540
        [% IF Koha.Preference('EnableItemGroups') %]
1541
            // Load item groups table
1542
            var itemGroupsTable = KohaTable("items-group-table", {
1543
                "bAutoWidth": false,
1544
                'sDom': '<"top pager"ilp>t<"bottom pager"ip>r',
1545
                "aoColumns": [
1546
                    {
1547
                        "mDataProp": function( oObj ) {
1548
                            return oObj.display_order;
1549
                        },
1550
                    },
1551
                    {
1552
                        "mDataProp": function( oObj ) {
1553
                            return oObj.description;
1554
                        },
1555
                    },
1556
                    {
1557
                        "mDataProp": function( oObj ) {
1558
                            [% IF CAN_user_editcatalogue_manage_item_groups %]
1559
                                return `<button class='item-group-edit btn btn-default btn-xs' data-item-group-id='${oObj.item_group_id}'>
1560
                                    <i class='fa fa-edit'></i> ${_("Edit")}
1561
                                </button>`
1562
                                + '&nbsp'
1563
                                + `<button class='item-group-delete btn btn-default btn-xs' data-item-group-id='${oObj.item_group_id}'>
1564
                                    <i class='fa fa-trash'></i> ${('Delete')}
1565
                                </button>`;
1566
                            [% ELSE %]
1567
                                return "";
1568
                            [% END %]
1569
                        },
1570
                    },
1571
                ],
1572
                "bPaginate": false,
1573
                "bProcessing": true,
1574
                "bServerSide": false,
1575
                "sAjaxSource": `/api/v1/biblios/${biblionumber}/item_groups?_per_page=-1`,
1576
                "sAjaxDataProp": "",
1577
                "fnServerData": function ( sSource, aoData, fnCallback ) {
1578
                    $.getJSON( sSource, aoData, function (json) {
1579
                        fnCallback(json)
1580
                    } );
1581
                },
1582
            });
1583
1584
            // Create new item groups
1585
            $('.item-group-create').on('click', function(){
1586
                $('#modal-item-group-create-form-description').val("");
1587
                $('#modal-item-group-create-submit').removeAttr('disabled');
1588
                $('#modal-item-group-create').modal('show');
1589
            });
1590
1591
            $("#modal-item-group-create-form").validate({
1592
                submitHandler: function(form) {
1593
                    $.ajax({
1594
                        url: `/api/v1/biblios/${biblionumber}/item_groups`,
1595
                        headers: { "x-koha-embed": "items" },
1596
                        success: function(item_groups){
1597
                            $('#modal-item-group-create-submit').attr('disabled', 'disabled');
1598
1599
                            var settings = {
1600
                              "url": `/api/v1/biblios/${biblionumber}/item_groups`,
1601
                              "method": "POST",
1602
                              "headers": {
1603
                                "Content-Type": "application/json"
1604
                              },
1605
                              "data": JSON.stringify(
1606
                                  {
1607
                                      "description": $("#modal-item-group-create-form-description").val(),
1608
                                      "display_order": $("#modal-item-group-create-form-display_order").val(),
1609
                                  }
1610
                              ),
1611
                            };
1612
1613
                            $.ajax(settings)
1614
                            .done(function (response) {
1615
                                $('#item-group-add-form-select').append($('<option>', {
1616
                                    value: response.item_group_id,
1617
                                    text: response.description
1618
                                }));
1619
1620
                                $('#modal-item-group-create').modal('hide');
1621
                                if ( item_groups.length == 0 ) {
1622
                                    // This bib has no previous item groups, reload the page
1623
                                    window.location.replace(`/cgi-bin/koha/catalogue/detail.pl?biblionumber=${biblionumber}`);
1624
                                } else {
1625
                                    // Has other item groups, just reload the table
1626
                                    itemGroupsTable.api().ajax.reload();
1627
                                }
1628
                            })
1629
                            .fail(function(err) {
1630
                                var message = err.responseJSON.error;
1631
                                alert(message);
1632
                            });
1633
                        }
1634
                    });
1635
                }
1636
            });
1637
1638
            $('#modal-item-group-create').on('shown.bs.modal', function () {
1639
                $('#modal-item-group-create-form-description').focus();
1640
            })
1641
1642
            // Edit existing item groups
1643
            $('body').on( 'click', '.item-group-edit', function(){
1644
                const item_group_id = $(this).data('item-group-id');
1645
                const url = `/api/v1/biblios/${biblionumber}/item_groups/${item_group_id}`;
1646
                $.get( url, function( data ) {
1647
                    $('#modal-item-group-edit-form-description').val( data.description );
1648
                    $('#modal-item-group-edit-form-display_order').val( data.display_order );
1649
                    $('#modal-item-group-edit-submit').data('item-group-id', item_group_id );
1650
                    $('#modal-item-group-edit-submit').removeAttr('disabled');
1651
                    $('#modal-item-group-edit').modal('show');
1652
                });
1653
            });
1654
1655
            $("#modal-item-group-edit-form").validate({
1656
                submitHandler: function(form) {
1657
                    $('#modal-item-group-edit-submit').attr('disabled', 'disabled');
1658
1659
                    const item_group_id = $('#modal-item-group-edit-submit').data('item-group-id');
1660
                    const url = `/api/v1/biblios/${biblionumber}/item_groups/${item_group_id}`;
1661
1662
                    var settings = {
1663
                      "url": url,
1664
                      "method": "PUT",
1665
                      "headers": {
1666
                        "Content-Type": "application/json"
1667
                      },
1668
                      "data": JSON.stringify(
1669
                          {
1670
                              "description": $("#modal-item-group-edit-form-description").val(),
1671
                              "display_order": $("#modal-item-group-edit-form-display_order").val(),
1672
                          }
1673
                      ),
1674
                    };
1675
1676
                    $.ajax(settings)
1677
                    .done(function (response) {
1678
                        $('#modal-item-group-edit').modal('hide');
1679
                        itemGroupsTable.api().ajax.reload();
1680
                    })
1681
                    .fail(function(err) {
1682
                        var message = err.responseJSON.error;
1683
                        alert(message);
1684
                    });
1685
                }
1686
            });
1687
1688
            $('#modal-item-group-edit').on('shown.bs.modal', function () {
1689
                $('#modal-item-group-edit-form-description').focus();
1690
            })
1691
1692
            // Delete existing item groups
1693
            $('body').on( 'click', '.item-group-delete', function(){
1694
                const item_group_id = $(this).data('item-group-id');
1695
                $('#modal-item-group-delete-submit').data('item-group-id', item_group_id );
1696
                $('#modal-item-group-delete-submit').removeAttr('disabled');
1697
                $('#modal-item-group-delete').modal('show');
1698
            });
1699
            $("#modal-item-group-delete-submit").on('click', function(){
1700
                $('#modal-item-group-delete-submit').attr('disabled', 'disabled');
1701
                const item_group_id = $("#modal-item-group-delete-submit").data('item-group-id');
1702
1703
                $.ajax({
1704
                    url: `/api/v1/biblios/${biblionumber}/item_groups/${item_group_id}`,
1705
                    headers: { "x-koha-embed": "items" },
1706
                    success: function(item_group_data){
1707
                        $.ajax({
1708
                          "url": `/api/v1/biblios/${biblionumber}/item_groups/${item_group_id}`,
1709
                          "method": "DELETE",
1710
                        })
1711
                        .done(function (response) {
1712
                            $('#modal-item-group-delete').modal('hide');
1713
                            $(`#item-group-add-form-select option[value='${item_group_id}']`).remove();
1714
                            if ( item_group_data.items === null ) {
1715
                                // No items for this item group, we can just refresh the table
1716
                                itemGroupsTable.api().ajax.reload();
1717
                            } else {
1718
                                // This item group had items attached to it, we need to reload the page
1719
                                window.location.replace(`/cgi-bin/koha/catalogue/detail.pl?biblionumber=${biblionumber}`);
1720
                            }
1721
                        })
1722
                        .fail(function(err) {
1723
                            var message = err.responseJSON.error;
1724
                            alert(message);
1725
                        });
1726
                    }
1727
                });
1728
            });
1729
1730
            // Add item(s) to a item group
1731
            $('.itemselection_action_item_group_set').on('click', function(){
1732
                $('#modal-item-group-set').modal('show');
1733
            });
1734
1735
            $("#modal-item-group-set-form").validate({
1736
                submitHandler: function(form) {
1737
                    $('#modal-item-group-set-submit').attr('disabled', 'disabled');
1738
1739
                    const item_group_id = $('#item-group-add-form-select').val();
1740
1741
                    let itemnumbers = new Array();
1742
                    $("input[name='itemnumber'][type='checkbox']:checked").each(function() {
1743
                        const itemnumber = $(this).val();
1744
                        itemnumbers.push( itemnumber );
1745
                    });
1746
                    if (itemnumbers.length > 0) {
1747
                        let url = '/cgi-bin/koha/catalogue/detail.pl?op=set_item_group';
1748
                        url += '&itemnumber=' + itemnumbers.join('&itemnumber=');
1749
                        url += '&biblionumber=[% biblionumber | uri %]';
1750
                        url += `&item_group_id=${item_group_id}`;
1751
1752
                        window.location.replace(url);
1753
                    }
1754
1755
                    $('#modal-item-group-set').modal('hide');
1756
                }
1757
            });
1758
1759
            // Remove item(s) from an item group
1760
            $('.itemselection_action_item_group_unset').on('click', function(){
1761
                $('#modal-item-group-unset').modal('show');
1762
            });
1763
1764
            $("#modal-item-group-unset-submit").on('click', function(){
1765
                $('#modal-item-group-unset-submit').attr('disabled', 'disabled');
1766
1767
                let itemnumbers = new Array();
1768
                $("input[name='itemnumber'][type='checkbox']:checked").each(function() {
1769
                    const itemnumber = $(this).val();
1770
                    itemnumbers.push( itemnumber );
1771
                });
1772
                if (itemnumbers.length > 0) {
1773
                    let url = '/cgi-bin/koha/catalogue/detail.pl?op=unset_item_group';
1774
                    url += '&itemnumber=' + itemnumbers.join('&itemnumber=');
1775
                    url += '&biblionumber=[% biblionumber | uri %]';
1776
1777
                    window.location.replace(url);
1778
                }
1779
1780
                $('#modal-item-group-unset').modal('hide');
1781
            });
1782
        [% END %]
1381
    </script>
1783
    </script>
1382
[% END %]
1784
[% END %]
1383
[% INCLUDE 'intranet-bottom.inc' %]
1785
[% INCLUDE 'intranet-bottom.inc' %]
1384
- 

Return to bug 24857