Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 94263c26

Von Werner Hahn vor etwa 1 Jahr hinzugefügt

  • ID 94263c2655fbddff0bd4128f8a0cef8642e7b001
  • Vorgänger 48f45a37
  • Nachfolger cf79e516

OrderController delete auf SL/Model/Record->delete gemapt

Unterschiede anzeigen:

SL/Controller/Order.pm
43 43
use SL::Helper::UserPreferences::UpdatePositions;
44 44

  
45 45
use SL::Controller::Helper::GetModels;
46
use SL::Model::Record;
46 47

  
47 48
use List::Util qw(first sum0);
48 49
use List::UtilsBy qw(sort_by uniq_by);
......
205 206
sub action_delete {
206 207
  my ($self) = @_;
207 208

  
208
  my $errors = $self->delete();
209

  
210
  if (scalar @{ $errors }) {
211
    $self->js->flash('error', $_) foreach @{ $errors };
212
    return $self->js->render();
213
  }
214

  
209
  my $number_type = $self->order->type =~ m{order} ? 'ordnumber' : 'quonumber';
210
  my %history = (snumbers => $number_type . '_' . $self->order->$number_type);
211
  my %params = (history => \%history);
212
  SL::Model::Record->delete($self->order, %params);
215 213
  my $text = $self->type eq sales_order_intake_type()        ? $::locale->text('The order intake has been deleted')
216 214
           : $self->type eq sales_order_type()               ? $::locale->text('The order confirmation has been deleted')
217 215
           : $self->type eq purchase_order_type()            ? $::locale->text('The order has been deleted')
......
2160 2158
  }
2161 2159
}
2162 2160

  
2163
# delete the order
2164
#
2165
# And remove related files in the spool directory
2166
sub delete {
2167
  my ($self) = @_;
2168

  
2169
  my $errors = [];
2170
  my $db     = $self->order->db;
2171

  
2172
  $db->with_transaction(
2173
    sub {
2174
      my @spoolfiles = grep { $_ } map { $_->spoolfile } @{ SL::DB::Manager::Status->get_all(where => [ trans_id => $self->order->id ]) };
2175
      $self->order->delete;
2176
      my $spool = $::lx_office_conf{paths}->{spool};
2177
      unlink map { "$spool/$_" } @spoolfiles if $spool;
2178

  
2179
      $self->save_history('DELETED');
2180

  
2181
      1;
2182
  }) || push(@{$errors}, $db->error);
2183

  
2184
  return $errors;
2185
}
2186

  
2187 2161
# save the order
2188 2162
#
2189 2163
# And delete items that are deleted in the form.

Auch abrufbar als: Unified diff