Revision 3da68680
Von Bernd Bleßmann vor etwa 1 Jahr hinzugefügt
SL/Controller/Order.pm | ||
---|---|---|
2082 | 2082 |
} |
2083 | 2083 |
} |
2084 | 2084 |
|
2085 |
# save the order
|
|
2085 |
# check for new or updated phone notes
|
|
2086 | 2086 |
# |
2087 |
# And delete items that are deleted in the form.
|
|
2088 |
sub save {
|
|
2087 |
# And put them into the order object.
|
|
2088 |
sub handle_phone_note {
|
|
2089 | 2089 |
my ($self) = @_; |
2090 | 2090 |
|
2091 |
if (scalar @{$self->order->items} == 0 && !grep { $self->type eq $_ } @{$::instance_conf->get_allowed_documents_with_no_positions() || []}) { |
|
2092 |
return [t8('The action you\'ve chosen has not been executed because the document does not contain any item yet.')]; |
|
2093 |
} |
|
2094 |
|
|
2095 |
# check for new or updated phone note |
|
2096 | 2091 |
if ($::form->{phone_note}->{subject} || $::form->{phone_note}->{body}) { |
2097 | 2092 |
if (!$::form->{phone_note}->{subject} || !$::form->{phone_note}->{body}) { |
2098 |
return [t8('Phone note needs a subject and a body.')];
|
|
2093 |
die t8('Phone note needs a subject and a body.');
|
|
2099 | 2094 |
} |
2100 | 2095 |
|
2101 | 2096 |
my $phone_note; |
2102 | 2097 |
if ($::form->{phone_note}->{id}) { |
2103 | 2098 |
$phone_note = first { $_->id == $::form->{phone_note}->{id} } @{$self->order->phone_notes}; |
2104 |
return [t8('Phone note not found for this order.')] if !$phone_note;
|
|
2099 |
die t8('Phone note not found for this order.') if !$phone_note;
|
|
2105 | 2100 |
} |
2106 | 2101 |
|
2107 | 2102 |
$phone_note = SL::DB::Note->new() if !$phone_note; |
... | ... | |
2114 | 2109 |
|
2115 | 2110 |
$self->order->add_phone_notes($phone_note) if $is_new; |
2116 | 2111 |
} |
2112 |
} |
|
2113 |
|
|
2114 |
# save the order |
|
2115 |
# |
|
2116 |
# And delete items that are deleted in the form. |
|
2117 |
sub save { |
|
2118 |
my ($self) = @_; |
|
2119 |
|
|
2120 |
if (scalar @{$self->order->items} == 0 && !grep { $self->type eq $_ } @{$::instance_conf->get_allowed_documents_with_no_positions() || []}) { |
|
2121 |
return [t8('The action you\'ve chosen has not been executed because the document does not contain any item yet.')]; |
|
2122 |
} |
|
2123 |
|
|
2124 |
$self->handle_phone_note; |
|
2117 | 2125 |
|
2118 | 2126 |
# create first version if none exists |
2119 | 2127 |
$self->order->add_order_version(SL::DB::OrderVersion->new(version => 1)) if !$self->order->order_version; |
Auch abrufbar als: Unified diff
Order-Controller: Behandlung von Telefonnotizen beim Speichern in sub ausgelagert