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
32 my $allsuggestions = $input->param('showall');
33 my $op = $input->param('op');
34 my $suggestion = $input->Vars;
35 delete $$suggestion{$_} foreach qw
<op suggestedbyme
>;
36 $op = 'else' unless $op;
38 my ( $template, $borrowernumber, $cookie );
39 my $deleted = $input->param('deleted');
40 my $submitted = $input->param('submitted');
42 if ( C4
::Context
->preference("AnonSuggestions") ) {
43 ( $template, $borrowernumber, $cookie ) = get_template_and_user
(
45 template_name
=> "opac-suggestions.tmpl",
48 authnotrequired
=> ( C4
::Context
->preference("OpacPublic") ?
1 : 0 ),
51 if ( !$$suggestion{suggestedby
} ) {
52 $$suggestion{suggestedby
} = C4
::Context
->preference("AnonymousPatron");
56 ( $template, $borrowernumber, $cookie ) = get_template_and_user
(
58 template_name
=> "opac-suggestions.tmpl",
66 delete $$suggestion{suggestedby
};
69 $$suggestion{suggestedby
} ||= $borrowernumber unless ($allsuggestions);
71 # warn "bornum:",$borrowernumber;
73 my $suggestions_loop =
74 &SearchSuggestion
( $suggestion);
75 if ( $op eq "add_confirm" ) {
76 if (@
$suggestions_loop>=1){
77 #some suggestion are answering the request Donot Add
80 $$suggestion{'suggesteddate'}=C4
::Dates
->today;
81 $$suggestion{'branchcode'}= $input->param('branch') || C4
::Context
->userenv->{"branch"};
82 &NewSuggestion
($suggestion);
83 # empty fields, to avoid filter in "SearchSuggestion"
84 $$suggestion{$_}='' foreach qw
<title author publishercode copyrightdate place collectiontitle isbn STATUS
>;
86 &SearchSuggestion
( $suggestion );
89 print $input->redirect("/cgi-bin/koha/opac-suggestions.pl?op=else&submitted=1");
93 if ( $op eq "delete_confirm" ) {
94 my @delete_field = $input->param("delete_field");
95 foreach my $delete_field (@delete_field) {
96 &DelSuggestion
( $borrowernumber, $delete_field );
99 print $input->redirect("/cgi-bin/koha/opac-suggestions.pl?op=else&deleted=1");
102 map{ $_->{'branchcodesuggestedby'}=GetBranchInfo
($_->{'branchcodesuggestedby'})->[0]->{'branchname'}} @
$suggestions_loop;
103 my $supportlist=GetSupportList
();
104 foreach my $support(@
$supportlist){
105 if ($$support{'imageurl'}){
106 $$support{'imageurl'}= getitemtypeimagelocation
( 'opac', $$support{'imageurl'} );
109 delete $$support{'imageurl'}
113 foreach my $suggestion(@
$suggestions_loop) {
114 if($suggestion->{'suggestedby'} == $borrowernumber) {
115 $suggestion->{'showcheckbox'} = $borrowernumber;
117 $suggestion->{'showcheckbox'} = 0;
119 if($suggestion->{'patronreason'}){
120 $suggestion->{'patronreason'} = GetKohaAuthorisedValueLib
("OPAC_SUG",$suggestion->{'patronreason'},1);
124 my $patron_reason_loop = GetAuthorisedValues
("OPAC_SUG");
126 # Is the person allowed to choose their branch
127 if ( C4
::Context
->preference("AllowPurchaseSuggestionBranchChoice") ) {
128 my ( $borr ) = GetMemberDetails
( $borrowernumber );
130 # pass the pickup branch along....
132 if (C4
::Context
->userenv && C4
::Context
->userenv->{'branch'}) {
133 $userbranch = C4
::Context
->userenv->{'branch'};
135 my $branch = $input->param('branch') || $borr->{'branchcode'} || $userbranch || '' ;
137 # make branch selection options...
138 my $branchloop = GetBranchesLoop
($branch);
139 $template->param( branchloop
=> $branchloop );
144 itemtypeloop
=> $supportlist,
145 suggestions_loop
=> $suggestions_loop,
146 patron_reason_loop
=> $patron_reason_loop,
147 showall
=> $allsuggestions,
149 suggestionsview
=> 1,
152 output_html_with_http_headers
$input, $cookie, $template->output;