From 913fe3398532666f18ec4856470fdfec53b1d388 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Wed, 28 Feb 2007 10:40:54 +0000 Subject: [PATCH] =?utf8?q?Dialogbuchen:=20Die=20Drop-Down-Boxen=20bei=20je?= =?utf8?q?dem=20Formularaufbau=20aus=20der=20Datenbank=20heraus=20aufbauen?= =?utf8?q?=20und=20nicht=20in=20$form=20mitschleifen.=20Behebt=20auch=20de?= =?utf8?q?n=20Fehler,=20dass=20das=20Steuerkonto=20beim=20initialen=20Aufb?= =?utf8?q?au=20nicht=20richtig=20ausgew=C3=A4hlt=20wurde.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/Form.pm | 60 +++++++++++++++++++++++++++ bin/mozilla/gl.pl | 102 +++++++++++++++++++--------------------------- 2 files changed, 103 insertions(+), 59 deletions(-) diff --git a/SL/Form.pm b/SL/Form.pm index 2f7aa793a..157bb61b0 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -1526,6 +1526,58 @@ sub _get_printers { $main::lxdebug->leave_sub(); } +sub _get_charts { + $main::lxdebug->enter_sub(); + + my ($self, $dbh, $params) = @_; + + $key = $params->{key}; + $key = "all_charts" unless ($key); + $self->{$key} = []; + + my $transdate = quote_db_date($params->{transdate}); + + my $query = + qq|SELECT c.accno, c.description, c.link, tk.taxkey_id, tk.tax_id | . + qq|FROM chart c | . + qq|LEFT JOIN taxkeys tk ON | . + qq|(tk.id = (SELECT id FROM taxkeys | . + qq| WHERE taxkeys.chart_id = c.id AND startdate <= $transdate | . + qq| ORDER BY startdate DESC LIMIT 1)) | . + qq|ORDER BY c.accno|; + + my $sth = $dbh->prepare($query); + $sth->execute() || $self->dberror($query); + + while ($ref = $sth->fetchrow_hashref(NAME_lc)) { + push(@{ $self->{$key} }, $ref); + } + $sth->finish; + + $main::lxdebug->leave_sub(); +} + +sub _get_taxcharts { + $main::lxdebug->enter_sub(); + + my ($self, $dbh, $key) = @_; + + $key = "all_taxcharts" unless ($key); + $self->{$key} = []; + + my $query = qq|SELECT * FROM tax ORDER BY taxkey|; + + my $sth = $dbh->prepare($query); + $sth->execute() || $self->dberror($query); + + while ($ref = $sth->fetchrow_hashref(NAME_lc)) { + push(@{ $self->{$key} }, $ref); + } + $sth->finish; + + $main::lxdebug->leave_sub(); +} + sub get_lists { $main::lxdebug->enter_sub(); @@ -1556,6 +1608,14 @@ sub get_lists { $self->_get_printers($dbh, $params{"printers"}); } + if ($params{"charts"}) { + $self->_get_charts($dbh, $params{"charts"}); + } + + if ($params{"taxcharts"}) { + $self->_get_taxcharts($dbh, $params{"taxcharts"}); + } + $dbh->disconnect(); $main::lxdebug->leave_sub(); diff --git a/bin/mozilla/gl.pl b/bin/mozilla/gl.pl index 2d8d31d3a..a20554d7f 100644 --- a/bin/mozilla/gl.pl +++ b/bin/mozilla/gl.pl @@ -81,24 +81,14 @@ sub add { # we use this only to set a default date GL->transaction(\%myconfig, \%$form); - map { - $chart .= - "" - } @{ $form->{chart} }; map { $tax .= qq|" - } @{ $form->{chart} }; map { $tax .= @@ -134,10 +120,6 @@ sub edit { . ($_->{rate} * 100) . qq| %| } @{ $form->{TAX} }; - $form->{chart} = $chart; - - $form->{taxchart} = $tax; - $form->{amount} = $form->format_amount(\%myconfig, $form->{amount}, 2); # departments @@ -1081,10 +1063,6 @@ sub display_rows { $form->{totaldebit} = 0; $form->{totalcredit} = 0; - my $chart = $form->{chart}; - $chart = $form->unquote($chart); - $form->{taxchart} = $form->unquote($form->{taxchart}); - $taxchart = $form->{taxchart}; my @old_project_ids = (); map({ push(@old_project_ids, $form->{"project_id_$_"}) @@ -1092,7 +1070,10 @@ sub display_rows { $form->get_lists("projects" => { "key" => "ALL_PROJECTS", "all" => 0, - "old_id" => \@old_project_ids }); + "old_id" => \@old_project_ids }, + "charts" => { "key" => "ALL_CHARTS", + "transdate" => $form->{transdate} }, + "taxcharts" => "ALL_TAXCHARTS"); my %project_labels = (); my @project_values = (""); @@ -1101,6 +1082,26 @@ sub display_rows { $project_labels{$item->{"id"}} = $item->{"projectnumber"}; } + my %chart_labels = (); + my @chart_values = (); + my $taxchart_init; + foreach my $item (@{ $form->{ALL_CHARTS} }) { + my $key = Q($item->{accno}) . "--" . Q($item->{tax_id}); + $taxchart_init = $item->{taxkey_id} unless (@chart_values); + push(@chart_values, $key); + $chart_labels{$key} = H($item->{accno}) . "--" . H($item->{description}); + } + + my %taxchart_labels = (); + my @taxchart_values = (); + foreach my $item (@{ $form->{ALL_TAXCHARTS} }) { + my $key = Q($item->{id}) . "--" . Q($item->{rate}); + $taxchart_init = $key if ($taxchart_init eq $item->{taxkey}); + push(@taxchart_values, $key); + $taxchart_labels{$key} = H($item->{taxdescription}) . " " . + H($item->{rate} * 100) . ' %'; + } + for $i (1 .. $form->{rowcount}) { $source = qq| @@ -1110,15 +1111,25 @@ sub display_rows { |; - if ($init) { - $accno = qq| - |; - $tax = - qq||; + $accno = qq|| . + $cgi->popup_menu('-name' => "accno_$i", + '-onChange' => "setTaxkey(this, $i)", + '-style' => 'width:200px', + '-tabindex' => ($i + 5 + (($i - 1) * 8)), + '-values' => \@chart_values, + '-labels' => \%chart_labels, + '-default' => $init ? '' : $form->{"accno_$i"}) + . qq||; + $tax = qq|| . + $cgi->popup_menu('-name' => "taxchart_$i", + '-style' => 'width:200px', + '-tabindex' => ($i + 10 + (($i - 1) * 8)), + '-values' => \@taxchart_values, + '-labels' => \%taxchart_labels, + '-default' => $init ? $taxchart_init : $form->{"taxchart_$i"}) + . qq||; + if ($init) { $korrektur = qq|{rowcount}) { - - $accno = $chart; - $chart_selected = $form->{"accno_$i"}; - $accno =~ - s/value=\"$chart_selected\"/value=\"$chart_selected\" selected/; - $accno = - qq||; - $tax = $taxchart; - $tax_selected = $form->{"taxchart_$i"}; - $tax =~ s/value=\"$tax_selected\"/value=\"$tax_selected\" selected/; - $tax = - qq||; - if ($form->{transfer}) { $checked = ($form->{"fx_transaction_$i"}) ? "1" : ""; $x = ($checked) ? "x" : ""; @@ -1182,14 +1176,6 @@ sub display_rows { $form->hide_form("accno_$i"); } else { - - $accno = qq| - |; - $tax = qq| - |; - $korrektur = qq|{closedto}> {locked}> - - @@ -1532,7 +1516,7 @@ sub delete { {script}> |; - map { $form->{$_} =~ s/\"/"/g } qw(reference description chart taxchart); + map { $form->{$_} =~ s/\"/"/g } qw(reference description); delete $form->{header}; -- 2.20.1