use Rose::Object::MakeMethods::Generic
(
scalar => [ qw(item_ids_to_delete is_custom_shipto_to_delete) ],
- 'scalar --get_set_init' => [ qw(order valid_types type cv p multi_items_models all_price_factors search_cvpartnumber show_update_button) ],
+ 'scalar --get_set_init' => [ qw(order valid_types type cv p all_price_factors search_cvpartnumber show_update_button) ],
);
$self->js->render();
}
-# open the dialog for entering multiple items at once
-sub action_show_multi_items_dialog {
- $_[0]->render('order/tabs/_multi_items_dialog', { layout => 0 },
- all_partsgroups => SL::DB::Manager::PartsGroup->get_all);
-}
-
-# update the filter results in the multi item dialog
-sub action_multi_items_update_result {
- my $max_count = 100;
-
- $::form->{multi_items}->{filter}->{obsolete} = 0;
-
- my $count = $_[0]->multi_items_models->count;
-
- if ($count == 0) {
- my $text = SL::Presenter::EscapedText->new(text => $::locale->text('No results.'));
- $_[0]->render($text, { layout => 0 });
- } elsif ($count > $max_count) {
- my $text = SL::Presenter::EscapedText->new(text => $::locale->text('Too many results (#1 from #2).', $count, $max_count));
- $_[0]->render($text, { layout => 0 });
- } else {
- my $multi_items = $_[0]->multi_items_models->get;
- $_[0]->render('order/tabs/_multi_items_result', { layout => 0 },
- multi_items => $multi_items);
- }
-}
-
# add item rows for multiple items at once
sub action_add_multi_items {
my ($self) = @_;
- my @form_attr = grep { $_->{qty_as_number} } @{ $::form->{add_multi_items} };
+ my @form_attr = grep { $_->{qty_as_number} } @{ $::form->{add_items} };
return $self->js->render() unless scalar @form_attr;
my @items;
}
$self->js
- ->run('kivi.Order.close_multi_items_dialog')
+ ->run('kivi.Part.close_picker_dialogs')
->run('kivi.Order.init_row_handlers')
->run('kivi.Order.renumber_positions')
->focus('#add_item_parts_id_name');
$_[0]->make_order;
}
-# model used to filter/display the parts in the multi-items dialog
-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 init_all_price_factors {
SL::DB::Manager::PriceFactor->get_all;
}
Displaying tax information
-=item * C<template/webpages/order/tabs/_multi_items_dialog.html>
-
-Dialog for entering more than one item at once
-
-=item * C<template/webpages/order/tabs/_multi_items_result.html>
-
-Results for the filter in the multi items dialog
-
=item * C<template/webpages/order/tabs/_price_sources_dialog.html>
Dialog for selecting price and discount sources
This behavior was implemented intentionally. But we can discuss, which behavior
should be implemented.
-=item *
-
-C<show_multi_items_dialog> does not use the currently inserted string for
-filtering.
-
=back
=head1 To discuss / Nice to have
$.post("controller.pl", data, kivi.eval_json_result);
};
- ns.setup_multi_items_dialog = function() {
- $('#multi_items_filter_table input, #multi_items_filter_table select').keydown(function(event) {
- if (event.keyCode == 13) {
- event.preventDefault();
- ns.multi_items_dialog_update_result();
- return false;
- }
- });
-
- $('#multi_items_filter_all_substr_multi_ilike').focus();
- };
-
- ns.show_multi_items_dialog = function() {
- if (!ns.check_cv()) return;
-
- $('#row_table_id thead a img').remove();
-
- kivi.popup_dialog({
- url: 'controller.pl?action=Order/show_multi_items_dialog',
- data: { type: $('#type').val() },
- id: 'jq_multi_items_dialog',
- load: kivi.Order.setup_multi_items_dialog,
- dialog: {
- title: kivi.t8('Add multiple items'),
- width: 800,
- height: 500
- }
- });
- return true;
- };
-
- ns.close_multi_items_dialog = function() {
- $('#jq_multi_items_dialog').dialog('close');
- };
-
- ns.multi_items_dialog_update_result = function() {
- var data = $('#multi_items_form').serializeArray();
- data.push({ name: 'type', value: $('#type').val() });
- $.ajax({
- url: 'controller.pl?action=Order/multi_items_update_result',
- data: data,
- method: 'post',
- success: function(data) {
- $('#multi_items_result').html(data);
- ns.multi_items_dialog_enable_continue();
- ns.multi_items_result_setup_events();
- }
- });
- };
-
- ns.multi_items_dialog_disable_continue = function() {
- // disable keydown-event and continue button to prevent
- // impatient users to add parts multiple times
- $('#multi_items_result input, #multi_items_position').off("keydown");
- $('#multi_items_dialog_continue_button').prop('disabled', true);
- };
-
- ns.multi_items_dialog_enable_continue = function() {
- $('#multi_items_result input, #multi_items_position').keydown(function(event) {
- if(event.keyCode == 13) {
- event.preventDefault();
- ns.add_multi_items();
- return false;
- }
- });
- $('#multi_items_dialog_continue_button').prop('disabled', false);
- };
-
- ns.multi_items_result_setup_events = function() {
- $('#multi_items_all_qty').change(ns.reformat_number);
- $('#multi_items_all_qty').change(function(event) {
- $('.multi_items_qty').val($(event.target).val());
- });
- $('.multi_items_qty').change(ns.reformat_number);
- }
-
- ns.add_multi_items = function() {
- // rows at all
- var n_rows = $('.multi_items_qty').length;
- if (n_rows == 0) return;
-
- // filled rows
- n_rows = $('.multi_items_qty').filter(function() {
- return $(this).val().length > 0;
- }).length;
- if (n_rows == 0) return;
-
- ns.multi_items_dialog_disable_continue();
-
+ ns.add_multi_items = function(data) {
var insert_before_item_id = ns.get_insert_before_item_id($('#multi_items_position').val());
-
- var data = $('#order_form').serializeArray();
- data = data.concat($('#multi_items_form').serializeArray());
+ data = data.concat($('#order_form').serializeArray());
data.push({ name: 'action', value: 'Order/add_multi_items' },
{ name: 'insert_before_item_id', value: insert_before_item_id });
$.post("controller.pl", data, kivi.eval_json_result);
};
- ns.set_input_to_one = function(clicked) {
- if ($(clicked).val() == '') {
- $(clicked).val(kivi.format_amount(1.00, -2));
- }
- $(clicked).select();
- };
-
ns.delete_order_item_row = function(clicked) {
var row = $(clicked).parents("tbody").first();
$(row).remove();
<td>
[%- SET PARAM_KEY = SELF.cv == "customer" ? 'with_customer_partnumber' : 'with_makemodel' -%]
[%- SET PARAM_VAL = SELF.search_cvpartnumber -%]
- [% P.part.picker('add_item.parts_id', '', fat_set_item=1, style='width: 300px', class="add_item_input", $PARAM_KEY=PARAM_VAL) %]</td>
+ [% P.part.picker('add_item.parts_id', '', style='width: 300px', class="add_item_input",
+ fat_set_item=1,
+ multiple_pos_input=1,
+ action={set_multi_items='kivi.Order.add_multi_items'},
+ $PARAM_KEY=PARAM_VAL) %]</td>
<td>[% L.input_tag('add_item.description', '', class="add_item_input") %]</td>
<td>
[% L.input_tag('add_item.qty_as_number', '', size = 5, class="add_item_input numeric") %]
+++ /dev/null
-[%- USE T8 %][%- USE HTML %][%- USE L %][%- USE LxERP %]
-
-<form method="post" id="multi_items_form" method="POST">
-
-<table id='multi_items_filter_table'>
- <tr>
- <th>[%- LxERP.t8("Description") %]/[%- LxERP.t8("Partnumber") %]:</th>
- <td>[%- L.input_tag('multi_items.filter.all:substr:multi::ilike', '') %]</td>
- <th>[%- LxERP.t8("Partsgroup") %]</th>
- <td>[%- L.select_tag('multi_items.filter.partsgroup_id', all_partsgroups, title_key='displayable_name', value_key='id', with_empty=1) %]</td>
- <tr>
-</table>
-
-[% L.button_tag('kivi.Order.multi_items_dialog_update_result()', LxERP.t8('Filter')) %]
-[% L.button_tag('$("#multi_items_form").resetForm()', LxERP.t8('Reset')) %]
-
-<hr>
-<div id='multi_items_result'></div>
-<hr>
-
-[% 'At position' | $T8 %]
-[% L.input_tag('multi_items.position', '', size = 5, class="numeric") %]</td>
-[% L.button_tag('kivi.Order.add_multi_items()', LxERP.t8('Continue'), id='multi_items_dialog_continue_button') %]
-<a href="#" onclick="kivi.Order.close_multi_items_dialog();">[%- LxERP.t8("Cancel") %]</a>
-
-
-</form>
+++ /dev/null
-[%- USE T8 %][%- USE HTML %][%- USE L %][%- USE LxERP %]
-
-<table width="100%">
- <tr>
- <td>[% 'for all' | $T8 %]
- <td>[% L.input_tag("multi_items.all_qty", '', size = 5, class='numeric') %]</td>
- </tr>
- <tr>
- <td colspan="5"><hr></td>
- </tr>
- [%- FOREACH item = multi_items %]
- <tr>
- <td></td>
- <td>
- [% L.hidden_tag("add_multi_items[+].parts_id", item.id) %]
- [% L.input_tag("add_multi_items[].qty_as_number", '', size = 5,
- class = 'multi_items_qty numeric', onclick = 'kivi.Order.set_input_to_one(this)') %]
- </td>
- <td>[% HTML.escape(item.unit) %]</td>
- <td>[% HTML.escape(item.partnumber) %]</td>
- <td>[% HTML.escape(item.description) %]</td>
- </tr>
- [%- END %]
-</table>
[%- PROCESS order/tabs/_item_input.html SELF=SELF %]
- [% L.button_tag('kivi.Order.show_multi_items_dialog()', LxERP.t8('Add multiple items')) %]
+ [% L.button_tag('$("#add_item_parts_id").data("part_picker").o.multiple=1; $("#add_item_parts_id").data("part_picker").open_dialog()', LxERP.t8('Add multiple items')) %]
<table width="100%">
<tr>