Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision b39653f8

Von Bernd Bleßmann vor etwa 6 Jahren hinzugefügt

  • ID b39653f82441d0db075db54950752f6efa267e1c
  • Vorgänger 828c7d4e
  • Nachfolger 39fa895d

Auftrags-Controller: Aufträge auch mit neuem Controller zusammenfassen können

Unterschiede anzeigen:

SL/Controller/Order.pm
99 99
  );
100 100
}
101 101

  
102
# edit a collective order (consisting of one or more existing orders)
103
sub action_edit_collective {
104
  my ($self) = @_;
105

  
106
  # collect order ids
107
  my @multi_ids = map {
108
    $_ =~ m{^multi_id_(\d+)$} && $::form->{'multi_id_' . $1} && $::form->{'trans_id_' . $1} && $::form->{'trans_id_' . $1}
109
  } grep { $_ =~ m{^multi_id_\d+$} } keys %$::form;
110

  
111
  # fall back to add if no ids are given
112
  if (scalar @multi_ids == 0) {
113
    $self->action_add();
114
    return;
115
  }
116

  
117
  # fall back to save as new if only one id is given
118
  if (scalar @multi_ids == 1) {
119
    $self->order(SL::DB::Order->new(id => $multi_ids[0])->load);
120
    $self->action_save_as_new();
121
    return;
122
  }
123

  
124
  # make new order from given orders
125
  my @multi_orders = map { SL::DB::Order->new(id => $_)->load } @multi_ids;
126
  $self->{converted_from_oe_id} = join ' ', map { $_->id } @multi_orders;
127
  $self->order(SL::DB::Order->new_from_multi(\@multi_orders, sort_sources_by => 'transdate'));
128

  
129
  $self->action_edit();
130
}
131

  
102 132
# delete the order
103 133
sub action_delete {
104 134
  my ($self) = @_;
......
1400 1430
  my $db     = $self->order->db;
1401 1431

  
1402 1432
  $db->with_transaction(sub {
1403
    SL::DB::OrderItem->new(id => $_)->delete for @{$self->item_ids_to_delete};
1433
    SL::DB::OrderItem->new(id => $_)->delete for @{$self->item_ids_to_delete || []};
1404 1434
    $self->order->save(cascade => 1);
1405 1435

  
1406 1436
    # link records
1407 1437
    if ($::form->{converted_from_oe_id}) {
1408
      my $src = SL::DB::Order->new(id => $::form->{converted_from_oe_id})->load;
1409
      # implement OE::_close_quotations_rfqs - this a 1 : 1 connection
1410
      # close only if workflow: quotation -> order. TODO test case
1411
      $src->update_attributes(closed => 1) if $src->type =~ /_quotation$/;
1412
      $src->link_to_record($self->order);
1413

  
1438
      my @converted_from_oe_ids = split ' ', $::form->{converted_from_oe_id};
1439
      foreach my $converted_from_oe_id (@converted_from_oe_ids) {
1440
        my $src = SL::DB::Order->new(id => $converted_from_oe_id)->load;
1441
        $src->update_attributes(closed => 1) if $src->type =~ /_quotation$/;
1442
        $src->link_to_record($self->order);
1443
      }
1414 1444
      if (scalar @{ $::form->{converted_from_orderitems_ids} || [] }) {
1415 1445
        my $idx = 0;
1416 1446
        foreach (@{ $self->order->items_sorted }) {
bin/mozilla/oe.pl
48 48
use List::Util qw(min max reduce sum);
49 49
use Data::Dumper;
50 50

  
51
use SL::Controller::Order;
52

  
51 53
use SL::DB::Customer;
52 54
use SL::DB::TaxZone;
53 55
use SL::DB::PaymentTerm;
......
184 186

  
185 187
  # editing without stuff to edit? try adding it first
186 188
  if ($form->{rowcount} && !$form->{print_and_save}) {
189
    if ($::instance_conf->get_feature_experimental_order) {
190
      my $c = SL::Controller::Order->new;
191
      $c->action_edit_collective();
192

  
193
      $main::lxdebug->leave_sub();
194
      $::dispatcher->end_request;
195
    }
196

  
187 197
    my $id;
188 198
    map { $id++ if $form->{"multi_id_$_"} } (1 .. $form->{rowcount});
189 199
    if (!$id) {

Auch abrufbar als: Unified diff