diff options
author | aurynn_cmd <aurynn_cmd@4979c152-3d1c-0410-bac9-87ea11338e46> | 2008-09-25 23:08:34 +0000 |
---|---|---|
committer | aurynn_cmd <aurynn_cmd@4979c152-3d1c-0410-bac9-87ea11338e46> | 2008-09-25 23:08:34 +0000 |
commit | a316a97097bf8bcf9a4f809faf30dd756e60563d (patch) | |
tree | 044e4ccae8fc9faf724970464e4bc8dab468c58f /LedgerSMB | |
parent | 899c61eba210d60d8212dcd086fd74fc7a1c9812 (diff) |
Saving locations and contacts to a user now works as expected.
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@2342 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'LedgerSMB')
-rw-r--r-- | LedgerSMB/DBObject/Admin.pm | 2 | ||||
-rw-r--r-- | LedgerSMB/DBObject/Location.pm | 6 | ||||
-rw-r--r-- | LedgerSMB/DBObject/User.pm | 57 |
3 files changed, 54 insertions, 11 deletions
diff --git a/LedgerSMB/DBObject/Admin.pm b/LedgerSMB/DBObject/Admin.pm index e16e5dea..362d0c39 100644 --- a/LedgerSMB/DBObject/Admin.pm +++ b/LedgerSMB/DBObject/Admin.pm @@ -267,7 +267,7 @@ sub get_countries { sub get_contact_classes { my $self = shift @_; - my $sth = $self->{dbh}->prepare("select id, class as classname from contact_class"); + my $sth = $self->{dbh}->prepare("select id, class as name from contact_class"); my $code = $sth->execute(); return $sth->fetchall_arrayref({}); } diff --git a/LedgerSMB/DBObject/Location.pm b/LedgerSMB/DBObject/Location.pm index 1b7e2699..64ac9f01 100644 --- a/LedgerSMB/DBObject/Location.pm +++ b/LedgerSMB/DBObject/Location.pm @@ -17,6 +17,7 @@ sub save { my ($ret) = $self->exec_method(funcname=>$type."__save_location", args=>[ $self->{user_id}, # entity_id $self->{location_id}, # location_id + 3, # location_class, currently being set to "shipping" $self->{address1}, $self->{address2}, $self->{address3}, # address info @@ -25,7 +26,8 @@ sub save { $self->{zipcode}, $self->{country} # obviously, country. ]); - $self->{id} = $ret->[0]; + $self->{id} = $ret->{$type."__save_location"}; + $self->{dbh}->commit(); return $self->{id}; } @@ -59,7 +61,7 @@ sub get { my ($ret) = $self->exec_method(funcname=>"location__get", args=>[$id]); - return $ret->[0]; + return $ret->{location__get}; } sub get_all { diff --git a/LedgerSMB/DBObject/User.pm b/LedgerSMB/DBObject/User.pm index 0ca6bcfc..00a7e9db 100644 --- a/LedgerSMB/DBObject/User.pm +++ b/LedgerSMB/DBObject/User.pm @@ -90,6 +90,7 @@ sub get { } $self->{roles} = \@rolstore; + $self->{entity_id} = $self->{entity}->{id}; print STDERR "Got all user information"; #$user->{user} = $u->get($id); @@ -145,16 +146,56 @@ sub save_contact { my $self = shift @_; my $id = shift @_; + my $class = shift @_; my $contact = shift @_; + my @ret; + + print STDERR Dumper($self->{entity}->{id}); + if ($id) { + print STDERR "Found ID.."; + @ret = $self->exec_method(funcname=>"person__save_contact", + args=>[ + $self->{entity}->{id}, + $self->{contacts}->[$id]->{contact_class}, + $self->{contacts}->[$id]->{contact}, + $contact + ] + ); + } + else{ + print STDERR "Did not find an ID, attempting to save a new contact..\n"; + print STDERR ($class."\n"); + print STDERR ($contact."\n"); + print STDERR ($self->{entity_id}."\n"); + @ret = $self->exec_method(funcname=>"person__save_contact", + args=>[ + $self->{entity_id}, + $class, + undef, + $contact + ] + ); + } + print STDERR Dumper(\@ret); + if ($ret[0]->{person__save_contact} == 1){ + $self->{dbh}->commit(); + } + else{ + $self->error("Couldn't save contact..."); + } + return 1; +} + +sub delete_contact { + + my $self = shift @_; + my $id = shift @_; + + # Okay + # ID doesn't actually conform to any database entry + # We're basically cheating outrageously here. + - my @ret = $self->exec_method(funcname=>"person__save_contact", - args=>[ - $self->{entity_id}, - $self->{contacts}->[$id]->{contact_class}, - $self->{contacts}->[$id]->{contact}, - $contact - ] - ); } 1; |