use C4::Debug;
use C4::Branch; # XXX subfield_is_koha_internal_p
use C4::Koha qw/IsAuthorisedValueCategory GetFrameworksLoop/;
+use C4::Context;
+use C4::Log;
+use Koha::DateUtils qw/dt_from_string output_pref/;
=head1 NAME
$session->param('report_filter', $filter) if $session;
$template->param( 'filter_set' => 1 );
}
-elsif ($session) {
+elsif ($session and not $input->param('clear_filters')) {
$filter = $session->param('report_filter');
}
'reportname' => $reportname,
'id' => $id,
);
+ logaction( "REPORTS", "MODIFY", $id, "$reportname | $sql" ) if C4::Context->preference("ReportsLog");
}
if ( $usecache ) {
$template->param(
cache_expiry => $cache_expiry,
public => $public,
} );
+ logaction( "REPORTS", "ADD", $id, "$name | $sql" ) if C4::Context->preference("ReportsLog");
$template->param(
'save_successful' => 1,
'reportname' => $name,
}
$labelid = $text;
$labelid =~ s/\W//g;
- $input =CGI::scrolling_list( # FIXME: factor out scrolling_list
- -name => "sql_params",
- -id => "sql_params_".$labelid,
- -values => \@authorised_values,
-# -default => $value,
- -labels => \%authorised_lib,
- -override => 1,
- -size => 1,
- -multiple => 0,
- -tabindex => 1,
- );
+ $input = {
+ name => "sql_params",
+ id => "sql_params_".$labelid,
+ values => \@authorised_values,
+ labels => \%authorised_lib,
+ };
}
push @tmpl_parameters, {'entry' => $text, 'input' => $input, 'labelid' => $labelid };
my @split = split /<<|>>/,$sql;
my @tmpl_parameters;
for(my $i=0;$i<$#split/2;$i++) {
- my $quoted = C4::Context->dbh->quote($sql_params[$i]);
+ my $quoted = $sql_params[$i];
# if there are special regexp chars, we must \ them
$split[$i*2+1] =~ s/(\||\?|\.|\*|\(|\)|\%)/\\$1/g;
+ if ($split[$i*2+1] =~ /\|\s*date\s*$/) {
+ $quoted = output_pref({ dt => dt_from_string($quoted), dateformat => 'iso', dateonly => 1 }) if $quoted;
+ }
+ $quoted = C4::Context->dbh->quote($quoted);
$sql =~ s/<<$split[$i*2+1]>>/$quoted/;
}
my ($sth, $errors) = execute_query($sql, $offset, $limit);