X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fio.pl;h=778c718f4ddd207e32c13e54f30ae1100b1b5a3f;hb=d51b3011755b4a7e006f433d9fe5836a22a69638;hp=15695215f8ad6a87f42749d9824c9cbb3f5d9b20;hpb=9c76bacaa1bfbefc80f7d595ca47ec882266dc70;p=kivitendo-erp.git diff --git a/bin/mozilla/io.pl b/bin/mozilla/io.pl index 15695215f..778c718f4 100644 --- a/bin/mozilla/io.pl +++ b/bin/mozilla/io.pl @@ -63,6 +63,7 @@ use SL::DB::Vendor; use SL::Helper::CreatePDF; use SL::Helper::Flash; use SL::Helper::PrintOptions; +use SL::Helper::ShippedQty; require "bin/mozilla/common.pl"; @@ -704,6 +705,8 @@ sub new_item { my $callback = build_std_url("action=return_from_new_item", "previousform=$previousform"); my $i = $::form->{rowcount}; + my $parts_classification_type = $::form->{vc} eq 'customer' ? 'sales' : 'purchases'; + my @HIDDENS; push @HIDDENS, { 'name' => 'callback', 'value' => $callback }; push @HIDDENS, map +{ 'name' => $_, 'value' => $::form->{$_} }, qw(rowcount vc); @@ -711,6 +714,8 @@ sub new_item { push @HIDDENS, { 'name' => "part.$price", 'value' => $::form->{"sellprice_$i"} }; push @HIDDENS, { 'name' => "part.notes", 'value' => $::form->{"longdescription_$i"} }; + push @HIDDENS, { 'name' => "parts_classification_type", 'value' => $parts_classification_type }; + $::form->header; print $::form->parse_html_template("generic/new_item", { HIDDENS => [ sort { $a->{name} cmp $b->{name} } @HIDDENS ] } ); } @@ -1665,37 +1670,14 @@ sub _update_part_information { } sub _update_ship { - $main::lxdebug->enter_sub(); - - my $form = $main::form; - my %myconfig = %main::myconfig; - - if (!$form->{ordnumber} || !$form->{id}) { - map { $form->{"ship_$_"} = 0 } (1..$form->{rowcount}); - $main::lxdebug->leave_sub(); - return; - } - - my $all_units = AM->retrieve_all_units(); - - my %ship = DO->get_shipped_qty('oe_id' => $form->{id}); + return unless $::form->{id}; + my $helper = SL::Helper::ShippedQty->new->calculate($::form->{id}); - foreach my $i (1..$form->{rowcount}) { - next unless ($form->{"id_${i}"}); - - $form->{"ship_$i"} = 0; - - my $ship_entry = $ship{$i}; - - next if (!$ship_entry || ($ship_entry->{qty_ordered} <= 0)); - - my $rowqty = $ship_entry->{qty_ordered} - $ship_entry->{qty_notdelivered}; - $rowqty *= $all_units->{$form->{"unit_$i"}}->{factor} / - $all_units->{$form->{"partunit_$i"}}->{factor} if !$form->{simple_save}; - $form->{"ship_$i"} = $rowqty; + for my $i (1..$::form->{rowcount}) { + if (my $oid = $::form->{"orderitems_id_$i"}) { + $::form->{"ship_$i"} = $helper->shipped_qty->{$oid}; + } } - - $main::lxdebug->leave_sub(); } sub _update_custom_variables { @@ -1987,14 +1969,19 @@ sub show_sales_purchase_email_dialog { my $email = ''; if ($::form->{cp_id}) { $email = SL::DB::Contact->load_cached($::form->{cp_id})->cp_email; - } elsif ($::form->{vc} && $::form->{vc_id}) { + } + + if (!$email && $::form->{vc} && $::form->{vc_id}) { $email = SL::DB::Customer->load_cached($::form->{vc_id})->email if 'customer' eq $::form->{vc}; $email = SL::DB::Vendor ->load_cached($::form->{vc_id})->email if 'vendor' eq $::form->{vc}; } + $email = '' if $::form->{type} eq 'purchase_delivery_order'; + my $email_form = { to => $email, subject => $::form->generate_email_subject, + message => $::form->generate_email_body, attachment_filename => $::form->generate_attachment_filename, };