Skip to content

Commit

Permalink
Volltextsuche auch bei Verkaufsrechnungen und Deb. Buchungen
Browse files Browse the repository at this point in the history
  • Loading branch information
wernerhahn committed Nov 8, 2024
1 parent 800aaec commit 4bc122b
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 1 deletion.
23 changes: 23 additions & 0 deletions SL/AR.pm
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,29 @@ sub ar_transactions {
}
}

$form->{fulltext} = trim($form->{fulltext});
if ($form->{fulltext}) {
my @fulltext_fields = qw(a.notes
a.intnotes
a.shipvia
a.transaction_description
a.quonumber
a.ordnumber
a.invnumber);
$where .= ' AND (';
$where .= join ' OR ', map {"$_ ILIKE ?"} @fulltext_fields;

$where .= <<SQL;
OR EXISTS (
SELECT files.id FROM files LEFT JOIN file_full_texts ON (file_full_texts.file_id = files.id)
WHERE files.object_id = a.id AND files.object_type = 'invoice'
AND file_full_texts.full_text ILIKE ?)
SQL
$where .= ')'; # end AND

push(@values, like($form->{fulltext})) for 1 .. (scalar @fulltext_fields) + 1;
}

if ($form->{parts_partnumber}) {
$where .= <<SQL;
AND EXISTS (
Expand Down
5 changes: 4 additions & 1 deletion bin/mozilla/ar.pl
Original file line number Diff line number Diff line change
Expand Up @@ -1154,7 +1154,7 @@ sub ar_transactions {
business_id parts_partnumber parts_description department_id
show_marked_as_closed show_not_mailed shippingpoint shipvia taxzone_id
payment_id shiptoname shiptodepartment_1 shiptodepartment_2 shiptostreet
shiptozipcode shiptocity shiptocountry
shiptozipcode shiptocity shiptocountry fulltext
);
push @hidden_variables, map { "cvar_$_->{name}" } @ct_searchable_custom_variables;

Expand Down Expand Up @@ -1331,6 +1331,9 @@ sub ar_transactions {
if ($form->{shiptocountry}) {
push @options, $locale->text('Country (Shipping)') . " : $form->{shiptocountry}";
}
if ($form->{fulltext}) {
push @options, $locale->text('Full Text') . " : $form->{fulltext}";
}

$form->{ALL_PRINTERS} = SL::DB::Manager::Printer->get_all_sorted;

Expand Down
4 changes: 4 additions & 0 deletions templates/design40_webpages/ar/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ <h1>[% title %]</h1>
<tr>
<th class="caption" colspan="2">[% 'Miscellaneous' | $T8 %]</th>
</tr>
<tr>
<th>[% 'Full Text' | $T8 %]</th>
<td>[% L.input_tag('fulltext', '') %]</td>
</tr>
<tr>
<th>[% 'Transaction description' | $T8 %]</th>
<td>[% L.input_tag("transaction_description", "") %]</td>
Expand Down
4 changes: 4 additions & 0 deletions templates/webpages/ar/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ <h1>[% title %]</h1>
<th align="right">[% 'Part Number' | $T8 %]</th>
<td>[% L.input_tag("parts_partnumber", "", style=style) %]</td>
</tr>
<tr>
<th align="right">[% 'Full Text' | $T8 %]</th>
<td>[% L.input_tag('fulltext', '', style=style) %]</td>
</tr>
<tr>
<th align=right nowrap>[% 'Shipping Point' | $T8 %]</th>
<td>[% L.input_tag("shippingpoint", "", style=style) %]</td>
Expand Down

0 comments on commit 4bc122b

Please sign in to comment.