X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fcp.pl;h=a70c32eebdcd2b2a74882e0053f4d0bec1567c57;hb=6e08e45474de9b64b0cdd310e0e93d8a998587e8;hp=d8890a10e95effad6be614cf9346da022226d164;hpb=4dbb09950c9f5596646537c12d991c99086fe7c1;p=kivitendo-erp.git diff --git a/bin/mozilla/cp.pl b/bin/mozilla/cp.pl index d8890a10e..a70c32eeb 100644 --- a/bin/mozilla/cp.pl +++ b/bin/mozilla/cp.pl @@ -31,64 +31,94 @@ # #====================================================================== - use SL::CP; -use SL::OP; use SL::IS; use SL::IR; +use SL::AR; +use SL::AP; +use Data::Dumper; +use strict; +#use warnings; + +require "bin/mozilla/arap.pl"; +require "bin/mozilla/common.pl"; -require "$form->{path}/arap.pl"; +our ($form, %myconfig, $lxdebug, $locale, $auth); 1; -# end of main +# end of main sub payment { $lxdebug->enter_sub(); - + $auth->assert('cash'); + + my (@curr); + $form->{ARAP} = ($form->{type} eq 'receipt') ? "AR" : "AP"; $form->{arap} = lc $form->{ARAP}; # setup customer/vendor selection for open invoices if ($form->{all_vc}) { + # Dieser Zweig funktioniert derzeit NIE. Ggf. ganz raus oder + # alle offenen Zahlungen wieder korrekt anzeigen. jb 12.10.2010 $form->all_vc(\%myconfig, $form->{vc}, $form->{ARAP}); } else { CP->get_openvc(\%myconfig, \%$form); } - + # Auswahlliste für vc zusammenbauen + # Erweiterung für schliessende option und erweiterung um value + # für bugfix 1771 (doppelte Leerzeichen werden nicht 'gepostet') $form->{"select$form->{vc}"} = ""; - - if ($form->{"all_$form->{vc}"}) { - $form->{"$form->{vc}_id"} = $form->{"all_$form->{vc}"}->[0]->{id}; - map { $form->{"select$form->{vc}"} .= "\n" if $form->{vc} eq "customer"; - map { $form->{selectdepartment} .= "\n" } + @{ $form->{"all_$form->{vc}"} }; } - CP->paymentaccounts(\%myconfig, \%$form); + # Standard Konto für Umlaufvermögen + my $accno_arap = IS->get_standard_accno_current_assets(\%myconfig, \%$form); + # Entsprechend präventiv die Auswahlliste für Kontonummer + # auch mit value= zusammenbauen (s.a. oben bugfix 1771) + # Wichtig: Auch das Template anpassen, damit hidden input korrekt die " + # escaped. $form->{selectaccount} = ""; $form->{"select$form->{ARAP}"} = ""; - map { $form->{selectaccount} .= "\n"; + $form->{account} = "$_->{accno}--$_->{description}" if ($_->{accno} eq $accno_arap) } @{ $form->{PR}{"$form->{ARAP}_paid"} }; + + # Braucht man das hier überhaupt? Erstmal auskommentieren .. jan 18.12.2010 + # map { + # $form->{"select$form->{ARAP}"} .= + # "\n" } @curr; - $form->{media} = "screen"; &form_header; &form_footer; @@ -96,380 +126,94 @@ sub payment { $lxdebug->leave_sub(); } - - sub form_header { - $lxdebug->enter_sub(); + $lxdebug->enter_sub; + $auth->assert('cash'); - $vclabel = ucfirst $form->{vc}; - $vclabel = $locale->text($vclabel); - - if ($form->{type} eq 'receipt') { - $form->{title} = $locale->text('Receipt'); - $form->{origtitle} = "Receipt"; - } - if ($form->{type} eq 'check') { - $form->{title} = $locale->text('Payment'); - $form->{origtitle} = "Payment"; - } + my ($vc, $arap, $exchangerate); -# $locale->text('Customer') -# $locale->text('Vendor') - - if ($form->{$form->{vc}} eq "") { + if ($form->{ $form->{vc} } eq "") { map { $form->{"addr$_"} = "" } (1 .. 4); } - if ($form->{currency} ne $form->{defaultcurrency}) { - $form->{exchangerate} = $form->format_amount(\%myconfig, $form->{exchangerate}); - if ($form->{forex}) { - $exchangerate = qq| - - |.$locale->text('Exchangerate').qq| - {exchangerate}>$form->{exchangerate} - -|; - } else { - $exchangerate = qq| - - |.$locale->text('Exchangerate').qq| - {exchangerate}> - -|; - } + # sometimes it happens that values in customer arrive without the signs '--' + # but in order to select the right option field we need values with '--' + if ($form->{vc} eq "customer"){ + my ($customername) = split /--/, $form->{ $form->{vc} }; + $form->{ $form->{vc} } = $customername . "--" . $form->{customer_id}; } - - foreach $item ($form->{vc}, account, currency, $form->{ARAP}, department) { + # bugfix 1771 + # geändert von + # offen: $form->{ARAP} kann raus? + for my $item ($form->{vc}, "account", "currency", $form->{ARAP}) { $form->{"select$item"} =~ s/ selected//; - $form->{"select$item"} =~ s/option>\Q$form->{$item}\E/option selected>$form->{$item}/; + $form->{"select$item"} =~ s/option value="\Q$form->{$item}\E">\Q$form->{$item}\E/option selected value="$form->{$item}">$form->{$item}/; } - $vc = ($form->{"select$form->{vc}"}) ? qq|| : qq|{vc} size=35 value="$form->{$form->{vc}}">|; + $vc = + ($form->{"select$form->{vc}"}) + ? qq|| + : qq|{vc} size=35 value="$form->{$form->{vc}}">|; + + $form->{openinvoices} = $form->{all_vc} ? "" : 1; + + # $locale->text('AR') + # $locale->text('AP') - if ($form->{all_vc}) { - $allvc = "checked"; - $form->{openinvoices} = ""; - } else { - $allvc = ""; - $form->{openinvoices} = 1; - } - -# $locale->text('AR') -# $locale->text('AP') - - $department = qq| - - |.$locale->text('Department').qq| - - - - - -| if $form->{selectdepartment}; - - $form->{jsscript} = $jscalendar; - $jsscript = ""; - if ($form->{jsscript}) - { - # with JavaScript Calendar - $button1 = qq| - - text('button').qq|> - |; - #write Trigger - $jsscript = Form->write_trigger(\%myconfig,"1","datepaid","BL","trigger1","","",""); - } - else - { - # without JavaScript Calendar - $button1 = qq| - |; - } - $form->header; $arap = lc $form->{ARAP}; - print qq| - - -
{script}> - -{defaultcurrency}> -{closedto}> -{vc}> -{type}> -{type}> - - -{ARAP}> -{openinvoices}> - - - - - - - - - - - - -$jsscript -|; + print $::form->parse_html_template('cp/form_header', { + is_customer => $form->{vc} eq 'customer', + is_receipt => $form->{type} eq 'receipt', + arap => $arap, + vccontent => $vc, + }); - $lxdebug->leave_sub(); + $lxdebug->leave_sub; } - sub list_invoices { - $lxdebug->enter_sub(); - - - @column_index = qw(invnumber transdate amount due checked paid); - - $colspan = $#column_index + 1; - - $invoice = $locale->text('Invoices'); - - print qq| - - - - -|; - - $lxdebug->leave_sub(); + $::lxdebug->leave_sub; } - sub form_footer { - $lxdebug->enter_sub(); - - - $form->{DF}{$form->{format}} = "selected"; - $form->{OP}{$form->{media}} = "selected"; - - $media = qq| - - - -
$form->{title}
- - - - - -
- - - - - - - - - {vc}"}"> - {"$form->{vc}_id"}> - {vc}"}"> - - - - - - - - - - - - - -
- - |.$locale->text('All').qq|
$vclabel$vc
|.$locale->text('Address').qq| - - - - - - - - - - - - - -
$form->{street}
$form->{zipcode}
$form->{city}
$form->{country}
-
|.$locale->text('Memo').qq|
-
- - $department - - - - {ARAP}"}"> - - - - - - - - $button1 - - - - - - {oldcurrency}> - - $exchangerate - - - - - - - - -
|.$locale->text($form->{ARAP}).qq| -
|.$locale->text('Account').qq| - -
|.$locale->text('Date').qq|
|.$locale->text('Currency').qq|
|.$locale->text('Source').qq|
|.$locale->text('Amount').qq|format_amount(\%myconfig, $form->{amount}, 2).qq|>
-
-
- - - - -|; - - $column_data{invnumber} = qq|"; - $column_data{transdate} = qq|"; - $column_data{amount} = qq|"; - $column_data{due} = qq|"; - $column_data{paid} = qq|"; - $column_data{checked} = qq|"; - - print qq| - -|; - map { print "$column_data{$_}\n" } @column_index; - print qq| - -|; - - for $i (1 .. $form->{rowcount}) { - - map { $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) } qw(amount due paid); - - $totalamount += $form->{"amount_$i"}; - $totaldue += $form->{"due_$i"}; - $totalpaid += $form->{"paid_$i"}; - - map { $form->{"${_}_$i"} = $form->format_amount(\%myconfig, $form->{"${_}_$i"}, 2) } qw(amount due paid); - - $column_data{invnumber} = qq| - - {"id_$i"}>|; - $column_data{transdate} = qq| - {"transdate_$i"}>|; - $column_data{amount} = qq| - {"amount_$i"}>|; - $column_data{due} = qq| - {"due_$i"}>|; - - $column_data{paid} = qq||; - - $form->{"checked_$i"} = ($form->{"checked_$i"}) ? "checked" : ""; - $column_data{checked} = qq||; - - $j++; $j %= 2; - print qq| - -|; - map { print "$column_data{$_}\n" } @column_index; - print qq| - -|; + $::lxdebug->enter_sub; + $::auth->assert('cash'); + + my @columns = qw(amount due paid invnumber id transdate checked); + my (@invoices, %total); + for my $i (1 .. $::form->{rowcount}) { + push @invoices, +{ map { $_ => $::form->{"$_\_$i"} } @columns }; + $total{$_} += $invoices[-1]{$_} = $::form->parse_amount(\%::myconfig, $invoices[-1]{$_}) for qw(amount due paid); } - map { $column_data{$_} = "" } @column_index; - - $column_data{amount} = qq||; - $column_data{due} = qq||; - $column_data{paid} = qq||; + print $::form->parse_html_template('cp/invoices', { + invoices => \@invoices, + totals => \%total, + }); - print qq| - -|; - map { print "$column_data{$_}\n" } @column_index; - print qq| - -
$invoice
|.$locale->text('Invoice')."|.$locale->text('Date')."|.$locale->text('Amount')."|.$locale->text('Due')."|.$locale->text('Amount')."|.$locale->text('Select')."
$form->{"invnumber_$i"}$form->{"transdate_$i"}$form->{"amount_$i"}$form->{"due_$i"}{"paid_$i"}>{"checked_$i"}>
 |.$form->format_amount(\%myconfig, $totalamount, 2, " ").qq||.$form->format_amount(\%myconfig, $totaldue, 2, " ").qq||.$form->format_amount(\%myconfig, $totalpaid, 2, " ").qq|
-

-{rowcount}> - -{path}> -{login}> -{password}> - -
- -|; - - if ($latex) { - print qq| -|; - } - - print qq| - - -|; - - if ($form->{menubar}) { - require "$form->{path}/menu.pl"; - &menubar; - } - - print qq| -
+ $::lxdebug->enter_sub; + $::auth->assert('cash'); - - -|; + print $::form->parse_html_template('cp/form_footer'); - $lxdebug->leave_sub(); + $::lxdebug->leave_sub; } - sub update { $lxdebug->enter_sub(); + $auth->assert('cash'); + my ($new_name_selected) = @_; - - + + my ($buysell, $newvc, $updated, $exchangerate, $amount); + if ($form->{vc} eq 'customer') { $buysell = "buy"; } else { @@ -477,40 +221,115 @@ sub update { } # if we switched to all_vc + # funktioniert derzeit nicht 12.10.2010 jb if ($form->{all_vc} ne $form->{oldall_vc}) { $form->{openinvoices} = ($form->{all_vc}) ? 0 : 1; - + $form->{"select$form->{vc}"} = ""; if ($form->{all_vc}) { $form->all_vc(\%myconfig, $form->{vc}, $form->{ARAP}); - + if ($form->{"all_$form->{vc}"}) { - map { $form->{"select$form->{vc}"} .= "