Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision cab8e369

Von Bernd Bleßmann vor etwa 1 Jahr hinzugefügt

  • ID cab8e369fb65a4a46c6ef1da5ca7b190e248b80c
  • Vorgänger f84ea53c
  • Nachfolger 4c2097ce

Order-Controller: Parsen von Telefonnotizen in sub ausgelagert

Unterschiede anzeigen:

SL/Controller/Order.pm
1396 1396
sub action_save_phone_note {
1397 1397
  my ($self) = @_;
1398 1398

  
1399
  if (!$::form->{phone_note}->{subject} || !$::form->{phone_note}->{body}) {
1400
    return $self->js->flash('error', t8('Phone note needs a subject and a body.'))->render;
1401
  }
1402

  
1403
  my $phone_note;
1404
  if ($::form->{phone_note}->{id}) {
1405
    $phone_note = first { $_->id == $::form->{phone_note}->{id} } @{$self->order->phone_notes};
1406
    return $self->js->flash('error', t8('Phone note not found for this order.'))->render if !$phone_note;
1407
  }
1408

  
1409
  $phone_note = SL::DB::Note->new() if !$phone_note;
1410
  my $is_new  = !$phone_note->id;
1411

  
1412
  $phone_note->assign_attributes(%{ $::form->{phone_note} },
1413
                                 trans_id     => $self->order->id,
1414
                                 trans_module => 'oe',
1415
                                 employee     => SL::DB::Manager::Employee->current);
1399
  my $phone_note = $self->parse_phone_note;
1400
  my $is_new     = !$phone_note->id;
1416 1401

  
1417 1402
  $phone_note->save;
1418 1403
  $self->order(SL::DB::Order->new(id => $self->order->id)->load);
......
2082 2067
  }
2083 2068
}
2084 2069

  
2085
# check for new or updated phone notes
2070
# parse new or updated phone note
2086 2071
#
2087 2072
# And put them into the order object.
2088
sub handle_phone_note {
2073
sub parse_phone_note {
2089 2074
  my ($self) = @_;
2090 2075

  
2091
  if ($::form->{phone_note}->{subject} || $::form->{phone_note}->{body}) {
2092
    if (!$::form->{phone_note}->{subject} || !$::form->{phone_note}->{body}) {
2093
      die t8('Phone note needs a subject and a body.');
2094
    }
2076
  if (!$::form->{phone_note}->{subject} || !$::form->{phone_note}->{body}) {
2077
    die t8('Phone note needs a subject and a body.');
2078
  }
2095 2079

  
2096
    my $phone_note;
2097
    if ($::form->{phone_note}->{id}) {
2098
      $phone_note = first { $_->id == $::form->{phone_note}->{id} } @{$self->order->phone_notes};
2099
      die t8('Phone note not found for this order.') if !$phone_note;
2100
    }
2080
  my $phone_note;
2081
  if ($::form->{phone_note}->{id}) {
2082
    $phone_note = first { $_->id == $::form->{phone_note}->{id} } @{$self->order->phone_notes};
2083
    die t8('Phone note not found for this order.') if !$phone_note;
2084
  }
2101 2085

  
2102
    $phone_note = SL::DB::Note->new() if !$phone_note;
2103
    my $is_new  = !$phone_note->id;
2086
  $phone_note = SL::DB::Note->new() if !$phone_note;
2087
  my $is_new  = !$phone_note->id;
2104 2088

  
2105
    $phone_note->assign_attributes(%{ $::form->{phone_note} },
2106
                                   trans_id     => $self->order->id,
2107
                                   trans_module => 'oe',
2108
                                   employee     => SL::DB::Manager::Employee->current);
2089
  $phone_note->assign_attributes(%{ $::form->{phone_note} },
2090
                                 trans_id     => $self->order->id,
2091
                                 trans_module => 'oe',
2092
                                 employee     => SL::DB::Manager::Employee->current);
2109 2093

  
2110
    $self->order->add_phone_notes($phone_note) if $is_new;
2111
  }
2094
  $self->order->add_phone_notes($phone_note) if $is_new;
2095
  return $phone_note;
2112 2096
}
2113 2097

  
2114 2098
# save the order
......
2121 2105
    return [t8('The action you\'ve chosen has not been executed because the document does not contain any item yet.')];
2122 2106
  }
2123 2107

  
2124
  $self->handle_phone_note;
2108
  $self->parse_phone_note if $::form->{phone_note}->{subject} || $::form->{phone_note}->{body};
2125 2109

  
2126 2110
  # create first version if none exists
2127 2111
  $self->order->add_order_version(SL::DB::OrderVersion->new(version => 1)) if !$self->order->order_version;

Auch abrufbar als: Unified diff