]> wagnertech.de Git - mfinanz.git/blobdiff - SL/CT.pm
Revert "Lieferanten/Kunden Namen richtig escapen"
[mfinanz.git] / SL / CT.pm
index 606c46a4962b1953380a9aa59648f4598aaa7ea1..80916ad580fe82572a3bc12e493a3ee9fd8be55b 100644 (file)
--- a/SL/CT.pm
+++ b/SL/CT.pm
@@ -44,7 +44,6 @@ use SL::CVar;
 use SL::DBUtils;
 use SL::FU;
 use SL::Notes;
-use List::MoreUtils qw(true);
 
 sub get_tuple {
   $main::lxdebug->enter_sub();
@@ -195,13 +194,6 @@ sub query_titles_and_greetings {
 
   my $dbh = $form->dbconnect($myconfig);
 
-  $query =
-    qq|SELECT DISTINCT(cp_greeting) | .
-    qq|FROM contacts | .
-    qq|WHERE cp_greeting ~ '[a-zA-Z]' | .
-    qq|ORDER BY cp_greeting|;
-  $form->{GREETINGS} = [ selectall_array_query($form, $dbh, $query) ];
-
   $query =
     qq|SELECT DISTINCT(greeting) | .
     qq|FROM customer | .
@@ -377,7 +369,6 @@ sub save_customer {
   $query = undef;
   if ( $form->{cp_id} ) {
     $query = qq|UPDATE contacts SET | .
-      qq|cp_greeting = ?, | .
       qq|cp_title = ?,  | .
       qq|cp_givenname = ?, | .
       qq|cp_name = ?, | .
@@ -393,10 +384,10 @@ sub save_customer {
       qq|cp_project = ?, | .
       qq|cp_privatphone = ?, | .
       qq|cp_privatemail = ?, | .
-      qq|cp_birthday = ? | .
+      qq|cp_birthday = ?, | .
+      qq|cp_gender = ? | .
       qq|WHERE cp_id = ?|;
     @values = (
-      $form->{cp_greeting},
       $form->{cp_title},
       $form->{cp_givenname},
       $form->{cp_name},
@@ -413,18 +404,18 @@ sub save_customer {
       $form->{cp_privatphone},
       $form->{cp_privatemail},
       $form->{cp_birthday},
+      $form->{cp_gender} eq 'f' ? 'f' : 'm',
       $form->{cp_id}
       );
   } elsif ( $form->{cp_name} || $form->{cp_givenname} ) {
     $query =
-      qq|INSERT INTO contacts ( cp_cv_id, cp_greeting, cp_title, cp_givenname,  | .
+      qq|INSERT INTO contacts ( cp_cv_id, cp_title, cp_givenname,  | .
       qq|  cp_name, cp_email, cp_phone1, cp_phone2, cp_abteilung, cp_fax, cp_mobile1, | .
       qq|  cp_mobile2, cp_satphone, cp_satfax, cp_project, cp_privatphone, cp_privatemail, | .
-      qq|  cp_birthday) | .
+      qq|  cp_birthday, cp_gender) | .
       qq|VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)|;
     @values = (
       $form->{id},
-      $form->{cp_greeting},
       $form->{cp_title},
       $form->{cp_givenname},
       $form->{cp_name},
@@ -440,7 +431,8 @@ sub save_customer {
       $form->{cp_project},
       $form->{cp_privatphone},
       $form->{cp_privatemail},
-      $form->{cp_birthday}
+      $form->{cp_birthday},
+      $form->{cp_gender} eq 'f' ? 'f' : 'm',
       );
   }
   do_query( $form, $dbh, $query, @values ) if ($query);
@@ -454,7 +446,8 @@ sub save_customer {
   CVar->save_custom_variables('dbh'       => $dbh,
                               'module'    => 'CT',
                               'trans_id'  => $form->{id},
-                              'variables' => $form);
+                              'variables' => $form,
+                              'always_valid' => 1);
 
   $rc = $dbh->commit();
   $dbh->disconnect();
@@ -582,7 +575,6 @@ sub save_vendor {
   $query = undef;
   if ( $form->{cp_id} ) {
     $query = qq|UPDATE contacts SET | .
-      qq|cp_greeting = ?, | .
       qq|cp_title = ?,  | .
       qq|cp_givenname = ?, | .
       qq|cp_name = ?, | .
@@ -598,10 +590,10 @@ sub save_vendor {
       qq|cp_project = ?, | .
       qq|cp_privatphone = ?, | .
       qq|cp_privatemail = ?, | .
-      qq|cp_birthday = ? | .
+      qq|cp_birthday = ?, | .
+      qq|cp_gender = ? | .
       qq|WHERE cp_id = ?|;
     @values = (
-      $form->{cp_greeting},
       $form->{cp_title},
       $form->{cp_givenname},
       $form->{cp_name},
@@ -618,18 +610,18 @@ sub save_vendor {
       $form->{cp_privatphone},
       $form->{cp_privatemail},
       $form->{cp_birthday},
+      $form->{cp_gender} eq 'f' ? 'f' : 'm',
       $form->{cp_id}
       );
   } elsif ( $form->{cp_name} || $form->{cp_givenname} ) {
     $query =
-      qq|INSERT INTO contacts ( cp_cv_id, cp_greeting, cp_title, cp_givenname,  | .
+      qq|INSERT INTO contacts ( cp_cv_id, cp_title, cp_givenname,  | .
       qq|  cp_name, cp_email, cp_phone1, cp_phone2, cp_abteilung, cp_fax, cp_mobile1, | .
       qq|  cp_mobile2, cp_satphone, cp_satfax, cp_project, cp_privatphone, cp_privatemail, | .
-      qq|  cp_birthday) | .
+      qq|  cp_birthday, cp_gender) | .
       qq|VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)|;
     @values = (
       $form->{id},
-      $form->{cp_greeting},
       $form->{cp_title},
       $form->{cp_givenname},
       $form->{cp_name},
@@ -645,7 +637,8 @@ sub save_vendor {
       $form->{cp_project},
       $form->{cp_privatphone},
       $form->{cp_privatemail},
-      $form->{cp_birthday}
+      $form->{cp_birthday},
+      $form->{cp_gender}
       );
   }
   do_query($form, $dbh, $query, @values) if ($query);
@@ -659,7 +652,8 @@ sub save_vendor {
   CVar->save_custom_variables('dbh'       => $dbh,
                               'module'    => 'CT',
                               'trans_id'  => $form->{id},
-                              'variables' => $form);
+                              'variables' => $form,
+                              'always_valid' => 1);
 
   $rc = $dbh->commit();
   $dbh->disconnect();
@@ -705,7 +699,7 @@ sub search {
   $form->{sort} = $sortorder;
   my $sortdir   = !defined $form->{sortdir} ? 'ASC' : $form->{sortdir} ? 'ASC' : 'DESC';
 
-  if ($sortorder ne 'id' && 1 >= true { $form->{$_} } qw(l_ordnumber l_quonumber l_invnumber)) {
+  if ($sortorder ne 'id' && 1 >= scalar grep { $form->{$_} } qw(l_ordnumber l_quonumber l_invnumber)) {
     $sortorder  = "lower($sortorder) ${sortdir}";
   } else {
     $sortorder .= " ${sortdir}";
@@ -919,6 +913,7 @@ sub get_delivery {
 
   my $arap = $form->{db} eq "vendor" ? "ap" : "ar";
   my $db = $form->{db} eq "customer" ? "customer" : "vendor";
+  my $qty_sign = $form->{db} eq 'vendor' ? ' * -1 AS qty' : '';
 
   my $where = " WHERE 1=1 ";
   my @values;
@@ -940,7 +935,7 @@ sub get_delivery {
     push(@values, conv_date($form->{to}));
   }
   my $query =
-    qq|SELECT s.shiptoname, i.qty, | .
+    qq|SELECT s.shiptoname, i.qty $qty_sign, | .
     qq|  ${arap}.id, ${arap}.transdate, ${arap}.invnumber, ${arap}.ordnumber, | .
     qq|  i.description, i.unit, i.sellprice, | .
     qq|  oe.id AS oe_id | .