Revision e02b6c61
Von Moritz Bunkus vor mehr als 16 Jahren hinzugefügt
SL/FU.pm | ||
---|---|---|
241 | 241 |
push @values, $employee_id; |
242 | 242 |
} |
243 | 243 |
|
244 |
my $order_by = ''; |
|
245 |
|
|
246 |
if ($form->{sort} ne 'title') { |
|
247 |
my %sort_columns = ( |
|
248 |
'follow_up_date' => [ qw(fu.follow_up_date fu.id) ], |
|
249 |
'created_on' => [ qw(created_on fu.id) ], |
|
250 |
'subject' => [ qw(lower(n.subject)) ], |
|
251 |
); |
|
252 |
|
|
253 |
my $sortdir = !defined $form->{sortdir} ? 'ASC' : $form->{sortdir} ? 'ASC' : 'DESC'; |
|
254 |
my $sortkey = $sort_columns{$form->{sort}} ? $form->{sort} : 'follow_up_date'; |
|
255 |
$order_by = 'ORDER BY ' . join(', ', map { "$_ $sortdir" } @{ $sort_columns{$sortkey} }); |
|
256 |
} |
|
257 |
|
|
244 | 258 |
$query = qq|SELECT fu.*, n.subject, n.body, n.created_by, |
245 | 259 |
fu.follow_up_date <= current_date AS due, |
246 | 260 |
fu.itime::DATE AS created_on, |
... | ... | |
253 | 267 |
WHERE ((fu.created_by = ?) OR (fu.created_for_user = ?) |
254 | 268 |
$where_user) |
255 | 269 |
$where |
256 |
ORDER BY fu.follow_up_date DESC, fu.id ASC|;
|
|
270 |
$order_by|;
|
|
257 | 271 |
|
258 | 272 |
my $follow_ups = selectall_hashref_query($form, $dbh, $query, @values); |
259 | 273 |
|
... | ... | |
266 | 280 |
$fu->{LINKS} = $self->retrieve_links(%{ $fu }); |
267 | 281 |
} |
268 | 282 |
|
283 |
if ($form->{sort} eq 'title') { |
|
284 |
my $dir_factor = !defined $form->{sortdir} ? 1 : $form->{sortdir} ? 1 : -1; |
|
285 |
$follow_ups = [ map { $_->[1] } |
|
286 |
sort { ($a->[0] cmp $b->[0]) * $dir_factor } |
|
287 |
map { my $fu = $follow_ups->[$_]; [ @{ $fu->{LINKS} } ? lc($fu->{LINKS}->[0]->{title}) : '', $fu ] } |
|
288 |
(0 .. scalar(@{ $follow_ups }) - 1) ]; |
|
289 |
} |
|
290 |
|
|
269 | 291 |
$main::lxdebug->leave_sub(); |
270 | 292 |
|
271 | 293 |
return $follow_ups; |
Auch abrufbar als: Unified diff
Wiedervorlagenbericht sortierbar gemacht.