zusaetzlich zu der vorhandenen has_storno funktion (bugfix)
[kivitendo-erp.git] / SL / IS.pm
index c37b1aa..5c07ca0 100644 (file)
--- a/SL/IS.pm
+++ b/SL/IS.pm
@@ -421,7 +421,7 @@ sub customer_details {
   # get contact id, set it if nessessary
   $form->{cp_id} *= 1;
 
-  my @values;
+  my @values =  (conv_i($form->{customer_id}));
 
   my $where = "";
   if ($form->{cp_id}) {
@@ -438,7 +438,6 @@ sub customer_details {
        WHERE (ct.id = ?) $where
        ORDER BY cp.cp_id
        LIMIT 1|;
-  push(@values, conv_i($form->{customer_id}));
   my $ref = selectfirst_hashref_query($form, $dbh, $query, @values);
 
   # remove id and taxincluded before copy back
@@ -2132,6 +2131,29 @@ sub has_storno {
 
   my $dbh = $form->dbconnect($myconfig);
 
+  my $query = qq|SELECT storno FROM $table WHERE storno_id = ?|;
+  my ($result) = selectrow_query($form, $dbh, $query, $form->{id});
+
+  $dbh->disconnect();
+
+  $main::lxdebug->leave_sub();
+
+  return $result;
+}
+
+sub is_storno {
+  $main::lxdebug->enter_sub();
+
+  my ($self, $myconfig, $form, $table) = @_;
+
+  $main::lxdebug->leave_sub() and return 0 unless ($form->{id});
+
+  # make sure there's no funny stuff in $table
+  # ToDO: die when this happens and throw an error
+  $main::lxdebug->leave_sub() and return 0 if ($table =~ /\W/);
+
+  my $dbh = $form->dbconnect($myconfig);
+
   my $query = qq|SELECT storno FROM $table WHERE id = ?|;
   my ($result) = selectrow_query($form, $dbh, $query, $form->{id});