X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FIC.pm;h=4254236db69e42e61e67ba6b8dd45642ead86e5c;hb=07ff196fa5510308b3daa45681574abf23b919ca;hp=bae6354511c890110f90f7195c43b30f55d8e832;hpb=70678a2e8fa05a292cba8a73ef5349a4ece78362;p=kivitendo-erp.git diff --git a/SL/IC.pm b/SL/IC.pm index bae635451..4254236db 100644 --- a/SL/IC.pm +++ b/SL/IC.pm @@ -45,6 +45,7 @@ use SL::HTML::Restrict; use SL::TransNumber; use SL::Util qw(trim); use SL::DB; +use SL::Presenter::Part qw(type_abbreviation classification_abbreviation separate_abbreviation); use Carp; use strict; @@ -128,6 +129,7 @@ sub assembly_item { # # column flags: # l_partnumber l_description l_listprice l_sellprice l_lastcost l_priceupdate l_weight l_unit l_rop l_image l_drawing l_microfiche l_partsgroup +# l_warehouse l_bin # # exclusives: # itemstatus = active | onhand | short | obsolete | orphaned @@ -136,6 +138,8 @@ sub assembly_item { # joining filters: # make model - makemodel # serialnumber transdatefrom transdateto - invoice/orderitems +# warehouse - warehouse +# bin - bin # # binary flags: # bought sold onorder ordered rfq quoted - aggreg joins with invoices/orders @@ -151,6 +155,8 @@ sub assembly_item { # onhand - as above, but masking the simple itemstatus results (doh!) # warehouse onhand # search by overrides of description +# soldtotal drops option default warehouse and bin +# soldtotal can not work if there are no documents checked # # disabled sanity checks and changes: # - searchitems = assembly will no longer disable bought @@ -167,6 +173,9 @@ sub all_parts { my ($self, $myconfig, $form) = @_; my $dbh = $form->get_standard_dbh($myconfig); + # sanity backend check + croak "Cannot combine soldtotal with default bin or default warehouse" if ($form->{l_soldtotal} && ($form->{l_bin} || $form->{l_warehouse})); + $form->{parts} = +{ }; $form->{soldtotal} = undef if $form->{l_soldtotal}; # security fix. top100 insists on putting strings in there... @@ -178,6 +187,7 @@ sub all_parts { my @like_filters = (@simple_filters, @invoice_oi_filters); my @all_columns = (@simple_filters, @makemodel_filters, @apoe_filters, @project_filters, qw(serialnumber)); my @simple_l_switches = (@all_columns, qw(notes listprice sellprice lastcost priceupdate weight unit rop image shop insertdate)); + my %no_simple_l_switches = (warehouse => 'wh.description as warehouse', bin => 'bin.description as bin'); my @oe_flags = qw(bought sold onorder ordered rfq quoted); my @qsooqr_flags = qw(invnumber ordnumber quonumber trans_id name module qty); my @deliverydate_flags = qw(deliverydate); @@ -212,8 +222,10 @@ sub all_parts { ) AS cv ON cv.id = apoe.customer_id OR cv.id = apoe.vendor_id|, mv => 'LEFT JOIN vendor AS mv ON mv.id = mm.make', project => 'LEFT JOIN project AS pj ON pj.id = COALESCE(ioi.project_id, apoe.globalproject_id)', + warehouse => 'LEFT JOIN warehouse AS wh ON wh.id = p.warehouse_id', + bin => 'LEFT JOIN bin ON bin.id = p.bin_id', ); - my @join_order = qw(partsgroup makemodel mv invoice_oi apoe cv pfac project); + my @join_order = qw(partsgroup makemodel mv invoice_oi apoe cv pfac project warehouse bin); my %table_prefix = ( deliverydate => 'apoe.', serialnumber => 'ioi.', @@ -235,7 +247,7 @@ sub all_parts { ); # if the join condition in these blocks are met, the column - # of the scecified table will gently override (coalesce actually) the original value + # of the specified table will gently override (coalesce actually) the original value # use it to conditionally coalesce values from subtables my @column_override = ( # column name, prefix, joins_needed, nick name (in case column is named like another) @@ -302,7 +314,11 @@ sub all_parts { # special case smart search if ($form->{all}) { - $form->{"l_$_"} = 1 for qw(partnumber description unit sellprice lastcost cvar_packaging linetotal); + $form->{"l_$_"} = 1 for qw(partnumber description unit sellprice lastcost linetotal); + $form->{l_service} = 1 if $form->{searchitems} eq 'service' || $form->{searchitems} eq ''; + $form->{l_assembly} = 1 if $form->{searchitems} eq 'assembly' || $form->{searchitems} eq ''; + $form->{l_part} = 1 if $form->{searchitems} eq 'part' || $form->{searchitems} eq ''; + $form->{l_assortment} = 1 if $form->{searchitems} eq 'assortment' || $form->{searchitems} eq ''; push @where_tokens, "p.partnumber ILIKE ? OR p.description ILIKE ?"; push @bind_vars, (like($form->{all})) x 2; } @@ -442,6 +458,8 @@ sub all_parts { $joins_needed{cv} = 1 if $bsooqr; $joins_needed{apoe} = 1 if $joins_needed{project} || $joins_needed{cv} || grep { $form->{$_} || $form->{"l_$_"} } @apoe_filters; $joins_needed{invoice_oi} = 1 if $joins_needed{project} || $joins_needed{apoe} || grep { $form->{$_} || $form->{"l_$_"} } @invoice_oi_filters; + $joins_needed{bin} = 1 if $form->{l_bin}; + $joins_needed{warehouse} = 1 if $form->{l_warehouse}; # special case for description search. # up in the simple filter section the description filter got interpreted as something like: WHERE description ILIKE '%$form->{description}%' @@ -478,6 +496,16 @@ sub all_parts { my $where_clause = join ' AND ', map { "($_)" } @where_tokens; my $group_clause = @group_tokens ? ' GROUP BY ' . join ', ', map { $token_builder->($_) } @group_tokens : ''; + # key of %no_simple_l_switch is the logical l_switch. + # the assigned value is the 'not so simple + # select token' + my $no_simple_select_clause; + foreach my $no_simple_l_switch (keys %no_simple_l_switches) { + next unless $form->{"l_${no_simple_l_switch}"}; + $no_simple_select_clause .= ', '. $no_simple_l_switches{$no_simple_l_switch}; + } + $select_clause .= $no_simple_select_clause; + my %oe_flag_to_cvar = ( bought => 'invoice', sold => 'invoice', @@ -617,8 +645,8 @@ sub get_parts { } $j++; - $form->{"type_and_classific_$j"} = $::request->presenter->type_abbreviation($ref->{part_type}). - $::request->presenter->classification_abbreviation($ref->{classification_id}); + $form->{"type_and_classific_$j"} = type_abbreviation($ref->{part_type}). + classification_abbreviation($ref->{classification_id}); $form->{"id_$j"} = $ref->{id}; $form->{"partnumber_$j"} = $ref->{partnumber}; $form->{"description_$j"} = $ref->{description}; @@ -915,10 +943,11 @@ sub prepare_parts_for_printing { my $id = $form->{"${prefix}${i}"}; next unless $id; my $prt = $parts_by_id{$id}; - my $type_abbr = $::request->presenter->type_abbreviation($prt->part_type); + my $type_abbr = type_abbreviation($prt->part_type); + push @{ $template_arrays{part_type} }, $prt->part_type; push @{ $template_arrays{part_abbreviation} }, $type_abbr; - push @{ $template_arrays{type_and_classific}}, $type_abbr.$::request->presenter->classification_abbreviation($prt->classification_id); - push @{ $template_arrays{separate} }, $::request->presenter->separate_abbreviation($prt->classification_id); + push @{ $template_arrays{type_and_classific}}, $type_abbr . classification_abbreviation($prt->classification_id); + push @{ $template_arrays{separate} }, separate_abbreviation($prt->classification_id); } $main::lxdebug->leave_sub();