fixed translatibility error in label-edit-layout.tmpl
[koha.git] / suggestion / acceptorreject.pl
blob12e2f136fa9c866c2a00db8de321fc38c2b17753
1 #!/usr/bin/perl
3 # Copyright 2000-2002 Katipo Communications
5 # This file is part of Koha.
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.
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.
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
21 =head1 NAME
23 acceptorreject.pl
25 =head1 DESCRIPTION
27 this script modify the status of a subscription to ACCEPTED or to REJECTED
29 =head1 PARAMETERS
31 =over 4
33 =item title
35 =item author
37 =item note
39 =item copyrightdate
41 =item publishercode
43 =item volumedesc
45 =item publicationyear
47 =item place
49 =item isbn
51 =item status
53 =item suggestedbyme
55 =item op
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.
62 =back
65 =cut
67 use strict;
68 use warnings;
70 use CGI;
72 use C4::Auth; # get_template_and_user
73 use C4::Output;
74 use C4::Suggestions;
75 use C4::Koha; # GetAuthorisedValue
76 use C4::Dates qw(format_date);
79 my $input = new CGI;
80 my $title = $input->param('title');
81 my $author = $input->param('author');
82 my $note = $input->param('note');
83 my $copyrightdate = $input->param('copyrightdate');
84 my $publishercode = $input->param('publishercode');
85 my $volumedesc = $input->param('volumedesc');
86 my $publicationyear = $input->param('publicationyear');
87 my $place = $input->param('place');
88 my $isbn = $input->param('isbn');
89 my $status = $input->param('status');
90 my $suggestedbyme = $input->param('suggestedbyme');
91 my $op = $input->param('op') || "aorr_confirm";
93 my $dbh = C4::Context->dbh;
94 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
96 template_name => "suggestion/acceptorreject.tmpl",
97 type => "intranet",
98 query => $input,
99 authnotrequired => 1,
100 flagsrequired => { catalogue => 1 },
104 my $suggestions;
106 my $branchcode;
107 my $userenv = C4::Context->userenv;
108 if ($userenv) {
109 unless ($userenv->{flags} % 2 == 1){
110 $branchcode=$userenv->{branch};
114 if ( $op eq "aorr_confirm" ) {
115 my $parameters=$input->Vars;
116 my @deletelist;
117 my $suggestiontype=$parameters->{suggestiontype};
118 foreach my $suggestionid (keys %$parameters){
119 next unless $suggestionid=~/^\d+$/;
120 ## it is a suggestion
121 if ($parameters->{$suggestionid}=~/delete/i){
122 push @deletelist,$suggestionid;
124 else {
125 ## it is not a deletion
126 ## Get the Reason
127 my $reason = $parameters->{"reason$suggestionid"};
128 if ( $reason eq "other" ) {
129 $reason = $parameters->{"other-reason$suggestionid"};
131 unless ($reason){
132 $reason= $parameters->{"reason".$suggestiontype."all"};
133 if ( $reason eq "other" ) {
134 $reason = $parameters->{"other-reason".$suggestiontype."all"};
137 ModStatus( $suggestionid, $parameters->{$suggestionid}, $loggedinuser, '', $reason );
140 $op = "else";
141 if (scalar(@deletelist)>0){
142 my $params = "&delete_field=".join ("&delete_field=",@deletelist);
143 print $input->redirect("/cgi-bin/koha/suggestion/acceptorreject.pl?op=delete_confirm$params");
144 exit;
147 elsif ( $op eq "delete_confirm" ) {
148 my @delete_field = $input->param("delete_field");
149 foreach my $delete_field (@delete_field) {
150 &DelSuggestion( $loggedinuser, $delete_field,"intranet" );
152 $op = 'else';
155 my $reasonsloop = GetAuthorisedValues("SUGGEST");
156 my $pending_suggestions = &SearchSuggestion("", "", "", "", 'ASKED', "", $branchcode);
157 map { $_->{'reasonsloop'} = $reasonsloop; $_->{'date'} = format_date($_->{'date'}) } @$pending_suggestions;
158 my $accepted_suggestions = &GetSuggestionByStatus('ACCEPTED', $branchcode);
159 map { $_->{'reasonsloop'} = $reasonsloop; $_->{'date'} = format_date($_->{'date'}) } @$accepted_suggestions;
160 my $rejected_suggestions = &GetSuggestionByStatus('REJECTED', $branchcode);
161 map { $_->{'reasonsloop'} = $reasonsloop; $_->{'date'} = format_date($_->{'date'}) } @$rejected_suggestions;
163 # FIXME: BAD use of map in VOID context.
165 my @allsuggestions;
166 push @allsuggestions,
167 { "suggestiontype" => "accepted",
168 'suggestions_loop' => $accepted_suggestions,
169 'reasonsloop' => $reasonsloop
171 push @allsuggestions,
172 { "suggestiontype" => "pending",
173 'suggestions_loop' => $pending_suggestions,
174 'reasonsloop' => $reasonsloop
176 push @allsuggestions,
177 { "suggestiontype" => "rejected",
178 'suggestions_loop' => $rejected_suggestions,
179 'reasonsloop' => $reasonsloop
182 $template->param(
183 suggestions => \@allsuggestions,
184 "op_$op" => 1,
185 dateformat => C4::Context->preference("dateformat"),
188 output_html_with_http_headers $input, $cookie, $template->output;