824 |
824 |
);
|
825 |
825 |
}
|
826 |
826 |
|
827 |
|
# workflow from sales order to sales quotation
|
828 |
|
sub action_save_and_sales_quotation {
|
|
827 |
# workflows to all types of this controller
|
|
828 |
sub action_save_and_order_workflow {
|
829 |
829 |
$_[0]->save_and_redirect_to(
|
830 |
|
action => 'sales_or_request_for_quotation',
|
831 |
|
type => $_[0]->type,
|
832 |
|
);
|
833 |
|
}
|
834 |
|
|
835 |
|
# workflow from sales order to sales quotation
|
836 |
|
sub action_save_and_request_for_quotation {
|
837 |
|
$_[0]->save_and_redirect_to(
|
838 |
|
action => 'sales_or_request_for_quotation',
|
839 |
|
type => $_[0]->type,
|
840 |
|
);
|
841 |
|
}
|
842 |
|
|
843 |
|
# workflow from sales quotation to sales order
|
844 |
|
sub action_save_and_sales_order {
|
845 |
|
$_[0]->save_and_redirect_to(
|
846 |
|
action => 'sales_or_purchase_order',
|
847 |
|
type => $_[0]->type,
|
848 |
|
use_shipto => $::form->{use_shipto},
|
849 |
|
);
|
850 |
|
}
|
851 |
|
|
852 |
|
# workflow from rfq to purchase order
|
853 |
|
sub action_save_and_purchase_order {
|
854 |
|
$_[0]->save_and_redirect_to(
|
855 |
|
action => 'sales_or_purchase_order',
|
|
830 |
action => 'order_workflow',
|
856 |
831 |
type => $_[0]->type,
|
|
832 |
to_type => $::form->{to_type},
|
857 |
833 |
use_shipto => $::form->{use_shipto},
|
858 |
834 |
);
|
859 |
835 |
}
|
... | ... | |
868 |
844 |
);
|
869 |
845 |
}
|
870 |
846 |
|
871 |
|
sub action_sales_or_purchase_order {
|
|
847 |
sub action_order_workflow {
|
872 |
848 |
my ($self) = @_;
|
873 |
849 |
|
874 |
850 |
$self->load_order;
|
875 |
851 |
|
876 |
|
my $destination_type = $::form->{type} eq sales_quotation_type() ? sales_order_type()
|
877 |
|
: $::form->{type} eq request_quotation_type() ? purchase_order_type()
|
878 |
|
: $::form->{type} eq purchase_order_type() ? sales_order_type()
|
879 |
|
: $::form->{type} eq sales_order_type() ? purchase_order_type()
|
880 |
|
: '';
|
|
852 |
my $destination_type = $::form->{to_type} ? $::form->{to_type} : '';
|
881 |
853 |
|
882 |
854 |
# check for direct delivery
|
883 |
855 |
# copy shipto in custom shipto (custom shipto will be copied by new_from() in case)
|
... | ... | |
888 |
860 |
}
|
889 |
861 |
|
890 |
862 |
$self->order(SL::DB::Order->new_from($self->order, destination_type => $destination_type));
|
891 |
|
$self->{converted_from_oe_id} = delete $::form->{id};
|
|
863 |
|
|
864 |
# no linked records from order to quotations
|
|
865 |
if (any { $destination_type eq $_ } (sales_quotation_type(), request_quotation_type())) {
|
|
866 |
delete $::form->{id};
|
|
867 |
delete $::form->{$_} for qw(converted_from_oe_id converted_from_orderitems_ids);
|
|
868 |
} else {
|
|
869 |
$self->{converted_from_oe_id} = delete $::form->{id};
|
|
870 |
}
|
892 |
871 |
|
893 |
872 |
# set item ids to new fake id, to identify them as new items
|
894 |
873 |
foreach my $item (@{$self->order->items_sorted}) {
|
... | ... | |
926 |
905 |
);
|
927 |
906 |
}
|
928 |
907 |
|
929 |
|
sub action_sales_or_request_for_quotation {
|
930 |
|
my ($self) = @_;
|
931 |
|
|
932 |
|
$self->load_order;
|
933 |
|
|
934 |
|
my $destination_type = $::form->{type} eq sales_order_type() ? sales_quotation_type() : request_quotation_type();
|
935 |
|
|
936 |
|
$self->order(SL::DB::Order->new_from($self->order, destination_type => $destination_type));
|
937 |
|
delete $::form->{id};
|
938 |
|
|
939 |
|
# no linked records from order to quotations
|
940 |
|
delete $::form->{$_} for qw(converted_from_oe_id converted_from_orderitems_ids);
|
941 |
|
|
942 |
|
# set item ids to new fake id, to identify them as new items
|
943 |
|
foreach my $item (@{$self->order->items_sorted}) {
|
944 |
|
$item->{new_fake_id} = join('_', 'new', Time::HiRes::gettimeofday(), int rand 1000000000000);
|
945 |
|
}
|
946 |
|
|
947 |
|
# change form type
|
948 |
|
$::form->{type} = $destination_type;
|
949 |
|
$self->type($self->init_type);
|
950 |
|
$self->cv ($self->init_cv);
|
951 |
|
$self->check_auth;
|
952 |
|
|
953 |
|
$self->recalc();
|
954 |
|
$self->get_unalterable_data();
|
955 |
|
$self->pre_render();
|
956 |
|
|
957 |
|
# trigger rendering values for second row as hidden, because they
|
958 |
|
# are loaded only on demand. So we need to keep the values from the
|
959 |
|
# source.
|
960 |
|
$_->{render_second_row} = 1 for @{ $self->order->items_sorted };
|
961 |
|
|
962 |
|
$self->render(
|
963 |
|
'order/form',
|
964 |
|
title => $self->get_title_for('edit'),
|
965 |
|
%{$self->{template_args}}
|
966 |
|
);
|
967 |
|
}
|
968 |
|
|
969 |
908 |
# set form elements in respect to a changed customer or vendor
|
970 |
909 |
#
|
971 |
910 |
# This action is called on an change of the customer/vendor picker.
|
... | ... | |
2344 |
2283 |
],
|
2345 |
2284 |
action => [
|
2346 |
2285 |
t8('Save and Quotation'),
|
2347 |
|
call => [ 'kivi.submit_ajax_form', $self->url_for(action => "save_and_sales_quotation"), '#order_form' ],
|
|
2286 |
call => [ 'kivi.submit_ajax_form', $self->url_for(action => "save_and_order_workflow", to_type => sales_quotation_type()), '#order_form' ],
|
2348 |
2287 |
checks => [ @req_trans_cost_art, @req_cusordnumber ],
|
2349 |
2288 |
only_if => (any { $self->type eq $_ } (sales_order_type())),
|
2350 |
2289 |
disabled => !$may_edit_create ? t8('You do not have the permissions to access this function.') : undef,
|
2351 |
2290 |
],
|
2352 |
2291 |
action => [
|
2353 |
2292 |
t8('Save and RFQ'),
|
2354 |
|
call => [ 'kivi.submit_ajax_form', $self->url_for(action => "save_and_request_for_quotation"), '#order_form' ],
|
|
2293 |
call => [ 'kivi.submit_ajax_form', $self->url_for(action => "save_and_order_workflow", to_type => request_quotation_type()), '#order_form' ],
|
2355 |
2294 |
only_if => (any { $self->type eq $_ } (purchase_order_type())),
|
2356 |
2295 |
disabled => !$may_edit_create ? t8('You do not have the permissions to access this function.') : undef,
|
2357 |
2296 |
],
|
2358 |
2297 |
action => [
|
2359 |
2298 |
t8('Save and Sales Order'),
|
2360 |
|
call => [ 'kivi.submit_ajax_form', $self->url_for(action => "save_and_sales_order"), '#order_form' ],
|
|
2299 |
call => [ 'kivi.submit_ajax_form', $self->url_for(action => "save_and_order_workflow", to_type => sales_order_type()), '#order_form' ],
|
2361 |
2300 |
checks => [ @req_trans_cost_art ],
|
2362 |
2301 |
only_if => (any { $self->type eq $_ } (sales_quotation_type(), purchase_order_type())),
|
2363 |
2302 |
disabled => !$may_edit_create ? t8('You do not have the permissions to access this function.') : undef,
|
2364 |
2303 |
],
|
2365 |
2304 |
action => [
|
2366 |
2305 |
t8('Save and Purchase Order'),
|
2367 |
|
call => [ 'kivi.Order.purchase_order_check_for_direct_delivery' ],
|
|
2306 |
call => [ 'kivi.Order.purchase_order_check_for_direct_delivery', { to_type => purchase_order_type() } ],
|
2368 |
2307 |
checks => [ @req_trans_cost_art, @req_cusordnumber ],
|
2369 |
2308 |
only_if => (any { $self->type eq $_ } (sales_order_type(), request_quotation_type())),
|
2370 |
2309 |
disabled => !$may_edit_create ? t8('You do not have the permissions to access this function.') : undef,
|
Auftrags-Controller: Workflows zum Controller selber vereinheitlicht
Es gibt nun eine Methode für die Worklows und das Workflow-Ziel
wird übergeben.