From f52af22a3d86b4679de648453b0f9ec4ab478edc 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 902dd7dcdc..07fc6ad5c8 100644 --- a/Koha/Item.pm +++ b/Koha/Item.pm @@ -2576,6 +2576,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 499df7a259..90431f1651 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 @@ -633,7 +633,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.5