From 8ef7fee7f6007ddf758de0e74839da386c3446f3 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Fri, 12 Jul 2013 08:47:53 +0200 Subject: [PATCH] =?utf8?q?Pflichtenhefte=20->=20Angebote/Auftr=C3=A4ge:=20?= =?utf8?q?nur=20Artikel=20mit=20Zeit-basierenden=20Einheiten?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/Controller/ClientConfig.pm | 13 ++++++++++-- SL/Controller/RequirementSpecOrder.pm | 21 +++++++++++++++++-- locale/de/all | 1 + .../webpages/client_config/_features.html | 2 +- .../_assignment_form.html | 4 ++-- 5 files changed, 34 insertions(+), 7 deletions(-) diff --git a/SL/Controller/ClientConfig.pm b/SL/Controller/ClientConfig.pm index e056927fc..53f59fe10 100644 --- a/SL/Controller/ClientConfig.pm +++ b/SL/Controller/ClientConfig.pm @@ -19,7 +19,8 @@ use SL::Template; __PACKAGE__->run_before('check_auth'); use Rose::Object::MakeMethods::Generic ( - 'scalar --get_set_init' => [ qw(defaults all_warehouses all_weightunits all_languages all_currencies all_templates all_parts posting_options payment_options accounting_options inventory_options profit_options accounts balance_startdate_method_options) ], + 'scalar --get_set_init' => [ qw(defaults all_warehouses all_weightunits all_languages all_currencies all_templates all_parts_time_unit + posting_options payment_options accounting_options inventory_options profit_options accounts balance_startdate_method_options) ], ); sub action_edit { @@ -140,10 +141,18 @@ sub init_defaults { SL::DB::Default->get sub init_all_warehouses { SL::DB::Manager::Warehouse->get_all_sorted } sub init_all_languages { SL::DB::Manager::Language->get_all_sorted } sub init_all_currencies { SL::DB::Manager::Currency->get_all_sorted } -sub init_all_parts { SL::DB::Manager::Part->get_all_sorted } sub init_all_weightunits { my $unit = SL::DB::Manager::Unit->find_by(name => 'kg'); $unit ? $unit->convertible_units : [] } sub init_all_templates { +{ SL::Template->available_templates } } +sub init_all_parts_time_unit { + my $h_unit = first { $_ } map { SL::DB::Manager::Unit->find_by(name => $_) } qw(Std h Stunde); + return [] unless $h_unit; + + my @convertible_unit_names = map { $_->name } @{ $h_unit->convertible_units }; + + return SL::DB::Manager::Part->get_all_sorted(where => [ unit => \@convertible_unit_names ]); +} + sub init_posting_options { [ { title => t8("never"), value => 0 }, { title => t8("every time"), value => 1 }, 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 # diff --git a/locale/de/all b/locale/de/all index 71e9ba0ee..f9124012e 100755 --- a/locale/de/all +++ b/locale/de/all @@ -2511,6 +2511,7 @@ $self->{texts} = { 'This could have happened for two reasons:' => 'Dies kann aus zwei Gründen geschehen sein:', 'This customer number is already in use.' => 'Diese Kundennummer wird bereits verwendet.', 'This feature especially prevents mistakes by mixing up prior tax and sales tax.' => 'Dieses Feature vermeidet insbesondere Verwechslungen von Umsatz- und Vorsteuer.', + 'This function requires the presence of articles with a time-based unit such as "h" or "min".' => 'Für diese Funktion mussen Artikel mit einer Zeit-basierten Einheit wie "Std" oder "min" existieren.', 'This group is valid for the following clients' => 'Diese Gruppe ist für die folgenden Mandanten gültig', 'This has been changed in this version, therefore please change the "old" bins to some real warehouse bins.' => 'Das wurde in dieser Version umgestellt, bitte ändern Sie die Freitext-Lagerplätze auf vorhandene Lagerplätze.', 'This has been changed in this version.' => 'Ab dieser Version ist dies nicht mehr so.', diff --git a/templates/webpages/client_config/_features.html b/templates/webpages/client_config/_features.html index 2576ebc06..f809c452c 100644 --- a/templates/webpages/client_config/_features.html +++ b/templates/webpages/client_config/_features.html @@ -61,7 +61,7 @@ [% LxERP.t8('Default article for converting into quotations and orders') %] - [% L.select_tag('defaults.requirement_spec_section_order_part_id', SELF.all_parts, default=SELF.defaults.requirement_spec_section_order_part_id, with_empty=1, title_sub=\make_part_title) %] + [% L.select_tag('defaults.requirement_spec_section_order_part_id', SELF.all_parts_time_unit, default=SELF.defaults.requirement_spec_section_order_part_id, with_empty=1, title_sub=\make_part_title) %] [% LxERP.t8('When converting a requirement spec into a quotation or an oder each section gets converted into a line position in the new record. This is the article used by default for this conversion.') %] diff --git a/templates/webpages/requirement_spec_order/_assignment_form.html b/templates/webpages/requirement_spec_order/_assignment_form.html index 6df34bbb2..161b23849 100644 --- a/templates/webpages/requirement_spec_order/_assignment_form.html +++ b/templates/webpages/requirement_spec_order/_assignment_form.html @@ -18,7 +18,7 @@ [% LxERP.t8("Assign the following article to all sections") %]: - [% L.select_tag('quotations_and_orders_dummy', SELF.all_parts, default=INSTANCE_CONF.get_requirement_spec_section_order_part_id, title_sub=\make_part_title, id='quoations_and_orders_order_id', style=style) %] + [% L.select_tag('quotations_and_orders_dummy', SELF.all_parts_time_unit, default=INSTANCE_CONF.get_requirement_spec_section_order_part_id, title_sub=\make_part_title, id='quoations_and_orders_order_id', style=style) %] [% L.button_tag('kivi.requirement_spec.assign_order_part_id_to_all()', LxERP.t8('Assign article')) %] @@ -41,7 +41,7 @@ [% HTML.escape(section.fb_number) %] [% HTML.escape(section.title) %] [% HTML.escape(P.truncate(section.description)) %] - [% L.select_tag('sections[].order_part_id', SELF.all_parts, default=section.order_part_id, with_empty=!for_new, title_sub=\make_part_title, style=style, no_id=1) %] + [% L.select_tag('sections[].order_part_id', SELF.all_parts_time_unit, default=section.order_part_id, with_empty=!for_new, title_sub=\make_part_title, style=style, no_id=1) %] [% END %] -- 2.20.1