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
31 my $allsuggestions = $input->param('showall');
32 my $op = $input->param('op');
33 my $suggestion = $input->Vars;
34 delete $$suggestion{$_} foreach qw
<op suggestedbyme
>;
35 $op = 'else' unless $op;
37 my ( $template, $borrowernumber, $cookie );
40 if ( C4
::Context
->preference("AnonSuggestions") ) {
41 ( $template, $borrowernumber, $cookie ) = get_template_and_user
(
43 template_name
=> "opac-suggestions.tmpl",
49 if ( !$$suggestion{suggestedby
} ) {
50 $$suggestion{suggestedby
} = C4
::Context
->preference("AnonSuggestions");
54 ( $template, $borrowernumber, $cookie ) = get_template_and_user
(
56 template_name
=> "opac-suggestions.tmpl",
64 delete $$suggestion{suggestedby
};
67 $$suggestion{suggestedby
} ||= $borrowernumber unless ($allsuggestions);
69 # warn "bornum:",$borrowernumber;
71 my $suggestions_loop =
72 &SearchSuggestion
( $suggestion);
73 if ( $op eq "add_confirm" ) {
74 if (@
$suggestions_loop>=1){
75 #some suggestion are answering the request Donot Add
78 $$suggestion{'suggestioncreateddate'}=C4
::Dates
->today;
79 $$suggestion{'branchcode'}=C4
::Context
->userenv->{"branch"};
80 &NewSuggestion
($suggestion);
81 # empty fields, to avoid filter in "SearchSuggestion"
82 $$suggestion{$_}='' foreach qw
<title author publishercode copyrightdate place collectiontitle isbn STATUS
>;
84 &SearchSuggestion
( $suggestion );
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 );
96 map{ $_->{'branchcodesuggestedby'}=GetBranchInfo
($_->{'branchcodesuggestedby'})->[0]->{'branchname'}} @
$suggestions_loop;
97 my $supportlist=GetSupportList
();
98 foreach my $support(@
$supportlist){
99 if ($$support{'imageurl'}){
100 $$support{'imageurl'}= getitemtypeimagelocation
( 'opac', $$support{'imageurl'} );
103 delete $$support{'imageurl'}
108 itemtypeloop
=> $supportlist,
109 suggestions_loop
=> $suggestions_loop,
110 showall
=> $allsuggestions,
116 output_html_with_http_headers
$input, $cookie, $template->output;