X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=bin%2Fmozilla%2Fgl.pl;h=f17680865a5f9a68b81af25e8f580ed53e796e1a;hb=84da0ba2f48ac09652557a5aca1a912b06fb0b0b;hp=734e9c4a64bb098e244bf6932caabcb5cf2e3f35;hpb=9feb246dea491959ab77055a5a1985ae64c9776f;p=kivitendo-erp.git diff --git a/bin/mozilla/gl.pl b/bin/mozilla/gl.pl index 734e9c4a6..f17680865 100644 --- a/bin/mozilla/gl.pl +++ b/bin/mozilla/gl.pl @@ -35,6 +35,7 @@ use SL::GL; use SL::PE; require "$form->{path}/arap.pl"; +require "bin/mozilla/common.pl"; 1; @@ -82,11 +83,11 @@ sub add { map { $chart .= - "{accno}--$_->{taxkey_id}\">$_->{accno}--$_->{description}" + "{accno}--$_->{tax_id}\">$_->{accno}--$_->{description}" } @{ $form->{chart} }; map { $tax .= - qq|$_->{taxdescription} | + qq|$_->{taxdescription} | . ($_->{rate} * 100) . qq| %| } @{ $form->{TAX} }; @@ -124,12 +125,12 @@ sub edit { GL->transaction(\%myconfig, \%$form); map { $chart .= - "{accno}--$_->{taxkey_id}\">$_->{accno}--$_->{description}" + "{accno}--$_->{tax_id}\">$_->{accno}--$_->{description}" } @{ $form->{chart} }; map { $tax .= - qq|$_->{taxdescription} | + qq|$_->{taxdescription} | . ($_->{rate} * 100) . qq| %| } @{ $form->{TAX} }; @@ -154,12 +155,10 @@ sub edit { my $tax = 0; my $taxaccno = ""; foreach $ref (@{ $form->{GL} }) { - $form->{"projectnumber_$i"} = "$ref->{projectnumber}--$ref->{project_id}"; - $j = $i - 1; if ($tax && ($ref->{accno} eq $taxaccno)) { $form->{"tax_$j"} = abs($ref->{amount}); - $form->{"taxchart_$j"} = $ref->{taxkey} . "--" . $ref->{taxrate}; + $form->{"taxchart_$j"} = $ref->{id} . "--" . $ref->{taxrate}; if ($form->{taxincluded}) { if ($ref->{amount} < 0) { $form->{"debit_$j"} += $form->{"tax_$j"}; @@ -168,7 +167,7 @@ sub edit { } } } else { - $form->{"accno_$i"} = "$ref->{accno}--$ref->{accnotaxkey}"; + $form->{"accno_$i"} = "$ref->{accno}--$ref->{tax_id}"; for (qw(fx_transaction source memo)) { $form->{"${_}_$i"} = $ref->{$_} } if ($ref->{amount} < 0) { $form->{totaldebit} -= $ref->{amount}; @@ -177,6 +176,7 @@ sub edit { $form->{totalcredit} += $ref->{amount}; $form->{"credit_$i"} = $ref->{amount}; } + $form->{"taxchart_$i"} = "0--0.00"; $i++; } if ($ref->{taxaccno} && !$tax) { @@ -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,9 +304,14 @@ sub search { | . $locale->text('Notes') . qq| + + | . $locale->text('Project Number') . qq| + $projectnumber + | . $locale->text('From') . qq| $button1 + | . $locale->text('To (time)') . qq| $button2 @@ -304,12 +324,8 @@ sub search { . $locale->text('All') . qq| | . $locale->text('Asset') . qq| - | - . $locale->text('Contra') . qq| | . $locale->text('Liability') . qq| - | - . $locale->text('Equity') . qq| | . $locale->text('Revenue') . qq| | @@ -345,6 +361,8 @@ sub search { | . $locale->text('Subtotal') . qq| + + | . $locale->text('Project Number') . qq| @@ -450,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}"; @@ -472,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; @@ -563,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; @@ -623,15 +648,17 @@ sub generate_report { |; } - $form->{balance} *= $ml; + $form->{balance} *= $ml; foreach $ref (@{ $form->{GL} }) { $form->{balance} *= $ml; + # if item ne sort print subtotal if ($form->{l_subtotal} eq 'Y') { if ($sameitem ne $ref->{ $form->{sort} }) { &gl_subtotal; } } + #foreach $key (sort keys(%{ $ref->{amount} })) { # $form->{balance} += $ref->{amount}{$key}; #} @@ -659,7 +686,7 @@ sub generate_report { $credit .= "" . $form->format_amount(\%myconfig, $ref->{credit}{$key}, 2, 0); } - $form->{balance} = abs($form->{balance}) - abs( $ref->{credit}{$key}); + $form->{balance} = abs($form->{balance}) - abs($ref->{credit}{$key}); } $debittax = ""; @@ -696,14 +723,15 @@ sub generate_report { foreach $key (sort keys(%{ $ref->{debit_accno} })) { if ($key == 0) { $debitaccno = - "{accno}&callback=$callback>$ref->{debit_accno}{$key}"; + "{debit_accno}{$key}&callback=$callback>$ref->{debit_accno}{$key}"; } else { $debitaccno .= - "{accno}&callback=$callback>$ref->{debit_accno}{$key}"; - } - if ($ref->{debit_taxkey}{$key} eq $debittaxkey) { - $ref->{debit_tax_accno}{$key} = $taxaccno; + "{debit_accno}{$key}&callback=$callback>$ref->{debit_accno}{$key}"; } + + # if ($ref->{debit_taxkey}{$key} eq $debittaxkey) { + # $ref->{debit_tax_accno}{$key} = $taxaccno; + # } $taxaccno = $ref->{debit_tax_accno}{$key}; $debittaxkey = $ref->{debit_taxkey}{$key}; } @@ -714,14 +742,15 @@ sub generate_report { foreach $key (sort keys(%{ $ref->{credit_accno} })) { if ($key == 0) { $creditaccno = - "{accno}&callback=$callback>$ref->{credit_accno}{$key}"; + "{credit_accno}{$key}&callback=$callback>$ref->{credit_accno}{$key}"; } else { $creditaccno .= - "{accno}&callback=$callback>$ref->{credit_accno}{$key}"; - } - if ($ref->{credit_taxkey}{$key} eq $credittaxkey) { - $ref->{credit_tax_accno}{$key} = $taxaccno; + "{credit_accno}{$key}&callback=$callback>$ref->{credit_accno}{$key}"; } + + # if ($ref->{credit_taxkey}{$key} eq $credittaxkey) { + # $ref->{credit_tax_accno}{$key} = $taxaccno; + # } $taxaccno = $ref->{credit_tax_accno}{$key}; $credittaxkey = $ref->{credit_taxkey}{$key}; } @@ -730,10 +759,10 @@ sub generate_report { foreach $key (sort keys(%{ $ref->{debit_tax_accno} })) { if ($key == 0) { $debittaxaccno = - "{accno}&callback=$callback>$ref->{debit_tax_accno}{$key}"; + "{debit_tax_accno}{$key}&callback=$callback>$ref->{debit_tax_accno}{$key}"; } else { $debittaxaccno .= - "{accno}&callback=$callback>$ref->{debit_tax_accno}{$key}"; + "{debit_tax_accno}{$key}&callback=$callback>$ref->{debit_tax_accno}{$key}"; } } @@ -741,10 +770,19 @@ sub generate_report { foreach $key (sort keys(%{ $ref->{credit_tax_accno} })) { if ($key == 0) { $credittaxaccno = - "{accno}&callback=$callback>$ref->{credit_tax_accno}{$key}"; + "{credit_tax_accno}{$key}&callback=$callback>$ref->{credit_tax_accno}{$key}"; } else { $credittaxaccno .= - "{accno}&callback=$callback>$ref->{credit_tax_accno}{$key}"; + "{credit_tax_accno}{$key}&callback=$callback>$ref->{credit_tax_accno}{$key}"; + } + } + + $transdate = ""; + foreach $key (sort keys(%{ $ref->{transdate} })) { + if ($key == 0) { + $transdate = "$ref->{transdate}{$key}"; + } else { + $transdate .= "$ref->{transdate}{$key}"; } } @@ -752,12 +790,10 @@ sub generate_report { # $ref->{credit} = $form->format_amount(\%myconfig, $ref->{credit}, 2, " "); $column_data{id} = " $ref->{id} "; - $column_data{transdate} = - " $ref->{transdate} "; + $column_data{transdate} = "$transdate"; $column_data{reference} = "{module}.pl?action=edit&id=$ref->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{reference}"; - $column_data{description} = - "$ref->{description} "; + $column_data{description} = "$ref->{description} "; $column_data{source} = "$ref->{source} "; $column_data{notes} = "$ref->{notes} "; $column_data{debit} = "$debit"; @@ -779,9 +815,10 @@ sub generate_report { $column_data{gifi_accno} = "{gifi_accno}&callback=$callback>$ref->{gifi_accno} "; $column_data{balance} = - "" - . $form->format_amount(\%myconfig, $form->{balance}, 2, 0) - . ""; + "" + . $form->format_amount(\%myconfig, $form->{balance}, 2, 0) . ""; + $column_data{projectnumbers} = + "" . join(", ", sort({ lc($a) cmp lc($b) } keys(%{ $ref->{projectnumbers} }))) . ""; $i++; $i %= 2; @@ -848,14 +885,7 @@ sub generate_report { |; - - if ($form->{menubar}) { - require "$form->{path}/menu.pl"; - &menubar; - } - - print qq| + . $locale->text('Vendor Invoice') . qq|"> @@ -894,21 +924,7 @@ sub gl_subtotal { sub update { $lxdebug->enter_sub(); - if ($form->{transdate} ne $form->{oldtransdate}) { - if ($form->{selectprojectnumber}) { - $form->all_projects(\%myconfig, undef, $form->{transdate}); - if (@{ $form->{all_project} }) { - $form->{selectprojectnumber} = "\n"; - for (@{ $form->{all_project} }) { - $form->{selectprojectnumber} .= - qq|$_->{projectnumber}\n|; - } - $form->{selectprojectnumber} = - $form->escape($form->{selectprojectnumber}, 1); - } - } - $form->{oldtransdate} = $form->{transdate}; - } + $form->{oldtransdate} = $form->{transdate}; my @a = (); my $count = 0; @@ -968,7 +984,7 @@ sub update { : $form->{"debit_$i"}; $j = $#a; if (($debitcredit && $credittax) || (!$debitcredit && $debittax)) { - $form->{"taxchart_$i"} = "0--"; + $form->{"taxchart_$i"} = "0--0.00"; $form->{"tax_$i"} = 0; } if (!$form->{"korrektur_$i"}) { @@ -1032,36 +1048,46 @@ sub display_rows { my ($init) = @_; $lxdebug->enter_sub(); - $form->{selectprojectnumber} = $form->unescape($form->{selectprojectnumber}) - if $form->{selectprojectnumber}; - $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_$_"}) + if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"})); + + $form->get_lists("projects" => { "key" => "ALL_PROJECTS", + "all" => 0, + "old_id" => \@old_project_ids }); + + my %project_labels = (); + my @project_values = (""); + foreach my $item (@{ $form->{"ALL_PROJECTS"} }) { + push(@project_values, $item->{"id"}); + $project_labels{$item->{"id"}} = $item->{"projectnumber"}; + } + for $i (1 .. $form->{rowcount}) { $source = qq| - |; $memo = qq| - |; if ($init) { $accno = qq| - $form->{chartinit}|; $tax = - qq|$form->{taxchart}|; - if ($form->{selectprojectnumber}) { - $project = qq| - $form->{selectprojectnumber}|; - } + $korrektur = qq|$accno|; $tax = $taxchart; @@ -1110,15 +1136,6 @@ sub display_rows { . ($i + 10 + (($i - 1) * 8)) . qq|>$tax|; - if ($form->{selectprojectnumber}) { - $form->{"projectnumber_$i"} = "" - if $form->{selectprojectnumber} !~ /$form->{"projectnumber_$i"}/; - - $project = $form->{"projectnumber_$i"}; - $project =~ s/--.*//; - $project = qq|$project|; - } - if ($form->{transfer}) { $checked = ($form->{"fx_transaction_$i"}) ? "1" : ""; $x = ($checked) ? "x" : ""; @@ -1131,7 +1148,7 @@ sub display_rows { qq||; - $form->hide_form("accno_$i", "projectnumber_$i"); + $form->hide_form("accno_$i"); } else { @@ -1141,10 +1158,7 @@ sub display_rows { $tax = qq| $taxchart|; - if ($form->{selectprojectnumber}) { - $project = qq| - $form->{selectprojectnumber}|; - } + $korrektur = qq|popup_menu('-name' => "project_id_$i", + '-values' => \@project_values, + '-labels' => \%project_labels, + '-default' => $form->{"project_id_$i"} )); + print qq| $accno $fx_transaction - - - $korrektur $tax $source $memo - $project + $projectnumber |; } $form->hide_form(qw(rowcount selectaccno)); - print qq| -|; + $lxdebug->leave_sub(); } @@ -1209,7 +1227,7 @@ sub form_header {