Lines 188-207
sub SearchSuggestion {
Link Here
|
188 |
} |
188 |
} |
189 |
|
189 |
|
190 |
# filter on date fields |
190 |
# filter on date fields |
|
|
191 |
my $dtf = Koha::Database->new->schema->storage->datetime_parser; |
191 |
foreach my $field (qw( suggesteddate manageddate accepteddate )) { |
192 |
foreach my $field (qw( suggesteddate manageddate accepteddate )) { |
192 |
my $from = $field . "_from"; |
193 |
my $from = $field . "_from"; |
193 |
my $to = $field . "_to"; |
194 |
my $to = $field . "_to"; |
194 |
my $from_dt; |
195 |
my $from_dt; |
195 |
$from_dt = eval { dt_from_string( $suggestion->{$from} ) } if ( $suggestion->{$from} ); |
196 |
$from_dt = eval { dt_from_string( $suggestion->{$from} ) } if ( $suggestion->{$from} ); |
196 |
my $from_sql = '0000-00-00'; |
197 |
my $to_dt; |
197 |
$from_sql = output_pref({ dt => $from_dt, dateformat => 'iso', dateonly => 1 }) |
198 |
$to_dt = eval { dt_from_string( $suggestion->{$to} ) } if ( $suggestion->{$to} ); |
198 |
if ($from_dt); |
199 |
if ( $from_dt ) { |
199 |
$debug && warn "SQL for start date ($field): $from_sql"; |
200 |
push @query, qq{ AND suggestions.$field >= ?}; |
200 |
if ( $suggestion->{$from} || $suggestion->{$to} ) { |
201 |
push @sql_params, $dtf->format_date($from_dt); |
201 |
push @query, qq{ AND suggestions.$field BETWEEN ? AND ? }; |
202 |
} |
202 |
push @sql_params, $from_sql; |
203 |
if ( $to_dt ) { |
203 |
push @sql_params, |
204 |
push @query, qq{ AND suggestions.$field <= ?}; |
204 |
output_pref({ dt => dt_from_string( $suggestion->{$to} ), dateformat => 'iso', dateonly => 1 }) || output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }); |
205 |
push @sql_params, $dtf->format_date($to_dt); |
205 |
} |
206 |
} |
206 |
} |
207 |
} |
207 |
|
208 |
|