]> wagnertech.de Git - mfinanz.git/blobdiff - SL/Form.pm
Fehlendes Objekt bei Funktionsaufruf.
[mfinanz.git] / SL / Form.pm
index b9e40f39b3baa53206787628686ac04e985f13d8..5e0b9fd535107c61bd26858846897d82275af853 100644 (file)
@@ -1344,16 +1344,36 @@ sub add_shipto {
                       WHERE shipto_id = $self->{shipto_id}|;
       $dbh->do($query) || $self->dberror($query);
     } else {
-      my $query =
-      qq|INSERT INTO shipto (trans_id, shiptoname, shiptodepartment_1, shiptodepartment_2, shiptostreet,
+      my $query = qq|SELECT * FROM shipto
+                                 WHERE shiptoname = '$self->{shiptoname}' AND
+                      shiptodepartment_1 = '$self->{shiptodepartment_1}' AND
+                      shiptodepartment_2 = '$self->{shiptodepartment_2}' AND
+                      shiptostreet = '$self->{shiptostreet}' AND
+                      shiptozipcode = '$self->{shiptozipcode}' AND
+                      shiptocity = '$self->{shiptocity}' AND
+                      shiptocountry = '$self->{shiptocountry}' AND
+                      shiptocontact = '$self->{shiptocontact}' AND
+                      shiptophone = '$self->{shiptophone}' AND
+                      shiptofax = '$self->{shiptofax}' AND
+                      shiptoemail = '$self->{shiptoemail}'
+                      | ;
+      my $sth = $dbh->prepare($query);
+      $sth->execute() || $self->dberror($query);
+      my $insert_check = $sth->fetch();
+      $sth->finish();
+      if(!$insert_check){
+        $query =
+        qq|INSERT INTO shipto (trans_id, shiptoname, shiptodepartment_1,
+                   shiptodepartment_2, shiptostreet,
                    shiptozipcode, shiptocity, shiptocountry, shiptocontact,
                   shiptophone, shiptofax, shiptoemail, module) VALUES ($id,
                   '$self->{shiptoname}', '$self->{shiptodepartment_1}', '$self->{shiptodepartment_2}', '$self->{shiptostreet}',
                   '$self->{shiptozipcode}', '$self->{shiptocity}',
                   '$self->{shiptocountry}', '$self->{shiptocontact}',
                   '$self->{shiptophone}', '$self->{shiptofax}',
-                  '$self->{shiptoemail}', '$module')|;
-      $dbh->do($query) || $self->dberror($query);
+                   '$self->{shiptoemail}', '$module')|;              
+        $dbh->do($query) || $self->dberror($query);
+     }
     }
   }
 ##/LINET
@@ -1383,6 +1403,8 @@ sub get_salesman {
 
   my ($self, $myconfig, $salesman_id) = @_;
 
+  $main::lxdebug->leave_sub() and return unless $salesman_id;
+
   my $dbh = $self->dbconnect($myconfig);
 
   my ($login) =
@@ -1620,6 +1642,18 @@ sub _get_employees {
   $main::lxdebug->leave_sub();
 }
 
+sub _get_business_types {
+  $main::lxdebug->enter_sub();
+
+  my ($self, $dbh, $key) = @_;
+
+  $key = "all_business_types" unless ($key);
+  $self->{$key} =
+    selectall_hashref_query($self, $dbh, qq|SELECT * FROM business|);
+
+  $main::lxdebug->leave_sub();
+}
+
 sub get_lists {
   $main::lxdebug->enter_sub();
 
@@ -1662,6 +1696,10 @@ sub get_lists {
     $self->_get_employees($dbh, $params{"employees"});
   }
 
+  if ($params{"business_types"}) {
+    $self->_get_business_types($dbh, $params{"business_types"});
+  }
+
   $dbh->disconnect();
 
   $main::lxdebug->leave_sub();
@@ -2521,9 +2559,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);
@@ -2538,8 +2581,10 @@ 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();