X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/455d008cdb1c6e53d442e94babfd6412cce34c38..000ba9b8aba4ba5c32507544afd7d790b53e11a7:/bin/mozilla/wh.pl diff --git a/bin/mozilla/wh.pl b/bin/mozilla/wh.pl index b7750f2ca..8cf3226db 100644 --- a/bin/mozilla/wh.pl +++ b/bin/mozilla/wh.pl @@ -574,6 +574,12 @@ sub journal { show_no_warehouses_error() if (!scalar @{ $form->{WAREHOUSES} }); + my $cvar_configs = CVar->get_configs('module' => 'IC'); + ($form->{CUSTOM_VARIABLES_FILTER_CODE}, + $form->{CUSTOM_VARIABLES_INCLUSION_CODE}) = CVar->render_search_options('variables' => $cvar_configs, + 'include_prefix' => 'l_', + 'include_value' => 'Y'); + setup_wh_journal_action_bar(); $form->header(); @@ -641,9 +647,18 @@ sub generate_journal { my $report = SL::ReportGenerator->new(\%myconfig, $form); + my $cvar_configs = CVar->get_configs('module' => 'IC'); + my @includeable_custom_variables = grep { $_->{includeable} } @{ $cvar_configs }; + my @searchable_custom_variables = grep { $_->{searchable} } @{ $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 description chargenumber bestbefore qty_op qty qty_unit unit partunit fromdate todate transtype_ids comment projectnumber); push @hidden_variables, qw(classification_id); + push @hidden_variables, map({'cvar_'. $_->{name}} @searchable_custom_variables); + push @hidden_variables, map({'cvar_'. $_->{name} .'_from'} grep({$_->{type} eq 'date'} @searchable_custom_variables)); + push @hidden_variables, map({'cvar_'. $_->{name} .'_to'} grep({$_->{type} eq 'date'} @searchable_custom_variables)); + push @hidden_variables, map({'cvar_'. $_->{name} .'_qtyop'} grep({$_->{type} eq 'number'} @searchable_custom_variables)); my %column_defs = ( 'ids' => { raw_header_data => checkbox_tag("", id => "check_all", checkall => "[data-checkall=1]") }, @@ -669,6 +684,9 @@ sub generate_journal { 'oe_id' => { 'text' => $locale->text('Document'), }, ); + my %column_defs_cvars = map { +"cvar_$_->{name}" => { 'text' => $_->{description} } } @includeable_custom_variables; + %column_defs = (%column_defs, %column_defs_cvars); + if ($form->{transtype_ids} && 'ARRAY' eq ref $form->{transtype_ids}) { for (my $i = 0; $i < scalar(@{ $form->{transtype_ids} }); $i++) { delete $form->{transtype_ids}[$i] if $form->{transtype_ids}[$i] eq ''; @@ -679,7 +697,7 @@ sub generate_journal { my $href = build_std_url('action=generate_journal', grep { $form->{$_} } @hidden_variables); $href .= "&maxrows=".$form->{maxrows}; - map { $column_defs{$_}->{link} = $href ."&page=".$page. "&sort=${_}&order=" . Q($_ eq $form->{sort} ? 1 - $form->{order} : $form->{order}) } @columns; + map { $column_defs{$_}->{link} = $href ."&page=".$page. "&sort=${_}&order=" . Q($_ eq $form->{sort} ? 1 - $form->{order} : $form->{order}) } grep {!/^cvar/} @columns; my %column_alignment = map { $_ => 'right' } qw(qty); @@ -704,6 +722,13 @@ sub generate_journal { my $all_units = AM->retrieve_units(\%myconfig, $form); + CVar->add_custom_variables_to_report('module' => 'IC', + 'trans_id_field' => 'parts_id', + 'configs' => $cvar_configs, + 'column_defs' => \%column_defs, + 'data' => \@contents); + + my %doc_types = ( 'sales_quotation' => { script => 'oe', title => $locale->text('Sales quotation') }, 'sales_order' => { script => 'oe', title => $locale->text('Sales Order') }, 'request_quotation' => { script => 'oe', title => $locale->text('Request quotation') }, @@ -786,12 +811,16 @@ sub report { my $locale = $main::locale; $form->get_lists('warehouses' => { 'key' => 'WAREHOUSES', - 'bins' => 'BINS', }); + 'bins' => 'BINS', }, + 'partsgroup' => 'PARTSGROUPS'); 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 } ]; + my $cvar_configs = CVar->get_configs('module' => 'IC'); + ($form->{CUSTOM_VARIABLES_FILTER_CODE}, + $form->{CUSTOM_VARIABLES_INCLUSION_CODE}) = CVar->render_search_options('variables' => $cvar_configs, + 'include_prefix' => 'l_', + 'include_value' => 'Y'); $form->{title} = $locale->text("Report about warehouse contents"); @@ -799,10 +828,9 @@ 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)), - # "CVAR_CONFIGS" => $CVAR_CONFIGS, # nyi searchable cvars - "INCLUDABLE_CVAR_CONFIGS" => $INCLUDABLE_CVAR_CONFIGS, + { "WAREHOUSES" => $form->{WAREHOUSES}, + "PARTSGROUPS" => $form->{PARTSGROUPS}, + "UNITS" => AM->unit_select_data(AM->retrieve_units(\%myconfig, $form)), }); $main::lxdebug->leave_sub(); @@ -817,8 +845,6 @@ 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}; @@ -827,7 +853,7 @@ sub generate_report { 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); + map { $filter{$_} = $form->{$_} if ($form->{$_}) } qw(warehouse_id bin_id classification_id partnumber description partsgroup_id chargenumber bestbefore date include_invalid_warehouses); # show filter stuff also in report my @options; @@ -844,6 +870,8 @@ sub generate_report { classification_id => sub { push @options, $locale->text('Parts Classification'). " : ". SL::DB::Manager::PartClassification->get_first(where => [ id => $form->{classification_id} ] )->description; }, description => sub { push @options, $locale->text('Description') . " : $form->{description}"}, + partsgroup_id => sub { push @options, $locale->text('Partsgroup') . " : " . + SL::DB::PartsGroup->new(id => $form->{partsgroup_id})->load->partsgroup}, chargenumber => sub { push @options, $locale->text('Charge Number') . " : $form->{chargenumber}"}, bestbefore => sub { push @options, $locale->text('Best Before') . " : $form->{bestbefore}"}, include_invalid_warehouses => sub { push @options, $locale->text('Include invalid warehouses ')}, @@ -894,13 +922,19 @@ sub generate_report { my $report = SL::ReportGenerator->new(\%myconfig, $form); + my $cvar_configs = CVar->get_configs('module' => 'IC'); my @includeable_custom_variables = grep { $_->{includeable} } @{ $cvar_configs }; + my @searchable_custom_variables = grep { $_->{searchable} } @{ $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(warehouse_id bin_id partnumber partstypes_id description partsgroup_id 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 stock_value_basis allrows); + push @hidden_variables, map({'cvar_'. $_->{name}} @searchable_custom_variables); + push @hidden_variables, map({'cvar_'. $_->{name} .'_from'} grep({$_->{type} eq 'date'} @searchable_custom_variables)); + push @hidden_variables, map({'cvar_'. $_->{name} .'_to'} grep({$_->{type} eq 'date'} @searchable_custom_variables)); + push @hidden_variables, map({'cvar_'. $_->{name} .'_qtyop'} grep({$_->{type} eq 'number'} @searchable_custom_variables)); my %column_defs = ( 'warehousedescription' => { 'text' => $locale->text('Warehouse'), }, @@ -917,12 +951,13 @@ sub generate_report { 'list_price' => { 'text' => $locale->text('List Price'), }, ); + my %column_defs_cvars = map { +"cvar_$_->{name}" => { 'text' => $_->{description} } } @includeable_custom_variables; + %column_defs = (%column_defs, %column_defs_cvars); + 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; + map { $column_defs{$_}->{link} = $href . "&page=".$page."&sort=${_}&order=" . Q($_ eq $sort_col ? 1 - $form->{order} : $form->{order}) } grep {!/^cvar_/} @columns; my %column_alignment = map { $_ => 'right' } qw(qty list_price purchase_price stock_value);