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
15 # with Koha; if not, write to the Free Software Foundation, Inc.,
16 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 use C4
::Auth
; # get_template_and_user
33 my $allsuggestions = $input->param('showall');
34 my $op = $input->param('op');
35 my $suggestion = $input->Vars;
36 delete $suggestion->{negcap
};
37 my $negcaptcha = $input->param('negcap');
39 # If a spambot accidentally populates the 'negcap' field in the sugesstions form, then silently skip and return.
41 print $input->redirect("/cgi-bin/koha/opac-suggestions.pl");
45 delete $$suggestion{$_} foreach qw
<op suggestedbyme
>;
46 $op = 'else' unless $op;
48 my ( $template, $borrowernumber, $cookie );
49 my $deleted = $input->param('deleted');
50 my $submitted = $input->param('submitted');
52 if ( C4
::Context
->preference("AnonSuggestions") ) {
53 ( $template, $borrowernumber, $cookie ) = get_template_and_user
(
55 template_name
=> "opac-suggestions.tt",
58 authnotrequired
=> ( C4
::Context
->preference("OpacPublic") ?
1 : 0 ),
61 if ( !$$suggestion{suggestedby
} ) {
62 $$suggestion{suggestedby
} = C4
::Context
->preference("AnonymousPatron");
66 ( $template, $borrowernumber, $cookie ) = get_template_and_user
(
68 template_name
=> "opac-suggestions.tt",
76 delete $$suggestion{suggestedby
};
79 $$suggestion{suggestedby
} ||= $borrowernumber unless ($allsuggestions);
81 # warn "bornum:",$borrowernumber;
83 my $suggestions_loop =
84 &SearchSuggestion
( $suggestion);
85 if ( $op eq "add_confirm" ) {
86 if (@
$suggestions_loop>=1){
87 #some suggestion are answering the request Donot Add
90 my $scrubber = C4
::Scrubber
->new();
91 foreach my $suggest (keys %$suggestion){
92 $suggestion->{$suggest} = $scrubber->scrub($suggestion->{$suggest});
94 $$suggestion{'suggesteddate'}=C4
::Dates
->today;
95 $$suggestion{'branchcode'}= $input->param('branch') || C4
::Context
->userenv->{"branch"};
97 &NewSuggestion
($suggestion);
98 # empty fields, to avoid filter in "SearchSuggestion"
99 $$suggestion{$_}='' foreach qw
<title author publishercode copyrightdate place collectiontitle isbn STATUS
>;
101 &SearchSuggestion
( $suggestion );
104 print $input->redirect("/cgi-bin/koha/opac-suggestions.pl?op=else&submitted=1");
108 if ( $op eq "delete_confirm" ) {
109 my @delete_field = $input->param("delete_field");
110 foreach my $delete_field (@delete_field) {
111 &DelSuggestion
( $borrowernumber, $delete_field );
114 print $input->redirect("/cgi-bin/koha/opac-suggestions.pl?op=else&deleted=1");
117 map{ $_->{'branchcodesuggestedby'}=GetBranchInfo
($_->{'branchcodesuggestedby'})->[0]->{'branchname'}} @
$suggestions_loop;
118 my $supportlist=GetSupportList
();
119 foreach my $support(@
$supportlist){
120 if ($$support{'imageurl'}){
121 $$support{'imageurl'}= getitemtypeimagelocation
( 'opac', $$support{'imageurl'} );
124 delete $$support{'imageurl'}
128 foreach my $suggestion(@
$suggestions_loop) {
129 if($suggestion->{'suggestedby'} == $borrowernumber) {
130 $suggestion->{'showcheckbox'} = $borrowernumber;
132 $suggestion->{'showcheckbox'} = 0;
134 if($suggestion->{'patronreason'}){
135 $suggestion->{'patronreason'} = GetKohaAuthorisedValueLib
("OPAC_SUG",$suggestion->{'patronreason'},1);
139 my $patron_reason_loop = GetAuthorisedValues
("OPAC_SUG");
141 # Is the person allowed to choose their branch
142 if ( C4
::Context
->preference("AllowPurchaseSuggestionBranchChoice") ) {
143 my ( $borr ) = GetMemberDetails
( $borrowernumber );
145 # pass the pickup branch along....
147 if (C4
::Context
->userenv && C4
::Context
->userenv->{'branch'}) {
148 $userbranch = C4
::Context
->userenv->{'branch'};
150 my $branch = $input->param('branch') || $borr->{'branchcode'} || $userbranch || '' ;
152 # make branch selection options...
153 my $branchloop = GetBranchesLoop
($branch);
154 $template->param( branchloop
=> $branchloop );
159 itemtypeloop
=> $supportlist,
160 suggestions_loop
=> $suggestions_loop,
161 patron_reason_loop
=> $patron_reason_loop,
162 showall
=> $allsuggestions,
164 suggestionsview
=> 1,
167 output_html_with_http_headers
$input, $cookie, $template->output;