From 8dc23f90869595d5c99e0cc2f562d8ae3653bc4c Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Tue, 7 May 2024 12:45:24 +0000 Subject: [PATCH] Bug 36182: Show vendor name if acquisition_source is a vendor_id This will make it so if acquisition_source is of an existing vendor_id, it'll show the vendor name instead of the id. If it's not of an existing vendor_id, show the raw value instead. I'm not 100% happy with this patch as it adds an edge case to Item::strings_map but I believe the only alternative is to make 952$e Source of acquisition an AV field in the default framework. Not only that, but this would have to be an AV field of type 'vendors' that'd have to allow to pick from existing vendors (similar to current 'branches'). The above is a ton more work than initial suggestions would imply. Happy to be proven wrong (in fact, hoping I am). This is compatible with main Koha only, not backportable to 23.11 --- Koha/Item.pm | 12 ++++++++++++ .../html_helpers/tables/items/catalogue_detail.inc | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Koha/Item.pm b/Koha/Item.pm index 91c15b22d5..88fab74068 100644 --- a/Koha/Item.pm +++ b/Koha/Item.pm @@ -2507,6 +2507,18 @@ sub strings_map { ( $type eq 'av' ? ( category => $code ) : () ), }; } + + if ( $col eq 'booksellerid' ) { + my $booksellerid = $self->booksellerid; + if ($booksellerid) { + my $bookseller = Koha::Acquisition::Booksellers->find( $booksellerid ); + + $strings->{$col} = { + str => $bookseller->name, + type => 'acquisition_source' + } if $bookseller; + } + } } return $strings; diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc index 74abd4779f..eee0a80b3f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc @@ -613,7 +613,7 @@ searchable: true, orderable: true, render: function (data, type, row, meta) { - return escape_str(row.acquisition_source); + return escape_str(row._strings.acquisition_source ? row._strings.acquisition_source.str : row.acquisition_source); } }, { -- 2.39.2