Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision db11732b

Von Sven Schöling vor etwa 8 Jahren hinzugefügt

  • ID db11732b27f9d7bd86fb6bf1cd4150e59a54559f
  • Vorgänger b21776d2
  • Nachfolger e2b04039

GDPDU: Export nach Buchungsjahr

Unterschiede anzeigen:

SL/Controller/Gdpdu.pm
4 4

  
5 5
use parent qw(SL::Controller::Base);
6 6

  
7
use DateTime;
7 8
use SL::GDPDU;
8 9
use SL::Locale::String qw(t8);
9 10
use SL::Helper::Flash;
10 11

  
12
use SL::DB::AccTransaction;
13

  
11 14
use Rose::Object::MakeMethods::Generic (
12 15
  'scalar --get_set_init' => [ qw(from to) ],
13 16
);
......
20 23
  $self->from(DateTime->today->add(years => -1)->add(days => 1)) if !$self->from;
21 24
  $self->to(DateTime->today)                                     if !$self->to;
22 25

  
23
  $self->render('gdpdu/filter', title => t8('GDPDU Export'));
26
  $::request->layout->add_javascripts('kivi.Gdpdu.js');
27
  $self->render('gdpdu/filter', current_year => DateTime->today->year, title => t8('GDPDU Export'));
24 28
}
25 29

  
26 30
sub action_export {
......
52 56

  
53 57
  my $error = 0;
54 58

  
55
  if (!$::form->{from}) {
56
    my $epoch = DateTime->new(day => 1, month => 1, year => 1900);
57
    flash('info', t8('No start date given, setting to #1', $epoch->to_kivitendo));
58
    $self->from($epoch);
59
  }
60

  
61
  if (!$::form->{to}) {
62
    flash('info', t8('No end date given, setting to today'));
63
    $self->to(DateTime->today);
59
  if ($::form->{method} eq 'year') {
60
    if ($::form->{year}) {
61
      $self->from(DateTime->new(year => $::form->{year}, month => 1,  day => 1));
62
      $self->to(  DateTime->new(year => $::form->{year}, month => 12, day => 31));
63
    } else {
64
      $error = 1;
65
      flash('error', t8('No year given for method year'));
66
    }
67
  } else {
68
    if (!$::form->{from}) {
69
      my $epoch = DateTime->new(day => 1, month => 1, year => 1900);
70
      flash('info', t8('No start date given, setting to #1', $epoch->to_kivitendo));
71
      $self->from($epoch);
72
    }
73

  
74
    if (!$::form->{to}) {
75
      flash('info', t8('No end date given, setting to today'));
76
      $self->to(DateTime->today);
77
    }
64 78
  }
65 79

  
66 80
  !$error;
67 81
}
68 82

  
83
sub available_years {
84
  my ($self) = @_;
85

  
86
  my $first_trans = SL::DB::Manager::AccTransaction->get_first(sort_by => 'transdate', limit => 1);
87

  
88
  return [] unless $first_trans;
89
  return [ reverse $first_trans->transdate->year .. DateTime->today->year ];
90
}
91

  
69 92
sub init_from { DateTime->from_kivitendo($::form->{from}) }
70 93
sub init_to { DateTime->from_kivitendo($::form->{to}) }
71 94

  
js/kivi.Gdpdu.js
1
namespace('kivi.Gdpdu', function(ns) {
2
  ns.grey_invalid_options = function(el){
3
    console.log(el);
4
    if ($(el).prop('checked')) {
5
      $(el).closest('tr').find('input.datepicker').prop('disabled', false).datepicker('enable');
6
      $(el).closest('tr').find('select').prop('disabled', 0);
7
    } else {
8
      $(el).closest('tr').find('input.datepicker').prop('disabled', true).datepicker('disable');
9
      $(el).closest('tr').find('select').prop('disabled', 1);
10
    }
11
  }
12

  
13
  ns.update_all_radio = function () {
14
    $('input[type=radio]').each(function(i,e) {ns.grey_invalid_options (e) });
15
  }
16

  
17
  ns.setup = function() {
18
    ns.update_all_radio();
19
    $('input[type=radio]').change(ns.update_all_radio);
20
  }
21
});
22

  
23
$(kivi.Gdpdu.setup);
templates/webpages/gdpdu/filter.html
9 9

  
10 10
<p>[% 'This export will include all records in the given time range and all supplicant information from checked entities. You will receive a single zip file. Please extract this file onto the data medium requested by your auditor.' | $T8 %]</p>
11 11

  
12
<form>
12
<form id='filter_form'>
13 13

  
14 14
<table>
15 15
  <tr>
16
    <td>[% 'From Date' | $T8 %]</td>
17
    <td>[% L.date_tag('from', SELF.from) %]</td>
16
    <td>[% L.radio_button_tag('method', value='year', checked=1) %]
17
    <td>[% 'Year' | $T8 %]</td>
18
    <td>[% L.select_tag('year', SELF.available_years, default=current_year) %]</td>
18 19
  </tr>
19 20
  <tr>
21
    <td>[% L.radio_button_tag('method') %]
22
    <td>[% 'From Date' | $T8 %]</td>
23
    <td>[% L.date_tag('from', SELF.from) %]</td>
20 24
    <td>[% 'To Date' | $T8 %]</td>
21 25
    <td>[% L.date_tag('to', SELF.to) %]</td>
22 26
  </tr>

Auch abrufbar als: Unified diff