Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 21437d97

Von Bernd Bleßmann vor 2 Monaten hinzugefügt

  • ID 21437d97fbd29ac3d48ec4480b0f762543bf9326
  • Vorgänger b6622ee9
  • Nachfolger 3ea4e13e

Zwischeninventur: Zähl-Maske auch für Nicht-Mobil

Unterschiede anzeigen:

SL/Controller/StockCounting.pm
12 12
use SL::DB::StockCounting;
13 13
use SL::DB::StockCountingItem;
14 14

  
15
use SL::Helper::Flash qw(flash);
15 16
use SL::Helper::Number qw(_format_total);
16 17
use SL::Locale::String qw(t8);
17 18
use SL::ReportGenerator;
......
44 45
sub action_select_counting {
45 46
  my ($self) = @_;
46 47

  
48
  if (!$::request->is_mobile) {
49
    $self->setup_select_counting_action_bar;
50
  }
51

  
47 52
  $self->render('stock_counting/select_counting');
48 53
}
49 54

  
50 55
sub action_start_counting {
51 56
  my ($self) = @_;
52 57

  
58
  if (!$::request->is_mobile) {
59
    $self->setup_count_action_bar;
60
  }
61

  
53 62
  $self->render('stock_counting/count');
54 63
}
55 64

  
56 65
sub action_count {
57 66
  my ($self) = @_;
58 67

  
68
  if (!$::request->is_mobile) {
69
    $self->setup_count_action_bar;
70
  }
71

  
59 72
  my @errors;
60 73
  push @errors, t8('EAN is missing')    if !$::form->{ean};
61 74

  
62
  return $self->render('stock_counting/count', errors => \@errors) if @errors;
75
  return $self->render_count_error(\@errors) if @errors;
63 76

  
64 77
  my $parts = SL::DB::Manager::Part->get_all(where => [ean => $::form->{ean},
65 78
                                                       or  => [obsolete => 0, obsolete => undef]]);
66 79
  push @errors, t8 ('Part not found')    if scalar(@$parts) == 0;
67 80
  push @errors, t8 ('Part is ambiguous') if scalar(@$parts) >  1;
68 81

  
69
  return $self->render('stock_counting/count', errors => \@errors) if @errors;
82
  return $self->render_count_error(\@errors) if @errors;
70 83

  
71 84
  $self->stock_counting_item->part($parts->[0]);
72 85

  
73 86
  my @validation_errors = $self->stock_counting_item->validate;
74 87
  push @errors, @validation_errors if @validation_errors;
75 88

  
76
  return $self->render('stock_counting/count', errors => \@errors) if @errors;
89
  return $self->render_count_error(\@errors) if @errors;
77 90

  
78 91
  $self->stock_counting_item->qty(1);
79 92
  $self->stock_counting_item->save;
80 93

  
81
  $self->render('stock_counting/count', successfully_counted => 1);
94
  if ($::request->is_mobile) {
95
    $self->render('stock_counting/count', successfully_counted => 1);
96
  } else {
97
    flash('info', t8('Part successfully counted'));
98
    $self->render('stock_counting/count');
99
  }
82 100
}
83 101

  
84 102
sub action_list {
......
237 255
  $_->{stocked} = $_->part->get_stock(bin_id => $_->bin_id) for @$objects;
238 256
}
239 257

  
258
sub render_count_error {
259
  my ($self, $errors) = @_;
260

  
261
  if ($::request->is_mobile) {
262
    $self->render('stock_counting/count', errors => $errors);
263
  } else {
264
    flash('error', @{$errors || [] });
265
    $self->render('stock_counting/count');
266
  }
267
}
268

  
269
sub setup_select_counting_action_bar {
270
  my ($self) = @_;
271

  
272
  for my $bar ($::request->layout->get('actionbar')) {
273
    $bar->add(
274
      action => [
275
        t8('Start Counting'),
276
        submit    => [ '#count_form', { action => 'StockCounting/start_counting' } ],
277
        accesskey => 'enter',
278
      ],
279
    );
280
  }
281
}
282

  
283
sub setup_count_action_bar {
284
  my ($self) = @_;
285
  for my $bar ($::request->layout->get('actionbar')) {
286
    $bar->add(
287
      action => [
288
        t8('Do count'),
289
        checks    => [ ['kivi.validate_form', '#count_form'] ],
290
        submit    => [ '#count_form', { action => 'StockCounting/count' } ],
291
        accesskey => 'enter',
292
      ],
293
    );
294
  }
295
}
296

  
240 297
1;

Auch abrufbar als: Unified diff