Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 4000272e

Von Jan Büren vor etwa 13 Jahren hinzugefügt

  • ID 4000272e5ea3a605f3625934f07033472832de49
  • Vorgänger 10af2ad6
  • Nachfolger 3286128e

Buchungsjournal: Bearbeiter und Buchungsdatum

- Buchungsjournal: Auswahl nach Bearbeiter einschränken

- Sortierung: Auswahl ob Buchungsjournal nach Buchungsdatum oder
Rechnungsdatum sortiert wird (Buchungsdatum ist Default)

- Datumsauswahl von-bis berücksichtigt ebenfalls Auswahl
Buchungsdatum/Rechnungsdatum

Unterschiede anzeigen:

SL/GL.pm
231 231
    push(@apvalues, '%' . $form->{source} . '%');
232 232
  }
233 233

  
234
  # default Datumseinschränkung falls nicht oder falsch übergeben (sollte nie passieren)
235
  $form->{datesort} = 'transdate' unless $form->{datesort} =~ /^(transdate|gldate)$/;
236

  
234 237
  if ($form->{datefrom}) {
235
    $glwhere .= " AND ac.transdate >= ?";
236
    $arwhere .= " AND ac.transdate >= ?";
237
    $apwhere .= " AND ac.transdate >= ?";
238
    $glwhere .= " AND ac.$form->{datesort} >= ?";
239
    $arwhere .= " AND ac.$form->{datesort} >= ?";
240
    $apwhere .= " AND ac.$form->{datesort} >= ?";
238 241
    push(@glvalues, $form->{datefrom});
239 242
    push(@arvalues, $form->{datefrom});
240 243
    push(@apvalues, $form->{datefrom});
241 244
  }
242 245

  
243 246
  if ($form->{dateto}) {
244
    $glwhere .= " AND ac.transdate <= ?";
245
    $arwhere .= " AND ac.transdate <= ?";
246
    $apwhere .= " AND ac.transdate <= ?";
247
    $glwhere .= " AND ac.$form->{datesort} <= ?";
248
    $arwhere .= " AND ac.$form->{datesort} <= ?";
249
    $apwhere .= " AND ac.$form->{datesort} <= ?";
247 250
    push(@glvalues, $form->{dateto});
248 251
    push(@arvalues, $form->{dateto});
249 252
    push(@apvalues, $form->{dateto});
......
257 260
    push(@arvalues, '%' . $form->{description} . '%');
258 261
    push(@apvalues, '%' . $form->{description} . '%');
259 262
  }
263
 
264
  if ($form->{employee} =~ /--/) {
265
    ($form->{employee_id},$form->{employee_name}) = split(/--/,$form->{employee});
266
    $query .= " AND o.employee_id = ?";
267
    push @values, conv_i($form->{employee_id});
268
  #if ($form->{employee_id}) {
269
    $glwhere .= " AND g.employee_id = ? ";
270
    $arwhere .= " AND a.employee_id = ? ";
271
    $apwhere .= " AND a.employee_id = ? ";
272
    push(@glvalues, conv_i($form->{employee_id}));
273
    push(@arvalues, conv_i($form->{employee_id}));
274
    push(@apvalues, conv_i($form->{employee_id}));
275
  }
260 276

  
261 277
  if ($form->{notes}) {
262 278
    $glwhere .= " AND g.notes ILIKE ?";
......
312 328
        qq|SELECT SUM(ac.amount)
313 329
           FROM acc_trans ac
314 330
           LEFT JOIN chart c ON (ac.chart_id = c.id)
315
           WHERE (c.accno = ?) AND (ac.transdate < ?)|;
331
           WHERE (c.accno = ?) AND (ac.$form->{datesort} < ?)|;
316 332
      ($form->{balance}) = selectrow_query($form, $dbh, $query, $form->{accno}, conv_date($form->{datefrom}));
317 333
    }
318 334
  }
......
322 338
  my %sort_columns =  (
323 339
    'id'           => [ qw(id)                   ],
324 340
    'transdate'    => [ qw(transdate id)         ],
341
    'gldate'       => [ qw(gldate id)         ],
325 342
    'reference'    => [ qw(lower_reference id)   ],
326 343
    'description'  => [ qw(lower_description id) ],
327 344
    'accno'        => [ qw(accno transdate id)   ],
......
331 348
    'source'          => { 'gl' => 'ac.source',     'arap' => 'ac.source',   },
332 349
    'description'     => { 'gl' => 'g.description', 'arap' => 'ct.name',     },
333 350
    );
334

  
351
  
352
  # sortdir = sort direction (ascending or descending)
335 353
  my $sortdir   = !defined $form->{sortdir} ? 'ASC' : $form->{sortdir} ? 'ASC' : 'DESC';
336
  my $sortkey   = $sort_columns{$form->{sort}} ? $form->{sort} : 'transdate';
354
  my $sortkey   = $sort_columns{$form->{sort}} ? $form->{sort} : $form->{datesort};  # default used to be transdate
337 355
  my $sortorder = join ', ', map { "$_ $sortdir" } @{ $sort_columns{$sortkey} };
338 356

  
339 357
  my %columns_for_sorting = ( 'gl' => '', 'arap' => '', );
......
347 365
  $query =
348 366
    qq|SELECT
349 367
        ac.acc_trans_id, g.id, 'gl' AS type, $false AS invoice, g.reference, ac.taxkey, c.link,
350
        g.description, ac.transdate, ac.source, ac.trans_id,
351
        ac.amount, c.accno, g.notes, t.chart_id
368
        g.description, ac.transdate, ac.gldate, ac.source, ac.trans_id,
369
        ac.amount, c.accno, g.notes, t.chart_id,
370
        CASE WHEN (COALESCE(e.name, '') = '') THEN e.login ELSE e.name END AS employee
352 371
        $project_columns
353 372
        $columns_for_sorting{gl}
354 373
      FROM gl g, acc_trans ac $project_join, chart c
......
360 379
      UNION
361 380

  
362 381
      SELECT ac.acc_trans_id, a.id, 'ar' AS type, a.invoice, a.invnumber, ac.taxkey, c.link,
363
        ct.name, ac.transdate, ac.source, ac.trans_id,
364
        ac.amount, c.accno, a.notes, t.chart_id
382
        ct.name, ac.transdate, ac.gldate, ac.source, ac.trans_id,
383
        ac.amount, c.accno, a.notes, t.chart_id,
384
        CASE WHEN (COALESCE(e.name, '') = '') THEN e.login ELSE e.name END AS employee
365 385
        $project_columns
366 386
        $columns_for_sorting{arap}
367 387
      FROM ar a, acc_trans ac $project_join, customer ct, chart c
......
374 394
      UNION
375 395

  
376 396
      SELECT ac.acc_trans_id, a.id, 'ap' AS type, a.invoice, a.invnumber, ac.taxkey, c.link,
377
        ct.name, ac.transdate, ac.source, ac.trans_id,
378
        ac.amount, c.accno, a.notes, t.chart_id
397
        ct.name, ac.transdate, ac.gldate, ac.source, ac.trans_id,
398
        ac.amount, c.accno, a.notes, t.chart_id,
399
        CASE WHEN (COALESCE(e.name, '') = '') THEN e.login ELSE e.name END AS employee
379 400
        $project_columns
380 401
        $columns_for_sorting{arap}
381 402
      FROM ap a, acc_trans ac $project_join, vendor ct, chart c
......
386 407
        AND (a.id = ac.trans_id)
387 408

  
388 409
      ORDER BY $sortorder, acc_trans_id $sortdir|;
410
#      ORDER BY gldate DESC, id DESC, acc_trans_id DESC
389 411

  
390 412
  my @values = (@glvalues, @arvalues, @apvalues);
391 413

  
bin/mozilla/gl.pl
242 242
| if $form->{selectdepartment};
243 243

  
244 244
  $form->get_lists("projects" => { "key" => "ALL_PROJECTS",
245
                                   "all" => 1 });
245
                                   "all" => 1},
246
                                   "employees"    => "ALL_EMPLOYEES" );
246 247

  
247 248
  my %project_labels = ();
248 249
  my @project_values = ("");
......
256 257
                         '-values' => \@project_values,
257 258
                         '-labels' => \%project_labels));
258 259

  
260
  my %employee_labels = ();
261
  my @employee_values = ("");
262
  foreach my $item (@{ $form->{"ALL_EMPLOYEES"} }) {
263
    # value in Form "1234--Name" ?bergeben
264
    my $id = "$item->{'id'}--$item->{'name'}";
265
    push(@employee_values, "$id");
266
    $employee_labels{$id} = $item->{"name"};
267
  }
268

  
269
  my $employeenumber =
270
    NTI($cgi->popup_menu('-name' => "employee",
271
                         '-values' => \@employee_values,
272
                         '-labels' => \%employee_labels));
273

  
259 274
  # use JavaScript Calendar or not
260 275
  $form->{jsscript} = 1;
261 276
  my $jsscript = "";
......
296 311

  
297 312
<form method=post action=gl.pl>
298 313

  
299
<input type=hidden name=sort value=transdate>
314
<input type=hidden name=sort value=datesort>
300 315

  
301 316
<table width=100%>
302 317
  <tr>
......
329 344
        </tr>
330 345
        <tr>
331 346
          <th align=right>| . $locale->text('From') . qq|</th>
347
 <tr>
348
    <th align=right>| . $locale->text('Employee') . qq|</th>
349
    <td colspan=3>$employeenumber</td>
350
  </tr>
351
  <tr>
352
    <th align=right>| . $locale->text('Date Sorting') . qq|</th>
353
    <td colspan=3>
354
    <input name=datesort class=radio type=radio value=gldate checked>&nbsp;| . $locale->text('Booking Date') . qq|
355
    <input name=datesort class=radio type=radio value=transdate>&nbsp;| . $locale->text('Invoice Date') . qq|
356
    </td>
357
  </tr>
358
  <tr>
359
    <th align=right>| . $locale->text('From') . qq|</th>
332 360
          $button1
333 361
          <th align=right>| . $locale->text('To (time)') . qq|</th>
334 362
          $button2
......
357 385
                    <td align=right><input name="l_id" class=checkbox type=checkbox value=Y></td>
358 386
                    <td>| . $locale->text('ID') . qq|</td>
359 387
                    <td align=right><input name="l_transdate" class=checkbox type=checkbox value=Y checked></td>
360
                    <td>| . $locale->text('Date') . qq|</td>
388
                    <td>| . $locale->text('Invoice Date') . qq|</td>
389
                    <td align=right><input name="l_gldate" class=checkbox type=checkbox value=Y checked></td>
390
                    <td>| . $locale->text('Booking Date') . qq|</td>
361 391
                    <td align=right><input name="l_reference" class=checkbox type=checkbox value=Y checked></td>
362 392
                    <td>| . $locale->text('Reference') . qq|</td>
363 393
                    <td align=right><input name="l_description" class=checkbox type=checkbox value=Y checked></td>
......
380 410
                    <td>| . $locale->text('Subtotal') . qq|</td>
381 411
                    <td align=right><input name="l_projectnumbers" class=checkbox type=checkbox value=Y></td>
382 412
                    <td>| . $locale->text('Project Number') . qq|</td>
413
                    <td align=right><input name="l_employee" class=checkbox type=checkbox value=Y></td>
414
                    <td>| . $locale->text('Employee') . qq|</td>
383 415
                  </tr>
384 416
                </table>
385 417
              </tr>
......
436 468
  my %myconfig = %main::myconfig;
437 469
  my $locale   = $main::locale;
438 470

  
439
  report_generator_set_default_sort('transdate', 1);
471
  # generate_report wird beim ersten Aufruf per Weiter-Knopf und POST mit der hidden Variablen sort mit Wert "datesort" (fr?her "transdate" als Defaultsortiervariable) ?bertragen
472

  
473
  # <form method=post action=gl.pl>
474
  # <input type=hidden name=sort value=datesort>    # form->{sort} setzen
475
  # <input type=hidden name=nextsub value=generate_report>
476

  
477
  # anhand von neuer Variable datesort wird jetzt $form->{sort} auf transdate oder gldate gesetzt
478
  # damit ist die Hidden Variable "sort" wahrscheinlich sogar ?berfl?ssig
479

  
480
  # ?ndert man die Sortierreihenfolge per Klick auf eine der ?berschriften wird die Variable "sort" per GET ?bergeben, z.B. id,transdate, gldate, ...
481
  # gl.pl?action=generate_report&employee=18383--Jan%20B%c3%bcren&datesort=transdate&category=X&l_transdate=Y&l_gldate=Y&l_id=Y&l_reference=Y&l_description=Y&l_source=Y&l_debit=Y&l_credit=Y&sort=gldate&sortdir=0
482

  
483
  if ( $form->{sort} eq 'datesort' ) {   # sollte bei einem Post (Aufruf aus Suchmaske) immer wahr sein
484
      # je nachdem ob in Suchmaske "transdate" oder "gldate" ausgesucht wurde erstes Suchergebnis entsprechend sortieren
485
      $form->{sort} = $form->{datesort};
486
  };
487

  
488
  # was passiert hier?
489
  report_generator_set_default_sort("$form->{datesort}", 1);
490
#  report_generator_set_default_sort('transdate', 1);
440 491

  
441 492
  GL->all_transactions(\%myconfig, \%$form);
442 493

  
......
457 508
  my $ml = ($form->{ml} =~ /(A|E|Q)/) ? -1 : 1;
458 509

  
459 510
  my @columns = qw(
460
    transdate      id               reference      description
461
    notes          source           debit          debit_accno
511
    gldate         transdate        id             reference      description
512
    notes          source           debit          debit_accno   
462 513
    credit         credit_accno     debit_tax      debit_tax_accno
463 514
    credit_tax     credit_tax_accno projectnumbers balance
464 515
  );
465 516

  
466
  my @hidden_variables = qw(accno source reference department description notes project_id datefrom dateto category l_subtotal);
517
  # add employee here, so that variable is still known and passed in url when choosing a different sort order in resulting table
518
  my @hidden_variables = qw(accno source reference department description notes project_id datefrom dateto employee datesort category l_subtotal);
467 519
  push @hidden_variables, map { "l_${_}" } @columns;
520
  foreach ( @hidden_variables ) {
521
      print URL "$_\n";
522
  };
468 523

  
469 524
  my (@options, @date_options);
470 525
  push @options,      $locale->text('Account')     . " : $form->{accno} $form->{account_description}" if ($form->{accno});
......
472 527
  push @options,      $locale->text('Reference')   . " : $form->{reference}"                          if ($form->{reference});
473 528
  push @options,      $locale->text('Description') . " : $form->{description}"                        if ($form->{description});
474 529
  push @options,      $locale->text('Notes')       . " : $form->{notes}"                              if ($form->{notes});
475

  
530
  push @options,      $locale->text('Employee')       . " : $form->{employee_name}"                              if ($form->{employee_name});
531
  my $datesorttext = $form->{datesort} eq 'transdate' ? $locale->text('Invoice Date') :  $locale->text('Booking Date');
532
  push @date_options,      "$datesorttext"                              if ($form->{datesort} and ($form->{datefrom} or $form->{dateto}));
476 533
  push @date_options, $locale->text('From'), $locale->date(\%myconfig, $form->{datefrom}, 1)          if ($form->{datefrom});
477 534
  push @date_options, $locale->text('Bis'),  $locale->date(\%myconfig, $form->{dateto},   1)          if ($form->{dateto});
478 535
  push @options,      join(' ', @date_options)                                                        if (scalar @date_options);
......
484 541

  
485 542

  
486 543
  my $callback = build_std_url('action=generate_report', grep { $form->{$_} } @hidden_variables);
544
  print URL $callback;
545
  close URL;
487 546

  
488 547
  $form->{l_credit_accno}     = 'Y';
489 548
  $form->{l_debit_accno}      = 'Y';
490 549
  $form->{l_credit_tax}       = 'Y';
491 550
  $form->{l_debit_tax}        = 'Y';
551
#  $form->{l_gldate}           = 'Y';  # Spalte mit gldate immer anzeigen
492 552
  $form->{l_credit_tax_accno} = 'Y';
553
  $form->{l_datesort} = 'Y';
493 554
  $form->{l_debit_tax_accno}  = 'Y';
494 555
  $form->{l_balance}          = $form->{accno} ? 'Y' : '';
495 556

  
496 557
  my %column_defs = (
497 558
    'id'               => { 'text' => $locale->text('ID'), },
498
    'transdate'        => { 'text' => $locale->text('Date'), },
559
    'transdate'        => { 'text' => $locale->text('Invoice Date'), },
560
    'gldate'           => { 'text' => $locale->text('Booking Date'), },
499 561
    'reference'        => { 'text' => $locale->text('Reference'), },
500 562
    'source'           => { 'text' => $locale->text('Source'), },
501 563
    'description'      => { 'text' => $locale->text('Description'), },
......
510 572
    'credit_tax_accno' => { 'text' => $locale->text('Credit Tax Account'), },
511 573
    'balance'          => { 'text' => $locale->text('Balance'), },
512 574
    'projectnumbers'   => { 'text' => $locale->text('Project Numbers'), },
575
    'employee'         => { 'text' => $locale->text('Employee'), },
513 576
  );
514 577

  
515
  foreach my $name (qw(id transdate reference description debit_accno credit_accno debit_tax_accno credit_tax_accno)) {
578
  foreach my $name (qw(id transdate gldate reference description debit_accno credit_accno debit_tax_accno credit_tax_accno)) {
516 579
    my $sortname                = $name =~ m/accno/ ? 'accno' : $name;
517 580
    my $sortdir                 = $sortname eq $form->{sort} ? 1 - $form->{sortdir} : $form->{sortdir};
518 581
    $column_defs{$name}->{link} = $callback . "&sort=$sortname&sortdir=$sortdir";
......
523 586

  
524 587
  my %column_alignment;
525 588
  map { $column_alignment{$_}     = 'right'  } qw(balance id debit credit debit_tax credit_tax balance);
526
  map { $column_alignment{$_}     = 'center' } qw(reference debit_accno credit_accno debit_tax_accno credit_tax_accno);
589
  map { $column_alignment{$_}     = 'center' } qw(transdate gldate reference debit_accno credit_accno debit_tax_accno credit_tax_accno);
527 590
  map { $column_alignment{$_}     = 'left' } qw(description source notes);
528 591
  map { $column_defs{$_}->{align} = $column_alignment{$_} } keys %column_alignment;
529 592

  
......
597 660

  
598 661
    map { $row->{$_}->{data} = $ref->{$_} } qw(id reference description notes);
599 662

  
600
    map { $row->{$_}->{data} = \@{ $rows{$_} }; } qw(transdate debit credit debit_accno credit_accno debit_tax_accno credit_tax_accno source);
663
    map { $row->{$_}->{data} = \@{ $rows{$_} }; } qw(transdate gldate debit credit debit_accno credit_accno debit_tax_accno credit_tax_accno source);
601 664

  
602 665
    foreach my $col (qw(debit_accno credit_accno debit_tax_accno credit_tax_accno)) {
603 666
      $row->{$col}->{link} = [ map { "${callback}&accno=" . E($_) } @{ $rows{$col} } ];

Auch abrufbar als: Unified diff