summaryrefslogtreecommitdiff
path: root/LedgerSMB/Employee.pm
blob: e792aa840f8a20a91fdbc7eedb41f30fb81be119 (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 $hashref = shift @{ $self->exec_method( procname => "employee_save" ) };
  30. $self->merge( $hashref, 'id' );
  31. }
  32. sub get {
  33. my $self = shift;
  34. my $hashref = shift @{ $self->exec_method( procname => "employee_get" ) };
  35. $self->merge( $hashref, keys %{$hashref} );
  36. }
  37. sub list_managers {
  38. my $self = shift;
  39. $self->{manager_list} =
  40. $self->exec_method( procname => "employee_list_managers" );
  41. }
  42. sub search {
  43. my $self = shift;
  44. $self->{search_results} =
  45. $self->exec_method( procname => "employee_search" );
  46. }
  47. sub set_location {
  48. my $self = shift @_;
  49. my $location = shift @_;
  50. my $code = $self->exec_method ( procname => 'employee_set_location',
  51. args=>[ $self->{id}, $location->{id} ] );
  52. if ($code) {
  53. # good, it worked.
  54. return 1;
  55. }
  56. return 0;
  57. }
  58. 1;