X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/e142cf7d27b16c1cab36fa28d4fca6e81e3ed816..8ef7fee7f6007ddf758de0e74839da386c3446f3:/SL/Controller/RequirementSpecOrder.pm diff --git a/SL/Controller/RequirementSpecOrder.pm b/SL/Controller/RequirementSpecOrder.pm index e444a7cc9..16303201c 100644 --- a/SL/Controller/RequirementSpecOrder.pm +++ b/SL/Controller/RequirementSpecOrder.pm @@ -22,7 +22,7 @@ use constant TAB_ID => 'ui-tabs-4'; use Rose::Object::MakeMethods::Generic ( scalar => [ qw(parts) ], - 'scalar --get_set_init' => [ qw(requirement_spec rs_order js h_unit_name all_customers all_parts) ], + 'scalar --get_set_init' => [ qw(requirement_spec rs_order js h_unit_name all_customers all_parts_time_unit) ], ); __PACKAGE__->run_before('setup'); @@ -40,6 +40,10 @@ sub action_list { sub action_new { my ($self) = @_; + if (!@{ $self->all_parts_time_unit }) { + return $self->js->flash('error', t8('This function requires the presence of articles with a time-based unit such as "h" or "min".'))->render($self); + } + my $html = $self->render('requirement_spec_order/new', { output => 0 }, make_part_title => sub { $_[0]->partnumber . ' ' . $_[0]->description }); $self->js->html('#' . TAB_ID(), $html) ->render($self); @@ -139,6 +143,10 @@ sub action_do_update { sub action_edit_assignment { my ($self) = @_; + if (!@{ $self->all_parts_time_unit }) { + return $self->js->flash('error', t8('This function requires the presence of articles with a time-based unit such as "h" or "min".'))->render($self); + } + my $html = $self->render('requirement_spec_order/edit_assignment', { output => 0 }, make_part_title => sub { $_[0]->partnumber . ' ' . $_[0]->description }); $self->js->html('#' . TAB_ID(), $html) ->render($self); @@ -201,10 +209,19 @@ sub init_js { } sub init_all_customers { SL::DB::Manager::Customer->get_all_sorted } -sub init_all_parts { SL::DB::Manager::Part->get_all_sorted } sub init_h_unit_name { first { SL::DB::Manager::Unit->find_by(name => $_) } qw(Std h Stunde) }; sub init_rs_order { SL::DB::RequirementSpecOrder->new(id => $::form->{rs_order_id})->load }; +sub init_all_parts_time_unit { + my ($self) = @_; + + return [] unless $self->h_unit_name; + + my @convertible_unit_names = map { $_->name } @{ SL::DB::Manager::Unit->find_by(name => $self->h_unit_name)->convertible_units }; + + return SL::DB::Manager::Part->get_all_sorted(where => [ unit => \@convertible_unit_names ]); +} + # # helpers #