summaryrefslogtreecommitdiff
path: root/LedgerSMB/Contact.pm
blob: b3d6b9d891c5e7f1adebd02fbc6354245a3b182e (plain)
  1. =head1 NAME
  2. LedgerSMB::Contact - LedgerSMB class for managing Contacts
  3. =head1 SYOPSIS
  4. This module creates object instances based on LedgerSMB's in-database ORM.
  5. =head1 METHODS
  6. The following method is static:
  7. =over
  8. =item new ($LedgerSMB object);
  9. The following methods are passed through to stored procedures via Autoload.
  10. =item save
  11. =item get
  12. =item search
  13. The above list may grow over time, and may depend on other installed modules.
  14. =back
  15. =head1 Copyright (C) 2007, The LedgerSMB core team.
  16. This file is licensed under the Gnu General Public License version 2, or at your
  17. option any later version. A copy of the license should have been included with
  18. your software.
  19. =cut
  20. package LedgerSMB::Contact;
  21. use base LedgerSMB::DBObject;
  22. #use LedgerSMB::Error;
  23. sub save {
  24. my $self = shift @_;
  25. # check for the various fields being appropriately set..
  26. if ($self->{person_id} && $self->{contact} && $self->{contact_class}) {
  27. my $id = shift @ {$self->exec_method( procname => "save_contact" ) };
  28. $self->merge($id);
  29. return $self->{id};
  30. }
  31. else {
  32. # raise an exception
  33. my $err = LedgerSMB::Error->new();
  34. $err->text("Unable to save contact information");
  35. $err->throw();
  36. }
  37. }
  38. sub get {
  39. my $self = shift @_;
  40. my $id = shift @_;
  41. my $result = shift @{ $self->exec_method(
  42. procname => 'get',
  43. args=>[$id]
  44. ) };
  45. }
  46. sub search {
  47. my $self = shift @_;
  48. my ($pattern, $offset, $limit) = @_;
  49. my $results = $self->exec_method(
  50. procname => 'search',
  51. args=>[$pattern, $offset, $limit]
  52. );
  53. return $results;
  54. }
  55. 1;