Revision 638e0b03
Von Sven Schöling vor fast 12 Jahren hinzugefügt
SL/Controller/CsvImport.pm | ||
---|---|---|
6 | 6 |
use SL::DB::CsvImportProfile; |
7 | 7 |
use SL::DB::CsvImportReport; |
8 | 8 |
use SL::DB::Unit; |
9 |
use SL::DB::Helper::Paginated (); |
|
9 | 10 |
use SL::Helper::Flash; |
10 | 11 |
use SL::SessionFile; |
11 | 12 |
use SL::Controller::CsvImport::Contact; |
... | ... | |
17 | 18 |
use SL::System::TaskServer; |
18 | 19 |
|
19 | 20 |
use List::MoreUtils qw(none); |
21 |
use List::Util qw(min); |
|
20 | 22 |
|
21 | 23 |
use parent qw(SL::Controller::Base); |
22 | 24 |
|
... | ... | |
123 | 125 |
sub action_report { |
124 | 126 |
my ($self, %params) = @_; |
125 | 127 |
|
126 |
$self->{report} = SL::DB::Manager::CsvImportReport->find_by(id => $params{report_id} || $::form->{id}); |
|
128 |
my $report_id = $params{report_id} || $::form->{id}; |
|
129 |
|
|
130 |
$self->{report} = SL::DB::Manager::CsvImportReport->find_by(id => $report_id); |
|
131 |
my $num_rows = SL::DB::Manager::CsvImportReportRow->get_all_count(query => [ csv_import_report_id => $report_id ]); |
|
132 |
my $num_cols = SL::DB::Manager::CsvImportReportRow->get_all_count(query => [ csv_import_report_id => $report_id, row => 0 ]); |
|
133 |
|
|
134 |
# manual paginating, yuck |
|
135 |
my $page = $::form->{page} || 1; |
|
136 |
my $pages = {}; |
|
137 |
$pages->{per_page} = $::form->{per_page} || 20; |
|
138 |
$pages->{max} = SL::DB::Helper::Paginated::ceil($num_rows / ($num_cols || 1), $pages->{per_page}) || 1; |
|
139 |
$pages->{cur} = $page < 1 ? 1 |
|
140 |
: $page > $pages->{max} ? $pages->{max} |
|
141 |
: $page; |
|
142 |
$pages->{common} = SL::DB::Helper::Paginated::make_common_pages($pages->{cur}, $pages->{max}); |
|
143 |
|
|
144 |
$self->{display_rows} = [ |
|
145 |
0, |
|
146 |
$pages->{per_page} * ($pages->{cur}-1) + 1 |
|
147 |
.. |
|
148 |
min($pages->{per_page} * $pages->{cur}, $num_rows / ($num_cols || 1) - 1) |
|
149 |
]; |
|
150 |
|
|
151 |
my @query = ( |
|
152 |
csv_import_report_id => $report_id, |
|
153 |
or => [ |
|
154 |
row => 0, |
|
155 |
and => [ |
|
156 |
row => { gt => $pages->{per_page} * ($pages->{cur}-1) }, |
|
157 |
row => { le => $pages->{per_page} * $pages->{cur} }, |
|
158 |
] |
|
159 |
] |
|
160 |
); |
|
161 |
|
|
162 |
my $rows = SL::DB::Manager::CsvImportReportRow->get_all(query => \@query); |
|
163 |
my $status = SL::DB::Manager::CsvImportReportStatus->get_all(query => \@query); |
|
164 |
|
|
165 |
$self->{report_rows} = $self->{report}->folded_rows(rows => $rows); |
|
166 |
$self->{report_status} = $self->{report}->folded_status(status => $status); |
|
167 |
$self->{pages} = $pages; |
|
168 |
|
|
169 |
my $base_url = $self->url_for(action => 'report', id => $report_id); |
|
127 | 170 |
|
128 |
$self->render('csv_import/report', { no_layout => $params{no_layout} }); |
|
171 |
$self->render('csv_import/report', { no_layout => $params{no_layout} }, base_url => $base_url);
|
|
129 | 172 |
} |
130 | 173 |
|
131 | 174 |
|
Auch abrufbar als: Unified diff
report paginaten