From aefdfccec77328aad996ae7c614d3e0be23f4b0d Mon Sep 17 00:00:00 2001 From: Koha User Date: Mon, 20 Oct 2025 16:04:40 +0200 Subject: [PATCH] Bug 28846: Check if biblioitems.itemtype mapping exists before using itemtypes in suggestions Test plan: 1 - Ensure you have no mappings on biblioitems.itemtype 2 - Create a suggestion -> there is a field "Document type" you get an error when submitting. 3 - Apply patch 4 - Create a suggestion -> there is no field anymore and you get no error 5 - Put back the mapping on biblioitems.itemtype and check the field "Document type" is still present suggestion form --- C4/Suggestions.pm | 10 ++++++---- .../prog/en/modules/suggestion/suggestion.tt | 10 ++++++---- suggestion/suggestion.pl | 5 +++++ 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/C4/Suggestions.pm b/C4/Suggestions.pm index 07040b9d5..785f252d4 100644 --- a/C4/Suggestions.pm +++ b/C4/Suggestions.pm @@ -440,10 +440,12 @@ sub MarcRecordFromNewSuggestion { } my ( $it_tag, $it_subfield ) = GetMarcFromKohaField('biblioitems.itemtype'); - if ( $record->field($it_tag) ) { - $record->field($it_tag)->add_subfields( $it_subfield => $suggestion->{itemtype} ); - } else { - $record->append_fields( MARC::Field->new( $it_tag, ' ', ' ', $it_subfield => $suggestion->{itemtype} ) ); + if ($it_tag) { + if ( $record->field($it_tag) ) { + $record->field($it_tag)->add_subfields( $it_subfield => $suggestion->{itemtype} ); + } else { + $record->append_fields( MARC::Field->new( $it_tag, ' ', ' ', $it_subfield => $suggestion->{itemtype} ) ); + } } return $record; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt index 3c287e1e2..afbd72840 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt @@ -412,10 +412,12 @@ -
  • - - [% PROCESS 'av-build-dropbox.inc' name="itemtype", category="SUGGEST_FORMAT", size=20, default=itemtype, empty=1 %] -
  • + [% UNLESS hide_itemtype %] +
  • + + [% PROCESS 'av-build-dropbox.inc' name="itemtype", category="SUGGEST_FORMAT", size=20, default=itemtype, empty=1 %] +
  • + [% END %] [% IF patron_reason_loop %]
  • diff --git a/suggestion/suggestion.pl b/suggestion/suggestion.pl index 249ae1843..21fc6de27 100755 --- a/suggestion/suggestion.pl +++ b/suggestion/suggestion.pl @@ -24,6 +24,7 @@ use C4::Auth qw( get_template_and_user ); use C4::Output qw( output_html_with_http_headers output_and_exit_if_error ); use C4::Suggestions; use C4::Koha qw( GetAuthorisedValues ); +use C4::Biblio qw( GetMarcFromKohaField ); use C4::Budgets qw( GetBudget GetBudgets GetBudgetHierarchy CanUserUseBudget ); use C4::Search qw( FindDuplicate GetDistinctValues ); use C4::Members; @@ -285,6 +286,10 @@ if ( $op =~ /cud-save/ ) { } elsif ( $op eq 'add_form' ) { #Adds suggestion + my ( $it_tag, $it_subfield ) = GetMarcFromKohaField('biblioitems.itemtype'); + unless ($it_tag) { + $template->param( hide_itemtype => 1 ); + } Init($suggestion_ref); $op = 'save'; } elsif ( $op eq 'edit_form' ) { -- 2.30.2