subs für den customer und employee select angepasst; sowie get_lists
[kivitendo-erp.git] / SL / Form.pm
index da224ab..9ba3f43 100644 (file)
@@ -1588,6 +1588,34 @@ sub _get_dunning_configs {
   $main::lxdebug->leave_sub();
 }
 
+sub _get_currencies {
+$main::lxdebug->enter_sub();
+
+  my ($self, $dbh, $key) = @_;
+
+  $key = "all_currencies" unless ($key);
+
+  my $query = qq|SELECT curr AS currency FROM defaults|;
+  $self->{$key} = [split(/\:/ , selectfirst_hashref_query($self, $dbh, $query)->{currency})];
+
+  $main::lxdebug->leave_sub();
+}
+
+sub _get_customers {
+  $main::lxdebug->enter_sub();
+
+  my ($self, $dbh, $key) = @_;
+
+  $key = "all_customers" unless ($key);
+
+  my $query = qq|SELECT * FROM customer LIMIT $main::myconfig{vclimit}|;
+
+  $self->{$key} = selectall_hashref_query($self, $dbh, $query);
+
+  $main::lxdebug->leave_sub();
+}
+
 sub get_lists {
   $main::lxdebug->enter_sub();
 
@@ -1645,6 +1673,14 @@ sub get_lists {
   if ($params{"dunning_configs"}) {
     $self->_get_dunning_configs($dbh, $params{"dunning_configs"});
   }
+  
+  if($params{"currencies"}) {
+    $self->_get_currencies($dbh, $params{"currencies"});
+  }
+  
+  if($params{"customers"}) {
+    $self->_get_customers($dbh, $params{"customers"});
+  }
 
   $dbh->disconnect();
 
@@ -1944,14 +1980,13 @@ sub create_links {
     }
 
     # now get the account numbers
-     $query = qq|SELECT c.accno, c.description, c.link, c.taxkey_id, tk.tax_id
-                 FROM chart c, taxkeys tk
-                 WHERE c.link LIKE ? 
-                   AND (    tk.chart_id = c.id OR     c.link LIKE '%_tax%') 
-                   AND (NOT tk.chart_id = c.id OR NOT c.link LIKE '%_tax%')
-                   AND (tk.id = (SELECT id FROM taxkeys WHERE taxkeys.chart_id = c.id AND startdate <= $transdate ORDER BY startdate DESC LIMIT 1)
-                     OR c.link LIKE '%_tax%')
-                 ORDER BY c.accno|;
+    $query = qq|SELECT c.accno, c.description, c.link, c.taxkey_id, tk.tax_id
+                FROM chart c
+                LEFT JOIN taxkeys tk ON (tk.chart_id = c.id)
+                WHERE c.link LIKE ?
+                  AND (tk.id = (SELECT id FROM taxkeys WHERE taxkeys.chart_id = c.id AND startdate <= $transdate ORDER BY startdate DESC LIMIT 1)
+                    OR c.link LIKE '%_tax%')
+                ORDER BY c.accno|;
 
     $sth = $dbh->prepare($query);
     do_statement($self, $sth, $query, "%$module%");