|
Lines 115-126
if ( ($op eq 'Upload') && $uploadfile ) { # Case is important in these ope
Link Here
|
| 115 |
} |
115 |
} |
| 116 |
my $results; |
116 |
my $results; |
| 117 |
foreach my $dir ( @directories ) { |
117 |
foreach my $dir ( @directories ) { |
| 118 |
$results = handle_dir( $dir, $filesuffix ); |
118 |
$results = handle_dir( $dir, $filesuffix, $template ); |
| 119 |
$handled++ if $results == 1; |
119 |
$handled++ if $results == 1; |
| 120 |
} |
120 |
} |
| 121 |
$total = scalar @directories; |
121 |
$total = scalar @directories; |
| 122 |
} else { #if ($filetype eq 'zip' ) |
122 |
} else { #if ($filetype eq 'zip' ) |
| 123 |
$results = handle_dir( $dirname, $filesuffix ); |
123 |
$results = handle_dir( $dirname, $filesuffix, $template, $cardnumber, $tempfile ); |
| 124 |
$handled = 1; |
124 |
$handled = 1; |
| 125 |
$total = 1; |
125 |
$total = 1; |
| 126 |
} |
126 |
} |
|
Lines 157-167
if ( $borrowernumber && !$errors && !$template->param('ERRORS') ) {
Link Here
|
| 157 |
} |
157 |
} |
| 158 |
|
158 |
|
| 159 |
sub handle_dir { |
159 |
sub handle_dir { |
| 160 |
my ( $dir, $suffix ) = @_; |
160 |
my ( $dir, $suffix, $template, $cardnumber, $source ) = @_; |
| 161 |
my $source; |
|
|
| 162 |
$debug and warn "Entering sub handle_dir; passed \$dir=$dir, \$suffix=$suffix"; |
161 |
$debug and warn "Entering sub handle_dir; passed \$dir=$dir, \$suffix=$suffix"; |
| 163 |
if ($suffix =~ m/zip/i) { # If we were sent a zip file, process any included data/idlink.txt files |
162 |
if ($suffix =~ m/zip/i) { # If we were sent a zip file, process any included data/idlink.txt files |
| 164 |
my ( $file, $filename, $cardnumber ); |
163 |
my ( $file, $filename ); |
|
|
164 |
undef $cardnumber; |
| 165 |
$debug and warn "Passed a zip file."; |
165 |
$debug and warn "Passed a zip file."; |
| 166 |
opendir my $dirhandle, $dir; |
166 |
opendir my $dirhandle, $dir; |
| 167 |
while ( my $filename = readdir $dirhandle ) { |
167 |
while ( my $filename = readdir $dirhandle ) { |
|
Lines 189-208
sub handle_dir {
Link Here
|
| 189 |
$filename =~ s/[\"\r\n\s]//g; |
189 |
$filename =~ s/[\"\r\n\s]//g; |
| 190 |
$debug and warn "Cardnumber: $cardnumber Filename: $filename"; |
190 |
$debug and warn "Cardnumber: $cardnumber Filename: $filename"; |
| 191 |
$source = "$dir/$filename"; |
191 |
$source = "$dir/$filename"; |
| 192 |
%counts = handle_file($cardnumber, $source, %counts); |
192 |
%counts = handle_file($cardnumber, $source, $template, %counts); |
| 193 |
} |
193 |
} |
| 194 |
close FILE; |
194 |
close FILE; |
| 195 |
closedir ($dirhandle); |
195 |
closedir ($dirhandle); |
| 196 |
} else { |
196 |
} else { |
| 197 |
$source = $tempfile; |
197 |
%counts = handle_file($cardnumber, $source, $template, %counts); |
| 198 |
%counts = handle_file($cardnumber, $source, %counts); |
|
|
| 199 |
} |
198 |
} |
| 200 |
push @counts, \%counts; |
199 |
push @counts, \%counts; |
| 201 |
return 1; |
200 |
return 1; |
| 202 |
} |
201 |
} |
| 203 |
|
202 |
|
| 204 |
sub handle_file { |
203 |
sub handle_file { |
| 205 |
my ($cardnumber, $source, %count) = @_; |
204 |
my ($cardnumber, $source, $template, %count) = @_; |
| 206 |
$debug and warn "Entering sub handle_file; passed \$cardnumber=$cardnumber, \$source=$source"; |
205 |
$debug and warn "Entering sub handle_file; passed \$cardnumber=$cardnumber, \$source=$source"; |
| 207 |
$count{filenames} = () if !$count{filenames}; |
206 |
$count{filenames} = () if !$count{filenames}; |
| 208 |
$count{source} = $source if !$count{source}; |
207 |
$count{source} = $source if !$count{source}; |
| 209 |
- |
|
|