]> wagnertech.de Git - kivitendo-erp.git/blobdiff - SL/Controller/Part.pm
S:P:Dunning: Link führt nicht mehr zum Drucken, sondern zum Mahnungsbericht, …
[kivitendo-erp.git] / SL / Controller / Part.pm
index 6092f2962c6ca8d8b8d486485824a1c47d381516..cfc94eea14a0355d0a32bd49b41007e3e5258375 100644 (file)
@@ -33,7 +33,7 @@ use Rose::Object::MakeMethods::Generic (
                                   all_buchungsgruppen all_payment_terms all_warehouses
                                   parts_classification_filter
                                   all_languages all_units all_price_factors) ],
-  'scalar'                => [ qw(warehouse bin) ],
+  'scalar'                => [ qw(warehouse bin stock_amounts journal) ],
 );
 
 # safety
@@ -263,6 +263,17 @@ sub action_history {
                                   history_entries => $history_entries);
 }
 
+sub action_inventory {
+  my ($self) = @_;
+
+  $::auth->assert('warehouse_contents');
+
+  $self->stock_amounts($self->part->get_simple_stock_sql);
+  $self->journal($self->part->get_mini_journal);
+
+  $_[0]->render('part/_inventory_data', { layout => 0 });
+};
+
 sub action_update_item_totals {
   my ($self) = @_;
 
@@ -412,15 +423,15 @@ sub action_show_multi_items_dialog {
 }
 
 sub action_multi_items_update_result {
-  my $max_count = 100;
+  my $max_count = $::form->{limit};
 
   my $count = $_[0]->multi_items_models->count;
 
   if ($count == 0) {
     my $text = escape($::locale->text('No results.'));
     $_[0]->render($text, { layout => 0 });
-  } elsif ($count > $max_count) {
-    my $text = escpae($::locale->text('Too many results (#1 from #2).', $count, $max_count));
+  } elsif ($max_count && $count > $max_count) {
+    my $text = escape($::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;
@@ -545,7 +556,7 @@ sub action_warehouse_changed {
     die unless ref($self->warehouse) eq 'SL::DB::Warehouse';
 
     if ( $self->warehouse->id and @{$self->warehouse->bins} ) {
-      $self->bin($self->warehouse->bins->[0]);
+      $self->bin($self->warehouse->bins_sorted->[0]);
       $self->js
         ->html('#bin', $self->build_bin_select)
         ->focus('#part_bin_id');
@@ -878,7 +889,7 @@ sub parse_form_customerprices {
 }
 
 sub build_bin_select {
-  select_tag('part.bin_id', [ $_[0]->warehouse->bins ],
+  select_tag('part.bin_id', [ @{ $_[0]->warehouse->bins_sorted } ],
     title_key => 'description',
     default   => $_[0]->bin->id,
   );
@@ -903,6 +914,8 @@ sub init_part {
 
   if ( $::form->{part}{id} ) {
     return SL::DB::Part->new(id => $::form->{part}{id})->load(with => [ qw(makemodels customerprices prices translations partsgroup shop_parts shop_parts.shop) ]);
+  } elsif ( $::form->{id} ) {
+    return SL::DB::Part->new(id => $::form->{id})->load; # used by inventory tab
   } else {
     die "part_type missing" unless $::form->{part}{part_type};
     return SL::DB::Part->new(part_type => $::form->{part}{part_type});