minor fixes (to get less warning during translation)
[wip/koha-chris_n.git] / opac / opac-suggestions.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, $borrowernumber, $cookie)
28     = get_template_and_user({template_name => "opac-suggestions.tmpl",
29                              type => "opac",
30                              query => $input,
31                              authnotrequired => 1,
32                              flagsrequired => {borrow => 1},
33                          });
34 if ($op eq "add_confirm") {
35         &newsuggestion($borrowernumber,$title,$author,$publishercode,$note,$copyrightdate,$volumedesc,$publicationyear,$place,$isbn,'');
36         # empty fields, to avoid filter in "searchsuggestion"
37         $title='';
38         $author='';
39         $publishercode='';
40         $copyrightdate ='';
41         $volumedesc = '';
42         $publicationyear = '';
43         $place = '';
44         $isbn = '';
45         $op='else';
46 }
47
48 if ($op eq "delete_confirm") {
49         my @delete_field = $input->param("delete_field");
50         foreach my $delete_field (@delete_field) {
51                 &delsuggestion($borrowernumber,$delete_field);
52         }
53         $op='else';
54 }
55
56 my $suggestions_loop= &searchsuggestion($borrowernumber,$author,$title,$publishercode,$status,$suggestedbyme);
57 $template->param(suggestions_loop => $suggestions_loop,
58                                 title => $title,
59                                 author => $author,
60                                 publishercode => $publishercode,
61                                 status => $status,
62                                 suggestedbyme => $suggestedbyme,
63                                 "op_$op" => 1,
64 );
65 output_html_with_http_headers $input, $cookie, $template->output;