Revision aeb5d92a
Von Bernd Bleßmann vor 8 Monaten hinzugefügt
SL/Controller/StockCountingReconciliation.pm | ||
---|---|---|
# check permissions
|
||
__PACKAGE__->run_before(sub { $::auth->assert('warehouse_management'); });
|
||
|
||
# load js
|
||
__PACKAGE__->run_before(sub { $::request->layout->add_javascripts('kivi.Validator.js'); });
|
||
|
||
my %sort_columns = (
|
||
counting => t8('Stock Counting'),
|
||
... | ... | |
sub action_list {
|
||
my ($self, %params) = @_;
|
||
|
||
# we need a counting selected
|
||
if (!$::form->{filter}->{counting_id}) {
|
||
$::form->{filter}->{counting_id} = 0;
|
||
}
|
||
|
||
$self->make_filter_summary;
|
||
$self->prepare_report;
|
||
|
||
my $objects = $self->models->get;
|
||
|
||
if ($::form->{group_counting_items}) {
|
||
my $grouped_objects_by;
|
||
my @grouped_objects;
|
||
foreach my $object (@$objects) {
|
||
my $group_object;
|
||
if (!$grouped_objects_by->{$object->counting_id}->{$object->part_id}->{$object->bin_id}) {
|
||
$group_object = SL::DB::StockCountingItem->new(
|
||
counting => $object->counting, part => $object->part, bin => $object->bin, qty => 0);
|
||
push @grouped_objects, $group_object;
|
||
$grouped_objects_by->{$object->counting_id}->{$object->part_id}->{$object->bin_id} = $group_object;
|
||
|
||
} else {
|
||
$group_object = $grouped_objects_by->{$object->counting_id}->{$object->part_id}->{$object->bin_id}
|
||
}
|
||
|
||
$group_object->id($group_object->id ? ($group_object->id . ',' . $object->id) : $object->id);
|
||
$group_object->qty($group_object->qty + $object->qty);
|
||
# group always
|
||
my $grouped_objects_by;
|
||
my @grouped_objects;
|
||
foreach my $object (@$objects) {
|
||
my $group_object;
|
||
if (!$grouped_objects_by->{$object->counting_id}->{$object->part_id}->{$object->bin_id}) {
|
||
$group_object = SL::DB::StockCountingItem->new(
|
||
counting => $object->counting, part => $object->part, bin => $object->bin, qty => 0);
|
||
push @grouped_objects, $group_object;
|
||
$grouped_objects_by->{$object->counting_id}->{$object->part_id}->{$object->bin_id} = $group_object;
|
||
|
||
} else {
|
||
$group_object = $grouped_objects_by->{$object->counting_id}->{$object->part_id}->{$object->bin_id}
|
||
}
|
||
|
||
$objects = \@grouped_objects;
|
||
$group_object->id($group_object->id ? ($group_object->id . ',' . $object->id) : $object->id);
|
||
$group_object->qty($group_object->qty + $object->qty);
|
||
}
|
||
|
||
$objects = \@grouped_objects;
|
||
|
||
$self->get_stocked($objects);
|
||
|
||
$self->setup_list_action_bar;
|
||
... | ... | |
}
|
||
|
||
sub init_countings {
|
||
SL::DB::Manager::StockCounting->get_all_sorted;
|
||
my $countings = SL::DB::Manager::StockCounting->get_all_sorted;
|
||
$countings = [ grep { !$_->is_reconciliated } @$countings ];
|
||
|
||
return $countings;
|
||
}
|
||
|
||
|
||
... | ... | |
my $report = SL::ReportGenerator->new(\%::myconfig, $::form);
|
||
$self->{report} = $report;
|
||
|
||
my @columns = $::form->{group_counting_items} ? qw(ids counting part bin qty stocked)
|
||
: qw(ids counting counted_at part bin qty stocked employee);
|
||
my @columns = qw(ids counting part bin qty stocked);
|
||
|
||
my %column_defs = (
|
||
ids => { raw_header_data => checkbox_tag("", id => "check_all", checkall => "[data-checkall=1]"),
|
||
... | ... | |
|
||
$report->set_columns(%column_defs);
|
||
$report->set_column_order(@columns);
|
||
$report->set_export_options(qw(list filter group_counting_items));
|
||
$report->set_export_options(qw(list filter));
|
||
$report->set_options_from_form;
|
||
|
||
$self->models->disable_plugin('paginated') if $report->{options}{output_format} =~ /^(pdf|csv)$/i;
|
||
$self->models->add_additional_url_params(filter => $::form->{filter}, group_counting_items => $::form->{group_counting_items});
|
||
$self->models->add_additional_url_params(filter => $::form->{filter});
|
||
$self->models->finalize;
|
||
$self->models->set_report_generator_sort_options(report => $report, sortable_columns => [keys %sort_columns]);
|
||
|
||
... | ... | |
|
||
my @filter_strings;
|
||
|
||
push @filter_strings, t8('Group Counting Items') if $::form->{group_counting_items};
|
||
|
||
my $filter = $::form->{filter} || {};
|
||
|
||
my $counting = $filter->{counting_id} ? SL::DB::StockCounting->new(id => $filter->{counting_id})->load->name : '';
|
||
... | ... | |
action => [
|
||
t8('Update'),
|
||
submit => [ '#filter_form', { action => 'StockCountingReconciliation/list' } ],
|
||
checks => [ ['kivi.validate_form', '#filter_form'] ],
|
||
accesskey => 'enter',
|
||
],
|
||
combobox => [
|
||
... | ... | |
action => [
|
||
t8('Reconcile'),
|
||
submit => [ '#form', { action => 'StockCountingReconciliation/reconcile', callback => $self->models->get_callback } ],
|
||
checks => [ [ 'kivi.check_if_entries_selected', '[name="ids[]"]' ] ],
|
||
checks => [ ['kivi.validate_form', '#filter_form'], [ 'kivi.check_if_entries_selected', '[name="ids[]"]' ] ],
|
||
confirm => t8('Do you really want the selected entries to be reconciled?'),
|
||
],
|
||
],
|
templates/design40_webpages/stock_counting_reconciliation/_filter.html | ||
---|---|---|
<th align="right">[% 'Stock Counting' | $T8 %]</th>
|
||
<td>
|
||
[% L.select_tag('filter.counting_id', SELF.countings,
|
||
default => filter.counting_id,
|
||
title_key => 'name',
|
||
value_key => 'id',
|
||
with_empty => 1,
|
||
class => 'wi-lightwide') %]
|
||
</td>
|
||
</tr>
|
||
<tr>
|
||
<th align="right">[% 'Group Counting Items' | $T8 %]</th>
|
||
<td>
|
||
[% L.checkbox_tag('group_counting_items', checked = FORM.group_counting_items, for_submit = 1) %]
|
||
default => filter.counting_id,
|
||
title_key => 'name',
|
||
value_key => 'id',
|
||
with_empty => 1,
|
||
class => 'wi-lightwide',
|
||
'data-validate' => 'required') %]
|
||
</td>
|
||
</tr>
|
||
</body>
|
||
... | ... | |
</div>
|
||
|
||
[% END # /BLOCK filter_toggle_panel %]
|
||
|
||
[% SET display_status = 'open' %]
|
||
[% INCLUDE 'common/toggle_panel.html' %]
|
||
|
||
</div>
|
templates/webpages/stock_counting_reconciliation/_filter.html | ||
---|---|---|
[%- USE HTML %]
|
||
|
||
<form action='controller.pl' method='post' id='filter_form'>
|
||
<div class='filter_toggle'>
|
||
<div class='filter_toggle' style='display:none'>
|
||
<a href='#' onClick='javascript:$(".filter_toggle").toggle()'>[% 'Show Filter' | $T8 %]</a>
|
||
[% SELF.filter_summary | html %]
|
||
</div>
|
||
|
||
<div class='filter_toggle' style='display:none'>
|
||
<div class='filter_toggle'>
|
||
<a href='#' onClick='javascript:$(".filter_toggle").toggle()'>[% 'Hide Filter' | $T8 %]</a>
|
||
<table id='filter_table'>
|
||
<tr>
|
||
<th align="right">[% 'Stock Counting' | $T8 %]</th>
|
||
<td>
|
||
[% L.select_tag('filter.counting_id', SELF.countings,
|
||
default => filter.counting_id,
|
||
title_key => 'name',
|
||
value_key => 'id',
|
||
with_empty => 1,
|
||
style => 'width: 200px') %]
|
||
</td>
|
||
</tr>
|
||
<tr>
|
||
<th align="right">[% 'Group Counting Items' | $T8 %]</th>
|
||
<td>
|
||
[% L.checkbox_tag('group_counting_items', checked = FORM.group_counting_items, for_submit = 1) %]
|
||
default => filter.counting_id,
|
||
title_key => 'name',
|
||
value_key => 'id',
|
||
with_empty => 1,
|
||
style => 'width: 200px',
|
||
'data-validate' => 'required') %]
|
||
</td>
|
||
</tr>
|
||
</table>
|
Auch abrufbar als: Unified diff
Zwischeninventur-Abgleich: Zählungsauswahl erzwingen und immer gruppieren