X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/fc55beb40ba99c736562d815bbe60f36883904bc..d331a3d77f0b24a301412799d2e9cc5fa1bf27ba:/SL/CT.pm diff --git a/SL/CT.pm b/SL/CT.pm index 2ec7aec69..37550e4af 100644 --- a/SL/CT.pm +++ b/SL/CT.pm @@ -68,11 +68,12 @@ sub get_tuple { my $ref = $sth->fetchrow_hashref("NAME_lc"); map { $form->{$_} = $ref->{$_} } keys %$ref; + $sth->finish; - # remove any trailing whitespace - $form->{curr} =~ s/\s*$//; + #get name of currency instead of id: + $query = qq|SELECT curr FROM currencies WHERE id=?|; + ($form->{curr}) = selectrow_query($form, $dbh, $query, conv_i($form->{curr})); - $sth->finish; if ( $form->{salesman_id} ) { my $query = qq|SELECT ct.name AS salesman | . @@ -319,7 +320,7 @@ sub save_customer { qq|user_password = ?, | . qq|c_vendor_id = ?, | . qq|klass = ?, | . - qq|curr = ?, | . + qq|curr = (SELECT id FROM currencies WHERE curr = ?), | . qq|taxincluded_checked = ? | . qq|WHERE id = ?|; my @values = ( @@ -362,7 +363,7 @@ sub save_customer { $form->{user_password}, $form->{c_vendor_id}, conv_i($form->{klass}), - substr($form->{currency}, 0, 3), + $form->{currency}, $form->{taxincluded_checked} ne '' ? $form->{taxincluded_checked} : undef, $form->{id} ); @@ -471,7 +472,7 @@ sub save_vendor { qq| username = ?, | . qq| user_password = ?, | . qq| v_customer_id = ?, | . - qq| curr = ? | . + qq| curr = (SELECT id FROM currencies WHERE curr = ?) | . qq|WHERE id = ?|; my @values = ( $form->{vendornumber}, @@ -511,7 +512,7 @@ sub save_vendor { $form->{username}, $form->{user_password}, $form->{v_customer_id}, - substr($form->{currency}, 0, 3), + $form->{currency}, $form->{id} ); do_query($form, $dbh, $query, @values); @@ -639,7 +640,7 @@ sub search { my $sortorder; if ( $join_records ) { # in UNION case order by hash key, e.g. salesman - # the UNION created an implicit select around the result + # the UNION created an implicit select around the result $sortorder = $allowed_sort_columns{$form->{sort}} ? $form->{sort} : "name"; } else { # in not UNION case order by hash value, e.g. e.name @@ -812,7 +813,7 @@ sub search { } $query .= qq| ORDER BY $sortorder|; - + $form->{CT} = selectall_hashref_query($form, $dbh, $query, @values); $main::lxdebug->leave_sub();