Lines 60-66
calculated but not applied.
Link Here
|
60 |
|
60 |
|
61 |
This script has the following parameters : |
61 |
This script has the following parameters : |
62 |
-h --help: this message |
62 |
-h --help: this message |
63 |
-l --log: log the output to a file |
63 |
-l --log: log the output to a file (optional if the -o parameter is given) |
64 |
-o --out: ouput directory for logs (defaults to env or /tmp if !exist) |
64 |
-o --out: ouput directory for logs (defaults to env or /tmp if !exist) |
65 |
-v --verbose |
65 |
-v --verbose |
66 |
|
66 |
|
Lines 82-91
my $delim = "\t"; # ? C4::Context->preference('delimiter') || "\t";
Link Here
|
82 |
|
82 |
|
83 |
my %is_holiday; |
83 |
my %is_holiday; |
84 |
my $today = DateTime->now( time_zone => C4::Context->tz() ); |
84 |
my $today = DateTime->now( time_zone => C4::Context->tz() ); |
85 |
my $filename = get_filename($output_dir); |
85 |
my $filename; |
|
|
86 |
if ($log or $output_dir) { |
87 |
$filename = get_filename($output_dir); |
88 |
} |
86 |
|
89 |
|
87 |
my $fh; |
90 |
my $fh; |
88 |
if ($log) { |
91 |
if ($filename) { |
89 |
open $fh, '>>', $filename or croak "Cannot write file $filename: $!"; |
92 |
open $fh, '>>', $filename or croak "Cannot write file $filename: $!"; |
90 |
print {$fh} join $delim, ( @borrower_fields, @item_fields, @other_fields ); |
93 |
print {$fh} join $delim, ( @borrower_fields, @item_fields, @other_fields ); |
91 |
print {$fh} "\n"; |
94 |
print {$fh} "\n"; |
Lines 131-137
for my $overdue ( @{$overdues} ) {
Link Here
|
131 |
); |
134 |
); |
132 |
} |
135 |
} |
133 |
} |
136 |
} |
134 |
if ($log) { |
137 |
if ($filename) { |
135 |
my @cells; |
138 |
my @cells; |
136 |
push @cells, |
139 |
push @cells, |
137 |
map { defined $borrower->{$_} ? $borrower->{$_} : q{} } |
140 |
map { defined $borrower->{$_} ? $borrower->{$_} : q{} } |
Lines 141-147
for my $overdue ( @{$overdues} ) {
Link Here
|
141 |
say {$fh} join $delim, @cells; |
144 |
say {$fh} join $delim, @cells; |
142 |
} |
145 |
} |
143 |
} |
146 |
} |
144 |
if ($log){ |
147 |
if ($filename){ |
145 |
close $fh; |
148 |
close $fh; |
146 |
} |
149 |
} |
147 |
|
150 |
|
Lines 150-156
if ($verbose) {
Link Here
|
150 |
print <<"EOM"; |
153 |
print <<"EOM"; |
151 |
Fines assessment -- $today |
154 |
Fines assessment -- $today |
152 |
EOM |
155 |
EOM |
153 |
if ($log) { |
156 |
if ($filename) { |
154 |
say "Saved to $filename"; |
157 |
say "Saved to $filename"; |
155 |
} |
158 |
} |
156 |
print <<"EOM"; |
159 |
print <<"EOM"; |
157 |
- |
|
|