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

  
bin/mozilla/gl.pl
421 421

  
422 422
  $auth->assert('general_ledger');
423 423

  
424
  $form->{sort} ||= "transdate";
424
  report_generator_set_default_sort('transdate', 1);
425 425

  
426 426
  GL->all_transactions(\%myconfig, \%$form);
427 427

  
......
468 468
  }
469 469

  
470 470

  
471
  my $callback = build_std_url('action=generate_report', @hidden_variables);
471
  my $callback = build_std_url('action=generate_report', grep { $form->{$_} } @hidden_variables);
472 472

  
473 473
  $form->{l_credit_accno}     = 'Y';
474 474
  $form->{l_debit_accno}      = 'Y';
......
497 497
    'projectnumbers'   => { 'text' => $locale->text('Project Numbers'), },
498 498
  );
499 499

  
500
  map { $column_defs{$_}->{link}    = $callback . "&sort=${_}" }  qw(id transdate reference source description);
501
  map { $column_defs{$_}->{link}    = $callback . "&sort=accno" } qw(debit_accno credit_accno debit_tax_accno credit_tax_accno debit_tax credit_tax);
500
  foreach my $name (qw(id transdate reference source description debit_accno credit_accno debit_tax_accno credit_tax_accno)) {
501
    my $sortname                = $name =~ m/accno/ ? 'accno' : $name;
502
    my $sortdir                 = $sortname eq $name ? 1 - $form->{sortdir} : $form->{sortdir};
503
    $column_defs{$name}->{link} = $callback . "&sort=$sortname&sortdir=$sortdir";
504
  }
505

  
502 506
  map { $column_defs{$_}->{visible} = $form->{"l_${_}"} ? 1 : 0 } @columns;
503 507
  map { $column_defs{$_}->{visible} = 0 } qw(debit_accno credit_accno debit_tax_accno credit_tax_accno) if $form->{accno};
504 508

  
505 509
  my %column_alignment;
506
  map { $column_alignment{$_} = 'right' }  qw(balance id debit credit debit_tax credit_tax);
507
  map { $column_alignment{$_} = 'center' } qw(transdate reference description source notes debit_accno credit_accno debit_tax_accno credit_tax_accno);
510
  map { $column_alignment{$_}     = 'right'  } qw(balance id debit credit debit_tax credit_tax);
511
  map { $column_alignment{$_}     = 'center' } qw(transdate reference description source notes debit_accno credit_accno debit_tax_accno credit_tax_accno);
512
  map { $column_defs{$_}->{align} = $column_alignment{$_} } keys %column_alignment;
508 513

  
509 514
  my $report = SL::ReportGenerator->new(\%myconfig, $form);
510 515

  
......
513 518

  
514 519
  $report->set_export_options('generate_report', @hidden_variables);
515 520

  
516
  $report->set_sort_indicator($form->{sort}, 1);
521
  $report->set_sort_indicator($form->{sort} eq 'accno' ? 'debit_accno' : $form->{sort}, $form->{sortdir});
517 522

  
518 523
  $report->set_options('top_info_text'        => join("\n", @options),
519 524
                       'output_format'        => 'HTML',
......
523 528
  $report->set_options_from_form();
524 529

  
525 530
  # add sort to callback
526
  $form->{callback} = "$callback&sort=" . E($form->{sort});
531
  $form->{callback} = "$callback&sort=" . E($form->{sort}) . "&sortdir=" . E($form->{sortdir});
527 532

  
528 533
  $form->{balance} *= $ml;
529 534

  

Auch abrufbar als: Unified diff