Bug 16219: Add 'params' parameter to runreport.pl
To test: 1 - Apply patch 2 - Write a report that takes no variables 3 - Run this using runreport.pl perl misc/cronjobs/runreport.pl 1 4 - Confirm results as expected 5 - Write a report that takes one or more variables 6 - Run using runreport.pl, but pass no params 7 - You should get a SQL error 8 - Now run passing the correct number of params perl misc/cronjobs/runreport.pl --param first --param=2nd 2 9 - Verify results as expected 10 - call runreport with no parameters perl misc/cronjobs/runreport.pl 11 - Verify documentation is correct and helpful Signed-off-by: Claire Gravely <claire.gravely@bsz-bw.de> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
parent
06e28c3ac5
commit
72197a9574
1 changed files with 12 additions and 1 deletions
|
@ -67,6 +67,7 @@ runreport.pl [ -h | -m ] [ -v ] reportID [ reportID ... ]
|
||||||
--to=s e-mail address to send report to
|
--to=s e-mail address to send report to
|
||||||
--from=s e-mail address to send report from
|
--from=s e-mail address to send report from
|
||||||
--subject=s subject for the e-mail
|
--subject=s subject for the e-mail
|
||||||
|
--params=s parameters for the report
|
||||||
--store-results store the result of the report
|
--store-results store the result of the report
|
||||||
--csv-header add column names as first line of csv output
|
--csv-header add column names as first line of csv output
|
||||||
|
|
||||||
|
@ -122,6 +123,10 @@ E-mail address to send report from. Defaults to KohaAdminEmailAddress.
|
||||||
|
|
||||||
Subject for the e-mail message. Defaults to "Koha Saved Report"
|
Subject for the e-mail message. Defaults to "Koha Saved Report"
|
||||||
|
|
||||||
|
=item B<--params>
|
||||||
|
|
||||||
|
Repeatable, should provide one param per param requested for the report
|
||||||
|
|
||||||
=item B<--store-results>
|
=item B<--store-results>
|
||||||
|
|
||||||
Store the result of the report into the saved_reports DB table.
|
Store the result of the report into the saved_reports DB table.
|
||||||
|
@ -175,6 +180,7 @@ my $format = "text";
|
||||||
my $to = "";
|
my $to = "";
|
||||||
my $from = "";
|
my $from = "";
|
||||||
my $subject = "";
|
my $subject = "";
|
||||||
|
my @params = ();
|
||||||
my $separator = ',';
|
my $separator = ',';
|
||||||
my $quote = '"';
|
my $quote = '"';
|
||||||
my $store_results = 0;
|
my $store_results = 0;
|
||||||
|
@ -192,6 +198,7 @@ GetOptions(
|
||||||
'to=s' => \$to,
|
'to=s' => \$to,
|
||||||
'from=s' => \$from,
|
'from=s' => \$from,
|
||||||
'subject=s' => \$subject,
|
'subject=s' => \$subject,
|
||||||
|
'param=s' => \@params,
|
||||||
'email' => \$email,
|
'email' => \$email,
|
||||||
'a|attachment' => \$attachment,
|
'a|attachment' => \$attachment,
|
||||||
'username:s' => \$username,
|
'username:s' => \$username,
|
||||||
|
@ -254,7 +261,11 @@ foreach my $report_id (@ARGV) {
|
||||||
$subject = 'Koha Saved Report';
|
$subject = 'Koha Saved Report';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
my ($sth) = execute_query( $sql, undef, undef, undef, $report_id );
|
|
||||||
|
# convert SQL parameters to placeholders
|
||||||
|
$sql =~ s/(<<.*?>>)/\?/g;
|
||||||
|
|
||||||
|
my ($sth) = execute_query( $sql, undef, undef, \@params, $report_id );
|
||||||
my $count = scalar($sth->rows);
|
my $count = scalar($sth->rows);
|
||||||
unless ($count) {
|
unless ($count) {
|
||||||
print "NO OUTPUT: 0 results from execute_query\n";
|
print "NO OUTPUT: 0 results from execute_query\n";
|
||||||
|
|
Loading…
Reference in a new issue