Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision a0e9a20c

Von Bernd Bleßmann vor 8 Monaten hinzugefügt

  • ID a0e9a20c91d14b612db1528d4d1c0b609a7f9574
  • Vorgänger 8e54812a
  • Nachfolger 60e0cecf

S:C:StockCounting: Bericht für Zählungen

Unterschiede anzeigen:

SL/Controller/StockCounting.pm
use strict;
use parent qw(SL::Controller::Base);
use POSIX qw(strftime);
use SL::Controller::Helper::GetModels;
use SL::Controller::Helper::ReportGenerator;
use SL::DB::Employee;
use SL::DB::StockCounting;
use SL::DB::StockCountingItem;
use SL::Helper::Number qw(_format_total);
use SL::Locale::String qw(t8);
use SL::ReportGenerator;
use Rose::Object::MakeMethods::Generic(
#scalar => [ qw() ],
'scalar --get_set_init' => [ qw(is_developer countings stock_counting_item) ],
'scalar --get_set_init' => [ qw(is_developer countings stock_counting_item models) ],
);
# check permissions
__PACKAGE__->run_before(sub { $::auth->assert('warehouse_management'); });
# load js
__PACKAGE__->run_before(sub { $::request->layout->add_javascripts('kivi.Validator.js', 'kivi.StockCounting.js'); });
__PACKAGE__->run_before(sub { $::request->layout->add_javascripts('kivi.Validator.js', 'kivi.StockCounting.js'); },
except => [ qw(list) ]);
my %sort_columns = (
counting => t8('Stock Counting'),
counted_at => t8('Counted At'),
qty => t8('Qty'),
part => t8('Article'),
bin => t8('Bin'),
employee => t8('Employee'),
);
################ actions #################
......
$self->render('stock_counting/count', successfully_counted => 1);
}
sub action_list {
my ($self, %params) = @_;
$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);
}
$objects = \@grouped_objects;
}
$self->get_stocked($objects);
$self->setup_list_action_bar;
$self->report_generator_list_objects(report => $self->{report}, objects => $objects);
}
sub init_is_developer {
!!$::auth->assert('developer', 'may_fail')
}
......
employee => SL::DB::Manager::Employee->current);
}
sub init_models {
my ($self) = @_;
SL::Controller::Helper::GetModels->new(
controller => $_[0],
model => 'StockCountingItem',
sorted => \%sort_columns,
disable_plugin => 'paginated',
with_objects => [ 'counting', 'employee', 'part' ],
);
}
sub prepare_report {
my ($self) = @_;
my $report = SL::ReportGenerator->new(\%::myconfig, $::form);
$self->{report} = $report;
my @columns = $::form->{group_counting_items} ? qw(counting part bin qty stocked)
: qw(counting counted_at part bin qty stocked employee);
my %column_defs = (
counting => { text => t8('Stock Counting'), sub => sub { $_[0]->counting->name }, },
counted_at => { text => t8('Counted At'), sub => sub { $_[0]->counted_at_as_timestamp }, },
qty => { text => t8('Qty'), sub => sub { $_[0]->qty_as_number }, align => 'right' },
part => { text => t8('Article'), sub => sub { $_[0]->part && $_[0]->part->displayable_name } },
bin => { text => t8('Bin'), sub => sub { $_[0]->bin->full_description } },
employee => { text => t8('Employee'), sub => sub { $_[0]->employee ? $_[0]->employee->safe_name : '---'} },
stocked => { text => t8('Stocked Qty'), sub => sub { _format_total($_[0]->{stocked}) }, align => 'right'},
);
# remove columns from defs which are not in @columns
foreach my $column (keys %column_defs) {
delete $column_defs{$column} if !grep { $column eq $_ } @columns;
}
my $title = t8('Stock Counting Items');
$report->{title} = $title; # for browser titlebar (title-tag)
$report->set_options(
controller_class => 'StockCountingItem',
std_column_visibility => 1,
output_format => 'HTML',
title => $title, # for heading
allow_pdf_export => 1,
allow_csv_export => 1,
);
$report->set_columns(%column_defs);
$report->set_column_order(@columns);
$report->set_export_options(qw(list filter group_counting_items));
$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->finalize;
$self->models->set_report_generator_sort_options(report => $report, sortable_columns => [keys %sort_columns]);
$report->set_options(
raw_top_info_text => $self->render('stock_counting/report_top', { output => 0 }),
raw_bottom_info_text => $self->render('stock_counting/report_bottom', { output => 0 }, models => $self->models),
attachment_basename => t8('stock_countings') . strftime('_%Y%m%d', localtime time),
);
}
sub make_filter_summary {
my ($self) = @_;
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 : '';
my @filters = (
[ $counting, t8('Stock Counting') ],
);
for (@filters) {
push @filter_strings, "$_->[1]: $_->[0]" if $_->[0];
}
$self->{filter_summary} = join ', ', @filter_strings;
}
sub setup_list_action_bar {
my ($self) = @_;
for my $bar ($::request->layout->get('actionbar')) {
$bar->add(
action => [
t8('Update'),
submit => [ '#filter_form', { action => 'StockCounting/list' } ],
accesskey => 'enter',
],
);
}
}
sub get_stocked {
my ($self, $objects) = @_;
$_->{stocked} = $_->part->get_stock(bin_id => $_->bin_id) for @$objects;
}
1;
menus/user/00-erp.yaml
access: warehouse_contents | warehouse_management
params:
action: Inventory/stocktaking_journal
- parent: warehouse_reports
id: warehouse_stock_counting_items
name: Stock Counting Items
order: 500
access: warehouse_management
params:
action: StockCounting/list
- id: general_ledger
name: General Ledger
icon: gl
templates/design40_webpages/stock_counting/_filter.html
[%- USE T8 %]
[%- USE L %]
[%- USE LxERP %]
<form action='controller.pl' method='post' id='filter_form'>
<div class="wrapper">
[% BLOCK filter_toggle_panel %]
<table id='filter_table' class='tbl-horizontal'>
<tbody>
<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,
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) %]
</td>
</tr>
</body>
</table>
[% L.hidden_tag('sort_by', FORM.sort_by) %]
[% L.hidden_tag('sort_dir', FORM.sort_dir) %]
[% L.hidden_tag('page', FORM.page) %]
<div class="buttons">
[% L.button_tag('$("#filter_form").clearForm()', LxERP.t8('Reset')) %]
</div>
[% END # /BLOCK filter_toggle_panel %]
[% INCLUDE 'common/toggle_panel.html' %]
</div>
</form>
templates/design40_webpages/stock_counting/report_bottom.html
[%- USE L %]
[% L.paginate_controls(models=SELF.models) %]
</form>
</div>
templates/design40_webpages/stock_counting/report_top.html
[%- PROCESS 'stock_counting/_filter.html' filter=SELF.models.filtered.laundered %]
<div class="wrapper">
<form method="post" action="controller.pl" id="form">
templates/webpages/stock_counting/_filter.html
[%- USE T8 %]
[%- USE L %]
[%- USE LxERP %]
[%- USE HTML %]
<form action='controller.pl' method='post' id='filter_form'>
<div class='filter_toggle'>
<a href='#' onClick='javascript:$(".filter_toggle").toggle()'>[% 'Show Filter' | $T8 %]</a>
[% SELF.filter_summary | html %]
</div>
<div class='filter_toggle' style='display:none'>
<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) %]
</td>
</tr>
</table>
[% L.hidden_tag('sort_by', FORM.sort_by) %]
[% L.hidden_tag('sort_dir', FORM.sort_dir) %]
[% L.hidden_tag('page', FORM.page) %]
[% L.button_tag('$("#filter_form").clearForm()', LxERP.t8('Reset')) %]
</div>
</form>
templates/webpages/stock_counting/report_bottom.html
[%- USE L %]
[% L.paginate_controls(models=SELF.models) %]
</form>
templates/webpages/stock_counting/report_top.html
[%- PROCESS 'stock_counting/_filter.html' filter=SELF.models.filtered.laundered %]
<hr>
<form method="post" action="controller.pl" id="form">

Auch abrufbar als: Unified diff