X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/a4e4f1a7ca65293cc7f3c45e29fc31571b4e91dd..001155e424a519b543499cdb1f1841f48cfae352:/SL/IS.pm diff --git a/SL/IS.pm b/SL/IS.pm index e3ed35ff0..29886a5bb 100644 --- a/SL/IS.pm +++ b/SL/IS.pm @@ -1174,6 +1174,17 @@ sub post_invoice { Common::webdav_folder($form); + if ($form->{convert_from_ar_ids}) { + RecordLinks->create_links('dbh' => $dbh, + 'mode' => 'ids', + 'from_table' => 'ar', + 'from_ids' => $form->{convert_from_ar_ids}, + 'to_table' => 'ar', + 'to_id' => $form->{id}, + ); + delete $form->{convert_from_ar_ids}; + } + # Link this record to the records it was created from. RecordLinks->create_links('dbh' => $dbh, 'mode' => 'ids', @@ -1910,10 +1921,23 @@ sub retrieve_item { push @values, '%' . $form->{"${field}_${i}"} . '%'; } - #Es soll auch nach EAN gesucht werden, ohne Einschränkung durch Beschreibung + my (%mm_by_id); if ($form->{"partnumber_$i"} && !$form->{"description_$i"}) { $where .= qq| OR (NOT p.obsolete = '1' AND p.ean = ? )|; push @values, $form->{"partnumber_$i"}; + + # also search hits in makemodels, but only cache the results by id and merge later + my $mm_query = qq| + SELECT parts_id, model FROM makemodel LEFT JOIN parts ON parts.id = parts_id WHERE NOT parts.obsolete AND model ILIKE ?; + |; + my $mm_results = selectall_hashref_query($::form, $dbh, $mm_query, '%' . $form->{"partnumber_$i"} . '%'); + my @mm_ids = map { $_->{parts_id} } @$mm_results; + push @{$mm_by_id{ $_->{parts_id} } ||= []}, $_ for @$mm_results; + + if (@mm_ids) { + $where .= qq| OR p.id IN (| . join(',', ('?') x @mm_ids) . qq|)|; + push @values, @mm_ids; + } } # Search for part ID overrides all other criteria. @@ -1947,6 +1971,7 @@ sub retrieve_item { qq|SELECT p.id, p.partnumber, p.description, p.sellprice, p.listprice, p.inventory_accno_id, p.lastcost, + p.ean, c1.accno AS inventory_accno, c1.new_chart_id AS inventory_new_chart, @@ -2002,6 +2027,15 @@ sub retrieve_item { while (my $ref = $sth->fetchrow_hashref('NAME_lc')) { + if ($mm_by_id{$ref->{id}}) { + $ref->{makemodels} = $mm_by_id{$ref->{id}}; + push @{ $ref->{matches} ||= [] }, $::locale->text('Model') . ': ' . join ', ', map { $_->{model} } @{ $mm_by_id{$ref->{id}} }; + } + + if ($ref->{ean} eq $::form->{"partnumber_$i"}) { + push @{ $ref->{matches} ||= [] }, $::locale->text('EAN') . ': ' . $ref->{ean}; + } + # In der Buchungsgruppe ist immer ein Bestandskonto verknuepft, auch wenn # es sich um eine Dienstleistung handelt. Bei Dienstleistungen muss das # Buchungskonto also aus dem Ergebnis rausgenommen werden.