summaryrefslogtreecommitdiff
path: root/LedgerSMB/DBObject/Location.pm
blob: 64ac9f013482327eaef088cf1b3882e411888707 (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. 3, # location_class, currently being set to "shipping"
  14. $self->{address1},
  15. $self->{address2},
  16. $self->{address3}, # address info
  17. $self->{city}, # city
  18. $self->{state}, # state/province
  19. $self->{zipcode},
  20. $self->{country} # obviously, country.
  21. ]);
  22. $self->{id} = $ret->{$type."__save_location"};
  23. $self->{dbh}->commit();
  24. return $self->{id};
  25. }
  26. sub delete {
  27. my $self = shift @_;
  28. my $id = shift @_;
  29. my $e_id = shift @_;
  30. my $type = shift @_;
  31. # e_id is an entity of some variety
  32. if (!$id && !$self->{location_id}) {
  33. $self->error("Must call delete with an ID...");
  34. }
  35. unless ($id) {
  36. $id = $self->{location_id};
  37. }
  38. my ($res) = $self->exec_method(funcname=>$type."__delete_location", args=>[$e_id,$id]);
  39. return $res->[0];
  40. }
  41. sub get {
  42. my $self = shift @_;
  43. my $id = shift @_;
  44. my ($ret) = $self->exec_method(funcname=>"location__get", args=>[$id]);
  45. return $ret->{location__get};
  46. }
  47. sub get_all {
  48. my $self = shift @_;
  49. my $user_id = shift @_;
  50. my $type = shift @_;
  51. my @locations = $self->exec_method(funcname=>$type."__all_locations", args=>[$user_id]);
  52. return \@locations;
  53. }
  54. 1;