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 my $negcaptcha = $input->param('negcap');
38 # If a spambot accidentally populates the 'negcap' field in the sugesstions form, then silently skip and return.
40 print $input->redirect("/cgi-bin/koha/opac-suggestions.pl");
44 delete $$suggestion{$_} foreach qw
<op suggestedbyme
>;
45 $op = 'else' unless $op;
47 my ( $template, $borrowernumber, $cookie );
48 my $deleted = $input->param('deleted');
49 my $submitted = $input->param('submitted');
51 if ( C4
::Context
->preference("AnonSuggestions") ) {
52 ( $template, $borrowernumber, $cookie ) = get_template_and_user
(
54 template_name
=> "opac-suggestions.tt",
57 authnotrequired
=> ( C4
::Context
->preference("OpacPublic") ?
1 : 0 ),
60 if ( !$$suggestion{suggestedby
} ) {
61 $$suggestion{suggestedby
} = C4
::Context
->preference("AnonymousPatron");
65 ( $template, $borrowernumber, $cookie ) = get_template_and_user
(
67 template_name
=> "opac-suggestions.tt",
75 delete $$suggestion{suggestedby
};
78 $$suggestion{suggestedby
} ||= $borrowernumber unless ($allsuggestions);
80 # warn "bornum:",$borrowernumber;
82 my $suggestions_loop =
83 &SearchSuggestion
( $suggestion);
84 if ( $op eq "add_confirm" ) {
85 if (@
$suggestions_loop>=1){
86 #some suggestion are answering the request Donot Add
89 my $scrubber = C4
::Scrubber
->new();
90 foreach my $suggest (keys %$suggestion){
91 $suggestion->{$suggest} = $scrubber->scrub($suggestion->{$suggest});
93 $$suggestion{'suggesteddate'}=C4
::Dates
->today;
94 $$suggestion{'branchcode'}= $input->param('branch') || C4
::Context
->userenv->{"branch"};
96 &NewSuggestion
($suggestion);
97 # empty fields, to avoid filter in "SearchSuggestion"
98 $$suggestion{$_}='' foreach qw
<title author publishercode copyrightdate place collectiontitle isbn STATUS
>;
100 &SearchSuggestion
( $suggestion );
103 print $input->redirect("/cgi-bin/koha/opac-suggestions.pl?op=else&submitted=1");
107 if ( $op eq "delete_confirm" ) {
108 my @delete_field = $input->param("delete_field");
109 foreach my $delete_field (@delete_field) {
110 &DelSuggestion
( $borrowernumber, $delete_field );
113 print $input->redirect("/cgi-bin/koha/opac-suggestions.pl?op=else&deleted=1");
116 map{ $_->{'branchcodesuggestedby'}=GetBranchInfo
($_->{'branchcodesuggestedby'})->[0]->{'branchname'}} @
$suggestions_loop;
117 my $supportlist=GetSupportList
();
118 foreach my $support(@
$supportlist){
119 if ($$support{'imageurl'}){
120 $$support{'imageurl'}= getitemtypeimagelocation
( 'opac', $$support{'imageurl'} );
123 delete $$support{'imageurl'}
127 foreach my $suggestion(@
$suggestions_loop) {
128 if($suggestion->{'suggestedby'} == $borrowernumber) {
129 $suggestion->{'showcheckbox'} = $borrowernumber;
131 $suggestion->{'showcheckbox'} = 0;
133 if($suggestion->{'patronreason'}){
134 $suggestion->{'patronreason'} = GetKohaAuthorisedValueLib
("OPAC_SUG",$suggestion->{'patronreason'},1);
138 my $patron_reason_loop = GetAuthorisedValues
("OPAC_SUG");
140 # Is the person allowed to choose their branch
141 if ( C4
::Context
->preference("AllowPurchaseSuggestionBranchChoice") ) {
142 my ( $borr ) = GetMemberDetails
( $borrowernumber );
144 # pass the pickup branch along....
146 if (C4
::Context
->userenv && C4
::Context
->userenv->{'branch'}) {
147 $userbranch = C4
::Context
->userenv->{'branch'};
149 my $branch = $input->param('branch') || $borr->{'branchcode'} || $userbranch || '' ;
151 # make branch selection options...
152 my $branchloop = GetBranchesLoop
($branch);
153 $template->param( branchloop
=> $branchloop );
158 itemtypeloop
=> $supportlist,
159 suggestions_loop
=> $suggestions_loop,
160 patron_reason_loop
=> $patron_reason_loop,
161 showall
=> $allsuggestions,
163 suggestionsview
=> 1,
166 output_html_with_http_headers
$input, $cookie, $template->output;