]> wagnertech.de Git - mfinanz.git/blobdiff - SL/Form.pm
Durch das Einbinden von SL::User in SL::Form werden einige Übersetzungen in anderen...
[mfinanz.git] / SL / Form.pm
index 5069c16f2401cadc1ce7de39931602b5679c2f81..d690be1c151e6c21eb1dc40f1c77bc41dfbf05b3 100644 (file)
@@ -44,6 +44,7 @@ use SL::Template;
 use CGI::Ajax;
 use SL::DBUtils;
 use SL::Menu;
+use SL::User;
 use CGI;
 
 sub _input_to_hash {
@@ -1377,6 +1378,35 @@ sub get_employee {
   $main::lxdebug->leave_sub();
 }
 
+sub get_salesman {
+  $main::lxdebug->enter_sub();
+
+  my ($self, $myconfig, $salesman_id) = @_;
+
+  my $dbh = $self->dbconnect($myconfig);
+
+  my ($login) =
+    selectrow_query($self, $dbh, qq|SELECT login FROM employee WHERE id = ?|,
+                    $salesman_id);
+
+  if ($login) {
+    my $user = new User($main::memberfile, $login);
+    map({ $self->{"salesman_$_"} = $user->{$_}; }
+        qw(address businessnumber co_ustid company duns email fax name
+           taxnumber tel));
+    $self->{salesman_login} = $login;
+
+    $self->{salesman_name} = $login
+      if ($self->{salesman_name} eq "");
+
+    map({ $self->{"salesman_$_"} =~ s/\\n/\n/g; } qw(address company));
+  }
+
+  $dbh->disconnect();
+
+  $main::lxdebug->leave_sub();
+}
+
 sub get_duedate {
   $main::lxdebug->enter_sub();
 
@@ -1578,6 +1608,18 @@ sub _get_taxcharts {
   $main::lxdebug->leave_sub();
 }
 
+sub _get_employees {
+  $main::lxdebug->enter_sub();
+
+  my ($self, $dbh, $key) = @_;
+
+  $key = "all_employees" unless ($key);
+  $self->{$key} =
+    selectall_hashref_query($self, $dbh, qq|SELECT * FROM employee|);
+
+  $main::lxdebug->leave_sub();
+}
+
 sub get_lists {
   $main::lxdebug->enter_sub();
 
@@ -1616,6 +1658,10 @@ sub get_lists {
     $self->_get_taxcharts($dbh, $params{"taxcharts"});
   }
 
+  if ($params{"employees"}) {
+    $self->_get_employees($dbh, $params{"employees"});
+  }
+
   $dbh->disconnect();
 
   $main::lxdebug->leave_sub();
@@ -1691,7 +1737,7 @@ sub all_vc {
 
   # build selection list
   if ($count < $myconfig->{vclimit}) {
-    $query = qq|SELECT id, name
+    $query = qq|SELECT id, name, salesman_id
                FROM $table WHERE not obsolete
                ORDER BY name|;
     $sth = $dbh->prepare($query);
@@ -2482,28 +2528,6 @@ sub update_business {
   return $var;
 }
 
-sub get_salesman {
-  $main::lxdebug->enter_sub();
-
-  my ($self, $myconfig, $salesman) = @_;
-
-  my $dbh   = $self->dbconnect($myconfig);
-  my $query =
-    qq|SELECT id, name FROM customer  WHERE (customernumber ilike '%$salesman%' OR name ilike '%$salesman%') AND business_id in (SELECT id from business WHERE salesman)|;
-  my $sth = $dbh->prepare($query);
-  $sth->execute || $self->dberror($query);
-
-  my $i = 0;
-  while ($ref = $sth->fetchrow_hashref(NAME_lc)) {
-    push(@{ $self->{salesman_list} }, $ref);
-    $i++;
-  }
-  $dbh->commit;
-  $main::lxdebug->leave_sub();
-
-  return $i;
-}
-
 sub get_partsgroup {
   $main::lxdebug->enter_sub();