summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;