X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=bin%2Fmozilla%2Foe.pl;h=baa041f364d9288bd5da8c5070f8d38153c946d3;hb=06b678305ce21a082d5c76d43cd9275969931156;hp=44bfbd49d68c39a6202ace05b5db9867d8e71f30;hpb=ee072e4f077213bf6f8792ca8f0a1afebbb6282f;p=kivitendo-erp.git
diff --git a/bin/mozilla/oe.pl b/bin/mozilla/oe.pl
index 44bfbd49d..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');
@@ -120,6 +137,21 @@ 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};
@@ -192,34 +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);
+ } else {
+ $form->{"discount_$i"} =
+ $form->format_amount(\%myconfig, $form->{"discount_$i"});
+ }
+ ($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);
- $form->{rowcount} = $i;
- }
+ (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();
@@ -241,14 +284,12 @@ sub form_header {
$button1 = qq|
{transdate}> |
text('button')
- . qq|> |
+ . $locale->text('button') . qq|>
|;
$button2 = qq|
{reqdate}> |
text('button')
- . qq|> |
+ . $locale->text('button') . qq|>
|;
#write Trigger
@@ -272,11 +313,9 @@ sub form_header {
@@ -345,8 +384,7 @@ sub form_header {
| . $locale->text('Terms: Net') . qq| |
{terms}> |
- . $locale->text('days')
- . qq| |
+ . $locale->text('days') . qq|
|;
@@ -371,14 +409,12 @@ sub form_header {
|
- . $locale->text('Quotation Number')
- . qq| |
+ . $locale->text('Quotation Number') . qq|
|
|
- . $locale->text('Customer Order Number')
- . qq| |
+ . $locale->text('Customer Order Number') . qq|
|
@@ -419,8 +455,7 @@ sub form_header {
$ordnumber = qq|
|
- . $locale->text('Quotation Number')
- . qq| |
+ . $locale->text('Quotation Number') . qq|
|
@@ -471,6 +506,7 @@ sub form_header {
if ($form->{type} eq 'sales_order') {
if ($form->{selectemployee}) {
$employee = qq|
+ {customer_klass}>
| . $locale->text('Salesperson') . qq| |
|
@@ -481,6 +517,7 @@ sub form_header {
}
} else {
$employee = qq|
+ {customer_klass}>
| . $locale->text('Employee') . qq| |
|
@@ -537,8 +574,7 @@ sub form_header {
{vc}_id value=$form->{"$form->{vc}_id"}>
{vc}"}">
|
- . $locale->text('Contact Person')
- . qq| |
+ . $locale->text('Contact Person') . qq|
$contact |
$creditremaining
@@ -633,8 +669,7 @@ sub form_footer {
if ($form->{taxaccounts}) {
$taxincluded = qq|
{taxincluded}> |
- . $locale->text('Tax Included')
- . qq|
+ . $locale->text('Tax Included') . qq|
|;
}
@@ -808,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}) {
@@ -888,7 +936,9 @@ sub update {
\%myconfig, $form->{currency}, $form->{transdate}, $buysell
)));
- my $i = $form->{rowcount};
+ # for pricegroups
+ $i = $form->{rowcount};
+
$exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
if ( ($form->{"partnumber_$i"} eq "")
@@ -940,6 +990,8 @@ sub update {
$form->{"sellprice_$i"} = $sellprice;
} else {
+ $form->{"sellprice_$i"} *= (1 - $form->{tradediscount});
+
# if there is an exchange rate adjust sellprice
$form->{"sellprice_$i"} /= $exchangerate;
}
@@ -960,7 +1012,13 @@ 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);
+
+ # build up html code for prices_$i
+ &set_pricegroup($i);
}
&display_form;
@@ -986,6 +1044,7 @@ sub update {
}
}
}
+
$lxdebug->leave_sub();
}
@@ -1046,7 +1105,8 @@ sub search {
$form->{warehouse} = qq|$form->{warehouse}--$form->{warehouse_id}|;
map {
- $form->{selectwarehouse} .= "