+
+ print("</body></html>");
+
+ $lxdebug->leave_sub();
+}
+
+sub download {
+ $lxdebug->enter_sub();
+
+ my $tmp_name = Common->tmpname();
+ my $zip_name = strftime("lx-office-datev-export-%Y%m%d.zip",
+ localtime(time()));
+
+ my $cwd = getcwd();
+ chdir("users") || die("chdir users");
+
+ my @filenames = split(/:/, $form->{"filenames"});
+ map({ s|.*/||; $form->error("Eine der KNE-Exportdateien wurde nicht " .
+ "gefunden. Wurde der Export bereits " .
+ "durchgeführt?") unless (-f $_); }
+ @filenames);
+
+ my $zip = Archive::Zip->new();
+ map({ $zip->addFile($_); } @filenames);
+ $zip->writeToFileNamed($tmp_name);
+ chdir($cwd);
+
+ open(IN, $tmp_name) || die("open $tmp_name");
+ print("Content-Type: application/zip\n");
+ print("Content-Disposition: attachment; filename=\"${zip_name}\"\n\n");
+ while (<IN>) {
+ print($_);
+ }
+ close(IN);
+
+ unlink($tmp_name);
+