Got undeleting biblios going (catalogue maintenance should probably be in a
authorrangi <rangi>
Tue, 13 Mar 2001 22:04:04 +0000 (22:04 +0000)
committerrangi <rangi>
Tue, 13 Mar 2001 22:04:04 +0000 (22:04 +0000)
password protected super librarian area or the like)

C4/Maintainance.pm
catmaintain.pl

index c6fd03f..de1d23e 100644 (file)
@@ -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)
     
index 5d2275e..a0201b2 100755 (executable)
@@ -43,12 +43,41 @@ if ($type eq 'allsub'){
   print "Successfully modified $oldsub is now $sub";
   print "<p><a href=/cgi-bin/koha/catmaintain.pl target=window0 onclick=\"window0.focus()\">Back to catalogue maintenance</a><br>";
   print "<a href=nowhere onclick=\"self.close()\">Close this window</a>";
+} elsif ($type eq 'undel'){
+  my $title=$input->param('title');
+  my ($count,$results)=deletedbib($title);
+  print "<table border=0>";
+  print "<tr><td><b>Title</b></td><td><b>Author</b></td><td><b>Undelete</b></td></tr>";
+  for (my $i=0;$i<$count;$i++){
+    print "<tr><td>$results->[$i]->{'title'}</td><td>$results->[$i]->{'author'}</td><td><a href=/cgi-bin/koha/catmaintain.pl?type=finun&bib=$results->[$i]->{'biblionumber'}>Undelete</a></td>\n";
+  }
+  print "</table>";
+} elsif ($type eq 'finun'){
+  my $bib=$input->param('bib');
+  undeletebib($bib);
+  print "Succesfully undeleted";
+  print "<p><a href=/cgi-bin/koha/catmaintain.pl>Back to Catalogue Maintenance</a>";
 } else {
+  print "<B>Subject Maintenance</b><br>";
   print "<form action=/cgi-bin/koha/catmaintain.pl method=post>";
   print "<input type=hidden name=type value=allsub>";
   print "Show all subjects beginning with <input type=text name=sub><br>";
   print "<input type=submit value=Show>";
   print "</form>";
+  print "<p>";
+  print "<B>Group Maintenance</b></br>";
+  print "<form action=/cgi-bin/koha/search.pl method=post>";
+  print "<input type=hidden name=type value=catmain>";
+  print "Show all Titles beginning with <input type=text name=title><br>";
+  print "<input type=submit value=Show>";
+  print "</form>";
+  print "<p>";
+  print "<B>Undelete Biblio</b></br>";
+  print "<form action=/cgi-bin/koha/catmaintain.pl method=post>";
+  print "<input type=hidden name=type value=undel>";
+  print "Show all Titles beginning with <input type=text name=title><br>";
+  print "<input type=submit value=Show>";
+  print "</form>";
 }
 print endmenu('catalog');
 print endpage();