Add comments, make branchrelations consistent with other table additions
[koha.git] / maint / catmaintain.pl
1 #!/usr/bin/perl
2
3 #script to do some serious catalogue maintainance
4 #written 22/11/00
5 # by chris@katipo.co.nz
6
7 use strict;
8 use CGI;
9 use C4::Output;
10 use C4::Database;
11 use C4::Maintainance;
12
13 my $input = new CGI;
14 print $input->header;
15 my $type=$input->param('type');
16 print startpage();
17 print startmenu('catalog');
18 my $blah;
19 my $num=0;
20 my $offset=0;
21 if ($type eq 'allsub'){
22   my $sub=$input->param('sub');
23   my ($count,$results)=listsubjects($sub,$num,$offset);
24   for (my $i=0;$i<$count;$i++){
25     my $sub2=$results->[$i]->{'subject'};
26     $sub2=~ s/ /%20/g;
27       $sub2=~ s/\'/%27/g;
28     print "\"<a href=\"/cgi-bin/koha/maint/catmaintain.pl?type=allsub&sub=$sub\" onclick=\'messenger(\"/cgi-bin/koha/maint/catmaintain.pl?type=modsub&sub=$sub2\");window1.focus()\'>$results->[$i]->{'subject'}\"</a><br>\n";
29   }
30 } elsif ($type eq 'modsub'){
31   my $sub=$input->param('sub');
32   print "<form action=/cgi-bin/koha/maint/catmaintain.pl>";
33   print "Subject:<input type=text value=\"$sub\" name=sub size=40><br>\n";
34   print "<input type=hidden name=type value=upsub>";
35   print "<input type=hidden name=oldsub value=\"$sub\">";
36   print "<input type=submit value=modify>";
37 #  print "<a href=\"nowhere\" onclick=\"document.forms[0].submit();\">Modify</a>";
38   print "</form>";
39   print "<p> This will change the subject headings on all the biblios this subject is applied to"
40 } elsif ($type eq 'upsub'){
41   my $sub=$input->param('sub');
42   my $oldsub=$input->param('oldsub');
43   updatesub($sub,$oldsub);
44   print "Successfully modified $oldsub is now $sub";
45   print "<p><a href=/cgi-bin/koha/maint/catmaintain.pl target=window0 onclick=\"window0.focus()\">Back to catalogue maintenance</a><br>";
46   print "<a href=nowhere onclick=\"self.close()\">Close this window</a>";
47 } elsif ($type eq 'undel'){
48   my $title=$input->param('title');
49   my ($count,$results)=deletedbib($title);
50   print "<table border=0>";
51   print "<tr><td><b>Title</b></td><td><b>Author</b></td><td><b>Undelete</b></td></tr>";
52   for (my $i=0;$i<$count;$i++){
53     print "<tr><td>$results->[$i]->{'title'}</td><td>$results->[$i]->{'author'}</td><td><a href=/cgi-bin/koha/maint/catmaintain.pl?type=finun&bib=$results->[$i]->{'biblionumber'}>Undelete</a></td>\n";
54   }
55   print "</table>";
56 } elsif ($type eq 'finun'){
57   my $bib=$input->param('bib');
58   undeletebib($bib);
59   print "Succesfully undeleted";
60   print "<p><a href=/cgi-bin/koha/maint/catmaintain.pl>Back to Catalogue Maintenance</a>";
61 } elsif ($type eq 'fixitemtype'){
62   my $bi=$input->param('bi');
63   my $item=$input->param('item');
64   print "<form method=post action=/cgi-bin/koha/maint/catmaintain.pl>";
65   print "<input type=hidden name=bi value=$bi>";
66   print "<input type=hidden name=type value=updatetype>";
67   print "Itemtype:<input type=text name=itemtype value=$item><br>\n";
68   print "<input type=submit value=Change>";
69   print "</form>";
70 } elsif ($type eq 'updatetype'){
71   my $bi=$input->param('bi');
72   my $itemtype=$input->param('itemtype');
73   updatetype($bi,$itemtype);
74   print "Updated successfully";
75   print "<p><a href=/cgi-bin/koha/maint/catmaintain.pl>Back to Catalogue Maintenance</a>";
76 } else {
77   print "<B>Subject Maintenance</b><br>";
78   print "<form action=/cgi-bin/koha/maint/catmaintain.pl method=post>";
79   print "<input type=hidden name=type value=allsub>";
80   print "Show all subjects beginning with <input type=text name=sub><br>";
81   print "<input type=submit value=Show>";
82   print "</form>";
83   print "<p>";
84   print "<B>Group Maintenance</b></br>";
85   print "<form action=/cgi-bin/koha/search.pl method=post>";
86   print "<input type=hidden name=type value=catmain>";
87   print "Show all Titles beginning with <input type=text name=title><br>";
88   print "Item Number <INPUT TYPE=\"text\"  SIZE=\"25\"   NAME=\"item\"><br>";
89   print "<input type=submit value=Show>";
90   print "</form>";
91   print "<p>";
92   print "<B>Undelete Biblio</b></br>";
93   print "<form action=/cgi-bin/koha/maint/catmaintain.pl method=post>";
94   print "<input type=hidden name=type value=undel>";
95   print "Show all Titles beginning with <input type=text name=title><br>";
96   print "<input type=submit value=Show>";
97   print "</form>";
98 }
99 print endmenu('catalog');
100 print endpage();