X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fwh.pl;h=1f554441b0010b19c1b808b5d27481ed9a86e314;hb=7fd8e363deae28ea51db21ab3bfe8f5a7587b6ec;hp=5df5ac052be9c78c7db63589897c3090868f1e5f;hpb=3c938e03dbb186f9c163e19473e9572f7fa16aea;p=kivitendo-erp.git diff --git a/bin/mozilla/wh.pl b/bin/mozilla/wh.pl index 5df5ac052..1f554441b 100644 --- a/bin/mozilla/wh.pl +++ b/bin/mozilla/wh.pl @@ -43,7 +43,9 @@ use SL::CT; use SL::IC; use SL::WH; use SL::OE; +use SL::Locale::String qw(t8); use SL::ReportGenerator; +use SL::Presenter::Part; use SL::DB::Part; @@ -69,6 +71,7 @@ use strict; # $locale->text('return_material') # $locale->text('release_material') # $locale->text('assembled') +# $locale->text('stocktaking') # -------------------------------------------------------------------- # Transfer @@ -108,16 +111,17 @@ sub transfer_warehouse_selection { my $content; if ($form->{trans_type} eq 'removal') { - $form->{nextsub} = "removal_parts_selection"; + setup_wh_transfer_warehouse_selection_action_bar("removal_parts_selection"); $form->{title} = $locale->text('Removal from Warehouse'); $content = $form->parse_html_template('wh/warehouse_selection'); } elsif (!$form->{trans_type} || ($form->{trans_type} eq 'transfer')) { - $form->{nextsub} = "transfer_parts_selection"; + setup_wh_transfer_warehouse_selection_action_bar("transfer_parts_selection"); $form->{title} = $locale->text('Transfer'); $content = $form->parse_html_template('wh/warehouse_selection'); } elsif ($form->{trans_type} eq 'assembly') { + setup_wh_transfer_warehouse_selection_assembly_action_bar(); $form->{title} = $locale->text('Produce Assembly'); $content = $form->parse_html_template('wh/warehouse_selection_assembly'); } @@ -139,6 +143,8 @@ sub transfer_parts_selection { transfer_or_removal_prepare_contents('direction' => 'transfer'); + setup_wh_transfer_parts_action_bar(); + $form->{title} = $locale->text('Transfer'); $form->header(); print $form->parse_html_template("wh/transfer_parts_selection"); @@ -442,6 +448,8 @@ sub removal_parts_selection { transfer_or_removal_prepare_contents('direction' => 'out'); + setup_wh_removal_parts_selection_action_bar(); + $form->{title} = $locale->text('Removal'); $form->header(); print $form->parse_html_template("wh/removal_parts_selection"); @@ -557,6 +565,8 @@ sub journal { show_no_warehouses_error() if (!scalar @{ $form->{WAREHOUSES} }); + setup_wh_journal_action_bar(); + $form->header(); print $form->parse_html_template("wh/journal_filter", { "UNITS" => AM->unit_select_data(AM->retrieve_units(\%myconfig, $form)) }); @@ -593,22 +603,21 @@ sub generate_journal { } # /filter stuff - my $allrows = 0; - $allrows = 1 if $form->{report_generator_output_format} ne 'HTML' ; + my $allrows = !!($form->{report_generator_output_format} ne 'HTML') ; # manual paginating - my $pages = {}; - my $page = $::form->{page} || 1; - $pages->{per_page} = $::form->{per_page} || 15; - my $first_nr = ($page - 1) * $pages->{per_page}; - my $last_nr = $first_nr + $pages->{per_page}; + my $pages = {}; + my $page = $::form->{page} || 1; + $pages->{per_page} = $::form->{per_page} || 15; + my $first_nr = ($page - 1) * $pages->{per_page}; + my $last_nr = $first_nr + $pages->{per_page}; # no optimisation if qty op if ( !$allrows && $form->{maxrows} && !$filter{qty_op}) { $filter{limit} = $pages->{per_page}; $filter{offset} = ($page - 1) * $pages->{per_page}; - $first_nr = 0; - $last_nr = $pages->{per_page}; + $first_nr = 0; + $last_nr = $pages->{per_page}; } my @contents = WH->get_warehouse_journal(%filter); @@ -693,12 +702,9 @@ sub generate_journal { my $idx = 0; foreach my $entry (@contents) { - $entry->{type_and_classific} = $::request->presenter->type_abbreviation($entry->{part_type}). - $::request->presenter->classification_abbreviation($entry->{classification_id}); + $entry->{type_and_classific} = SL::Presenter::Part::type_abbreviation($entry->{part_type}) . + SL::Presenter::Part::classification_abbreviation($entry->{classification_id}); $entry->{qty} = $form->format_amount(\%myconfig, $entry->{qty}); -# $entry->{qty} = $form->format_amount_units('amount' => $entry->{qty}, -# 'part_unit' => $entry->{partunit}, -# 'conv_units' => 'convertible'); $entry->{trans_type} = $locale->text($entry->{trans_type}); my $row = { }; @@ -761,10 +767,11 @@ sub report { $form->{title} = $locale->text("Report about warehouse contents"); + setup_wh_report_action_bar(); + $form->header(); print $form->parse_html_template("wh/report_filter", - { "nextsub" => "generate_report", - "WAREHOUSES" => $form->{WAREHOUSES}, + { "WAREHOUSES" => $form->{WAREHOUSES}, "UNITS" => AM->unit_select_data(AM->retrieve_units(\%myconfig, $form)) }); $main::lxdebug->leave_sub(); @@ -784,7 +791,7 @@ sub generate_report { my $sort_col = $form->{sort}; my %filter; - my @columns = qw(warehousedescription bindescription partnumber type_and_classific partdescription chargenumber bestbefore comment qty partunit purchase_price stock_value); + my @columns = qw(warehousedescription bindescription partnumber type_and_classific partdescription chargenumber bestbefore comment qty partunit list_price purchase_price stock_value); # filter stuff map { $filter{$_} = $form->{$_} if ($form->{$_}) } qw(warehouse_id bin_id classification_id partnumber description chargenumber bestbefore date include_invalid_warehouses); @@ -828,20 +835,19 @@ sub generate_report { $form->{report_generator_output_format} = 'HTML' if !$form->{report_generator_output_format}; # manual paginating - my $allrows = 0; - $allrows = 1 if $form->{report_generator_output_format} ne 'HTML' ; - my $page = $::form->{page} || 1; - my $pages = {}; - $pages->{per_page} = $::form->{per_page} || 20; - my $first_nr = ($page - 1) * $pages->{per_page}; - my $last_nr = $first_nr + $pages->{per_page}; + my $allrows = $form->{report_generator_output_format} eq 'HTML' ? $form->{allrows} : 1; + my $page = $::form->{page} || 1; + my $pages = {}; + $pages->{per_page} = $::form->{per_page} || 20; + my $first_nr = ($page - 1) * $pages->{per_page}; + my $last_nr = $first_nr + $pages->{per_page}; # no optimisation if qty op if ( !$allrows && $form->{maxrows} && !$filter{qty_op}) { $filter{limit} = $pages->{per_page}; $filter{offset} = ($page - 1) * $pages->{per_page}; - $first_nr = 0; - $last_nr = $pages->{per_page}; + $first_nr = 0; + $last_nr = $pages->{per_page}; } my @contents = WH->get_warehouse_report(%filter); @@ -858,7 +864,7 @@ sub generate_report { my @hidden_variables = map { "l_${_}" } @columns; push @hidden_variables, qw(warehouse_id bin_id partnumber partstypes_id description chargenumber bestbefore qty_op qty qty_unit partunit l_warehousedescription l_bindescription); push @hidden_variables, qw(include_empty_bins subtotal include_invalid_warehouses date); - push @hidden_variables, qw(classification_id); + push @hidden_variables, qw(classification_id stock_value_basis); my %column_defs = ( 'warehousedescription' => { 'text' => $locale->text('Warehouse'), }, @@ -871,7 +877,8 @@ sub generate_report { 'qty' => { 'text' => $locale->text('Qty'), }, 'partunit' => { 'text' => $locale->text('Unit'), }, 'stock_value' => { 'text' => $locale->text('Stock value'), }, - 'purchase_price' => { 'text' => $locale->text('Purchase Price'), }, + 'purchase_price' => { 'text' => $locale->text('Purchase price'), }, + 'list_price' => { 'text' => $locale->text('List Price'), }, ); my $href = build_std_url('action=generate_report', grep { $form->{$_} } @hidden_variables); @@ -879,7 +886,7 @@ sub generate_report { map { $column_defs{$_}->{link} = $href . "&page=".$page."&sort=${_}&order=" . Q($_ eq $sort_col ? 1 - $form->{order} : $form->{order}) } @columns; - my %column_alignment = map { $_ => 'right' } qw(qty purchase_price stock_value); + my %column_alignment = map { $_ => 'right' } qw(qty list_price purchase_price stock_value); map { $column_defs{$_}->{visible} = $form->{"l_${_}"} ? 1 : 0 } @columns; @@ -911,8 +918,8 @@ sub generate_report { foreach my $entry (@contents) { - $entry->{type_and_classific} = $::request->presenter->type_abbreviation($entry->{part_type}). - $::request->presenter->classification_abbreviation($entry->{classification_id}); + $entry->{type_and_classific} = SL::Presenter::Part::type_abbreviation($entry->{part_type}). + SL::Presenter::Part::classification_abbreviation($entry->{classification_id}); map { $subtotals{$_} += $entry->{$_} } @subtotals_columns; $total_stock_value += $entry->{stock_value} * 1; $entry->{qty} = $form->format_amount(\%myconfig, $entry->{qty}); @@ -921,6 +928,7 @@ sub generate_report { # 'conv_units' => 'convertible'); $entry->{stock_value} = $form->format_amount(\%myconfig, $entry->{stock_value} * 1, 2); $entry->{purchase_price} = $form->format_amount(\%myconfig, $entry->{purchase_price} * 1, 2); + $entry->{list_price} = $form->format_amount(\%myconfig, $entry->{list_price} * 1, 2); my $row_set = [ { map { $_ => { 'data' => $entry->{$_}, 'align' => $column_alignment{$_} } } @columns } ]; @@ -935,6 +943,7 @@ sub generate_report { # 'conv_units' => 'convertible'); $row->{stock_value}->{data} = $form->format_amount(\%myconfig, $subtotals{stock_value} * 1, 2); $row->{purchase_price}->{data} = $form->format_amount(\%myconfig, $subtotals{purchase_price} * 1, 2); + $row->{list_price}->{data} = $form->format_amount(\%myconfig, $subtotals{list_price} * 1, 2); %subtotals = map { $_ => 0 } @subtotals_columns; @@ -1066,6 +1075,103 @@ sub stock { call_sub($form->{stock_nextsub} || $form->{nextsub}); } +sub setup_wh_transfer_warehouse_selection_action_bar { + my ($action) = @_; + + for my $bar ($::request->layout->get('actionbar')) { + $bar->add( + action => [ + t8('Update'), + submit => [ '#form', { action => $action } ], + accesskey => 'enter', + ], + ); + } +} + +sub setup_wh_transfer_warehouse_selection_assembly_action_bar { + my ($action) = @_; + + for my $bar ($::request->layout->get('actionbar')) { + $bar->add( + action => [ + t8('Update'), + submit => [ '#form', { action => 'transfer_assembly_update_part' } ], + accesskey => 'enter', + ], + action => [ + t8('Produce'), + submit => [ '#form', { action => 'create_assembly' } ], + disabled => $::form->{parts_id} ? undef : $::locale->text('No assembly has been selected yet.'), + ], + ); + } +} + +sub setup_wh_transfer_parts_action_bar { + my ($action) = @_; + + for my $bar ($::request->layout->get('actionbar')) { + $bar->add( + action => [ + t8('Transfer'), + submit => [ '#form', { action => 'transfer_parts' } ], + accesskey => 'enter', + ], + action => [ + t8('Back'), + call => [ 'kivi.history_back' ], + ], + ); + } +} + +sub setup_wh_removal_parts_selection_action_bar { + my ($action) = @_; + + for my $bar ($::request->layout->get('actionbar')) { + $bar->add( + action => [ + t8('Transfer out'), + submit => [ '#form', { action => 'remove_parts' } ], + accesskey => 'enter', + ], + action => [ + t8('Back'), + call => [ 'kivi.history_back' ], + ], + ); + } +} + +sub setup_wh_report_action_bar { + my ($action) = @_; + + for my $bar ($::request->layout->get('actionbar')) { + $bar->add( + action => [ + t8('Show'), + submit => [ '#form', { action => 'generate_report' } ], + accesskey => 'enter', + ], + ); + } +} + +sub setup_wh_journal_action_bar { + my ($action) = @_; + + for my $bar ($::request->layout->get('actionbar')) { + $bar->add( + action => [ + t8('Show'), + submit => [ '#form', { action => 'generate_journal' } ], + accesskey => 'enter', + ], + ); + } +} + 1; __END__