X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fwh.pl;h=2e812f31f1333cb52fd180ba2665906a69d59fe7;hb=3c22e5f4b953f463a33b722d6f4f122e4a20c99a;hp=f4b2d5f10925a8924e2e0fa04a365dbe69e220ab;hpb=36965d410fb789753a90633541b6c58ca210499e;p=kivitendo-erp.git diff --git a/bin/mozilla/wh.pl b/bin/mozilla/wh.pl index f4b2d5f10..2e812f31f 100644 --- a/bin/mozilla/wh.pl +++ b/bin/mozilla/wh.pl @@ -39,6 +39,7 @@ use SL::Form; use SL::User; use SL::AM; +use SL::CVar; use SL::CT; use SL::IC; use SL::WH; @@ -765,6 +766,9 @@ sub report { show_no_warehouses_error() if (!scalar @{ $form->{WAREHOUSES} }); + my $CVAR_CONFIGS = SL::DB::Manager::CustomVariableConfig->get_all_sorted(where => [ module => 'IC' ]); + my $INCLUDABLE_CVAR_CONFIGS = [ grep { $_->includeable } @{ $CVAR_CONFIGS } ]; + $form->{title} = $locale->text("Report about warehouse contents"); setup_wh_report_action_bar(); @@ -772,7 +776,10 @@ sub report { $form->header(); print $form->parse_html_template("wh/report_filter", { "WAREHOUSES" => $form->{WAREHOUSES}, - "UNITS" => AM->unit_select_data(AM->retrieve_units(\%myconfig, $form)) }); + "UNITS" => AM->unit_select_data(AM->retrieve_units(\%myconfig, $form)), + # "CVAR_CONFIGS" => $CVAR_CONFIGS, # nyi searchable cvars + "INCLUDABLE_CVAR_CONFIGS" => $INCLUDABLE_CVAR_CONFIGS, + }); $main::lxdebug->leave_sub(); } @@ -786,12 +793,14 @@ sub generate_report { my %myconfig = %main::myconfig; my $locale = $main::locale; + my $cvar_configs = CVar->get_configs('module' => 'IC'); + $form->{title} = $locale->text("Report about warehouse contents"); $form->{sort} ||= 'partnumber'; 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); @@ -835,7 +844,7 @@ sub generate_report { $form->{report_generator_output_format} = 'HTML' if !$form->{report_generator_output_format}; # manual paginating - my $allrows = !!($form->{report_generator_output_format} ne 'HTML') ; + 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; @@ -861,10 +870,13 @@ sub generate_report { my $report = SL::ReportGenerator->new(\%myconfig, $form); + my @includeable_custom_variables = grep { $_->{includeable} } @{ $cvar_configs }; + push @columns, map { "cvar_$_->{name}" } @includeable_custom_variables; + 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 allrows); my %column_defs = ( 'warehousedescription' => { 'text' => $locale->text('Warehouse'), }, @@ -878,14 +890,17 @@ sub generate_report { 'partunit' => { 'text' => $locale->text('Unit'), }, 'stock_value' => { 'text' => $locale->text('Stock value'), }, '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); $href .= "&maxrows=".$form->{maxrows}; + my %column_defs_cvars = map { +"cvar_$_->{name}" => { 'text' => $_->{description} } } @includeable_custom_variables; + %column_defs = (%column_defs, %column_defs_cvars); 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; @@ -906,6 +921,11 @@ sub generate_report { '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'; + CVar->add_custom_variables_to_report('module' => 'IC', + 'trans_id_field' => 'parts_id', + 'configs' => $cvar_configs, + 'column_defs' => \%column_defs, + 'data' => \@contents); my $all_units = AM->retrieve_units(\%myconfig, $form); my $idx = 0; @@ -927,6 +947,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 } ]; @@ -941,6 +962,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;