use SL::Common;
use SL::CVar;
use SL::DBUtils;
+use SL::DB::Default;
use SL::FU;
use SL::Notes;
use SL::TransNumber;
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 name AS curr FROM currencies WHERE id=?|;
+ ($form->{curr}) = selectrow_query($form, $dbh, $query, conv_i($form->{currency_id}));
- $sth->finish;
if ( $form->{salesman_id} ) {
my $query =
qq|SELECT ct.name AS salesman | .
$query = qq|SELECT nextval('id')|;
($form->{id}) = selectrow_query($form, $dbh, $query);
- $query = qq|INSERT INTO customer (id, name) VALUES (?, '')|;
+ $query = qq|INSERT INTO customer (id, name, currency_id) VALUES (?, '', (SELECT currency_id FROM defaults))|;
do_query($form, $dbh, $query, $form->{id});
}
qq|user_password = ?, | .
qq|c_vendor_id = ?, | .
qq|klass = ?, | .
- qq|curr = ?, | .
+ qq|currency_id = (SELECT id FROM currencies WHERE name = ?), | .
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}
);
$query = qq|SELECT nextval('id')|;
($form->{id}) = selectrow_query($form, $dbh, $query);
- $query = qq|INSERT INTO vendor (id, name) VALUES (?, '')|;
+ $query = qq|INSERT INTO vendor (id, name, currency_id) VALUES (?, '', (SELECT currency_id FROM defaults))|;
do_query($form, $dbh, $query, $form->{id});
my $vendornumber = SL::TransNumber->new(type => 'vendor',
qq| username = ?, | .
qq| user_password = ?, | .
qq| v_customer_id = ?, | .
- qq| curr = ? | .
+ qq| currency_id = (SELECT id FROM currencies WHERE name = ?) | .
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 ($self, $myconfig, $form) = @_;
my $locale = $main::locale;
+ my $defaults = SL::DB::Default->get;
+ $form->error($::locale->text('No print templates have been created for this client yet. Please do so in the client configuration.')) if !$defaults->templates;
+ $form->{templates} = $defaults->templates;
+
$form->{formname} = 'sales_quotation';
$form->{type} = 'sales_quotation';
$form->{format} = 'excel';
$form->{notes} =~ s/^\s+//g;
- $form->{templates} = $myconfig->{templates};
-
delete $form->{printer_command};
$form->get_employee_info($myconfig);