X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=bin%2Fmozilla%2Foe.pl;h=0760f4afab0b1e72644168e409467ab79f371286;hb=981b670e29449b7ebffe6c910439a05e6613ec6b;hp=cf6bd40b2f4f5b13190d7f8f5752ee11588332c0;hpb=7933b6bd762c5bac0f0a6bc401ede33c30ece67b;p=kivitendo-erp.git
diff --git a/bin/mozilla/oe.pl b/bin/mozilla/oe.pl
index cf6bd40b2..0760f4afa 100644
--- a/bin/mozilla/oe.pl
+++ b/bin/mozilla/oe.pl
@@ -1,4 +1,4 @@
-#=====================================================================
+# #=====================================================================
# LX-Office ERP
# Copyright (C) 2004
# Based on SQL-Ledger Version 2.1.9
@@ -77,6 +77,22 @@ sub add {
sub edit {
$lxdebug->enter_sub();
+ # editing without stuff to edit? try adding it first
+ if ($form->{rowcount}) {
+ map {$id++ if $form->{"id_$_"}} (1 .. $form->{rowcount});
+ if (!$id) {
+ # reset rowcount
+ undef $form->{rowcount};
+ &add;
+ return;
+ }
+ } else {
+ if (!$form->{id}) {
+ &add;
+ return;
+ }
+ }
+
if ($form->{type} eq 'purchase_order') {
$form->{title} = $locale->text('Edit Purchase Order');
$form->{heading} = $locale->text('Purchase Order');
@@ -121,6 +137,14 @@ sub order_links {
OE->retrieve(\%myconfig, \%$form);
+ # if multiple rowcounts (== collective order) then check if the
+ # there were more than one customer (in that case OE::retrieve removes
+ # the content from the field)
+ if ($form->{rowcount} && $form->{type} eq 'sales_order' && defined $form->{customer} && $form->{customer} eq '') {
+# $main::lxdebug->message(0, "Detected Edit order with concurrent customers");
+ $form->error($locale->text('Collective Orders only work for orders from one customer!'));
+ }
+
$taxincluded = $form->{taxincluded};
$form->{shipto} = 1 if $form->{id};
@@ -197,40 +221,20 @@ sub prepare_order {
$form->{media} = "screen";
$form->{formname} = $form->{type};
- if ($form->{id}) {
-
map { $form->{$_} =~ s/\"/"/g }
qw(ordnumber quonumber shippingpoint shipvia notes intnotes shiptoname shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact);
foreach $ref (@{ $form->{form_details} }) {
- $i++;
- map { $form->{"${_}_$i"} = $ref->{$_} } keys %{$ref};
- $form->{"discount_$i"} =
- $form->format_amount(\%myconfig, $form->{"discount_$i"} * 100);
+ $form->{rowcount} = ++$i;
- ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
- $dec = length $dec;
- $decimalplaces = ($dec > 2) ? $dec : 2;
-
- $form->{"sellprice_$i"} =
- $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
- $decimalplaces);
-
- (my $dec_qty) = ($form->{"qty_$i"} =~ /\.(\d+)/);
- $dec_qty = length $dec_qty;
-
- $form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
-
- map { $form->{"${_}_$i"} =~ s/\"/"/g }
- qw(partnumber description unit);
- $form->{rowcount} = $i;
+ map { $form->{"${_}_$i"} = $ref->{$_} } keys %{$ref};
}
- } elsif ($form->{rowcount}) {
+
for my $i (1 .. $form->{rowcount}) {
$form->{"discount_$i"} =
$form->format_amount(\%myconfig, $form->{"discount_$i"} * 100);
- ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
+ ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
$dec = length $dec;
$decimalplaces = ($dec > 2) ? $dec : 2;
@@ -245,7 +249,6 @@ sub prepare_order {
map { $form->{"${_}_$i"} =~ s/\"/"/g }
qw(partnumber description unit);
}
- }
$lxdebug->leave_sub();
}
@@ -860,7 +863,16 @@ Bearbeiten des $form->{heading}
. $locale->text('Order') . qq|">
|;
}
+ } elsif ($form->{type} =~ /sales_order$/ && $form->{rowcount}) {
+ print qq|
+
Workflow $form->{heading}
+
+
+|;
}
+
if ($form->{menubar}) {
require "$form->{path}/menu.pl";
@@ -1312,6 +1324,11 @@ sub orders {
}
}
+ # only show checkboxes if gotten here via sales_order form.
+ if ($form->{type} =~ /sales_order/) {
+ unshift @column_index, "ids";
+ }
+
if ($form->{l_subtotal} eq 'Y') {
$callback .= "&l_subtotal=Y";
$href .= "&l_subtotal=Y";
@@ -1384,6 +1401,8 @@ sub orders {
$column_header{employee} =
qq|