Don't extract purely-numeric strings like "1" either
[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
8 # Copyright 2000-2002 Katipo Communications
9 #
10 # This file is part of Koha.
11 #
12 # Koha is free software; you can redistribute it and/or modify it under the
13 # terms of the GNU General Public License as published by the Free Software
14 # Foundation; either version 2 of the License, or (at your option) any later
15 # version.
16 #
17 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
18 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
19 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
20 #
21 # You should have received a copy of the GNU General Public License along with
22 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
23 # Suite 330, Boston, MA  02111-1307 USA
24
25 use strict;
26 use CGI;
27 use C4::Output;
28 use C4::Maintainance;
29
30 my $input = new CGI;
31 print $input->header;
32 my $type=$input->param('type');
33 print startpage();
34 print startmenu('catalog');
35 my $blah;
36 my $num=0;
37 my $offset=0;
38 if ($type eq 'allsub'){
39   my $sub=$input->param('sub');
40   my ($count,$results)=listsubjects($sub,$num,$offset);
41   for (my $i=0;$i<$count;$i++){
42     my $sub2=$results->[$i]->{'subject'};
43     $sub2=~ s/ /%20/g;
44       $sub2=~ s/\'/%27/g;
45     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";
46   }
47 } elsif ($type eq 'modsub'){
48   my $sub=$input->param('sub');
49   print "<form action=/cgi-bin/koha/maint/catmaintain.pl>";
50   print "Subject:<input type=text value=\"$sub\" name=sub size=40><br>\n";
51   print "<input type=hidden name=type value=upsub>";
52   print "<input type=hidden name=oldsub value=\"$sub\">";
53   print "<input type=submit value=modify>";
54 #  print "<a href=\"nowhere\" onclick=\"document.forms[0].submit();\">Modify</a>";
55   print "</form>";
56   print "<p> This will change the subject headings on all the biblios this subject is applied to"
57 } elsif ($type eq 'upsub'){
58   my $sub=$input->param('sub');
59   my $oldsub=$input->param('oldsub');
60   updatesub($sub,$oldsub);
61   print "Successfully modified $oldsub is now $sub";
62   print "<p><a href=/cgi-bin/koha/maint/catmaintain.pl target=window0 onclick=\"window0.focus()\">Back to catalogue maintenance</a><br>";
63   print "<a href=nowhere onclick=\"self.close()\">Close this window</a>";
64 } elsif ($type eq 'undel'){
65   my $title=$input->param('title');
66   my ($count,$results)=deletedbib($title);
67   print "<table border=0>";
68   print "<tr><td><b>Title</b></td><td><b>Author</b></td><td><b>Undelete</b></td></tr>";
69   for (my $i=0;$i<$count;$i++){
70     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";
71   }
72   print "</table>";
73 } elsif ($type eq 'finun'){
74   my $bib=$input->param('bib');
75   undeletebib($bib);
76   print "Succesfully undeleted";
77   print "<p><a href=/cgi-bin/koha/maint/catmaintain.pl>Back to Catalogue Maintenance</a>";
78 } elsif ($type eq 'fixitemtype'){
79   my $bi=$input->param('bi');
80   my $item=$input->param('item');
81   print "<form method=post action=/cgi-bin/koha/maint/catmaintain.pl>";
82   print "<input type=hidden name=bi value=$bi>";
83   print "<input type=hidden name=type value=updatetype>";
84   print "Itemtype:<input type=text name=itemtype value=$item><br>\n";
85   print "<input type=submit value=Change>";
86   print "</form>";
87 } elsif ($type eq 'updatetype'){
88   my $bi=$input->param('bi');
89   my $itemtype=$input->param('itemtype');
90   updatetype($bi,$itemtype);
91   print "Updated successfully";
92   print "<p><a href=/cgi-bin/koha/maint/catmaintain.pl>Back to Catalogue Maintenance</a>";
93 } else {
94   print "<B>Subject Maintenance</b><br>";
95   print "<form action=/cgi-bin/koha/maint/catmaintain.pl method=post>";
96   print "<input type=hidden name=type value=allsub>";
97   print "Show all subjects beginning with <input type=text name=sub><br>";
98   print "<input type=submit value=Show>";
99   print "</form>";
100   print "<p>";
101   print "<B>Group Maintenance</b></br>";
102   print "<form action=/cgi-bin/koha/search.pl method=post>";
103   print "<input type=hidden name=type value=catmain>";
104   print "Show all Titles beginning with <input type=text name=title><br>";
105   print "Item Number <INPUT TYPE=\"text\"  SIZE=\"25\"   NAME=\"item\"><br>";
106   print "<input type=submit value=Show>";
107   print "</form>";
108   print "<p>";
109   print "<B>Undelete Biblio</b></br>";
110   print "<form action=/cgi-bin/koha/maint/catmaintain.pl method=post>";
111   print "<input type=hidden name=type value=undel>";
112   print "Show all Titles beginning with <input type=text name=title><br>";
113   print "<input type=submit value=Show>";
114   print "</form>";
115 }
116 print endmenu('catalog');
117 print endpage();