#
#======================================================================
+use utf8;
+use strict;
+
use POSIX qw(strftime);
use List::Util qw(sum);
require "bin/mozilla/drafts.pl";
require "bin/mozilla/reportgenerator.pl";
-use strict;
-
# this is for our long dates
# $locale->text('January')
# $locale->text('February')
| if $form->{selectdepartment};
$form->get_lists("projects" => { "key" => "ALL_PROJECTS",
- "all" => 1 });
+ "all" => 1},
+ "employees" => "ALL_EMPLOYEES" );
my %project_labels = ();
my @project_values = ("");
'-values' => \@project_values,
'-labels' => \%project_labels));
+ my %employee_labels = ();
+ my @employee_values = ("");
+ foreach my $item (@{ $form->{"ALL_EMPLOYEES"} }) {
+ # value in Form "1234--Name" übergeben
+ my $id = "$item->{'id'}--$item->{'name'}";
+ push(@employee_values, "$id");
+ $employee_labels{$id} = $item->{"name"};
+ }
+
+ my $employeenumber =
+ NTI($cgi->popup_menu('-name' => "employee",
+ '-values' => \@employee_values,
+ '-labels' => \%employee_labels));
+
# use JavaScript Calendar or not
$form->{jsscript} = 1;
my $jsscript = "";
<form method=post action=gl.pl>
-<input type=hidden name=sort value=transdate>
+<input type=hidden name=sort value=datesort>
<table width=100%>
<tr>
$department
<tr>
<th align=right>| . $locale->text('Description') . qq|</th>
- <td colspan=3><input name=description size=40></td>
+ <td><input name=description size=40></td>
+ <th align=right>| . $locale->text('Account Number') . qq|</th>
+ <td><input name=accno size=20></td>
</tr>
<tr>
<th align=right>| . $locale->text('Notes') . qq|</th>
</tr>
<tr>
<th align=right>| . $locale->text('From') . qq|</th>
+ <tr>
+ <th align=right>| . $locale->text('Employee') . qq|</th>
+ <td colspan=3>$employeenumber</td>
+ </tr>
+ <tr>
+ <th align=right>| . $locale->text('Date Sorting') . qq|</th>
+ <td colspan=3>
+ <input name=datesort class=radio type=radio value=gldate checked> | . $locale->text('Booking Date') . qq|
+ <input name=datesort class=radio type=radio value=transdate> | . $locale->text('Invoice Date') . qq|
+ </td>
+ </tr>
+ <tr>
+ <th align=right>| . $locale->text('From') . qq|</th>
$button1
<th align=right>| . $locale->text('To (time)') . qq|</th>
$button2
<td align=right><input name="l_id" class=checkbox type=checkbox value=Y></td>
<td>| . $locale->text('ID') . qq|</td>
<td align=right><input name="l_transdate" class=checkbox type=checkbox value=Y checked></td>
- <td>| . $locale->text('Date') . qq|</td>
+ <td>| . $locale->text('Invoice Date') . qq|</td>
+ <td align=right><input name="l_gldate" class=checkbox type=checkbox value=Y checked></td>
+ <td>| . $locale->text('Booking Date') . qq|</td>
<td align=right><input name="l_reference" class=checkbox type=checkbox value=Y checked></td>
<td>| . $locale->text('Reference') . qq|</td>
<td align=right><input name="l_description" class=checkbox type=checkbox value=Y checked></td>
<td>| . $locale->text('Subtotal') . qq|</td>
<td align=right><input name="l_projectnumbers" class=checkbox type=checkbox value=Y></td>
<td>| . $locale->text('Project Number') . qq|</td>
+ <td align=right><input name="l_employee" class=checkbox type=checkbox value=Y></td>
+ <td>| . $locale->text('Employee') . qq|</td>
</tr>
</table>
</tr>
my %myconfig = %main::myconfig;
my $locale = $main::locale;
- report_generator_set_default_sort('transdate', 1);
+ # 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
+
+ # <form method=post action=gl.pl>
+ # <input type=hidden name=sort value=datesort> # form->{sort} setzen
+ # <input type=hidden name=nextsub value=generate_report>
+
+ # anhand von neuer Variable datesort wird jetzt $form->{sort} auf transdate oder gldate gesetzt
+ # damit ist die Hidden Variable "sort" wahrscheinlich sogar überflüssig
+
+ # ändert man die Sortierreihenfolge per Klick auf eine der Überschriften wird die Variable "sort" per GET übergeben, z.B. id,transdate, gldate, ...
+ # 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
+
+ if ( $form->{sort} eq 'datesort' ) { # sollte bei einem Post (Aufruf aus Suchmaske) immer wahr sein
+ # je nachdem ob in Suchmaske "transdate" oder "gldate" ausgesucht wurde erstes Suchergebnis entsprechend sortieren
+ $form->{sort} = $form->{datesort};
+ };
+
+ # was passiert hier?
+ report_generator_set_default_sort("$form->{datesort}", 1);
+# report_generator_set_default_sort('transdate', 1);
GL->all_transactions(\%myconfig, \%$form);
my $ml = ($form->{ml} =~ /(A|E|Q)/) ? -1 : 1;
my @columns = qw(
- transdate id reference description
- notes source debit debit_accno
+ gldate transdate id reference description
+ notes source debit debit_accno
credit credit_accno debit_tax debit_tax_accno
- credit_tax credit_tax_accno projectnumbers balance
+ credit_tax credit_tax_accno projectnumbers balance employee
);
- my @hidden_variables = qw(accno source reference department description notes project_id datefrom dateto category l_subtotal);
+ # add employee here, so that variable is still known and passed in url when choosing a different sort order in resulting table
+ my @hidden_variables = qw(accno source reference department description notes project_id datefrom dateto employee datesort category l_subtotal);
push @hidden_variables, map { "l_${_}" } @columns;
+ foreach ( @hidden_variables ) {
+ print URL "$_\n";
+ };
my (@options, @date_options);
push @options, $locale->text('Account') . " : $form->{accno} $form->{account_description}" if ($form->{accno});
push @options, $locale->text('Reference') . " : $form->{reference}" if ($form->{reference});
push @options, $locale->text('Description') . " : $form->{description}" if ($form->{description});
push @options, $locale->text('Notes') . " : $form->{notes}" if ($form->{notes});
-
+ push @options, $locale->text('Employee') . " : $form->{employee_name}" if ($form->{employee_name});
+ my $datesorttext = $form->{datesort} eq 'transdate' ? $locale->text('Invoice Date') : $locale->text('Booking Date');
+ push @date_options, "$datesorttext" if ($form->{datesort} and ($form->{datefrom} or $form->{dateto}));
push @date_options, $locale->text('From'), $locale->date(\%myconfig, $form->{datefrom}, 1) if ($form->{datefrom});
push @date_options, $locale->text('Bis'), $locale->date(\%myconfig, $form->{dateto}, 1) if ($form->{dateto});
push @options, join(' ', @date_options) if (scalar @date_options);
my $callback = build_std_url('action=generate_report', grep { $form->{$_} } @hidden_variables);
+ print URL $callback;
+ close URL;
$form->{l_credit_accno} = 'Y';
$form->{l_debit_accno} = 'Y';
$form->{l_credit_tax} = 'Y';
$form->{l_debit_tax} = 'Y';
+# $form->{l_gldate} = 'Y'; # Spalte mit gldate immer anzeigen
$form->{l_credit_tax_accno} = 'Y';
+ $form->{l_datesort} = 'Y';
$form->{l_debit_tax_accno} = 'Y';
$form->{l_balance} = $form->{accno} ? 'Y' : '';
my %column_defs = (
'id' => { 'text' => $locale->text('ID'), },
- 'transdate' => { 'text' => $locale->text('Date'), },
+ 'transdate' => { 'text' => $locale->text('Invoice Date'), },
+ 'gldate' => { 'text' => $locale->text('Booking Date'), },
'reference' => { 'text' => $locale->text('Reference'), },
'source' => { 'text' => $locale->text('Source'), },
'description' => { 'text' => $locale->text('Description'), },
'credit_tax_accno' => { 'text' => $locale->text('Credit Tax Account'), },
'balance' => { 'text' => $locale->text('Balance'), },
'projectnumbers' => { 'text' => $locale->text('Project Numbers'), },
+ 'employee' => { 'text' => $locale->text('Employee'), },
);
- foreach my $name (qw(id transdate reference description debit_accno credit_accno debit_tax_accno credit_tax_accno)) {
+ foreach my $name (qw(id transdate gldate reference description debit_accno credit_accno debit_tax_accno credit_tax_accno)) {
my $sortname = $name =~ m/accno/ ? 'accno' : $name;
my $sortdir = $sortname eq $form->{sort} ? 1 - $form->{sortdir} : $form->{sortdir};
$column_defs{$name}->{link} = $callback . "&sort=$sortname&sortdir=$sortdir";
my %column_alignment;
map { $column_alignment{$_} = 'right' } qw(balance id debit credit debit_tax credit_tax balance);
- map { $column_alignment{$_} = 'center' } qw(reference debit_accno credit_accno debit_tax_accno credit_tax_accno);
+ map { $column_alignment{$_} = 'center' } qw(transdate gldate reference debit_accno credit_accno debit_tax_accno credit_tax_accno);
map { $column_alignment{$_} = 'left' } qw(description source notes);
map { $column_defs{$_}->{align} = $column_alignment{$_} } keys %column_alignment;
'attachment_basename' => $locale->text('general_ledger_list') . strftime('_%Y%m%d', localtime time),
);
$report->set_options_from_form();
+ $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
# add sort to callback
$form->{callback} = "$callback&sort=" . E($form->{sort}) . "&sortdir=" . E($form->{sortdir});
$row->{balance}->{data} = $data;
$row->{projectnumbers}->{data} = join ", ", sort { lc($a) cmp lc($b) } keys %{ $ref->{projectnumbers} };
- map { $row->{$_}->{data} = $ref->{$_} } qw(id reference description notes);
+ map { $row->{$_}->{data} = $ref->{$_} } qw(id reference description notes gldate employee);
map { $row->{$_}->{data} = \@{ $rows{$_} }; } qw(transdate debit credit debit_accno credit_accno debit_tax_accno credit_tax_accno source);
my %charts = ();
my $taxchart_init;
foreach my $item (@{ $form->{ALL_CHARTS} }) {
- if ($item->{charttype} eq 'H'){ #falls überschrift
- next; #überspringen (Bug 1150)
+ if ($item->{charttype} eq 'H'){ #falls überschrift
+ next; #überspringen (Bug 1150)
}
my $key = $item->{accno} . "--" . $item->{tax_id};
$taxchart_init = $item->{tax_id} unless (@chart_values);
print qq|<input class=submit type=submit name=action value="| . $locale->text('Storno') . qq|">|;
}
- # Löschen und Ändern von Buchungen nicht mehr möglich (GoB) nur am selben Tag möglich
+ # Löschen und Ändern von Buchungen nicht mehr möglich (GoB) nur am selben Tag möglich
if (!$form->{locked} && $radieren) {
print qq|
<input class=submit type=submit name=action value="| . $locale->text('Post') . qq|" accesskey="b">
remove_draft() if $form->{remove_draft};
- $form->{callback} = build_std_url("action=add", "show_details");
+ $form->{callback} = build_std_url("action=add&DONT_LOAD_DRAFT=1", "show_details");
$form->redirect($form->{callback});
$main::lxdebug->leave_sub();