Backing down the required version of Graphics::Magick
[koha.git] / opac / opac-suggestions.pl
blobe11cd0bcb7c81fba9f720b66f2897c0ca82455bc
1 #!/usr/bin/perl
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
8 # version.
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
18 use strict;
19 use warnings;
21 use CGI;
22 use C4::Auth; # get_template_and_user
23 use C4::Branch;
24 use C4::Koha;
25 use C4::Output;
26 use C4::Suggestions;
27 use C4::Koha;
28 use C4::Dates;
30 my $input = new CGI;
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 );
38 my $deleted = $input->param('deleted');
39 my $submitted = $input->param('submitted');
41 if ( C4::Context->preference("AnonSuggestions") ) {
42 ( $template, $borrowernumber, $cookie ) = get_template_and_user(
44 template_name => "opac-suggestions.tmpl",
45 query => $input,
46 type => "opac",
47 authnotrequired => 1,
50 if ( !$$suggestion{suggestedby} ) {
51 $$suggestion{suggestedby} = C4::Context->preference("AnonSuggestions");
54 else {
55 ( $template, $borrowernumber, $cookie ) = get_template_and_user(
57 template_name => "opac-suggestions.tmpl",
58 query => $input,
59 type => "opac",
60 authnotrequired => 0,
64 if ($allsuggestions){
65 delete $$suggestion{suggestedby};
67 else {
68 $$suggestion{suggestedby} ||= $borrowernumber unless ($allsuggestions);
70 # warn "bornum:",$borrowernumber;
71 use YAML;
72 my $suggestions_loop =
73 &SearchSuggestion( $suggestion);
74 if ( $op eq "add_confirm" ) {
75 if (@$suggestions_loop>=1){
76 #some suggestion are answering the request Donot Add
78 else {
79 $$suggestion{'suggesteddate'}=C4::Dates->today;
80 $$suggestion{'branchcode'}=C4::Context->userenv->{"branch"};
81 &NewSuggestion($suggestion);
82 # empty fields, to avoid filter in "SearchSuggestion"
83 $$suggestion{$_}='' foreach qw<title author publishercode copyrightdate place collectiontitle isbn STATUS>;
84 $suggestions_loop =
85 &SearchSuggestion( $suggestion );
87 $op = 'else';
88 print $input->redirect("/cgi-bin/koha/opac-suggestions.pl?op=else&submitted=1");
89 exit;
92 if ( $op eq "delete_confirm" ) {
93 my @delete_field = $input->param("delete_field");
94 foreach my $delete_field (@delete_field) {
95 &DelSuggestion( $borrowernumber, $delete_field );
97 $op = 'else';
98 print $input->redirect("/cgi-bin/koha/opac-suggestions.pl?op=else&deleted=1");
99 exit;
101 map{ $_->{'branchcodesuggestedby'}=GetBranchInfo($_->{'branchcodesuggestedby'})->[0]->{'branchname'}} @$suggestions_loop;
102 my $supportlist=GetSupportList();
103 foreach my $support(@$supportlist){
104 if ($$support{'imageurl'}){
105 $$support{'imageurl'}= getitemtypeimagelocation( 'opac', $$support{'imageurl'} );
107 else {
108 delete $$support{'imageurl'}
112 foreach my $suggestion(@$suggestions_loop) {
113 if($suggestion->{'suggestedby'} == $borrowernumber) {
114 $suggestion->{'showcheckbox'} = $borrowernumber;
115 } else {
116 $suggestion->{'showcheckbox'} = 0;
120 $template->param(
121 %$suggestion,
122 itemtypeloop=> $supportlist,
123 suggestions_loop => $suggestions_loop,
124 showall => $allsuggestions,
125 "op_$op" => 1,
126 suggestionsview => 1,
130 output_html_with_http_headers $input, $cookie, $template->output;