From 9995ff8fd156866e363b09f02ef0ca505191fe08 Mon Sep 17 00:00:00 2001 From: Henri-Damien LAURENT Date: Wed, 16 Sep 2009 00:00:28 +0200 Subject: [PATCH] MT 0001094, Follow-up : Enhancement : Item is moved rather than deleted and re-created --- cataloguing/moveitem.pl | 75 +++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 41 deletions(-) diff --git a/cataloguing/moveitem.pl b/cataloguing/moveitem.pl index a461600ef0..67cdf685ee 100755 --- a/cataloguing/moveitem.pl +++ b/cataloguing/moveitem.pl @@ -65,54 +65,47 @@ if ($barcode && $biblionumber) { if ($itemnumber) { # And then, we get the item - my $item = GetItem($itemnumber); - - if ($item) { - - # We delete the item from the old record (we can't delete afterwards, because of constraint on barcode duplicity) - my $results = GetBiblioFromItemNumber($itemnumber, $barcode); - my $frombiblionumber = $results->{'biblionumber'}; - - my $order = GetOrderFromItemnumber($itemnumber); - if ($order){ - $order->{'biblionumber'} = $biblionumber; - ModOrder($order); - } - - if ($frombiblionumber) { - DelItem(C4::Context->dbh, $frombiblionumber, $itemnumber); - } - - # We add the item to the requested record - my ($biblionumber, $biblioitemnumber, $newitemnumber) = AddItem($item, $biblionumber); - - if ($order){ - my $orderitem = { - ordernumber => $order->{'ordernumber'}, - itemnumber => $itemnumber, - newitemnumber => $newitemnumber, - }; - ModOrderItem($orderitem); - } - - if ($newitemnumber) { - $template->param(success => 1); - } else { - $template->param(error => 1, - errornonewitem => 1); - } - } else { - $template->param(error => 1, - errornoitem => 1); + my $item = GetItem($itemnumber); + + if ($item) { + + my $results = GetBiblioFromItemNumber($itemnumber, $barcode); + my $frombiblionumber = $results->{'biblionumber'}; + + my $moveresult = MoveItemFromBiblio($itemnumber, $frombiblionumber, $biblionumber); + my $order = GetOrderFromItemnumber($itemnumber); + if ($order){ + $order->{'biblionumber'} = $biblionumber; + ModOrder($order); + my $orderitem = { + ordernumber => $order->{'ordernumber'}, + itemnumber => $itemnumber, + newitemnumber => $newitemnumber, + }; + ModOrderItem($orderitem); } + if ($moveresult) { + $template->param(success => 1); + } else { + $template->param(error => 1, + errornonewitem => 1); + } + + + } else { + $template->param(error => 1, + errornoitem => 1); + } } else { - $template->param(error => 1, - errornoitemnumber => 1); + $template->param(error => 1, + errornoitemnumber => 1); + } $template->param( barcode => $barcode, itemnumber => $itemnumber, ); + } else { $template->param(missingparameter => 1); if (!$barcode) { $template->param(missingbarcode => 1); } -- 2.39.5