@@ -, +, @@
---
Koha/Item.pm | 27 +++++++++++++++++++
api/v1/swagger/definitions/item.yaml | 10 +++++++
api/v1/swagger/paths/biblios.yaml | 2 ++
.../prog/en/modules/catalogue/detail.tt | 23 +++++++++-------
4 files changed, 53 insertions(+), 9 deletions(-)
--- a/Koha/Item.pm
+++ a/Koha/Item.pm
@@ -1888,6 +1888,33 @@ sub bundle_items {
return Koha::Items->_new_from_dbic($rs);
}
+
+=head3 bundle_items_not_lost
+
+ my $bundle_items = $item->bundle_items_not_lost;
+
+Returns the items associated with this bundle that are not lost
+
+=cut
+
+sub bundle_items_not_lost {
+ my ($self) = @_;
+ return $self->bundle_items->search( { itemlost => { '!=' => 0 } } );
+}
+
+=head3 bundle_items_lost
+
+ my $bundle_items = $item->bundle_items_lost;
+
+Returns the items associated with this bundle that are lost
+
+=cut
+
+sub bundle_items_lost {
+ my ($self) = @_;
+ return $self->bundle_items->search( { itemlost => 0 } );
+}
+
=head3 is_bundle
my $is_bundle = $item->is_bundle;
--- a/api/v1/swagger/definitions/item.yaml
+++ a/api/v1/swagger/definitions/item.yaml
@@ -270,6 +270,16 @@ properties:
type:
- object
- "null"
+ bundle_items_lost_count:
+ type:
+ - integer
+ - "null"
+ description: Number of lost items in the bundle
+ bundle_items_not_lost_count:
+ type:
+ - integer
+ - "null"
+ description: Number of items not lost in the bundle
course_item:
type:
- object
--- a/api/v1/swagger/paths/biblios.yaml
+++ a/api/v1/swagger/paths/biblios.yaml
@@ -437,6 +437,8 @@
- item_type
- in_bundle
- bundle_host
+ - bundle_items_lost+count
+ - bundle_items_not_lost+count
- course_item.course_reserves.course
- cover_image_ids
- item_group_item.item_group.description
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt
@@ -1857,14 +1857,15 @@
[% IF bundlesEnabled %]
// Add event listener for opening and closing bundle details
- $('#' + table_name + ' tbody').on('click', 'button.details-control', function () {
+ $('#' + tab_id + '_table tbody').on('click', 'button.details-control', function () {
var button = $(this);
var tr = button.closest('tr');
var dTable = button.closest('table').DataTable({ 'retrieve': true });
- var itemnumber = tr.data('itemnumber');
- var duedate = tr.data('duedate');
- var row = dTable.row( tr );
+ let row = dTable.row( tr );
+ let data = row.data();
+ let itemnumber = data.item_id;
+ let duedate = (data.checkout&&data.checkout.due_date) || null;
if ( row.child.isShown() ) {
// This row is already open - close it
@@ -2186,7 +2187,9 @@
[% IF Koha.Preference('UseRecalls') %]
embed.push('recall', 'recall+strings', 'recall.patron')
[% END %]
- embed.push('in_bundle', 'bundle_host');
+ [% IF bundlesEnabled %]
+ embed.push('in_bundle', 'bundle_host', 'bundle_items_lost+count', 'bundle_items_not_lost+count');
+ [% END %]
[% IF Koha.Preference('UseCourseReserves') %]
embed.push('course_item.course_reserves.course');
[% END %]
@@ -2460,9 +2463,11 @@
nodes += '(%s)'.format(escape_str(av_restricted.get(row.restricted_status.toString())));
}
- if ( row.in_bundle ) {
- nodes += '%s'.format(_("In bundle: %s").format($biblio_to_html(row.bundle_host.biblio, { link: true })));
- }
+ [% IF bundlesEnabled %]
+ if ( row.in_bundle ) {
+ nodes += '%s'.format(_("In bundle: %s").format($biblio_to_html(row.bundle_host.biblio, { link: true })));
+ }
+ [% END %]
return nodes;
}
},
@@ -2659,7 +2664,7 @@
}
[% IF bundlesEnabled %]
// FIXME How do we handle that correctly?
- //nodes += ''.format(escape_str(row.bundled), escape_str(row.bundled_lost));
+ nodes += ''.format(escape_str(row.bundle_items_not_lost_count), escape_str(row.bundle_items_lost_count));
[% END %]
return nodes;
--