X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Foe.pl;h=7aa3f2eb28a1da3334ba1ffb9aa6fe15bd872072;hb=bbc9fa5eef6ad9cfadb370029cab8429fb82de88;hp=44bfbd49d68c39a6202ace05b5db9867d8e71f30;hpb=0576299f2aa98125991c4ffcd2f75073ea583d7d;p=kivitendo-erp.git diff --git a/bin/mozilla/oe.pl b/bin/mozilla/oe.pl index 44bfbd49d..7aa3f2eb2 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 @@ -30,6 +30,7 @@ # Order entry module # Quotation module #====================================================================== +use Data::Dumper; use SL::OE; use SL::IR; @@ -77,6 +78,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 +138,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}; @@ -135,9 +168,21 @@ sub order_links { # get customer / vendor if ($form->{type} =~ /(purchase_order|request_quotation|receive_order)/) { IR->get_vendor(\%myconfig, \%$form); + + #quote all_vendor Bug 133 + foreach $ref (@{ $form->{all_vendor} }) { + $ref->{name} = $form->quote($ref->{name}); + } + } if ($form->{type} =~ /(sales|ship)_(order|quotation)/) { IS->get_customer(\%myconfig, \%$form); + + #quote all_vendor Bug 133 + foreach $ref (@{ $form->{all_customer} }) { + $ref->{name} = $form->quote($ref->{name}); + } + } $form->{cp_id} = $cp_id; @@ -192,34 +237,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; + + # copy reqdate from deliverydate for invoice -> order conversion + $form->{"reqdate_$i"} = $form->{"deliverydate_$i"} + unless $form->{"reqdate_$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); - $form->{"sellprice_$i"} = - $form->format_amount(\%myconfig, $form->{"sellprice_$i"}, - $decimalplaces); - $form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$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); - $form->{rowcount} = $i; - } + map { $form->{"${_}_$i"} =~ s/\"/"/g } + qw(partnumber description unit); } $lxdebug->leave_sub(); @@ -241,14 +297,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 +326,9 @@ sub form_header { + . $locale->text('Open') . qq| + . $locale->text('Closed') . qq|
| - . $locale->text('Open') - . qq| | - . $locale->text('Closed') - . qq|
@@ -291,6 +343,9 @@ sub form_header { s/option>\Q$form->{$item}\E/option selected>$form->{$item}/; } + #quote select[customer|vendor] Bug 133 + $form->{"select$form->{vc}"} = $form->quote($form->{"select$form->{vc}"}); + #build contacts if ($form->{all_contacts}) { @@ -345,8 +400,7 @@ sub form_header { | . $locale->text('Terms: Net') . qq| {terms}> | - . $locale->text('days') - . qq| + . $locale->text('days') . qq| |; @@ -371,14 +425,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 +471,7 @@ sub form_header { $ordnumber = qq| | - . $locale->text('Quotation Number') - . qq| + . $locale->text('Quotation Number') . qq| @@ -471,6 +522,7 @@ sub form_header { if ($form->{type} eq 'sales_order') { if ($form->{selectemployee}) { $employee = qq| + {customer_klass}> | . $locale->text('Salesperson') . qq| @@ -481,6 +533,7 @@ sub form_header { } } else { $employee = qq| + {customer_klass}> | . $locale->text('Employee') . qq| @@ -537,8 +590,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 +685,7 @@ sub form_footer { if ($form->{taxaccounts}) { $taxincluded = qq| {taxincluded}> | - . $locale->text('Tax Included') - . qq|

+ . $locale->text('Tax Included') . qq|

|; } @@ -808,10 +859,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 +952,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 +1006,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 +1028,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 +1060,7 @@ sub update { } } } + $lxdebug->leave_sub(); } @@ -1046,7 +1121,8 @@ sub search { $form->{warehouse} = qq|$form->{warehouse}--$form->{warehouse_id}|; map { - $form->{selectwarehouse} .= "