From 9680897326dad8cc0b35336855f658a580d6bbe5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bernd=20Ble=C3=9Fmann?= Date: Thu, 12 Nov 2015 22:59:49 +0100 Subject: [PATCH] =?utf8?q?Auftrags-Controller:=20einfachen=20Filter=20f?= =?utf8?q?=C3=BCr=20Mehrfach-Artikelauswahl.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/Controller/Order.pm | 37 +++++++++---- .../order/tabs/_multi_items_dialog.html | 45 +++++++++------- .../order/tabs/_multi_items_result.html | 15 ++++++ templates/webpages/order/tabs/basic_data.html | 53 +++++++------------ 4 files changed, 90 insertions(+), 60 deletions(-) create mode 100644 templates/webpages/order/tabs/_multi_items_result.html diff --git a/SL/Controller/Order.pm b/SL/Controller/Order.pm index 9310f9110..3203485fa 100644 --- a/SL/Controller/Order.pm +++ b/SL/Controller/Order.pm @@ -20,10 +20,13 @@ use SL::DB::Project; use SL::DB::Default; use SL::DB::Unit; use SL::DB::Price; +use SL::DB::Part; use SL::Helper::DateTime; use SL::Helper::CreatePDF qw(:all); +use SL::Controller::Helper::GetModels; + use List::Util qw(max first); use List::MoreUtils qw(none pairwise first_index); use English qw(-no_match_vars); @@ -31,7 +34,7 @@ use File::Spec; use Rose::Object::MakeMethods::Generic ( - 'scalar --get_set_init' => [ qw(order valid_types type cv p) ], + 'scalar --get_set_init' => [ qw(order valid_types type cv p multi_items_models) ], ); @@ -339,15 +342,14 @@ sub action_add_item { } sub action_show_multi_items_dialog { - my ($self) = @_; - - $self->{multi_items}->{parts} = SL::DB::Manager::Part->get_all_sorted(where => [ obsolete => 0 ]); - my $dialog_html = $self->render('order/tabs/_multi_items_dialog', { output => 0 }); + require SL::DB::PartsGroup; + $_[0]->render('order/tabs/_multi_items_dialog', { layout => 0 }, + all_partsgroups => SL::DB::Manager::PartsGroup->get_all); +} - $self->js - ->run('show_multi_items_dialog', $dialog_html, t8('Add multiple parts')) - ->reinit_widgets - ->render(); +sub action_multi_items_update_result { + $_[0]->render('order/tabs/_multi_items_result', { layout => 0 }, + multi_items => $_[0]->multi_items_models->get); } sub action_add_multi_items { @@ -469,6 +471,23 @@ sub init_order { _make_order(); } +sub init_multi_items_models { + SL::Controller::Helper::GetModels->new( + controller => $_[0], + model => 'Part', + with_objects => [ qw(unit_obj) ], + disable_plugin => 'paginated', + source => $::form->{multi_items}, + sorted => { + _default => { + by => 'partnumber', + dir => 1, + }, + partnumber => t8('Partnumber'), + description => t8('Description')} + ); +} + sub _check_auth { my ($self) = @_; diff --git a/templates/webpages/order/tabs/_multi_items_dialog.html b/templates/webpages/order/tabs/_multi_items_dialog.html index 45c5b92f8..f96018c79 100644 --- a/templates/webpages/order/tabs/_multi_items_dialog.html +++ b/templates/webpages/order/tabs/_multi_items_dialog.html @@ -1,33 +1,42 @@ [%- USE T8 %][%- USE HTML %][%- USE L %][%- USE LxERP %]
-

[%- 'Add multiple parts' | $T8 %] [%- SELF.type | $T8 %]

- - - [%- FOREACH part = SELF.multi_items.parts %] - - - - - - - [%- END %] + +
- [% L.hidden_tag("add_multi_items[+].parts_id", part.id) %] - [% L.input_tag("add_multi_items[].qty", '', size => 5) %] - [% HTML.escape(part.unit) %][% HTML.escape(part.partnumber) %][% HTML.escape(part.description) %]
+ + + + + +
[%- LxERP.t8("Description") %]/[%- LxERP.t8("Partnumber") %]:[%- L.input_tag('multi_items.filter.all:substr::ilike', '') %][%- LxERP.t8("Group") %][%- L.select_tag('multi_items.filter.partsgroup_id', all_partsgroups, title_key='displayable_name', value_key='id', with_empty=1) %]
-
-[% L.hidden_tag('action', 'Order/dispatch') %] +[% L.button_tag('update_result()', LxERP.t8('Filter')) %] +[% 'Reset' | $T8 %] + +
+
+
+ [% L.button_tag('add_multi_items()', LxERP.t8('Continue')) %] [%- LxERP.t8("Cancel") %] diff --git a/templates/webpages/order/tabs/_multi_items_result.html b/templates/webpages/order/tabs/_multi_items_result.html new file mode 100644 index 000000000..c0cafffdb --- /dev/null +++ b/templates/webpages/order/tabs/_multi_items_result.html @@ -0,0 +1,15 @@ +[%- USE T8 %][%- USE HTML %][%- USE L %][%- USE LxERP %] + + + [%- FOREACH item = multi_items %] + + + + + + + [%- END %] +
+ [% L.hidden_tag("add_multi_items[+].parts_id", item.id) %] + [% L.input_tag("add_multi_items[].qty", '', size => 5) %] + [% HTML.escape(item.unit) %][% HTML.escape(item.partnumber) %][% HTML.escape(item.description) %]
diff --git a/templates/webpages/order/tabs/basic_data.html b/templates/webpages/order/tabs/basic_data.html index d66c9105e..c25ec72ce 100644 --- a/templates/webpages/order/tabs/basic_data.html +++ b/templates/webpages/order/tabs/basic_data.html @@ -138,7 +138,7 @@ [%- PROCESS order/tabs/_item_input.html %] - [% L.button_tag('setup_multi_items_dialog()', LxERP.t8('Add multiple parts')) %] + [% L.button_tag('show_multi_items_dialog()', LxERP.t8('Add multiple parts')) %] @@ -278,43 +278,30 @@ function add_item() { $.post("controller.pl", data, kivi.eval_json_result); } -function setup_multi_items_dialog() { +function show_multi_items_dialog() { if (!check_cv()) return; - var data = $('#order_form').serialize(); - data += '&action=Order/show_multi_items_dialog'; - - $.post("controller.pl", data, kivi.eval_json_result); -} - -var multi_items_dialog; - -function show_multi_items_dialog(html, title) { - var id = 'jq_multi_items_dialog'; - var dialog_params = { - id: id, - width: 800, - height: 500, - modal: true, - close: function(event, ui) { - multi_items_dialog.remove(); - }, - }; - - $('#' + id).remove(); - - multi_items_dialog = $('').appendTo('body'); - multi_items_dialog.attr('title', title); - multi_items_dialog.html(html); - multi_items_dialog.dialog(dialog_params); - - $('.cancel').click(close_multi_items_dialog); + var data = 'type=' + $('#type').val(); + data += 'type=' + $('#type').val(); + kivi.popup_dialog({ + url: 'controller.pl?action=Order/show_multi_items_dialog', + data: $.extend({}, + { 'type': $('#type').val(), + 'callback': 'Order/add_multi_items', + 'callback_data_id': 'order_form' }), + id: 'jq_multi_items_dialog', + dialog: { + title: kivi.t8('Add multiple items'), + width: 800, + height: 500 + } + }); return true; } -var close_multi_items_dialog = function() { - multi_items_dialog.dialog('close'); -} +function close_multi_items_dialog() { + $('#jq_multi_items_dialog').dialog('close'); +}; function delete_order_item_row(clicked) { var row = $(clicked).parents("tbody").first(); -- 2.20.1