Revision db11732b
Von Sven Schöling vor mehr als 8 Jahren hinzugefügt
SL/Controller/Gdpdu.pm | ||
---|---|---|
|
||
use parent qw(SL::Controller::Base);
|
||
|
||
use DateTime;
|
||
use SL::GDPDU;
|
||
use SL::Locale::String qw(t8);
|
||
use SL::Helper::Flash;
|
||
|
||
use SL::DB::AccTransaction;
|
||
|
||
use Rose::Object::MakeMethods::Generic (
|
||
'scalar --get_set_init' => [ qw(from to) ],
|
||
);
|
||
... | ... | |
$self->from(DateTime->today->add(years => -1)->add(days => 1)) if !$self->from;
|
||
$self->to(DateTime->today) if !$self->to;
|
||
|
||
$self->render('gdpdu/filter', title => t8('GDPDU Export'));
|
||
$::request->layout->add_javascripts('kivi.Gdpdu.js');
|
||
$self->render('gdpdu/filter', current_year => DateTime->today->year, title => t8('GDPDU Export'));
|
||
}
|
||
|
||
sub action_export {
|
||
... | ... | |
|
||
my $error = 0;
|
||
|
||
if (!$::form->{from}) {
|
||
my $epoch = DateTime->new(day => 1, month => 1, year => 1900);
|
||
flash('info', t8('No start date given, setting to #1', $epoch->to_kivitendo));
|
||
$self->from($epoch);
|
||
}
|
||
|
||
if (!$::form->{to}) {
|
||
flash('info', t8('No end date given, setting to today'));
|
||
$self->to(DateTime->today);
|
||
if ($::form->{method} eq 'year') {
|
||
if ($::form->{year}) {
|
||
$self->from(DateTime->new(year => $::form->{year}, month => 1, day => 1));
|
||
$self->to( DateTime->new(year => $::form->{year}, month => 12, day => 31));
|
||
} else {
|
||
$error = 1;
|
||
flash('error', t8('No year given for method year'));
|
||
}
|
||
} else {
|
||
if (!$::form->{from}) {
|
||
my $epoch = DateTime->new(day => 1, month => 1, year => 1900);
|
||
flash('info', t8('No start date given, setting to #1', $epoch->to_kivitendo));
|
||
$self->from($epoch);
|
||
}
|
||
|
||
if (!$::form->{to}) {
|
||
flash('info', t8('No end date given, setting to today'));
|
||
$self->to(DateTime->today);
|
||
}
|
||
}
|
||
|
||
!$error;
|
||
}
|
||
|
||
sub available_years {
|
||
my ($self) = @_;
|
||
|
||
my $first_trans = SL::DB::Manager::AccTransaction->get_first(sort_by => 'transdate', limit => 1);
|
||
|
||
return [] unless $first_trans;
|
||
return [ reverse $first_trans->transdate->year .. DateTime->today->year ];
|
||
}
|
||
|
||
sub init_from { DateTime->from_kivitendo($::form->{from}) }
|
||
sub init_to { DateTime->from_kivitendo($::form->{to}) }
|
||
|
js/kivi.Gdpdu.js | ||
---|---|---|
namespace('kivi.Gdpdu', function(ns) {
|
||
ns.grey_invalid_options = function(el){
|
||
console.log(el);
|
||
if ($(el).prop('checked')) {
|
||
$(el).closest('tr').find('input.datepicker').prop('disabled', false).datepicker('enable');
|
||
$(el).closest('tr').find('select').prop('disabled', 0);
|
||
} else {
|
||
$(el).closest('tr').find('input.datepicker').prop('disabled', true).datepicker('disable');
|
||
$(el).closest('tr').find('select').prop('disabled', 1);
|
||
}
|
||
}
|
||
|
||
ns.update_all_radio = function () {
|
||
$('input[type=radio]').each(function(i,e) {ns.grey_invalid_options (e) });
|
||
}
|
||
|
||
ns.setup = function() {
|
||
ns.update_all_radio();
|
||
$('input[type=radio]').change(ns.update_all_radio);
|
||
}
|
||
});
|
||
|
||
$(kivi.Gdpdu.setup);
|
templates/webpages/gdpdu/filter.html | ||
---|---|---|
|
||
<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>
|
||
|
||
<form>
|
||
<form id='filter_form'>
|
||
|
||
<table>
|
||
<tr>
|
||
<td>[% 'From Date' | $T8 %]</td>
|
||
<td>[% L.date_tag('from', SELF.from) %]</td>
|
||
<td>[% L.radio_button_tag('method', value='year', checked=1) %]
|
||
<td>[% 'Year' | $T8 %]</td>
|
||
<td>[% L.select_tag('year', SELF.available_years, default=current_year) %]</td>
|
||
</tr>
|
||
<tr>
|
||
<td>[% L.radio_button_tag('method') %]
|
||
<td>[% 'From Date' | $T8 %]</td>
|
||
<td>[% L.date_tag('from', SELF.from) %]</td>
|
||
<td>[% 'To Date' | $T8 %]</td>
|
||
<td>[% L.date_tag('to', SELF.to) %]</td>
|
||
</tr>
|
Auch abrufbar als: Unified diff
GDPDU: Export nach Buchungsjahr