From 4d35327d19aeaaa3597bc2f745edba3a1ed86509 Mon Sep 17 00:00:00 2001 From: rangi Date: Tue, 13 Mar 2001 22:04:04 +0000 Subject: [PATCH] Got undeleting biblios going (catalogue maintenance should probably be in a password protected super librarian area or the like) --- C4/Maintainance.pm | 61 +++++++++++++++++++++++++++++++++++++++++++++- catmaintain.pl | 29 ++++++++++++++++++++++ 2 files changed, 89 insertions(+), 1 deletion(-) diff --git a/C4/Maintainance.pm b/C4/Maintainance.pm index c6fd03fb10..de1d23e178 100644 --- a/C4/Maintainance.pm +++ b/C4/Maintainance.pm @@ -13,7 +13,7 @@ use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); $VERSION = 0.01; @ISA = qw(Exporter); -@EXPORT = qw(&listsubjects &updatesub); +@EXPORT = qw(&listsubjects &updatesub &shiftgroup &deletedbib &undeletebib); %EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ], # your exported package globals go here, @@ -80,5 +80,64 @@ sub updatesub{ $sth->finish; $dbh->disconnect; } + +sub shiftgroup{ + my ($bib,$bi)=@_; + my $dbh=C4Connect; + my $query="update biblioitems set biblionumber=$bib where biblioitemnumber=$bi"; + my $sth=$dbh->prepare($query); + $sth->execute; + $sth->finish; + $query="update items set biblionumber=$bib where biblioitemnumber=$bi"; + $sth=$dbh->prepare($query); + $sth->execute; + $sth->finish; + $dbh->disconnect; +} + +sub deletedbib{ + my ($title)=@_; + my $dbh=C4Connect; + my $query="Select * from deletedbiblio where title like '$title%' order by title"; + my $sth=$dbh->prepare($query); + $sth->execute; + my @results; + my $i=0; + while (my $data=$sth->fetchrow_hashref){ + $results[$i]=$data; + $i++; + } + $sth->finish; + $dbh->disconnect; + return($i,\@results); +} + +sub undeletebib{ + my ($bib)=@_; + my $dbh=C4Connect; + my $query="select * from deletedbiblio where biblionumber=$bib"; + my $sth=$dbh->prepare($query); + $sth->execute; + if (my @data=$sth->fetchrow_array){ + $sth->finish; + $query="Insert into biblio values ("; + foreach my $temp (@data){ + $temp=~ s/\'/\\\'/g; + $query=$query."'$temp',"; + } + $query=~ s/\,$/\)/; + # print $query; + $sth=$dbh->prepare($query); + $sth->execute; + $sth->finish; + } + $query="Delete from deletedbiblio where biblionumber=$bib"; + $sth=$dbh->prepare($query); + $sth->execute; + $sth->finish; + $dbh->disconnect; +} + + END { } # module clean-up code here (global destructor) diff --git a/catmaintain.pl b/catmaintain.pl index 5d2275ec0b..a0201b29cd 100755 --- a/catmaintain.pl +++ b/catmaintain.pl @@ -43,12 +43,41 @@ if ($type eq 'allsub'){ print "Successfully modified $oldsub is now $sub"; print "

Back to catalogue maintenance
"; print "Close this window"; +} elsif ($type eq 'undel'){ + my $title=$input->param('title'); + my ($count,$results)=deletedbib($title); + print ""; + print ""; + for (my $i=0;$i<$count;$i++){ + print "\n"; + } + print "
TitleAuthorUndelete
$results->[$i]->{'title'}$results->[$i]->{'author'}[$i]->{'biblionumber'}>Undelete
"; +} elsif ($type eq 'finun'){ + my $bib=$input->param('bib'); + undeletebib($bib); + print "Succesfully undeleted"; + print "

Back to Catalogue Maintenance"; } else { + print "Subject Maintenance
"; print "

"; print ""; print "Show all subjects beginning with
"; print ""; print "
"; + print "

"; + print "Group Maintenance
"; + print "

"; + print ""; + print "Show all Titles beginning with
"; + print ""; + print "
"; + print "

"; + print "Undelete Biblio
"; + print "

"; + print ""; + print "Show all Titles beginning with
"; + print ""; + print "
"; } print endmenu('catalog'); print endpage(); -- 2.39.5