booksellers page, some changes
[koha.git] / opac / opac-suggestions.pl
blobcd512de0790ac57960298d39fd1126acb1e011cb
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 );
40 if ( C4::Context->preference("AnonSuggestions") ) {
41 ( $template, $borrowernumber, $cookie ) = get_template_and_user(
43 template_name => "opac-suggestions.tmpl",
44 query => $input,
45 type => "opac",
46 authnotrequired => 1,
49 if ( !$$suggestion{suggestedby} ) {
50 $$suggestion{suggestedby} = C4::Context->preference("AnonSuggestions");
53 else {
54 ( $template, $borrowernumber, $cookie ) = get_template_and_user(
56 template_name => "opac-suggestions.tmpl",
57 query => $input,
58 type => "opac",
59 authnotrequired => 0,
63 if ($allsuggestions){
64 delete $$suggestion{suggestedby};
66 else {
67 $$suggestion{suggestedby} ||= $borrowernumber unless ($allsuggestions);
69 warn "bornum:",$borrowernumber;
70 use YAML;
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
77 else {
78 $$suggestion{'suggestioncreatedon'}=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>;
83 $suggestions_loop =
84 &SearchSuggestion( $suggestion );
86 $op = 'else';
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 );
94 $op = 'else';
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( 'intranet', $$support{'imageurl'} );
102 else {
103 delete $$support{'imageurl'}
106 $template->param(
107 %$suggestion,
108 itemtypeloop=> $supportlist,
109 suggestions_loop => $suggestions_loop,
110 showall => $allsuggestions,
111 "op_$op" => 1,
112 suggestionsview => 1
115 output_html_with_http_headers $input, $cookie, $template->output;