Einkaufsrechnungen: Suche nach Artikelnummer/-beschreibung in Positionen
authorMoritz Bunkus <m.bunkus@linet-services.de>
Mon, 25 Apr 2016 13:01:34 +0000 (15:01 +0200)
committerMoritz Bunkus <m.bunkus@linet-services.de>
Mon, 25 Apr 2016 13:07:23 +0000 (15:07 +0200)
SL/AP.pm
bin/mozilla/ap.pl
templates/webpages/ap/search.html

index 9e108a1..92dc733 100644 (file)
--- a/SL/AP.pm
+++ b/SL/AP.pm
@@ -507,6 +507,33 @@ sub ap_transactions {
     }
   }
 
+  if ($form->{parts_partnumber}) {
+    $where .= <<SQL;
+      AND EXISTS (
+        SELECT invoice.trans_id
+        FROM invoice
+        LEFT JOIN parts ON (invoice.parts_id = parts.id)
+        WHERE (invoice.trans_id = a.id)
+          AND (parts.partnumber ILIKE ?)
+        LIMIT 1
+      )
+SQL
+    push @values, like($form->{parts_partnumber});
+  }
+
+  if ($form->{parts_description}) {
+    $where .= <<SQL;
+      AND EXISTS (
+        SELECT invoice.trans_id
+        FROM invoice
+        WHERE (invoice.trans_id = a.id)
+          AND (invoice.description ILIKE ?)
+        LIMIT 1
+      )
+SQL
+    push @values, like($form->{parts_description});
+  }
+
   if ($where) {
     substr($where, 0, 4, " WHERE ");
     $query .= $where;
index 1cf71d8..b3b111a 100644 (file)
@@ -903,7 +903,8 @@ sub ap_transactions {
        vendornumber country ustid taxzone payment_terms charts direct_debit);
 
   my @hidden_variables = map { "l_${_}" } @columns;
-  push @hidden_variables, "l_subtotal", qw(open closed vendor invnumber ordnumber transaction_description notes project_id transdatefrom transdateto department);
+  push @hidden_variables, "l_subtotal", qw(open closed vendor invnumber ordnumber transaction_description notes project_id transdatefrom transdateto department
+                                           parts_partnumber parts_description);
 
   my $href = build_std_url('action=ap_transactions', grep { $form->{$_} } @hidden_variables);
 
@@ -959,6 +960,8 @@ sub ap_transactions {
   push @options, $locale->text('Order Number')            . " : $form->{ordnumber}"                      if ($form->{ordnumber});
   push @options, $locale->text('Notes')                   . " : $form->{notes}"                          if ($form->{notes});
   push @options, $locale->text('Transaction description') . " : $form->{transaction_description}"        if ($form->{transaction_description});
+  push @options, $locale->text('Part Description')        . " : $form->{parts_description}"              if $form->{parts_description};
+  push @options, $locale->text('Part Number')             . " : $form->{parts_partnumber}"               if $form->{parts_partnumber};
   push @options, $locale->text('From') . " " . $locale->date(\%myconfig, $form->{transdatefrom}, 1)      if ($form->{transdatefrom});
   push @options, $locale->text('Bis')  . " " . $locale->date(\%myconfig, $form->{transdateto},   1)      if ($form->{transdateto});
   push @options, $locale->text('Open')                                                                   if ($form->{open});
index ba2c118..0f69244 100644 (file)
      </tr>
      <tr>
       <th align=right nowrap>[% 'Notes' | $T8 %]</th>
-      <td colspan=3><input name=notes size=40></td>
+      <td><input name=notes size=20></td>
+      <th align="right">[% 'Part Description' | $T8 %]</th>
+      <td><input name="parts_description" size="20"></td>
      </tr>
      <tr>
       <th align="right">[% 'Project Number' | $T8 %]</th>
-      <td colspan="3">
+      <td>
             [%- INCLUDE 'generic/multibox.html'
                  name          =  'project_id',
                  style         = "width: 250px",
@@ -71,6 +73,8 @@
                  allow_textbox = 0,
             -%]
       </td>
+      <th align="right">[% 'Part Number' | $T8 %]</th>
+      <td><input name="parts_partnumber" size="20"></td>
      </tr>
      <tr>
       <th align=right nowrap>[% 'From' | $T8 %]</th>