X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FController%2FRequirementSpec.pm;h=6f5bf21e3b5aee935bc74404ad436183e2195ba7;hb=24bb9ded832e2ed1054973fd025cfa6c5fec021e;hp=d70cd2d947045bd953899e0ffced8996a9b73712;hpb=953f63b08d7894b6dea55f8361e983ba09e6e4fb;p=kivitendo-erp.git diff --git a/SL/Controller/RequirementSpec.pm b/SL/Controller/RequirementSpec.pm index d70cd2d94..6f5bf21e3 100644 --- a/SL/Controller/RequirementSpec.pm +++ b/SL/Controller/RequirementSpec.pm @@ -55,7 +55,7 @@ sub action_list { $self->_setup_search_action_bar; $self->prepare_report; - $self->report_generator_list_objects(report => $self->{report}, objects => $self->models->get, action_bar => 1); + $self->report_generator_list_objects(report => $self->{report}, objects => $self->models->get); } sub action_new { @@ -325,7 +325,7 @@ sub setup { $::auth->assert('requirement_spec_edit'); $::request->{layout}->use_stylesheet("${_}.css") for qw(jquery.contextMenu requirement_spec); - $::request->{layout}->use_javascript("${_}.js") for qw(jquery.jstree jquery/jquery.contextMenu jquery/jquery.hotkeys requirement_spec ckeditor/ckeditor ckeditor/adapters/jquery kivi.Part.js autocomplete_customer); + $::request->{layout}->use_javascript("${_}.js") for qw(jquery.jstree jquery/jquery.contextMenu jquery/jquery.hotkeys requirement_spec ckeditor/ckeditor ckeditor/adapters/jquery kivi.Part autocomplete_customer); $self->init_visible_section; return 1; @@ -383,10 +383,11 @@ sub init_include_cvars { # sub create_or_update { - my $self = shift; - my $is_new = !$self->requirement_spec->id; - my $params = delete($::form->{requirement_spec}) || { }; - my $cvars = delete($::form->{cvars}) || { }; + my $self = shift; + my $is_new = !$self->requirement_spec->id; + my $previous_customer_id = $self->requirement_spec->customer_id; + my $params = delete($::form->{requirement_spec}) || { }; + my $cvars = delete($::form->{cvars}) || { }; # Forcefully make it clear to Rose which custom_variables exist (or don't), so that the ones added with »add_custom_variables« are visible when calling »custom_variables«. if ($is_new) { @@ -425,6 +426,18 @@ sub create_or_update { $self->requirement_spec($self->copy_source->create_copy(%{ $params })); } else { $self->requirement_spec->save(cascade => 1); + + # If the current requirement spec has versions and the + # customer's been changed, then the customer of all the versions + # has to be changed, too. + if ( !$is_new + && !$self->requirement_spec->is_template + && ($previous_customer_id != $self->requirement_spec->customer_id)) { + SL::DB::Manager::RequirementSpec->update_all( + set => { customer_id => $self->requirement_spec->customer_id }, + where => [ working_copy_id => $self->requirement_spec->id ], + ); + } } 1; })) {