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

(-)a/C4/Suggestions.pm (+33 lines)
Lines 28-33 use C4::Output; Link Here
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::Debug;
29
use C4::Debug;
30
use C4::Letters;
30
use C4::Letters;
31
use Koha::DateUtils qw( dt_from_string );
32
31
use List::MoreUtils qw(any);
33
use List::MoreUtils qw(any);
32
use C4::Dates qw(format_date_in_iso);
34
use C4::Dates qw(format_date_in_iso);
33
use base qw(Exporter);
35
use base qw(Exporter);
Lines 428-433 sub NewSuggestion { Link Here
428
430
429
    $suggestion->{STATUS} = "ASKED" unless $suggestion->{STATUS};
431
    $suggestion->{STATUS} = "ASKED" unless $suggestion->{STATUS};
430
432
433
    for my $field ( qw(
434
        suggestedby
435
        managedby
436
        manageddate
437
        acceptedby
438
        accepteddate
439
        rejectedby
440
        rejecteddate
441
    ) ) {
442
        # Set the fields to NULL if not given.
443
        $suggestion->{$field} ||= undef;
444
    }
445
446
    $suggestion->{suggesteddate} = dt_from_string unless $suggestion->{suggesteddate};
447
431
    my $rs = Koha::Database->new->schema->resultset('Suggestion');
448
    my $rs = Koha::Database->new->schema->resultset('Suggestion');
432
    return $rs->create($suggestion)->id;
449
    return $rs->create($suggestion)->id;
433
}
450
}
Lines 449-454 sub ModSuggestion { Link Here
449
    my ($suggestion) = @_;
466
    my ($suggestion) = @_;
450
    return unless( $suggestion and defined($suggestion->{suggestionid}) );
467
    return unless( $suggestion and defined($suggestion->{suggestionid}) );
451
468
469
    for my $field ( qw(
470
        suggestedby
471
        managedby
472
        manageddate
473
        acceptedby
474
        accepteddate
475
        rejectedby
476
        rejecteddate
477
    ) ) {
478
        # Set the fields to NULL if not given.
479
        $suggestion->{$field} = undef
480
          if exists $suggestion->{$field}
481
          and ($suggestion->{$field} == '0'
482
            or $suggestion->{$field} == '' );
483
    }
484
452
    my $rs = Koha::Database->new->schema->resultset('Suggestion')->find($suggestion->{suggestionid});
485
    my $rs = Koha::Database->new->schema->resultset('Suggestion')->find($suggestion->{suggestionid});
453
    my $status_update_table = 1;
486
    my $status_update_table = 1;
454
    eval {
487
    eval {
(-)a/suggestion/suggestion.pl (-2 / +4 lines)
Lines 124-130 $template->param('borrowernumber' => $borrowernumber); Link Here
124
##  Operations
124
##  Operations
125
##
125
##
126
if ( $op =~ /save/i ) {
126
if ( $op =~ /save/i ) {
127
        if ( $suggestion_only->{"STATUS"} ) {
127
    $suggestion_only->{suggesteddate} = dt_from_string( $suggestion_only->{suggesteddate} )
128
        if $suggestion_only->{suggesteddate};
129
130
    if ( $suggestion_only->{"STATUS"} ) {
128
        if ( my $tmpstatus = lc( $suggestion_only->{"STATUS"} ) =~ /ACCEPTED|REJECTED/i ) {
131
        if ( my $tmpstatus = lc( $suggestion_only->{"STATUS"} ) =~ /ACCEPTED|REJECTED/i ) {
129
            $suggestion_only->{ lc( $suggestion_only->{"STATUS"}) . "date" } = dt_from_string;
132
            $suggestion_only->{ lc( $suggestion_only->{"STATUS"}) . "date" } = dt_from_string;
130
            $suggestion_only->{ lc( $suggestion_only->{"STATUS"}) . "by" }   = C4::Context->userenv->{number};
133
            $suggestion_only->{ lc( $suggestion_only->{"STATUS"}) . "by" }   = C4::Context->userenv->{number};
131
- 

Return to bug 12627