]> wagnertech.de Git - mfinanz.git/blobdiff - SL/Controller/Inventory.pm
Presenter: Neue Struktur in den restlichen Bereichen umgesetzt
[mfinanz.git] / SL / Controller / Inventory.pm
index e416e809dba8541720fa7c154a37197d0f244c4e..866c1535346cebc9e7ea02a122fc41a4fc0a92b5 100644 (file)
@@ -13,7 +13,7 @@ use SL::DB::Unit;
 use SL::WH;
 use SL::ReportGenerator;
 use SL::Locale::String qw(t8);
-use SL::Presenter;
+use SL::Presenter::Tag qw(select_tag);
 use SL::DBUtils;
 use SL::Helper::Flash;
 use SL::Controller::Helper::ReportGenerator;
@@ -21,7 +21,7 @@ use SL::Controller::Helper::ReportGenerator;
 use English qw(-no_match_vars);
 
 use Rose::Object::MakeMethods::Generic (
-  'scalar --get_set_init' => [ qw(warehouses units p) ],
+  'scalar --get_set_init' => [ qw(warehouses units) ],
   'scalar'                => [ qw(warehouse bin unit part) ],
 );
 
@@ -44,6 +44,7 @@ sub action_stock_in {
   $::request->layout->focus('#part_id_name');
   my $transfer_types = WH->retrieve_transfer_types('in');
   map { $_->{description} = $main::locale->text($_->{description}) } @{ $transfer_types };
+  $self->setup_stock_in_action_bar;
   $self->render('inventory/warehouse_selection_stock', title => $::form->{title}, TRANSFER_TYPES => $transfer_types );
 }
 
@@ -56,10 +57,10 @@ sub action_stock_usage {
                                        'bins'   => 'BINS', });
   $::request->layout->use_javascript("${_}.js") for qw(kivi.PartsWarehouse);
 
+  $self->setup_stock_usage_action_bar;
   $self->render('inventory/warehouse_usage',
                 title => $::form->{title},
                 year => DateTime->today->year,
-  #              PARTSCLASSIFICATIONS => SL::DB:Manager::PartsClassification->get_all_classifications_by_name() ,
                 WAREHOUSES => $::form->{WAREHOUSES},
                 WAREHOUSE_FILTER => 1,
                 warehouse_id => 0,
@@ -70,7 +71,7 @@ sub action_stock_usage {
 
 sub getnumcolumns {
   my ($self) = @_;
-  return qw(stock incorrection found insum back outcorrection disposed 
+  return qw(stock incorrection found insum back outcorrection disposed
                      missing shipped used outsum consumed averconsumed);
 }
 
@@ -92,12 +93,12 @@ sub action_usage {
 
   push @columns , qw(ptype unit) if $form->{report_generator_output_format} eq 'HTML';
 
-  my @numcolumns = qw(stock incorrection found insum back outcorrection disposed 
+  my @numcolumns = qw(stock incorrection found insum back outcorrection disposed
                      missing shipped used outsum consumed averconsumed);
 
   push @columns , $self->getnumcolumns();
 
-  my @hidden_variables = qw(reporttype year duetyp fromdate todate 
+  my @hidden_variables = qw(reporttype year duetyp fromdate todate
                             warehouse_id bin_id partnumber description bestbefore chargenumber partstypes_id);
   my %column_defs = (
     'partnumber'      => { 'text' => $locale->text('Part Number'), },
@@ -126,7 +127,7 @@ sub action_usage {
   my @custom_headers = ();
   # Zeile 1:
   push @custom_headers, [
-      { 'text' => $locale->text('Part'),   
+      { 'text' => $locale->text('Part'),
         'colspan' => ($form->{report_generator_output_format} eq 'HTML'?4:2), 'align' => 'center'},
       { 'text' => $locale->text('Into bin'), 'colspan' => 4, 'align' => 'center'},
       { 'text' => $locale->text('From bin'), 'colspan' => 7, 'align' => 'center'},
@@ -250,7 +251,7 @@ sub action_usage {
   $end->set_second(59);
   $end->set_minute(59);
   $end->set_hour(23);
-  if ( $end->epoch() > $actualepoch ) { 
+  if ( $end->epoch() > $actualepoch ) {
       $end = DateTime->now_local;
       my $dur = $start->delta_md($end);
       $days = $dur->delta_months()*30 + $dur->delta_days() ;
@@ -317,7 +318,7 @@ sub action_usage {
                   $report->add_data($last_row);
               }
               $row_ind++ ;
-          } 
+          }
           $last_partid = $entry->parts_id;
           $last_row = { };
           $last_row->{partnumber}->{data} = $entry->part->partnumber;
@@ -344,14 +345,14 @@ sub action_usage {
       if ( $entry->trans_type->description eq 'correction' ) {
           $prefix = $entry->trans_type->direction;
       }
-      $last_row->{$prefix.$entry->trans_type->description}->{data} += 
+      $last_row->{$prefix.$entry->trans_type->description}->{data} +=
           ( $entry->trans_type->direction eq 'out' ? -$entry->qty : $entry->qty );
   }
   if ( $last_partid > 0 && ( $allrows || ($row_ind >= $first_nr && $row_ind < $last_nr ))) {
       $self->make_row_result($last_row,$days,$last_partid);
       $report->add_data($last_row);
       $row_ind++ ;
-  } 
+  }
   my $num_rows = @{ $report->{data} } ;
   #$main::lxdebug->message(LXDebug->DEBUG2(), "count=".$row_ind." rows=".$num_rows);
 
@@ -380,12 +381,11 @@ sub make_row_result {
   $row->{insum}->{data}  = $row->{stock}->{data} + $row->{incorrection}->{data} + $row->{found}->{data};
   $row->{outsum}->{data} = $row->{back}->{data} + $row->{outcorrection}->{data} + $row->{disposed}->{data} +
        $row->{missing}->{data} + $row->{shipped}->{data} + $row->{used}->{data};
-  $row->{consumed}->{data} = $row->{outsum}->{data} - 
+  $row->{consumed}->{data} = $row->{outsum}->{data} -
        $row->{outcorrection}->{data} - $row->{incorrection}->{data};
   $row->{averconsumed}->{data} = $row->{consumed}->{data}*30/$days ;
   map { $row->{$_}->{data} = $form->format_amount($myconfig,$row->{$_}->{data},2); } $self->getnumcolumns();
   $row->{partnumber}->{link} = 'controller.pl?action=Part/edit&part.id' . $partid;
-#  $row->{partdescription}->{link} = 'ic.pl?action=edit&id='.$partid;
 }
 
 sub action_stock {
@@ -505,10 +505,6 @@ sub init_units {
   SL::DB::Manager::Unit->get_all;
 }
 
-sub init_p {
-  SL::Presenter->get;
-}
-
 sub set_target_from_part {
   my ($self) = @_;
 
@@ -554,7 +550,7 @@ sub set_layout {
 }
 
 sub build_warehouse_select {
$_[0]->p->select_tag('warehouse_id', $_[0]->warehouses,
 select_tag('warehouse_id', $_[0]->warehouses,
    title_key => 'description',
    default   => $_[0]->warehouse->id,
    onchange  => 'reload_bin_selection()',
@@ -562,7 +558,7 @@ sub build_warehouse_select {
 }
 
 sub build_bin_select {
-  $_[0]->p->select_tag('bin_id', [ $_[0]->warehouse->bins ],
+  select_tag('bin_id', [ $_[0]->warehouse->bins ],
     title_key => 'description',
     default   => $_[0]->bin->id,
   );
@@ -570,11 +566,11 @@ sub build_bin_select {
 
 sub build_unit_select {
   $_[0]->part->id
-    ? $_[0]->p->select_tag('unit_id', $_[0]->part->available_units,
+    ? select_tag('unit_id', $_[0]->part->available_units,
         title_key => 'name',
         default   => $_[0]->part->unit_obj->id,
       )
-    : $_[0]->p->select_tag('unit_id', $_[0]->units,
+    : select_tag('unit_id', $_[0]->units,
         title_key => 'name',
       )
 }
@@ -623,4 +619,88 @@ sub show_no_warehouses_error {
   $::form->show_generic_error($msg);
 }
 
+sub setup_stock_in_action_bar {
+  my ($self, %params) = @_;
+
+  for my $bar ($::request->layout->get('actionbar')) {
+    $bar->add(
+      action => [
+        t8('Stock'),
+        submit    => [ '#form', { action => 'Inventory/stock' } ],
+        checks    => [ 'check_part_selection_before_stocking' ],
+        accesskey => 'enter',
+      ],
+    );
+  }
+}
+
+sub setup_stock_usage_action_bar {
+  my ($self, %params) = @_;
+
+  for my $bar ($::request->layout->get('actionbar')) {
+    $bar->add(
+      action => [
+        t8('Show'),
+        submit    => [ '#form', { action => 'Inventory/usage' } ],
+        accesskey => 'enter',
+      ],
+    );
+  }
+}
+
 1;
+__END__
+
+=encoding utf-8
+
+=head1 NAME
+
+SL::Controller::Inventory - Report Controller for inventory
+
+=head1 DESCRIPTION
+
+This controller makes three reports about inventory in warehouses/stocks
+
+- warehouse content
+
+- warehouse journal
+
+- warehouse withdrawal
+
+=head1 FUNCTIONS
+
+=over 4
+
+=item C<action_stock_usage>
+
+Create a search form for stock withdrawal.
+The search parameter for report are made like the reports in bin/mozilla/rp.pl
+
+=item C<action_usage>
+
+Make a report about stock withdrawal.
+
+The manual pagination is implemented like the pagination in SL::Controller::CsvImport.
+
+=back
+
+=head1 SPECIAL CASES
+
+Because of the PFD-Table Formatter some parameters for PDF must be different to the HTML parameters.
+So in german language there are some tries to use a HTML Break in the second heading line
+to produce two line heading inside table. The actual version has some abbreviations for the header texts.
+
+=head1 BUGS
+
+The PDF-Table library has some limits (doesn't display all if the line is to large) so
+the format is adapted to this
+
+
+=head1 AUTHOR
+
+only for C<action_stock_usage> and C<action_usage>:
+
+Martin Helmling E<lt>martin.helmling@opendynamic.deE<gt>
+
+
+=cut