More changes to implement jQuery upgrade.
[koha.git] / opac / opac-suggestions.pl
blobb739817c957ddb9685e9c9eec7c418bf1058c3e4
1 #!/usr/bin/perl
3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it under the
6 # terms of the GNU General Public License as published by the Free Software
7 # Foundation; either version 2 of the License, or (at your option) any later
8 # version.
10 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License along with
15 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
16 # Suite 330, Boston, MA 02111-1307 USA
18 use strict;
19 use warnings;
21 use CGI;
22 use C4::Auth; # get_template_and_user
23 use C4::Branch;
24 use C4::Output;
25 use C4::Suggestions;
27 my $input = new CGI;
28 my $title = $input->param('title');
29 my $author = $input->param('author');
30 my $note = $input->param('note');
31 my $copyrightdate = $input->param('copyrightdate');
32 my $publishercode = $input->param('publishercode');
33 my $volumedesc = $input->param('volumedesc');
34 my $publicationyear = $input->param('publicationyear');
35 my $place = $input->param('place');
36 my $isbn = $input->param('isbn');
37 my $status = $input->param('status');
38 my $suggestedbyme = (defined $input->param('suggestedby')? $input->param('suggestedby'):1);
39 my $op = $input->param('op');
40 $op = 'else' unless $op;
42 my ( $template, $borrowernumber, $cookie );
44 my $dbh = C4::Context->dbh;
46 if ( C4::Context->preference("AnonSuggestions") ) {
47 ( $template, $borrowernumber, $cookie ) = get_template_and_user(
49 template_name => "opac-suggestions.tmpl",
50 query => $input,
51 type => "opac",
52 authnotrequired => 1,
55 if ( !$borrowernumber ) {
56 $borrowernumber = C4::Context->preference("AnonSuggestions");
59 else {
60 ( $template, $borrowernumber, $cookie ) = get_template_and_user(
62 template_name => "opac-suggestions.tmpl",
63 query => $input,
64 type => "opac",
65 authnotrequired => 0,
70 if ( $op eq "add_confirm" ) {
71 &NewSuggestion(
72 $borrowernumber, $title, $author, $publishercode,
73 $note, $copyrightdate, $volumedesc, $publicationyear,
74 $place, $isbn, ''
77 # empty fields, to avoid filter in "SearchSuggestion"
78 $title = '';
79 $author = '';
80 $publishercode = '';
81 $copyrightdate = '';
82 $volumedesc = '';
83 $publicationyear = '';
84 $place = '';
85 $isbn = '';
86 $op = 'else';
89 if ( $op eq "delete_confirm" ) {
90 my @delete_field = $input->param("delete_field");
91 foreach my $delete_field (@delete_field) {
92 &DelSuggestion( $borrowernumber, $delete_field );
94 $op = 'else';
97 my $suggestions_loop =
98 &SearchSuggestion( $borrowernumber, $author, $title, $publishercode, $status,
99 $suggestedbyme );
100 map{ $_->{'branchcodesuggestedby'}=GetBranchInfo($_->{'branchcodesuggestedby'})->[0]->{'branchname'}} @$suggestions_loop;
101 $template->param(
102 suggestions_loop => $suggestions_loop,
103 title => $title,
104 author => $author,
105 publishercode => $publishercode,
106 status => $status,
107 suggestedbyme => $suggestedbyme,
108 "op_$op" => 1,
109 suggestionsview => 1
112 output_html_with_http_headers $input, $cookie, $template->output;