Revision eb1089c2
Von Bernd Bleßmann vor 8 Monaten hinzugefügt
| SL/Controller/Warehouse.pm | ||
|---|---|---|
|
use parent qw(SL::Controller::Base);
|
||
|
|
||
|
use SL::DB::Warehouse;
|
||
|
use SL::Presenter::Tag qw(select_tag);
|
||
|
|
||
|
__PACKAGE__->run_before('check_auth');
|
||
|
__PACKAGE__->run_before(sub { $::auth->assert('developer') },
|
||
|
only => [ qw(test_page) ]);
|
||
|
|
||
|
#
|
||
|
# actions
|
||
|
#
|
||
|
|
||
|
sub action_test_page {
|
||
|
$_[0]->render('warehouse/test_page');
|
||
|
}
|
||
|
|
||
|
sub action_reorder {
|
||
|
my ($self) = @_;
|
||
|
|
||
|
SL::DB::Warehouse->reorder_list(@{ $::form->{warehouse_id} || [] });
|
||
|
|
||
|
$self->render(\'', { type => 'json' });
|
||
|
$self->render(\'', { type => 'json' }); # make emacs happy again ')
|
||
|
}
|
||
|
|
||
|
sub action_wh_bin_select_update_bins {
|
||
|
my ($self) = @_;
|
||
|
|
||
|
my $wh_id = $::form->{wh_id};
|
||
|
my $bin_dom_id = $::form->{bin_dom_id} || 'bin';
|
||
|
|
||
|
my $bins = $wh_id ? SL::DB::Warehouse->new(id => $wh_id)->load->bins_sorted_naturally
|
||
|
: [{id => '', description => ''}];
|
||
|
|
||
|
$self->js->run('kivi.Warehouse.wh_bin_select_update_bins', $bin_dom_id, [map { {key => $_->{id}, value => $_->{description}} } @$bins])
|
||
|
->render;
|
||
|
}
|
||
|
|
||
|
|
||
|
#
|
||
|
# filters
|
||
|
#
|
||
| SL/Presenter/ALL.pm | ||
|---|---|---|
|
use SL::Presenter::BankAccount;
|
||
|
use SL::Presenter::BankTransaction;
|
||
|
use SL::Presenter::MaterialComponents;
|
||
|
use SL::Presenter::Warehouse;
|
||
|
|
||
|
our %presenters = (
|
||
|
chart => 'SL::Presenter::Chart',
|
||
| ... | ... | |
|
bank_account => 'SL::Presenter::BankAccount',
|
||
|
bank_transaction => 'SL::Presenter::BankTransaction',
|
||
|
M => 'SL::Presenter::MaterialComponents',
|
||
|
warehouse => 'SL::Presenter::Warehouse',
|
||
|
);
|
||
|
|
||
|
sub wrap {
|
||
| SL/Presenter/Warehouse.pm | ||
|---|---|---|
|
package SL::Presenter::Warehouse;
|
||
|
|
||
|
use strict;
|
||
|
|
||
|
use SL::DB::Bin;
|
||
|
use SL::DB::Warehouse;
|
||
|
use SL::Locale::String qw(t8);
|
||
|
use SL::Presenter::EscapedText qw(escape is_escaped);
|
||
|
use SL::Presenter::Tag qw(name_to_id div_tag select_tag);
|
||
|
|
||
|
use Exporter qw(import);
|
||
|
our @EXPORT_OK = qw(
|
||
|
wh_bin_select
|
||
|
);
|
||
|
our %EXPORT_TAGS = (ALL => \@EXPORT_OK);
|
||
|
|
||
|
|
||
|
sub wh_bin_select {
|
||
|
my ($name, %attributes) = @_;
|
||
|
|
||
|
my $div_name = $name;
|
||
|
my $wh_name = delete $attributes{wh_name} || "${div_name}_wh";
|
||
|
my $bin_name = delete $attributes{bin_name} || "${div_name}_bin";
|
||
|
my $div_id = delete $attributes{id} || name_to_id($name);
|
||
|
my $wh_id = delete $attributes{wh_id} || name_to_id($wh_name) || "${div_id}_wh";
|
||
|
my $bin_id = delete $attributes{bin_id} || name_to_id($bin_name) || "${div_id}_bin";
|
||
|
|
||
|
my $bin_default = delete $attributes{bin_default};
|
||
|
my $wh_default = delete $attributes{wh_default} || ($bin_default && SL::DB::Bin->new(id => $bin_default)->load->warehouse_id);
|
||
|
my $with_empty = delete $attributes{with_empty};
|
||
|
|
||
|
my %wh_additional_condition = $wh_default ? (id => $wh_default) : undef;
|
||
|
my $all_warehouses = SL::DB::Manager::Warehouse->get_all_sorted( where => [or => [invalid => undef, invalid => 0, %wh_additional_condition]]);
|
||
|
my $all_bins = $wh_default ? SL::DB::Warehouse->new(id => $wh_default)->load->bins_sorted_naturally
|
||
|
: $with_empty ? undef
|
||
|
: $all_warehouses->[0]->bins_sorted_naturally;
|
||
|
|
||
|
my %div_attributes = (
|
||
|
name => $div_name,
|
||
|
id => $div_id,
|
||
|
%attributes
|
||
|
);
|
||
|
|
||
|
my %wh_attributes = (
|
||
|
name => $wh_name,
|
||
|
id => $wh_id,
|
||
|
default => $wh_default,
|
||
|
with_empty => $with_empty,
|
||
|
title_key => 'description',
|
||
|
onchange => 'kivi.Warehouse.wh_changed(this);',
|
||
|
'data-bin-dom-name' => $bin_name,
|
||
|
'data-bin-dom-id' => $bin_id,
|
||
|
%attributes
|
||
|
);
|
||
|
|
||
|
my %bin_attributes = (
|
||
|
name => $bin_name,
|
||
|
id => $bin_id,
|
||
|
default => $bin_default,
|
||
|
title_key => 'description',
|
||
|
%attributes
|
||
|
);
|
||
|
|
||
|
$::request->layout->add_javascripts('kivi.Warehouse.js');
|
||
|
|
||
|
div_tag(select_tag("${name}_wh", $all_warehouses, %wh_attributes) .
|
||
|
select_tag($bin_name, $all_bins, %bin_attributes),
|
||
|
%div_attributes);
|
||
|
}
|
||
|
|
||
|
|
||
|
1;
|
||
| js/kivi.Warehouse.js | ||
|---|---|---|
|
namespace('kivi.Warehouse', function(ns) {
|
||
|
|
||
|
ns.wh_changed = function(target) {
|
||
|
const wh_id = $(target).val();
|
||
|
const bin_dom_name = $(target).data('bin-dom-name');
|
||
|
const bin_dom_id = $(target).data('bin-dom-id');
|
||
|
$.post("controller.pl", { action: 'Warehouse/wh_bin_select_update_bins',
|
||
|
wh_id: wh_id,
|
||
|
bin_dom_id: bin_dom_id },
|
||
|
kivi.eval_json_result);
|
||
|
};
|
||
|
|
||
|
ns.wh_bin_select_update_bins = function(bin_dom_id, bins) {
|
||
|
const $bin_select = $('#' + bin_dom_id);
|
||
|
$bin_select.empty();
|
||
|
$.each(bins, function(idx, elt) {
|
||
|
$bin_select.append($('<option/>', {value: elt.key, text: elt.value}));
|
||
|
});
|
||
|
};
|
||
|
|
||
|
});
|
||
| locale/de/all | ||
|---|---|---|
|
'Warehouse (name)' => 'Lager (Name)',
|
||
|
'Warehouse From' => 'Quelllager',
|
||
|
'Warehouse Migration' => 'Lagermigration',
|
||
|
'Warehouse Test' => 'Lager-Test',
|
||
|
'Warehouse To' => 'Ziellager',
|
||
|
'Warehouse content' => 'Lagerbestand',
|
||
|
'Warehouse deleted.' => 'Lager gelöscht.',
|
||
|
'Warehouse management' => 'Lagerverwaltung/Bestandsveränderung',
|
||
|
'Warehouse saved.' => 'Lager gespeichert.',
|
||
|
'Warehouse/Bin Testpage' => 'Lager/Lagerplatz-Testseite',
|
||
|
'Warehouses' => 'Lager',
|
||
|
'Warn before saving orders with duplicate parts (new controller only)' => 'Beim Speichern warnen, wenn doppelte Artikel in einem Auftrag sind',
|
||
|
'Warn before saving orders without a delivery date' => 'Warnung ausgeben, falls Aufträge kein Lieferdatum haben.',
|
||
| locale/en/all | ||
|---|---|---|
|
'Warehouse (name)' => '',
|
||
|
'Warehouse From' => '',
|
||
|
'Warehouse Migration' => '',
|
||
|
'Warehouse Test' => '',
|
||
|
'Warehouse To' => '',
|
||
|
'Warehouse content' => '',
|
||
|
'Warehouse deleted.' => '',
|
||
|
'Warehouse management' => '',
|
||
|
'Warehouse saved.' => '',
|
||
|
'Warehouse/Bin Testpage' => '',
|
||
|
'Warehouses' => '',
|
||
|
'Warn before saving orders with duplicate parts (new controller only)' => '',
|
||
|
'Warn before saving orders without a delivery date' => '',
|
||
| menus/user/00-erp.yaml | ||
|---|---|---|
|
order: 400
|
||
|
params:
|
||
|
action: Project/test_page
|
||
|
- parent: develop
|
||
|
id: warehouse_test
|
||
|
name: Warehouse Test
|
||
|
access: developer
|
||
|
order: 430
|
||
|
params:
|
||
|
action: Warehouse/test_page
|
||
|
- parent: develop
|
||
|
id: ckeditor_test
|
||
|
name: CKEditor5 Test
|
||
| templates/design40_webpages/warehouse/test_page.html | ||
|---|---|---|
|
[% USE T8 %]
|
||
|
[% USE P %]
|
||
|
|
||
|
<h1>[% 'Warehouse/Bin Testpage' | $T8 %]</h1>
|
||
|
|
||
|
<div class="wrapper">
|
||
|
[% P.warehouse.wh_bin_select('wh') %]
|
||
|
|
||
|
with_empty: [% P.warehouse.wh_bin_select('wh2', with_empty=1) %]
|
||
|
</div>
|
||
| templates/webpages/warehouse/test_page.html | ||
|---|---|---|
|
[% USE T8 %]
|
||
|
[% USE P %]
|
||
|
|
||
|
<h1>[% 'Warehouse/Bin Testpage' | $T8 %]</h1>
|
||
|
|
||
|
<div>
|
||
|
[% P.warehouse.wh_bin_select('wh') %]
|
||
|
|
||
|
with_empty: [% P.warehouse.wh_bin_select('wh2', with_empty=1) %]
|
||
|
</div>
|
||
Auch abrufbar als: Unified diff
Presenter für Lager/Lagerplatz-Auswahl