Revision 3904292e
Von Bernd Bleßmann vor mehr als 2 Jahren hinzugefügt
SL/Controller/Order.pm | ||
---|---|---|
515 | 515 |
} |
516 | 516 |
|
517 | 517 |
# send email |
518 |
# |
|
519 |
# Todo: handling error messages: flash is not displayed in dialog, but in the main form |
|
520 | 518 |
sub action_send_email { |
521 | 519 |
my ($self) = @_; |
522 | 520 |
|
... | ... | |
530 | 528 |
|
531 | 529 |
$self->js_reset_order_and_item_ids_after_save; |
532 | 530 |
|
531 |
my @redirect_params = ( |
|
532 |
action => 'edit', |
|
533 |
type => $self->type, |
|
534 |
id => $self->order->id, |
|
535 |
); |
|
536 |
|
|
537 |
# Set the error handler to reload the document and display errors later, |
|
538 |
# because the document is already saved and saving can have some side effects |
|
539 |
# such as generating a document number, project number or reocrd links, |
|
540 |
# which will be up to date when the document is reloaded. |
|
541 |
# Hint: Do not use "die" here and try to catch exceptions in subroutine |
|
542 |
# calls. You should use "$::form->error" which respects the error handler. |
|
543 |
local $::form->{__ERROR_HANDLER} = sub { |
|
544 |
flash_later('error', $_[0]); |
|
545 |
$self->redirect_to(@redirect_params); |
|
546 |
$::dispatcher->end_request; |
|
547 |
}; |
|
548 |
|
|
533 | 549 |
my $email_form = delete $::form->{email_form}; |
534 | 550 |
|
535 | 551 |
if ($email_form->{additional_to}) { |
... | ... | |
568 | 584 |
printer_id => $::form->{print_options}->{printer_id}, |
569 | 585 |
groupitems => $::form->{print_options}->{groupitems}}); |
570 | 586 |
if (scalar @errors) { |
571 |
return $self->js->flash('error', t8('Generating the document failed: #1', $errors[0]))->render($self);
|
|
587 |
$::form->error(t8('Generating the document failed: #1', $errors[0]));
|
|
572 | 588 |
} |
573 | 589 |
|
574 | 590 |
my @warnings = $self->store_doc_to_webdav_and_filemanagement($doc, $::form->{attachment_filename}, $::form->{formname}); |
... | ... | |
613 | 629 |
# DMS kivi version should have a record_link to email_journal |
614 | 630 |
# the record link has to refer to the correct version -> helper table file <-> file_version |
615 | 631 |
$file_id = $self->{file_id} || $::form->{file_id}; |
616 |
die "No file id" unless $file_id;
|
|
632 |
$::form->error("No file id") unless $file_id;
|
|
617 | 633 |
} |
618 | 634 |
|
619 | 635 |
# email is sent -> set this version to final and link to journal and file |
620 | 636 |
my $current_version = SL::DB::Manager::OrderVersion->get_all(where => [oe_id => $self->order->id, final_version => 0]); |
621 |
die "Invalid version state" unless scalar @{ $current_version } == 1;
|
|
637 |
$::form->error("Invalid version state") unless scalar @{ $current_version } == 1;
|
|
622 | 638 |
$current_version->[0]->update_attributes(file_id => $file_id, |
623 | 639 |
email_journal_id => $::form->{email_journal_id}, |
624 | 640 |
final_version => 1); |
... | ... | |
626 | 642 |
|
627 | 643 |
flash_later('info', t8('The email has been sent.')); |
628 | 644 |
|
629 |
my @redirect_params = ( |
|
630 |
action => 'edit', |
|
631 |
type => $self->type, |
|
632 |
id => $self->order->id, |
|
633 |
); |
|
634 |
|
|
635 | 645 |
$self->redirect_to(@redirect_params); |
636 | 646 |
} |
637 | 647 |
|
Auch abrufbar als: Unified diff
Auftrags-Controller: Beleg neu laden nach "Speichern und E-Mail" auch bei Fehler
Wenn nach dem Speichern ein Fehler auftritt, Beleg neu laden mit redirect.
Gleiche Problematik/Begründung wie in commit
1268bf670c06f5a66ad78a75e41ad6c15061d9bc
Zudem wird dann auch der E-Mail-Dialog geschlossen und die Fehlermeldung
verschwindet nicht so im "Schatten".