X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/9bfa364bd40e88b7db83fac1417cbf476dbb434b..828c7d4e23cdaf973f83d5dc545e9be8ef73bedc:/SL/Controller/Order.pm?ds=sidebyside diff --git a/SL/Controller/Order.pm b/SL/Controller/Order.pm index 976f62f0c..0144529d5 100644 --- a/SL/Controller/Order.pm +++ b/SL/Controller/Order.pm @@ -210,6 +210,16 @@ sub action_save_as_new { sub action_print { my ($self) = @_; + my $errors = $self->save(); + + if (scalar @{ $errors }) { + $self->js->flash('error', $_) foreach @{ $errors }; + return $self->js->render(); + } + + $self->js->val('#id', $self->order->id) + ->val('#order_' . $self->nr_key(), $self->order->number); + my $format = $::form->{print_options}->{format}; my $media = $::form->{print_options}->{media}; my $formname = $::form->{print_options}->{formname}; @@ -370,6 +380,17 @@ sub action_show_email_dialog { sub action_send_email { my ($self) = @_; + my $errors = $self->save(); + + if (scalar @{ $errors }) { + $self->js->run('kivi.Order.close_email_dialog'); + $self->js->flash('error', $_) foreach @{ $errors }; + return $self->js->render(); + } + + $self->js->val('#id', $self->order->id) + ->val('#order_' . $self->nr_key(), $self->order->number); + my $email_form = delete $::form->{email_form}; my %field_names = (to => 'email'); @@ -417,6 +438,8 @@ sub action_send_email { $intnotes .= t8('Subject') . ": " . $::form->{subject} . "\n\n"; $intnotes .= t8('Message') . ": " . $::form->{message}; + $self->order->update_attributes(intnotes => $intnotes); + $self->js ->val('#order_intnotes', $intnotes) ->run('kivi.Order.close_email_dialog') @@ -1382,7 +1405,11 @@ sub save { # link records if ($::form->{converted_from_oe_id}) { - SL::DB::Order->new(id => $::form->{converted_from_oe_id})->load->link_to_record($self->order); + my $src = SL::DB::Order->new(id => $::form->{converted_from_oe_id})->load; + # implement OE::_close_quotations_rfqs - this a 1 : 1 connection + # close only if workflow: quotation -> order. TODO test case + $src->update_attributes(closed => 1) if $src->type =~ /_quotation$/; + $src->link_to_record($self->order); if (scalar @{ $::form->{converted_from_orderitems_ids} || [] }) { my $idx = 0; @@ -1565,12 +1592,12 @@ sub setup_edit_action_bar { t8('Export'), ], action => [ - t8('Print'), - call => [ 'kivi.Order.show_print_options' ], + t8('Save and print'), + call => [ 'kivi.Order.show_print_options', $::instance_conf->get_order_warn_duplicate_parts ], ], action => [ - t8('E-mail'), - call => [ 'kivi.Order.email' ], + t8('Save and E-mail'), + call => [ 'kivi.Order.email', $::instance_conf->get_order_warn_duplicate_parts ], ], action => [ t8('Download attachments of all parts'), @@ -1790,11 +1817,6 @@ Possibility to enter more than one item at once. =item * -Save order only on "save" (and "save and delivery order"-workflow). No -hidden save on "print" or "email". - -=item * - Item list in a scrollable area, so that the workflow buttons stay at the bottom.