X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=SL%2FController%2FPart.pm;h=d27304029366ed90c63c67330eaa2919e142ff42;hb=51b8947817754d49df0694529a5b1b93d180baf3;hp=461090bd9d99ce3b5b3f29fcf65b7786ee8f0742;hpb=065cf8d539872ce878b73d348a61c41b48579245;p=kivitendo-erp.git diff --git a/SL/Controller/Part.pm b/SL/Controller/Part.pm index 461090bd9..d27304029 100644 --- a/SL/Controller/Part.pm +++ b/SL/Controller/Part.pm @@ -6,6 +6,7 @@ use parent qw(SL::Controller::Base); use Clone qw(clone); use SL::DB::Part; use SL::DB::PartsGroup; +use SL::DB::Shop; use SL::Controller::Helper::GetModels; use SL::Locale::String qw(t8); use SL::JSON; @@ -21,7 +22,7 @@ use Carp; use Rose::Object::MakeMethods::Generic ( 'scalar --get_set_init' => [ qw(parts models part p warehouses multi_items_models - makemodels + makemodels shops_not_assigned orphaned assortment assortment_items assembly assembly_items all_pricegroups all_translations all_partsgroups all_units @@ -42,7 +43,6 @@ __PACKAGE__->run_before('check_part_id', only => [ qw(edit delete) ]); sub action_add_part { my ($self, %params) = @_; - $::form->{callback} = $self->url_for(action => 'add_part') unless $::form->{callback}; $self->part( SL::DB::Part->new_part ); $self->add; }; @@ -50,7 +50,6 @@ sub action_add_part { sub action_add_service { my ($self, %params) = @_; - $::form->{callback} = $self->url_for(action => 'add_service') unless $::form->{callback}; $self->part( SL::DB::Part->new_service ); $self->add; }; @@ -58,7 +57,6 @@ sub action_add_service { sub action_add_assembly { my ($self, %params) = @_; - $::form->{callback} = $self->url_for(action => 'add_assembly') unless $::form->{callback}; $self->part( SL::DB::Part->new_assembly ); $self->add; }; @@ -66,7 +64,6 @@ sub action_add_assembly { sub action_add_assortment { my ($self, %params) = @_; - $::form->{callback} = $self->url_for(action => 'add_assortment') unless $::form->{callback}; $self->part( SL::DB::Part->new_assortment ); $self->add; }; @@ -194,11 +191,7 @@ sub action_delete { if ( $::form->{callback} ) { $self->redirect_to($::form->unescape($::form->{callback})); } else { - my @redirect_params = ( - controller => 'controller.pl', - action => 'LoginScreen/user_login' - ); - $self->redirect_to(@redirect_params); + $self->redirect_to(controller => 'ic.pl', action => 'search', searchitems => 'article'); } } @@ -644,7 +637,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); + $::request->layout->use_javascript("${_}.js") for qw(kivi.Part kivi.File kivi.PriceRule ckeditor/ckeditor ckeditor/adapters/jquery kivi.ShopPart); $::request->layout->add_javascripts_inline("\$(function(){kivi.PriceRule.load_price_rules_for_part(@{[ $self->part->id ]})});") if $self->part->id; } @@ -811,7 +804,7 @@ sub init_part { # used by edit, save, delete and add if ( $::form->{part}{id} ) { - return SL::DB::Part->new(id => $::form->{part}{id})->load(with => [ qw(makemodels prices translations partsgroup) ]); + return SL::DB::Part->new(id => $::form->{part}{id})->load(with => [ qw(makemodels prices translations partsgroup shop_parts shop_parts.shop) ]); } else { die "part_type missing" unless $::form->{part}{part_type}; return SL::DB::Part->new(part_type => $::form->{part}{part_type}); @@ -820,7 +813,7 @@ sub init_part { sub init_orphaned { my ($self) = @_; - return $self->part->orphaned; + return $::auth->assert('assembly_edit', 1) // $self->part->orphaned; } sub init_models { @@ -932,6 +925,18 @@ sub init_all_buchungsgruppen { } } +sub init_shops_not_assigned { + my ($self) = @_; + + my @used_shop_ids = map { $_->shop->id } @{ $self->part->shop_parts }; + if ( @used_shop_ids ) { + return SL::DB::Manager::Shop->get_all( query => [ obsolete => 0, '!id' => \@used_shop_ids ], sort_by => 'sortkey' ); + } + else { + return SL::DB::Manager::Shop->get_all( query => [ obsolete => 0 ], sort_by => 'sortkey' ); + } +} + sub init_all_units { my ($self) = @_; if ( $self->part->orphaned ) {