description => 'p.',
qty => 'ioi.',
serialnumber => 'ioi.',
+ quotation => 'apoe.',
+ cv => 'cv.',
);
# if the join condition in these blocks are met, the column
# column name, prefix, joins_needed
[ 'description', 'ioi.', 'invoice_oi' ],
[ 'deliverydate', 'ioi.', 'invoice_oi' ],
- [ 'transdate' , 'apoe.', 'apoe' ],
- [ 'unit' , 'ioi.', 'invoice_oi' ],
+ [ 'transdate', 'apoe.', 'apoe' ],
+ [ 'unit', 'ioi.', 'invoice_oi' ],
);
# careful with renames. these are HARD, and any filters done on the original column will break
my $make_token_builder = sub {
my $joins_needed = shift;
sub {
- my ($col, $group) = @_;
+ my ($col, $alias) = @_;
my @coalesce_tokens =
map { ($_->[1] || 'p.') . $_->[0] }
grep { !$_->[2] || $joins_needed->{$_->[2]} }
- grep { $_->[0] eq $col }
+ grep { $_->[0] eq $col }
@column_override, [ $col, $table_prefix{$col} ];
my $coalesce = scalar @coalesce_tokens > 1;
return ($coalesce
? sprintf 'COALESCE(%s)', join ', ', @coalesce_tokens
: shift @coalesce_tokens)
- . ($group && ($coalesce || $renamed_columns{$col})
+ . ($alias && ($coalesce || $renamed_columns{$col})
? " AS " . ($renamed_columns{$col} || $col)
: '');
}
my $bsooqr = any { $form->{$_} } @oe_flags;
my @bsooqr_tokens = ();
- push @select_tokens, @qsooqr_flags if $bsooqr;
+ push @select_tokens, @qsooqr_flags, 'quotation', 'cv' if $bsooqr;
push @select_tokens, @deliverydate_flags if $bsooqr && $form->{l_deliverydate};
push @select_tokens, $q_assembly_lastcost if ($form->{searchitems} eq 'assembly') && $form->{l_lastcost};
push @bsooqr_tokens, q|module = 'ir' AND NOT ioi.assemblyitem| if $form->{bought};
my $dbh = $form->get_standard_dbh($myconfig);
- my $query = qq|SELECT id, partnumber, description, unit FROM parts WHERE id IN (| . join(', ', ('?') x scalar(@ids)) . qq|)|;
+ my $query = qq|SELECT * FROM parts WHERE id IN (| . join(', ', ('?') x scalar(@ids)) . qq|)|;
my $info = selectall_hashref_query($form, $dbh, $query, map { conv_i($_) } @ids);