Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 781e38df

Von Tamino Steinert vor etwa 1 Jahr hinzugefügt

  • ID 781e38df6557e20f9dbc78d4297c2ae3686d8589
  • Vorgänger 60a2e713
  • Nachfolger 2aec7b6d

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

  
......
1213 1204

  
1214 1205
  $self->js
1215 1206
    ->val('#id', $self->order->id)
1216
    ->val('#converted_from_oe_id', '')
1217
    ->val('#converted_from_reclamation_id', '')
1207
    ->val('#converted_from_record_type_ref', '')
1208
    ->val('#converted_from_record_id',  '')
1218 1209
    ->val('#order_' . $self->nr_key(), $self->order->number);
1219 1210

  
1220 1211
  my $idx = 0;
......
1231 1222
  } continue {
1232 1223
    $idx++;
1233 1224
  }
1234
  $self->js->val('[name="converted_from_orderitems_ids[+]"]', '');
1235
  $self->js->val('[name="converted_from_reclamation_items_ids[+]"]', '');
1225
  $self->js->val('[name="converted_from_record_item_type_refs[+]"]', '');
1226
  $self->js->val('[name="converted_from_record_item_ids[+]"]', '');
1236 1227
}
1237 1228

  
1238 1229
#
......
1624 1615
sub save {
1625 1616
  my ($self) = @_;
1626 1617

  
1627
  # link records
1628
  if ($::form->{converted_from_oe_id}) {
1629
    my @converted_from_oe_ids = split ' ', $::form->{converted_from_oe_id};
1630
    set_record_link_conversions(
1631
      $self->order,
1632
      'SL::DB::Order'     => \@converted_from_oe_ids,
1633
      'SL::DB::OrderItem' => $::form->{converted_from_orderitems_ids},
1634
    );
1635
  }
1636
  if ($::form->{converted_from_reclamation_id}) {
1637
    my @converted_from_reclamation_ids =
1638
      split ' ', $::form->{converted_from_reclamation_id};
1639
    set_record_link_conversions(
1640
      $self->order,
1641
      'SL::DB::Reclamation'     => \@converted_from_reclamation_ids,
1642
      'SL::DB::ReclamationItem' => $::form->{converted_from_reclamation_items_ids},
1643
    );
1644
  }
1618
  set_record_link_conversions($self->order,
1619
    delete $::form->{RECORD_TYPE_REF()}
1620
      => delete $::form->{RECORD_ID()},
1621
    delete $::form->{RECORD_ITEM_TYPE_REF()}
1622
      => delete $::form->{RECORD_ITEM_ID()},
1623
  );
1645 1624

  
1646 1625
  my $items_to_delete  = scalar @{ $self->item_ids_to_delete || [] }
1647 1626
                       ? 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_ref[+]", ITEM.converted_from_record_item_type_ref) %]
19
      [% L.hidden_tag("converted_from_record_item_id[+]",       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_ref[+]", ITEM.converted_from_record_item_type_ref) %]
19
      [% L.hidden_tag("converted_from_record_item_id[+]",       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