summaryrefslogtreecommitdiff
path: root/LedgerSMB/DBObject/Date.pm
blob: 50d0bcd810d7e004136df8a386946e52bdfd717a (plain)
  1. =head1 NAME
  2. LedgerSMB::Date Date Handling Back-end Routines for LedgerSMB
  3. =head1 SYNOPSIS
  4. Provides the functions for generating the data structures for dates used in
  5. LedgerSMB.
  6. =cut
  7. package LedgerSMB::DBObject::Date;
  8. use base qw(LedgerSMB::DBObject);
  9. use strict;
  10. use Math::BigFloat lib => 'GMP';
  11. our $VERSION = '0.1.0';
  12. =head1 METHODS
  13. =over
  14. =item LedgerSMB::DBObject::Payment->new()
  15. Inherited from LedgerSMB::DBObject. Please see that documnetation for details.
  16. =item $self->build_filter_by_period()
  17. This function takes $locale as an argument to build the list boxes, of the
  18. period filter.
  19. It sets $self->{yearsOptions}, $self->{$monthsOptions}, $self->{radioOptions}
  20. so you just pass the hash to the template system. :)
  21. =back
  22. =cut
  23. sub build_filter_by_period {
  24. my ($self, $locale) = @_;
  25. my @all_years = $self->call_procedure(procname => 'date_get_all_years');
  26. for my $ref (0 .. $#all_years) {
  27. push @{$self->{yearsOptions}} , { value => $all_years[$ref]{year},
  28. text => $all_years[$ref]{year}}
  29. }
  30. @{$self->{monthsOptions}} = (
  31. { value => '01', text => $locale->text('January')},
  32. { value => '02', text => $locale->text('February')},
  33. { value => '03', text => $locale->text('March')},
  34. { value => '04', text => $locale->text('April')},
  35. { value => '05', text => $locale->text('May')},
  36. { value => '06', text => $locale->text('June')},
  37. { value => '07', text => $locale->text('July')},
  38. { value => '08', text => $locale->text('August')},
  39. { value => '09', text => $locale->text('September')},
  40. { value => '10', text => $locale->text('October')},
  41. { value => '11', text => $locale->text('November')},
  42. { value => '12', text => $locale->text('December')}
  43. );
  44. @{$self->{radioOptions}} = (
  45. {
  46. label => $locale->text('Current'),
  47. name => 'radioPeriod',
  48. value => '1',
  49. },
  50. {
  51. label => $locale->text('Month'),
  52. name => 'radioPeriod',
  53. value => '2',
  54. active => '1',
  55. },
  56. {
  57. label => $locale->text('Quarter'),
  58. name => 'radioPeriod',
  59. value => '3',
  60. },
  61. {
  62. label => $locale->text('Year'),
  63. name => 'radioPeriod',
  64. value => '4',
  65. });
  66. }
  67. 1;