Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision aeb5d92a

Von Bernd Bleßmann vor 27 Tagen hinzugefügt

  • ID aeb5d92a5150d537f8ee7665de0a22dd3853f9a7
  • Vorgänger 7dd981c4
  • Nachfolger 26fe3dfa

Zwischeninventur-Abgleich: Zählungsauswahl erzwingen und immer gruppieren

Unterschiede anzeigen:

SL/Controller/StockCountingReconciliation.pm
28 28
# check permissions
29 29
__PACKAGE__->run_before(sub { $::auth->assert('warehouse_management'); });
30 30

  
31
# load js
32
__PACKAGE__->run_before(sub { $::request->layout->add_javascripts('kivi.Validator.js'); });
31 33

  
32 34
my %sort_columns = (
33 35
  counting   => t8('Stock Counting'),
......
42 44
sub action_list {
43 45
  my ($self, %params) = @_;
44 46

  
47
  # we need a counting selected
48
  if (!$::form->{filter}->{counting_id}) {
49
    $::form->{filter}->{counting_id} = 0;
50
  }
51

  
45 52
  $self->make_filter_summary;
46 53
  $self->prepare_report;
47 54

  
48 55
  my $objects = $self->models->get;
49 56

  
50
  if ($::form->{group_counting_items}) {
51
    my $grouped_objects_by;
52
    my @grouped_objects;
53
    foreach my $object (@$objects) {
54
      my $group_object;
55
      if (!$grouped_objects_by->{$object->counting_id}->{$object->part_id}->{$object->bin_id}) {
56
        $group_object = SL::DB::StockCountingItem->new(
57
          counting => $object->counting, part => $object->part, bin => $object->bin, qty => 0);
58
        push @grouped_objects, $group_object;
59
        $grouped_objects_by->{$object->counting_id}->{$object->part_id}->{$object->bin_id} = $group_object;
60

  
61
      } else {
62
        $group_object = $grouped_objects_by->{$object->counting_id}->{$object->part_id}->{$object->bin_id}
63
      }
64

  
65
      $group_object->id($group_object->id ? ($group_object->id . ',' . $object->id) : $object->id);
66
      $group_object->qty($group_object->qty + $object->qty);
57
  # group always
58
  my $grouped_objects_by;
59
  my @grouped_objects;
60
  foreach my $object (@$objects) {
61
    my $group_object;
62
    if (!$grouped_objects_by->{$object->counting_id}->{$object->part_id}->{$object->bin_id}) {
63
      $group_object = SL::DB::StockCountingItem->new(
64
        counting => $object->counting, part => $object->part, bin => $object->bin, qty => 0);
65
      push @grouped_objects, $group_object;
66
      $grouped_objects_by->{$object->counting_id}->{$object->part_id}->{$object->bin_id} = $group_object;
67

  
68
    } else {
69
      $group_object = $grouped_objects_by->{$object->counting_id}->{$object->part_id}->{$object->bin_id}
67 70
    }
68 71

  
69
    $objects = \@grouped_objects;
72
    $group_object->id($group_object->id ? ($group_object->id . ',' . $object->id) : $object->id);
73
    $group_object->qty($group_object->qty + $object->qty);
70 74
  }
71 75

  
76
  $objects = \@grouped_objects;
77

  
72 78
  $self->get_stocked($objects);
73 79

  
74 80
  $self->setup_list_action_bar;
......
136 142
}
137 143

  
138 144
sub init_countings {
139
  SL::DB::Manager::StockCounting->get_all_sorted;
145
  my $countings = SL::DB::Manager::StockCounting->get_all_sorted;
146
  $countings    = [ grep { !$_->is_reconciliated } @$countings ];
147

  
148
  return $countings;
140 149
}
141 150

  
142 151

  
......
146 155
  my $report      = SL::ReportGenerator->new(\%::myconfig, $::form);
147 156
  $self->{report} = $report;
148 157

  
149
  my @columns = $::form->{group_counting_items} ? qw(ids counting part bin qty stocked)
150
              : qw(ids counting counted_at part bin qty stocked employee);
158
  my @columns = qw(ids counting part bin qty stocked);
151 159

  
152 160
  my %column_defs = (
153 161
    ids        => { raw_header_data => checkbox_tag("", id => "check_all", checkall  => "[data-checkall=1]"),
......
181 189

  
182 190
  $report->set_columns(%column_defs);
183 191
  $report->set_column_order(@columns);
184
  $report->set_export_options(qw(list filter group_counting_items));
192
  $report->set_export_options(qw(list filter));
185 193
  $report->set_options_from_form;
186 194

  
187 195
  $self->models->disable_plugin('paginated') if $report->{options}{output_format} =~ /^(pdf|csv)$/i;
188
  $self->models->add_additional_url_params(filter => $::form->{filter}, group_counting_items => $::form->{group_counting_items});
196
  $self->models->add_additional_url_params(filter => $::form->{filter});
189 197
  $self->models->finalize;
190 198
  $self->models->set_report_generator_sort_options(report => $report, sortable_columns => [keys %sort_columns]);
191 199

  
......
201 209

  
202 210
  my @filter_strings;
203 211

  
204
  push @filter_strings, t8('Group Counting Items') if $::form->{group_counting_items};
205

  
206 212
  my $filter = $::form->{filter} || {};
207 213

  
208 214
  my $counting = $filter->{counting_id} ? SL::DB::StockCounting->new(id => $filter->{counting_id})->load->name : '';
......
232 238
      action => [
233 239
        t8('Update'),
234 240
        submit    => [ '#filter_form', { action => 'StockCountingReconciliation/list' } ],
241
        checks    => [ ['kivi.validate_form', '#filter_form'] ],
235 242
        accesskey => 'enter',
236 243
      ],
237 244
      combobox => [
......
241 248
        action => [
242 249
          t8('Reconcile'),
243 250
          submit  => [ '#form', { action => 'StockCountingReconciliation/reconcile', callback => $self->models->get_callback } ],
244
          checks  => [ [ 'kivi.check_if_entries_selected', '[name="ids[]"]' ] ],
251
          checks  => [ ['kivi.validate_form', '#filter_form'], [ 'kivi.check_if_entries_selected', '[name="ids[]"]' ] ],
245 252
          confirm => t8('Do you really want the selected entries to be reconciled?'),
246 253
        ],
247 254
      ],

Auch abrufbar als: Unified diff