summaryrefslogtreecommitdiff
path: root/LedgerSMB/DBObject/Location.pm
blob: 1b7e2699aa1cfc96a3f1af30093c4e6ffe04cb0d (plain)
  1. package LedgerSMB::DBObject::Location;
  2. use base LedgerSMB::DBObject;
  3. sub create {
  4. my $self = shift @_;
  5. }
  6. sub save {
  7. my $self = shift @_;
  8. my $type = shift @_;
  9. # assumes all the parameters are present...
  10. my ($ret) = $self->exec_method(funcname=>$type."__save_location", args=>[
  11. $self->{user_id}, # entity_id
  12. $self->{location_id}, # location_id
  13. $self->{address1},
  14. $self->{address2},
  15. $self->{address3}, # address info
  16. $self->{city}, # city
  17. $self->{state}, # state/province
  18. $self->{zipcode},
  19. $self->{country} # obviously, country.
  20. ]);
  21. $self->{id} = $ret->[0];
  22. return $self->{id};
  23. }
  24. sub delete {
  25. my $self = shift @_;
  26. my $id = shift @_;
  27. my $e_id = shift @_;
  28. my $type = shift @_;
  29. # e_id is an entity of some variety
  30. if (!$id && !$self->{location_id}) {
  31. $self->error("Must call delete with an ID...");
  32. }
  33. unless ($id) {
  34. $id = $self->{location_id};
  35. }
  36. my ($res) = $self->exec_method(funcname=>$type."__delete_location", args=>[$e_id,$id]);
  37. return $res->[0];
  38. }
  39. sub get {
  40. my $self = shift @_;
  41. my $id = shift @_;
  42. my ($ret) = $self->exec_method(funcname=>"location__get", args=>[$id]);
  43. return $ret->[0];
  44. }
  45. sub get_all {
  46. my $self = shift @_;
  47. my $user_id = shift @_;
  48. my $type = shift @_;
  49. my @locations = $self->exec_method(funcname=>$type."__all_locations", args=>[$user_id]);
  50. return \@locations;
  51. }
  52. 1;