Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 35fd4233

Von Tamino Steinert vor etwa 1 Jahr hinzugefügt

  • ID 35fd4233c6a6190a84c8690779aa987252597c16
  • Vorgänger fa117c2d
  • Nachfolger d84ce795

DeliveryOrder: Nutze Type und ID zum Erstellen von verknüpften Belegen

Unterschiede anzeigen:

SL/Controller/DeliveryOrder.pm
32 32
use SL::DB::TransferType;
33 33
use SL::DB::ValidityToken;
34 34
use SL::DB::Warehouse;
35
use SL::DB::Helper::RecordLink qw(set_record_link_conversions RECORD_ID RECORD_ITEM_ID);
35
use SL::DB::Helper::RecordLink qw(set_record_link_conversions RECORD_ID RECORD_TYPE_REF RECORD_ITEM_ID RECORD_ITEM_TYPE_REF);
36 36
use SL::DB::Helper::TypeDataProxy;
37 37
use SL::DB::Helper::Record qw(get_object_name_from_type get_class_from_type);
38 38
use SL::DB::DeliveryOrder;
......
132 132
  my $delivery_order = SL::Model::Record->new_from_workflow($record, $self->type, %flags);
133 133
  $self->order($delivery_order);
134 134

  
135
  if (ref($record) eq 'SL::DB::Reclamation') {
136
    $self->{converted_from_reclamation_id}       = $delivery_order->{ RECORD_ID()      };
137
    $_   ->{converted_from_reclamation_items_id} = $_             ->{ RECORD_ITEM_ID() } for @{ $delivery_order->items_sorted };
138
  }
139
  if (ref($record) eq 'SL::DB::Order') {
140
    $self->{converted_from_oe_id}       = $delivery_order->{ RECORD_ID()      };
141
    $_   ->{converted_from_oe_items_id} = $_             ->{ RECORD_ITEM_ID() } for @{ $delivery_order->items_sorted };
142
  }
143

  
144 135
  $self->action_add;
145 136
}
146 137

  
......
1239 1230

  
1240 1231
  $self->js
1241 1232
    ->val('#id', $self->order->id)
1242
    ->val('#converted_from_oe_id', '')
1243
    ->val('#converted_from_reclamation_id', '')
1233
    ->val('#converted_from_record_type_ref', '')
1234
    ->val('#converted_from_record_id',  '')
1244 1235
    ->val('#order_' . $self->nr_key(), $self->order->number);
1245 1236

  
1246 1237
  my $idx = 0;
......
1257 1248
  } continue {
1258 1249
    $idx++;
1259 1250
  }
1260
  $self->js->val('[name="converted_from_orderitems_ids[+]"]', '');
1261
  $self->js->val('[name="converted_from_reclamation_items_ids[+]"]', '');
1251
  $self->js->val('[name="converted_from_record_item_type_refs[+]"]', '');
1252
  $self->js->val('[name="converted_from_record_item_ids[+]"]', '');
1262 1253
}
1263 1254

  
1264 1255
#
......
1650 1641
sub save {
1651 1642
  my ($self) = @_;
1652 1643

  
1653
  # link records
1654
  if ($::form->{converted_from_oe_id}) {
1655
    my @converted_from_oe_ids = split ' ', $::form->{converted_from_oe_id};
1656
    set_record_link_conversions(
1657
      $self->order,
1658
      'SL::DB::Order'     => \@converted_from_oe_ids,
1659
      'SL::DB::OrderItem' => $::form->{converted_from_orderitems_ids},
1660
    );
1661
  }
1662
  if ($::form->{converted_from_reclamation_id}) {
1663
    my @converted_from_reclamation_ids =
1664
      split ' ', $::form->{converted_from_reclamation_id};
1665
    set_record_link_conversions(
1666
      $self->order,
1667
      'SL::DB::Reclamation'     => \@converted_from_reclamation_ids,
1668
      'SL::DB::ReclamationItem' => $::form->{converted_from_reclamation_items_ids},
1669
    );
1670
  }
1644
  set_record_link_conversions($self->order,
1645
    delete $::form->{RECORD_TYPE_REF()}
1646
      => delete $::form->{RECORD_ID()},
1647
    delete $::form->{RECORD_ITEM_TYPE_REF()}
1648
      => delete $::form->{RECORD_ITEM_ID()},
1649
  );
1671 1650

  
1672 1651
  my $items_to_delete  = scalar @{ $self->item_ids_to_delete || [] }
1673 1652
                       ? SL::DB::Manager::DeliveryOrderItem->get_all(where => [id => $self->item_ids_to_delete])
templates/design40_webpages/delivery_order/form.html
19 19
  [% L.hidden_tag('callback',             FORM.callback) %]
20 20
  [% L.hidden_tag('type',                 FORM.type) %]
21 21
  [% L.hidden_tag('id',                   SELF.order.id) %]
22
  [% L.hidden_tag('converted_from_oe_id', SELF.converted_from_oe_id) %]
23
  [% L.hidden_tag('converted_from_reclamation_id', SELF.converted_from_reclamation_id) %]
22
  [% L.hidden_tag('converted_from_record_type_ref', SELF.order.converted_from_record_type_ref) %]
23
  [% L.hidden_tag('converted_from_record_id',       SELF.order.converted_from_record_id) %]
24 24

  
25 25
  [% IF !SELF.order.id %]
26 26
  [%   L.hidden_tag('form_validity_token', FORM.form_validity_token) %]
templates/design40_webpages/delivery_order/tabs/_row.html
15 15
                     alt=LxERP.t8('Show details'), title=LxERP.t8('Show details'), class="expand") %]
16 16
      [%- END %]
17 17
      [% L.hidden_tag("orderitem_ids[+]", ID) %]
18
      [% L.hidden_tag("converted_from_orderitems_ids[+]", ITEM.converted_from_orderitems_id) %]
19
      [% L.hidden_tag("converted_from_reclamation_items_ids[+]", ITEM.converted_from_reclamation_items_id) %]
18
      [% L.hidden_tag("converted_from_record_item_type_refs[+]", ITEM.converted_from_record_item_type_ref) %]
19
      [% L.hidden_tag("converted_from_record_item_ids[+]",       ITEM.converted_from_record_item_id) %]
20 20
      [% L.hidden_tag("order.orderitems[+].id", ITEM.id, id='item_' _ ID) %]
21 21
      [% L.hidden_tag("order.orderitems[].stock_info", ITEM.stock_info, class="data-stock-info") %]
22 22
      [% L.hidden_tag("order.orderitems[].parts_id", ITEM.parts_id) %]
templates/webpages/delivery_order/form.html
19 19
  [% L.hidden_tag('callback',             FORM.callback) %]
20 20
  [% L.hidden_tag('type',                 FORM.type) %]
21 21
  [% L.hidden_tag('id',                   SELF.order.id) %]
22
  [% L.hidden_tag('converted_from_oe_id', SELF.converted_from_oe_id) %]
23
  [% L.hidden_tag('converted_from_reclamation_id', SELF.converted_from_reclamation_id) %]
22
  [% L.hidden_tag('converted_from_record_type_ref', SELF.order.converted_from_record_type_ref) %]
23
  [% L.hidden_tag('converted_from_record_id',       SELF.order.converted_from_record_id) %]
24 24

  
25 25
  [% IF !SELF.order.id %]
26 26
  [%   L.hidden_tag('form_validity_token', FORM.form_validity_token) %]
templates/webpages/delivery_order/tabs/_row.html
15 15
                     alt=LxERP.t8('Show details'), title=LxERP.t8('Show details'), class="expand") %]
16 16
      [%- END %]
17 17
      [% L.hidden_tag("orderitem_ids[+]", ID) %]
18
      [% L.hidden_tag("converted_from_orderitems_ids[+]", ITEM.converted_from_orderitems_id) %]
19
      [% L.hidden_tag("converted_from_reclamation_items_ids[+]", ITEM.converted_from_reclamation_items_id) %]
18
      [% L.hidden_tag("converted_from_record_item_type_refs[+]", ITEM.converted_from_record_item_type_ref) %]
19
      [% L.hidden_tag("converted_from_record_item_ids[+]",       ITEM.converted_from_record_item_id) %]
20 20
      [% L.hidden_tag("order.orderitems[+].id", ITEM.id, id='item_' _ ID) %]
21 21
      [% L.hidden_tag("order.orderitems[].stock_info", ITEM.stock_info, class="data-stock-info") %]
22 22
      [% L.hidden_tag("order.orderitems[].parts_id", ITEM.parts_id) %]

Auch abrufbar als: Unified diff