@@ -, +, @@ --- Koha/Item.pm | 25 ++++++++++++++++++- Koha/Schema/Result/Item.pm | 24 ++++++++++++++++++ api/v1/swagger/definitions/item.yaml | 8 ++++++ api/v1/swagger/paths/biblios.yaml | 2 ++ .../tables/items/catalogue_detail.inc | 5 ++-- 5 files changed, 61 insertions(+), 3 deletions(-) --- a/Koha/Item.pm +++ a/Koha/Item.pm @@ -385,8 +385,19 @@ sub effective_itemtype { =cut sub home_branch { - my ($self) = @_; + return shift->home_library(@_); +} + +=head3 home_library + +my $library = $item->home_library +Return the Koha::Library object representing the home library + +=cut + +sub home_library { + my ($self) = @_; my $hb_rs = $self->_result->homebranch; return Koha::Library->_new_from_dbic( $hb_rs ); @@ -397,6 +408,18 @@ sub home_branch { =cut sub holding_branch { + return shift->home_library(@_); +} + +=head3 holding_library + +my $library = $item->holding_library + +Return the Koha::Library object representing the holding library + +=cut + +sub holding_library { my ($self) = @_; my $hb_rs = $self->_result->holdingbranch; --- a/Koha/Schema/Result/Item.pm +++ a/Koha/Schema/Result/Item.pm @@ -995,6 +995,30 @@ __PACKAGE__->belongs_to( { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, ); +__PACKAGE__->belongs_to( + "holding_library", + "Koha::Schema::Result::Branch", + { branchcode => "holdingbranch" }, + { + is_deferrable => 1, + join_type => "LEFT", + on_delete => "RESTRICT", + on_update => "CASCADE", + }, +); + +__PACKAGE__->belongs_to( + "home_library", + "Koha::Schema::Result::Branch", + { branchcode => "homebranch" }, + { + is_deferrable => 1, + join_type => "LEFT", + on_delete => "RESTRICT", + on_update => "CASCADE", + }, +); + __PACKAGE__->add_columns( '+bookable' => { is_boolean => 1 }, '+exclude_from_local_holds_priority' => { is_boolean => 1 }, --- a/api/v1/swagger/definitions/item.yaml +++ a/api/v1/swagger/definitions/item.yaml @@ -230,6 +230,14 @@ properties: type: - object - "null" + home_library: + type: + - object + - "null" + holding_library: + type: + - object + - "null" cover_image_ids: type: - array --- a/api/v1/swagger/paths/biblios.yaml +++ a/api/v1/swagger/paths/biblios.yaml @@ -423,6 +423,8 @@ type: string enum: - +strings + - home_library + - holding_library - biblio.title - checkout - checkout.patron --- a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc +++ a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc @@ -179,6 +179,7 @@ [%# Do we need separate/new endpoints or do we hack the somewhere client-side? %] let item_table_url = "/api/v1/biblios/[% biblio.biblionumber | uri %]/items?"; let embed = ["+strings,checkout,checkout.patron,transfer,transfer+strings,first_hold,first_hold+strings,first_hold.patron,first_hold.desk,item_type"]; + embed.push('home_library', 'holding_library'); [% IF Koha.Preference('LocalCoverImages') %] embed.push('cover_image_ids'); [% END %] @@ -300,7 +301,7 @@ }, [% END %] { - data: "me.holding_library_id", + data: "me.holding_library_id:holding_library.name", className: "location", searchable: true, orderable: true, @@ -309,7 +310,7 @@ } }, { - data: "me.home_library_id", + data: "me.home_library_id:home_library.name", className: "homebranch", searchable: true, orderable: true, --