use Data::Dumper;
use SL::AM;
+use SL::Common;
use SL::DBUtils;
sub invoice_details {
# save printed, emailed and queued
$form->save_status($dbh);
- if ($form->{webdav}) {
- &webdav_folder($myconfig, $form);
- }
+ Common::webdav_folder($form) if ($main::webdav);
my $rc = $dbh->commit;
$dbh->disconnect;
}
$sth->finish;
- if ($form->{webdav}) {
- &webdav_folder($myconfig, $form);
- }
+ Common::webdav_folder($form) if ($main::webdav);
}
my $rc = $dbh->commit;
$main::lxdebug->leave_sub();
}
-sub webdav_folder {
- $main::lxdebug->enter_sub();
-
- my ($myconfig, $form) = @_;
-
-SWITCH: {
- $path = "webdav/rechnungen/" . $form->{invnumber}, last SWITCH
- if ($form->{vc} eq "customer");
- $path = "webdav/einkaufsrechnungen/" . $form->{invnumber}, last SWITCH
- if ($form->{vc} eq "vendor");
- }
-
- if (!-d $path) {
- mkdir($path, 0770) or die "can't make directory $!\n";
- } else {
- if ($form->{id}) {
- @files = <$path/*>;
- foreach $file (@files) {
- $file =~ /\/([^\/]*)$/;
- $fname = $1;
- $ENV{'SCRIPT_NAME'} =~ /\/([^\/]*)\//;
- $lxerp = $1;
- $link = "http://" . $ENV{'SERVER_NAME'} . "/" . $lxerp . "/" . $file;
- $form->{WEBDAV}{$fname} = $link;
- }
- }
- }
-
- $main::lxdebug->leave_sub();
-}
-
1;