View | Details | Raw Unified | Return to bug 12627
Collapse All | Expand All

(-)a/C4/Suggestions.pm (-12 / +3 lines)
Lines 426-438 Insert a new suggestion on database with value given on input arg. Link Here
426
sub NewSuggestion {
426
sub NewSuggestion {
427
    my ($suggestion) = @_;
427
    my ($suggestion) = @_;
428
428
429
    my $new_suggestion = { %$suggestion };
430
    $suggestion->{STATUS} = "ASKED" unless $suggestion->{STATUS};
429
    $suggestion->{STATUS} = "ASKED" unless $suggestion->{STATUS};
431
    $new_suggestion->{status} = $suggestion->{STATUS};
432
    delete $new_suggestion->{STATUS};
433
430
434
    my $rs = Koha::Database->new->schema->resultset('Suggestion');
431
    my $rs = Koha::Database->new->schema->resultset('Suggestion');
435
    return $rs->create($new_suggestion)->id;
432
    return $rs->create($suggestion)->id;
436
}
433
}
437
434
438
=head2 ModSuggestion
435
=head2 ModSuggestion
Lines 452-470 sub ModSuggestion { Link Here
452
    my ($suggestion) = @_;
449
    my ($suggestion) = @_;
453
    return unless( $suggestion and defined($suggestion->{suggestionid}) );
450
    return unless( $suggestion and defined($suggestion->{suggestionid}) );
454
451
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')->find($suggestion->{suggestionid});
452
    my $rs = Koha::Database->new->schema->resultset('Suggestion')->find($suggestion->{suggestionid});
461
    my $status_update_table = 1;
453
    my $status_update_table = 1;
462
    eval {
454
    eval {
463
        $rs->update($mod_suggestion);
455
        $rs->update($suggestion);
464
    };
456
    };
465
    $status_update_table = 0 if( $@ );
457
    $status_update_table = 0 if( $@ );
466
458
467
    if ( $status ) {
459
    if ( $suggestion->{STATUS} ) {
468
460
469
        # fetch the entire updated suggestion so that we can populate the letter
461
        # fetch the entire updated suggestion so that we can populate the letter
470
        my $full_suggestion = GetSuggestion( $suggestion->{suggestionid} );
462
        my $full_suggestion = GetSuggestion( $suggestion->{suggestionid} );
471
- 

Return to bug 12627