Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 4b48d335

Von Moritz Bunkus vor mehr als 16 Jahren hinzugefügt

  • ID 4b48d335511464f7a37b92e6d5c0cbed616fe48d
  • Vorgänger 44244279
  • Nachfolger 1eaf4978

Buchungsjournal auf- und absteigend sortierbar gemacht.

Unterschiede anzeigen:

SL/GL.pm
323 323

  
324 324
  my $false = ($myconfig->{dbdriver} eq 'Pg') ? FALSE: q|'0'|;
325 325

  
326
  my $sortorder;
327

  
328
  if ($form->{sort}) {
329
    $form->{sort} =~ s/[^a-zA-Z_]//g;
330
    $sortorder = $form->{sort} . ",";
326
  my %sort_columns =  (
327
    'id'           => [ qw(id)                   ],
328
    'transdate'    => [ qw(transdate id)         ],
329
    'reference'    => [ qw(lower_reference id)   ],
330
    'source'       => [ qw(lower_source id)      ],
331
    'description'  => [ qw(lower_description id) ],
332
    'accno'        => [ qw(accno transdate id)   ],
333
    );
334
  my %lowered_columns =  (
335
    'reference'       => { 'gl' => 'g.reference',   'arap' => 'a.invnumber', },
336
    'source'          => { 'gl' => 'ac.source',     'arap' => 'ac.source',   },
337
    'description'     => { 'gl' => 'g.description', 'arap' => 'ct.name',     },
338
    );
339

  
340
  my $sortdir   = !defined $form->{sortdir} ? 'ASC' : $form->{sortdir} ? 'ASC' : 'DESC';
341
  my $sortkey   = $sort_columns{$form->{sort}} ? $form->{sort} : 'transdate';
342
  my $sortorder = join ', ', map { "$_ $sortdir" } @{ $sort_columns{$sortkey} };
343

  
344
  my %columns_for_sorting = ( 'gl' => '', 'arap' => '', );
345
  foreach my $spec (@{ $sort_columns{$sortkey} }) {
346
    next if ($spec !~ m/^lower_(.*)$/);
347

  
348
    my $column = $1;
349
    map { $columns_for_sorting{$_} .= sprintf(', lower(%s) AS lower_%s', $lowered_columns{$column}->{$_}, $column) } qw(gl arap);
331 350
  }
332 351

  
333 352
  my $query =
......
336 355
        g.description, ac.transdate, ac.source, ac.trans_id,
337 356
        ac.amount, c.accno, g.notes, t.chart_id, ac.oid
338 357
        $project_columns
358
        $columns_for_sorting{gl}
339 359
      FROM gl g, acc_trans ac $project_join, chart c
340 360
      LEFT JOIN tax t ON (t.chart_id = c.id)
341 361
      WHERE $glwhere
......
348 368
        ct.name, ac.transdate, ac.source, ac.trans_id,
349 369
        ac.amount, c.accno, a.notes, t.chart_id, ac.oid
350 370
        $project_columns
371
        $columns_for_sorting{arap}
351 372
      FROM ar a, acc_trans ac $project_join, customer ct, chart c
352 373
      LEFT JOIN tax t ON (t.chart_id=c.id)
353 374
      WHERE $arwhere
......
361 382
        ct.name, ac.transdate, ac.source, ac.trans_id,
362 383
        ac.amount, c.accno, a.notes, t.chart_id, ac.oid
363 384
        $project_columns
385
        $columns_for_sorting{arap}
364 386
      FROM ap a, acc_trans ac $project_join, vendor ct, chart c
365 387
      LEFT JOIN tax t ON (t.chart_id=c.id)
366 388
      WHERE $apwhere
......
368 390
        AND (a.vendor_id = ct.id)
369 391
        AND (a.id = ac.trans_id)
370 392

  
371
      ORDER BY $sortorder transdate, trans_id, acoid, taxkey DESC|;
393
      ORDER BY $sortorder, acoid $sortdir|;
372 394

  
373 395
  my @values = (@glvalues, @arvalues, @apvalues);
374 396

  

Auch abrufbar als: Unified diff