use Data::Dumper;
use List::MoreUtils qw(all any uniq);
-use YAML;
use SL::CVar;
use SL::DBUtils;
SQL
my $query_tax = <<SQL;
- SELECT c.accno, t.taxdescription AS description, t.rate, t.taxnumber
+ SELECT c.accno, t.taxdescription AS description, t.rate,
+ c.accno as taxnumber
FROM tax t
LEFT JOIN chart c ON c.id = t.chart_id
WHERE t.id IN
$sth->finish();
+ $query = qq|SELECT
+ cp.parts_id,
+ cp.customer_partnumber AS customer_model,
+ c.name AS customer_make
+ FROM part_customer_prices cp
+ LEFT JOIN customer c ON (cp.customer_id = c.id)
+ WHERE cp.parts_id IN ($placeholders)|;
+
+ my %customermodel = ();
+
+ $sth = prepare_execute_query($form, $dbh, $query, @part_ids);
+
+ while (my $ref = $sth->fetchrow_hashref()) {
+ $customermodel{$ref->{parts_id}} ||= [];
+ push @{ $customermodel{$ref->{parts_id}} }, $ref;
+ }
+
+ $sth->finish();
+
my @columns = qw(ean image microfiche drawing);
$query = qq|SELECT id, | . join(', ', @columns) . qq|
my %data = selectall_as_map($form, $dbh, $query, 'id', \@columns, @part_ids);
my %template_arrays;
- map { $template_arrays{$_} = [] } (qw(make model), @columns);
+ map { $template_arrays{$_} = [] } (qw(make model customer_make customer_model), @columns);
foreach my $i (1 .. $rowcount) {
my $id = $form->{"${prefix}${i}"};
push @{ $template_arrays{make} }, [];
push @{ $template_arrays{model} }, [];
- next if (!$makemodel{$id});
+ if ($makemodel{$id}) {
+ foreach my $ref (@{ $makemodel{$id} }) {
+ map { push @{ $template_arrays{$_}->[-1] }, $ref->{$_} } qw(make model);
+ }
+ }
+
+ push @{ $template_arrays{customer_make} }, [];
+ push @{ $template_arrays{customer_model} }, [];
- foreach my $ref (@{ $makemodel{$id} }) {
- map { push @{ $template_arrays{$_}->[-1] }, $ref->{$_} } qw(make model);
+ if ($customermodel{$id}) {
+ foreach my $ref (@{ $customermodel{$id} }) {
+ push @{ $template_arrays{$_}->[-1] }, $ref->{$_} for qw(customer_make customer_model);
+ }
}
+
}
my $parts = SL::DB::Manager::Part->get_all(query => [ id => \@part_ids ]);
return %template_arrays;
}
-sub normalize_text_blocks {
- $main::lxdebug->enter_sub();
-
- my $self = shift;
- my %params = @_;
-
- my $form = $params{form} || $main::form;
-
- # check if feature is enabled (select normalize_part_descriptions from defaults)
- return unless ($::instance_conf->get_normalize_part_descriptions);
-
- foreach (qw(description notes)) {
- $form->{$_} =~ s/\s+$//s;
- $form->{$_} =~ s/^\s+//s;
- $form->{$_} =~ s/ {2,}/ /g;
- }
- $main::lxdebug->leave_sub();
-}
-
-
1;