[Koha-cvs] koha C4/Biblio.pm cataloguing/addbiblio.pl cata... [rel_3_0]
Antoine Farnault
antoine at koha-fr.org
Mon Oct 9 18:44:23 CEST 2006
CVSROOT: /sources/koha
Module name: koha
Branch: rel_3_0
Changes by: Antoine Farnault <toins> 06/10/09 16:44:23
Modified files:
C4 : Biblio.pm
cataloguing : addbiblio.pl additem.pl
Log message:
Sync with dev_week.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Biblio.pm?cvsroot=koha&only_with_tag=rel_3_0&r1=1.178.2.11&r2=1.178.2.12
http://cvs.savannah.gnu.org/viewcvs/koha/cataloguing/addbiblio.pl?cvsroot=koha&only_with_tag=rel_3_0&r1=1.14.2.5&r2=1.14.2.6
http://cvs.savannah.gnu.org/viewcvs/koha/cataloguing/additem.pl?cvsroot=koha&only_with_tag=rel_3_0&r1=1.7.2.5&r2=1.7.2.6
Patches:
Index: C4/Biblio.pm
===================================================================
RCS file: /sources/koha/koha/C4/Biblio.pm,v
retrieving revision 1.178.2.11
retrieving revision 1.178.2.12
diff -u -b -r1.178.2.11 -r1.178.2.12
--- C4/Biblio.pm 6 Oct 2006 13:23:49 -0000 1.178.2.11
+++ C4/Biblio.pm 9 Oct 2006 16:44:23 -0000 1.178.2.12
@@ -28,7 +28,6 @@
use MARC::File::USMARC;
use MARC::File::XML;
use ZOOM;
-use Data::Dumper;
use C4::Koha;
use C4::Date;
use utf8;
@@ -162,9 +161,7 @@
# transform the data into koha-table style data
my $olddata = MARCmarc2koha( $dbh, $record,$frameworkcode );
-
- #
- $oldbibnum = _koha_add_biblio( $dbh, $olddata );
+ $oldbibnum = _koha_add_biblio( $dbh, $olddata,$frameworkcode );
$olddata->{'biblionumber'} = $oldbibnum;
$oldbibitemnum = _koha_add_biblioitem( $dbh, $olddata );
@@ -407,12 +404,22 @@
sub ModItem {
- my ( $dbh, $record, $biblionumber, $itemnumber, $delete ) = @_;
-
+ my ( $dbh, $record, $biblionumber, $itemnumber, $delete, $new_item_hashref) = @_;
+ # if we have a MARC record, we're coming from cataloging and so
+ # we do the whole routine: update the MARC and zebra, then update the koha
+ # tables
+ if ($record) {
&MARCmoditem( $dbh, $record, $biblionumber, $itemnumber, $delete );
my $frameworkcode=MARCfind_frameworkcode($dbh,$biblionumber);
my $olditem = MARCmarc2koha( $dbh, $record,$frameworkcode );
_koha_modify_item( $dbh, $olditem );
+ return undef;
+ }
+ # otherwise, we're just looking to modify something quickly
+ # (like a status) so we just update the koha tables
+ elsif ($new_item_hashref) {
+ _koha_modify_item( $dbh, $new_item_hashref );
+ }
}
=head2 DelBiblio
@@ -497,6 +504,7 @@
$sth->execute($biblionumber);
$sth = $dbh->prepare("DELETE FROM additionalauthors WHERE biblionumber=?");
$sth->execute($biblionumber);
+ return undef;
}
@@ -1261,8 +1269,7 @@
sub MARCfind_frameworkcode {
my ( $dbh, $bibid ) = @_;
- my $sth =
- $dbh->prepare("select frameworkcode from biblio where biblionumber=?");
+ my $sth = $dbh->prepare("select frameworkcode from biblio where biblionumber=?");
$sth->execute($bibid);
my ($frameworkcode) = $sth->fetchrow;
return $frameworkcode;
@@ -1439,8 +1446,7 @@
if (!defined $sth){
my $dbh=C4::Context->dbh;
-$sth =
- $dbh->prepare(
+ $sth = $dbh->prepare(
"select tagfield,tagsubfield from marc_subfield_structure where frameworkcode=? and kohafield=?"
);
}
@@ -1455,10 +1461,9 @@
}else {
- $record->insert_fields_ordered( $tagfield, " ", " ", $tagsubfield => $value );
+ $record->add_fields( $tagfield, " ", " ", $tagsubfield => $value );
}
}
-
return $record;
}
@@ -1503,7 +1508,7 @@
$ind2 = substr(@$indicator[$j],1,1);
}
else {
- warn "Indicator is empty";
+ warn "Indicator in @$tags[$i] is empty";
$ind2 = " ";
}
$xml.="<datafield tag=\"@$tags[$i]\" ind1=\"$ind1\" ind2=\"$ind2\">\n";
@@ -1945,33 +1950,29 @@
=cut
sub _koha_add_biblio {
- my ( $dbh, $biblio ) = @_;
-
- # my $dbh = &C4Connect;
+ my ( $dbh, $biblio,$frameworkcode ) = @_;
my $sth = $dbh->prepare("Select max(biblionumber) from biblio");
$sth->execute;
my $data = $sth->fetchrow_arrayref;
- my $bibnum = $$data[0] + 1;
+ my $biblionumber = $$data[0] + 1;
my $series = 0;
if ( $biblio->{'seriestitle'} ) { $series = 1 }
$sth->finish;
- $sth =
- $dbh->prepare(
-"insert into biblio set biblionumber = ?, title = ?, author = ?, copyrightdate = ?, serial = ?, seriestitle = ?, notes = ?, abstract = ?, unititle = ?"
+ $sth = $dbh->prepare(
+ "INSERT INTO biblio
+ SET biblionumber = ?, title = ?, author = ?, copyrightdate = ?, serial = ?, seriestitle = ?, notes = ?, abstract = ?, unititle = ?, frameworkcode = ? "
);
$sth->execute(
- $bibnum, $biblio->{'title'},
+ $biblionumber,$biblio->{'title'},
$biblio->{'author'}, $biblio->{'copyrightdate'},
$biblio->{'serial'}, $biblio->{'seriestitle'},
$biblio->{'notes'}, $biblio->{'abstract'},
- $biblio->{'unititle'},
+ $biblio->{'unititle'},$frameworkcode
);
$sth->finish;
-
- # $dbh->disconnect;
- return ($bibnum);
+ return ($biblionumber);
}
=head2 _koha_modify_biblio
@@ -3831,8 +3832,11 @@
=cut
-# $Id: Biblio.pm,v 1.178.2.11 2006/10/06 13:23:49 toins Exp $
+# $Id: Biblio.pm,v 1.178.2.12 2006/10/09 16:44:23 toins Exp $
# $Log: Biblio.pm,v $
+# Revision 1.178.2.12 2006/10/09 16:44:23 toins
+# Sync with dev_week.
+#
# Revision 1.178.2.11 2006/10/06 13:23:49 toins
# Synch with dev_week.
#
Index: cataloguing/addbiblio.pl
===================================================================
RCS file: /sources/koha/koha/cataloguing/addbiblio.pl,v
retrieving revision 1.14.2.5
retrieving revision 1.14.2.6
diff -u -b -r1.14.2.5 -r1.14.2.6
--- cataloguing/addbiblio.pl 6 Oct 2006 13:23:49 -0000 1.14.2.5
+++ cataloguing/addbiblio.pl 9 Oct 2006 16:44:23 -0000 1.14.2.6
@@ -1,6 +1,6 @@
#!/usr/bin/perl
-# $Id: addbiblio.pl,v 1.14.2.5 2006/10/06 13:23:49 toins Exp $
+# $Id: addbiblio.pl,v 1.14.2.6 2006/10/09 16:44:23 toins Exp $
# Copyright 2000-2002 Katipo Communications
#
@@ -95,7 +95,26 @@
$sth->execute($id);
my ($file,$marc,$encoding) = $sth->fetchrow;
if ($marc) {
- my $record = MARC::File::USMARC::decode($marc);
+ my $record = MARC::Record->new_from_usmarc($marc);
+ #my $record = MARC::File::USMARC::decode($marc);
+
+ my @warnings = $record->warnings();
+ foreach my $warning (@warnings) {
+ warn "WARNING".$warning;
+ }
+
+ my $marcxml = $record->as_xml_record("UTF-8");
+ #warn "MARCXML:".$marcxml;
+ my $marcxml_entity_encoded;
+ use Unicode::Normalize;
+ foreach my $line (split(/\n/, $marcxml)) {
+ my $nfc_string = NFC($line);
+ $nfc_string =~s/([\x{0080}-\x{fffd}])/sprintf('&#x%X;',ord($1))/sgoe;
+ $marcxml_entity_encoded .= $nfc_string."\n";
+ }
+ #warn $marcxml_entity_encoded;
+ $record=MARC::Record->new_from_xml($marcxml_entity_encoded,C4::Context->preference('TemplateEncoding'),C4::Context->preference('marcflavour'));
+
if (ref($record) eq undef) {
return -1;
} else {
@@ -117,7 +136,7 @@
$field=MARC::Field->new($tag,"","",$subfieldcode=>$subfieldvalue) if ($subfieldcode ne $subfield);
}
}
- warn $field->as_formatted;
+# warn $field->as_formatted;
# }
}
$record->delete_field($record->field($tag));
@@ -408,16 +427,13 @@
#=========================
my $input = new CGI;
my $error = $input->param('error');
-my $biblionumber=$input->param('biblionumber'); # if biblionumber exists, it's a modif, not a new biblio.
-my $oldbiblionumber;
-if (!$biblionumber){
- $oldbiblionumber=$input->param('oldbiblionumber');
- }
+my $oldbiblionumber=$input->param('oldbiblionumber'); # if bib exists, it's a modif, not a new biblio.
my $breedingid = $input->param('breedingid');
my $z3950 = $input->param('z3950');
my $op = $input->param('op');
my $frameworkcode = $input->param('frameworkcode');
my $dbh = C4::Context->dbh;
+my $biblionumber;
if ($oldbiblionumber) {
@@ -466,10 +482,7 @@
$tagslib = &MARCgettagslib($dbh,1,$frameworkcode);
my $record=-1;
my $encoding="";
-#$record = MARCgetbiblio($dbh,$biblionumber) if ($biblionumber);
-$dbh = C4::Context->dbh;
$record=MARCgetbiblio($dbh,$biblionumber) if ($biblionumber);
-# warn "record :".$record->as_formatted;
($record,$encoding) = MARCfindbreeding($dbh,$breedingid) if ($breedingid);
$is_a_modif=0;
@@ -529,6 +542,7 @@
biblioitemnumtagsubfield => $biblioitemnumtagsubfield,
biblioitemnumber => $biblioitemnumber,
duplicatebiblionumber => $duplicatebiblionumber,
+ duplicatebibid => $duplicatebibid,
duplicatetitle => $duplicatetitle,
);
}
@@ -606,6 +620,7 @@
biblioitemnumber => $biblioitemnumber,
);
}
+$template->param( title => $record->title() ) if ($record ne "-1");
$template->param(
frameworkcode => $frameworkcode,
itemtype => $frameworkcode, # HINT: if the library has itemtype = framework, itemtype is auto filled !
Index: cataloguing/additem.pl
===================================================================
RCS file: /sources/koha/koha/cataloguing/additem.pl,v
retrieving revision 1.7.2.5
retrieving revision 1.7.2.6
diff -u -b -r1.7.2.5 -r1.7.2.6
--- cataloguing/additem.pl 6 Oct 2006 13:23:49 -0000 1.7.2.5
+++ cataloguing/additem.pl 9 Oct 2006 16:44:23 -0000 1.7.2.6
@@ -1,6 +1,6 @@
#!/usr/bin/perl
-# $Id: additem.pl,v 1.7.2.5 2006/10/06 13:23:49 toins Exp $
+# $Id: additem.pl,v 1.7.2.6 2006/10/09 16:44:23 toins Exp $
# Copyright 2000-2002 Katipo Communications
#
@@ -73,9 +73,9 @@
my $op = $input->param('op');
# find itemtype
-my $itemtype = &MARCfind_frameworkcode($dbh,$biblionumber);
+my $frameworkcode = &MARCfind_frameworkcode($dbh,$biblionumber);
-my $tagslib = &MARCgettagslib($dbh,1,$itemtype);
+my $tagslib = &MARCgettagslib($dbh,1,$frameworkcode);
my $record = MARCgetbiblio($dbh,$biblionumber);
# warn "==>".$record->as_formatted;
my $oldrecord = MARCmarc2koha($dbh,$record);
@@ -130,9 +130,18 @@
#------------------------------------------------------------------------------------------------------------------------------
} elsif ($op eq "delitem") {
#------------------------------------------------------------------------------------------------------------------------------
-# retrieve item if exist => then, it's a modif
- &DelItem($dbh,$biblionumber,$itemnumber);
+ # check that there is no issue on this item before deletion.
+ my $sth=$dbh->prepare("select * from issues i where i.returndate is null and i.itemnumber=?");
+ $sth->execute($itemnumber);
+ my $onloan=$sth->fetchrow;
+ push @errors,"book_on_loan" if ($onloan); ##error book_on_loan added to template as well
+ if ($onloan){
$nextop="additem";
+ }else{
+ &DelItem($dbh,$biblionumber,$itemnumber);
+ print $input->redirect("additem.pl?bibid=$biblionumber&frameworkcode=$frameworkcode");
+ #$nextop="additem";
+ }
#------------------------------------------------------------------------------------------------------------------------------
} elsif ($op eq "saveitem") {
#------------------------------------------------------------------------------------------------------------------------------
@@ -175,8 +184,8 @@
my %witness; #---- stores the list of subfields used at least once, with the "meaning" of the code
my @big_array;
#---- finds where items.itemnumber is stored
-my ($itemtagfield,$itemtagsubfield) = &MARCfind_marc_from_kohafield($dbh,"items.itemnumber",$itemtype);
-my ($branchtagfield,$branchtagsubfield) = &MARCfind_marc_from_kohafield($dbh,"items.homebranch",$itemtype);
+my ($itemtagfield,$itemtagsubfield) = &MARCfind_marc_from_kohafield($dbh,"items.itemnumber",$frameworkcode);
+my ($branchtagfield,$branchtagsubfield) = &MARCfind_marc_from_kohafield($dbh,"items.homebranch",$frameworkcode);
foreach my $field (@fields) {
next if ($field->tag()<10);
@@ -206,7 +215,7 @@
$big_array[$i]{$subfield_code}=" " unless ($big_array[$i]{$subfield_code});
}
}
-my ($holdingbrtagf,$holdingbrtagsubf) = &MARCfind_marc_from_kohafield($dbh,"items.holdingbranch",$itemtype);
+my ($holdingbrtagf,$holdingbrtagsubf) = &MARCfind_marc_from_kohafield($dbh,"items.holdingbranch",$frameworkcode);
@big_array = sort {$a->{$holdingbrtagsubf} cmp $b->{$holdingbrtagsubf}} @big_array;
# now, construct template !
More information about the Koha-cvs
mailing list