From: Moritz Bunkus Date: Wed, 11 May 2011 08:49:36 +0000 (+0200) Subject: Sortieren von Lagerhäusern auf Drag-n-Drop & AJAX mittels jQuery UI Sortable umgestellt X-Git-Tag: release-2.6.3~25^2~65^2~1 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=047a0b577ec117c9061d40728803c70ff8191962;p=kivitendo-erp.git Sortieren von Lagerhäusern auf Drag-n-Drop & AJAX mittels jQuery UI Sortable umgestellt --- diff --git a/SL/Controller/Warehouse.pm b/SL/Controller/Warehouse.pm new file mode 100644 index 000000000..a7b059c89 --- /dev/null +++ b/SL/Controller/Warehouse.pm @@ -0,0 +1,36 @@ +package SL::Controller::Warehouse; + +use strict; + +use parent qw(SL::Controller::Base); + +use SL::DB::Warehouse; + +__PACKAGE__->run_before('check_auth'); + +# +# actions +# + +sub action_reorder { + my ($self) = @_; + + my @ids = @{ $::form->{warehouse_id} || [] }; + my $result = SL::DB::Warehouse->new->db->do_transaction(sub { + foreach my $idx (0 .. scalar(@ids) - 1) { + SL::DB::Warehouse->new(id => $ids[$idx])->load->update_attributes(sortkey => $idx + 1); + } + }); + + $self->render(type => 'js', inline => '1;'); +} + +# +# filters +# + +sub check_auth { + $::auth->assert('config'); +} + +1; diff --git a/bin/mozilla/am.pl b/bin/mozilla/am.pl index 588ad9ae5..e96c604a1 100644 --- a/bin/mozilla/am.pl +++ b/bin/mozilla/am.pl @@ -3230,16 +3230,6 @@ sub list_warehouses { AM->get_all_warehouses(\%myconfig, $form); - my $previous; - foreach my $current (@{ $form->{WAREHOUSES} }) { - if ($previous) { - $previous->{next_id} = $current->{id}; - $current->{previous_id} = $previous->{id}; - } - - $previous = $current; - } - $form->{callback} = build_std_url('action=list_warehouses'); $form->{title} = $locale->text('Warehouses'); $form->{url_base} = build_std_url('callback'); @@ -3272,20 +3262,6 @@ sub save_warehouse { $main::lxdebug->leave_sub(); } -sub swap_warehouses { - $main::lxdebug->enter_sub(); - - my $form = $main::form; - my %myconfig = %main::myconfig; - - $main::auth->assert('config'); - - AM->swap_sortkeys(\%myconfig, $form, 'warehouse'); - list_warehouses(); - - $main::lxdebug->leave_sub(); -} - sub delete_warehouse { $main::lxdebug->enter_sub(); diff --git a/templates/webpages/am/list_warehouses.html b/templates/webpages/am/list_warehouses.html index 843abe586..e47e7c241 100644 --- a/templates/webpages/am/list_warehouses.html +++ b/templates/webpages/am/list_warehouses.html @@ -1,24 +1,26 @@ -[%- USE T8 %] -[% USE HTML %] +[%- USE T8 %][% USE LxERP %][% USE L %] +[% USE HTML %] + + + + [% IF saved_message %]

[% saved_message %]

[% END %]
[% title %]

- - - - - - - +
[% 'Description' | $T8 %][% 'Number of bins' | $T8 %][% 'Invalid' | $T8 %]
+ + + + + - [% SET row_odd = '1' %][% FOREACH warehouse = WAREHOUSES %] - - - + [% FOREACH warehouse = WAREHOUSES %] + + @@ -37,5 +39,7 @@

+ [% L.sortable_element('#warehouse_list tbody', 'url' => 'controller.pl?action=Warehouse/reorder', 'with' => 'warehouse_id') %] +
[ LxERP.t8('reorder item') %][% 'Description' | $T8 %][% 'Number of bins' | $T8 %][% 'Invalid' | $T8 %]
[% IF warehouse.previous_id %][% END %][% IF warehouse.next_id %][% END %]
[ LxERP.t8('reorder item') %] [% HTML.escape(warehouse.description) %] [% HTML.escape(warehouse.number_of_bins) %] [% IF warehouse.invalid %][% 'Yes' | $T8 %][% ELSE %][% 'No' | $T8 %][% END %]