Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 8e206587

Von Moritz Bunkus vor mehr als 17 Jahren hinzugefügt

  • ID 8e2065873b0e00dde437383bb22c57be508e331f
  • Vorgänger 15682dc4
  • Nachfolger 94fe7579

Bugfixes und Code-Reorganisierung beim "Webdav"-Feature. Beim Anlegen von Verzeichnissen werden auch eventuell fehlende Elternverzeichnisse angelegt. Bei jedem Neuaufbau der Maske wird die Liste der vorhandenen Dateien aktualisiert, nicht nur beim Speichern & Laden.

Unterschiede anzeigen:

SL/Common.pm
187 187
  return $vendors;
188 188
}
189 189

  
190
sub mkdir_with_parents {
191
  $main::lxdebug->enter_sub();
192

  
193
  my ($full_path) = @_;
194

  
195
  my $path = "";
196

  
197
  $full_path =~ s|/+|/|;
198

  
199
  foreach my $part (split(m|/|, $full_path)) {
200
    $path .= "/" if ($path);
201
    $path .= $part;
202

  
203
    die("Could not create directory '$path' because a file exists with " .
204
        "the same name.\n") if (-f $path);
205

  
206
    if (! -d $path) {
207
      mkdir($path, 0770) || die("Could not create the directory '$path'. " .
208
                                "OS error: $!\n");
209
    }
210
  }
211

  
212
  $main::lxdebug->leave_sub();
213
}
214

  
215
sub webdav_folder {
216
  $main::lxdebug->enter_sub();
217

  
218
  my ($form) = @_;
219

  
220
  return $main::lxdebug->leave_sub()
221
    unless ($main::webdav && $form->{id});
222

  
223
  my ($path, $number);
224

  
225
  $form->{WEBDAV} = {};
226

  
227
  if ($form->{type} eq "sales_quotation") {
228
    ($path, $number) = ("angebote", $form->{quonumber});
229
  } elsif ($form->{type} eq "sales_order") {
230
    ($path, $number) = ("bestellungen", $form->{ordnumber});
231
  } elsif ($form->{type} eq "request_quotation") {
232
    ($path, $number) = ("anfragen", $form->{quonumber});
233
  } elsif ($form->{type} eq "purchase_order") {
234
    ($path, $number) = ("lieferantenbestellungen", $form->{ordnumber});
235
  } elsif ($form->{type} eq "credit_note") {
236
    ($path, $number) = ("gutschriften", $form->{invnumber});
237
  } elsif ($form->{vc} eq "customer") {
238
    ($path, $number) = ("rechnungen", $form->{invnumber});
239
  } else {
240
    ($path, $number) = ("einkaufsrechnungen", $form->{invnumber});
241
  }
242

  
243
  return $main::lxdebug->leave_sub() unless ($path && $number);
244

  
245
  $path = "webdav/${path}/${number}";
246

  
247
  if (!-d $path) {
248
    mkdir_with_parents($path);
249

  
250
  } else {
251
    my $base_path = substr($ENV{'SCRIPT_NAME'}, 1);
252
    $base_path =~ s|[^/]+$||;
253

  
254
    foreach my $file (<$path/*>) {
255
      my $fname = $file;
256
      $fname =~ s|.*/||;
257
      $form->{WEBDAV}{$fname} =
258
        ($ENV{"HTTPS"} ? "https://" : "http://") .
259
        $ENV{'SERVER_NAME'} . "/" . $base_path . $file;
260
    }
261
  }
262

  
263
  $main::lxdebug->leave_sub();
264
}
265

  
190 266
1;
SL/IR.pm
35 35
package IR;
36 36

  
37 37
use SL::AM;
38
use SL::Common;
38 39
use SL::DBUtils;
39 40

  
40 41
sub post_invoice {
......
665 666
              WHERE amount = 0|;
666 667
  $dbh->do($query) || $form->dberror($query);
667 668

  
668
  if ($form->{webdav}) {
669
    &webdav_folder($myconfig, $form);
670
  }
669
  Common::webdav_folder($form) if ($main::webdav);
671 670

  
672 671
  my $rc = $dbh->commit;
673 672
  $dbh->disconnect;
......
963 962
    }
964 963
    $sth->finish;
965 964

  
966
    if ($form->{webdav}) {
967
      &webdav_folder($myconfig, $form);
968
    }
969

  
965
    Common::webdav_folder($form) if ($main::webdav);
970 966
  }
971 967

  
972 968
  my $rc = $dbh->commit;
......
1288 1284
  $main::lxdebug->leave_sub();
1289 1285
}
1290 1286

  
1291
sub webdav_folder {
1292
  $main::lxdebug->enter_sub();
1293

  
1294
  my ($myconfig, $form) = @_;
1295

  
1296
SWITCH: {
1297
    $path = "webdav/rechnungen/" . $form->{invnumber}, last SWITCH
1298
      if ($form->{vc} eq "customer");
1299
    $path = "webdav/einkaufsrechnungen/" . $form->{invnumber}, last SWITCH
1300
      if ($form->{vc} eq "vendor");
1301
  }
1302

  
1303
  if (!-d $path) {
1304
    mkdir($path, 0770) or die "can't make directory $!\n";
1305
  } else {
1306
    if ($form->{id}) {
1307
      @files = <$path/*>;
1308
      foreach $file (@files) {
1309

  
1310
        $file =~ /\/([^\/]*)$/;
1311
        $fname = $1;
1312
        $ENV{'SCRIPT_NAME'} =~ /\/([^\/]*)\//;
1313
        $lxerp = $1;
1314
        $link  = "http://" . $ENV{'SERVER_NAME'} . "/" . $lxerp . "/" . $file;
1315
        $form->{WEBDAV}{$fname} = $link;
1316
      }
1317
    }
1318
  }
1319

  
1320
  $main::lxdebug->leave_sub();
1321
}
1322

  
1323 1287
sub post_payment {
1324 1288
  $main::lxdebug->enter_sub();
1325 1289

  
SL/IS.pm
36 36

  
37 37
use Data::Dumper;
38 38
use SL::AM;
39
use SL::Common;
39 40
use SL::DBUtils;
40 41

  
41 42
sub invoice_details {
......
1038 1039
  # save printed, emailed and queued
1039 1040
  $form->save_status($dbh);
1040 1041

  
1041
  if ($form->{webdav}) {
1042
    &webdav_folder($myconfig, $form);
1043
  }
1042
  Common::webdav_folder($form) if ($main::webdav);
1044 1043

  
1045 1044
  my $rc = $dbh->commit;
1046 1045
  $dbh->disconnect;
......
1658 1657
    }
1659 1658
    $sth->finish;
1660 1659

  
1661
    if ($form->{webdav}) {
1662
      &webdav_folder($myconfig, $form);
1663
    }
1660
    Common::webdav_folder($form) if ($main::webdav);
1664 1661
  }
1665 1662

  
1666 1663
  my $rc = $dbh->commit;
......
2185 2182
  $main::lxdebug->leave_sub();
2186 2183
}
2187 2184

  
2188
sub webdav_folder {
2189
  $main::lxdebug->enter_sub();
2190

  
2191
  my ($myconfig, $form) = @_;
2192

  
2193
SWITCH: {
2194
    $path = "webdav/rechnungen/" . $form->{invnumber}, last SWITCH
2195
      if ($form->{vc} eq "customer");
2196
    $path = "webdav/einkaufsrechnungen/" . $form->{invnumber}, last SWITCH
2197
      if ($form->{vc} eq "vendor");
2198
  }
2199

  
2200
  if (!-d $path) {
2201
    mkdir($path, 0770) or die "can't make directory $!\n";
2202
  } else {
2203
    if ($form->{id}) {
2204
      @files = <$path/*>;
2205
      foreach $file (@files) {
2206
        $file =~ /\/([^\/]*)$/;
2207
        $fname = $1;
2208
        $ENV{'SCRIPT_NAME'} =~ /\/([^\/]*)\//;
2209
        $lxerp = $1;
2210
        $link  = "http://" . $ENV{'SERVER_NAME'} . "/" . $lxerp . "/" . $file;
2211
        $form->{WEBDAV}{$fname} = $link;
2212
      }
2213
    }
2214
  }
2215

  
2216
  $main::lxdebug->leave_sub();
2217
}
2218

  
2219 2185
1;
2220 2186

  
SL/OE.pm
35 35
package OE;
36 36

  
37 37
use SL::AM;
38
use SL::Common;
38 39
use SL::DBUtils;
39 40

  
40 41
sub transactions {
......
481 482

  
482 483
  $form->{ordtotal} = $amount;
483 484

  
484
  if ($form->{webdav}) {
485
    &webdav_folder($myconfig, $form);
486
  }
487

  
488 485
  # add shipto
489 486
  $form->{name} = $form->{ $form->{vc} };
490 487
  $form->{name} =~ s/--$form->{"$form->{vc}_id"}//;
......
517 514
  my $rc = $dbh->commit;
518 515
  $dbh->disconnect;
519 516

  
517
  Common::webdav_folder($form) if ($main::webdav);
518

  
520 519
  $main::lxdebug->leave_sub();
521 520

  
522 521
  return $rc;
......
916 915
    $form->get_exchangerate($dbh, $form->{currency}, $form->{transdate},
917 916
                            ($form->{vc} eq 'customer') ? "buy" : "sell");
918 917

  
919
  if ($form->{webdav}) {
920
    &webdav_folder($myconfig, $form);
921
  }
918
  Common::webdav_folder($form) if ($main::webdav);
922 919

  
923 920
  # get tax zones
924 921
  $query = qq|SELECT id, description
......
1641 1638
  return $rc;
1642 1639
}
1643 1640

  
1644
sub webdav_folder {
1645
  $main::lxdebug->enter_sub();
1646

  
1647
  my ($myconfig, $form) = @_;
1648

  
1649
SWITCH: {
1650
    $path = "webdav/angebote/" . $form->{quonumber}, last SWITCH
1651
      if ($form->{type} eq "sales_quotation");
1652
    $path = "webdav/bestellungen/" . $form->{ordnumber}, last SWITCH
1653
      if ($form->{type} eq "sales_order");
1654
    $path = "webdav/anfragen/" . $form->{quonumber}, last SWITCH
1655
      if ($form->{type} eq "request_quotation");
1656
    $path = "webdav/lieferantenbestellungen/" . $form->{ordnumber}, last SWITCH
1657
      if ($form->{type} eq "purchase_order");
1658
  }
1659

  
1660
  if (!-d $path) {
1661
    mkdir($path, 0770) or die "can't make directory $!\n";
1662
  } else {
1663
    if ($form->{id}) {
1664
      @files = <$path/*>;
1665
      foreach $file (@files) {
1666
        $file =~ /\/([^\/]*)$/;
1667
        $fname = $1;
1668
        $ENV{'SCRIPT_NAME'} =~ /\/([^\/]*)\//;
1669
        $lxerp = $1;
1670
        $link  = "http://" . $ENV{'SERVER_NAME'} . "/" . $lxerp . "/" . $file;
1671
        $form->{WEBDAV}{$fname} = $link;
1672
      }
1673
    }
1674
  }
1675

  
1676
  $main::lxdebug->leave_sub();
1677
}
1678 1641
1;
1679 1642

  
bin/mozilla/io.pl
889 889
    exit;
890 890
  }
891 891

  
892
  Common::webdav_folder($form) if ($webdav);
893

  
892 894
  #   if (   $form->{print_and_post}
893 895
  #       && $form->{second_run}
894 896
  #       && ($form->{action} eq "display_form")) {
doc/changelog
3 3
####################################
4 4
2007-02-?? - Version 2.4.2
5 5

  
6
  - Bugfixes und Code-Reorganisierung beim "Webdav"-Feature. Beim
7
    Anlegen von Verzeichnissen werden auch eventuell fehlende
8
    Elternverzeichnisse angelegt. Bei jedem Neuaufbau der Maske wird
9
    die Liste der vorhandenen Dateien aktualisiert, nicht nur beim
10
    Speichern & Laden.
6 11
  - Bei h?heren Mahnstufen wurde die Rechnung mehrmals angezeigt
7 12
  - In der Uebersicht der Mahnungen hat ein Klick auf die Rechnungsnummer
8 13
    nicht die Rechnungsmaske ge?ffnet

Auch abrufbar als: Unified diff