Revision 47c3bf62
Von Moritz Bunkus vor fast 16 Jahren hinzugefügt
SL/IC.pm | ||
---|---|---|
1796 | 1796 |
return %info_map; |
1797 | 1797 |
} |
1798 | 1798 |
|
1799 |
sub prepare_parts_for_printing { |
|
1800 |
$main::lxdebug->enter_sub(); |
|
1801 |
|
|
1802 |
my $self = shift; |
|
1803 |
my %params = @_; |
|
1804 |
|
|
1805 |
my $myconfig = \%main::myconfig; |
|
1806 |
my $form = $main::form; |
|
1807 |
|
|
1808 |
my $dbh = $params{dbh} || $form->get_standard_dbh($myconfig); |
|
1809 |
|
|
1810 |
my $prefix = $params{prefix} || 'id_'; |
|
1811 |
my $rowcount = defined $params{rowcount} ? $params{rowcount} : $form->{rowcount}; |
|
1812 |
|
|
1813 |
my @part_ids = keys %{ { map { $_ => 1 } grep { $_ } map { $form->{"${prefix}${_}"} } (1 .. $rowcount) } }; |
|
1814 |
|
|
1815 |
if (!@part_ids) { |
|
1816 |
$main::lxdebug->leave_sub(); |
|
1817 |
return; |
|
1818 |
} |
|
1819 |
|
|
1820 |
my $placeholders = join ', ', ('?') x scalar(@part_ids); |
|
1821 |
my $query = qq|SELECT parts_id, make, model |
|
1822 |
FROM makemodel |
|
1823 |
WHERE parts_id IN ($placeholders)|; |
|
1824 |
my %makemodel = (); |
|
1825 |
|
|
1826 |
my $sth = prepare_execute_query($form, $dbh, $query, @part_ids); |
|
1827 |
|
|
1828 |
while (my $ref = $sth->fetchrow_hashref()) { |
|
1829 |
$makemodel{$ref->{parts_id}} ||= []; |
|
1830 |
push @{ $makemodel{$ref->{parts_id}} }, $ref; |
|
1831 |
} |
|
1832 |
|
|
1833 |
$sth->finish(); |
|
1834 |
|
|
1835 |
my @columns = qw(ean); |
|
1836 |
|
|
1837 |
$query = qq|SELECT id, | . join(', ', @columns) . qq| |
|
1838 |
FROM parts |
|
1839 |
WHERE id IN ($placeholders)|; |
|
1840 |
|
|
1841 |
my %data = selectall_as_map($form, $dbh, $query, 'id', \@columns, @part_ids); |
|
1842 |
|
|
1843 |
map { $form->{$_} = [] } (qw(make model), @columns); |
|
1844 |
|
|
1845 |
foreach my $i (1 .. $rowcount) { |
|
1846 |
my $id = $form->{"${prefix}${i}"}; |
|
1847 |
|
|
1848 |
next if (!$id); |
|
1849 |
|
|
1850 |
foreach (@columns) { |
|
1851 |
push @{ $form->{$_} }, $data{$id}->{$_}; |
|
1852 |
} |
|
1853 |
|
|
1854 |
push @{ $form->{make} }, []; |
|
1855 |
push @{ $form->{model} }, []; |
|
1856 |
|
|
1857 |
next if (!$makemodel{$id}); |
|
1858 |
|
|
1859 |
foreach my $ref (@{ $makemodel{$id} }) { |
|
1860 |
map { push @{ $form->{$_}->[-1] }, $ref->{$_} } qw(make model); |
|
1861 |
} |
|
1862 |
} |
|
1863 |
|
|
1864 |
$main::lxdebug->leave_sub(); |
|
1865 |
} |
|
1866 |
|
|
1799 | 1867 |
|
1800 | 1868 |
1; |
Auch abrufbar als: Unified diff
Einige Variablen der Warenstammdaten auch beim Ausdruck zur Verfügung stellen: ean, make, model.