From 8f165d2357ff8c1b2c364cca1224c04eee324006 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Mon, 12 Sep 2016 08:58:02 +0000 Subject: [PATCH] Bug 6852 [QA Followup] - Tidy AddItem MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Kyle M Hall (cherry picked from commit 989904c7ab0a24ddbe29264671fc8b5ebb175af2) Signed-off-by: Frédéric Demians --- C4/Items.pm | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/C4/Items.pm b/C4/Items.pm index 2c23b8ca4d..a4e95a42e4 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -280,43 +280,44 @@ the biblio items tag for display and indexing. =cut sub AddItem { - my $item = shift; + my $item = shift; my $biblionumber = shift; my $dbh = @_ ? shift : C4::Context->dbh; - my $frameworkcode = @_ ? shift : GetFrameworkCode( $biblionumber ); - my $unlinked_item_subfields; + my $frameworkcode = @_ ? shift : GetFrameworkCode($biblionumber); + my $unlinked_item_subfields; if (@_) { - $unlinked_item_subfields = shift - }; + $unlinked_item_subfields = shift; + } # needs old biblionumber and biblioitemnumber $item->{'biblionumber'} = $biblionumber; my $sth = $dbh->prepare("SELECT biblioitemnumber FROM biblioitems WHERE biblionumber=?"); $sth->execute( $item->{'biblionumber'} ); - ($item->{'biblioitemnumber'}) = $sth->fetchrow; + ( $item->{'biblioitemnumber'} ) = $sth->fetchrow; _set_defaults_for_add($item); _set_derived_columns_for_add($item); $item->{'more_subfields_xml'} = _get_unlinked_subfields_xml($unlinked_item_subfields); + # FIXME - checks here - unless ( $item->{itype} ) { # default to biblioitem.itemtype if no itype + unless ( $item->{itype} ) { # default to biblioitem.itemtype if no itype my $itype_sth = $dbh->prepare("SELECT itemtype FROM biblioitems WHERE biblionumber = ?"); $itype_sth->execute( $item->{'biblionumber'} ); ( $item->{'itype'} ) = $itype_sth->fetchrow_array; } - my ( $itemnumber, $error ) = _koha_new_item( $item, $item->{barcode} ); - if( $error ) { - return; - } + my ( $itemnumber, $error ) = _koha_new_item( $item, $item->{barcode} ); + return if $error; + $item->{'itemnumber'} = $itemnumber; ModZebra( $item->{biblionumber}, "specialUpdate", "biblioserver" ); - - logaction("CATALOGUING", "ADD", $itemnumber, "item") if C4::Context->preference("CataloguingLog"); - - return ($item->{biblionumber}, $item->{biblioitemnumber}, $itemnumber); + + logaction( "CATALOGUING", "ADD", $itemnumber, "item" ) + if C4::Context->preference("CataloguingLog"); + + return ( $item->{biblionumber}, $item->{biblioitemnumber}, $itemnumber ); } =head2 AddItemBatchFromMarc -- 2.39.5