Head & rel_2_2 merged
[koha.git] / suggestion / acceptorreject.pl
1 #!/usr/bin/perl
2 use strict;
3 require Exporter;
4 use CGI;
5 use HTML::Template;
6
7 use C4::Auth;       # get_template_and_user
8 use C4::Interface::CGI::Output;
9 use C4::Suggestions;
10
11 my $input = new CGI;
12 my $title = $input->param('title');
13 my $author = $input->param('author');
14 my $note = $input->param('note');
15 my $copyrightdate =$input->param('copyrightdate');
16 my $publishercode = $input->param('publishercode');
17 my $volumedesc = $input->param('volumedesc');
18 my $publicationyear = $input->param('publicationyear');
19 my $place = $input->param('place');
20 my $isbn = $input->param('isbn');
21 my $status = $input->param('status');
22 my $suggestedbyme = $input->param('suggestedbyme');
23 my $op = $input->param('op');
24 $op = 'else' unless $op;
25
26 my $dbh = C4::Context->dbh;
27 my ($template, $loggedinuser, $cookie)
28     = get_template_and_user({template_name => "suggestion/acceptorreject.tmpl",
29                              type => "intranet",
30                              query => $input,
31                              authnotrequired => 1,
32                              flagsrequired => {borrow => 1},
33                          });
34 if ($op eq "aorr_confirm") {
35         my @suggestionlist = $input->param("aorr");
36         foreach my $suggestion (@suggestionlist) {
37                 if ($suggestion =~ /(A|R)(.*)/) {
38                         my ($newstatus,$suggestionid) = ($1,$2);
39                         $newstatus="REJECTED" if $newstatus eq "R";
40                         $newstatus="ACCEPTED" if $newstatus eq "A";
41                         changestatus($suggestionid,$newstatus,$loggedinuser);
42                 }
43         }
44         $op="else";
45 }
46
47 if ($op eq "delete_confirm") {
48         my @delete_field = $input->param("delete_field");
49         foreach my $delete_field (@delete_field) {
50                 &delsuggestion($loggedinuser,$delete_field);
51         }
52         $op='else';
53 }
54
55 my $suggestions_loop= &searchsuggestion("","","","",'ASKED',"");
56 $template->param(suggestions_loop => $suggestions_loop,
57                 "op_$op" => 1,
58                 intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
59                 intranetstylesheet => C4::Context->preference("intranetstylesheet"),
60                 IntranetNav => C4::Context->preference("IntranetNav"),
61 );
62 output_html_with_http_headers $input, $cookie, $template->output;