Revision 97487d25
Von Bernd Bleßmann vor mehr als 1 Jahr hinzugefügt
SL/Controller/Order.pm | ||
---|---|---|
1384 | 1384 |
sub action_save_phone_note { |
1385 | 1385 |
my ($self) = @_; |
1386 | 1386 |
|
1387 |
if (!$::form->{phone_note}->{subject} || !$::form->{phone_note}->{body}) { |
|
1388 |
return $self->js->flash('error', t8('Phone note needs a subject and a body.'))->render; |
|
1389 |
} |
|
1390 |
|
|
1391 |
my $phone_note; |
|
1392 |
if ($::form->{phone_note}->{id}) { |
|
1393 |
$phone_note = first { $_->id == $::form->{phone_note}->{id} } @{$self->order->phone_notes}; |
|
1394 |
return $self->js->flash('error', t8('Phone note not found for this order.'))->render if !$phone_note; |
|
1395 |
} |
|
1396 |
|
|
1397 |
$phone_note = SL::DB::Note->new() if !$phone_note; |
|
1398 |
my $is_new = !$phone_note->id; |
|
1399 |
|
|
1400 |
$phone_note->assign_attributes(%{ $::form->{phone_note} }, |
|
1401 |
trans_id => $self->order->id, |
|
1402 |
trans_module => 'oe', |
|
1403 |
employee => SL::DB::Manager::Employee->current); |
|
1387 |
my $phone_note = $self->parse_phone_note; |
|
1388 |
my $is_new = !$phone_note->id; |
|
1404 | 1389 |
|
1405 | 1390 |
$phone_note->save; |
1406 | 1391 |
$self->order(SL::DB::Order->new(id => $self->order->id)->load); |
... | ... | |
2065 | 2050 |
} |
2066 | 2051 |
} |
2067 | 2052 |
|
2068 |
# check for new or updated phone notes
|
|
2053 |
# parse new or updated phone note
|
|
2069 | 2054 |
# |
2070 | 2055 |
# And put them into the order object. |
2071 |
sub handle_phone_note {
|
|
2056 |
sub parse_phone_note {
|
|
2072 | 2057 |
my ($self) = @_; |
2073 | 2058 |
|
2074 |
if ($::form->{phone_note}->{subject} || $::form->{phone_note}->{body}) { |
|
2075 |
if (!$::form->{phone_note}->{subject} || !$::form->{phone_note}->{body}) { |
|
2076 |
die t8('Phone note needs a subject and a body.'); |
|
2077 |
} |
|
2059 |
if (!$::form->{phone_note}->{subject} || !$::form->{phone_note}->{body}) { |
|
2060 |
die t8('Phone note needs a subject and a body.'); |
|
2061 |
} |
|
2078 | 2062 |
|
2079 |
my $phone_note;
|
|
2080 |
if ($::form->{phone_note}->{id}) {
|
|
2081 |
$phone_note = first { $_->id == $::form->{phone_note}->{id} } @{$self->order->phone_notes};
|
|
2082 |
die t8('Phone note not found for this order.') if !$phone_note;
|
|
2083 |
}
|
|
2063 |
my $phone_note; |
|
2064 |
if ($::form->{phone_note}->{id}) { |
|
2065 |
$phone_note = first { $_->id == $::form->{phone_note}->{id} } @{$self->order->phone_notes}; |
|
2066 |
die t8('Phone note not found for this order.') if !$phone_note; |
|
2067 |
} |
|
2084 | 2068 |
|
2085 |
$phone_note = SL::DB::Note->new() if !$phone_note;
|
|
2086 |
my $is_new = !$phone_note->id;
|
|
2069 |
$phone_note = SL::DB::Note->new() if !$phone_note; |
|
2070 |
my $is_new = !$phone_note->id; |
|
2087 | 2071 |
|
2088 |
$phone_note->assign_attributes(%{ $::form->{phone_note} },
|
|
2089 |
trans_id => $self->order->id,
|
|
2090 |
trans_module => 'oe',
|
|
2091 |
employee => SL::DB::Manager::Employee->current);
|
|
2072 |
$phone_note->assign_attributes(%{ $::form->{phone_note} }, |
|
2073 |
trans_id => $self->order->id, |
|
2074 |
trans_module => 'oe', |
|
2075 |
employee => SL::DB::Manager::Employee->current); |
|
2092 | 2076 |
|
2093 |
$self->order->add_phone_notes($phone_note) if $is_new;
|
|
2094 |
}
|
|
2077 |
$self->order->add_phone_notes($phone_note) if $is_new; |
|
2078 |
return $phone_note;
|
|
2095 | 2079 |
} |
2096 | 2080 |
|
2097 | 2081 |
# save the order |
... | ... | |
2100 | 2084 |
sub save { |
2101 | 2085 |
my ($self) = @_; |
2102 | 2086 |
|
2103 |
$self->handle_phone_note;
|
|
2087 |
$self->parse_phone_note if $::form->{phone_note}->{subject} || $::form->{phone_note}->{body};
|
|
2104 | 2088 |
|
2105 | 2089 |
# create first version if none exists |
2106 | 2090 |
$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