From 07ccbf8dde5208f1615447aece57a76dc049d8d0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Mon, 24 Oct 2011 15:43:55 +0200 Subject: [PATCH] cp templates. --- bin/mozilla/cp.pl | 375 +++---------------------- templates/webpages/cp/form_footer.html | 15 + templates/webpages/cp/form_header.html | 116 ++++++++ templates/webpages/cp/invoices.html | 35 +++ 4 files changed, 206 insertions(+), 335 deletions(-) create mode 100644 templates/webpages/cp/form_footer.html create mode 100644 templates/webpages/cp/form_header.html create mode 100644 templates/webpages/cp/invoices.html diff --git a/bin/mozilla/cp.pl b/bin/mozilla/cp.pl index 721a4a8cf..ea7e43084 100644 --- a/bin/mozilla/cp.pl +++ b/bin/mozilla/cp.pl @@ -36,7 +36,7 @@ use SL::IS; use SL::IR; use SL::AR; use SL::AP; -use strict ("vars", "subs"); +use strict; #use warnings; require "bin/mozilla/arap.pl"; @@ -118,55 +118,20 @@ sub payment { } sub form_header { - $lxdebug->enter_sub(); + $lxdebug->enter_sub; $auth->assert('cash'); - my ($vc, $vclabel, $allvc, $arap, $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"; - } - - # $locale->text('Customer') - # $locale->text('Vendor') + my ($vc, $arap, $exchangerate); + my ($onload); 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}> - -|; - } - } - foreach my $item ($form->{vc}, "account", "currency", $form->{ARAP}) { + 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>\Q$form->{$item}\E/option selected>$form->{$item}/; } $vc = @@ -174,310 +139,55 @@ sub form_header { ? qq|| : qq|{vc} size=35 value="$form->{$form->{vc}}">|; - if ($form->{all_vc}) { - $allvc = "checked"; - $form->{openinvoices} = ""; - } else { - $allvc = ""; - $form->{openinvoices} = 1; - } + $form->{openinvoices} = $form->{all_vc} ? "" : 1; # $locale->text('AR') # $locale->text('AP') - $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 { - - # 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 -|; - - if ($form->{openinvoices_other_currencies}) { - my $warning = $form->{vc} eq 'customer' ? $::locale->text('There are #1 more open invoices for this customer with other currencies.', $form->{openinvoices_other_currencies}) - : $::locale->text('There are #1 more open invoices from this vendor with other currencies.', $form->{openinvoices_other_currencies}); - - print qq| - - - - - -|; - } - $lxdebug->leave_sub(); + print $::form->parse_html_template('cp/form_header', { + is_customer => $form->{vc} eq 'customer', + is_receipt => $form->{type} eq 'receipt', + onload => $onload, + arap => $arap, + vccontent => $vc, + }); + + $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(); + $::lxdebug->enter_sub; + $::auth->assert('cash'); - $auth->assert('cash'); - - print qq| - - - -
$form->{title}
- - - - - -
- - - - - {vc}"}) . qq|"> - {vc}_id"}) . qq|"> - {vc}"}) . qq|"> - - - - - - - - - - - - - - - - -
$vclabel$vc
| . $locale->text('Invoice Number') . qq| -
| . $locale->text('Address') . qq| - - - - - - - - - - - - - -
$form->{street}
$form->{zipcode}
$form->{city}
$form->{country}
-
| . $locale->text('Memo') . qq|
-
- - - - - - - - $button1 - - - - - - {oldcurrency}> - - $exchangerate - - - - - - - - -
| . $locale->text('Account') . qq| - -
| . $locale->text('Date') . qq|
| . $locale->text('Currency') . qq|
| . $locale->text('Source') . qq|
| . $locale->text('Amount') . qq|| . $form->format_amount(\%myconfig, $form->{amount}, 2) . qq|
-
-
| . $::locale->text('Note') . qq|: $warning
- - - - -|; - - $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}> - -
- - -
+ print $::form->parse_html_template('cp/form_footer'); - - -|; - - $lxdebug->leave_sub(); + $::lxdebug->leave_sub; } sub update { @@ -651,21 +361,16 @@ sub post { # Beim Aktualisieren wird das Konto übernommen # und jetzt auch Beleg und Datum - $form->{callback} = "cp.pl?action=payment&vc=$form->{vc}&type=$form->{type}&account=$form->{account}&$form->{currency}" . + $form->{callback} = "cp.pl?action=payment&vc=$form->{vc}&type=$form->{type}&account=$form->{account}&$form->{currency}" . "&datepaid=$form->{datepaid}&source=$form->{source}"; - my $msg1 = "$form->{origtitle} posted!"; - my $msg2 = "Cannot post $form->{origtitle}!"; + my $msg1 = $::form->{type} eq 'receipt' ? $::locale->text("Receipt posted!") : $::locale->text("Payment posted!"); + my $msg2 = $::form->{type} eq 'receipt' ? $::locale->text("Cannot post Receipt!") : $::locale->text("Cannot post Payment!"); - # $locale->text('Payment posted!') - # $locale->text('Receipt posted!') - # $locale->text('Cannot post Payment!') - # $locale->text('Cannot post Receipt!') # Die Nachrichten (Receipt posted!) werden nicht angezeigt. # Entweder wieder aktivieren oder komplett rausnehmen - $form->redirect($locale->text($msg1)) - if (CP->process_payment(\%myconfig, \%$form)); - $form->error($locale->text($msg2)); + $form->redirect($msg1) if (CP->process_payment(\%::myconfig, $::form)); + $form->error($msg2); $lxdebug->leave_sub(); } @@ -684,7 +389,7 @@ sub check_form { ::end_of_request(); } $form->error($locale->text('Date missing!')) unless $form->{datepaid}; - my $selected_check = 1; + my $selected_check = 1; for my $i (1 .. $form->{rowcount}) { if ($form->{"checked_$i"}) { if ($form->parse_amount(\%myconfig, $form->{"paid_$i"}, 2) <= 0) { # negativen Betrag eingegeben @@ -692,7 +397,7 @@ sub check_form { } undef($selected_check); # last; # ich muss doch über alle buchungen laufen, da ich noch - # die freitext-eingabe der werte prüfen will + # die freitext-eingabe der werte prüfen will } } $form->error($locale->text('No transaction selected!')) if $selected_check; diff --git a/templates/webpages/cp/form_footer.html b/templates/webpages/cp/form_footer.html new file mode 100644 index 000000000..91976467b --- /dev/null +++ b/templates/webpages/cp/form_footer.html @@ -0,0 +1,15 @@ +[%- USE T8 %] +[%- USE HTML %] + +
+ + + + +
+ + + + + + diff --git a/templates/webpages/cp/form_header.html b/templates/webpages/cp/form_header.html new file mode 100644 index 000000000..368f077f6 --- /dev/null +++ b/templates/webpages/cp/form_header.html @@ -0,0 +1,116 @@ +[%- USE L %] +[%- USE HTML %] +[%- USE T8 %] +[%- USE LxERP %] + + +
+ +[% L.hidden_tag('defaultcurrency', defaultcurrency) %] +[% L.hidden_tag('closedto', closedto) %] +[% L.hidden_tag('vc', vc) %] +[% L.hidden_tag('type', type) %] +[% L.hidden_tag('formname', type) %] +[% L.hidden_tag('queued', queued) %] +[% L.hidden_tag('arap', arap) %] +[% L.hidden_tag('ARAP', ARAP) %] +[% L.hidden_tag('openinvoices', openinvoices) %] + +

[% is_receipt ? LxERP.t8('Receipt') : LxERP.t8('Payment') %]

+ + + + + + +
+ + + + + [% IF vc == 'customer' %] + [% L.hidden_tag('selectcustomer', selectcustomer) %] + [% L.hidden_tag('customer_id', customer_id) %] + [% L.hidden_tag('oldcustomer', oldcustomer) %] + [% ELSE %] + [% L.hidden_tag('selectvendor', selectvendor) %] + [% L.hidden_tag('vendor_id', vendor_id) %] + [% L.hidden_tag('oldvendor', oldvendor) %] + [% END %] + + + + + + + + + + + + +
[% is_customer ? LxERP.t8('Customer') : LxERP.t8('Vendor') %][% vccontent %]
[% 'Invoice Number' | $T8 %] +
[% 'Address' | $T8 %] + + + + + + + + + + + + + +
[% street | html %][% L.hidden_tag('street', street) %]
[% zipcode | html %][% L.hidden_tag('zipcode', zipcode) %]
[% city | html %][% L.hidden_tag('city', city) %]
[% country | html %][% L.hidden_tag('country', country) %]
+
[% 'Memo' | $T8 %]
+
+ + + + + + + + + + + + + + + +[% IF currency != defaultcurrency %] + + +[% IF forex %] + +[%- ELSE %] + +[%- END %] + +[% END %] + + + + + + + + +
[% 'Account' | $T8 %] + +
[% 'Date' | $T8 %][% L.date_tag('datepaid', datepaid) %]
[% 'Currency' | $T8 %]
[% 'Exchangerate' | $T8 %][% LxERP.format_amount(exchangerate) %][% L.hidden_tag('exchangerate', LxERP.format_amount(exchangerate)) %][% L.input_tag('exchangerate', LxERP.format_amount(exchangerate), size=10) %]
[% 'Source' | $T8 %]
[% 'Amount' | $T8 %][% LxERP.format_amount(amount, 2) %]
+
+ +[% IF openinvoices_other_currencies %] + + [% 'Note' | $T8 %]: + [%- IF is_customer %] + [% LxERP.t8('There are #1 more open invoices for this customer with other currencies.', openinvoices_other_currencies) %] + [%- ELSE %] + [% LxERP.t8('There are #1 more open invoices from this vendor with other currencies.', openinvoices_other_currencies) %] + [%- END %] +[% END %] diff --git a/templates/webpages/cp/invoices.html b/templates/webpages/cp/invoices.html new file mode 100644 index 000000000..4565f355e --- /dev/null +++ b/templates/webpages/cp/invoices.html @@ -0,0 +1,35 @@ +[%- USE T8 %] +[%- USE HTML %] +[%- USE L %] +[%- USE LxERP %] + + + + + + + + + + + + +[%- FOREACH row = invoices %] + + + + + + + + +[%- END %] + + + + + + + + +
[% 'Invoices' | $T8 %]
[% 'Invoice' | $T8 %][% 'Date' | $T8 %][% 'Amount' | $T8 %][% 'Due' | $T8 %][% 'Select' | $T8 %][% 'Amount' | $T8 %]
[% row.invnumber | html %][% L.hidden_tag('invnumber_' _ loop.count, row.invnumber); L.hidden_tag('id_' _ loop.count, row.id) %][% row.transdate | html %][% L.hidden_tag('transdate_' _ loop.count, row.transdate) %][% LxERP.format_amount(row.amount, 2) %][% L.hidden_tag('amount_' _ loop.count, LxERP.format_amount(row.amount, 2)) %][% LxERP.format_amount(row.due, 2) %][% L.hidden_tag('due_' _ loop.count, LxERP.format_amount(row.due, 2)) %][% L.checkbox_tag('checked_' _ loop.count, checked=row.checked) %][% L.input_tag('paid_' _ loop.count, LxERP.format_amount(row.paid, 2), size=10) %]
  [% LxERP.format_amount(totals.amount, 2) %][% LxERP.format_amount(totals.due, 2) %] [% LxERP.format_amount(totals.paid, 2) %]
-- 2.20.1