Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 4cff1777

Von Tamino Steinert vor etwa 1 Jahr hinzugefügt

  • ID 4cff1777d726529cc833c5b0cf579a86ed008847
  • Vorgänger 7da8047a
  • Nachfolger c8e91c4e

Records: Workflow-Methoden angepasst und vereinheitlicht

Unterschiede anzeigen:

SL/Controller/Order.pm
35 35
use SL::DB::ValidityToken;
36 36
use SL::DB::Helper::RecordLink qw(set_record_link_conversions RECORD_ID RECORD_ITEM_ID);
37 37
use SL::DB::Helper::TypeDataProxy;
38
use SL::DB::Helper::Record qw(get_object_name_from_type get_class_from_type);
38 39
use SL::Model::Record;
39 40
use SL::DB::Order::TypeData qw(:types);
40 41
use SL::DB::Reclamation::TypeData qw(:types);
......
96 97
  );
97 98
}
98 99

  
99
sub action_add_from_reclamation {
100
sub action_add_from_record {
100 101
  my ($self) = @_;
102
  my $from_type = $::form->{from_type};
103
  my $from_id   = $::form->{from_id};
101 104

  
102
  my $reclamation = SL::DB::Reclamation->new(id => $::form->{from_id})->load;
103
  my %params;
104
  my $target_type = $reclamation->is_sales ? SALES_ORDER_TYPE()
105
                                           : PURCHASE_ORDER_TYPE();
106
  my $order = SL::Model::Record->new_from_workflow($reclamation, $target_type);
107

  
108
  $self->{converted_from_reclamation_id}       = $order->{ RECORD_ID()      };
109
  $_   ->{converted_from_reclamation_items_id} = $_    ->{ RECORD_ITEM_ID() } for @{ $order->items_sorted };
105
  unless ($from_type && $from_id) {
106
    $self->js->flash('error', t8("Can't create new record."));
107
    $self->js->flash('error', t8("No 'from_type' was given.")) unless ($from_type);
108
    $self->js->flash('error', t8("No 'from_id' was given."))   unless ($from_id);
109
    return $self->js->render();
110
  }
110 111

  
112
  my $record = SL::Model::Record->get_record($from_type, $from_id);
113
  my $order = SL::Model::Record->new_from_workflow($record, $self->type);
111 114
  $self->order($order);
112 115

  
116
  if (ref($record) eq 'SL::DB::Reclamation') {
117
    $self->{converted_from_reclamation_id}       = $order->{ RECORD_ID()      };
118
    $_   ->{converted_from_reclamation_items_id} = $_    ->{ RECORD_ITEM_ID() } for @{ $order->items_sorted };
119
  }
120

  
121

  
113 122
  $self->recalc();
114 123
  $self->pre_render();
115 124

  
......
119 128

  
120 129
  $self->render(
121 130
    'order/form',
122
    title => $self->type_data->text('edit'),
131
    title => $self->type_data->text('add'),
123 132
    %{$self->{template_args}}
124 133
  );
125 134
}
......
765 774
  $_[0]->render(\ !!$has_active_periodic_invoices, { type => 'text' });
766 775
}
767 776

  
777
sub action_save_and_new_record {
778
  my ($self) = @_;
779
  my $to_type = $::form->{to_type};
780
  my $to_controller = get_object_name_from_type($to_type);
781

  
782
  $self->save();
783
  flash_later('info', $self->type_data->text('saved'));
784

  
785
  $self->redirect_to(
786
    controller => $to_controller,
787
    action     => 'add_from_record',
788
    type       => $to_type,
789
    from_id    => $self->order->id,
790
    from_type  => $self->order->type,
791
  );
792
}
793

  
768 794
# save the order and redirect to the frontend subroutine for a new
769 795
# delivery order
770 796
sub action_save_and_delivery_order {
......
783 809
  );
784 810
}
785 811

  
786
sub action_save_and_supplier_delivery_order {
787
  my ($self) = @_;
788

  
789
  $self->save_and_redirect_to(
790
    controller => 'controller.pl',
791
    action     => 'DeliveryOrder/add_from_order',
792
    type       => 'supplier_delivery_order',
793
  );
794
}
795

  
796
# save the order and redirect to the frontend subroutine for a new reclamation
797
sub action_save_and_reclamation {
798
  my ($self) = @_;
799

  
800
  # can't use save_and_redirect_to, because id is set!
801
  $self->save();
802

  
803
  my $to_type = $self->order->is_sales ? SALES_RECLAMATION_TYPE()
804
                                       : PURCHASE_RECLAMATION_TYPE();
805
  $self->redirect_to(
806
    controller => 'Reclamation',
807
    action     => 'add_from_order',
808
    type       => $to_type,
809
    from_id    => $self->order->id,
810
  );
811
}
812

  
813 812
# save the order and redirect to the frontend subroutine for a new
814 813
# invoice
815 814
sub action_save_and_invoice {

Auch abrufbar als: Unified diff