[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb: [1588] trunk/LedgerSMB



Revision: 1588
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=1588&view=rev
Author:   aurynn_cmd
Date:     2007-09-13 15:05:20 -0700 (Thu, 13 Sep 2007)

Log Message:
-----------
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.

Modified Paths:
--------------
    trunk/LedgerSMB/Contact.pm
    trunk/LedgerSMB/DBObject.pm

Modified: trunk/LedgerSMB/Contact.pm
===================================================================
--- trunk/LedgerSMB/Contact.pm	2007-09-13 21:49:39 UTC (rev 1587)
+++ trunk/LedgerSMB/Contact.pm	2007-09-13 22:05:20 UTC (rev 1588)
@@ -34,3 +34,55 @@
 
 =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

Modified: trunk/LedgerSMB/DBObject.pm
===================================================================
--- trunk/LedgerSMB/DBObject.pm	2007-09-13 21:49:39 UTC (rev 1587)
+++ trunk/LedgerSMB/DBObject.pm	2007-09-13 22:05:20 UTC (rev 1588)
@@ -266,4 +266,15 @@
     return @return_array;
 }
 
+sub set {
+    
+    my $self = shift @_;
+    my %args = @_;
+    
+    for my $arg (keys(%args)) {
+        $self->{$arg} = $args{$arg};
+    }
+    return 1;    
+}
+
 1;


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.