summaryrefslogtreecommitdiff
path: root/LedgerSMB
diff options
context:
space:
mode:
authoraurynn_cmd <aurynn_cmd@4979c152-3d1c-0410-bac9-87ea11338e46>2007-09-13 22:05:20 +0000
committeraurynn_cmd <aurynn_cmd@4979c152-3d1c-0410-bac9-87ea11338e46>2007-09-13 22:05:20 +0000
commita498349aa91f645793b8ce2905ca38ef3bef4469 (patch)
tree35a1a8ceb3215fabeb91c929282a827d57562e53 /LedgerSMB
parent56ad90dff170995d2c74592ed2ab8714394dedcc (diff)
Updates to admin.pm to correct for multiple Contact objects, instead of a single contact object.
DBObject has ->set() added, which allows setting 1..n args in the object. Contact stub beginning to be expanded, ->get, ->save and ->search implemented. git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1588 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'LedgerSMB')
-rw-r--r--LedgerSMB/Contact.pm52
-rw-r--r--LedgerSMB/DBObject.pm11
2 files changed, 63 insertions, 0 deletions
diff --git a/LedgerSMB/Contact.pm b/LedgerSMB/Contact.pm
index 473e50c5..b98a6298 100644
--- a/LedgerSMB/Contact.pm
+++ b/LedgerSMB/Contact.pm
@@ -34,3 +34,55 @@ your software.
=cut
+package LedgerSMB::Contact;
+
+use base LedgerSMB::DBObject;
+use LedgerSMB::Error;
+
+
+sub save {
+
+ my $self = shift @_;
+
+ # check for the various fields being appropriately set..
+
+ if ($self->{person_id} && $self->{contact} && $self->{contact_class}) {
+
+ my $id = shift @ {$self->exec_method( procname => "save_contact" ) };
+ $self->merge($id);
+ return $self->{id};
+ }
+ else {
+
+ # raise an exception
+ my $err = LedgerSMB::Error->new();
+ $err->text("Unable to save contact information");
+ $err->throw();
+ }
+}
+
+sub get {
+
+ my $self=shift @_;
+ my $id = shift @_;
+
+ my $result = shift @{ $self->exec_method(
+ procname => 'get',
+ args=>[$id]
+ );
+}
+
+sub search {
+
+ my $self = shift @_;
+ my ($pattern, $offset, $limit) = @_;
+
+ my $results = $self->exec_method(
+ procname => 'search',
+ args=>[$pattern, $offset, $limit]
+ );
+
+ return $results;
+}
+
+1; \ No newline at end of file
diff --git a/LedgerSMB/DBObject.pm b/LedgerSMB/DBObject.pm
index e712c934..f83ab3ea 100644
--- a/LedgerSMB/DBObject.pm
+++ b/LedgerSMB/DBObject.pm
@@ -266,4 +266,15 @@ sub _parse_array {
return @return_array;
}
+sub set {
+
+ my $self = shift @_;
+ my %args = @_;
+
+ for my $arg (keys(%args)) {
+ $self->{$arg} = $args{$arg};
+ }
+ return 1;
+}
+
1;