Sub renamed & GPL Licence added.
[koha.git] / suggestion / acceptorreject.pl
1 #!/usr/bin/perl
2
3 # Copyright 2000-2002 Katipo Communications
4 #
5 # This file is part of Koha.
6 #
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
10 # version.
11 #
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License along with
17 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
18 # Suite 330, Boston, MA  02111-1307 USA
19
20 # $Id$
21
22 use strict;
23 require Exporter;
24 use CGI;
25 use HTML::Template;
26 use C4::Auth;       # get_template_and_user
27 use C4::Interface::CGI::Output;
28 use C4::Suggestions;
29
30 my $input = new CGI;
31 my $title = $input->param('title');
32 my $author = $input->param('author');
33 my $note = $input->param('note');
34 my $copyrightdate =$input->param('copyrightdate');
35 my $publishercode = $input->param('publishercode');
36 my $volumedesc = $input->param('volumedesc');
37 my $publicationyear = $input->param('publicationyear');
38 my $place = $input->param('place');
39 my $isbn = $input->param('isbn');
40 my $status = $input->param('status');
41 my $suggestedbyme = $input->param('suggestedbyme');
42 my $op = $input->param('op');
43 $op = 'else' unless $op;
44
45 my $dbh = C4::Context->dbh;
46 my ($template, $loggedinuser, $cookie)
47     = get_template_and_user({template_name => "suggestion/acceptorreject.tmpl",
48                              type => "intranet",
49                              query => $input,
50                              authnotrequired => 1,
51                              flagsrequired => {borrow => 1},
52                          });
53 if ($op eq "aorr_confirm") {
54         my @suggestionlist = $input->param("aorr");
55         foreach my $suggestion (@suggestionlist) {
56                 if ($suggestion =~ /(A|R)(.*)/) {
57                         my ($newstatus,$suggestionid) = ($1,$2);
58                         $newstatus="REJECTED" if $newstatus eq "R";
59                         $newstatus="ACCEPTED" if $newstatus eq "A";
60                         ModStatus($suggestionid,$newstatus,$loggedinuser);
61                 }
62         }
63         $op="else";
64 }
65
66 if ($op eq "delete_confirm") {
67         my @delete_field = $input->param("delete_field");
68         foreach my $delete_field (@delete_field) {
69                 &DelSuggestion($loggedinuser,$delete_field);
70         }
71         $op='else';
72 }
73
74 my $suggestions_loop= &SearchSuggestion("","","","",'ASKED',"");
75 $template->param(suggestions_loop => $suggestions_loop,
76                 "op_$op" => 1,
77                 intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
78                 intranetstylesheet => C4::Context->preference("intranetstylesheet"),
79                 IntranetNav => C4::Context->preference("IntranetNav"),
80 );
81 output_html_with_http_headers $input, $cookie, $template->output;