X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fgl.pl;h=625490dc86958b6eb7b0eb393ef20dda90d6a692;hb=d4a434e1deba2695ef4d4a3fc0d51ac1b2044fb0;hp=f7810c76bc2ba41697b0bf394a97b7d7ba85d988;hpb=0a1bea675b76367bf2fb15ffb3213fee858c9803;p=kivitendo-erp.git diff --git a/bin/mozilla/gl.pl b/bin/mozilla/gl.pl index f7810c76b..625490dc8 100644 --- a/bin/mozilla/gl.pl +++ b/bin/mozilla/gl.pl @@ -31,6 +31,9 @@ # #====================================================================== +use utf8; +use strict; + use POSIX qw(strftime); use List::Util qw(sum); @@ -44,8 +47,6 @@ require "bin/mozilla/common.pl"; require "bin/mozilla/drafts.pl"; require "bin/mozilla/reportgenerator.pl"; -use strict; - # this is for our long dates # $locale->text('January') # $locale->text('February') @@ -217,7 +218,7 @@ sub search { my $form = $main::form; my %myconfig = %main::myconfig; my $locale = $main::locale; - my $cgi = $main::cgi; + my $cgi = $::request->{cgi}; $form->{title} = $locale->text('Journal'); @@ -233,7 +234,8 @@ sub search { } (@{ $form->{all_departments} || [] }); } - my $department = qq| + my $department; + $department = qq| | . $locale->text('Department') . qq| @@ -241,7 +243,8 @@ sub search { | if $form->{selectdepartment}; $form->get_lists("projects" => { "key" => "ALL_PROJECTS", - "all" => 1 }); + "all" => 1}, + "employees" => "ALL_EMPLOYEES" ); my %project_labels = (); my @project_values = (""); @@ -255,6 +258,20 @@ sub search { '-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 = ""; @@ -295,7 +312,7 @@ sub search {
- + @@ -326,8 +343,19 @@ sub search { - - + + + + + + + + + + $button1 $button2 @@ -356,7 +384,9 @@ sub search { - + + + @@ -379,6 +409,8 @@ sub search { + +
| . $locale->text('Project Number') . qq| $projectnumber
| . $locale->text('From') . qq|
| . $locale->text('Employee') . qq|$employeenumber
| . $locale->text('Filter date by') . qq| +  | . $locale->text('Booking Date') . qq| +  | . $locale->text('Invoice Date') . qq| +
| . $locale->text('From') . qq|| . $locale->text('To (time)') . qq| | . $locale->text('ID') . qq| | . $locale->text('Date') . qq|| . $locale->text('Invoice Date') . qq|| . $locale->text('Booking Date') . qq| | . $locale->text('Reference') . qq| | . $locale->text('Subtotal') . qq| | . $locale->text('Project Number') . qq|| . $locale->text('Employee') . qq|
@@ -435,7 +467,26 @@ sub generate_report { 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->{sort} setzen + # + + # 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); @@ -456,14 +507,18 @@ sub generate_report { my $ml = ($form->{ml} =~ /(A|E|Q)/) ? -1 : 1; my @columns = qw( - transdate id reference description + 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}); @@ -471,7 +526,9 @@ sub generate_report { 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); @@ -483,18 +540,23 @@ sub generate_report { 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'), }, @@ -509,9 +571,10 @@ sub generate_report { '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"; @@ -522,7 +585,7 @@ sub generate_report { 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; @@ -541,6 +604,7 @@ sub generate_report { '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}); @@ -593,7 +657,7 @@ sub generate_report { $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); @@ -798,7 +862,7 @@ sub display_rows { my $form = $main::form; my %myconfig = %main::myconfig; - my $cgi = $main::cgi; + my $cgi = $::request->{cgi}; $form->{debit_1} = 0 if !$form->{"debit_1"}; $form->{totaldebit} = 0; @@ -816,8 +880,8 @@ sub display_rows { 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); @@ -954,7 +1018,7 @@ sub display_rows { my $projectnumber_hidden = qq| |; - my $copy2credit = 'onkeyup="copy_debit_to_credit()"' if $i == 1; + my $copy2credit = $i == 1 ? 'onkeyup="copy_debit_to_credit()"' : ''; print qq| $accno @@ -1016,10 +1080,9 @@ sub form_header { $form->{title} = $locale->text("$title General Ledger Transaction"); my $readonly = ($form->{id}) ? "readonly" : ""; - my $show_details_checked = "checked" if $form->{show_details}; - - my $ob_transaction_checked = "checked" if $form->{ob_transaction}; - my $cb_transaction_checked = "checked" if $form->{cb_transaction}; + my $show_details_checked = $form->{show_details} ? "checked" : ''; + my $ob_transaction_checked = $form->{ob_transaction} ? "checked" : ''; + my $cb_transaction_checked = $form->{cb_transaction} ? "checked" : ''; # $locale->text('Add General Ledger Transaction') # $locale->text('Edit General Ledger Transaction') @@ -1284,7 +1347,7 @@ sub form_footer { my $form = $main::form; my %myconfig = %main::myconfig; my $locale = $main::locale; - my $cgi = $main::cgi; + my $cgi = $::request->{cgi}; my $follow_ups_block; if ($form->{id}) { @@ -1332,7 +1395,7 @@ $follow_ups_block print 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| @@ -1347,7 +1410,7 @@ $follow_ups_block } else { if ($form->{draft_id}) { - my $remove_draft_checked = 'checked' if ($form->{remove_draft}); + my $remove_draft_checked = $form->{remove_draft} ? 'checked' : ''; print qq|

\n| . qq| | . qq| \n| @@ -1608,7 +1671,7 @@ sub post { 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();