summaryrefslogtreecommitdiff
path: root/LedgerSMB
diff options
context:
space:
mode:
Diffstat (limited to 'LedgerSMB')
-rw-r--r--LedgerSMB/AM.pm12
-rw-r--r--LedgerSMB/DBObject/Company.pm6
-rw-r--r--LedgerSMB/Setting.pm4
3 files changed, 17 insertions, 5 deletions
diff --git a/LedgerSMB/AM.pm b/LedgerSMB/AM.pm
index 3885829e..d2fdeca2 100644
--- a/LedgerSMB/AM.pm
+++ b/LedgerSMB/AM.pm
@@ -1815,7 +1815,7 @@ sub save_defaults {
fxgain_accno_id fxloss_accno_id glnumber sinumber vinumber
sonumber ponumber sqnumber rfqnumber partnumber employeenumber
customernumber vendornumber projectnumber yearend curr
- weightunit businessnumber)
+ weightunit businessnumber default_country)
)
{
my $val = $form->{$_};
@@ -2416,7 +2416,15 @@ sub get_all_defaults {
while ( ( $skey, $value ) = $sth->fetchrow_array() ) {
$form->{$skey} = $value;
}
-
+ $sth->finish;
+ $query = "select id, name from country order by name";
+ $sth = $dbh->prepare($query);
+ $sth->execute;
+ $form->{countries} = [];
+ while ($ref = $sth->fetchrow_hashref('NAME_lc')) {
+ push @{$form->{countries}}, $ref;
+ }
+ $sth->finish;
$self->defaultaccounts( undef, $form );
$dbh->commit;
}
diff --git a/LedgerSMB/DBObject/Company.pm b/LedgerSMB/DBObject/Company.pm
index 4d11d858..d8ea8039 100644
--- a/LedgerSMB/DBObject/Company.pm
+++ b/LedgerSMB/DBObject/Company.pm
@@ -11,6 +11,7 @@ retrieving customers and vendors.
package LedgerSMB::DBObject::Company;
+use LedgerSMB::Setting;
use base qw(LedgerSMB::DBObject);
use strict;
@@ -165,7 +166,10 @@ sub get_metadata {
@{$self->{contact_class_list}} =
$self->exec_method(funcname => 'entity_list_contact_class');
-
+ my $country_setting = LedgerSMB::Setting->new({base => $self, copy => 'base'});
+ $country_setting->{key} = 'default_country';
+ $country_setting->get;
+ $self->{default_country} = $country_setting->{value};
}
sub save_contact {
diff --git a/LedgerSMB/Setting.pm b/LedgerSMB/Setting.pm
index f9fc122c..637a8f84 100644
--- a/LedgerSMB/Setting.pm
+++ b/LedgerSMB/Setting.pm
@@ -52,8 +52,8 @@ our $VERSION = '1.0.0';
sub get {
my $self = shift;
- my $hashref = shift @{ $self->exec_method( funcname => 'setting_get' ) };
- $self->merge( $hashref, 'value' );
+ my ($hashref) = $self->exec_method( funcname => 'setting_get' ) ;
+ $self->{value} = $hashref->{setting_get};
}
sub increment {