summaryrefslogtreecommitdiff
path: root/LedgerSMB/Batch.pm
blob: 34d0185cc774bcad4e324bbd8be5c160a3bb311a (plain)
  1. package LedgerSMB::Batch;
  2. use base qw(LedgerSMB::DBObject);
  3. sub create {
  4. $self = shift @_;
  5. my ($ref) = $self->exec_method(funcname => 'batch_create');
  6. $self->{id} = $ref->{batch_create};
  7. $self->{dbh}->commit;
  8. return $ref->{id};
  9. }
  10. sub delete_voucher {
  11. my ($self, $voucher_id) = @_;
  12. $self->call_procedure(procname => 'voucher__delete', args => [$voucher_id]);
  13. $self->{dbh}->commit;
  14. }
  15. sub get_search_criteria {
  16. $self = shift @_;
  17. @{$self->{batch_classes}} = $self->exec_method(
  18. funcname => 'batch_list_classes'
  19. );
  20. @{$self->{batch_users}} = $self->exec_method(
  21. funcname => 'batch_get_users'
  22. );
  23. unshift @{$self->{batch_users}}, {username => $self->{_locale}->text('Any'), id => '0', entity_id => ''};
  24. }
  25. sub get_search_results {
  26. my ($self, $args) = @_;
  27. if ($args->{mini}){
  28. $search_proc = "batch_search_mini";
  29. } else {
  30. $search_proc = "batch_search";
  31. }
  32. @{$self->{search_results}} = $self->exec_method(funcname => $search_proc);
  33. return @{$self->{search_results}};
  34. }
  35. sub get_class_id {
  36. my ($self, $type) = @_;
  37. @results = $self->call_procedure(
  38. procname => 'batch_get_class_id',
  39. args => [$type]
  40. );
  41. my $result = pop @results;
  42. return $result->{batch_get_class_id};
  43. }
  44. sub post {
  45. my ($self) = @_;
  46. ($self->{post_return_ref}) = $self->exec_method(funcname => 'batch_post');
  47. $self->{dbh}->commit;
  48. return $self->{post_return_ref};
  49. }
  50. sub delete {
  51. my ($self) = @_;
  52. ($self->{delete_ref}) = $self->exec_method(funcname => 'batch_delete');
  53. $self->{dbh}->commit;
  54. return $self->{delete_ref};
  55. }
  56. sub list_vouchers {
  57. my ($self) = @_;
  58. @{$self->{vouchers}} = $self->exec_method(funcname => 'voucher_list');
  59. return @{$self->{vouchers}};
  60. }
  61. 1;