summaryrefslogtreecommitdiff
path: root/LedgerSMB/Employee.pm
blob: 59a550f25667616d11139a7e91418003dad195f9 (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. =over
  8. =item new ($LedgerSMB object);
  9. =back
  10. The following methods are passed through to stored procedures via Autoload.
  11. =over
  12. =item save
  13. =item get
  14. =item search
  15. =item list_managers
  16. The above list may grow over time, and may depend on other installed modules.
  17. =back
  18. =head1 Copyright (C) 2007, The LedgerSMB core team.
  19. This file is licensed under the Gnu General Public License version 2, or at your
  20. option any later version. A copy of the license should have been included with
  21. your software.
  22. =cut
  23. package LedgerSMB::Employee;
  24. use base qw(LedgerSMB::DBObject);
  25. use strict;
  26. our $VERSION = '1.0.0';
  27. sub save {
  28. my $self = shift;
  29. my $person = shift @{ $self->exec_method (procname => 'person_save',
  30. args => [] )};
  31. my $hashref = shift @{ $self->exec_method( procname => "employee_save" ) };
  32. $self->merge( $hashref, 'id' );
  33. }
  34. sub get {
  35. my $self = shift;
  36. my $hashref = shift @{ $self->exec_method( procname => "employee_get" ) };
  37. $self->merge( $hashref, keys %{$hashref} );
  38. }
  39. sub list_managers {
  40. my $self = shift;
  41. $self->{manager_list} =
  42. $self->exec_method( procname => "employee_list_managers" );
  43. }
  44. sub search {
  45. my $self = shift;
  46. $self->{search_results} =
  47. $self->exec_method( procname => "employee_search" );
  48. }
  49. sub set_location {
  50. my $self = shift @_;
  51. my $location = shift @_;
  52. my $code = $self->exec_method ( procname => 'employee_set_location',
  53. args=>[ $self->{id}, $location->{id} ] );
  54. if ($code) {
  55. # good, it worked.
  56. return 1;
  57. }
  58. return 0;
  59. }
  60. 1;