X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=bin%2Fmozilla%2Foe.pl;h=baa041f364d9288bd5da8c5070f8d38153c946d3;hb=06b678305ce21a082d5c76d43cd9275969931156;hp=6c410c159e3501e4aa3510075568200d6d220af6;hpb=2ceb6719379a2825dfd3f2ea41c94eb7ec06a491;p=kivitendo-erp.git
diff --git a/bin/mozilla/oe.pl b/bin/mozilla/oe.pl
index 6c410c159..baa041f36 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,23 @@ 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');
@@ -115,12 +132,26 @@ sub order_links {
# retrieve order/quotation
$form->{webdav} = $webdav;
-
# set jscalendar
$form->{jscalendar} = $jscalendar;
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};
@@ -193,51 +224,45 @@ sub order_links {
sub prepare_order {
$lxdebug->enter_sub();
- $form->{format} = "html";
+ $form->{format} = "pdf";
$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);
- map { $form->{$_} =~ s/\"/"/g }
- qw(ordnumber quonumber shippingpoint shipvia notes intnotes shiptoname shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact);
+ foreach $ref (@{ $form->{form_details} }) {
+ $form->{rowcount} = ++$i;
- foreach $ref (@{ $form->{form_details} }) {
- $i++;
- map { $form->{"${_}_$i"} = $ref->{$_} } keys %{$ref};
+ map { $form->{"${_}_$i"} = $ref->{$_} } keys %{$ref};
+ }
+ for my $i (1 .. $form->{rowcount}) {
+ if ($form->{id}) {
$form->{"discount_$i"} =
$form->format_amount(\%myconfig, $form->{"discount_$i"} * 100);
-
- ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
- $dec = length $dec;
- $decimalplaces = ($dec > 2) ? $dec : 2;
-
- $form->{"sellprice_$i"} =
- $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
- $decimalplaces);
- $form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$i"});
-
- map { $form->{"${_}_$i"} =~ s/\"/"/g }
- qw(partnumber description unit);
- $form->{rowcount} = $i;
+ } else {
+ $form->{"discount_$i"} =
+ $form->format_amount(\%myconfig, $form->{"discount_$i"});
}
- } 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 = length $dec;
+ $decimalplaces = ($dec > 2) ? $dec : 2;
- ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
- $dec = length $dec;
- $decimalplaces = ($dec > 2) ? $dec : 2;
+ # copy reqdate from deliverydate for invoice -> order conversion
+ $form->{"reqdate_$i"} = $form->{"deliverydate_$i"}
+ unless $form->{"reqdate_$i"};
- $form->{"sellprice_$i"} =
- $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
- $decimalplaces);
- $form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$i"});
+ $form->{"sellprice_$i"} =
+ $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
+ $decimalplaces);
- map { $form->{"${_}_$i"} =~ s/\"/"/g }
- qw(partnumber description unit);
- }
+ (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);
}
$lxdebug->leave_sub();
@@ -818,10 +843,15 @@ Bearbeiten des $form->{heading}
. $locale->text('Save as new') . qq|">
|;
- if ($form->{type} =~ /quotation$/) {
+ if ($form->{type} =~ /sales_quotation$/) {
+ print qq|
+|;
+ }
+ if ($form->{type} =~ /request_quotation$/) {
print qq|
|;
+ . $locale->text('Purchase Order') . qq|">|;
}
print qq|
|;
}
+ } elsif ($form->{type} =~ /sales_order$/ && $form->{rowcount}) {
+ print qq|
+
Workflow $form->{heading}
+
+
+|;
}
if ($form->{menubar}) {
@@ -953,6 +991,7 @@ sub update {
} else {
$form->{"sellprice_$i"} *= (1 - $form->{tradediscount});
+
# if there is an exchange rate adjust sellprice
$form->{"sellprice_$i"} /= $exchangerate;
}
@@ -973,7 +1012,7 @@ sub update {
$form->format_amount(\%myconfig, $form->{"sellprice_$i"},
$decimalplaces);
$form->{"qty_$i"} =
- $form->format_amount(\%myconfig, $form->{"qty_$i"});
+ $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
# get pricegroups for parts
IS->get_pricegroups_for_parts(\%myconfig, \%$form);
@@ -1006,7 +1045,6 @@ sub update {
}
}
-
$lxdebug->leave_sub();
}
@@ -1305,6 +1343,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";
@@ -1377,6 +1420,8 @@ sub orders {
$column_header{employee} =
qq|