Adding information in header about logged in user
[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::Auth;
28 use C4::Output;
29 use C4::Interface::CGI::Output;
30 use C4::Maintainance;
31 use HTML::Template;
32
33 my $input = new CGI;
34 my ($template, $loggedinuser, $cookie)
35     = get_template_and_user({template_name   => 'maint/catmaintain.tmpl',
36                              query           => $input,
37                              type            => 'intranet',
38                              authnotrequired => 0,
39                              flagsrequired   => {catalogue => 1},
40                              debug           => 1,
41                              });
42
43 my %params = ();
44
45
46 my $type=$input->param('type');
47 my $blah;
48 my $num=0;
49 my $offset=0;
50 if ($type eq 'allsub'){
51   my $sub=$input->param('sub');
52   my ($count,$results)=listsubjects($sub,$num,$offset);
53   my @it = ();
54   for (my $i=0;$i<$count;$i++){
55     my $sub2=$results->[$i]->{'subject'};
56     push @it, {'sub2' => $sub2, 'subject' => $results->[$i]->{'subject'}};
57   }
58   %params = ('sub' => $sub, 'loop' => \@it);
59
60 } elsif ($type eq 'modsub'){
61   %params = ('sub' => $input->param('sub'));
62
63 } elsif ($type eq 'upsub'){
64   my $sub=$input->param('sub');
65   my $oldsub=$input->param('oldsub');
66   updatesub($sub,$oldsub);
67   %params = ('sub' => $sub, 'oldsub' => $oldsub);
68
69 } elsif ($type eq 'undel'){
70   my $title=$input->param('title');
71   my ($count,$results)=deletedbib($title);
72   my @it = ();
73   for (my $i=0;$i<$count;$i++){
74     push @it, {
75         'title'    => $results->[$i]->{'title'},
76         'author'   => $results->[$i]->{'author'},
77         'undelete' => "type=finun&bib=$results->[$i]->{'biblionumber'}",
78       };
79   }
80   %params = ('loop' => \@it);
81
82 } elsif ($type eq 'finun'){
83   my $bib=$input->param('bib');
84   undeletebib($bib);
85
86 } elsif ($type eq 'fixitemtype'){
87   my $bi=$input->param('bi');
88   my $item=$input->param('item');
89   %params = ('bi' => $bi, 'item' => $item);
90
91 } elsif ($type eq 'updatetype'){
92   my $bi=$input->param('bi');
93   my $itemtype=$input->param('itemtype');
94   updatetype($bi,$itemtype);
95
96 } else {
97   $type = 'mainmenu'; # NOTE
98
99 }
100
101 $template->param(type => 'intranet',
102                 "$type-p" => 1,
103                  %params);
104
105 output_html_with_http_headers $input, $cookie, $template->output;