Bugzilla – Attachment 137318 Details for
Bug 24857
Add ability to group items for records
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24857: Add item group management to detail.pl
Bug-24857-Add-item-group-management-to-detailpl.patch (text/plain), 34.97 KB, created by
Kyle M Hall (khall)
on 2022-07-07 14:49:30 UTC
(
hide
)
Description:
Bug 24857: Add item group management to detail.pl
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2022-07-07 14:49:30 UTC
Size:
34.97 KB
patch
obsolete
>From d74bfabf59170abdb0aacea3ca5b016135f63ce7 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Tue, 8 Mar 2022 12:01:48 +0000 >Subject: [PATCH] Bug 24857: Add item group management to detail.pl > >Test Plan: >1) Apply the patches for this bug >2) Run updatedatabase.pl >3) Restart all the things! >4) Enable the new syspref EnableItemGroups >5) Browse to detail.pl for a record with items >6) Note the new Item Groups tab >7) Test creating, editing and deleting groups >8) On the Holdings tab, select one or more items using the checkboxes >8) Note new selection options for setting an item group for items, > and for clearing an item group for items. >9) Test adding and clearing the item group for items >--- > admin/columns_settings.yml | 4 + > catalogue/detail.pl | 37 ++ > .../prog/en/includes/html_helpers.inc | 24 +- > .../prog/en/modules/catalogue/detail.tt | 410 +++++++++++++++++- > 4 files changed, 462 insertions(+), 13 deletions(-) > >diff --git a/admin/columns_settings.yml b/admin/columns_settings.yml >index 3c4f7c2d320..7e68c4d0b5f 100644 >--- a/admin/columns_settings.yml >+++ b/admin/columns_settings.yml >@@ -358,6 +358,8 @@ modules: > columnname: holdings_homebranch > - > columnname: holdings_ccode >+ - >+ columnname: holdings_volume > - > columnname: holdings_itemcallnumber > - >@@ -421,6 +423,8 @@ modules: > columnname: otherholdings_homebranch > - > columnname: otherholdings_ccode >+ - >+ columnname: otherholdings_volume > - > columnname: otherholdings_itemcallnumber > - >diff --git a/catalogue/detail.pl b/catalogue/detail.pl >index a5f2ede6ba0..34447566b57 100755 >--- a/catalogue/detail.pl >+++ b/catalogue/detail.pl >@@ -47,7 +47,10 @@ use C4::HTML5Media; > use C4::CourseReserves qw( GetItemCourseReservesInfo ); > use Koha::AuthorisedValues; > use Koha::Biblios; >+use Koha::Biblio::ItemGroup::Items; >+use Koha::Biblio::ItemGroups; > use Koha::CoverImages; >+use Koha::DateUtils; > use Koha::Illrequests; > use Koha::Items; > use Koha::ItemTypes; >@@ -99,6 +102,39 @@ if ( not defined $record ) { > my $marc_record = eval { $biblio->metadata->record }; > $template->param( decoding_error => $@ ); > >+my $op = $query->param('op') || q{}; >+if ( $op eq 'set_item_group' ) { >+ my $item_group_id = $query->param('item_group_id'); >+ my @itemnumbers = $query->multi_param('itemnumber'); >+ >+ foreach my $item_id (@itemnumbers) { >+ my $item_group_item = Koha::Biblio::ItemGroup::Items->find( { item_id => $item_id } ); >+ >+ if ($item_group_item) { >+ $item_group_item->item_group_id($item_group_id); >+ } >+ else { >+ $item_group_item = Koha::Biblio::ItemGroup::Item->new( >+ { >+ item_id => $item_id, >+ item_group_id => $item_group_id, >+ } >+ ); >+ } >+ >+ $item_group_item->store(); >+ } >+} >+elsif ( $op eq 'unset_item_group' ) { >+ my $item_group_id = $query->param('item_group_id'); >+ my @itemnumbers = $query->multi_param('itemnumber'); >+ >+ foreach my $item_id (@itemnumbers) { >+ my $item_group_item = Koha::Biblio::ItemGroup::Items->find( { item_id => $item_id } ); >+ $item_group_item->delete() if $item_group_item; >+ } >+} >+ > if($query->cookie("holdfor")){ > my $holdfor_patron = Koha::Patrons->find( $query->cookie("holdfor") ); > if ( $holdfor_patron ) { >@@ -340,6 +376,7 @@ foreach my $item (@items) { > > # checking for holds > my $item_object = Koha::Items->find( $item->{itemnumber} ); >+ $item->{object} = $item_object; > my $holds = $item_object->current_holds; > if ( my $first_hold = $holds->next ) { > $item->{first_hold} = $first_hold; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc >index 97b64abd0a4..fdcc6eadfa9 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc >@@ -101,12 +101,12 @@ > > [% SET mv = subfield.marc_value %] > [% IF ( mv.type == 'hidden' ) %] >- <input type="hidden" id="[%- mv.id | html -%]" name="[% kohafield | html %]" class="input_marceditor" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]"> >+ <input type="hidden" id="[%- mv.id | html -%]" name="[% kohafield | html %]" class="input_marceditor [% kohafield | html %]" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]"> > [% ELSIF ( mv.type == 'select' ) %] > [% IF ( mv.readonly || subfield.IS_RETURN_CLAIM ) %] >- <select name="[% kohafield | html %]" id="[%- mv.id | html -%]" class="input_marceditor" readonly="readonly" disabled="disabled" data-width="50%"> >+ <select name="[% kohafield | html %]" id="[%- mv.id | html -%]" class="input_marceditor [% kohafield | html %]" readonly="readonly" disabled="disabled" data-width="50%"> > [% ELSE %] >- <select name="[% kohafield | html %]" id="[%- mv.id | html -%]" class="input_marceditor select2" data-category="[% mv.category | html %]" data-width="50%"> >+ <select name="[% kohafield | html %]" id="[%- mv.id | html -%]" class="input_marceditor select2 [% kohafield | html %]" data-category="[% mv.category | html %]" data-width="50%"> > [% END %] > > [% FOREACH aval IN mv.values %] >@@ -123,19 +123,19 @@ > </select> > [% ELSIF ( mv.type == 'text_auth' ) %] > [% IF mv.readonly %] >- <input type="text" id="[%- mv.id | html -%]" name="[% kohafield | html %]" class="input_marceditor" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" readonly="readonly" /> >+ <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" /> > [% ELSE %] >- <input type="text" id="[%- mv.id | html -%]" name="[% kohafield | html %]" class="input_marceditor" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" /> >+ <input type="text" id="[%- mv.id | html -%]" name="[% kohafield | html %]" class="input_marceditor [% kohafield | html %]" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" /> > [% SET dopop = "Dopop('/cgi-bin/koha/authorities/auth_finder.pl?authtypecode=\"${mv.authtypecode}\"&index=${mv.id}','${mv.id}')" %] > <a href="#" class="buttonDot" onclick="[%- dopop | html -%]; return false;" title="Tag editor">...</a> > [% END %] > [% ELSIF ( mv.type == 'text_plugin' ) %] > [% IF mv.readonly %] >- <input type="text" id="[%- mv.id | html -%]" name="[% kohafield | html %]" class="input_marceditor" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" readonly="readonly" /> >+ <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" /> > [% ELSE %] >- <input type="text" id="[%- mv.id | html -%]" name="[% kohafield | html %]" class="input_marceditor" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" /> >+ <input type="text" id="[%- mv.id | html -%]" name="[% kohafield | html %]" class="input_marceditor [% kohafield | html %]" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" /> > [% IF ( mv.nopopup ) %] >- <a href="#" id="buttonDot_[%- mv.id | html -%]" class="[%- mv.class | html -%]" title="No popup">...</a> >+ <a href="#" id="buttonDot_[%- mv.id | html -%]" class="[%- mv.class | html -%]" title="No popup">...</a> > [% ELSE %] > <a href="#" id="buttonDot_[%- mv.id | html -%]" class="[%- mv.class | html -%]" title="Tag editor">...</a> > [% END %] >@@ -145,15 +145,15 @@ > [% END %] > [% ELSIF ( mv.type == 'text' ) %] > [% IF mv.readonly %] >- <input type="text" id="[%- mv.id | html -%]" name="[% kohafield | html %]" class="input_marceditor" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" readonly="readonly" /> >+ <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" /> > [% ELSE %] >- <input type="text" id="[%- mv.id | html -%]" name="[% kohafield | html %]" class="input_marceditor" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" /> >+ <input type="text" id="[%- mv.id | html -%]" name="[% kohafield | html %]" class="input_marceditor [% kohafield | html %]" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" /> > [% END %] > [% ELSIF ( mv.type == 'textarea' ) %] > [% IF mv.readonly %] >- <textarea id="[%- mv.id | html -%]" name="[% kohafield | html %]" class="input_marceditor" rows="5" cols="64" readonly="readonly" >[% mv.value | html %]</textarea> >+ <textarea id="[%- mv.id | html -%]" name="[% kohafield | html %]" class="input_marceditor [% kohafield | html %]" rows="5" cols="64" readonly="readonly" >[% mv.value | html %]</textarea> > [% ELSE %] >- <textarea id="[%- mv.id | html -%]" name="[% kohafield | html %]" class="input_marceditor" rows="5" cols="64" >[% mv.value | html %]</textarea> >+ <textarea id="[%- mv.id | html -%]" name="[% kohafield | html %]" class="input_marceditor [% kohafield | html %]" rows="5" cols="64" >[% mv.value | html %]</textarea> > [% END %] > [% END %] > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >index 117046cd6d8..eeecfd16692 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >@@ -283,7 +283,12 @@ > <a href="#holdings" aria-controls="holdings" role="tab" data-toggle="tab">Holdings ([% itemloop.size() || 0 | html %])</a> > </li> > [% END %] >-[% IF ( MARCNOTES ) %]<li role="presentation"><a href="#description" aria-controls="description" role="tab" data-toggle="tab">Descriptions ([% ( MARCNOTES.size || 1 ) | html %])</a></li>[% END %] >+ [% IF Koha.Preference('EnableItemGroups') %] >+ <li role="presentation"> >+ <a href="#item_groups" aria-controls="item_groups" role="tab" data-toggle="tab">Item groups</a> >+ </li> >+ [% END %] >+[% 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 %] > [% 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 %] > [% IF ( subscriptionsnumber ) %]<li role="presentation"><a href="#subscriptions" aria-controls="subscriptions" role="tab" data-toggle="tab">Subscriptions</a></li>[% END %] > [% 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 %] >@@ -321,6 +326,10 @@ > [% IF CAN_user_tools_items_batchmod %] > <a class="itemselection_action_modify"><i class="fa fa-pencil"></i> Modify selected items</a> > [% END %] >+ [% IF CAN_user_editcatalogue_manage_item_groups && biblio.item_groups.count %] >+ <a class="itemselection_action_item_group_set" href="#"><i class="fa fa-book"></i> Add/move to item group</a> >+ <a class="itemselection_action_item_group_unset" href="#"><i class="fa fa-unlink"></i> Remove from item group</a> >+ [% END %] > </span> > [% END %] > </div> >@@ -335,6 +344,9 @@ > <th id="[% tab | html %]_holdingbranch" data-colname="[% tab | html %]_holdingbranch">Current library</th> > <th id="[% tab | html %]_homebranch" data-colname="[% tab | html %]_homebranch">Home library</th> > [% IF ( itemdata_ccode ) %]<th id="[% tab | html %]_ccode" data-colname="[% tab | html %]_ccode">Collection</th>[% END %] >+ [% IF Koha.Preference('EnableItemGroups') %] >+ <th id="[% tab | html %]_item_group" data-colname="[% tab | html %]_item_group">Item group</th> >+ [% END %] > <th id="[% tab | html %]_itemcallnumber" data-colname="[% tab | html %]_itemcallnumber">Call number</th> > [% IF volinfo %] > <th id="[% tab | html %]_enumchron" data-colname="[% tab | html %]_enumchron">Serial enumeration / chronology</th> >@@ -411,6 +423,7 @@ Note that permanent location is a code, and location may be an authval. > </span> > </td> > [% IF ( itemdata_ccode ) %]<td>[% item.ccode | html %]</td>[% END %] >+ [% IF Koha.Preference('EnableItemGroups') %]<td class="item_group">[% item.object.item_group.description | html %]</td>[% END %] > <td class="itemcallnumber">[% IF ( item.itemcallnumber ) %] [% item.itemcallnumber | html %][% END %]</td> > [% IF ( volinfo ) %] > [% IF itemdata_publisheddate #If there is at least one published date, use it for sorting %] >@@ -627,6 +640,26 @@ Note that permanent location is a code, and location may be an authval. > > [% END %][%# end of block items_table %] > >+[% IF Koha.Preference('EnableItemGroups') %] >+ <div role="tabpanel" class="tab-pane" id="item_groups"> >+ [% IF CAN_user_editcatalogue_manage_item_groups %] >+ <div class="item_groups_table_table_controls"> >+ <a href="#" class="item-group-create btn btn-default btn-xs"><i class="fa fa-plus"></i> New item group</a> >+ </div> >+ [% END %] >+ <table class="items-group-table" id="items-group-table"> >+ <thead> >+ <tr> >+ <td>Display Order</td> >+ <td>Description</td> >+ <td> </td> >+ </tr> >+ </thead> >+ </table> >+ </div> >+[% END %] >+ >+ > <div role="tabpanel" class="tab-pane" id="holdings"> > > [% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectStaffProfile') && Koha.Preference('NovelistSelectStaffView') == 'above' ) %] >@@ -1059,6 +1092,136 @@ Note that permanent location is a code, and location may be an authval. > > [% END %] > >+<div class="modal fade" id="modal-item-group-create" tabindex="-1" role="dialog" aria-labelledby="modal-item-group-create-label"> >+ <div class="modal-dialog"> >+ <div class="modal-content"> >+ <div class="modal-header"> >+ <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">Ã</button> >+ <h3 id="modal-item-group-create-label"><i class="fa fa-plus"></i> Create a new item group</h3> >+ </div> >+ <form id="modal-item-group-create-form" class="validated"> >+ <div class="modal-body"> >+ <fieldset> >+ <p> >+ <label for="item_group_description" class="required">Name: </label> >+ <input name="description" id="modal-item-group-create-form-description" type="text" size="30" required="required" class="required" /> >+ <span class="required">Required</span> >+ </p> >+ <p> >+ <label for="item_group_display_order" class="required">Display order: </label> >+ <input name="display_order" id="modal-item-group-create-form-display_order" value="0" size="5" required="required" class="required" /> >+ <span class="required">Required</span> >+ <br/> >+ <span class="hint">Numbers only, item groups will be displayed in counting order</span> >+ </p> >+ </fieldset> >+ </div> >+ <div class="modal-footer"> >+ <button id="modal-item-group-create-submit" class="btn btn-default"><i class="fa fa-plus"></i> Submit</button> >+ <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button> >+ </div> >+ </form> >+ </div> >+ </div> >+</div> >+ >+<div class="modal fade" id="modal-item-group-edit" tabindex="-1" role="dialog" aria-labelledby="modal-item-group-edit-label"> >+ <div class="modal-dialog"> >+ <div class="modal-content"> >+ <div class="modal-header"> >+ <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">Ã</button> >+ <h3 id="modal-item-group-edit-label"><i class='fa fa-edit'></i> Edit item group</h3> >+ </div> >+ <form id="modal-item-group-edit-form" class="validated"> >+ <div class="modal-body"> >+ <fieldset> >+ <p> >+ <label for="item_group_description" class="required">Name: </label> >+ <input name="description" id="modal-item-group-edit-form-description" type="text" size="30" required="required" class="required" /> >+ <span class="required">Required</span> >+ </p> >+ <p> >+ <label for="item_group_display_order" class="required">Sort order: </label> >+ <input name="display_order" id="modal-item-group-edit-form-display_order" size="5" /> >+ <span class="hint">Numbers only, item groups will be displayed in counting order</span> >+ </p> >+ </fieldset> >+ </div> >+ <div class="modal-footer"> >+ <button id="modal-item-group-edit-submit" class="btn btn-default"><i class='fa fa-edit'></i> Submit</button> >+ <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button> >+ </div> >+ </form> >+ </div> >+ </div> >+</div> >+ >+<div class="modal fade" id="modal-item-group-delete" tabindex="-1" role="dialog" aria-labelledby="modal-item-group-delete-label"> >+ <div class="modal-dialog"> >+ <div class="modal-content"> >+ <div class="modal-header"> >+ <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">Ã</button> >+ <h3 id="modal-item-group-delete-label"><i class='fa fa-trash'></i> Delete item group</h3> >+ </div> >+ <div class="modal-body"> >+ Are you sure you want to delete this item group? >+ </div> >+ <div class="modal-footer"> >+ <button id="modal-item-group-delete-submit" class="btn btn-danger"><i class='fa fa-trash'></i> Delete</button> >+ <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button> >+ </div> >+ </div> >+ </div> >+</div> >+ >+<div class="modal fade" id="modal-item-group-set" tabindex="-1" role="dialog" aria-labelledby="modal-item-group-set-label"> >+ <div class="modal-dialog"> >+ <div class="modal-content"> >+ <div class="modal-header"> >+ <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">Ã</button> >+ <h3 id="modal-item-group-set-label"><i class='fa fa-book'></i> Set item group for items</h3> >+ </div> >+ <form id="modal-item-group-set-form" class="validated"> >+ <div class="modal-body"> >+ <fieldset> >+ <p> >+ <label for="item_group" class="required">Item group: </label> >+ <select name="item_group" id="item-group-add-form-select"> >+ [% FOREACH ig IN biblio.item_groups %] >+ <option value="[% ig.id | html %]">[% ig.description | html %]</option> >+ [% END %] >+ </select> >+ <span class="required">Required</span> >+ </p> >+ </fieldset> >+ </div> >+ <div class="modal-footer"> >+ <button id="modal-item-group-set-submit" class="btn btn-default"><i class='fa fa-book'></i> Set item group</button> >+ <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button> >+ </div> >+ </form> >+ </div> >+ </div> >+</div> >+ >+<div class="modal fade" id="modal-item-group-unset" tabindex="-1" role="dialog" aria-labelledby="modal-item-group-unset-label"> >+ <div class="modal-dialog"> >+ <div class="modal-content"> >+ <div class="modal-header"> >+ <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">Ã</button> >+ <h3 id="modal-item-group-unset-label"><i class='fa fa-unlink'></i> Remove item from item group</h3> >+ </div> >+ <div class="modal-body"> >+ Are you sure you want to remove these item(s) from their item group(s)? >+ </div> >+ <div class="modal-footer"> >+ <button id="modal-item-group-unset-submit" class="btn btn-danger"><i class='fa fa-unlink'></i> Remove</button> >+ <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button> >+ </div> >+ </div> >+ </div> >+</div> >+ > [% MACRO jsinclude BLOCK %] > [% INCLUDE 'catalog-strings.inc' %] > [% Asset.js("js/catalog.js") | $raw %] >@@ -1419,6 +1582,251 @@ Note that permanent location is a code, and location may be an authval. > if ( search_value ){ $('#cat-search-block #search-form').val(search_value)}; > }); > [% END %] >+ >+ [% IF Koha.Preference('EnableItemGroups') %] >+ // Load item groups table >+ var itemGroupsTable = KohaTable("items-group-table", { >+ "bAutoWidth": false, >+ 'sDom': '<"top pager"ilp>t<"bottom pager"ip>r', >+ "aoColumns": [ >+ { >+ "mDataProp": function( oObj ) { >+ return oObj.display_order; >+ }, >+ }, >+ { >+ "mDataProp": function( oObj ) { >+ return oObj.description; >+ }, >+ }, >+ { >+ "mDataProp": function( oObj ) { >+ [% IF CAN_user_editcatalogue_manage_item_groups %] >+ return `<button class='item-group-edit btn btn-default btn-xs' data-item-group-id='${oObj.item_group_id}'> >+ <i class='fa fa-edit'></i> ${_("Edit")} >+ </button>` >+ + ' ' >+ + `<button class='item-group-delete btn btn-default btn-xs' data-item-group-id='${oObj.item_group_id}'> >+ <i class='fa fa-trash'></i> ${('Delete')} >+ </button>`; >+ [% ELSE %] >+ return ""; >+ [% END %] >+ }, >+ }, >+ ], >+ "bPaginate": false, >+ "bProcessing": true, >+ "bServerSide": false, >+ "sAjaxSource": `/api/v1/biblios/${biblionumber}/item_groups?_per_page=-1`, >+ "sAjaxDataProp": "", >+ "fnServerData": function ( sSource, aoData, fnCallback ) { >+ $.getJSON( sSource, aoData, function (json) { >+ fnCallback(json) >+ } ); >+ }, >+ }); >+ >+ // Create new item groups >+ $('.item-group-create').on('click', function(){ >+ $('#modal-item-group-create-form-description').val(""); >+ $('#modal-item-group-create-submit').removeAttr('disabled'); >+ $('#modal-item-group-create').modal('show'); >+ }); >+ >+ $("#modal-item-group-create-form").validate({ >+ submitHandler: function(form) { >+ $.ajax({ >+ url: `/api/v1/biblios/${biblionumber}/item_groups`, >+ headers: { "x-koha-embed": "items" }, >+ success: function(item_groups){ >+ $('#modal-item-group-create-submit').attr('disabled', 'disabled'); >+ >+ var settings = { >+ "url": `/api/v1/biblios/${biblionumber}/item_groups`, >+ "method": "POST", >+ "headers": { >+ "Content-Type": "application/json" >+ }, >+ "data": JSON.stringify( >+ { >+ "description": $("#modal-item-group-create-form-description").val(), >+ "display_order": $("#modal-item-group-create-form-display_order").val(), >+ } >+ ), >+ }; >+ >+ $.ajax(settings) >+ .done(function (response) { >+ $('#item-group-add-form-select').append($('<option>', { >+ value: response.item_group_id, >+ text: response.description >+ })); >+ >+ $('#modal-item-group-create').modal('hide'); >+ if ( item_groups.length == 0 ) { >+ // This bib has no previous item groups, reload the page >+ window.location.replace(`/cgi-bin/koha/catalogue/detail.pl?biblionumber=${biblionumber}`); >+ } else { >+ // Has other item groups, just reload the table >+ itemGroupsTable.api().ajax.reload(); >+ } >+ }) >+ .fail(function(err) { >+ var message = err.responseJSON.error; >+ alert(message); >+ }); >+ } >+ }); >+ } >+ }); >+ >+ $('#modal-item-group-create').on('shown.bs.modal', function () { >+ $('#modal-item-group-create-form-description').focus(); >+ }) >+ >+ // Edit existing item groups >+ $('body').on( 'click', '.item-group-edit', function(){ >+ const item_group_id = $(this).data('item-group-id'); >+ const url = `/api/v1/biblios/${biblionumber}/item_groups/${item_group_id}`; >+ $.get( url, function( data ) { >+ $('#modal-item-group-edit-form-description').val( data.description ); >+ $('#modal-item-group-edit-form-display_order').val( data.display_order ); >+ $('#modal-item-group-edit-submit').data('item-group-id', item_group_id ); >+ $('#modal-item-group-edit-submit').removeAttr('disabled'); >+ $('#modal-item-group-edit').modal('show'); >+ }); >+ }); >+ >+ $("#modal-item-group-edit-form").validate({ >+ submitHandler: function(form) { >+ $('#modal-item-group-edit-submit').attr('disabled', 'disabled'); >+ >+ const item_group_id = $('#modal-item-group-edit-submit').data('item-group-id'); >+ const url = `/api/v1/biblios/${biblionumber}/item_groups/${item_group_id}`; >+ >+ var settings = { >+ "url": url, >+ "method": "PUT", >+ "headers": { >+ "Content-Type": "application/json" >+ }, >+ "data": JSON.stringify( >+ { >+ "description": $("#modal-item-group-edit-form-description").val(), >+ "display_order": $("#modal-item-group-edit-form-display_order").val(), >+ } >+ ), >+ }; >+ >+ $.ajax(settings) >+ .done(function (response) { >+ $('#modal-item-group-edit').modal('hide'); >+ itemGroupsTable.api().ajax.reload(); >+ }) >+ .fail(function(err) { >+ var message = err.responseJSON.error; >+ alert(message); >+ }); >+ } >+ }); >+ >+ $('#modal-item-group-edit').on('shown.bs.modal', function () { >+ $('#modal-item-group-edit-form-description').focus(); >+ }) >+ >+ // Delete existing item groups >+ $('body').on( 'click', '.item-group-delete', function(){ >+ const item_group_id = $(this).data('item-group-id'); >+ $('#modal-item-group-delete-submit').data('item-group-id', item_group_id ); >+ $('#modal-item-group-delete-submit').removeAttr('disabled'); >+ $('#modal-item-group-delete').modal('show'); >+ }); >+ $("#modal-item-group-delete-submit").on('click', function(){ >+ $('#modal-item-group-delete-submit').attr('disabled', 'disabled'); >+ const item_group_id = $("#modal-item-group-delete-submit").data('item-group-id'); >+ >+ $.ajax({ >+ url: `/api/v1/biblios/${biblionumber}/item_groups/${item_group_id}`, >+ headers: { "x-koha-embed": "items" }, >+ success: function(item_group_data){ >+ $.ajax({ >+ "url": `/api/v1/biblios/${biblionumber}/item_groups/${item_group_id}`, >+ "method": "DELETE", >+ }) >+ .done(function (response) { >+ $('#modal-item-group-delete').modal('hide'); >+ $(`#item-group-add-form-select option[value='${item_group_id}']`).remove(); >+ if ( item_group_data.items === null ) { >+ // No items for this item group, we can just refresh the table >+ itemGroupsTable.api().ajax.reload(); >+ } else { >+ // This item group had items attached to it, we need to reload the page >+ window.location.replace(`/cgi-bin/koha/catalogue/detail.pl?biblionumber=${biblionumber}`); >+ } >+ }) >+ .fail(function(err) { >+ var message = err.responseJSON.error; >+ alert(message); >+ }); >+ } >+ }); >+ }); >+ >+ // Add item(s) to a item group >+ $('.itemselection_action_item_group_set').on('click', function(){ >+ $('#modal-item-group-set').modal('show'); >+ }); >+ >+ $("#modal-item-group-set-form").validate({ >+ submitHandler: function(form) { >+ $('#modal-item-group-set-submit').attr('disabled', 'disabled'); >+ >+ const item_group_id = $('#item-group-add-form-select').val(); >+ >+ let itemnumbers = new Array(); >+ $("input[name='itemnumber'][type='checkbox']:checked").each(function() { >+ const itemnumber = $(this).val(); >+ itemnumbers.push( itemnumber ); >+ }); >+ if (itemnumbers.length > 0) { >+ let url = '/cgi-bin/koha/catalogue/detail.pl?op=set_item_group'; >+ url += '&itemnumber=' + itemnumbers.join('&itemnumber='); >+ url += '&biblionumber=[% biblionumber | uri %]'; >+ url += `&item_group_id=${item_group_id}`; >+ >+ window.location.replace(url); >+ } >+ >+ $('#modal-item-group-set').modal('hide'); >+ } >+ }); >+ >+ // Remove item(s) from an item group >+ $('.itemselection_action_item_group_unset').on('click', function(){ >+ $('#modal-item-group-unset').modal('show'); >+ }); >+ >+ $("#modal-item-group-unset-submit").on('click', function(){ >+ $('#modal-item-group-unset-submit').attr('disabled', 'disabled'); >+ >+ let itemnumbers = new Array(); >+ $("input[name='itemnumber'][type='checkbox']:checked").each(function() { >+ const itemnumber = $(this).val(); >+ itemnumbers.push( itemnumber ); >+ }); >+ if (itemnumbers.length > 0) { >+ let url = '/cgi-bin/koha/catalogue/detail.pl?op=unset_item_group'; >+ url += '&itemnumber=' + itemnumbers.join('&itemnumber='); >+ url += '&biblionumber=[% biblionumber | uri %]'; >+ >+ window.location.replace(url); >+ } >+ >+ $('#modal-item-group-unset').modal('hide'); >+ >+ }); >+ [% END %] > </script> > [% END %] > [% INCLUDE 'intranet-bottom.inc' %] >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 24857
:
100652
|
100653
|
100654
|
100655
|
100656
|
100657
|
100658
|
100659
|
100660
|
100661
|
100662
|
101637
|
101638
|
101639
|
101640
|
101641
|
101642
|
101643
|
101644
|
101645
|
101646
|
101647
|
101648
|
101650
|
101651
|
101652
|
101653
|
101654
|
101655
|
101656
|
101657
|
101658
|
101659
|
101660
|
101661
|
101670
|
101671
|
101672
|
101673
|
101674
|
101675
|
101676
|
101677
|
101678
|
101679
|
101680
|
101681
|
101730
|
101731
|
101732
|
101733
|
101734
|
101735
|
101736
|
101737
|
101738
|
101739
|
101740
|
101741
|
101752
|
101753
|
101754
|
101755
|
101756
|
101757
|
101758
|
101759
|
101760
|
101761
|
101762
|
101763
|
104952
|
104953
|
104954
|
104955
|
104956
|
104957
|
104958
|
104959
|
104960
|
104961
|
104962
|
104963
|
104964
|
104966
|
106728
|
106729
|
106730
|
106731
|
106732
|
106733
|
106734
|
106735
|
106736
|
106737
|
106738
|
106739
|
106740
|
106741
|
108443
|
108444
|
108445
|
108446
|
108447
|
108448
|
108449
|
108450
|
108451
|
108452
|
108453
|
108454
|
108455
|
108456
|
108666
|
108667
|
108668
|
108669
|
108670
|
108671
|
108672
|
108673
|
108674
|
108675
|
108676
|
108677
|
108678
|
108679
|
108680
|
108681
|
108682
|
108683
|
108684
|
108685
|
108686
|
109074
|
109075
|
109076
|
109077
|
109078
|
109079
|
109080
|
109081
|
109082
|
109083
|
109084
|
109085
|
109086
|
109087
|
109088
|
109089
|
109090
|
109091
|
109092
|
109093
|
109094
|
109795
|
109796
|
109797
|
109798
|
109799
|
109800
|
109801
|
109802
|
109803
|
109804
|
109805
|
109806
|
109807
|
109808
|
109809
|
109810
|
109811
|
109812
|
109813
|
109814
|
109815
|
109894
|
109901
|
109902
|
109903
|
109904
|
109905
|
109906
|
109907
|
109908
|
109909
|
109910
|
109911
|
109912
|
109913
|
109914
|
109915
|
109916
|
109917
|
109918
|
109919
|
109920
|
109921
|
109922
|
109923
|
113136
|
113137
|
113138
|
113139
|
113140
|
113141
|
113142
|
113143
|
113144
|
113145
|
113146
|
113147
|
113148
|
113149
|
113150
|
113151
|
113152
|
113153
|
113154
|
113155
|
113156
|
113157
|
113158
|
113159
|
113160
|
113168
|
113169
|
113170
|
113171
|
113172
|
113173
|
113174
|
113175
|
113176
|
113177
|
113178
|
113179
|
113180
|
113181
|
113182
|
113183
|
113184
|
113185
|
113186
|
113187
|
113188
|
113189
|
113190
|
113191
|
120495
|
120496
|
120497
|
120498
|
120499
|
120500
|
120501
|
120502
|
120503
|
120504
|
120505
|
120506
|
120507
|
120508
|
120509
|
120510
|
120511
|
120512
|
120513
|
120514
|
120515
|
120516
|
120517
|
120518
|
122808
|
122809
|
122810
|
122811
|
122812
|
122813
|
122814
|
122815
|
122816
|
122817
|
122818
|
122819
|
122820
|
122821
|
122822
|
122823
|
122824
|
122825
|
122826
|
122827
|
122828
|
122829
|
122830
|
122831
|
123882
|
123883
|
123884
|
123885
|
123886
|
123887
|
123888
|
123889
|
123890
|
123891
|
123892
|
123893
|
123894
|
123895
|
123896
|
123897
|
123898
|
123899
|
123900
|
123901
|
123902
|
123903
|
123904
|
123905
|
123906
|
123907
|
123908
|
123909
|
123910
|
123912
|
124021
|
124022
|
124023
|
124024
|
124025
|
124026
|
124027
|
124028
|
124029
|
124030
|
124031
|
124032
|
124033
|
124034
|
124035
|
124036
|
124037
|
124038
|
124039
|
124040
|
124041
|
124042
|
124043
|
124044
|
124045
|
124046
|
124047
|
124048
|
124049
|
124050
|
124051
|
124052
|
124053
|
124331
|
124332
|
124333
|
124334
|
124335
|
124336
|
124337
|
124338
|
124339
|
124340
|
124341
|
124342
|
124343
|
124344
|
124345
|
124346
|
124347
|
124348
|
124349
|
124351
|
124352
|
124353
|
124354
|
124355
|
124356
|
124357
|
124358
|
124359
|
124360
|
124361
|
124362
|
124363
|
124421
|
124463
|
124583
|
124584
|
124585
|
124586
|
124587
|
124588
|
124589
|
124590
|
124591
|
124592
|
124593
|
124594
|
124595
|
124596
|
124597
|
124598
|
124599
|
124600
|
124601
|
124602
|
124603
|
124604
|
124605
|
124606
|
124607
|
124608
|
124609
|
124610
|
124611
|
124612
|
124613
|
124614
|
124615
|
131449
|
131450
|
131451
|
131452
|
131453
|
131454
|
131455
|
131456
|
134288
|
134289
|
134290
|
134291
|
134292
|
134293
|
134294
|
134295
|
134296
|
135590
|
135591
|
135592
|
135593
|
135594
|
135595
|
135596
|
135597
|
135598
|
135599
|
135600
|
135601
|
135602
|
135603
|
135604
|
135605
|
135606
|
135607
|
135608
|
135609
|
135610
|
135614
|
135615
|
135616
|
135617
|
135618
|
135619
|
135620
|
135621
|
135622
|
135623
|
135624
|
135625
|
135626
|
135627
|
135628
|
135629
|
137259
|
137260
|
137261
|
137262
|
137263
|
137264
|
137265
|
137266
|
137267
|
137268
|
137311
|
137314
|
137315
|
137316
|
137317
| 137318 |
137319
|
137320
|
137321
|
137322
|
137323
|
137441
|
137442
|
137443
|
137608
|
138933