Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 43819438

Von Werner Hahn vor mehr als 1 Jahr hinzugefügt

  • ID 43819438f6ee83da76a7151e64ba313f75fe2326
  • Vorgänger 9854c20c
  • Nachfolger f5f5863a

Dispomanager Meldebestand Bestellte Artikel als Report

Unterschiede anzeigen:

SL/Controller/DispositionManager.pm
4 4

  
5 5
use parent qw(SL::Controller::Base);
6 6

  
7
use SL::Controller::Helper::GetModels;
8
use SL::Controller::Helper::ReportGenerator;
7 9
use SL::DB::Part;
8 10
use SL::DB::PurchaseBasketItem;
9 11
use SL::PriceSource;
......
13 15

  
14 16
use Data::Dumper;
15 17

  
18
use Rose::Object::MakeMethods::Generic
19
(
20
 'scalar --get_set_init' => [ qw(models) ],
21
);
22

  
16 23
sub action_list_parts {
17 24
  my ( $self ) = @_;
18
  my $parts = $self->_get_parts;
25
  $self->{action} = 'list_parts';
26
  $self->prepare_report('Reorder Level List', $::form->{noshow} ? 1 : 0 );
27

  
28
  my $objects = $::form->{noshow} ? [] : $self->models->get;
29

  
19 30
  $self->_setup_list_action_bar;
20
  $self->render('disposition_manager/list_parts', title => t8('Parts short onhand'), PARTS => $parts);
31
  $self->report_generator_list_objects(report => $self->{report}, objects => $objects);
21 32
}
22 33

  
34
sub prepare_report {
35
  my ($self, $title, $noshow ) = @_;
36
  $main::lxdebug->enter_sub();
37

  
38
  my $locale   = $main::locale;
39
  my $report = SL::ReportGenerator->new(\%::myconfig, $::form);
40
  $self->{report} = $report;
41

  
42
  my @columns  = qw(partnumber description drawing available onhand ordered); # consume);
43
  my @visible  = qw(partnumber description drawing available onhand ordered); # consume);
44
  my @sortable = qw(partnumber description); # consume);
45

  
46
  my %column_defs = (
47
    'partnumber'                  => { sub                                   => sub { $_[0]->partnumber }, text                                                   => t8('Part Number'),
48
                         obj_link => sub { $_[0]->presenter->link_to },   },
49
    'description'                 => { sub                                   => sub { $_[0]->description }, text                                                  => t8('Part Description'),
50
                         obj_link => sub { $_[0]->presenter->link_to },   },
51
    'drawing'                     => { sub                                   => sub { $_[0]->drawing }, text                                                      => t8('Drawing'), },
52
    'available'                   => { sub                                   => sub { $::form->format_amount(\%::myconfig,$_[0]->onhandqty,2); }, text            => t8('Available Stock'), },
53
    'onhand'                      => { sub                                   => sub { $::form->format_amount(\%::myconfig,$_[0]->stockqty,2); }, text             => t8('All On Hand'), },
54
    'rop'                         => { sub                                   => sub { $::form->format_amount(\%::myconfig,$_[0]->rop,2); }, text                  => t8('Rop'), },
55
    'ordered'                     => { sub                                   => sub { $::form->format_amount(\%::myconfig,$_[0]->get_open_ordered_qty,2); }, text => t8('Ordered purchase'), },
56
    # 'consume'       => { sub => sub { $::form->format_amount(\%::myconfig,$_[0]->consume,2); }, text => t8('Consume'), },
57
      );
58

  
59
#  for my $col (@sortable) {
60
#    $column_defs{$col}{link} = $self->self_url(
61
#      sort_by  => $col,
62
#      sort_dir => ($self->{sort_by} eq $col ? 1 - $self->{sort_dir} : $self->{sort_dir}),
63
#      page     => $self->{pages}{cur},
64
#      retype   => $::form->{retype},
65
#      stock    => $::form->{stock},
66
#    );
67
#  }
68

  
69
  map { $column_defs{$_}->{visible} = 1 } @visible;
70

  
71
  $report->set_options(
72
    controller_class     => 'DispositionManager',
73
    output_format        => 'HTML',
74
    title                => t8($title),
75
    allow_pdf_export      => 1,
76
    allow_csv_export      => 1,
77
    no_data_message       => !$noshow,
78
  );
79
  $report->set_columns(%column_defs);
80
  $report->set_column_order(@columns);
81
  $report->set_export_options(qw(list_parts));
82
  $report->set_options_from_form;
83

  
84
  unless ( $noshow ) {
85
    $self->models->disable_plugin('paginated'); # if $report->{options}{output_format} =~ /^(pdf|csv)$/i;
86
    $self->models->finalize; # for filter laundering
87
    $self->models->set_report_generator_sort_options(report => $report, sortable_columns => \@sortable);
88
    #$report->set_sort_indicator($self->{sort_by}, $self->{sort_dir});
89
  }
90
  #$::request->layout->add_javascripts('kivi.PartsWarehouse.js');
91
  #$::form->get_lists('warehouses' => { 'key'    => 'WAREHOUSES',
92
  #                                     'bins'   => 'BINS', });
93
  my $parts = $self->_get_parts(0);
94
  my $top    = $self->render('disposition_manager/list_parts', { output => 0 },
95
                             noshow => $noshow,
96
                             PARTS => $parts,
97
                           );
98
  my $bottom = $noshow ? undef : $self->render('reorder_level_list/report_bottom', { output => 0}, models => $self->models );
99
  $report->set_options(
100
    raw_top_info_text    => $top,
101
    raw_bottom_info_text => $bottom,
102
  );
103
  $main::lxdebug->leave_sub();
104
}
23 105
sub action_add_to_purchase_basket{
24 106
  my ( $self ) = @_;
25 107

  
......
185 267
}
186 268

  
187 269
sub _get_parts {
188
  my ($self) = @_;
270
  my ($self, $ordered) = @_;
189 271

  
190 272
  my $query = <<SQL;
191 273
SELECT *
......
197 279
   ORDER BY partnumber
198 280
SQL
199 281

  
200
  return SL::DB::Manager::Part->get_objects_from_sql( sql => $query );
282
  my $parts = SL::DB::Manager::Part->get_objects_from_sql( sql => $query );
283
  my $parts_to_order = [ grep { !$_->get_open_ordered_qty } @{$parts} ];
284
  my $parts_ordered = [ map { $_->id } grep { $_->get_open_ordered_qty } @{$parts} ];
285
  return $parts_to_order if !$ordered;
286
  return $parts_ordered if $ordered;
201 287
};
202 288

  
289
sub init_models {
290
  my ($self) = @_;
291
  my $parts1 = $self->_get_parts(1) || [];
292
  my @parts = @{$parts1};
293
  my $get_models =  SL::Controller::Helper::GetModels->new(
294
    controller => $self,
295
    model => 'Part',
296
    sorted => {
297
      _default => {
298
        by    => 'partnumber',
299
        dir   => 1,
300
      },
301
      partnumber   => $::locale->text('Part Number'),
302
      description   => $::locale->text('Description'),
303
     },
304
    query        => [
305
      (id            => \@parts) x !!@parts,
306
    ],
307
    paginated => {
308
      form_params => [ qw(page per_page) ],
309
      per_page    => 10,
310
    }
311
  );
312
  return $get_models;
313
}
314

  
315

  
203 316

  
204 317
sub _setup_list_action_bar {
205 318
  my ($self) = @_;
templates/webpages/disposition_manager/list_parts.html
1 1
[%- USE HTML -%][%- USE LxERP -%][%- USE L -%][%- USE T8 -%]
2 2
[% USE Dumper %]
3 3
[%- INCLUDE 'common/flash.html' %]
4
<h1>[% title %]</h1>
5 4
<hr>
6 5
<h2>[% 'Short onhand' | $T8 %]</h2>
7 6
<div style="margin:1em;">
......
32 31
      [% END %]
33 32
    [% END %]
34 33
  </table>
35
</div>
36 34
</form>
37 35
<hr>
38 36
<h2>[% 'Short onhand Ordered' | $T8 %]</h2>
37
<<<<<<< HEAD
39 38
<div style="margin:1em;">
40 39
<table width="100%">
41 40
  <thead>
......
59 58
    [% END %]
60 59
  [% END %]
61 60
</table>
61
=======
62
>>>>>>> a1d2278510 (Dispomanager Meldebestand Bestellte Artikel als Report)
62 63
</div>

Auch abrufbar als: Unified diff