Added functionality to allow invalid itemtype to be fixed
[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     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";
28   }
29 } elsif ($type eq 'modsub'){
30   my $sub=$input->param('sub');
31   print "<form action=/cgi-bin/koha/maint/catmaintain.pl>";
32   print "Subject:<input type=text value=\"$sub\" name=sub size=40><br>\n";
33   print "<input type=hidden name=type value=upsub>";
34   print "<input type=hidden name=oldsub value=\"$sub\">";
35   print "<input type=submit value=modify>";
36 #  print "<a href=\"nowhere\" onclick=\"document.forms[0].submit();\">Modify</a>";
37   print "</form>";
38   print "<p> This will change the subject headings on all the biblios this subject is applied to"
39 } elsif ($type eq 'upsub'){
40   my $sub=$input->param('sub');
41   my $oldsub=$input->param('oldsub');
42   updatesub($sub,$oldsub);
43   print "Successfully modified $oldsub is now $sub";
44   print "<p><a href=/cgi-bin/koha/maint/catmaintain.pl target=window0 onclick=\"window0.focus()\">Back to catalogue maintenance</a><br>";
45   print "<a href=nowhere onclick=\"self.close()\">Close this window</a>";
46 } elsif ($type eq 'undel'){
47   my $title=$input->param('title');
48   my ($count,$results)=deletedbib($title);
49   print "<table border=0>";
50   print "<tr><td><b>Title</b></td><td><b>Author</b></td><td><b>Undelete</b></td></tr>";
51   for (my $i=0;$i<$count;$i++){
52     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";
53   }
54   print "</table>";
55 } elsif ($type eq 'finun'){
56   my $bib=$input->param('bib');
57   undeletebib($bib);
58   print "Succesfully undeleted";
59   print "<p><a href=/cgi-bin/koha/maint/catmaintain.pl>Back to Catalogue Maintenance</a>";
60 } elsif ($type eq 'fixitemtype'){
61   my $bi=$input->param('bi');
62   my $item=$input->param('item');
63   print "<form method=post action=/cgi-bin/koha/maint/catmaintain.pl>";
64   print "<input type=hidden name=bi value=$bi>";
65   print "<input type=hidden name=type value=updatetype>";
66   print "Itemtype:<input type=text name=itemtype value=$item><br>\n";
67   print "<input type=submit value=Change>";
68   print "</form>";
69 } elsif ($type eq 'updatetype'){
70   my $bi=$input->param('bi');
71   my $itemtype=$input->param('itemtype');
72   updatetype($bi,$itemtype);
73   print "Updated successfully";
74   print "<p><a href=/cgi-bin/koha/maint/catmaintain.pl>Back to Catalogue Maintenance</a>";
75 } else {
76   print "<B>Subject Maintenance</b><br>";
77   print "<form action=/cgi-bin/koha/maint/catmaintain.pl method=post>";
78   print "<input type=hidden name=type value=allsub>";
79   print "Show all subjects beginning with <input type=text name=sub><br>";
80   print "<input type=submit value=Show>";
81   print "</form>";
82   print "<p>";
83   print "<B>Group Maintenance</b></br>";
84   print "<form action=/cgi-bin/koha/search.pl method=post>";
85   print "<input type=hidden name=type value=catmain>";
86   print "Show all Titles beginning with <input type=text name=title><br>";
87   print "<input type=submit value=Show>";
88   print "</form>";
89   print "<p>";
90   print "<B>Undelete Biblio</b></br>";
91   print "<form action=/cgi-bin/koha/maint/catmaintain.pl method=post>";
92   print "<input type=hidden name=type value=undel>";
93   print "Show all Titles beginning with <input type=text name=title><br>";
94   print "<input type=submit value=Show>";
95   print "</form>";
96 }
97 print endmenu('catalog');
98 print endpage();