X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fcp.pl;h=9b77e5766b1a7b8f273429fbb7bcb36d65c67dbf;hb=24d1656ebd75cc1125b15b1c9727cae0fb4417d1;hp=d8890a10e95effad6be614cf9346da022226d164;hpb=4dbb09950c9f5596646537c12d991c99086fe7c1;p=kivitendo-erp.git diff --git a/bin/mozilla/cp.pl b/bin/mozilla/cp.pl index d8890a10e..9b77e5766 100644 --- a/bin/mozilla/cp.pl +++ b/bin/mozilla/cp.pl @@ -24,71 +24,73 @@ # 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 # #====================================================================== - use SL::CP; -use SL::OP; use SL::IS; use SL::IR; +use SL::AR; +use SL::AP; +use Data::Dumper; +use SL::Locale::String qw(t8); +use strict; +#use warnings; + +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(); - - $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]; - $form->{defaultcurrency} = $form->{currency} = $form->{oldcurrency} = $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} = + $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; @@ -96,630 +98,320 @@ 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"; - } + $::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 $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}}">|; + $form->{openinvoices} = 1; + + # $locale->text('AR') + # $locale->text('AP') + + setup_cp_form_action_bar(can_post => !!$form->{rowcount}); - 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, + }); - $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(); - + $::lxdebug->enter_sub; + $::auth->assert('cash'); - $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->leave_sub(); + $::lxdebug->leave_sub; } - sub update { $lxdebug->enter_sub(); - my ($new_name_selected) = @_; - - + $auth->assert('cash'); + + my ($buysell, $updated, $exchangerate, $amount); + if ($form->{vc} eq 'customer') { $buysell = "buy"; } else { $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}"} .= "