From 686b17d4202ace044fa538f0b33fba8fa22b436f Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 20 Aug 2014 17:05:19 +0200 Subject: [PATCH] [PASSED QA] Bug 12743: ACQ: default values for catalogue records At the moment, it is possible to create records in acquisitions, but the ACQ framework is only used for items created in this module. This patch allows to defined default values in the ACQ framework for records created on the acquisition module. Test plan: 1/ Make sure you have the ACQ framework created (otherwise create it from the default framework). 2/ Define a default value for a field (for instance 099$z=1). 3/ Go in the acquisition module and create a new order from a new record. 4/ Fill mandatory information and save. 5/ Go on the detail page of this record and verify the default value exist. Signed-off-by: Gaetan Boisson Signed-off-by: Kyle M Hall --- acqui/addorder.pl | 21 +++++++++++++++++++++ 1 files changed, 21 insertions(+), 0 deletions(-) diff --git a/acqui/addorder.pl b/acqui/addorder.pl index e048d05..99cf762 100755 --- a/acqui/addorder.pl +++ b/acqui/addorder.pl @@ -129,6 +129,8 @@ use C4::Biblio; # AddBiblio TransformKohaToMarc use C4::Budgets; use C4::Items; use C4::Output; +use C4::Koha qw( subfield_is_koha_internal_p ); +use MARC::Field; ### "-------------------- addorder.pl ----------" @@ -259,6 +261,25 @@ if ( $orderinfo->{quantity} ne '0' ) { "aqorders.discount" => $$orderinfo{discount} ? $$orderinfo{discount} : "", }); + + my $tagslib = C4::Biblio::GetMarcStructure( 1, 'ACQ' ); + if ( $tagslib ) { + my ( $itemfield ) = C4::Biblio::GetMarcFromKohaField( 'items.itemnumber', '' ); + for my $tag ( sort keys %$tagslib ) { + next unless $tag; + next if $tag == $itemfield; + for my $subfield ( sort keys %{ $tagslib->{$tag} } ) { + next if ( subfield_is_koha_internal_p($subfield) ); + my $defaultvalue = $tagslib->{$tag}{$subfield}{defaultvalue}; + if ( defined $defaultvalue and $defaultvalue ne '' ) { + $record->insert_fields_ordered( + MARC::Field->new( $tag, '', '', $subfield => $defaultvalue ) + ); + } + } + } + } + # create the record in catalogue, with framework '' my ($biblionumber,$bibitemnum) = AddBiblio($record,''); # change suggestion status if applicable -- 1.7.2.5