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

(-)a/suggestion/suggestion.pl (-14 / +8 lines)
Lines 384-408 if ($op=~/else/) { Link Here
384
384
385
        # filter on date fields
385
        # filter on date fields
386
        foreach my $field (qw( suggesteddate manageddate accepteddate )) {
386
        foreach my $field (qw( suggesteddate manageddate accepteddate )) {
387
            my $from = $field . "_from";
387
            my $from    = delete $search_params->{"${field}_from"};
388
            my $to   = $field . "_to";
388
            my $to      = delete $search_params->{"${field}_to"};
389
            my $from_dt =
389
390
              $suggestion_ref->{$from}
390
            my $from_dt = $from && eval { dt_from_string($from) };
391
              ? eval { dt_from_string( $suggestion_ref->{$from} ) }
391
            my $to_dt   = $to && eval { dt_from_string($to) };
392
              : undef;
393
            my $to_dt =
394
              $suggestion_ref->{$to}
395
              ? eval { dt_from_string( $suggestion_ref->{$to} ) }
396
              : undef;
397
392
398
            if ( $from_dt || $to_dt ) {
393
            if ( $from_dt || $to_dt ) {
399
                my $dtf = Koha::Database->new->schema->storage->datetime_parser;
394
                my $dtf = Koha::Database->new->schema->storage->datetime_parser;
400
                if ( $from_dt && $to_dt ) {
395
                if ( $from_dt && $to_dt ) {
401
                    $search_params->{$field} = { -between => [ $from_dt, $to_dt ] };
396
                    $search_params->{$field} = { -between => [ $dtf->format_date($from_dt), $dtf->format_date($to_dt) ] };
402
                } elsif ( $from_dt ) {
397
                } elsif ( $from_dt ) {
403
                    $search_params->{$field} = { '>=' => $from_dt };
398
                    $search_params->{$field} = { '>=' => $dtf->format_date($from_dt) };
404
                } elsif ( $to_dt ) {
399
                } elsif ( $to_dt ) {
405
                    $search_params->{$field} = { '<=' => $to_dt };
400
                    $search_params->{$field} = { '<=' => $dtf->format_date($to_dt) };
406
                }
401
                }
407
            }
402
            }
408
        }
403
        }
409
- 

Return to bug 31158