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 | .
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 = (
$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}
);
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},
$form->{username},
$form->{user_password},
$form->{v_customer_id},
- substr($form->{currency}, 0, 3),
+ $form->{currency},
$form->{id}
);
do_query($form, $dbh, $query, @values);
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
}
$query .= qq| ORDER BY $sortorder|;
-
+
$form->{CT} = selectall_hashref_query($form, $dbh, $query, @values);
$main::lxdebug->leave_sub();