|
Lines 125-137
unless ( $op eq 'cud-save' ) {
Link Here
|
| 125 |
} |
125 |
} |
| 126 |
|
126 |
|
| 127 |
my ( $template, $borrowernumber, $cookie, $userflags ) = get_template_and_user( |
127 |
my ( $template, $borrowernumber, $cookie, $userflags ) = get_template_and_user( |
| 128 |
{ |
128 |
{ |
| 129 |
template_name => "suggestion/suggestion.tt", |
129 |
template_name => "suggestion/suggestion.tt", |
| 130 |
query => $input, |
130 |
query => $input, |
| 131 |
type => "intranet", |
131 |
type => "intranet", |
| 132 |
flagsrequired => { suggestions => 'suggestions_manage' }, |
132 |
flagsrequired => { suggestions => '*' }, |
| 133 |
} |
133 |
} |
| 134 |
); |
134 |
); |
|
|
135 |
|
| 136 |
my $librarian = Koha::Patrons->find($borrowernumber); |
| 135 |
|
137 |
|
| 136 |
$borrowernumber = $input->param('borrowernumber') if ( $input->param('borrowernumber') ); |
138 |
$borrowernumber = $input->param('borrowernumber') if ( $input->param('borrowernumber') ); |
| 137 |
$template->param('borrowernumber' => $borrowernumber); |
139 |
$template->param('borrowernumber' => $borrowernumber); |
|
Lines 141-148
my $branchfilter = $input->param('branchcode') || C4::Context->userenv->{'branch
Link Here
|
| 141 |
## Operations |
143 |
## Operations |
| 142 |
## |
144 |
## |
| 143 |
|
145 |
|
|
|
146 |
my @messages; |
| 144 |
if ( $op =~ /cud-save/ ) { |
147 |
if ( $op =~ /cud-save/ ) { |
|
|
148 |
output_and_exit_if_error($input, $cookie, $template, { check => 'csrf_token' }); |
| 149 |
|
| 145 |
my @messages; |
150 |
my @messages; |
|
|
151 |
|
| 146 |
my $biblio = MarcRecordFromNewSuggestion({ |
152 |
my $biblio = MarcRecordFromNewSuggestion({ |
| 147 |
title => $suggestion_only->{title}, |
153 |
title => $suggestion_only->{title}, |
| 148 |
author => $suggestion_only->{author}, |
154 |
author => $suggestion_only->{author}, |
|
Lines 201-207
if ( $op =~ /cud-save/ ) {
Link Here
|
| 201 |
if exists $suggestion_only->{branchcode} |
207 |
if exists $suggestion_only->{branchcode} |
| 202 |
&& $suggestion_only->{branchcode} eq ""; |
208 |
&& $suggestion_only->{branchcode} eq ""; |
| 203 |
|
209 |
|
| 204 |
&ModSuggestion($suggestion_only); |
210 |
if ( $librarian->has_permission( { 'suggestions' => 'suggestions_manage' } ) ) { |
|
|
211 |
&ModSuggestion($suggestion_only); |
| 212 |
} else { |
| 213 |
push @messages, { type => 'error', code => 'no_manage_permission' }; |
| 214 |
$template->param( messages => \@messages, ); |
| 215 |
} |
| 205 |
|
216 |
|
| 206 |
if ( $notify ) { |
217 |
if ( $notify ) { |
| 207 |
my $patron = Koha::Patrons->find( $suggestion_only->{managedby} ); |
218 |
my $patron = Koha::Patrons->find( $suggestion_only->{managedby} ); |
|
Lines 241-247
if ( $op =~ /cud-save/ ) {
Link Here
|
| 241 |
} |
252 |
} |
| 242 |
else { |
253 |
else { |
| 243 |
## Adding some informations related to suggestion |
254 |
## Adding some informations related to suggestion |
| 244 |
Koha::Suggestion->new($suggestion_only)->store(); |
255 |
if ( $librarian->has_permission( { 'suggestions' => 'suggestions_create' } ) ) { |
|
|
256 |
Koha::Suggestion->new($suggestion_only)->store(); |
| 257 |
} else { |
| 258 |
push @messages, { type => 'error', code => 'no_delete_permission' }; |
| 259 |
$template->param( messages => \@messages ); |
| 260 |
} |
| 245 |
} |
261 |
} |
| 246 |
# empty fields, to avoid filter in "SearchSuggestion" |
262 |
# empty fields, to avoid filter in "SearchSuggestion" |
| 247 |
} |
263 |
} |
|
Lines 303-319
elsif ($op eq "cud-update_status" ) {
Link Here
|
| 303 |
$suggestion->{reason} = $reason; |
319 |
$suggestion->{reason} = $reason; |
| 304 |
} |
320 |
} |
| 305 |
|
321 |
|
| 306 |
foreach my $suggestionid (@editsuggestions) { |
322 |
if ( $librarian->has_permission( { 'suggestions' => 'suggestions_manage' } ) ) { |
| 307 |
next unless $suggestionid; |
323 |
foreach my $suggestionid (@editsuggestions) { |
| 308 |
$suggestion->{suggestionid} = $suggestionid; |
324 |
next unless $suggestionid; |
| 309 |
&ModSuggestion($suggestion); |
325 |
$suggestion->{suggestionid} = $suggestionid; |
|
|
326 |
&ModSuggestion($suggestion); |
| 327 |
} |
| 328 |
redirect_with_params($input); |
| 329 |
} else { |
| 330 |
push @messages, { type => 'error', code => 'no_manage_permission' }; |
| 331 |
$template->param( messages => \@messages, ); |
| 310 |
} |
332 |
} |
| 311 |
redirect_with_params($input); |
333 |
redirect_with_params($input); |
| 312 |
}elsif ($op eq "cud-delete" ) { |
334 |
} elsif ($op eq "cud-delete" ) { |
| 313 |
foreach my $delete_field (@editsuggestions) { |
335 |
if ( $librarian->has_permission( { 'suggestions' => 'suggestions_delete' } ) ) { |
| 314 |
&DelSuggestion( $borrowernumber, $delete_field,'intranet' ); |
336 |
foreach my $delete_field (@editsuggestions) { |
|
|
337 |
&DelSuggestion( $borrowernumber, $delete_field, 'intranet' ); |
| 338 |
} |
| 339 |
redirect_with_params($input); |
| 340 |
} else { |
| 341 |
push @messages, { type => 'error', code => 'no_delete_permission' }; |
| 342 |
$template->param( messages => \@messages, ); |
| 315 |
} |
343 |
} |
| 316 |
redirect_with_params($input); |
|
|
| 317 |
} |
344 |
} |
| 318 |
elsif ($op eq "cud-archive" ) { |
345 |
elsif ($op eq "cud-archive" ) { |
| 319 |
Koha::Suggestions->find($_)->update({ archived => 1 }) for @editsuggestions; |
346 |
Koha::Suggestions->find($_)->update({ archived => 1 }) for @editsuggestions; |
|
Lines 324-341
elsif ($op eq "cud-unarchive" ) {
Link Here
|
| 324 |
redirect_with_params($input); |
351 |
redirect_with_params($input); |
| 325 |
} |
352 |
} |
| 326 |
elsif ( $op eq 'cud-update_itemtype' ) { |
353 |
elsif ( $op eq 'cud-update_itemtype' ) { |
| 327 |
foreach my $suggestionid (@editsuggestions) { |
354 |
if ( $librarian->has_permission( { 'suggestions' => 'suggestions_manage' } ) ) { |
| 328 |
next unless $suggestionid; |
355 |
foreach my $suggestionid (@editsuggestions) { |
| 329 |
&ModSuggestion({ suggestionid => $suggestionid, itemtype => $new_itemtype }); |
356 |
next unless $suggestionid; |
|
|
357 |
&ModSuggestion({ suggestionid => $suggestionid, itemtype => $new_itemtype }); |
| 358 |
} |
| 359 |
redirect_with_params($input); |
| 360 |
} else { |
| 361 |
push @messages, { type => 'error', code => 'no_manage_permission' }; |
| 362 |
$template->param( messages => \@messages, ); |
| 330 |
} |
363 |
} |
| 331 |
redirect_with_params($input); |
|
|
| 332 |
} |
364 |
} |
| 333 |
elsif ( $op eq 'cud-update_manager' ) { |
365 |
elsif ( $op eq 'cud-update_manager' ) { |
| 334 |
foreach my $suggestionid (@editsuggestions) { |
366 |
if ( $librarian->has_permission( { 'suggestions' => 'suggestions_manage' } ) ) { |
| 335 |
next unless $suggestionid; |
367 |
foreach my $suggestionid (@editsuggestions) { |
| 336 |
&ModSuggestion({ suggestionid => $suggestionid, managedby => $sugg_managedby }); |
368 |
next unless $suggestionid; |
|
|
369 |
&ModSuggestion({ suggestionid => $suggestionid, managedby => $sugg_managedby }); |
| 370 |
} |
| 371 |
redirect_with_params($input); |
| 372 |
} else { |
| 373 |
push @messages, { type => 'error', code => 'no_manage_permission' }; |
| 374 |
$template->param( messages => \@messages, ); |
| 337 |
} |
375 |
} |
| 338 |
redirect_with_params($input); |
|
|
| 339 |
} |
376 |
} |
| 340 |
elsif ( $op eq 'show' ) { |
377 |
elsif ( $op eq 'show' ) { |
| 341 |
$suggestion_ref=&GetSuggestion($$suggestion_ref{'suggestionid'}); |
378 |
$suggestion_ref=&GetSuggestion($$suggestion_ref{'suggestionid'}); |