X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FController%2FPart.pm;h=aae4e531e016e0d8da56f6bd0ff5447c1bb7fad5;hb=2b2a37fd95a5cae44a8c6862e79f86d2cbc2a189;hp=3f7409e8bb14a010d83c398f0fd7c9a80c2542fa;hpb=d1809c2258dc72d73a6aaf9392bdf290fc5ee289;p=kivitendo-erp.git diff --git a/SL/Controller/Part.pm b/SL/Controller/Part.pm index 3f7409e8b..aae4e531e 100644 --- a/SL/Controller/Part.pm +++ b/SL/Controller/Part.pm @@ -41,6 +41,9 @@ use Rose::Object::MakeMethods::Generic ( __PACKAGE__->run_before(sub { $::auth->assert('part_service_assembly_edit') }, except => [ qw(ajax_autocomplete part_picker_search part_picker_result) ]); +__PACKAGE__->run_before(sub { $::auth->assert('developer') }, + only => [ qw(test_page) ]); + __PACKAGE__->run_before('check_part_id', only => [ qw(edit delete) ]); # actions for editing parts @@ -157,6 +160,26 @@ sub action_save { } } +sub action_save_and_purchase_order { + my ($self) = @_; + + my $session_value; + if (1 == scalar @{$self->part->makemodels}) { + my $prepared_form = Form->new(''); + $prepared_form->{vendor_id} = $self->part->makemodels->[0]->make; + $session_value = $::auth->save_form_in_session(form => $prepared_form); + } + + $::form->{callback} = $self->url_for( + controller => 'Order', + action => 'return_from_create_part', + type => 'purchase_order', + previousform => $session_value, + ); + + $self->_run_action('save'); +} + sub action_abort { my ($self) = @_; @@ -706,7 +729,7 @@ sub add { sub _set_javascript { my ($self) = @_; - $::request->layout->use_javascript("${_}.js") for qw(kivi.Part kivi.File kivi.PriceRule ckeditor/ckeditor ckeditor/adapters/jquery kivi.ShopPart); + $::request->layout->use_javascript("${_}.js") for qw(kivi.Part kivi.File kivi.PriceRule ckeditor/ckeditor ckeditor/adapters/jquery kivi.ShopPart kivi.Validator); $::request->layout->add_javascripts_inline("\$(function(){kivi.PriceRule.load_price_rules_for_part(@{[ $self->part->id ]})});") if $self->part->id; } @@ -1097,7 +1120,7 @@ sub init_all_price_factors { } sub init_all_pricegroups { - SL::DB::Manager::Pricegroup->get_all_sorted; + SL::DB::Manager::Pricegroup->get_all_sorted(query => [ obsolete => 0 ]); } # model used to filter/display the parts in the multi-items dialog @@ -1332,6 +1355,7 @@ sub _setup_form_action_bar { t8('Save'), call => [ 'kivi.Part.save' ], disabled => !$may_edit ? t8('You do not have the permissions to access this function.') : undef, + checks => ['kivi.validate_form'], ], action => [ t8('Use as new'), @@ -1342,10 +1366,24 @@ sub _setup_form_action_bar { ], ], # end of combobox "Save" + combobox => [ + action => [ t8('Workflow') ], + action => [ + t8('Save and Purchase Order'), + submit => [ '#ic', { action => "Part/save_and_purchase_order" } ], + checks => ['kivi.validate_form'], + disabled => !$self->part->id ? t8('The object has not been saved yet.') + : !$may_edit ? t8('You do not have the permissions to access this function.') + : !$::auth->assert('purchase_order_edit', 'may fail') ? t8('You do not have the permissions to access this function.') + : undef, + only_if => !$::form->{inline_create}, + ], + ], + action => [ t8('Abort'), submit => [ '#ic', { action => "Part/abort" } ], - only_if => !!$::form->{show_abort}, + only_if => !!$::form->{inline_create}, ], action => [