Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 854d733e

Von Tamino Steinert vor etwa 1 Jahr hinzugefügt

  • ID 854d733e4adfa524aeaf748b1c1c1f1645fbb91f
  • Vorgänger 1c934069
  • Nachfolger 45823f3f

Records: Workflow-Methoden angepasst und vereinheitlicht

Unterschiede anzeigen:

SL/Controller/DeliveryOrder.pm
33 33
use SL::DB::Warehouse;
34 34
use SL::DB::Helper::RecordLink qw(set_record_link_conversions);
35 35
use SL::DB::Helper::TypeDataProxy;
36
use SL::DB::Helper::Record qw(get_object_name_from_type get_class_from_type);
36 37
use SL::DB::DeliveryOrder;
37 38
use SL::DB::DeliveryOrder::TypeData qw(:types);
38 39
use SL::DB::Order::TypeData qw(:types);
......
98 99
  );
99 100
}
100 101

  
101
sub action_add_from_order {
102
sub action_add_from_record {
102 103
  my ($self) = @_;
103
  # this interfers with init_order
104
  $self->{converted_from_oe_id} = delete $::form->{id};
105

  
106
  $self->type_data->validate;
107

  
108
  my $order = SL::DB::Order->new(id => $self->{converted_from_oe_id})->load;
109

  
110
  my $target_type = $::form->{type};
111
  my $delivery_order = SL::Model::Record->new_from_workflow($order, $target_type);
112
  $self->order($delivery_order);
104
  my $from_type = $::form->{from_type};
105
  my $from_id   = $::form->{from_id};
113 106

  
114
  $self->action_add;
115
}
116

  
117
sub action_add_from_reclamation {
118
  my ($self) = @_;
107
  unless ($from_type && $from_id) {
108
    $self->js->flash('error', t8("Can't create new record."));
109
    $self->js->flash('error', t8("No 'from_type' was given.")) unless ($from_type);
110
    $self->js->flash('error', t8("No 'from_id' was given."))   unless ($from_id);
111
    return $self->js->render();
112
  }
119 113

  
120
  my $reclamation = SL::DB::Reclamation->new(id => $::form->{from_id})->load;
121
  my $target_type = $reclamation->is_sales ? 'rma_delivery_order'
122
                                           : 'supplier_delivery_order';
123
  my $delivery_order = SL::Model::Record->new_from_workflow($reclamation, $target_type);
124
  $self->{converted_from_reclamation_id} = $::form->{from_id};
114
  my $record = SL::Model::Record->get_record($from_type, $from_id);
115
  my $delivery_order = SL::Model::Record->new_from_workflow($record, $self->type);
125 116
  $self->order($delivery_order);
126 117

  
127 118
  $self->action_add;
......
507 498
  $self->redirect_to(@redirect_params);
508 499
}
509 500

  
501
sub action_save_and_new_record {
502
  my ($self) = @_;
503
  my $to_type = $::form->{to_type};
504
  my $to_controller = get_object_name_from_type($to_type);
505

  
506
  $self->save();
507
  flash_later('info', $self->type_data->text('saved'));
508

  
509
  $self->redirect_to(
510
    controller => $to_controller,
511
    action     => 'add_from_record',
512
    type       => $to_type,
513
    from_id    => $self->order->id,
514
    from_type  => $self->order->type,
515
  );
516
}
517

  
510 518
# save the order and redirect to the frontend subroutine for a new
511 519
# delivery order
512 520
sub action_save_and_delivery_order {

Auch abrufbar als: Unified diff