Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision ec90d597

Von Tamino Steinert vor etwa 1 Jahr hinzugefügt

  • ID ec90d5977ba6752ae8ac2ce7b87822c2068becdc
  • Vorgänger 728164f0
  • Nachfolger aa2fcd58

Model::Record: Workflow mit ausgewählten Positionen ermöglichen

Unterschiede anzeigen:

SL/Controller/DeliveryOrder.pm
81 81

  
82 82
__PACKAGE__->run_before('get_unalterable_data',
83 83
  only => [ qw(
84
    save save_as_new save_and_delivery_order save_and_invoice
84
    save save_as_new save_and_new_record save_and_invoice
85 85
    save_and_ap_transaction print send_email
86 86
    ) ]);
87 87

  
......
118 118
  die "No 'from_type' was given." unless ($from_type);
119 119
  die "No 'from_id' was given."   unless ($from_id);
120 120

  
121
  my %flags = ();
122
  if (defined($::form->{from_item_ids})) {
123
    my %use_item = map { $_ => 1 } @{$::form->{from_item_ids}};
124
    $flags{item_filter} = sub {
125
      my ($item) = @_;
126
      return %use_item{$item->id};
127
    }
128
  }
129

  
121 130
  my $record = SL::Model::Record->get_record($from_type, $from_id);
122
  my $delivery_order = SL::Model::Record->new_from_workflow($record, $self->type);
131
  my $delivery_order = SL::Model::Record->new_from_workflow($record, $self->type, %flags);
123 132
  $self->order($delivery_order);
124 133

  
125 134
  $self->action_add;
......
515 524
  my $to_type = $::form->{to_type};
516 525
  my $to_controller = get_object_name_from_type($to_type);
517 526

  
527
  my %additional_params = ();
528
  if ($::form->{only_selected_items}) {
529
    my $from_item_ids = $::form->{selected_items} || [];
530
    $additional_params{from_item_ids} = $from_item_ids;
531
  }
532

  
518 533
  $self->save();
519 534
  flash_later('info', $self->type_data->text('saved'));
520 535

  
......
524 539
    type       => $to_type,
525 540
    from_id    => $self->order->id,
526 541
    from_type  => $self->order->type,
542
    %additional_params,
527 543
  );
528 544
}
529 545

  
SL/Controller/Order.pm
106 106
  die "No 'from_type' was given." unless ($from_type);
107 107
  die "No 'from_id' was given."   unless ($from_id);
108 108

  
109
  my %flags = ();
110
  if (defined($::form->{from_item_ids})) {
111
    my %use_item = map { $_ => 1 } @{$::form->{from_item_ids}};
112
    $flags{item_filter} = sub {
113
      my ($item) = @_;
114
      return %use_item{$item->id};
115
    }
116
  }
117

  
109 118
  my $record = SL::Model::Record->get_record($from_type, $from_id);
110
  my $order = SL::Model::Record->new_from_workflow($record, $self->type);
119
  my $order = SL::Model::Record->new_from_workflow($record, $self->type, %flags);
111 120
  $self->order($order);
112 121

  
113 122
  if (ref($record) eq 'SL::DB::Reclamation') {
......
772 781
  $self->save();
773 782
  flash_later('info', $self->type_data->text('saved'));
774 783

  
784
  my %additional_params = ();
785
  if ($::form->{only_selected_items}) {
786
    my $from_item_ids = $::form->{selected_items} || [];
787
    $additional_params{from_item_ids} = $from_item_ids;
788
  }
789

  
775 790
  $self->redirect_to(
776 791
    controller => $to_controller,
777 792
    action     => 'add_from_record',
778 793
    type       => $to_type,
779 794
    from_id    => $self->order->id,
780 795
    from_type  => $self->order->type,
796
    %additional_params,
781 797
  );
782 798
}
783 799

  
SL/Controller/Reclamation.pm
120 120
  die "No 'from_type' was given." unless ($from_type);
121 121
  die "No 'from_id' was given."   unless ($from_id);
122 122

  
123
  my %flags = ();
124
  if (defined($::form->{from_item_ids})) {
125
    my %use_item = map { $_ => 1 } @{$::form->{from_item_ids}};
126
    $flags{item_filter} = sub {
127
      my ($item) = @_;
128
      return %use_item{$item->id};
129
    }
130
  }
131

  
123 132
  my $record = SL::Model::Record->get_record($from_type, $from_id);
124
  my $reclamation = SL::Model::Record->new_from_workflow($record, $self->type);
133
  my $reclamation = SL::Model::Record->new_from_workflow($record, $self->type, %flags);
125 134
  $self->reclamation($reclamation);
126 135

  
127 136
  if ($record->type eq SALES_RECLAMATION_TYPE()) { # check for direct delivery
......
504 513
  my $to_type = $::form->{to_type};
505 514
  my $to_controller = get_object_name_from_type($to_type);
506 515

  
516
  my %additional_params = ();
517
  if ($::form->{only_selected_items}) {
518
    my $from_item_ids = $::form->{selected_items} || [];
519
    $additional_params{from_item_ids} = $from_item_ids;
520
  }
521

  
507 522
  $self->save();
508 523
  flash_later('info', t8('The reclamation has been saved'));
509 524

  
......
513 528
    type       => $to_type,
514 529
    from_id    => $self->reclamation->id,
515 530
    from_type  => $self->reclamation->type,
531
    %additional_params,
516 532
  );
517 533
}
518 534

  

Auch abrufbar als: Unified diff