return $vendors;
}
+sub mkdir_with_parents {
+ $main::lxdebug->enter_sub();
+
+ my ($full_path) = @_;
+
+ my $path = "";
+
+ $full_path =~ s|/+|/|;
+
+ foreach my $part (split(m|/|, $full_path)) {
+ $path .= "/" if ($path);
+ $path .= $part;
+
+ die("Could not create directory '$path' because a file exists with " .
+ "the same name.\n") if (-f $path);
+
+ if (! -d $path) {
+ mkdir($path, 0770) || die("Could not create the directory '$path'. " .
+ "OS error: $!\n");
+ }
+ }
+
+ $main::lxdebug->leave_sub();
+}
+
+sub webdav_folder {
+ $main::lxdebug->enter_sub();
+
+ my ($form) = @_;
+
+ return $main::lxdebug->leave_sub()
+ unless ($main::webdav && $form->{id});
+
+ my ($path, $number);
+
+ $form->{WEBDAV} = {};
+
+ if ($form->{type} eq "sales_quotation") {
+ ($path, $number) = ("angebote", $form->{quonumber});
+ } elsif ($form->{type} eq "sales_order") {
+ ($path, $number) = ("bestellungen", $form->{ordnumber});
+ } elsif ($form->{type} eq "request_quotation") {
+ ($path, $number) = ("anfragen", $form->{quonumber});
+ } elsif ($form->{type} eq "purchase_order") {
+ ($path, $number) = ("lieferantenbestellungen", $form->{ordnumber});
+ } elsif ($form->{type} eq "credit_note") {
+ ($path, $number) = ("gutschriften", $form->{invnumber});
+ } elsif ($form->{vc} eq "customer") {
+ ($path, $number) = ("rechnungen", $form->{invnumber});
+ } else {
+ ($path, $number) = ("einkaufsrechnungen", $form->{invnumber});
+ }
+
+ return $main::lxdebug->leave_sub() unless ($path && $number);
+
+ $path = "webdav/${path}/${number}";
+
+ if (!-d $path) {
+ mkdir_with_parents($path);
+
+ } else {
+ my $base_path = substr($ENV{'SCRIPT_NAME'}, 1);
+ $base_path =~ s|[^/]+$||;
+
+ foreach my $file (<$path/*>) {
+ my $fname = $file;
+ $fname =~ s|.*/||;
+ $form->{WEBDAV}{$fname} =
+ ($ENV{"HTTPS"} ? "https://" : "http://") .
+ $ENV{'SERVER_NAME'} . "/" . $base_path . $file;
+ }
+ }
+
+ $main::lxdebug->leave_sub();
+}
+
1;
package IR;
use SL::AM;
+use SL::Common;
use SL::DBUtils;
sub post_invoice {
WHERE amount = 0|;
$dbh->do($query) || $form->dberror($query);
- 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();
-}
-
sub post_payment {
$main::lxdebug->enter_sub();
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;
package OE;
use SL::AM;
+use SL::Common;
use SL::DBUtils;
sub transactions {
$form->{ordtotal} = $amount;
- if ($form->{webdav}) {
- &webdav_folder($myconfig, $form);
- }
-
# add shipto
$form->{name} = $form->{ $form->{vc} };
$form->{name} =~ s/--$form->{"$form->{vc}_id"}//;
my $rc = $dbh->commit;
$dbh->disconnect;
+ Common::webdav_folder($form) if ($main::webdav);
+
$main::lxdebug->leave_sub();
return $rc;
$form->get_exchangerate($dbh, $form->{currency}, $form->{transdate},
($form->{vc} eq 'customer') ? "buy" : "sell");
- if ($form->{webdav}) {
- &webdav_folder($myconfig, $form);
- }
+ Common::webdav_folder($form) if ($main::webdav);
# get tax zones
$query = qq|SELECT id, description
return $rc;
}
-sub webdav_folder {
- $main::lxdebug->enter_sub();
-
- my ($myconfig, $form) = @_;
-
-SWITCH: {
- $path = "webdav/angebote/" . $form->{quonumber}, last SWITCH
- if ($form->{type} eq "sales_quotation");
- $path = "webdav/bestellungen/" . $form->{ordnumber}, last SWITCH
- if ($form->{type} eq "sales_order");
- $path = "webdav/anfragen/" . $form->{quonumber}, last SWITCH
- if ($form->{type} eq "request_quotation");
- $path = "webdav/lieferantenbestellungen/" . $form->{ordnumber}, last SWITCH
- if ($form->{type} eq "purchase_order");
- }
-
- 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;
exit;
}
+ Common::webdav_folder($form) if ($webdav);
+
# if ( $form->{print_and_post}
# && $form->{second_run}
# && ($form->{action} eq "display_form")) {
####################################\r
2007-02-?? - Version 2.4.2\r
\r
+ - Bugfixes und Code-Reorganisierung beim "Webdav"-Feature. Beim\r
+ Anlegen von Verzeichnissen werden auch eventuell fehlende\r
+ Elternverzeichnisse angelegt. Bei jedem Neuaufbau der Maske wird\r
+ die Liste der vorhandenen Dateien aktualisiert, nicht nur beim\r
+ Speichern & Laden.\r
- Bei höheren Mahnstufen wurde die Rechnung mehrmals angezeigt\r
- In der Uebersicht der Mahnungen hat ein Klick auf die Rechnungsnummer\r
nicht die Rechnungsmaske geöffnet\r