POD 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 =head1 NAME
23
24 acceptorreject.pl
25
26 =head1 DESCRIPTION
27
28 this script modify the status of a subscription to ACCEPTED or to REJECTED
29
30 =head1 PARAMETERS
31
32 =over 4
33
34 =item title
35
36 =item author
37
38 =item note
39
40 =item copyrightdate
41
42 =item publishercode
43
44 =item volumedesc
45
46 =item publicationyear
47
48 =item place
49
50 =item isbn
51
52 =item status
53
54 =item suggestedbyme
55
56 =item op
57 op can be :
58  * aorr_confirm : to confirm accept or reject
59  * delete_confirm : to confirm the deletion
60
61 =back
62
63
64 =cut
65
66
67 use strict;
68 require Exporter;
69 use CGI;
70 use HTML::Template;
71 use C4::Auth;       # get_template_and_user
72 use C4::Interface::CGI::Output;
73 use C4::Suggestions;
74
75 my $input = new CGI;
76 my $title = $input->param('title');
77 my $author = $input->param('author');
78 my $note = $input->param('note');
79 my $copyrightdate =$input->param('copyrightdate');
80 my $publishercode = $input->param('publishercode');
81 my $volumedesc = $input->param('volumedesc');
82 my $publicationyear = $input->param('publicationyear');
83 my $place = $input->param('place');
84 my $isbn = $input->param('isbn');
85 my $status = $input->param('status');
86 my $suggestedbyme = $input->param('suggestedbyme');
87 my $op = $input->param('op');
88 $op = 'else' unless $op;
89
90 my $dbh = C4::Context->dbh;
91 my ($template, $loggedinuser, $cookie)
92     = get_template_and_user({template_name => "suggestion/acceptorreject.tmpl",
93                              type => "intranet",
94                              query => $input,
95                              authnotrequired => 1,
96                              flagsrequired => {borrow => 1},
97                          });
98 if ($op eq "aorr_confirm") {
99         my @suggestionlist = $input->param("aorr");
100         foreach my $suggestion (@suggestionlist) {
101                 if ($suggestion =~ /(A|R)(.*)/) {
102                         my ($newstatus,$suggestionid) = ($1,$2);
103                         $newstatus="REJECTED" if $newstatus eq "R";
104                         $newstatus="ACCEPTED" if $newstatus eq "A";
105                         ModStatus($suggestionid,$newstatus,$loggedinuser);
106                 }
107         }
108         $op="else";
109 }
110
111 if ($op eq "delete_confirm") {
112         my @delete_field = $input->param("delete_field");
113         foreach my $delete_field (@delete_field) {
114                 &DelSuggestion($loggedinuser,$delete_field);
115         }
116         $op='else';
117 }
118
119 my $suggestions_loop= &SearchSuggestion("","","","",'ASKED',"");
120 $template->param(suggestions_loop => $suggestions_loop,
121                 "op_$op" => 1,
122                 intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
123                 intranetstylesheet => C4::Context->preference("intranetstylesheet"),
124                 IntranetNav => C4::Context->preference("IntranetNav"),
125 );
126 output_html_with_http_headers $input, $cookie, $template->output;