From: Sven Schöling Date: Wed, 25 Jan 2012 11:40:55 +0000 (+0100) Subject: am/buchungsgruppen_header auf template umgeschrieben X-Git-Tag: release-2.7.0beta1~19 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=da311bca6dc1e57ed00c251fbec0141aac27f579;p=kivitendo-erp.git am/buchungsgruppen_header auf template umgeschrieben --- diff --git a/bin/mozilla/am.pl b/bin/mozilla/am.pl index 8f01265ad..0672e7c39 100644 --- a/bin/mozilla/am.pl +++ b/bin/mozilla/am.pl @@ -847,150 +847,39 @@ sub list_buchungsgruppe { } sub buchungsgruppe_header { - $main::lxdebug->enter_sub(); - - my $form = $main::form; - my $locale = $main::locale; - - $main::auth->assert('config'); - - $form->{title} = $locale->text("$form->{title} Buchungsgruppe"); + $::lxdebug->enter_sub; + $::auth->assert('config'); # $locale->text('Add Accounting Group') # $locale->text('Edit Accounting Group') + $::form->{title} = $::locale->text("$::form->{title} Buchungsgruppe"); my ($acc_inventory, $acc_income, $acc_expense) = ({}, {}, {}); my %acc_type_map = ( - "IC" => $acc_inventory, - "IC_income" => $acc_income, - "IC_sale" => $acc_income, - "IC_expense" => $acc_expense, - "IC_cogs" => $acc_expense, - ); + IC => $acc_inventory, + IC_income => $acc_income, + IC_sale => $acc_income, + IC_expense => $acc_expense, + IC_cogs => $acc_expense, + ); - foreach my $key (keys(%acc_type_map)) { - foreach my $ref (@{ $form->{IC_links}{$key} }) { - $acc_type_map{$key}->{$ref->{"id"}} = $ref; + for my $key (keys %acc_type_map) { + for my $ref (@{ $::form->{IC_links}{$key} }) { + $acc_type_map{$key}{$ref->{id}} = $ref; } } - foreach my $type (qw(IC IC_income IC_expense)) { - $form->{"select$type"} = - join("", - map({ "" } - sort({ $a->{"accno"} cmp $b->{"accno"} } - values(%{$acc_type_map{$type}})))); - } - - if ($form->{id}) { - $form->{selectIC} =~ s/selected//g; - $form->{selectIC} =~ s/ value=\Q$form->{inventory_accno_id}\E/ value=$form->{inventory_accno_id} selected/; - $form->{selectIC_income} =~ s/selected//g; - $form->{selectIC_income} =~ s/ value=\Q$form->{income_accno_id_0}\E/ value=$form->{income_accno_id_0} selected/; - $form->{selectIC_expense} =~ s/selected//g; - $form->{selectIC_expense} =~ s/ value=\Q$form->{expense_accno_id_0}\E/ value=$form->{expense_accno_id_0} selected/; - } - - my $linkaccounts; - if ( $::instance_conf->get_inventory_system eq 'perpetual' ) { # was !$::lx_office_conf{system}->{eur}) { } - $linkaccounts = qq| - - | . $locale->text('Inventory') . qq| - - - |; - } elsif ( $::instance_conf->get_inventory_system eq 'periodic' ) { - # don't allow choice of inventory accno and don't show that line - $linkaccounts = qq| - {inventory_accno_id}>|; - }; - - - $linkaccounts .= qq| - - | . $locale->text('National Revenues') . qq| - - - - | . $locale->text('National Expenses') . qq| - - |; - if ($form->{id}) { - $form->{selectIC_income} =~ s/selected//g; - $form->{selectIC_income} =~ s/ value=\Q$form->{income_accno_id_1}\E/ value=$form->{income_accno_id_1} selected/; - $form->{selectIC_expense} =~ s/selected//g; - $form->{selectIC_expense} =~ s/ value=\Q$form->{expense_accno_id_1}\E/ value=$form->{expense_accno_id_1} selected/; - } - $linkaccounts .= qq| - | . $locale->text('Revenues EU with UStId') . qq| - - - - | . $locale->text('Expenses EU with UStId') . qq| - - |; - - if ($form->{id}) { - $form->{selectIC_income} =~ s/selected//g; - $form->{selectIC_income} =~ s/ value=\Q$form->{income_accno_id_2}\E/ value=$form->{income_accno_id_2} selected/; - $form->{selectIC_expense} =~ s/selected//g; - $form->{selectIC_expense} =~ s/ value=\Q$form->{expense_accno_id_2}\E/ value=$form->{expense_accno_id_2} selected/; - } - - $linkaccounts .= qq| - | . $locale->text('Revenues EU without UStId') . qq| - - - - | . $locale->text('Expenses EU without UStId') . qq| - - |; - - if ($form->{id}) { - $form->{selectIC_income} =~ s/selected//g; - $form->{selectIC_income} =~ s/ value=\Q$form->{income_accno_id_3}\E/ value=$form->{income_accno_id_3} selected/; - $form->{selectIC_expense} =~ s/selected//g; - $form->{selectIC_expense} =~ s/ value=\Q$form->{expense_accno_id_3}\E/ value=$form->{expense_accno_id_3} selected/; - } - - $linkaccounts .= qq| - | . $locale->text('Foreign Revenues') . qq| - - - - | . $locale->text('Foreign Expenses') . qq| - - -|; - - - $form->header; - - print qq| - - -
+ my %sorted_accounts = map { + $_ => [ sort { $a->{accno} cmp $b->{accno} } values %{ $acc_type_map{$_} } ], + } keys %acc_type_map; -{id}> - - - - - - - - - - - - $linkaccounts - - -
$form->{title}
| . $locale->text('Buchungsgruppe') . qq|

-|; + $::form->header; + print $::form->parse_html_template('am/buchungsgruppe_header', { + accounts => \%sorted_accounts, + account_label => sub { "$_[0]{accno}--$_[0]{description}" }, + }); - $main::lxdebug->leave_sub(); + $::lxdebug->leave_sub; } sub save_buchungsgruppe { diff --git a/templates/webpages/am/buchungsgruppe_header.html b/templates/webpages/am/buchungsgruppe_header.html new file mode 100644 index 000000000..59c311069 --- /dev/null +++ b/templates/webpages/am/buchungsgruppe_header.html @@ -0,0 +1,63 @@ +[%- USE HTML %] +[%- USE L %] +[%- USE LxERP %] +[%- USE T8 %] + + +

[% title | html %]

+ + + + + + + + + + + +[%- IF INSTANCE_CONF.get_inventory_system == 'perpetual' %] + + + + +[%- ELSE %] + + + +[%- END %] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
[% 'Buchungsgruppe' | $T8 %]
[% 'Inventory' | $T8 %][% L.select_tag('inventory_accno_id', L.options_for_select(accounts.IC, title_sub=\account_label, default=invetory_accno_id)) %]
[% L.hidden_tag('inventory_accno_id', inventory_accno_id) %]
[% 'National Revenues' | $T8 %][% L.select_tag('income_accno_id_0', L.options_for_select(accounts.IC_income, title_sub=\account_label, default=income_accno_id_0)) %]
[% 'National Expenses' | $T8 %][% L.select_tag('expense_accno_id_0', L.options_for_select(accounts.IC_expense, title_sub=\account_label, default=expense_accno_id_0)) %]
[% 'Revenues EU with UStId' | $T8 %][% L.select_tag('income_accno_id_1', L.options_for_select(accounts.IC_income, title_sub=\account_label, default=income_accno_id_1)) %]
[% 'Expenses EU with UStId' | $T8 %][% L.select_tag('expense_accno_id_1', L.options_for_select(accounts.IC_expense, title_sub=\account_label, default=expense_accno_id_1)) %]
[% 'Revenues EU without UStId' | $T8 %][% L.select_tag('income_accno_id_2', L.options_for_select(accounts.IC_income, title_sub=\account_label, default=income_accno_id_2)) %]
[% 'Expenses EU without UStId' | $T8 %][% L.select_tag('expense_accno_id_2', L.options_for_select(accounts.IC_expense, title_sub=\account_label, default=expense_accno_id_2)) %]
[% 'Foreign Revenues' | $T8 %][% L.select_tag('income_accno_id_3', L.options_for_select(accounts.IC_income, title_sub=\account_label, default=income_accno_id_3)) %]
[% 'Foreign Expenses' | $T8 %][% L.select_tag('expense_accno_id_3', L.options_for_select(accounts.IC_expense, title_sub=\account_label, default=expense_accno_id_3)) %]