From 022c5fa814ce712ec278b3c1355ddf0bb3e34b88 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Sat, 21 Mar 2015 12:27:04 -0400 Subject: [PATCH] Bug 7369 - duplicate item This patch adds a link to duplicate existing items on the edit items screen To test: 1 - Apply patch 2 - navigate to the edit items screen for a record with existing items 3 - click the duplicate link and ensure item info but not barcode are carried over 4 - save the item and ensure it is added correctly 5 - check that all previous functionality on page works as before Signed-off-by: Mark Tompsett Signed-off-by: Kyle M Hall --- cataloguing/additem.pl | 34 ++++++++++++++++++++++ .../prog/en/modules/cataloguing/additem.tt | 3 +- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl index b74605a..db09984 100755 --- a/cataloguing/additem.pl +++ b/cataloguing/additem.pl @@ -585,6 +585,40 @@ if ($op eq "additem") { $itemrecord = C4::Items::GetMarcItem($biblionumber,$itemnumber); $nextop = "saveitem"; #------------------------------------------------------------------------------- +} elsif ($op eq "dupeitem") { +#------------------------------------------------------------------------------- +# retrieve item if exist => then, it's a modif + $itemrecord = C4::Items::GetMarcItem($biblionumber,$itemnumber); + if (C4::Context->preference('autoBarcode') eq 'incremental') { + $itemrecord = _increment_barcode($itemrecord, $frameworkcode); + } + else { + # we have to clear the barcode field in the duplicate item record to make way for the new one generated by the javascript plugin + my ($tagfield,$tagsubfield) = &GetMarcFromKohaField("items.barcode",$frameworkcode); + my $fieldItem = $itemrecord->field($tagfield); + $itemrecord->delete_field($fieldItem); + $fieldItem->delete_subfields($tagsubfield); + $itemrecord->insert_fields_ordered($fieldItem); + } + + #check for hidden subfield and remove them for the duplicated item + foreach my $field ($itemrecord->fields()){ + my $tag = $field->{_tag}; + foreach my $subfield ($field->subfields()){ + my $subfieldtag = $subfield->[0]; + if (subfield_is_koha_internal_p($subfieldtag) || $tagslib->{$tag}->{$subfieldtag}->{'tab'} ne "10" + || abs($tagslib->{$tag}->{$subfieldtag}->{hidden})>4 ){ + my $fieldItem = $itemrecord->field($tag); + $itemrecord->delete_field($fieldItem); + $fieldItem->delete_subfields($subfieldtag); + $itemrecord->insert_fields_ordered($fieldItem); + } + } + } + + $itemrecord = removeFieldsForPrefill($itemrecord) if ($prefillitem); + $nextop = "additem"; +#------------------------------------------------------------------------------- } elsif ($op eq "delitem") { #------------------------------------------------------------------------------- # check that there is no issue on this item before deletion. diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt index 1b0e317..b9db7b2 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt @@ -175,7 +175,8 @@ function confirm_deletion() { [% IF ( item_loo.hostitemflag ) %] Edit in host   Delink [% ELSE %] - Edit + Edit + Duplicate [% IF ( item_loo.countanalytics ) %] View analytics [% ELSE %] -- 2.1.4