Bug 31158: (bug 23991 follow-up) Fix suggestion search by dates
Search suggestions by date is broken, we don't remove the '_from' CGI params for the DBIC query DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st execute failed: Unknown column 'suggesteddate_from' in 'where clause' at /kohadevbox/koha/Koha/Objects.pm line 394 at /usr/share/perl5/DBIx/Class/Exception.pm line 77 Test plan: Create some suggestions, search for them using date range (suggested date, managed date and accepted date) Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
parent
5e29433bdc
commit
89f2f369a6
|
|
@ -384,25 +384,20 @@ if ($op=~/else/) {
|
|||
|
||||
# filter on date fields
|
||||
foreach my $field (qw( suggesteddate manageddate accepteddate )) {
|
||||
my $from = $field . "_from";
|
||||
my $to = $field . "_to";
|
||||
my $from_dt =
|
||||
$suggestion_ref->{$from}
|
||||
? eval { dt_from_string( $suggestion_ref->{$from} ) }
|
||||
: undef;
|
||||
my $to_dt =
|
||||
$suggestion_ref->{$to}
|
||||
? eval { dt_from_string( $suggestion_ref->{$to} ) }
|
||||
: undef;
|
||||
my $from = delete $search_params->{"${field}_from"};
|
||||
my $to = delete $search_params->{"${field}_to"};
|
||||
|
||||
my $from_dt = $from && eval { dt_from_string($from) };
|
||||
my $to_dt = $to && eval { dt_from_string($to) };
|
||||
|
||||
if ( $from_dt || $to_dt ) {
|
||||
my $dtf = Koha::Database->new->schema->storage->datetime_parser;
|
||||
if ( $from_dt && $to_dt ) {
|
||||
$search_params->{$field} = { -between => [ $from_dt, $to_dt ] };
|
||||
$search_params->{$field} = { -between => [ $dtf->format_date($from_dt), $dtf->format_date($to_dt) ] };
|
||||
} elsif ( $from_dt ) {
|
||||
$search_params->{$field} = { '>=' => $from_dt };
|
||||
$search_params->{$field} = { '>=' => $dtf->format_date($from_dt) };
|
||||
} elsif ( $to_dt ) {
|
||||
$search_params->{$field} = { '<=' => $to_dt };
|
||||
$search_params->{$field} = { '<=' => $dtf->format_date($to_dt) };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue