Bug 608.
[kivitendo-erp.git] / SL / Form.pm
index 95cd80e..6a1fa81 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 {
@@ -147,7 +148,7 @@ sub new {
   $self->{action} = lc $self->{action};
   $self->{action} =~ s/( |-|,|\#)/_/g;
 
-  $self->{version}   = "2.4.1";
+  $self->{version}   = "2.4.2";
 
   $main::lxdebug->leave_sub();
 
@@ -433,7 +434,7 @@ function fokus(){document.$self->{fokus}.focus();}
   <script type="text/javascript" src="js/tabcontent.js">
   
   /***********************************************
-  * Tab Content script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
+  * Tab Content script- Dynamic Drive DHTML code library (www.dynamicdrive.com)
   * This notice MUST stay intact for legal use
   * Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
   ***********************************************/
@@ -959,7 +960,7 @@ sub datetonum {
 # Database routines used throughout
 
 sub dbconnect {
-  $main::lxdebug->enter_sub();
+  $main::lxdebug->enter_sub(2);
 
   my ($self, $myconfig) = @_;
 
@@ -974,7 +975,7 @@ sub dbconnect {
     $dbh->do($myconfig->{dboptions}) || $self->dberror($myconfig->{dboptions});
   }
 
-  $main::lxdebug->leave_sub();
+  $main::lxdebug->leave_sub(2);
 
   return $dbh;
 }
@@ -1092,7 +1093,7 @@ sub get_exchangerate {
 
   unless ($transdate) {
     $main::lxdebug->leave_sub();
-    return "";
+    return 1;
   }
 
   my $query = qq|SELECT e.$fld FROM exchangerate e
@@ -1104,7 +1105,7 @@ sub get_exchangerate {
   my ($exchangerate) = $sth->fetchrow_array;
   $sth->finish;
 
-  if ($exchangerate == 0) {
+  if (!$exchangerate) {
     $exchangerate = 1;
   }
 
@@ -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();
 
@@ -1395,48 +1425,245 @@ sub get_duedate {
   $main::lxdebug->leave_sub();
 }
 
-# get other contact for transaction and form - html/tex
-sub get_contact {
+# get contacts for id, if no contact return {"","","","",""}
+sub _get_contacts {
   $main::lxdebug->enter_sub();
 
-  my ($self, $dbh, $id) = @_;
+  my ($self, $dbh, $id, $key) = @_;
 
-  my $query = qq|SELECT c.*
-              FROM contacts c
-              WHERE cp_id=$id|;
-  $sth = $dbh->prepare($query);
-  $sth->execute || $self->dberror($query);
+  $key = "all_contacts" unless ($key);
+  $self->{$key} = [];
 
-  $ref = $sth->fetchrow_hashref(NAME_lc);
+  my $query =
+    qq|SELECT c.cp_id, c.cp_cv_id, c.cp_name, c.cp_givenname, c.cp_abteilung | .
+    qq|FROM contacts c | .
+    qq|WHERE cp_cv_id = ? | .
+    qq|ORDER BY lower(c.cp_name)|;
+  my $sth = $dbh->prepare($query);
+  $sth->execute($id) || $self->dberror($query . " ($id)");
 
-  push @{ $self->{$_} }, $ref;
+  my $i = 0;
+  while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
+    push @{ $self->{$key} }, $ref;
+    $i++;
+  }
 
+  if ($i == 0) {
+    push @{ $self->{$key} }, { { "", "", "", "", "", "" } };
+  }
   $sth->finish;
   $main::lxdebug->leave_sub();
 }
 
-# get contacts for id, if no contact return {"","","","",""}
-sub get_contacts {
+sub _get_projects {
   $main::lxdebug->enter_sub();
 
-  my ($self, $dbh, $id) = @_;
+  my ($self, $dbh, $key) = @_;
+
+  my ($all, $old_id, $where, @values);
+
+  if (ref($key) eq "HASH") {
+    my $params = $key;
+
+    $key = "ALL_PROJECTS";
+
+    foreach my $p (keys(%{$params})) {
+      if ($p eq "all") {
+        $all = $params->{$p};
+      } elsif ($p eq "old_id") {
+        $old_id = $params->{$p};
+      } elsif ($p eq "key") {
+        $key = $params->{$p};
+      }
+    }
+  }
+
+  if (!$all) {
+    $where = "WHERE active ";
+    if ($old_id) {
+      if (ref($old_id) eq "ARRAY") {
+        my @ids = grep({ $_ } @{$old_id});
+        if (@ids) {
+          $where .= " OR id IN (" . join(",", map({ "?" } @ids)) . ") ";
+          push(@values, @ids);
+        }
+      } else {
+        $where .= " OR (id = ?) ";
+        push(@values, $old_id);
+      }
+    }
+  }
 
-  my $query = qq|SELECT c.cp_id, c.cp_cv_id, c.cp_name, c.cp_givenname, c.cp_abteilung
-              FROM contacts c
-              WHERE cp_cv_id=$id|;
+  my $query =
+    qq|SELECT id, projectnumber, description, active | .
+    qq|FROM project | .
+    $where .
+    qq|ORDER BY lower(projectnumber)|;
   my $sth = $dbh->prepare($query);
-  $sth->execute || $self->dberror($query);
+  $sth->execute(@values) ||
+    $self->dberror($query . " (" . join(", ", @values) . ")");
 
-  my $i = 0;
+  $self->{$key} = [];
   while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
-    push @{ $self->{all_contacts} }, $ref;
-    $i++;
+    push(@{ $self->{$key} }, $ref);
   }
 
-  if ($i == 0) {
-    push @{ $self->{all_contacts} }, { { "", "", "", "", "", "" } };
+  $sth->finish;
+  $main::lxdebug->leave_sub();
+}
+
+sub _get_shipto {
+  $main::lxdebug->enter_sub();
+
+  my ($self, $dbh, $vc_id, $key) = @_;
+
+  $key = "all_shipto" unless ($key);
+  $self->{$key} = [];
+
+  # get shipping addresses
+  my $query =
+    qq|SELECT s.shipto_id,s.shiptoname,s.shiptodepartment_1 | .
+    qq|FROM shipto s | .
+    qq|WHERE s.trans_id = ?|;
+  my $sth = $dbh->prepare($query);
+  $sth->execute($vc_id) || $self->dberror($query . " ($vc_id)");
+
+  while ($ref = $sth->fetchrow_hashref(NAME_lc)) {
+    push(@{ $self->{$key} }, $ref);
   }
   $sth->finish;
+
+  $main::lxdebug->leave_sub();
+}
+
+sub _get_printers {
+  $main::lxdebug->enter_sub();
+
+  my ($self, $dbh, $key) = @_;
+
+  $key = "all_printers" unless ($key);
+  $self->{$key} = [];
+
+  my $query = qq|SELECT id, printer_description, printer_command FROM printers|;
+  my $sth = $dbh->prepare($query);
+  $sth->execute() || $self->dberror($query);
+
+  while ($ref = $sth->fetchrow_hashref(NAME_lc)) {
+    push(@{ $self->{$key} }, $ref);
+  }
+  $sth->finish;
+
+  $main::lxdebug->leave_sub();
+}
+
+sub _get_charts {
+  $main::lxdebug->enter_sub();
+
+  my ($self, $dbh, $params) = @_;
+
+  $key = $params->{key};
+  $key = "all_charts" unless ($key);
+  $self->{$key} = [];
+
+  my $transdate = quote_db_date($params->{transdate});
+
+  my $query =
+    qq|SELECT c.accno, c.description, c.link, tk.taxkey_id, tk.tax_id | .
+    qq|FROM chart c | .
+    qq|LEFT JOIN taxkeys tk ON | .
+    qq|(tk.id = (SELECT id FROM taxkeys | .
+    qq|          WHERE taxkeys.chart_id = c.id AND startdate <= $transdate | .
+    qq|          ORDER BY startdate DESC LIMIT 1)) | .
+    qq|ORDER BY c.accno|;
+
+  my $sth = $dbh->prepare($query);
+  $sth->execute() || $self->dberror($query);
+
+  while ($ref = $sth->fetchrow_hashref(NAME_lc)) {
+    push(@{ $self->{$key} }, $ref);
+  }
+  $sth->finish;
+
+  $main::lxdebug->leave_sub();
+}
+
+sub _get_taxcharts {
+  $main::lxdebug->enter_sub();
+
+  my ($self, $dbh, $key) = @_;
+
+  $key = "all_taxcharts" unless ($key);
+  $self->{$key} = [];
+
+  my $query = qq|SELECT * FROM tax ORDER BY taxkey|;
+
+  my $sth = $dbh->prepare($query);
+  $sth->execute() || $self->dberror($query);
+
+  while ($ref = $sth->fetchrow_hashref(NAME_lc)) {
+    push(@{ $self->{$key} }, $ref);
+  }
+  $sth->finish;
+
+  $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();
+
+  my $self = shift;
+  my %params = @_;
+
+  my $dbh = $self->dbconnect(\%main::myconfig);
+  my ($sth, $query, $ref);
+
+  my $vc = $self->{"vc"} eq "customer" ? "customer" : "vendor";
+  my $vc_id = $self->{"${vc}_id"};
+
+  if ($params{"contacts"}) {
+    $self->_get_contacts($dbh, $vc_id, $params{"contacts"});
+  }
+
+  if ($params{"shipto"}) {
+    $self->_get_shipto($dbh, $vc_id, $params{"shipto"});
+  }
+
+  if ($params{"projects"} || $params{"all_projects"}) {
+    $self->_get_projects($dbh, $params{"all_projects"} ?
+                         $params{"all_projects"} : $params{"projects"},
+                         $params{"all_projects"} ? 1 : 0);
+  }
+
+  if ($params{"printers"}) {
+    $self->_get_printers($dbh, $params{"printers"});
+  }
+
+  if ($params{"charts"}) {
+    $self->_get_charts($dbh, $params{"charts"});
+  }
+
+  if ($params{"taxcharts"}) {
+    $self->_get_taxcharts($dbh, $params{"taxcharts"});
+  }
+
+  if ($params{"employees"}) {
+    $self->_get_employees($dbh, $params{"employees"});
+  }
+
+  $dbh->disconnect();
+
   $main::lxdebug->leave_sub();
 }
 
@@ -1510,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);
@@ -1611,7 +1838,6 @@ sub all_vc {
   $main::lxdebug->leave_sub();
 }
 
-
 sub language_payment {
   $main::lxdebug->enter_sub();
 
@@ -1729,12 +1955,14 @@ 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 '%$module%' AND c.id=tk.chart_id AND tk.id = (SELECT id from taxkeys where taxkeys.chart_id =c.id AND startdate<=$transdate ORDER BY startdate desc LIMIT 1)
+                WHERE c.link LIKE '%$module%' AND c.id=tk.chart_id AND tk.id = 
+                      (SELECT id FROM taxkeys where taxkeys.chart_id = c.id AND startdate <= $transdate ORDER BY startdate desc LIMIT 1)
                 ORDER BY c.accno|;
   
     $sth = $dbh->prepare($query);
-    $sth->execute || $self->dberror($query);
-  
+
+    do_statement($form, $sth, $query);
+
     $self->{accounts} = "";
     while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
   
@@ -1757,43 +1985,17 @@ sub create_links {
   }
 
   # get taxkeys and description
-  $query = qq|SELECT id, taxkey, taxdescription
-              FROM tax|;
-  $sth = $dbh->prepare($query);
-  $sth->execute || $self->dberror($query);
-
-  $ref = $sth->fetchrow_hashref(NAME_lc);
-
-  while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
-    push @{ $self->{TAXKEY} }, $ref;
-  }
-
-  $sth->finish;
-
+  $query = qq|SELECT id, taxkey, taxdescription FROM tax|;
+  $self->{TAXKEY} = selectall_hashref_query($form, $dbh, $query);
 
   # get tax zones
-  $query = qq|SELECT id, description
-              FROM tax_zones|;
-  $sth = $dbh->prepare($query);
-  $sth->execute || $self->dberror($query);
-
-
-  while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
-    push @{ $self->{TAXZONE} }, $ref;
-  }
-  $sth->finish;
+  $query = qq|SELECT id, description FROM tax_zones|;
+  $self->{TAXZONE} = selectall_hashref_query($form, $dbh, $query);
 
   if (($module eq "AP") || ($module eq "AR")) {
-
     # get tax rates and description
     $query = qq| SELECT * FROM tax t|;
-    $sth   = $dbh->prepare($query);
-    $sth->execute || $self->dberror($query);
-    $self->{TAX} = ();
-    while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
-      push @{ $self->{TAX} }, $ref;
-    }
-    $sth->finish;
+    $self->{TAX} = selectall_hashref_query($form, $dbh, $query);
   }
 
   if ($self->{id}) {
@@ -1811,7 +2013,7 @@ sub create_links {
                LEFT JOIN department d ON (d.id = a.department_id)
                WHERE a.id = $self->{id}|;
     $sth = $dbh->prepare($query);
-    $sth->execute || $self->dberror($query);
+    do_statement($form, $sth, $query);
 
     $ref = $sth->fetchrow_hashref(NAME_lc);
     foreach $key (keys %$ref) {
@@ -1826,13 +2028,30 @@ 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 '%$module%' AND (((tk.chart_id=c.id) AND NOT(c.link like '%_tax%')) OR (NOT(tk.chart_id=c.id) AND (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)) AND NOT(c.link like '%_tax%')) 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.chart_id = c.id AND NOT c.link like '%_tax%')
+          OR (NOT tk.chart_id = c.id AND     c.link like '%_tax%')
+          AND 
+            tk.id = (  SELECT id from taxkeys 
+                       WHERE taxkeys.chart_id = c.id 
+                       AND startdate <= ? 
+                       ORDER BY startdate desc LIMIT 1
+                    ) 
+        ORDER BY c.accno|;
+    
     $sth = $dbh->prepare($query);
-    $sth->execute || $self->dberror($query);
+    do_statement($form, $sth, $query, "%$module%", $transdate);
   
     $self->{accounts} = "";
     while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
@@ -1866,7 +2085,7 @@ sub create_links {
                AND a.fx_transaction = '0'
                ORDER BY a.oid,a.transdate|;
     $sth = $dbh->prepare($query);
-    $sth->execute || $self->dberror($query);
+    do_statement($form, $sth, $query);
 
     my $fld = ($table eq 'customer') ? 'buy' : 'sell';
 
@@ -1900,7 +2119,7 @@ sub create_links {
                   WHERE d.fxloss_accno_id = c.id) AS fxloss_accno
                FROM defaults d|;
     $sth = $dbh->prepare($query);
-    $sth->execute || $self->dberror($query);
+    do_statement($form, $sth, $query);
 
     $ref = $sth->fetchrow_hashref(NAME_lc);
     map { $self->{$_} = $ref->{$_} } keys %$ref;
@@ -1917,7 +2136,7 @@ sub create_links {
                   WHERE d.fxloss_accno_id = c.id) AS fxloss_accno
                FROM defaults d|;
     $sth = $dbh->prepare($query);
-    $sth->execute || $self->dberror($query);
+    do_statement($form, $sth, $query);
 
     $ref = $sth->fetchrow_hashref(NAME_lc);
     map { $self->{$_} = $ref->{$_} } keys %$ref;
@@ -2131,6 +2350,83 @@ sub update_status {
   $main::lxdebug->leave_sub();
 }
 
+#--- 4 locale ---#
+# $main::locale->text('SAVED') 
+# $main::locale->text('DELETED') 
+# $main::locale->text('ADDED')
+# $main::locale->text('PAYMENT POSTED')
+# $main::locale->text('POSTED')
+# $main::locale->text('POSTED AS NEW')
+# $main::locale->text('ELSE')
+# $main::locale->text('SAVED FOR DUNNING')
+# $main::locale->text('DUNNING STARTED')
+# $main::locale->text('PRINTED')
+# $main::locale->text('MAILED')
+# $main::locale->text('SCREENED')
+# $main::locale->text('invoice')
+# $main::locale->text('proforma')
+# $main::locale->text('sales_order')
+# $main::locale->text('packing_list')
+# $main::locale->text('pick_list')
+# $main::locale->text('purchase_order')
+# $main::locale->text('bin_list')
+# $main::locale->text('sales_quotation')
+# $main::locale->text('request_quotation')
+
+sub save_history {
+       $main::lxdebug->enter_sub();
+       
+       my $self = shift();
+       my $dbh = shift();
+       
+       if(!exists $self->{employee_id}) {
+               &get_employee($self, $dbh);
+       }
+       
+       my $query =
+    qq|INSERT INTO history_erp (trans_id, employee_id, addition, what_done) | .
+    qq|VALUES (?, ?, ?, ?)|;
+  my @values = (conv_i($self->{id}), conv_i($self->{employee_id}),
+                $self->{addition}, $self->{what_done});
+  do_query($self, $dbh, $query, @values);
+       
+       $main::lxdebug->leave_sub();
+}
+
+sub get_history {
+       $main::lxdebug->enter_sub();
+       
+       my $self = shift();
+       my $dbh = shift();
+       my $trans_id = shift();
+       my $restriction = shift();
+       my @tempArray;
+       my $i = 0;
+       if ($trans_id ne "") {
+               my $query =
+      qq|SELECT h.employee_id, h.itime::timestamp(0) AS itime, h.addition, h.what_done, emp.name | .
+      qq|FROM history_erp h | .
+      qq|LEFT JOIN employee emp | .
+      qq|ON emp.id = h.employee_id | .
+      qq|WHERE trans_id = ? |
+      . $restriction;
+       
+               my $sth = $dbh->prepare($query) || $self->dberror($query);
+       
+               $sth->execute($trans_id) || $self->dberror("$query ($trans_id)");
+
+               while(my $hash_ref = $sth->fetchrow_hashref()) {
+                       $hash_ref->{addition} = $main::locale->text($hash_ref->{addition});
+                       $hash_ref->{what_done} = $main::locale->text($hash_ref->{what_done});
+                       $tempArray[$i++] = $hash_ref; 
+               }
+    $main::lxdebug->leave_sub() and return \@tempArray
+      if ($i > 0 && $tempArray[0] ne "");
+       }
+       $main::lxdebug->leave_sub();
+       return 0;
+}
+
 sub save_status {
   $main::lxdebug->enter_sub();
 
@@ -2141,9 +2437,9 @@ sub save_status {
   my $formnames  = $self->{printed};
   my $emailforms = $self->{emailed};
 
-  my $query = qq|DELETE FROM status
-                 WHERE formname = '$self->{formname}'
-                AND trans_id = $self->{id}|;
+  $query = qq|DELETE FROM status
+              WHERE formname = '$self->{formname}'
+                     AND trans_id = $self->{id}|;
   $dbh->do($query) || $self->dberror($query);
 
   # this only applies to the forms
@@ -2191,9 +2487,14 @@ sub save_status {
 sub update_defaults {
   $main::lxdebug->enter_sub();
 
-  my ($self, $myconfig, $fld) = @_;
+  my ($self, $myconfig, $fld, $provided_dbh) = @_;
 
-  my $dbh   = $self->dbconnect_noauto($myconfig);
+  my $dbh;
+  if ($provided_dbh) {
+    $dbh = $provided_dbh;
+  } else {
+    $dbh = $self->dbconnect_noauto($myconfig);
+  }
   my $query = qq|SELECT $fld FROM defaults FOR UPDATE|;
   my $sth   = $dbh->prepare($query);
 
@@ -2207,8 +2508,10 @@ sub update_defaults {
               SET $fld = '$var'|;
   $dbh->do($query) || $self->dberror($query);
 
-  $dbh->commit;
-  $dbh->disconnect;
+  if (!$provided_dbh) {
+    $dbh->commit;
+    $dbh->disconnect;
+  }
 
   $main::lxdebug->leave_sub();
 
@@ -2218,9 +2521,14 @@ sub update_defaults {
 sub update_business {
   $main::lxdebug->enter_sub();
 
-  my ($self, $myconfig, $business_id) = @_;
+  my ($self, $myconfig, $business_id, $provided_dbh) = @_;
 
-  my $dbh   = $self->dbconnect_noauto($myconfig);
+  my $dbh;
+  if ($provided_dbh) {
+    $dbh = $provided_dbh;
+  } else {
+    $dbh = $self->dbconnect_noauto($myconfig);
+  }
   my $query =
     qq|SELECT customernumberinit FROM business  WHERE id=$business_id FOR UPDATE|;
   my $sth = $dbh->prepare($query);
@@ -2235,36 +2543,16 @@ sub update_business {
               SET customernumberinit = '$var' WHERE id=$business_id|;
   $dbh->do($query) || $self->dberror($query);
 
-  $dbh->commit;
-  $dbh->disconnect;
+  if (!$provided_dbh) {
+    $dbh->commit;
+    $dbh->disconnect;
+  }
 
   $main::lxdebug->leave_sub();
 
   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();