Revision 77e57dde
Von Tamino Steinert vor mehr als 1 Jahr hinzugefügt
SL/Controller/Order.pm | ||
---|---|---|
34 | 34 |
use SL::DB::ValidityToken; |
35 | 35 |
use SL::DB::Helper::RecordLink qw(set_record_link_conversions RECORD_ID RECORD_ITEM_ID); |
36 | 36 |
use SL::DB::Helper::TypeDataProxy; |
37 |
use SL::DB::Helper::Record qw(get_object_name_from_type get_class_from_type); |
|
37 | 38 |
use SL::Model::Record; |
38 | 39 |
use SL::DB::Order::TypeData qw(:types); |
39 | 40 |
use SL::DB::Reclamation::TypeData qw(:types); |
... | ... | |
95 | 96 |
); |
96 | 97 |
} |
97 | 98 |
|
98 |
sub action_add_from_reclamation {
|
|
99 |
sub action_add_from_record {
|
|
99 | 100 |
my ($self) = @_; |
101 |
my $from_type = $::form->{from_type}; |
|
102 |
my $from_id = $::form->{from_id}; |
|
100 | 103 |
|
101 |
my $reclamation = SL::DB::Reclamation->new(id => $::form->{from_id})->load; |
|
102 |
my %params; |
|
103 |
my $target_type = $reclamation->is_sales ? SALES_ORDER_TYPE() |
|
104 |
: PURCHASE_ORDER_TYPE(); |
|
105 |
my $order = SL::Model::Record->new_from_workflow($reclamation, $target_type); |
|
106 |
|
|
107 |
$self->{converted_from_reclamation_id} = $order->{ RECORD_ID() }; |
|
108 |
$_ ->{converted_from_reclamation_items_id} = $_ ->{ RECORD_ITEM_ID() } for @{ $order->items_sorted }; |
|
104 |
unless ($from_type && $from_id) { |
|
105 |
$self->js->flash('error', t8("Can't create new record.")); |
|
106 |
$self->js->flash('error', t8("No 'from_type' was given.")) unless ($from_type); |
|
107 |
$self->js->flash('error', t8("No 'from_id' was given.")) unless ($from_id); |
|
108 |
return $self->js->render(); |
|
109 |
} |
|
109 | 110 |
|
111 |
my $record = SL::Model::Record->get_record($from_type, $from_id); |
|
112 |
my $order = SL::Model::Record->new_from_workflow($record, $self->type); |
|
110 | 113 |
$self->order($order); |
111 | 114 |
|
115 |
if (ref($record) eq 'SL::DB::Reclamation') { |
|
116 |
$self->{converted_from_reclamation_id} = $order->{ RECORD_ID() }; |
|
117 |
$_ ->{converted_from_reclamation_items_id} = $_ ->{ RECORD_ITEM_ID() } for @{ $order->items_sorted }; |
|
118 |
} |
|
119 |
|
|
120 |
|
|
112 | 121 |
$self->recalc(); |
113 | 122 |
$self->pre_render(); |
114 | 123 |
|
... | ... | |
118 | 127 |
|
119 | 128 |
$self->render( |
120 | 129 |
'order/form', |
121 |
title => $self->type_data->text('edit'),
|
|
130 |
title => $self->type_data->text('add'),
|
|
122 | 131 |
%{$self->{template_args}} |
123 | 132 |
); |
124 | 133 |
} |
... | ... | |
753 | 762 |
$_[0]->render(\ !!$has_active_periodic_invoices, { type => 'text' }); |
754 | 763 |
} |
755 | 764 |
|
756 |
# save the order and redirect to the frontend subroutine for a new |
|
757 |
# delivery order |
|
758 |
sub action_save_and_delivery_order { |
|
765 |
sub action_save_and_new_record { |
|
759 | 766 |
my ($self) = @_; |
767 |
my $to_type = $::form->{to_type}; |
|
768 |
my $to_controller = get_object_name_from_type($to_type); |
|
760 | 769 |
|
761 |
$self->save_and_redirect_to( |
|
762 |
controller => 'oe.pl', |
|
763 |
action => 'oe_delivery_order_from_order', |
|
764 |
); |
|
765 |
} |
|
766 |
|
|
767 |
sub action_save_and_supplier_delivery_order { |
|
768 |
my ($self) = @_; |
|
770 |
$self->save(); |
|
771 |
flash_later('info', $self->type_data->text('saved')); |
|
769 | 772 |
|
770 |
$self->save_and_redirect_to( |
|
771 |
controller => 'controller.pl', |
|
772 |
action => 'DeliveryOrder/add_from_order', |
|
773 |
type => 'supplier_delivery_order', |
|
773 |
$self->redirect_to( |
|
774 |
controller => $to_controller, |
|
775 |
action => 'add_from_record', |
|
776 |
type => $to_type, |
|
777 |
from_id => $self->order->id, |
|
778 |
from_type => $self->order->type, |
|
774 | 779 |
); |
775 | 780 |
} |
776 | 781 |
|
777 |
# save the order and redirect to the frontend subroutine for a new reclamation |
|
778 |
sub action_save_and_reclamation { |
|
782 |
# save the order and redirect to the frontend subroutine for a new |
|
783 |
# delivery order |
|
784 |
sub action_save_and_delivery_order { |
|
779 | 785 |
my ($self) = @_; |
780 | 786 |
|
781 |
# can't use save_and_redirect_to, because id is set! |
|
782 |
$self->save(); |
|
783 |
|
|
784 |
my $to_type = $self->order->is_sales ? SALES_RECLAMATION_TYPE() |
|
785 |
: PURCHASE_RECLAMATION_TYPE(); |
|
786 |
$self->redirect_to( |
|
787 |
controller => 'Reclamation', |
|
788 |
action => 'add_from_order', |
|
789 |
type => $to_type, |
|
790 |
from_id => $self->order->id, |
|
787 |
$self->save_and_redirect_to( |
|
788 |
controller => 'oe.pl', |
|
789 |
action => 'oe_delivery_order_from_order', |
|
791 | 790 |
); |
792 | 791 |
} |
793 | 792 |
|
Auch abrufbar als: Unified diff
Records: Workflow-Methoden angepasst und vereinheitlicht