Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 6e568231

Von Werner Hahn vor mehr als 1 Jahr hinzugefügt

  • ID 6e5682317d26c301ce295c1d60ad9b21d41af1b1
  • Vorgänger d0d02f4e
  • Nachfolger 1a0c3772

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

Unterschiede anzeigen:

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

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

  
46 47
use List::Util qw(first sum0);
47 48
use List::UtilsBy qw(sort_by uniq_by);
......
195 196
sub action_delete {
196 197
  my ($self) = @_;
197 198

  
198
  my $errors = $self->delete();
199

  
200
  if (scalar @{ $errors }) {
201
    $self->js->flash('error', $_) foreach @{ $errors };
202
    return $self->js->render();
203
  }
204

  
199
  my $number_type = $self->order->type =~ m{order} ? 'ordnumber' : 'quonumber';
200
  my %history = (snumbers => $number_type . '_' . $self->order->$number_type);
201
  my %params = (history => \%history);
202
  SL::Model::Record->delete($self->order, %params);
205 203
  my $text = $self->type eq sales_order_type()       ? $::locale->text('The order has been deleted')
206 204
           : $self->type eq purchase_order_type()    ? $::locale->text('The order has been deleted')
207 205
           : $self->type eq sales_quotation_type()   ? $::locale->text('The quotation has been deleted')
......
2139 2137
  }
2140 2138
}
2141 2139

  
2142
# delete the order
2143
#
2144
# And remove related files in the spool directory
2145
sub delete {
2146
  my ($self) = @_;
2147

  
2148
  my $errors = [];
2149
  my $db     = $self->order->db;
2150

  
2151
  $db->with_transaction(
2152
    sub {
2153
      my @spoolfiles = grep { $_ } map { $_->spoolfile } @{ SL::DB::Manager::Status->get_all(where => [ trans_id => $self->order->id ]) };
2154
      $self->order->delete;
2155
      my $spool = $::lx_office_conf{paths}->{spool};
2156
      unlink map { "$spool/$_" } @spoolfiles if $spool;
2157

  
2158
      $self->save_history('DELETED');
2159

  
2160
      1;
2161
  }) || push(@{$errors}, $db->error);
2162

  
2163
  return $errors;
2164
}
2165

  
2166 2140
# save the order
2167 2141
#
2168 2142
# And delete items that are deleted in the form.

Auch abrufbar als: Unified diff