Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision aeb5d92a

Von Bernd Bleßmann vor 4 Monaten 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
      ],
templates/design40_webpages/stock_counting_reconciliation/_filter.html
12 12
      <th align="right">[% 'Stock Counting' | $T8 %]</th>
13 13
      <td>
14 14
       [% L.select_tag('filter.counting_id', SELF.countings,
15
                       default    => filter.counting_id,
16
                       title_key  => 'name',
17
                       value_key  => 'id',
18
                       with_empty => 1,
19
                       class      => 'wi-lightwide') %]
20
      </td>
21
     </tr>
22
     <tr>
23
      <th align="right">[% 'Group Counting Items' | $T8 %]</th>
24
      <td>
25
       [% L.checkbox_tag('group_counting_items', checked = FORM.group_counting_items, for_submit = 1) %]
15
                       default         => filter.counting_id,
16
                       title_key       => 'name',
17
                       value_key       => 'id',
18
                       with_empty      => 1,
19
                       class           => 'wi-lightwide',
20
                       'data-validate' => 'required') %]
26 21
      </td>
27 22
     </tr>
28 23
    </body>
......
37 32
   </div>
38 33

  
39 34
   [% END # /BLOCK filter_toggle_panel %]
40

  
35
   [% SET display_status = 'open' %]
41 36
   [% INCLUDE 'common/toggle_panel.html' %]
42 37

  
43 38
 </div>
templates/webpages/stock_counting_reconciliation/_filter.html
4 4
[%- USE HTML %]
5 5

  
6 6
<form action='controller.pl' method='post' id='filter_form'>
7
 <div class='filter_toggle'>
7
 <div class='filter_toggle' style='display:none'>
8 8
  <a href='#' onClick='javascript:$(".filter_toggle").toggle()'>[% 'Show Filter' | $T8 %]</a>
9 9
  [% SELF.filter_summary | html %]
10 10
 </div>
11 11

  
12
 <div class='filter_toggle' style='display:none'>
12
 <div class='filter_toggle'>
13 13
  <a href='#' onClick='javascript:$(".filter_toggle").toggle()'>[% 'Hide Filter' | $T8 %]</a>
14 14
  <table id='filter_table'>
15 15
   <tr>
16 16
    <th align="right">[% 'Stock Counting' | $T8 %]</th>
17 17
    <td>
18 18
     [% L.select_tag('filter.counting_id', SELF.countings,
19
                     default    => filter.counting_id,
20
                     title_key  => 'name',
21
                     value_key  => 'id',
22
                     with_empty => 1,
23
                     style      => 'width: 200px') %]
24
    </td>
25
   </tr>
26
   <tr>
27
    <th align="right">[% 'Group Counting Items' | $T8 %]</th>
28
    <td>
29
     [% L.checkbox_tag('group_counting_items', checked = FORM.group_counting_items, for_submit = 1) %]
19
                     default         => filter.counting_id,
20
                     title_key       => 'name',
21
                     value_key       => 'id',
22
                     with_empty      => 1,
23
                     style           => 'width: 200px',
24
                     'data-validate' => 'required') %]
30 25
    </td>
31 26
   </tr>
32 27
  </table>

Auch abrufbar als: Unified diff