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
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
22 use C4::Auth; # get_template_and_user
29 my $suggestedbyme = (defined $input->param('suggestedby')? $input->param('suggestedby'):1);
30 my $op = $input->param('op');
31 my $suggestion = $input->Vars;
32 delete $$suggestion{$_} foreach qw<op suggestedbyme>;
33 $op = 'else' unless $op;
35 my ( $template, $borrowernumber, $cookie );
37 my $dbh = C4::Context->dbh;
39 if ( C4::Context->preference("AnonSuggestions") ) {
40 ( $template, $borrowernumber, $cookie ) = get_template_and_user(
42 template_name => "opac-suggestions.tmpl",
48 if ( !$$suggestion{suggestedby} ) {
49 $$suggestion{suggestedby} = C4::Context->preference("AnonSuggestions");
53 ( $template, $borrowernumber, $cookie ) = get_template_and_user(
55 template_name => "opac-suggestions.tmpl",
62 $$suggestion{suggestedby} ||= $borrowernumber;
64 my $suggestions_loop =
65 &SearchSuggestion( $suggestion,
67 if ( $op eq "add_confirm" ) {
68 if (@$suggestions_loop>=1){
69 #some suggestion are answering the request Donot Add
72 $$suggestion{'suggestioncreatedon'}=C4::Dates->today;
73 $$suggestion{'branchcode'}=C4::Context->userenv->{"branch"};
74 &NewSuggestion($suggestion);
75 # empty fields, to avoid filter in "SearchSuggestion"
76 $$suggestion{$_}='' foreach qw<title author publishercode copyrightdate place collectiontitle isbn STATUS>;
78 &SearchSuggestion( $suggestion,
84 if ( $op eq "delete_confirm" ) {
85 my @delete_field = $input->param("delete_field");
86 foreach my $delete_field (@delete_field) {
87 &DelSuggestion( $borrowernumber, $delete_field );
92 map{ $_->{'branchcodesuggestedby'}=GetBranchInfo($_->{'branchcodesuggestedby'})->[0]->{'branchname'}} @$suggestions_loop;
93 my $supportlist=GetSupportList();
94 foreach my $support(@$supportlist){
95 if ($$support{'imageurl'}){
96 $$support{'imageurl'}= getitemtypeimagelocation( 'intranet', $$support{'imageurl'} );
99 delete $$support{'imageurl'}
104 itemtypeloop=> $supportlist,
105 suggestions_loop => $suggestions_loop,
106 suggestedbyme => $suggestedbyme,
110 output_html_with_http_headers $input, $cookie, $template->output;