[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Koha-cvs] CVS: koha/C4 Biblio.pm,1.67,1.68
From: |
Paul POULAIN |
Subject: |
[Koha-cvs] CVS: koha/C4 Biblio.pm,1.67,1.68 |
Date: |
Thu, 06 Nov 2003 09:18:33 -0800 |
Update of /cvsroot/koha/koha/C4
In directory sc8-pr-cvs1:/tmp/cvs-serv21738/C4
Modified Files:
Biblio.pm
Log Message:
bugfix for #384
1st draft for MARC biblio deletion.
Still does not work well, but at least, Biblio.pm compiles & it should'nt break
too many things
(Note the trash in the MARCdetail, but don't use it, please :-) )
Index: Biblio.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Biblio.pm,v
retrieving revision 1.67
retrieving revision 1.68
diff -C2 -r1.67 -r1.68
*** Biblio.pm 25 Oct 2003 08:46:27 -0000 1.67
--- Biblio.pm 6 Nov 2003 17:18:30 -0000 1.68
***************
*** 2,5 ****
--- 2,12 ----
# $Id$
# $Log$
+ # Revision 1.68 2003/11/06 17:18:30 tipaul
+ # bugfix for #384
+ #
+ # 1st draft for MARC biblio deletion.
+ # Still does not work well, but at least, Biblio.pm compiles & it should'nt
break too many things
+ # (Note the trash in the MARCdetail, but don't use it, please :-) )
+ #
# Revision 1.67 2003/10/25 08:46:27 tipaul
# minor fixes for bilbio deletion (still buggy)
***************
*** 333,337 ****
@ISA = qw(Exporter);
#
! # don't forget MARCxxx subs are here only for testing purposes. Should not be
used
# as the old-style API and the NEW one are the only public functions.
#
--- 340,344 ----
@ISA = qw(Exporter);
#
! # don't forget MARCxxx subs are exported only for testing purposes. Should
not be used
# as the old-style API and the NEW one are the only public functions.
#
***************
*** 358,361 ****
--- 365,369 ----
&NEWnewbiblio &NEWnewitem
&NEWmodbiblio &NEWmoditem
+ &NEWdelbiblio
&MARCaddbiblio &MARCadditem
***************
*** 819,822 ****
--- 827,839 ----
# due to a too complex structure of MARC (repeatable fields and subfields),
# the best solution for a modif is to delete / recreate the record.
+
+ # 1st of all, copy the MARC::Record to deletedbiblio table => if a true
deletion, MARC data will be kept.
+ # if deletion called before MARCmodbiblio => won't do anything, as the
oldbiblionumber doesn't
+ # exist in deletedbiblio table
+ my $record = MARCgetbiblio($dbh,$bibid);
+ my $oldbiblionumber =
MARCfind_oldbiblionumber_from_MARCbibid($dbh,$bibid);
+ my $copy2deleted=$dbh->prepare("update deletedbiblio set marc=? where
biblionumber=?");
+ $copy2deleted->execute($record->as_usmarc(),$oldbiblionumber);
+ # now, delete in MARC tables.
if ($keep_items eq 1) {
#search item field code
***************
*** 1347,1350 ****
--- 1364,1379 ----
}
+ sub NEWdelbiblio {
+ my ($dbh,$bibid)address@hidden;
+ my $biblio = &MARCfind_oldbiblionumber_from_MARCbibid($dbh,$bibid);
+ &OLDdelbiblio($dbh,$biblio);
+ my $sth = $dbh->prepare("select biblioitemnumber from biblioitems where
biblionumber=?");
+ $sth->execute($biblio);
+ while(my ($biblioitemnumber) = $sth->fetchrow) {
+ OLDdeletebiblioitem($dbh,$biblioitemnumber);
+ }
+ &MARCdelbiblio($dbh,$bibid,0);
+ }
+
sub NEWnewitem {
***************
*** 1457,1461 ****
serial
= ?, seriestitle = ?, notes = ?, abstract = ?";
$sth = $dbh->prepare($query);
!
$sth->execute($bibnum,$biblio->{'title'},$biblio->{'author'},$biblio->{'copyright'},$series,$biblio->{'seriestitle'},$biblio->{'notes'},$biblio->{'abstract'});
$sth->finish;
--- 1486,1490 ----
serial
= ?, seriestitle = ?, notes = ?, abstract = ?";
$sth = $dbh->prepare($query);
!
$sth->execute($bibnum,$biblio->{'title'},$biblio->{'author'},$biblio->{'copyrightdate'},$series,$biblio->{'seriestitle'},$biblio->{'notes'},$biblio->{'abstract'});
$sth->finish;
***************
*** 1790,1807 ****
where biblioitemnumber = $biblioitemnumber";
my $sth = $dbh->prepare($query);
! my @results;
$sth->execute;
! if (@results = $sth->fetchrow_array) {
! $query = "Insert into deletedbiblioitems values (";
! foreach my $value (@results) {
! $value = $dbh->quote($value);
! $query .= "$value,";
! } # foreach
!
! $query =~ s/\,$/\)/;
! $dbh->do($query);
!
$query = "Delete from biblioitems
where biblioitemnumber = $biblioitemnumber";
--- 1819,1835 ----
where biblioitemnumber = $biblioitemnumber";
my $sth = $dbh->prepare($query);
! my $results;
$sth->execute;
! if ($results = $sth->fetchrow_hashref) {
! $sth->finish;
! $sth=$dbh->prepare("Insert into deletedbiblioitems (biblioitemnumber,
biblionumber, volume, number, classification, itemtype,
! isbn, issn ,dewey ,subclass
,publicationyear ,publishercode ,volumedate ,volumeddesc ,timestamp ,illus ,
! pages ,notes ,size ,url ,lccn )
values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
!
! $sth->execute($results->{biblioitemnumber}, $results->{biblionumber},
$results->{volume}, $results->{number}, $results->{classification},
$results->{itemtype},
! $results->{isbn}, $results->{issn}
,$results->{dewey} ,$results->{subclass} ,$results->{publicationyear}
,$results->{publishercode} ,$results->{volumedate} ,$results->{volumeddesc}
,$results->{timestamp} ,$results->{illus} ,
! $results->{pages} ,$results->{notes}
,$results->{size} ,$results->{url} ,$results->{lccn} );
$query = "Delete from biblioitems
where biblioitemnumber = $biblioitemnumber";
***************
*** 1813,1816 ****
--- 1841,1845 ----
$sth = $dbh->prepare($query);
$sth->execute;
+ my @results;
while (@results = $sth->fetchrow_array) {
$query = "Insert into deleteditems values (";
***************
*** 1835,1838 ****
--- 1864,1868 ----
if (my @data=$sth->fetchrow_array){
$sth->finish;
+ # FIXME => replace insert values by insert (field) values ($value)
$query="Insert into deletedbiblio values (";
foreach my $temp (@data){
***************
*** 1840,1844 ****
$query .= "'$temp',";
}
! $query=~ s/\,$/\)/;
$sth=$dbh->prepare($query);
$sth->execute;
--- 1870,1875 ----
$query .= "'$temp',";
}
! #replacing the last , by ",?)"
! $query=~ s/\,$/\,\?\)/;
$sth=$dbh->prepare($query);
$sth->execute;
***************
*** 2123,2131 ****
sub delbiblio {
! my ($biblio)address@hidden;
! my $dbh = C4::Context->dbh;
! &OLDdelbiblio($dbh,$biblio);
! my $bibid = &MARCfind_MARCbibid_from_oldbiblionumber($dbh,$biblio);
! &MARCdelbiblio($dbh,$bibid,0);
}
--- 2154,2162 ----
sub delbiblio {
! my ($biblio)address@hidden;
! my $dbh = C4::Context->dbh;
! &OLDdelbiblio($dbh,$biblio);
! my $bibid = &MARCfind_MARCbibid_from_oldbiblionumber($dbh,$biblio);
! &MARCdelbiblio($dbh,$bibid,0);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Koha-cvs] CVS: koha/C4 Biblio.pm,1.67,1.68,
Paul POULAIN <=