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