|
Lines 26-32
use CGI;
Link Here
|
| 26 |
use C4::Context; |
26 |
use C4::Context; |
| 27 |
use C4::Output; |
27 |
use C4::Output; |
| 28 |
use C4::Dates qw(format_date format_date_in_iso); |
28 |
use C4::Dates qw(format_date format_date_in_iso); |
| 29 |
use C4::SQLHelper qw(:all); |
|
|
| 30 |
use C4::Debug; |
29 |
use C4::Debug; |
| 31 |
use C4::Letters; |
30 |
use C4::Letters; |
| 32 |
use List::MoreUtils qw(any); |
31 |
use List::MoreUtils qw(any); |
|
Lines 426-433
Insert a new suggestion on database with value given on input arg.
Link Here
|
| 426 |
|
425 |
|
| 427 |
sub NewSuggestion { |
426 |
sub NewSuggestion { |
| 428 |
my ($suggestion) = @_; |
427 |
my ($suggestion) = @_; |
|
|
428 |
|
| 429 |
my $new_suggestion = { %$suggestion }; |
| 429 |
$suggestion->{STATUS} = "ASKED" unless $suggestion->{STATUS}; |
430 |
$suggestion->{STATUS} = "ASKED" unless $suggestion->{STATUS}; |
| 430 |
return InsertInTable( "suggestions", $suggestion ); |
431 |
$new_suggestion->{status} = $suggestion->{STATUS}; |
|
|
432 |
delete $new_suggestion->{STATUS}; |
| 433 |
|
| 434 |
my $rs = Koha::Database->new->schema->resultset('Suggestion'); |
| 435 |
return $rs->create($new_suggestion)->id; |
| 431 |
} |
436 |
} |
| 432 |
|
437 |
|
| 433 |
=head2 ModSuggestion |
438 |
=head2 ModSuggestion |
|
Lines 445-453
Note that there is no function to modify a suggestion.
Link Here
|
| 445 |
|
450 |
|
| 446 |
sub ModSuggestion { |
451 |
sub ModSuggestion { |
| 447 |
my ($suggestion) = @_; |
452 |
my ($suggestion) = @_; |
| 448 |
my $status_update_table = UpdateInTable( "suggestions", $suggestion ); |
453 |
return unless( $suggestion and defined($suggestion->{suggestionid}) ); |
|
|
454 |
|
| 455 |
my $mod_suggestion = { %$suggestion }; |
| 456 |
my $status = $suggestion->{STATUS}; |
| 457 |
delete $mod_suggestion->{STATUS}; |
| 458 |
$mod_suggestion->{status} = $status; |
| 459 |
|
| 460 |
my $rs = Koha::Database->new->schema->resultset('Suggestion'); |
| 461 |
my $status_update_table = $rs->update($suggestion); |
| 449 |
|
462 |
|
| 450 |
if ( $suggestion->{STATUS} ) { |
463 |
if ( $status ) { |
| 451 |
|
464 |
|
| 452 |
# fetch the entire updated suggestion so that we can populate the letter |
465 |
# fetch the entire updated suggestion so that we can populate the letter |
| 453 |
my $full_suggestion = GetSuggestion( $suggestion->{suggestionid} ); |
466 |
my $full_suggestion = GetSuggestion( $suggestion->{suggestionid} ); |