Revision fcf1cda2
Von Bernd Bleßmann vor fast 2 Jahren hinzugefügt
SL/Controller/Order.pm | ||
---|---|---|
1373 | 1373 |
sub action_save_phone_note { |
1374 | 1374 |
my ($self) = @_; |
1375 | 1375 |
|
1376 |
if (!$::form->{phone_note}->{subject} || !$::form->{phone_note}->{body}) { |
|
1377 |
return $self->js->flash('error', t8('Phone note needs a subject and a body.'))->render; |
|
1378 |
} |
|
1379 |
|
|
1380 |
my $phone_note; |
|
1381 |
if ($::form->{phone_note}->{id}) { |
|
1382 |
$phone_note = first { $_->id == $::form->{phone_note}->{id} } @{$self->order->phone_notes}; |
|
1383 |
return $self->js->flash('error', t8('Phone note not found for this order.'))->render if !$phone_note; |
|
1384 |
} |
|
1385 |
|
|
1386 |
$phone_note = SL::DB::Note->new() if !$phone_note; |
|
1387 |
my $is_new = !$phone_note->id; |
|
1388 |
|
|
1389 |
$phone_note->assign_attributes(%{ $::form->{phone_note} }, |
|
1390 |
trans_id => $self->order->id, |
|
1391 |
trans_module => 'oe', |
|
1392 |
employee => SL::DB::Manager::Employee->current); |
|
1376 |
my $phone_note = $self->parse_phone_note; |
|
1377 |
my $is_new = !$phone_note->id; |
|
1393 | 1378 |
|
1394 | 1379 |
$phone_note->save; |
1395 | 1380 |
$self->order(SL::DB::Order->new(id => $self->order->id)->load); |
... | ... | |
2025 | 2010 |
} |
2026 | 2011 |
} |
2027 | 2012 |
|
2028 |
# check for new or updated phone notes
|
|
2013 |
# parse new or updated phone note
|
|
2029 | 2014 |
# |
2030 | 2015 |
# And put them into the order object. |
2031 |
sub handle_phone_note {
|
|
2016 |
sub parse_phone_note {
|
|
2032 | 2017 |
my ($self) = @_; |
2033 | 2018 |
|
2034 |
if ($::form->{phone_note}->{subject} || $::form->{phone_note}->{body}) { |
|
2035 |
if (!$::form->{phone_note}->{subject} || !$::form->{phone_note}->{body}) { |
|
2036 |
die t8('Phone note needs a subject and a body.'); |
|
2037 |
} |
|
2019 |
if (!$::form->{phone_note}->{subject} || !$::form->{phone_note}->{body}) { |
|
2020 |
die t8('Phone note needs a subject and a body.'); |
|
2021 |
} |
|
2038 | 2022 |
|
2039 |
my $phone_note;
|
|
2040 |
if ($::form->{phone_note}->{id}) {
|
|
2041 |
$phone_note = first { $_->id == $::form->{phone_note}->{id} } @{$self->order->phone_notes};
|
|
2042 |
die t8('Phone note not found for this order.') if !$phone_note;
|
|
2043 |
}
|
|
2023 |
my $phone_note; |
|
2024 |
if ($::form->{phone_note}->{id}) { |
|
2025 |
$phone_note = first { $_->id == $::form->{phone_note}->{id} } @{$self->order->phone_notes}; |
|
2026 |
die t8('Phone note not found for this order.') if !$phone_note; |
|
2027 |
} |
|
2044 | 2028 |
|
2045 |
$phone_note = SL::DB::Note->new() if !$phone_note;
|
|
2046 |
my $is_new = !$phone_note->id;
|
|
2029 |
$phone_note = SL::DB::Note->new() if !$phone_note; |
|
2030 |
my $is_new = !$phone_note->id; |
|
2047 | 2031 |
|
2048 |
$phone_note->assign_attributes(%{ $::form->{phone_note} },
|
|
2049 |
trans_id => $self->order->id,
|
|
2050 |
trans_module => 'oe',
|
|
2051 |
employee => SL::DB::Manager::Employee->current);
|
|
2032 |
$phone_note->assign_attributes(%{ $::form->{phone_note} }, |
|
2033 |
trans_id => $self->order->id, |
|
2034 |
trans_module => 'oe', |
|
2035 |
employee => SL::DB::Manager::Employee->current); |
|
2052 | 2036 |
|
2053 |
$self->order->add_phone_notes($phone_note) if $is_new;
|
|
2054 |
}
|
|
2037 |
$self->order->add_phone_notes($phone_note) if $is_new; |
|
2038 |
return $phone_note;
|
|
2055 | 2039 |
} |
2056 | 2040 |
|
2057 | 2041 |
# save the order |
... | ... | |
2060 | 2044 |
sub save { |
2061 | 2045 |
my ($self) = @_; |
2062 | 2046 |
|
2063 |
$self->handle_phone_note;
|
|
2047 |
$self->parse_phone_note if $::form->{phone_note}->{subject} || $::form->{phone_note}->{body};
|
|
2064 | 2048 |
|
2065 | 2049 |
# create first version if none exists |
2066 | 2050 |
$self->order->add_order_version(SL::DB::OrderVersion->new(version => 1)) if !$self->order->order_version; |
Auch abrufbar als: Unified diff
Order-Controller: Parsen von Telefonnotizen in sub ausgelagert