Patch from Joe Atzberger to remove $Id$ and $Log$ from scripts
[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
21 =head1 NAME
22
23 acceptorreject.pl
24
25 =head1 DESCRIPTION
26
27 this script modify the status of a subscription to ACCEPTED or to REJECTED
28
29 =head1 PARAMETERS
30
31 =over 4
32
33 =item title
34
35 =item author
36
37 =item note
38
39 =item copyrightdate
40
41 =item publishercode
42
43 =item volumedesc
44
45 =item publicationyear
46
47 =item place
48
49 =item isbn
50
51 =item status
52
53 =item suggestedbyme
54
55 =item op
56
57 op can be :
58  * aorr_confirm : to confirm accept or reject
59  * delete_confirm : to confirm the deletion
60  * accepted : to display only accepted. 
61  
62 =back
63
64
65 =cut
66
67 use strict;
68 require Exporter;
69 use CGI;
70
71 use C4::Auth;    # get_template_and_user
72 use C4::Output;
73 use C4::Suggestions;
74 use C4::Koha;    # GetAuthorisedValue
75
76 my $input           = new CGI;
77 my $title           = $input->param('title');
78 my $author          = $input->param('author');
79 my $note            = $input->param('note');
80 my $copyrightdate   = $input->param('copyrightdate');
81 my $publishercode   = $input->param('publishercode');
82 my $volumedesc      = $input->param('volumedesc');
83 my $publicationyear = $input->param('publicationyear');
84 my $place           = $input->param('place');
85 my $isbn            = $input->param('isbn');
86 my $status          = $input->param('status');
87 my $suggestedbyme   = $input->param('suggestedbyme');
88 my $op              = $input->param('op') || "aorr_confirm";
89
90 my $dbh = C4::Context->dbh;
91 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
92     {
93         template_name   => "suggestion/acceptorreject.tmpl",
94         type            => "intranet",
95         query           => $input,
96         authnotrequired => 1,
97         flagsrequired   => { catalogue => 1 },
98     }
99 );
100
101 my $suggestions;
102
103 if ( $op eq "aorr_confirm" ) {
104     my @suggestionlist = $input->param("aorr");
105
106     foreach my $suggestion (@suggestionlist) {
107         if ( $suggestion =~ /(A|R)(.*)/ ) {
108             my ( $newstatus, $suggestionid ) = ( $1, $2 );
109             $newstatus = "REJECTED" if $newstatus eq "R";
110             $newstatus = "ACCEPTED" if $newstatus eq "A";
111             my $reason = $input->param( "reason" . $suggestionid );
112             if ( $reason eq "other" ) {
113                 $reason = $input->param( "other-reason" . $suggestionid );
114             }
115             ModStatus( $suggestionid, $newstatus, $loggedinuser, '', $reason );
116         }
117     }
118     $op = "else";
119     $suggestions = &SearchSuggestion( "", "", "", "", 'ASKED', "" );
120 }
121
122 if ( $op eq "delete_confirm" ) {
123     my @delete_field = $input->param("delete_field");
124     foreach my $delete_field (@delete_field) {
125         &DelSuggestion( $loggedinuser, $delete_field );
126     }
127     $op = 'else';
128     $suggestions = &SearchSuggestion( "", "", "", "", 'ASKED', "" );
129 }
130
131 if ( $op eq "accepted" ) {
132     $suggestions = &GetSuggestionByStatus('ACCEPTED');
133     $template->param(done => 1);
134 }
135
136 if ( $op eq "rejected" ) {
137     $suggestions = &GetSuggestionByStatus('REJECTED');
138     $template->param(done => 1);
139 }
140
141 my $reasonsloop = GetAuthorisedValues("SUGGEST");
142 my @suggestions_loop;
143 foreach my $suggestion (@$suggestions) {
144     $suggestion->{'reasonsloop'} = $reasonsloop;
145     push @suggestions_loop, $suggestion;
146 }
147
148 $template->param(
149     suggestions_loop        => \@suggestions_loop,
150     "op_$op"                => 1,
151     intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
152     intranetstylesheet => C4::Context->preference("intranetstylesheet"),
153     IntranetNav        => C4::Context->preference("IntranetNav"),
154 );
155
156 output_html_with_http_headers $input, $cookie, $template->output;