|
Lines 54-59
runreport.pl [ -h | -m ] [ -v ] reportID [ reportID ... ]
Link Here
|
| 54 |
--format=s selects format. Choice of text, html, csv or tsv |
54 |
--format=s selects format. Choice of text, html, csv or tsv |
| 55 |
|
55 |
|
| 56 |
-e --email whether to use e-mail (implied by --to or --from) |
56 |
-e --email whether to use e-mail (implied by --to or --from) |
|
|
57 |
--send_empty whether to send an email when there are no results from the specified report |
| 57 |
-a --attachment additionally attach the report as a file. cannot be used with html format |
58 |
-a --attachment additionally attach the report as a file. cannot be used with html format |
| 58 |
--username username to pass to the SMTP server for authentication |
59 |
--username username to pass to the SMTP server for authentication |
| 59 |
--password password to pass to the SMTP server for authentication |
60 |
--password password to pass to the SMTP server for authentication |
|
Lines 173-192
binmode STDOUT, ":encoding(UTF-8)";
Link Here
|
| 173 |
# These variables can be set by command line options, |
174 |
# These variables can be set by command line options, |
| 174 |
# initially set to default values. |
175 |
# initially set to default values. |
| 175 |
|
176 |
|
| 176 |
my $help = 0; |
177 |
my $help = 0; |
| 177 |
my $man = 0; |
178 |
my $man = 0; |
| 178 |
my $verbose = 0; |
179 |
my $verbose = 0; |
| 179 |
my $send_email = 0; |
180 |
my $send_email = 0; |
| 180 |
my $attachment = 0; |
181 |
my $send_empty = 0; |
| 181 |
my $format = "text"; |
182 |
my $attachment = 0; |
| 182 |
my $to = ""; |
183 |
my $format = "text"; |
| 183 |
my $from = ""; |
184 |
my $to = ""; |
| 184 |
my $subject = ""; |
185 |
my $from = ""; |
| 185 |
my @params = (); |
186 |
my $subject = ""; |
| 186 |
my $separator = ','; |
187 |
my @params = (); |
| 187 |
my $quote = '"'; |
188 |
my $separator = ','; |
|
|
189 |
my $quote = '"'; |
| 188 |
my $store_results = 0; |
190 |
my $store_results = 0; |
| 189 |
my $csv_header = 0; |
191 |
my $csv_header = 0; |
| 190 |
my $csv_separator = ""; |
192 |
my $csv_separator = ""; |
| 191 |
|
193 |
|
| 192 |
my $username = undef; |
194 |
my $username = undef; |
|
Lines 206-211
GetOptions(
Link Here
|
| 206 |
'subject=s' => \$subject, |
208 |
'subject=s' => \$subject, |
| 207 |
'param=s' => \@params, |
209 |
'param=s' => \@params, |
| 208 |
'email' => \$send_email, |
210 |
'email' => \$send_email, |
|
|
211 |
'send_empty' => \$send_empty, |
| 209 |
'a|attachment' => \$attachment, |
212 |
'a|attachment' => \$attachment, |
| 210 |
'username:s' => \$username, |
213 |
'username:s' => \$username, |
| 211 |
'password:s' => \$password, |
214 |
'password:s' => \$password, |
|
Lines 288-294
foreach my $report_id (@ARGV) {
Link Here
|
| 288 |
} |
291 |
} |
| 289 |
); |
292 |
); |
| 290 |
my $count = scalar($sth->rows); |
293 |
my $count = scalar($sth->rows); |
| 291 |
unless ($count) { |
294 |
unless ($count || $send_empty ) { |
| 292 |
print "NO OUTPUT: 0 results from execute_query\n"; |
295 |
print "NO OUTPUT: 0 results from execute_query\n"; |
| 293 |
next; |
296 |
next; |
| 294 |
} |
297 |
} |
|
Lines 296-302
foreach my $report_id (@ARGV) {
Link Here
|
| 296 |
|
299 |
|
| 297 |
my $message; |
300 |
my $message; |
| 298 |
my @rows_to_store; |
301 |
my @rows_to_store; |
| 299 |
if ($format eq 'html') { |
302 |
if( !$count ){ |
|
|
303 |
$message = "No results were returned for the report\n"; |
| 304 |
} elsif ($format eq 'html') { |
| 300 |
my $cgi = CGI->new(); |
305 |
my $cgi = CGI->new(); |
| 301 |
my @rows; |
306 |
my @rows; |
| 302 |
while (my $line = $sth->fetchrow_arrayref) { |
307 |
while (my $line = $sth->fetchrow_arrayref) { |
|
Lines 327-333
foreach my $report_id (@ARGV) {
Link Here
|
| 327 |
} |
332 |
} |
| 328 |
$message = Encode::decode_utf8($message); |
333 |
$message = Encode::decode_utf8($message); |
| 329 |
} |
334 |
} |
| 330 |
if ( $store_results ) { |
335 |
if ( $store_results && $count ) { |
| 331 |
my $json = to_json( \@rows_to_store ); |
336 |
my $json = to_json( \@rows_to_store ); |
| 332 |
C4::Reports::Guided::store_results( $report_id, $json ); |
337 |
C4::Reports::Guided::store_results( $report_id, $json ); |
| 333 |
} |
338 |
} |
| 334 |
- |
|
|