Added code to allow deleting of biblioitems
authortruth_nz <truth_nz>
Tue, 14 May 2002 04:12:52 +0000 (04:12 +0000)
committertruth_nz <truth_nz>
Tue, 14 May 2002 04:12:52 +0000 (04:12 +0000)
C4/Acquisitions.pm
acqui.simple/addbooks.pl
acqui.simple/savebiblioitem.pl
deletebiblioitem.pl [new file with mode: 0755]
modbibitem.pl

index f7d400b..088c1d7 100644 (file)
@@ -15,7 +15,7 @@ $VERSION = 0.01;
 &newordernum &modbiblio &modorder &getsingleorder &invoice &receiveorder
 &bookfundbreakdown &curconvert &updatesup &insertsup &newitems &modbibitem
 &getcurrencies &modsubtitle &modsubject &modaddauthor &moditem &countitems 
-&findall &needsmod &delitem &delbibitem &delbiblio &delorder &branches
+&findall &needsmod &delitem &deletebiblioitem &delbiblio &delorder &branches
 &getallorders &getrecorders &updatecurrencies &getorder &getcurrency &updaterecorder
 &updatecost &checkitems &modnote &getitemtypes &getbiblio
 &getbiblioitem &getitemsbybiblioitem &isbnsearch &keywordsearch
@@ -1115,32 +1115,62 @@ sub delitem{
   $dbh->disconnect;
 }
 
-sub delbibitem{
-  my ($itemnum)=@_;
-  my $dbh=C4Connect;
-  my $query="select * from biblioitems where biblioitemnumber=$itemnum";
-  my $sth=$dbh->prepare($query);
-  $sth->execute;
-  if (my @data=$sth->fetchrow_array){
-    $sth->finish;
-    $query="Insert into deletedbiblioitems values (";
-    foreach my $temp (@data){
-      $temp=~ s/\'/\\\'/g;
-      $query=$query."'$temp',";
-    }
-    $query=~ s/\,$/\)/;
-#   print $query;
-    $sth=$dbh->prepare($query);
+
+sub deletebiblioitem {
+    my ($biblioitemnumber) = @_;
+    my $dbh   = C4Connect;
+    my $query = "Select * from biblioitems
+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";
+        $dbh->do($query);
+    } # if
+
     $sth->finish;
-    $query = "Delete from biblioitems where biblioitemnumber=$itemnum";
-    $sth=$dbh->prepare($query);
+
+# Now delete all the items attached to the biblioitem
+
+    $query = "Select * from items where biblioitemnumber = $biblioitemnumber";
+    $sth   = $dbh->prepare($query);
+
     $sth->execute;
+
+    while (@results = $sth->fetchrow_array) {
+
+       $query = "Insert into deleteditems values (";
+       foreach my $value (@results) {
+           $value  = $dbh->quote($value);
+           $query .= "$value,";
+       } # foreach
+
+       $query =~ s/\,$/\)/;
+       $dbh->do($query);
+    } # while
+
     $sth->finish;
-  }
-  $sth->finish;
-  $dbh->disconnect;
-}
+
+    $query = "Delete from items where biblioitemnumber = $biblioitemnumber";
+    $dbh->do($query);
+    
+    $dbh->disconnect;
+} # sub deletebiblioitem
+
 
 sub delbiblio{
   my ($biblio)=@_;
index 4a335e2..6e016f3 100755 (executable)
@@ -11,7 +11,8 @@ use strict;
 use C4::Output;
 
 my $input = new CGI;
-my $error = $input->param('error');
+my $error   = $input->param('error');
+my $success = $input->param('biblioitem');
 
 print $input->header;
 print startpage();
@@ -33,7 +34,12 @@ EOF
 <font color="red" size="5">No items found</font>
 <p />
 EOF
-    } # if
+    } elsif ($success eq "added") {
+       print << "EOF";
+<font color="red" size="5">Website Biblioitem Added</font>
+<p />
+EOF
+    } # elsif
 
     print << "EOF";
 <table bgcolor="#ffcc00" width="80%" cellpadding="5">
index 2e3d06e..3970430 100755 (executable)
@@ -35,6 +35,10 @@ if (! $biblionumber) {
 } else {
 
     $biblioitemnum = &newbiblioitem($biblioitem);
-
-    print $input->redirect("additem.pl?biblioitemnum=$biblioitemnum");
+    
+    if ($input->param('itemtype') eq "WEB") {
+       print $input->redirect("addbooks.pl?biblioitem=added");
+    } else {
+       print $input->redirect("additem.pl?biblioitemnum=$biblioitemnum");
+    } # else
 } # else
diff --git a/deletebiblioitem.pl b/deletebiblioitem.pl
new file mode 100755 (executable)
index 0000000..292c33e
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/perl
+
+use strict;
+use C4::Acquisitions;
+use CGI;
+
+my $input = new CGI;
+my $biblionumber     = $input->param('biblionumber');
+my $biblioitemnumber = $input->param('biblioitemnumber');
+
+if (! $biblionumber) {
+    print $input->redirect("/catalogue/");
+
+} elsif (! $biblioitemnumber) {
+    print $input->param("detail.pl?type=intra&bib=$biblionumber");
+
+} else {
+    &deletebiblioitem($biblioitemnumber);
+
+    print $input->redirect("detail.pl?type=intra&bib=$biblionumber");
+} # else
index 9640994..d9555b0 100755 (executable)
@@ -19,7 +19,7 @@ my $data=bibitemdata($bibitemnum);
 my $biblio=$input->param('biblio');
 my $submit=$input->param('submit.x');
 if ($submit eq ''){                                                                                                      
-  print $input->redirect("/cgi-bin/koha/delbibitem.pl?bibitemnum=$bibitemnum&biblio=$biblio");                            
+  print $input->redirect("deletebiblioitem.pl?biblioitemnumber=$bibitemnum&biblionumber=$biblio");
 }
 print $input->header;
 #my ($count,$subject)=subject($data->{'biblionumber'});