X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fwh.pl;h=5c0a5e7d0937e29db4da2107b0db9e6026b32586;hb=612e3ebee1757bdc62db37fa348f028c36157ed4;hp=aa22c51d5797a60041737ecf85b191c4523923dc;hpb=8c6da40329649dd3015da8364e831e0e47155694;p=kivitendo-erp.git diff --git a/bin/mozilla/wh.pl b/bin/mozilla/wh.pl index aa22c51d5..5c0a5e7d0 100644 --- a/bin/mozilla/wh.pl +++ b/bin/mozilla/wh.pl @@ -44,6 +44,8 @@ use SL::WH; use SL::OE; use SL::ReportGenerator; +use SL::DB::Part; + use Data::Dumper; require "bin/mozilla/common.pl"; @@ -65,6 +67,7 @@ use strict; # $locale->text('used') # $locale->text('return_material') # $locale->text('release_material') +# $locale->text('assembled') # -------------------------------------------------------------------- # Transfer @@ -85,8 +88,16 @@ sub transfer_warehouse_selection { show_no_warehouses_error() if (!scalar @{ $form->{WAREHOUSES} }); my $units = AM->retrieve_units(\%myconfig, $form); + + my $part = 0; + if ( $form->{parts_id} ) { + $part = SL::DB::Part->new(); + $part->id($form->{parts_id}); + $part->load(); + } + # der zweite Parameter von unit_select_data gibt den default-Namen (selected) vor - $form->{UNITS} = AM->unit_select_data($units, $form->{partunit}, 0, $form->{partunit}); + $form->{UNITS} = AM->unit_select_data($units, $form->{unit}, 0, $part ? $part->unit : 0); if (scalar @{ $form->{WAREHOUSES} }) { $form->{warehouse_id} ||= $form->{WAREHOUSES}->[0]->{id}; @@ -95,8 +106,6 @@ sub transfer_warehouse_selection { my $content; - $form->{jsscript} = 1; - if ($form->{trans_type} eq 'removal') { $form->{nextsub} = "removal_parts_selection"; $form->{title} = $locale->text('Removal from Warehouse'); @@ -176,7 +185,9 @@ sub transfer_or_removal_prepare_contents { "ean" => $form->{ean}, "description" => $form->{description}); - $form->show_generic_error($locale->text("The selected warehouse is empty.")) if (0 == scalar(@contents)); + if (0 == scalar(@contents)) { + $form->show_generic_error($locale->text("The selected warehouse is empty, or no stocked items where found that match the filter settings.")); + } my $all_units = AM->retrieve_units(\%myconfig, $form); @@ -270,6 +281,7 @@ sub transfer_parts { } $transfer->{comment} = $form->{comment}; + $transfer->{change_default_bin} = $form->{change_default_bin}; push @transfers, $transfer; @@ -311,7 +323,7 @@ sub transfer_stock_update_part { } elsif (($form->{partnumber} && ($form->{partnumber} ne $form->{old_partnumber})) || $form->{description} || $form->{ean}) { - $form->{no_services} = 1; +# $form->{no_services} = 1; # services may now be transfered. fix for Bug 1383. $form->{no_assemblies} = 0; # assemblies duerfen eingelagert werden (z.B. bei retouren) my $parts = Common->retrieve_parts(\%myconfig, $form, 'description', 1); @@ -319,7 +331,7 @@ sub transfer_stock_update_part { if (!scalar @{ $parts }) { new_item(action => "transfer_stock_update_part"); } elsif (scalar @{ $parts } == 1) { - @{$form}{qw(parts_id partnumber description ean)} = @{$parts->[0]}{qw(id partnumber description ean)}; + @{$form}{qw(parts_id partnumber description ean warehouse_id bin_id)} = @{$parts->[0]}{qw(id partnumber description ean warehouse_id bin_id)}; transfer_stock_get_partunit(); transfer_warehouse_selection(); @@ -386,7 +398,7 @@ sub transfer_stock_part_selected { my $form = $main::form; - @{$form}{qw(parts_id partnumber description ean)} = @{$part}{qw(id partnumber description ean)}; + @{$form}{qw(parts_id partnumber description ean warehouse_id bin_id)} = @{$part}{qw(id partnumber description ean warehouse_id bin_id)}; transfer_stock_get_partunit(); transfer_warehouse_selection(); @@ -436,7 +448,7 @@ sub create_assembly { $form->error($locale->text('The warehouse or the bin is missing.')); } - if (!$main::show_best_before) { + if (!$::instance_conf->get_show_bestbefore) { $form->{bestbefore} = ''; } @@ -444,7 +456,7 @@ sub create_assembly { # Anm. jb 18.3. vielleicht auch nur meine unwissenheit in perl-datenstrukturen my %TRANSFER = ( 'transfer_type' => 'assembly', - 'login' => $form->{login}, + 'login' => $::myconfig{login}, 'dst_warehouse_id' => $form->{warehouse_id}, 'dst_bin_id' => $form->{bin_id}, 'chargenumber' => $form->{chargenumber}, @@ -644,8 +656,6 @@ sub journal { show_no_warehouses_error() if (!scalar @{ $form->{WAREHOUSES} }); - $form->{jsscript} = 1; - $form->header(); print $form->parse_html_template("wh/journal_filter", { "UNITS" => AM->unit_select_data(AM->retrieve_units(\%myconfig, $form)) }); @@ -722,6 +732,7 @@ sub generate_journal { 'title' => $form->{title}, 'attachment_basename' => strftime($locale->text('warehouse_journal_list') . '_%Y%m%d', localtime time)); $report->set_options_from_form(); + $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv'; my $all_units = AM->retrieve_units(\%myconfig, $form); my @contents = WH->get_warehouse_journal(%filter); @@ -789,10 +800,6 @@ sub report { show_no_warehouses_error() if (!scalar @{ $form->{WAREHOUSES} }); - $form->{jsscript} = 1; - -# $form->{fokus} = "partnumber"; -# $form->{onload} .= "focus();"; $form->{title} = $locale->text("Report about warehouse contents"); $form->header(); @@ -821,7 +828,27 @@ sub generate_report { my @columns = qw(warehousedescription bindescription partnumber partdescription chargenumber bestbefore qty stock_value); # filter stuff - map { $filter{$_} = $form->{$_} if ($form->{$_}) } qw(warehouse_id bin_id partnumber description chargenumber bestbefore); + map { $filter{$_} = $form->{$_} if ($form->{$_}) } qw(warehouse_id bin_id partnumber description chargenumber bestbefore date include_invalid_warehouses); + + # show filter stuff also in report + my @options; + # dispatch all options + my $dispatch_options = { + warehouse_id => sub { push @options, $locale->text('Warehouse') . " : " . + SL::DB::Manager::Warehouse->find_by(id => $form->{warehouse_id})->description}, + bin_id => sub { push @options, $locale->text('Bin') . " : " . + SL::DB::Manager::Bin->find_by(id => $form->{bin_id})->description}, + partnumber => sub { push @options, $locale->text('Partnumber') . " : $form->{partnumber}"}, + description => sub { push @options, $locale->text('Description') . " : $form->{description}"}, + chargenumber => sub { push @options, $locale->text('Charge Number') . " : $form->{chargenumber}"}, + bestbefore => sub { push @options, $locale->text('Best Before') . " : $form->{bestbefore}"}, + date => sub { push @options, $locale->text('Date') . " : $form->{date}"}, + include_invalid_warehouses => sub { push @options, $locale->text('Include invalid warehouses ')}, + }; + foreach (keys %filter) { + $dispatch_options->{$_}->() if $dispatch_options->{$_}; + } + # / end show filter stuff also in report $filter{qty_op} = WH->convert_qty_op($form->{qty_op}); if ($filter{qty_op}) { @@ -839,7 +866,7 @@ sub generate_report { my @hidden_variables = map { "l_${_}" } @columns; push @hidden_variables, qw(warehouse_id bin_id partnumber description chargenumber bestbefore qty_op qty qty_unit l_warehousedescription l_bindescription); - push @hidden_variables, qw(include_empty_bins subtotal); + push @hidden_variables, qw(include_empty_bins subtotal include_invalid_warehouses date); my %column_defs = ( 'warehousedescription' => { 'text' => $locale->text('Warehouse'), }, @@ -866,10 +893,12 @@ sub generate_report { $report->set_sort_indicator($sort_col, $form->{order}); - $report->set_options('output_format' => 'HTML', + $report->set_options('top_info_text' => join("\n", @options), + 'output_format' => 'HTML', 'title' => $form->{title}, 'attachment_basename' => strftime($locale->text('warehouse_report_list') . '_%Y%m%d', localtime time)); $report->set_options_from_form(); + $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv'; my $all_units = AM->retrieve_units(\%myconfig, $form); my @contents = WH->get_warehouse_report(%filter); @@ -892,7 +921,7 @@ sub generate_report { my $row_set = [ { map { $_ => { 'data' => $entry->{$_}, 'align' => $column_alignment{$_} } } @columns } ]; - if (($form->{subtotal} eq 'Y') + if ( ($form->{subtotal} eq 'Y' && !$form->{report_generator_csv_options_for_import} ) && (($idx == (scalar @contents - 1)) || ($entry->{$sort_col} ne $contents[$idx + 1]->{$sort_col}))) { @@ -912,7 +941,7 @@ sub generate_report { $idx++; } - if ($column_defs{stock_value}->{visible}) { + if ( $column_defs{stock_value}->{visible} && !$form->{report_generator_csv_options_for_import} ) { $report->add_separator(); my $row = { map { $_ => { 'data' => '', 'class' => 'listsubtotal', } } @columns }; @@ -944,7 +973,7 @@ sub show_no_warehouses_error { my $msg = $locale->text('No warehouse has been created yet or the quantity of the bins is not configured yet.') . ' '; - if ($main::auth->check_right($form->{login}, 'config')) { + if ($main::auth->check_right($::myconfig{login}, 'config')) { $msg .= $locale->text('You can create warehouses and bins via the menu "System -> Warehouses".'); } else { $msg .= $locale->text('Please ask your administrator to create warehouses and bins.');