From 4f210d45563750560f8002733feca30d2715cd34 Mon Sep 17 00:00:00 2001 From: rangi Date: Mon, 3 Apr 2006 04:00:02 +0000 Subject: [PATCH] Modify item now works BUT only if there is only one item, if there is more than one item, it gets messed up. They get combined into the form, ill work on this next --- C4/Biblio.pm | 18 ++++++++++++++++-- cataloguing/additem.pl | 12 +++++++++--- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 7bc73f20a6..81f6f65909 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -26,6 +26,8 @@ use C4::Search; use MARC::Record; use MARC::File::USMARC; use MARC::File::XML; +use Smart::Comments; + use ZOOM; use vars qw($VERSION @ISA @EXPORT); @@ -1624,21 +1626,27 @@ sub REALmoditem { $error .= $sth->errstr; } my ($rawmarc,$frameworkcode) = $sth->fetchrow; - warn "ERROR IN REALmoditem, MARC record not found" unless $rawmarc; +# warn "ERROR IN REALmoditem, MARC record not found" unless $rawmarc; # my $record = MARC::File::USMARC::decode($rawmarc); my $record=C4::Search::get_record($item->{biblionumber}); +####$record # ok, we have the marc record, find the previous item record for this itemnumber and delete it my ($itemnumberfield,$itemnumbersubfield) = MARCfind_marc_from_kohafield($dbh,'items.itemnumber',$frameworkcode); # prepare the new item record my $itemrecord = MARC::File::USMARC::decode($item->{marc}); my $itemfield = $itemrecord->field($itemnumberfield); - $itemfield->add_subfields($itemnumbersubfield => '$itemnumber'); + +# $itemfield->add_subfields($itemnumbersubfield => '$itemnumber'); # parse all fields fields from the complete record foreach ($record->field($itemnumberfield)) { # when the previous field is found, replace by the new one if ($_->subfield($itemnumbersubfield) == $item->{itemnum}) { $_->replace_with($itemfield); } + else { + my $temptest = $_->subfield($itemnumbersubfield); + warn " failed itemnum is $item->{itemnum} and value in record is $temptest"; + } } # $record->insert_grouped_field($itemfield); # save the record into biblioitem @@ -3021,6 +3029,12 @@ Paul POULAIN paul.poulain@free.fr # $Id$ # $Log$ +# Revision 1.168 2006/04/03 04:00:02 rangi +# Modify item now works +# +# BUT only if there is only one item, if there is more than one item, it gets messed up. +# They get combined into the form, ill work on this next +# # Revision 1.167 2006/04/03 02:12:49 kados # some modifs to improve plugin support # diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl index 8e2759eb95..4f241b1834 100755 --- a/cataloguing/additem.pl +++ b/cataloguing/additem.pl @@ -30,6 +30,7 @@ use C4::Koha; # XXX subfield_is_koha_internal_p use C4::Search; use HTML::Template; use MARC::File::USMARC; +use Smart::Comments; sub find_value { my ($tagfield,$insubfield,$record) = @_; @@ -55,6 +56,10 @@ if (!$biblionumber){ } my $biblioitemnumber = find_biblioitemnumber($dbh,$biblionumber); my $itemnumber = $input->param('itemnumber'); +if (!$itemnumber){ + $itemnumber=$input->param('itemnum'); + } + my $op = $input->param('op'); # find itemtype @@ -105,7 +110,7 @@ if ($op eq "additem") { } elsif ($op eq "edititem") { #------------------------------------------------------------------------------------------------------------------------------ # retrieve item if exist => then, it's a modif - $itemrecord = MARCgetitem($dbh,$biblionumber,$itemnumber); + $itemrecord = get_record($biblionumber); $nextop="saveitem"; #------------------------------------------------------------------------------------------------------------------------------ } elsif ($op eq "delitem") { @@ -128,7 +133,7 @@ if ($op eq "additem") { my $itemrecord=MARC::Record::new_from_xml($xml, 'UTF-8'); # MARC::Record builded => now, record in DB # warn "R: ".$record->as_formatted; - my ($oldbiblionumber,$oldbibnum,$oldbibitemnum) = NEWmoditem($dbh,$record,$biblionumber,$itemnumber,0); + my ($oldbiblionumber,$oldbibnum,$oldbibitemnum) = NEWmoditem($dbh,$itemrecord,$biblionumber,$itemnumber,0); $itemnumber=""; $nextop="additem"; } @@ -149,7 +154,7 @@ my ($template, $loggedinuser, $cookie) my %indicators; $indicators{995}=' '; # now, build existiing item list -my $temp = MARCgetbiblio($dbh,$biblionumber); +my $temp = get_record($biblionumber); my @fields = $temp->fields(); #my @fields = $record->fields(); my %witness; #---- stores the list of subfields used at least once, with the "meaning" of the code @@ -319,6 +324,7 @@ $template->param(item_loop => \@item_value_loop, author => $oldrecord->{author}, item => \@loop_data, itemnumber => $itemnumber, + itemnum => $itemnumber, itemtagfield => $itemtagfield, itemtagsubfield =>$itemtagsubfield, op => $nextop, -- 2.39.2