Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision e02b6c61

Von Moritz Bunkus vor mehr als 16 Jahren hinzugefügt

  • ID e02b6c616968db9aef1ba9425254d4b29ff1c7e8
  • Vorgänger aa589686
  • Nachfolger 10090774

Wiedervorlagenbericht sortierbar gemacht.

Unterschiede anzeigen:

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;
bin/mozilla/fu.pl
205 205

  
206 206
  my @report_params = qw(created_for subject body reference follow_up_date_from follow_up_date_to itime_from itime_to due_only all_users done not_done);
207 207

  
208
  report_generator_set_default_sort('follow_up_date', 1);
209

  
208 210
  my $follow_ups    = FU->follow_ups(map { $_ => $form->{$_} } @report_params);
209 211
  $form->{rowcount} = scalar @{ $follow_ups };
210 212

  
......
222 224
  );
223 225

  
224 226
  my @columns = qw(selected follow_up_date created_on subject title created_by_name created_for_user_name done);
227
  my $href    = build_std_url('action=report', grep { $form->{$_} } @report_params);
228

  
229
  foreach my $name (qw(follow_up_date created_on title subject)) {
230
    my $sortdir                 = $form->{sort} eq $name ? 1 - $form->{sortdir} : $form->{sortdir};
231
    $column_defs{$name}->{link} = $href . "&sort=$name&sortdir=$sortdir";
232
  }
225 233

  
226 234
  my @options;
227 235

  
......
253 261

  
254 262
  $report->set_export_options('report', @report_params);
255 263

  
256
  $report->set_sort_indicator('follow_up_date', 1);
264
  $report->set_sort_indicator($form->{sort}, $form->{sortdir});
257 265

  
258 266
  $report->set_options('raw_top_info_text'    => $form->parse_html_template('fu/report_top',    { 'OPTIONS' => \@options }),
259 267
                       'raw_bottom_info_text' => $form->parse_html_template('fu/report_bottom', { 'HIDDEN'  => \@hidden_report_params }),

Auch abrufbar als: Unified diff