From 134ecd713fae927536c69259fbd3489f0925fc3f Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Tue, 20 Feb 2007 09:12:51 +0000 Subject: [PATCH] =?utf8?q?Buchungsjournal:=20Filterm=C3=B6glichkeit=20nach?= =?utf8?q?=20Projekten=20sowie=20das=20Anzeigen=20von=20Projektnummern=20i?= =?utf8?q?mplementiert.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/GL.pm | 32 +++++++++++++++++++++++++++----- bin/mozilla/gl.pl | 36 +++++++++++++++++++++++++++++++++--- locale/de/all | 1 + locale/de/gl | 1 + 4 files changed, 62 insertions(+), 8 deletions(-) diff --git a/SL/GL.pm b/SL/GL.pm index 8aef1b108..43b4c53d6 100644 --- a/SL/GL.pm +++ b/SL/GL.pm @@ -201,7 +201,7 @@ sub post_transaction { if ($tax != 0) { # add taxentry $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, - source, memo, taxkey) + source, memo, project_id, taxkey) VALUES ($form->{id}, (SELECT t.chart_id FROM tax t @@ -300,6 +300,21 @@ sub all_transactions { $apwhere .= " AND ap.id in (SELECT trans_id FROM acc_trans ac2 WHERE ac2.chart_id IN (SELECT id FROM chart c2 WHERE c2.category = '$form->{category}'))"; } + if ($form->{project_id}) { + $glwhere .= " AND g.id IN (SELECT DISTINCT trans_id FROM acc_trans WHERE project_id = " . conv_i($form->{project_id}, 'NULL') . ")"; + $arwhere .= + " AND ((a.globalproject_id = " . conv_i($form->{project_id}, 'NULL') . ") OR " . + " (a.id IN (SELECT DISTINCT trans_id FROM acc_trans WHERE project_id = " . conv_i($form->{project_id}, 'NULL') . ")))"; + $apwhere .= + " AND ((a.globalproject_id = " . conv_i($form->{project_id}, 'NULL') . ") OR " . + " (a.id IN (SELECT DISTINCT trans_id FROM acc_trans WHERE project_id = " . conv_i($form->{project_id}, 'NULL') . ")))"; + } + + my ($project_columns, %project_join); + if ($form->{"l_projectnumbers"}) { + $project_columns = ", ac.project_id, pr.projectnumber"; + $project_join = "LEFT JOIN project pr ON (ac.project_id = pr.id)"; + } if ($form->{accno}) { @@ -375,7 +390,8 @@ sub all_transactions { qq|SELECT ac.oid AS acoid, g.id, 'gl' AS type, $false AS invoice, g.reference, ac.taxkey, c.link, g.description, ac.transdate, ac.source, ac.trans_id, ac.amount, c.accno, c.gifi_accno, g.notes, t.chart_id, ac.oid - FROM gl g, acc_trans ac, chart c LEFT JOIN tax t ON + $project_columns + FROM gl g, acc_trans ac $project_join, chart c LEFT JOIN tax t ON (t.chart_id=c.id) WHERE $glwhere AND ac.chart_id = c.id @@ -384,7 +400,8 @@ sub all_transactions { SELECT ac.oid AS acoid, a.id, 'ar' AS type, a.invoice, a.invnumber, ac.taxkey, c.link, ct.name, ac.transdate, ac.source, ac.trans_id, ac.amount, c.accno, c.gifi_accno, a.notes, t.chart_id, ac.oid - FROM ar a, acc_trans ac, customer ct, chart c LEFT JOIN tax t ON + $project_columns + FROM ar a, acc_trans ac $project_join, customer ct, chart c LEFT JOIN tax t ON (t.chart_id=c.id) WHERE $arwhere AND ac.chart_id = c.id @@ -394,7 +411,8 @@ sub all_transactions { SELECT ac.oid AS acoid, a.id, 'ap' AS type, a.invoice, a.invnumber, ac.taxkey, c.link, ct.name, ac.transdate, ac.source, ac.trans_id, ac.amount, c.accno, c.gifi_accno, a.notes, t.chart_id, ac.oid - FROM ap a, acc_trans ac, vendor ct, chart c LEFT JOIN tax t ON + $project_columns + FROM ap a, acc_trans ac $project_join, vendor ct, chart c LEFT JOIN tax t ON (t.chart_id=c.id) WHERE $apwhere AND ac.chart_id = c.id @@ -447,7 +465,10 @@ sub all_transactions { $ref->{module} = "ar"; } } - + + $ref->{"projectnumbers"} = {}; + $ref->{"projectnumbers"}->{$ref->{"projectnumber"}} = 1 if ($ref->{"projectnumber"}); + $balance = $ref->{amount}; # Linenumbers of General Ledger @@ -503,6 +524,7 @@ sub all_transactions { $balance = (int($balance * 100000) + int(100000 * $ref2->{amount})) / 100000; + $ref->{"projectnumbers"}->{$ref2->{"projectnumber"}} = 1 if ($ref2->{"projectnumber"}); if ($ref2->{chart_id} > 0) { # all tax accounts, following lines if ($ref2->{amount} < 0) { diff --git a/bin/mozilla/gl.pl b/bin/mozilla/gl.pl index 89febc208..f17680865 100644 --- a/bin/mozilla/gl.pl +++ b/bin/mozilla/gl.pl @@ -227,6 +227,21 @@ sub search { | if $form->{selectdepartment}; + $form->get_lists("projects" => { "key" => "ALL_PROJECTS", + "all" => 1 }); + + my %project_labels = (); + my @project_values = (""); + foreach my $item (@{ $form->{"ALL_PROJECTS"} }) { + push(@project_values, $item->{"id"}); + $project_labels{$item->{"id"}} = $item->{"projectnumber"}; + } + + my $projectnumber = + NTI($cgi->popup_menu('-name' => "project_id", + '-values' => \@project_values, + '-labels' => \%project_labels)); + # use JavaScript Calendar or not $form->{jsscript} = $jscalendar; $jsscript = ""; @@ -289,6 +304,10 @@ sub search { | . $locale->text('Notes') . qq| + + | . $locale->text('Project Number') . qq| + $projectnumber + | . $locale->text('From') . qq| $button1 @@ -342,6 +361,8 @@ sub search { | . $locale->text('Subtotal') . qq| + + | . $locale->text('Project Number') . qq| @@ -447,6 +468,10 @@ sub generate_report { $option .= "\n
" if $option; $option .= $locale->text('Notes') . " : $form->{notes}"; } + if ($form->{project_id}) { + $href .= "&project_id=" . $form->escape($form->{project_id}); + $callback .= "&project_id=" . $form->escape($form->{project_id}); + } if ($form->{datefrom}) { $href .= "&datefrom=$form->{datefrom}"; @@ -469,9 +494,10 @@ sub generate_report { . $locale->date(\%myconfig, $form->{dateto}, 1); } - @columns = $form->sort_columns( - qw(transdate id reference description notes source debit debit_accno credit credit_accno debit_tax debit_tax_accno credit_tax credit_tax_accno accno gifi_accno) - ); + @columns = + qw(transdate id reference description notes source debit debit_accno credit + credit_accno debit_tax debit_tax_accno credit_tax credit_tax_accno accno + gifi_accno projectnumbers); if ($form->{accno} || $form->{gifi_accno}) { @columns = grep !/(accno|gifi_accno)/, @columns; @@ -560,6 +586,8 @@ sub generate_report { . $locale->text('GIFI') . ""; $column_header{balance} = "" . $locale->text('Balance') . ""; + $column_header{projectnumbers} = + "" . $locale->text('Project Numbers') . ""; $form->{landscape} = 1; @@ -789,6 +817,8 @@ sub generate_report { $column_data{balance} = "" . $form->format_amount(\%myconfig, $form->{balance}, 2, 0) . ""; + $column_data{projectnumbers} = + "" . join(", ", sort({ lc($a) cmp lc($b) } keys(%{ $ref->{projectnumbers} }))) . ""; $i++; $i %= 2; diff --git a/locale/de/all b/locale/de/all index c653f197f..0f060455b 100644 --- a/locale/de/all +++ b/locale/de/all @@ -804,6 +804,7 @@ gestartet', 'Project' => 'Projekt', 'Project Number' => 'Projektnummer', 'Project Number missing!' => 'Projektnummer fehlt!', + 'Project Numbers' => 'Projektnummern', 'Project Transactions' => 'Projektbuchungen', 'Project deleted!' => 'Projekt gelöscht!', 'Project description' => 'Projektbeschreibung', diff --git a/locale/de/gl b/locale/de/gl index db5b6a8ae..17559c4a8 100644 --- a/locale/de/gl +++ b/locale/de/gl @@ -78,6 +78,7 @@ $self->{texts} = { 'Post' => 'Buchen', 'Post as new' => 'Neu buchen', 'Project Number' => 'Projektnummer', + 'Project Numbers' => 'Projektnummern', 'Project not on file!' => 'Dieses Projekt ist nicht in der Datenbank!', 'Reference' => 'Referenz', 'Reference missing!' => 'Referenz fehlt!', -- 2.20.1