[Koha-cvs] koha C4/Biblio.pm cataloguing/additem.pl

Chris Cormack chris at katipo.co.nz
Mon Apr 3 06:00:02 CEST 2006


CVSROOT:	/sources/koha
Module name:	koha
Branch: 	
Changes by:	Chris Cormack <rangi at savannah.gnu.org>	06/04/03 04:00:02

Modified files:
	C4             : Biblio.pm 
	cataloguing    : additem.pl 

Log message:
	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

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/koha/C4/Biblio.pm.diff?tr1=1.167&tr2=1.168&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/koha/koha/cataloguing/additem.pl.diff?tr1=1.6&tr2=1.7&r1=text&r2=text

Patches:
Index: koha/C4/Biblio.pm
diff -u koha/C4/Biblio.pm:1.167 koha/C4/Biblio.pm:1.168
--- koha/C4/Biblio.pm:1.167	Mon Apr  3 02:12:49 2006
+++ koha/C4/Biblio.pm	Mon Apr  3 04:00:02 2006
@@ -26,11 +26,13 @@
 use MARC::Record;
 use MARC::File::USMARC;
 use MARC::File::XML;
+use Smart::Comments;
+
 use ZOOM;
 use vars qw($VERSION @ISA @EXPORT);
 
 # set the version for version checking
-$VERSION = do { my @v = '$Revision: 1.167 $' =~ /\d+/g;
+$VERSION = do { my @v = '$Revision: 1.168 $' =~ /\d+/g;
                 shift(@v) . "." . join("_", map {sprintf "%03d", $_ } @v); };
 
 @ISA = qw(Exporter);
@@ -1624,21 +1626,27 @@
         $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
@@ -3019,8 +3027,14 @@
 
 =cut
 
-# $Id: Biblio.pm,v 1.167 2006/04/03 02:12:49 kados Exp $
+# $Id: Biblio.pm,v 1.168 2006/04/03 04:00:02 rangi Exp $
 # $Log: Biblio.pm,v $
+# 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
 #
Index: koha/cataloguing/additem.pl
diff -u koha/cataloguing/additem.pl:1.6 koha/cataloguing/additem.pl:1.7
--- koha/cataloguing/additem.pl:1.6	Mon Mar  6 03:12:38 2006
+++ koha/cataloguing/additem.pl	Mon Apr  3 04:00:02 2006
@@ -1,6 +1,6 @@
 #!/usr/bin/perl
 
-# $Id: additem.pl,v 1.6 2006/03/06 03:12:38 rangi Exp $
+# $Id: additem.pl,v 1.7 2006/04/03 04:00:02 rangi Exp $
 
 # Copyright 2000-2002 Katipo Communications
 #
@@ -30,6 +30,7 @@
 use C4::Search;
 use HTML::Template;
 use MARC::File::USMARC;
+use Smart::Comments;
 
 sub find_value {
 	my ($tagfield,$insubfield,$record) = @_;
@@ -55,6 +56,10 @@
 }
 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 @@
 } 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 @@
         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 %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 @@
 						author => $oldrecord->{author},
 						item => \@loop_data,
 						itemnumber => $itemnumber,
+    						itemnum => $itemnumber,
 						itemtagfield => $itemtagfield,
 						itemtagsubfield =>$itemtagsubfield,
 						op => $nextop,





More information about the Koha-cvs mailing list