X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fam.pl;h=500547597816ee5a1f0bd441d284ffec3736e242;hb=10687edafbc052375683d65e36ce42b4586f7240;hp=c6586af5bd47e031afcce7a550a56be1e95dd214;hpb=32fc2e889d08ec0bba083bdbde271e131357a829;p=kivitendo-erp.git diff --git a/bin/mozilla/am.pl b/bin/mozilla/am.pl index c6586af5b..500547597 100644 --- a/bin/mozilla/am.pl +++ b/bin/mozilla/am.pl @@ -34,6 +34,7 @@ use utf8; use SL::Auth; +use SL::Auth::PasswordPolicy; use SL::AM; use SL::CA; use SL::Form; @@ -42,11 +43,8 @@ use SL::USTVA; use SL::Iconv; use SL::TODO; use SL::Printer; -use CGI::Ajax; use CGI; -use Data::Dumper; - require "bin/mozilla/common.pl"; use strict; @@ -330,31 +328,31 @@ sub account_header { } # preselection chart type - my $select_charttype = q{}; - - my %charttype = ( - 'A' => $locale->text('Account'), - 'H' => $locale->text('Heading'), - ); + my @all_charttypes = ({'name' => $locale->text('Account'), 'value' => 'A'}, + {'name' => $locale->text('Heading'), 'value' => 'H'}, + ); + my $selected_charttype = $form->{charttype}; - foreach my $item ( sort({ $a <=> $b } keys %charttype) ) { - if ($item eq $form->{charttype}) { - $select_charttype .= qq||; - foreach my $item (('1,000.00', '1000.00', '1.000,00', '1000,00')) { - $numberformat .= - ($item eq $form->{output_numberformat}) - ? ""; - } - - my $dateformat = - qq||; - foreach my $item (qw(mm-dd-yy mm/dd/yy dd-mm-yy dd/mm/yy dd.mm.yy yyyy-mm-dd)) { - $dateformat .= - ($item eq $form->{output_dateformat}) - ? ""; - } - - print qq| - - -
- -{id}> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
$form->{title}
| . $locale->text('Language') . qq|
| . $locale->text('Template Code') . qq|
| . $locale->text('Article Code') . qq|
| . $locale->text('Number Format') . qq|
| . $locale->text('Date Format') . qq|
| . $locale->text('Long Dates') . qq|{output_longdates} ? " checked" : "") . - qq|>| . $locale->text("Yes") . - qq|{output_longdates} ? "" : " checked") . - qq|>| . $locale->text("No") . - qq|

-|; - - $main::lxdebug->leave_sub(); -} - -sub save_language { - $main::lxdebug->enter_sub(); - - my $form = $main::form; - my %myconfig = %main::myconfig; - my $locale = $main::locale; - - $main::auth->assert('config'); - - $form->isblank("description", $locale->text('Language missing!')); - $form->isblank("template_code", $locale->text('Template Code missing!')); - $form->isblank("article_code", $locale->text('Article Code missing!')); - AM->save_language(\%myconfig, \%$form); - $form->redirect($locale->text('Language saved!')); - - $main::lxdebug->leave_sub(); -} - -sub delete_language { - $main::lxdebug->enter_sub(); - - my $form = $main::form; - my %myconfig = %main::myconfig; - my $locale = $main::locale; - - $main::auth->assert('config'); - - AM->delete_language(\%myconfig, \%$form); - $form->redirect($locale->text('Language deleted!')); - - $main::lxdebug->leave_sub(); -} - - -sub add_buchungsgruppe { - $main::lxdebug->enter_sub(); - - my $form = $main::form; - my %myconfig = %main::myconfig; - my $locale = $main::locale; - - $main::auth->assert('config'); - - # $locale->text("Add Buchungsgruppe") - # $locale->text("Edit Buchungsgruppe") - $form->{title} = "Add"; - - $form->{callback} = "am.pl?action=add_buchungsgruppe" unless $form->{callback}; - - AM->get_buchungsgruppe(\%myconfig, \%$form); - $form->{"inventory_accno_id"} = $form->{"std_inventory_accno_id"}; - for (my $i = 0; 4 > $i; $i++) { - map({ $form->{"${_}_accno_id_$i"} = $form->{"std_${_}_accno_id"}; } - qw(income expense)); - } - - &buchungsgruppe_header; - &form_footer; - - $main::lxdebug->leave_sub(); -} - -sub edit_buchungsgruppe { - $main::lxdebug->enter_sub(); - - my $form = $main::form; - my %myconfig = %main::myconfig; - - $main::auth->assert('config'); - - $form->{title} = "Edit"; - - AM->get_buchungsgruppe(\%myconfig, \%$form); - - &buchungsgruppe_header; - - &form_footer; - - $main::lxdebug->leave_sub(); -} - -sub list_buchungsgruppe { - $main::lxdebug->enter_sub(); - - my $form = $main::form; - my %myconfig = %main::myconfig; - my $locale = $main::locale; - - $main::auth->assert('config'); - - AM->buchungsgruppe(\%myconfig, \%$form); - - $form->{callback} = "am.pl?action=list_buchungsgruppe"; - - my $callback = $form->escape($form->{callback}); - - $form->{title} = $locale->text('Buchungsgruppen'); - - my @column_index = qw(up down description inventory_accno - income_accno_0 expense_accno_0 - income_accno_1 expense_accno_1 - income_accno_2 expense_accno_2 - income_accno_3 expense_accno_3 ); - my %column_header; - $column_header{up} = - qq|| - . qq|| . $locale->text(| - . qq||; - $column_header{down} = - qq|| - . qq|| . $locale->text(| - . qq||; - $column_header{description} = - qq|| - . $locale->text('Description') - . qq||; - $column_header{inventory_accno} = - qq|| - . $locale->text('Bestandskonto') - . qq||; - $column_header{income_accno_0} = - qq|| - . $locale->text('National Revenues') - . qq||; - $column_header{expense_accno_0} = - qq|| - . $locale->text('National Expenses') - . qq||; - $column_header{income_accno_1} = - qq|| - . $locale->text('Revenues EU with UStId') - . qq||; - $column_header{expense_accno_1} = - qq|| - . $locale->text('Expenses EU with UStId') - . qq||; - $column_header{income_accno_2} = - qq|| - . $locale->text('Revenues EU without UStId') - . qq||; - $column_header{expense_accno_2} = - qq|| - . $locale->text('Expenses EU without UStId') - . qq||; - $column_header{income_accno_3} = - qq|| - . $locale->text('Foreign Revenues') - . qq||; - $column_header{expense_accno_3} = - qq|| - . $locale->text('Foreign Expenses') - . qq||; - $form->header; - - print qq| - - - - - - - - - - - - - -
$form->{title}
- - -|; - - map { print "$column_header{$_}\n" } @column_index; - - print qq| - -|; - - my $swap_link = qq|am.pl?action=swap_buchungsgruppen&|; - - my $row = 0; - my ($i, %column_data); - foreach my $ref (@{ $form->{ALL} }) { - - $i++; - $i %= 2; - - print qq| - -|; - - if ($row) { - my $pref = $form->{ALL}->[$row - 1]; - $column_data{up} = - qq||; - } else { - $column_data{up} = qq||; - } - - if ($row == (scalar(@{ $form->{ALL} }) - 1)) { - $column_data{down} = qq||; - } else { - my $nref = $form->{ALL}->[$row + 1]; - $column_data{down} = - qq||; - } - - $column_data{description} = qq||; - $column_data{inventory_accno} = qq||; - $column_data{income_accno_0} = - qq||; - $column_data{expense_accno_0} = qq||; - $column_data{income_accno_1} = - qq||; - $column_data{expense_accno_1} = qq||; - $column_data{income_accno_2} = - qq||; - $column_data{expense_accno_2} = qq||; - $column_data{income_accno_3} = - qq||; - $column_data{expense_accno_3} = qq||; - - map { print "$column_data{$_}\n" } @column_index; - - print qq| - -|; - - $row++; + foreach my $id ( + qw(inventory_accno_id income_accno_id expense_accno_id fxgain_accno_id fxloss_accno_id) + ) { + if ($form->{id} == $form->{$id}) { + $form->error($locale->text('Cannot delete default account!')); + } } - print qq| -
| . - qq|| . - qq|| . $locale->text(| . - qq|  | . - qq|| . - qq|| . $locale->text(| . - qq|$ref->{description}$ref->{inventory_accno}$ref->{income_accno_0}$ref->{expense_accno_0}$ref->{income_accno_1}$ref->{expense_accno_1}$ref->{income_accno_2}$ref->{expense_accno_2}$ref->{income_accno_3}$ref->{expense_accno_3}
-

+ $form->redirect($locale->text('Account deleted!')) + if (AM->delete_account(\%myconfig, \%$form)); + $form->error($locale->text('Cannot delete account!')); + + $main::lxdebug->leave_sub(); +} -
- +sub add_lead { + $main::lxdebug->enter_sub(); - + my $form = $main::form; - + $main::auth->assert('config'); - + $form->{title} = "Add"; -
+ $form->{callback} = "am.pl?action=add_lead" unless $form->{callback}; - - -|; + &lead_header; + &form_footer; $main::lxdebug->leave_sub(); } -sub buchungsgruppe_header { +sub edit_lead { $main::lxdebug->enter_sub(); my $form = $main::form; - my $locale = $main::locale; + my %myconfig = %main::myconfig; $main::auth->assert('config'); - $form->{title} = $locale->text("$form->{title} Buchungsgruppe"); - - # $locale->text('Add Accounting Group') - # $locale->text('Edit Accounting Group') + $form->{title} = "Edit"; - 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, - ); + AM->get_lead(\%myconfig, \%$form); - foreach my $key (keys(%acc_type_map)) { - foreach my $ref (@{ $form->{IC_links}{$key} }) { - $acc_type_map{$key}->{$ref->{"id"}} = $ref; - } - } + &lead_header; - 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}})))); - } + $form->{orphaned} = 1; + &form_footer; - 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/; - } + $main::lxdebug->leave_sub(); +} - my $linkaccounts; - if (!$main::eur) { - $linkaccounts = qq| - - | . $locale->text('Inventory') . qq| - - - |; - } else { - $linkaccounts = qq| - {inventory_accno_id}>|; - } +sub list_lead { + $::lxdebug->enter_sub; + $::auth->assert('config'); + AM->lead(\%::myconfig, $::form); - $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/; - } + $::form->{callback} = "am.pl?action=list_lead"; + $::form->{title} = $::locale->text('Lead'); - $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/; - } + $::form->header; + print $::form->parse_html_template('am/lead_list'); - $linkaccounts .= qq| - | . $locale->text('Foreign Revenues') . qq| - - - - | . $locale->text('Foreign Expenses') . qq| - - -|; + $::lxdebug->leave_sub; +} +sub lead_header { + $::lxdebug->enter_sub; + $::auth->assert('config'); - $form->header; + # $locale->text('Add Lead') + # $locale->text('Edit Lead') + $::form->{title} = $::locale->text("$::form->{title} Lead"); - print qq| - - -
- -{id}> - - - - - - - - - - - - $linkaccounts - - -
$form->{title}
| . $locale->text('Buchungsgruppe') . qq|

-|; + $::form->header; + print $::form->parse_html_template('am/lead_header'); - $main::lxdebug->leave_sub(); + $::lxdebug->leave_sub; } -sub save_buchungsgruppe { +sub save_lead { $main::lxdebug->enter_sub(); my $form = $main::form; @@ -1981,14 +652,13 @@ sub save_buchungsgruppe { $main::auth->assert('config'); $form->isblank("description", $locale->text('Description missing!')); - - AM->save_buchungsgruppe(\%myconfig, \%$form); - $form->redirect($locale->text('Accounting Group saved!')); + AM->save_lead(\%myconfig, \%$form); + $form->redirect($locale->text('lead saved!')); $main::lxdebug->leave_sub(); } -sub delete_buchungsgruppe { +sub delete_lead { $main::lxdebug->enter_sub(); my $form = $main::form; @@ -1997,27 +667,30 @@ sub delete_buchungsgruppe { $main::auth->assert('config'); - AM->delete_buchungsgruppe(\%myconfig, \%$form); - $form->redirect($locale->text('Accounting Group deleted!')); + AM->delete_lead(\%myconfig, \%$form); + $form->redirect($locale->text('lead deleted!')); $main::lxdebug->leave_sub(); } -sub swap_buchungsgruppen { +sub add_language { $main::lxdebug->enter_sub(); my $form = $main::form; - my %myconfig = %main::myconfig; $main::auth->assert('config'); - AM->swap_sortkeys(\%myconfig, $form, "buchungsgruppen"); - list_buchungsgruppe(); + $form->{title} = "Add"; + + $form->{callback} = "am.pl?action=add_language" unless $form->{callback}; + + &language_header; + &form_footer; $main::lxdebug->leave_sub(); } -sub add_payment { +sub edit_language { $main::lxdebug->enter_sub(); my $form = $main::form; @@ -2025,46 +698,71 @@ sub add_payment { $main::auth->assert('config'); - $form->{title} = "Add"; + $form->{title} = "Edit"; - $form->{callback} = "am.pl?action=add_payment" unless $form->{callback}; + AM->get_language(\%myconfig, \%$form); - $form->{terms_netto} = 0; - $form->{terms_skonto} = 0; - $form->{percent_skonto} = 0; - my @languages = AM->language(\%myconfig, $form, 1); - map({ $_->{"language"} = $_->{"description"}; - $_->{"language_id"} = $_->{"id"}; } @languages); - $form->{"TRANSLATION"} = \@languages; - &payment_header; + &language_header; + + $form->{orphaned} = 1; &form_footer; $main::lxdebug->leave_sub(); } -sub edit_payment { +sub list_language { + $::lxdebug->enter_sub; + $::auth->assert('config'); + + AM->language(\%::myconfig, $::form); + + $::form->{callback} = "am.pl?action=list_language"; + $::form->{title} = $::locale->text('Languages'); + + $::form->header; + + print $::form->parse_html_template('am/language_list'); + + $::lxdebug->leave_sub; +} + +sub language_header { + $::lxdebug->enter_sub; + $::auth->assert('config'); + + # $locale->text('Add Language') + # $locale->text('Edit Language') + $::form->{title} = $::locale->text("$::form->{title} Language"); + + $::form->header; + + print $::form->parse_html_template('am/language_header', { + numberformats => [ '1,000.00', '1000.00', '1.000,00', '1000,00' ], + dateformats => [ qw(mm/dd/yy dd/mm/yy dd.mm.yy yyyy-mm-dd) ], + }); + + $::lxdebug->leave_sub; +} + +sub save_language { $main::lxdebug->enter_sub(); my $form = $main::form; my %myconfig = %main::myconfig; + my $locale = $main::locale; $main::auth->assert('config'); - $form->{title} = "Edit"; - - AM->get_payment(\%myconfig, $form); - $form->{percent_skonto} = - $form->format_amount(\%myconfig, $form->{percent_skonto} * 100); - - &payment_header; - - $form->{orphaned} = 1; - &form_footer; + $form->isblank("description", $locale->text('Language missing!')); + $form->isblank("template_code", $locale->text('Template Code missing!')); + $form->isblank("article_code", $locale->text('Article Code missing!')); + AM->save_language(\%myconfig, \%$form); + $form->redirect($locale->text('Language saved!')); $main::lxdebug->leave_sub(); } -sub list_payment { +sub delete_language { $main::lxdebug->enter_sub(); my $form = $main::form; @@ -2073,267 +771,114 @@ sub list_payment { $main::auth->assert('config'); - AM->payment(\%myconfig, \%$form); - - $form->{callback} = build_std_url("action=list_payment"); - - my $callback = $form->escape($form->{callback}); - - $form->{title} = $locale->text('Payment Terms'); - - my @column_index = qw(up down description description_long terms_netto - terms_skonto percent_skonto); - my %column_header; - $column_header{up} = - qq|| - . qq|| . $locale->text(| - . qq||; - $column_header{down} = - qq|| - . qq|| . $locale->text(| - . qq||; - $column_header{description} = - qq|| - . $locale->text('Description') - . qq||; - $column_header{description_long} = - qq|| - . $locale->text('Long Description') - . qq||; - $column_header{terms_netto} = - qq|| - . $locale->text('Netto Terms') - . qq||; - $column_header{terms_skonto} = - qq|| - . $locale->text('Skonto Terms') - . qq||; - $column_header{percent_skonto} = - qq|| - . $locale->text('Skonto') - . qq| %|; + AM->delete_language(\%myconfig, \%$form); + $form->redirect($locale->text('Language deleted!')); - $form->header; + $main::lxdebug->leave_sub(); +} - print qq| - - - - - - - - - - - - -
$form->{title}
- - -|; +sub add_buchungsgruppe { + $main::lxdebug->enter_sub(); - map { print "$column_header{$_}\n" } @column_index; + my $form = $main::form; + my %myconfig = %main::myconfig; + my $locale = $main::locale; - print qq| - -|; + $main::auth->assert('config'); - my $swap_link = build_std_url("action=swap_payment_terms"); + # $locale->text("Add Buchungsgruppe") + # $locale->text("Edit Buchungsgruppe") + $form->{title} = "Add"; - my $row = 0; - my ($i, %column_data); - foreach my $ref (@{ $form->{ALL} }) { + $form->{callback} = "am.pl?action=add_buchungsgruppe" unless $form->{callback}; - $i++; - $i %= 2; - - print qq| - -|; - - if ($row) { - my $pref = $form->{ALL}->[$row - 1]; - $column_data{up} = - qq||; - } else { - $column_data{up} = qq||; - } + AM->get_buchungsgruppe(\%myconfig, \%$form); + $form->{"inventory_accno_id"} = $form->{"std_inventory_accno_id"}; + for (my $i = 0; 4 > $i; $i++) { + map({ $form->{"${_}_accno_id_$i"} = $form->{"std_${_}_accno_id"}; } + qw(income expense)); + } - if ($row == (scalar(@{ $form->{ALL} }) - 1)) { - $column_data{down} = qq||; - } else { - my $nref = $form->{ALL}->[$row + 1]; - $column_data{down} = - qq||; - } + &buchungsgruppe_header; + &form_footer; - $column_data{description} = - qq||; - $column_data{description_long} = - qq||; - $column_data{terms_netto} = - qq||; - $column_data{terms_skonto} = - qq||; - $column_data{percent_skonto} = - qq||; - map { print "$column_data{$_}\n" } @column_index; - - print qq| - -|; - $row++; - } + $main::lxdebug->leave_sub(); +} - print qq| -
| . - qq|| . - qq|| . $locale->text(| . - qq|  | . - qq|| . - qq|| . $locale->text(| . - qq|{id}", "callback=$callback") . - qq|">| . H($ref->{description}) . qq|| . H($ref->{description_long}) . qq|$ref->{terms_netto}$ref->{terms_skonto}| . - $form->format_amount(\%myconfig, $ref->{percent_skonto} * 100) . - qq|%
-

+sub edit_buchungsgruppe { + $main::lxdebug->enter_sub(); -
- + my $form = $main::form; + my %myconfig = %main::myconfig; - + $main::auth->assert('config'); - + $form->{title} = "Edit"; - + AM->get_buchungsgruppe(\%myconfig, \%$form); -
+ &buchungsgruppe_header; - - -|; + &form_footer; $main::lxdebug->leave_sub(); } -sub payment_header { - $main::lxdebug->enter_sub(); - - my $form = $main::form; - my $locale = $main::locale; +sub list_buchungsgruppe { + $::lxdebug->enter_sub; + $::auth->assert('config'); - $main::auth->assert('config'); + AM->buchungsgruppe(\%::myconfig, $::form); - $form->{title} = $locale->text("$form->{title} Payment Terms"); + $::form->{callback} = "am.pl?action=list_buchungsgruppe"; + $::form->{title} = $::locale->text('Buchungsgruppen'); + $::form->header; - # $locale->text('Add Payment Terms') - # $locale->text('Edit Payment Terms') + print $::form->parse_html_template('am/buchungsgruppe_list', { + swap_link => qq|am.pl?action=swap_buchungsgruppen&|, + }); - $form->{description} =~ s/\"/"/g; + $::lxdebug->leave_sub; +} +sub buchungsgruppe_header { + $::lxdebug->enter_sub; + $::auth->assert('config'); + # $locale->text('Add Accounting Group') + # $locale->text('Edit Accounting Group') + $::form->{title} = $::locale->text("$::form->{title} Buchungsgruppe"); - $form->header; + 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, + ); - print qq| - - -
- -{id}> - - - - - - - - - - - - - - - -|; - - foreach my $language (@{ $form->{"TRANSLATION"} }) { - print qq| - - - - -|; + for my $key (keys %acc_type_map) { + for my $ref (@{ $::form->{IC_links}{$key} }) { + $acc_type_map{$key}{$ref->{id}} = $ref; + } } - print qq| - - - - - - - - - - - - - - -
$form->{title}
| . $locale->text('Description') . qq|
| . $locale->text('Long Description') . qq|
| . - sprintf($locale->text('Translation (%s)'), - $language->{"language"}) - . qq|
| . $locale->text('Netto Terms') . qq|
| . $locale->text('Skonto Terms') . qq|
| . $locale->text('Skonto') . qq| %

- -

| . $locale->text("You can use the following strings in the long " . - "description and all translations. They will be " . - "replaced by their actual values by Lx-Office " . - "before they're output.") -. qq|

- -|; + my %sorted_accounts = map { + $_ => [ sort { $a->{accno} cmp $b->{accno} } values %{ $acc_type_map{$_} } ], + } keys %acc_type_map; - $main::lxdebug->leave_sub(); + $::form->header; + print $::form->parse_html_template('am/buchungsgruppe_header', { + accounts => \%sorted_accounts, + account_label => sub { "$_[0]{accno}--$_[0]{description}" }, + }); + + $::lxdebug->leave_sub; } -sub save_payment { +sub save_buchungsgruppe { $main::lxdebug->enter_sub(); my $form = $main::form; @@ -2343,15 +888,14 @@ sub save_payment { $main::auth->assert('config'); $form->isblank("description", $locale->text('Description missing!')); - $form->{"percent_skonto"} = - $form->parse_amount(\%myconfig, $form->{percent_skonto}) / 100; - AM->save_payment(\%myconfig, \%$form); - $form->redirect($locale->text('Payment Terms saved!')); + + AM->save_buchungsgruppe(\%myconfig, \%$form); + $form->redirect($locale->text('Accounting Group saved!')); $main::lxdebug->leave_sub(); } -sub delete_payment { +sub delete_buchungsgruppe { $main::lxdebug->enter_sub(); my $form = $main::form; @@ -2360,13 +904,13 @@ sub delete_payment { $main::auth->assert('config'); - AM->delete_payment(\%myconfig, \%$form); - $form->redirect($locale->text('Payment terms deleted!')); + AM->delete_buchungsgruppe(\%myconfig, \%$form); + $form->redirect($locale->text('Accounting Group deleted!')); $main::lxdebug->leave_sub(); } -sub swap_payment_terms { +sub swap_buchungsgruppen { $main::lxdebug->enter_sub(); my $form = $main::form; @@ -2374,8 +918,8 @@ sub swap_payment_terms { $main::auth->assert('config'); - AM->swap_sortkeys(\%myconfig, $form, "payment_terms"); - list_payment(); + AM->swap_sortkeys(\%myconfig, $form, "buchungsgruppen"); + list_buchungsgruppe(); $main::lxdebug->leave_sub(); } @@ -2393,6 +937,11 @@ sub edit_defaults { map { $form->{"defaults_${_}"} = $form->{defaults}->{$_} } keys %{ $form->{defaults} }; + # default language + my $all_languages = SL::DB::Manager::Language->get_all; + +# cash = IST-Versteuerung, accrual = SOLL-Versteuerung + foreach my $key (keys %{ $form->{IC} }) { foreach my $accno (sort keys %{ $form->{IC}->{$key} }) { my $array = "ACCNOS_" . uc($key); @@ -2410,7 +959,8 @@ sub edit_defaults { $form->{title} = $locale->text('Ranges of numbers and default accounts'); $form->header(); - print $form->parse_html_template('am/edit_defaults'); + print $form->parse_html_template('am/edit_defaults', + { ALL_LANGUAGES => $all_languages, }); $main::lxdebug->leave_sub(); } @@ -2452,24 +1002,25 @@ sub config { my %myconfig = %main::myconfig; my $locale = $main::locale; - _build_cfg_options('dateformat', qw(mm-dd-yy mm/dd/yy dd-mm-yy dd/mm/yy dd.mm.yy yyyy-mm-dd)); + _build_cfg_options('dateformat', qw(mm/dd/yy dd/mm/yy dd.mm.yy yyyy-mm-dd)); _build_cfg_options('numberformat', ('1,000.00', '1000.00', '1.000,00', '1000,00')); my @formats = (); - if ($main::opendocument_templates && $main::openofficeorg_writer_bin && - $main::xvfb_bin && (-x $main::openofficeorg_writer_bin) && (-x $main::xvfb_bin)) { + if ($::lx_office_conf{print_templates}->{opendocument} + && $::lx_office_conf{applications}->{openofficeorg_writer} && (-x $::lx_office_conf{applications}->{openofficeorg_writer}) + && $::lx_office_conf{applications}->{xvfb} && (-x $::lx_office_conf{applications}->{xvfb})) { push(@formats, { "name" => $locale->text("PDF (OpenDocument/OASIS)"), "value" => "opendocument_pdf" }); } - if ($main::latex_templates) { + if ($::lx_office_conf{print_templates}->{latex}) { push(@formats, { "name" => $locale->text("PDF"), "value" => "pdf" }); } push(@formats, { "name" => "HTML", "value" => "html" }); - if ($main::latex_templates) { + if ($::lx_office_conf{print_templates}->{latex}) { push(@formats, { "name" => $locale->text("Postscript"), "value" => "postscript" }); } - if ($main::opendocument_templates) { + if ($::lx_office_conf{print_templates}->{opendocument}) { push(@formats, { "name" => $locale->text("OpenDocument/OASIS"), "value" => "opendocument" }); } @@ -2497,14 +1048,7 @@ sub config { { 'name' => $locale->text('Queue'), 'value' => 'queue', 'selected' => $selected{queue}, }, ]; - $form->{PRINTERS} = []; - foreach my $printer (SL::Printer->all_printers(%::myconfig)) { - push @{ $form->{PRINTERS} }, { - 'name' => $printer->{printer_description}, - 'value' => $printer->{id}, - 'selected' => $printer->{id} == $myconfig{default_printer_id}, - }; - } + $form->{PRINTERS} = [ SL::Printer->all_printers(%::myconfig) ]; my %countrycodes = User->country_codes; @@ -2518,7 +1062,7 @@ sub config { } $form->{STYLESHEETS} = []; - foreach my $item (qw(lx-office-erp.css Win2000.css Mobile.css)) { + foreach my $item (qw(lx-office-erp.css Win2000.css Mobile.css kivitendo.css)) { push @{ $form->{STYLESHEETS} }, { 'name' => $item, 'value' => $item, @@ -2549,62 +1093,44 @@ sub save_preferences { TODO->save_user_config('login' => $form->{login}, %{ $form->{todo_cfg} || { } }); - $form->redirect($locale->text('Preferences saved!')) if (AM->save_preferences(\%myconfig, \%$form, 0)); - $form->error($locale->text('Cannot save preferences!')); - - $main::lxdebug->leave_sub(); -} - -sub audit_control { - $main::lxdebug->enter_sub(); - - my $form = $main::form; - my %myconfig = %main::myconfig; - my $locale = $main::locale; - - $main::auth->assert('config'); - - $form->{title} = $locale->text('Audit Control'); + if (AM->save_preferences(\%myconfig, $form)) { + if ($::auth->can_change_password() + && defined $form->{new_password} + && ($form->{new_password} ne '********')) { + my $verifier = SL::Auth::PasswordPolicy->new; + my $result = $verifier->verify($form->{new_password}); - AM->closedto(\%myconfig, \%$form); + if ($result != SL::Auth::PasswordPolicy->OK()) { + $form->error($::locale->text('The settings were saved, but the password was not changed.') . ' ' . join(' ', $verifier->errors($result))); + } - $form->header; + $::auth->change_password($form->{login}, $form->{new_password}); - print qq| - + $form->{password} = $form->{new_password}; + $::auth->set_session_value('password', $form->{password}); + $::auth->create_or_refresh_session(); + } - + $form->redirect($locale->text('Preferences saved!')); + } - - - - - - -
$form->{title}
- - - - - -
| . $locale->text('Close Books up to') . qq|{closedto}>
-
+ $form->error($locale->text('Cannot save preferences!')); -
+ $main::lxdebug->leave_sub(); +} -
- +sub audit_control { + $::lxdebug->enter_sub; + $::auth->assert('config'); - + $::form->{title} = $::locale->text('Audit Control'); -
+ AM->closedto(\%::myconfig, $::form); - - -|; + $::form->header; + print $::form->parse_html_template('am/audit_control'); - $main::lxdebug->leave_sub(); + $::lxdebug->leave_sub; } sub doclose { @@ -2665,15 +1191,13 @@ sub edit_units { $units = AM->retrieve_units(\%myconfig, $form); my $ddbox = AM->unit_select_data($units, undef, 1); - my $updownlink = build_std_url("action=swap_units"); - $form->{"title"} = $locale->text("Add and edit units"); $form->header(); print($form->parse_html_template("am/edit_units", { "UNITS" => \@unit_list, "NEW_BASE_UNIT_DDBOX" => $ddbox, "LANGUAGES" => \@languages, - "updownlink" => $updownlink })); + })); $main::lxdebug->leave_sub(); } @@ -2866,7 +1390,7 @@ sub show_am_history { my %searchNo = ( "Artikelnummer" => "partnumber", "Kundennummer" => "customernumber", "Lieferantennummer" => "vendornumber", - "Projektnummer" => "projectnummer", + "Projektnummer" => "projectnumber", "Buchungsnummer" => "ordnumber", "Eingangsrechnungnummer" => "invnumber", "Ausgangsrechnungnummer" => "invnumber", @@ -2875,7 +1399,8 @@ sub show_am_history { my $dbh = $form->dbconnect(\%myconfig); - my $restriction = qq| AND (| . join(' OR ', map { " addition = " . $dbh->quote($_) } split(m/\,/, $form->{einschraenkungen})) . qq|)| if $form->{einschraenkungen}; + my $restriction; + $restriction = qq| AND (| . join(' OR ', map { " addition = " . $dbh->quote($_) } split(m/\,/, $form->{einschraenkungen})) . qq|)| if $form->{einschraenkungen}; $restriction .= qq| AND h.itime::date >= | . conv_dateq($form->{fromdate}) if $form->{fromdate}; $restriction .= qq| AND h.itime::date <= | . conv_dateq($form->{todate}) if $form->{todate}; if ($form->{mitarbeiter} =~ m/^\d+$/) { @@ -2911,22 +1436,6 @@ sub show_am_history { $main::lxdebug->leave_sub(); } -sub swap_units { - $main::lxdebug->enter_sub(); - - my $form = $main::form; - my %myconfig = %main::myconfig; - - $main::auth->assert('config'); - - my $dir = $form->{"dir"} eq "down" ? "down" : "up"; - AM->swap_units(\%myconfig, $form, $dir, $form->{"name"}); - - edit_units(); - - $main::lxdebug->leave_sub(); -} - sub add_tax { $main::lxdebug->enter_sub(); @@ -3077,7 +1586,7 @@ sub add_price_factor { $form->{title} = $locale->text('Add Price Factor'); $form->{callback} ||= build_std_url('action=add_price_factor'); - $form->{fokus} = 'description'; + $::request->{layout}->focus('#description'); $form->header(); print $form->parse_html_template('am/edit_price_factor'); @@ -3096,7 +1605,7 @@ sub edit_price_factor { $form->{title} = $locale->text('Edit Price Factor'); $form->{callback} ||= build_std_url('action=add_price_factor'); - $form->{fokus} = 'description'; + $::request->{layout}->focus('#description'); AM->get_price_factor(\%myconfig, $form); @@ -3119,16 +1628,8 @@ sub list_price_factors { AM->get_all_price_factors(\%myconfig, \%$form); - my $previous; foreach my $current (@{ $form->{PRICE_FACTORS} }) { - if ($previous) { - $previous->{next_id} = $current->{id}; - $current->{previous_id} = $previous->{id}; - } - $current->{factor} = $form->format_amount(\%myconfig, $current->{factor} * 1); - - $previous = $current; } $form->{callback} = build_std_url('action=list_price_factors'); @@ -3182,20 +1683,6 @@ sub delete_price_factor { $main::lxdebug->leave_sub(); } -sub swap_price_factors { - $main::lxdebug->enter_sub(); - - my $form = $main::form; - my %myconfig = %main::myconfig; - - $main::auth->assert('config'); - - AM->swap_sortkeys(\%myconfig, $form, 'price_factors'); - list_price_factors(); - - $main::lxdebug->leave_sub(); -} - sub add_warehouse { $main::lxdebug->enter_sub(); @@ -3206,7 +1693,7 @@ sub add_warehouse { $form->{title} = $locale->text('Add Warehouse'); $form->{callback} ||= build_std_url('action=add_warehouse'); - $form->{fokus} = 'description'; + $::request->{layout}->focus('#description'); $form->header(); print $form->parse_html_template('am/edit_warehouse'); @@ -3229,7 +1716,7 @@ sub edit_warehouse { $form->{title} = $locale->text('Edit Warehouse'); $form->{callback} ||= build_std_url('action=list_warehouses'); - $form->{fokus} = 'description'; + $::request->{layout}->focus('#description'); $form->header(); print $form->parse_html_template('am/edit_warehouse'); @@ -3248,16 +1735,6 @@ sub list_warehouses { AM->get_all_warehouses(\%myconfig, $form); - my $previous; - foreach my $current (@{ $form->{WAREHOUSES} }) { - if ($previous) { - $previous->{next_id} = $current->{id}; - $current->{previous_id} = $previous->{id}; - } - - $previous = $current; - } - $form->{callback} = build_std_url('action=list_warehouses'); $form->{title} = $locale->text('Warehouses'); $form->{url_base} = build_std_url('callback'); @@ -3290,20 +1767,6 @@ sub save_warehouse { $main::lxdebug->leave_sub(); } -sub swap_warehouses { - $main::lxdebug->enter_sub(); - - my $form = $main::form; - my %myconfig = %main::myconfig; - - $main::auth->assert('config'); - - AM->swap_sortkeys(\%myconfig, $form, 'warehouse'); - list_warehouses(); - - $main::lxdebug->leave_sub(); -} - sub delete_warehouse { $main::lxdebug->enter_sub();