X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fam.pl;h=27b18e400fc77f1111e30112c5679d57d4fc7e6c;hb=e2b9e1737230c4e4209904784808dcaec723f730;hp=60814f2dcfa1dd9c8f8b76b3104ffd47ae131744;hpb=e0d47e23c8ef3863f7c2387e49e2207f9140f0db;p=kivitendo-erp.git diff --git a/bin/mozilla/am.pl b/bin/mozilla/am.pl index 60814f2dc..27b18e400 100644 --- a/bin/mozilla/am.pl +++ b/bin/mozilla/am.pl @@ -31,45 +31,61 @@ # #====================================================================== +use SL::Auth; use SL::AM; use SL::CA; use SL::Form; use SL::User; +use SL::USTVA; +use SL::Iconv; +use SL::TODO; +use CGI::Ajax; +use CGI; use Data::Dumper; -1; - +require "bin/mozilla/common.pl"; +use strict; -require "$form->{path}/common.pl"; +1; # end of main -sub add { &{"add_$form->{type}"} } -sub edit { &{"edit_$form->{type}"} } -sub save { &{"save_$form->{type}"} } -sub delete { &{"delete_$form->{type}"} } +sub add { call_sub("add_$main::form->{type}"); } +sub delete { call_sub("delete_$main::form->{type}"); } +sub save { call_sub("save_$main::form->{type}"); } +sub edit { call_sub("edit_$main::form->{type}"); } +sub continue { call_sub($main::form->{"nextsub"}); } +sub save_as_new { call_sub("save_as_new_$main::form->{type}"); } sub add_account { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + my $form = $main::form; + my %myconfig = %main::myconfig; + + $main::auth->assert('config'); $form->{title} = "Add"; $form->{charttype} = "A"; AM->get_account(\%myconfig, \%$form); - $form->{callback} = - "$form->{script}?action=list_account&path=$form->{path}&login=$form->{login}&password=$form->{password}" - unless $form->{callback}; + $form->{callback} = "am.pl?action=list_account" unless $form->{callback}; &account_header; &form_footer; - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } sub edit_account { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + my $form = $main::form; + my %myconfig = %main::myconfig; + + $main::auth->assert('config'); $form->{title} = "Edit"; AM->get_account(\%myconfig, \%$form); @@ -81,134 +97,122 @@ sub edit_account { &account_header; &form_footer; - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } sub account_header { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + my $form = $main::form; + my %myconfig = %main::myconfig; + my $locale = $main::locale; + + $main::auth->assert('config'); + + if ( $form->{action} eq 'edit_account') { + $form->{account_exists} = '1'; + } $form->{title} = $locale->text("$form->{title} Account"); - $checked{ $form->{charttype} } = "checked"; - $checked{"$form->{category}_"} = "checked"; - $checked{CT_tax} = ($form->{CT_tax}) ? "" : "checked"; + $form->{"$form->{charttype}_checked"} = "checked"; + $form->{"$form->{category}_checked"} = "checked"; - $form->{description} =~ s/\"/"/g; + $form->{select_tax} = ""; + + my @tax_report_pos = USTVA->report_variables({ + myconfig => \%myconfig, + form => $form, + type => '', + attribute => 'position', + calc => '', + }); if (@{ $form->{TAXKEY} }) { - foreach $item (@{ $form->{TAXKEY} }) { - if ($item->{tax} == $form->{tax}) { - $form->{selecttaxkey} .= - ""; + $form->{selectnewaccount} = qq||; } - foreach $item (@{ $form->{NEWACCOUNT} }) { + foreach my $item (@{ $form->{NEWACCOUNT} }) { if ($item->{id} == $form->{new_chart_id}) { $form->{selectnewaccount} .= - ""; + qq||; } elsif (!$form->{new_chart_valid}) { $form->{selectnewaccount} .= - ""; + qq||; } } } - $newaccount = qq| - - - - - - - - - -
| . $locale->text('Folgekonto') . qq|| . $locale->text('Gültig ab') . qq|
- - |; - - $form->{selectustva} = "\n|; + my %eur = ( + 1 => "Umsatzerlöse", 2 => "sonstige Erlöse", 3 => "Privatanteile", 4 => "Zinserträge", @@ -224,7 +228,7 @@ sub account_header { 14 => "Steuern, Versich., Beiträge", 15 => "Kfz-Steuern", 16 => "Kfz-Versicherungen", - 17 => "Sonst. Fahrtkosten", + 17 => "Sonst. Fahrzeugkosten", 18 => "Werbe- und Reisekosten", 19 => "Instandhaltung u. Werkzeuge", 20 => "Fachzeitschriften, Bücher", @@ -239,25 +243,20 @@ sub account_header { 29 => "Zinsaufwand", 30 => "Ausserordentlicher Aufwand", 31 => "Betriebliche Steuern"); - foreach $item (sort({ $a <=> $b } keys(%eur))) { + foreach my $item (sort({ $a <=> $b } keys(%eur))) { + my $text = H(SL::Iconv::convert("ISO-8859-15", $main::dbcharset, $eur{$item})); if ($item == $form->{pos_eur}) { - $form->{selecteur} .= "\n|; } else { - $form->{selecteur} .= "\n|; } } - $eur = qq| - - | . $locale->text('EUER') . qq| - - - |; - - $form->{selectbwa} = "\n|; - %bwapos = (1 => 'Umsatzerlöse', + my %bwapos = ( + 1 => 'Umsatzerlöse', 2 => 'Best.Verdg.FE/UE', 3 => 'Aktiv.Eigenleistung', 4 => 'Mat./Wareneinkauf', @@ -279,209 +278,103 @@ sub account_header { 33 => 'Sonst.neutr.Ertrag', 34 => 'Verr.kalk.Kosten', 35 => 'Steuern Eink.u.Ertr.'); - foreach $item (sort({ $a <=> $b } keys %bwapos)) { + foreach my $item (sort({ $a <=> $b } keys %bwapos)) { + my $text = H(SL::Iconv::convert("ISO-8859-15", $main::dbcharset, $bwapos{$item})); if ($item == $form->{pos_bwa}) { - $form->{selectbwa} .= "\n|; + foreach my $item ((1, 2, 3, 4)) { + if ($item == $form->{pos_bilanz}) { + $select_bilanz .= qq|\n|; + + my %category = ( + 'A' => $locale->text('Asset'), + 'L' => $locale->text('Liability'), + 'Q' => $locale->text('Equity'), + 'I' => $locale->text('Revenue'), + 'E' => $locale->text('Expense'), + 'C' => $locale->text('Costs'), + ); + foreach my $item ( sort({ $a <=> $b } keys %category) ) { + if ($item eq $form->{category}) { + $select_category .= qq|"; + $form->show_generic_error(sprintf($locale->text("The name in row %d has already been used before."), $i)) if ($new_units->{$form->{"name_$i"}}); + my %h = map({ $_ => $form->{"${_}_$i"} } qw(name base_unit factor old_name)); + $new_units->{$form->{"name_$i"}} = \%h; + $new_units->{$form->{"name_$i"}}->{"row"} = $i; + set_unit_languages($new_units->{$form->{"old_name_$i"}}, \@languages, $i); } - if (!$myconfig{"default_media"}) { - $myconfig{"default_media"} = "screen"; + foreach my $unit (values(%{$new_units})) { + next unless ($unit->{"old_name"}); + if ($unit->{"base_unit"}) { + $form->show_generic_error(sprintf($locale->text("The base unit does not exist or it is about to be deleted in row %d."), $unit->{"row"})) + unless (defined($new_units->{$unit->{"base_unit"}})); + $unit->{"factor"} = $form->parse_amount(\%myconfig, $unit->{"factor"}); + $form->show_generic_error(sprintf($locale->text("The factor is missing in row %d."), $unit->{"row"})) unless ($unit->{"factor"} >= 1.0); + } else { + $unit->{"base_unit"} = undef; + $unit->{"factor"} = undef; + } } - my %selected = ($myconfig{"default_media"} => "selected"); - my $default_media = qq| - - - -|; - %selected = (); - $selected{$myconfig{"default_printer_id"}} = "selected" - if ($myconfig{"default_printer_id"}); - my $default_printer = qq||; - AM->printer(\%myconfig, $form); - foreach my $printer (@{$form->{"ALL"}}) { - $default_printer .= qq||; - } + foreach my $unit (values(%{$new_units})) { + next if ($unit->{"unchanged_unit"}); - %countrycodes = User->country_codes; - $countrycodes = ''; - foreach $key (sort { $countrycodes{$a} cmp $countrycodes{$b} } - keys %countrycodes - ) { - $countrycodes .= - ($myconfig{countrycode} eq $key) - ? "