summaryrefslogtreecommitdiff
path: root/LedgerSMB/Employee.pm
blob: 1165c441ba6b95faedefb785b86a957d56f0f60f (plain)
  1. =head1 NAME
  2. LedgerSMB::Employee - LedgerSMB class for managing Employees
  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. =item new ($LedgerSMB object);
  8. The following methods are passed through to stored procedures via Autoload.
  9. =item save
  10. =item get
  11. =item search
  12. =item list_managers
  13. The above list may grow over time, and may depend on other installed modules.
  14. =head1 Copyright (C) 2007, The LedgerSMB core team.
  15. This file is licensed under the Gnu General Public License version 2, or at your
  16. option any later version. A copy of the license should have been included with
  17. your software.
  18. =back
  19. =cut
  20. package LedgerSMB::Employee;
  21. use LedgerSMB;
  22. use LedgerSMB::DBObject;
  23. @ISA = (LedgerSMB::DBObject);
  24. sub AUTOLOAD {
  25. my $procname = "employee_$LedgerSMB::Employee::Autoload";
  26. $self->exec_method($procname);
  27. }
  28. sub new {
  29. my $lsmb = shift @_;
  30. if (! $lsmb->isa(LedgerSMB)){
  31. $self->error("Employee called without LedgerSMB object arg");
  32. my $self = {};
  33. for $attr (keys $lsmb){
  34. $self->{$attr} = $lsmb->{$attr};
  35. }
  36. bless $self;
  37. }
  38. sub save {
  39. my $hashref = shift ($self->exec_method("employee_save"));
  40. $self->merge($hashref, 'id');
  41. }
  42. sub get {
  43. my $hashref = shift ($self->exec_method("employee_get"));
  44. $self->merge($hashref, keys $hashref);
  45. }
  46. sub delete {
  47. $self->exec_method("employee_delete");
  48. }
  49. sub list_managers {
  50. $self->{manager_list} = $self->exec_method("employee_list_managers");
  51. }
  52. sub search {
  53. $self->{search_results} = $self->exec_method("employee_search");
  54. }