X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fcp.pl;h=9b77e5766b1a7b8f273429fbb7bcb36d65c67dbf;hb=2a0cbd885790174fa0f212e6661b30362650a42c;hp=d341ffdfc89855cc80c9f3f9e5b8622b32fad9b8;hpb=57eb13371bb3387afbef6ffa4cb71dd9d9f9e33e;p=kivitendo-erp.git diff --git a/bin/mozilla/cp.pl b/bin/mozilla/cp.pl index d341ffdfc..9b77e5766 100644 --- a/bin/mozilla/cp.pl +++ b/bin/mozilla/cp.pl @@ -24,7 +24,8 @@ # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +# MA 02110-1335, USA. #====================================================================== # # Payment module @@ -32,14 +33,15 @@ #====================================================================== use SL::CP; -use SL::OP; use SL::IS; use SL::IR; - -use strict ("vars", "subs"); +use SL::AR; +use SL::AP; +use Data::Dumper; +use SL::Locale::String qw(t8); +use strict; #use warnings; -require "bin/mozilla/arap.pl"; require "bin/mozilla/common.pl"; our ($form, %myconfig, $lxdebug, $locale, $auth); @@ -58,54 +60,37 @@ sub payment { $form->{ARAP} = ($form->{type} eq 'receipt') ? "AR" : "AP"; $form->{arap} = lc $form->{ARAP}; - # setup customer/vendor selection for open invoices - if ($form->{all_vc}) { - $form->all_vc(\%myconfig, $form->{vc}, $form->{ARAP}); - } else { - CP->get_openvc(\%myconfig, \%$form); - } - - $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"; + $form->{account} = "$_->{accno}--$_->{description}" if ($_->{accno} eq $accno_arap) } @{ $form->{PR}{"$form->{ARAP}_paid"} }; # currencies - @curr = split(/:/, $form->{currencies}); - chomp $curr[0]; + # oldcurrency ist zwar noch hier als fragment enthalten, wird aber bei + # der aktualisierung der form auch nicht mitübernommen. das konzept + # old_$FOO habe ich auch noch nicht verstanden ... + # Ok. Wenn currency übernommen werden, dann in callback-string über- + # geben und hier reinparsen, oder besser multibox oder html auslagern? + # Antwort: form->currency wird mit oldcurrency oder curr[0] überschrieben + # Wofür macht das Sinn? + @curr = $form->get_all_currencies(); $form->{defaultcurrency} = $form->{currency} = $form->{oldcurrency} = - $curr[0]; + $form->get_default_currency(\%myconfig); + # Entsprechend präventiv die Auswahlliste für Währungen + # auch mit value= zusammenbauen (s.a. oben bugfix 1771) $form->{selectcurrency} = ""; - map { $form->{selectcurrency} .= "\n" } @curr; - $form->{media} = "screen"; &form_header; &form_footer; @@ -114,401 +99,75 @@ sub payment { } sub form_header { - $lxdebug->enter_sub(); + $lxdebug->enter_sub; $auth->assert('cash'); - my ($vc, $vclabel, $allvc, $arap, $department, $exchangerate); - my ($jsscript, $button1, $button2, $onload); - - $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"; - } + $::request->layout->add_javascripts("kivi.CustomerVendor.js"); - # $locale->text('Customer') - # $locale->text('Vendor') + my ($arap, $exchangerate); - if ($form->{ $form->{vc} } eq "") { + if (!$form->{ $form->{vc} . '_id' }) { 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}> - -|; - } - } - - foreach my $item ($form->{vc}, "account", "currency", $form->{ARAP}, "department") { + # bugfix 1771 + # geändert von + # offen: $form->{ARAP} kann raus? + for my $item ("account", "currency", $form->{ARAP}) { + $form->{$item} = H($form->{$item}); $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}}">|; - - if ($form->{all_vc}) { - $allvc = "checked"; - $form->{openinvoices} = ""; - } else { - $allvc = ""; - $form->{openinvoices} = 1; - } + $form->{openinvoices} = 1; # $locale->text('AR') # $locale->text('AP') - $department = qq| - - | . $locale->text('Department') . qq| - - - - - -| if $form->{selectdepartment}; - - $form->{jsscript} = 1; - $jsscript = ""; - if ($form->{jsscript}) { - - # with JavaScript Calendar - $button1 = qq| - - text('button') . qq|> - |; - - #write Trigger - $jsscript = - Form->write_trigger(\%myconfig, "1", "datepaid", "BL", "trigger1"); - } else { + setup_cp_form_action_bar(can_post => !!$form->{rowcount}); - # without JavaScript Calendar - $button1 = qq| - |; - } - $form->{javascript} .= qq||; $form->header; $arap = lc $form->{ARAP}; - $onload = qq|focus()|; - $onload .= qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|; - $onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|; - print qq| - - -
- -{defaultcurrency}> -{closedto}> -{vc}> -{type}> -{type}> - - -{ARAP}> -{openinvoices}> - - - - - - - - - - - - -$jsscript -|; - $lxdebug->leave_sub(); + print $::form->parse_html_template('cp/form_header', { + is_customer => $form->{vc} eq 'customer', + is_receipt => $form->{type} eq 'receipt', + arap => $arap, + }); + + $lxdebug->leave_sub; } sub list_invoices { - $lxdebug->enter_sub(); - - $auth->assert('cash'); - - my (@column_index, %column_data, $colspan, $invoice); - my ($totalamount, $totaldue, $totalpaid); - - @column_index = qw(invnumber transdate amount due checked paid); - - $colspan = $#column_index + 1; - - $invoice = $locale->text('Invoices'); - - print qq| - - - - -|; + print $::form->parse_html_template('cp/invoices', { + invoices => \@invoices, + totals => \%total, + }); - $lxdebug->leave_sub(); + $::lxdebug->leave_sub; } sub form_footer { - $lxdebug->enter_sub(); - - $auth->assert('cash'); - - my ($media, $format, $latex_templates); - - $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 - - - - - - - $button1 - - - - - - {oldcurrency}> - - $exchangerate - - - - - - - - -
| . $locale->text('Account') . qq| - -
| . $locale->text('Date') . qq|
| . $locale->text('Currency') . qq|
| . $locale->text('Source') . qq|
| . $locale->text('Amount') . 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 my $i (1 .. $form->{rowcount}) { - - my $j = 0; - - 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 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}> - -
- -|; - - if ($latex_templates) { - print qq| -|; - } - - print qq| - - - -
+ $::lxdebug->enter_sub; + $::auth->assert('cash'); - - -|; + print $::form->parse_html_template('cp/form_footer'); - $lxdebug->leave_sub(); + $::lxdebug->leave_sub; } sub update { @@ -516,9 +175,7 @@ sub update { $auth->assert('cash'); - my ($new_name_selected) = @_; - - my ($buysell, $newvc, $updated, $exchangerate, $amount); + my ($buysell, $updated, $exchangerate, $amount); if ($form->{vc} eq 'customer') { $buysell = "buy"; @@ -526,65 +183,64 @@ sub update { $buysell = "sell"; } - # if we switched to all_vc - 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}"} .= - "