|
Lines 112-147
if ( $op eq 'else' ) {
Link Here
|
| 112 |
} |
112 |
} |
| 113 |
} |
113 |
} |
| 114 |
|
114 |
|
| 115 |
my $suggestions_loop = |
115 |
my $suggestions_loop = &SearchSuggestion($suggestion); |
| 116 |
&SearchSuggestion( $suggestion); |
|
|
| 117 |
if ( $op eq "add_confirm" ) { |
116 |
if ( $op eq "add_confirm" ) { |
| 118 |
my $count_own_suggestions = $borrowernumber ? &SearchSuggestion( { suggestedby => $borrowernumber}) : 0; |
117 |
my $count_own_suggestions = $borrowernumber ? &SearchSuggestion( { suggestedby => $borrowernumber } ) : 0; |
| 119 |
if( @$count_own_suggestions >= C4::Context->preference("MaxOpenSuggestions") ){ |
118 |
if ( @$count_own_suggestions >= C4::Context->preference("MaxOpenSuggestions") ) |
| 120 |
push @messages, { type => 'error', code => 'too_many'}; |
119 |
{ |
|
|
120 |
push @messages, { type => 'error', code => 'too_many' }; |
| 121 |
} |
121 |
} |
| 122 |
elsif (@$suggestions_loop>=1){ |
122 |
elsif ( @$suggestions_loop >= 1 ) { |
| 123 |
#some suggestion are answering the request Donot Add |
123 |
|
| 124 |
for my $suggestion ( @$suggestions_loop ) { |
124 |
#some suggestion are answering the request Donot Add |
| 125 |
push @messages, { type => 'error', code => 'already_exists', id => $suggestion->{suggestionid} }; |
125 |
for my $suggestion (@$suggestions_loop) { |
|
|
126 |
push @messages, |
| 127 |
{ |
| 128 |
type => 'error', |
| 129 |
code => 'already_exists', |
| 130 |
id => $suggestion->{suggestionid} |
| 131 |
}; |
| 126 |
last; |
132 |
last; |
| 127 |
} |
133 |
} |
| 128 |
} |
134 |
} |
| 129 |
else { |
135 |
else { |
| 130 |
my $scrubber = C4::Scrubber->new(); |
136 |
my $scrubber = C4::Scrubber->new(); |
| 131 |
foreach my $suggest (keys %$suggestion){ |
137 |
foreach my $suggest ( keys %$suggestion ) { |
|
|
138 |
|
| 132 |
# Don't know why the encode is needed for Perl v5.10 here |
139 |
# Don't know why the encode is needed for Perl v5.10 here |
| 133 |
$suggestion->{$suggest} = Encode::encode("utf8", $scrubber->scrub($suggestion->{$suggest}) ); |
140 |
$suggestion->{$suggest} = Encode::encode( "utf8", |
| 134 |
} |
141 |
$scrubber->scrub( $suggestion->{$suggest} ) ); |
|
|
142 |
} |
| 135 |
$suggestion->{suggesteddate} = dt_from_string; |
143 |
$suggestion->{suggesteddate} = dt_from_string; |
| 136 |
$suggestion->{branchcode} = $input->param('branchcode') || C4::Context->userenv->{"branch"}; |
144 |
$suggestion->{branchcode} = $input->param('branchcode') || C4::Context->userenv->{"branch"}; |
| 137 |
|
145 |
|
| 138 |
&NewSuggestion($suggestion); |
146 |
&NewSuggestion($suggestion); |
| 139 |
# empty fields, to avoid filter in "SearchSuggestion" |
147 |
|
| 140 |
$$suggestion{$_}='' foreach qw<title author publishercode copyrightdate place collectiontitle isbn STATUS>; |
148 |
# delete empty fields, to avoid filter in "SearchSuggestion" |
| 141 |
$suggestions_loop = |
149 |
foreach my $field ( qw( title author publishercode copyrightdate place collectiontitle isbn STATUS ) ) { |
| 142 |
&SearchSuggestion( $suggestion ); |
150 |
delete $suggestion->{$field} unless $suggestion->{$field}; |
|
|
151 |
} |
| 152 |
$suggestions_loop = &SearchSuggestion($suggestion); |
| 143 |
push @messages, { type => 'info', code => 'success_on_inserted' }; |
153 |
push @messages, { type => 'info', code => 'success_on_inserted' }; |
| 144 |
} |
154 |
} |
| 145 |
$op = 'else'; |
155 |
$op = 'else'; |
| 146 |
} |
156 |
} |
| 147 |
|
157 |
|
|
Lines 161-173
map{
Link Here
|
| 161 |
$library ? $s->{branchcodesuggestedby} = $library->branchname : () |
171 |
$library ? $s->{branchcodesuggestedby} = $library->branchname : () |
| 162 |
} @$suggestions_loop; |
172 |
} @$suggestions_loop; |
| 163 |
|
173 |
|
| 164 |
my $own_suggestions_count = 0; |
|
|
| 165 |
foreach my $suggestion(@$suggestions_loop) { |
174 |
foreach my $suggestion(@$suggestions_loop) { |
| 166 |
if($suggestion->{'suggestedby'} == $borrowernumber) { |
175 |
if($suggestion->{'suggestedby'} == $borrowernumber) { |
| 167 |
$suggestion->{'showcheckbox'} = $borrowernumber; |
176 |
$suggestion->{'showcheckbox'} = $borrowernumber; |
| 168 |
if ( $suggestion->{'STATUS'} eq 'ASKED' ) { |
|
|
| 169 |
$own_suggestions_count++; |
| 170 |
} |
| 171 |
} else { |
177 |
} else { |
| 172 |
$suggestion->{'showcheckbox'} = 0; |
178 |
$suggestion->{'showcheckbox'} = 0; |
| 173 |
} |
179 |
} |
|
Lines 195-209
if ( C4::Context->preference("AllowPurchaseSuggestionBranchChoice") ) {
Link Here
|
| 195 |
} |
201 |
} |
| 196 |
|
202 |
|
| 197 |
$template->param( |
203 |
$template->param( |
| 198 |
%$suggestion, |
204 |
%$suggestion, |
| 199 |
suggestions_loop => $suggestions_loop, |
205 |
suggestions_loop => $suggestions_loop, |
| 200 |
patron_reason_loop => $patron_reason_loop, |
206 |
patron_reason_loop => $patron_reason_loop, |
| 201 |
"op_$op" => 1, |
207 |
"op_$op" => 1, |
| 202 |
$op => 1, |
208 |
$op => 1, |
| 203 |
messages => \@messages, |
209 |
messages => \@messages, |
| 204 |
suggestionsview => 1, |
210 |
suggestionsview => 1, |
| 205 |
suggested_by_anyone => $suggested_by_anyone, |
211 |
suggested_by_anyone => $suggested_by_anyone, |
| 206 |
own_suggestions_count => $own_suggestions_count, |
212 |
own_suggestions_count => scalar @{ |
|
|
213 |
SearchSuggestion( |
| 214 |
{ suggestedby => $borrowernumber, STATUS => 'ASKED' } |
| 215 |
) |
| 216 |
}, |
| 207 |
); |
217 |
); |
| 208 |
|
218 |
|
| 209 |
output_html_with_http_headers $input, $cookie, $template->output; |
219 |
output_html_with_http_headers $input, $cookie, $template->output; |
| 210 |
- |
|
|