Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 94e596e5

Von Moritz Bunkus vor mehr als 16 Jahren hinzugefügt

  • ID 94e596e55cef6b9ef9b80b5a4dba8204e0c29c9f
  • Vorgänger f6a2cdd5
  • Nachfolger bbc63419

Berichte über Zahlungsein- und ausgänge auf und absteigend sortierbar gemacht.

Unterschiede anzeigen:

SL/RP.pm
1632 1632
    $where .= " AND (ac.memo ILIKE " . $dbh->quote('%' . $form->{memo} . '%') . ") ";
1633 1633
  }
1634 1634

  
1635
  my $sortorder = join(', ', qw(name invnumber ordnumber transdate source));
1636
  $sortorder = $form->{sort} if ($form->{sort} && grep({ $_ eq $form->{sort} } qw(transdate invnumber name source memo)));
1635
  my %sort_columns =  (
1636
    'transdate'    => [ qw(transdate lower_invnumber lower_name) ],
1637
    'invnumber'    => [ qw(lower_invnumber lower_name transdate) ],
1638
    'name'         => [ qw(lower_name transdate)                 ],
1639
    'source'       => [ qw(lower_source)                         ],
1640
    'memo'         => [ qw(lower_memo)                           ],
1641
    );
1642
  my %lowered_columns =  (
1643
    'invnumber'       => { 'gl' => 'g.reference',   'arap' => 'a.invnumber', },
1644
    'memo'            => { 'gl' => 'ac.memo',       'arap' => 'ac.memo',     },
1645
    'source'          => { 'gl' => 'ac.source',     'arap' => 'ac.source',   },
1646
    'name'            => { 'gl' => 'g.description', 'arap' => 'c.name',      },
1647
    );
1648

  
1649
  my $sortdir   = !defined $form->{sortdir} ? 'ASC' : $form->{sortdir} ? 'ASC' : 'DESC';
1650
  my $sortkey   = $sort_columns{$form->{sort}} ? $form->{sort} : 'transdate';
1651
  my $sortorder = join ', ', map { "$_ $sortdir" } @{ $sort_columns{$sortkey} };
1652

  
1653

  
1654
  my %columns_for_sorting = ( 'gl' => '', 'arap' => '', );
1655
  foreach my $spec (@{ $sort_columns{$sortkey} }) {
1656
    next if ($spec !~ m/^lower_(.*)$/);
1657

  
1658
    my $column = $1;
1659
    map { $columns_for_sorting{$_} .= sprintf(', lower(%s) AS lower_%s', $lowered_columns{$column}->{$_}, $column) } qw(gl arap);
1660
  }
1637 1661

  
1638 1662
  $query = qq|SELECT id, accno, description FROM chart WHERE accno = ?|;
1639 1663
  my $sth = prepare_query($form, $dbh, $query);
......
1642 1666
      qq|SELECT c.name, a.invnumber, a.ordnumber,
1643 1667
           ac.transdate, ac.amount * $ml AS paid, ac.source,
1644 1668
           a.invoice, a.id, ac.memo, '${arap}' AS module
1669
           $columns_for_sorting{arap}
1645 1670
         FROM acc_trans ac
1646 1671
         JOIN $arap a ON (ac.trans_id = a.id)
1647 1672
         JOIN $table c ON (c.id = a.${table}_id)
......
1655 1680
         SELECT g.description, g.reference, NULL AS ordnumber,
1656 1681
           ac.transdate, ac.amount * $ml AS paid, ac.source,
1657 1682
           '0' as invoice, g.id, ac.memo, 'gl' AS module
1683
           $columns_for_sorting{gl}
1658 1684
         FROM acc_trans ac
1659 1685
         JOIN gl g ON (g.id = ac.trans_id)
1660 1686
         $dpt_join

Auch abrufbar als: Unified diff