X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fam.pl;h=b3ec6045c291b0da8b3a5db548bb6b6325439acb;hb=1b9a64fa292f375c82b4af788d0606354bc4e8ff;hp=bcb39d258f066a65813f4ca81a272541914ae4be;hpb=5ac0b1b2cb0b120d0421acd6355a31e376885646;p=kivitendo-erp.git diff --git a/bin/mozilla/am.pl b/bin/mozilla/am.pl index bcb39d258..b3ec6045c 100644 --- a/bin/mozilla/am.pl +++ b/bin/mozilla/am.pl @@ -24,7 +24,8 @@ # 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. #====================================================================== # # administration @@ -42,7 +43,11 @@ use SL::User; use SL::USTVA; use SL::Iconv; use SL::TODO; -use SL::Printer; +use SL::DB::Printer; +use SL::DB::Tax; +use SL::DB::Language; +use SL::DB::Default; +use SL::DBUtils qw(selectall_array_query); use CGI; require "bin/mozilla/common.pl"; @@ -85,10 +90,17 @@ sub edit_account { my $form = $main::form; my %myconfig = %main::myconfig; + my $defaults = SL::DB::Default->get; $main::auth->assert('config'); $form->{title} = "Edit"; + $form->{feature_balance} = $defaults->feature_balance; + $form->{feature_datev} = $defaults->feature_datev; + $form->{feature_erfolgsrechnung} = $defaults->feature_erfolgsrechnung; + $form->{feature_eurechnung} = $defaults->feature_eurechnung; + $form->{feature_ustva} = $defaults->feature_ustva; + AM->get_account(\%myconfig, \%$form); foreach my $item (split(/:/, $form->{link})) { @@ -254,6 +266,20 @@ sub account_header { } + my $select_er = q|\n|; + my %er = ( + 1 => "Ertrag", + 6 => "Aufwand"); + foreach my $item (sort({ $a <=> $b } keys(%er))) { + my $text = H($::locale->{iconv_utf8}->convert($er{$item})); + if ($item == $form->{pos_er}) { + $select_er .= qq|\n|; + } else { + $select_er .= qq|\n|; + } + + } + my $select_bwa = q|\n|; my %bwapos = ( @@ -356,6 +382,7 @@ sub account_header { select_bwa => $select_bwa, select_bilanz => $select_bilanz, select_eur => $select_eur, + select_er => $select_er, }; # Ausgabe des Templates @@ -573,7 +600,7 @@ sub delete_account { $form->{title} = $locale->text('Delete Account'); foreach my $id ( - qw(inventory_accno_id income_accno_id expense_accno_id fxgain_accno_id fxloss_accno_id) + qw(inventory_accno_id income_accno_id expense_accno_id fxgain_accno_id fxloss_accno_id rndgain_accno_id rndloss_accno_id) ) { if ($form->{id} == $form->{$id}) { $form->error($locale->text('Cannot delete default account!')); @@ -748,7 +775,7 @@ sub language_header { $::form->header; print $::form->parse_html_template('am/language_header', { - numberformats => [ '1,000.00', '1000.00', '1.000,00', '1000,00' ], + numberformats => [ '1,000.00', '1000.00', '1.000,00', '1000,00', "1'000.00" ], dateformats => [ qw(mm/dd/yy dd/mm/yy dd.mm.yy yyyy-mm-dd) ], }); @@ -788,207 +815,6 @@ sub delete_language { $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 { - $::lxdebug->enter_sub; - $::auth->assert('config'); - - AM->buchungsgruppe(\%::myconfig, $::form); - - $::form->{callback} = "am.pl?action=list_buchungsgruppe"; - $::form->{title} = $::locale->text('Buchungsgruppen'); - $::form->header; - - print $::form->parse_html_template('am/buchungsgruppe_list', { - swap_link => qq|am.pl?action=swap_buchungsgruppen&|, - }); - - $::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"); - - 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, - ); - - for my $key (keys %acc_type_map) { - for my $ref (@{ $::form->{IC_links}{$key} }) { - $acc_type_map{$key}{$ref->{id}} = $ref; - } - } - - my %sorted_accounts = map { - $_ => [ sort { $a->{accno} cmp $b->{accno} } values %{ $acc_type_map{$_} } ], - } keys %acc_type_map; - - $::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_buchungsgruppe { - $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('Description missing!')); - - AM->save_buchungsgruppe(\%myconfig, \%$form); - $form->redirect($locale->text('Accounting Group saved!')); - - $main::lxdebug->leave_sub(); -} - -sub delete_buchungsgruppe { - $main::lxdebug->enter_sub(); - - my $form = $main::form; - my %myconfig = %main::myconfig; - my $locale = $main::locale; - - $main::auth->assert('config'); - - AM->delete_buchungsgruppe(\%myconfig, \%$form); - $form->redirect($locale->text('Accounting Group deleted!')); - - $main::lxdebug->leave_sub(); -} - -sub swap_buchungsgruppen { - $main::lxdebug->enter_sub(); - - my $form = $main::form; - my %myconfig = %main::myconfig; - - $main::auth->assert('config'); - - AM->swap_sortkeys(\%myconfig, $form, "buchungsgruppen"); - list_buchungsgruppe(); - - $main::lxdebug->leave_sub(); -} - -sub edit_defaults { - $main::lxdebug->enter_sub(); - - my $form = $main::form; - my %myconfig = %main::myconfig; - my $locale = $main::locale; - - # get defaults for account numbers and last numbers - AM->defaultaccounts(\%myconfig, \%$form); - $form->{ALL_UNITS} = AM->convertible_units(AM->retrieve_all_units(), 'g'); - - 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); - $form->{$array} ||= []; - - my $value = "${accno}--" . $form->{IC}->{$key}->{$accno}->{description}; - push @{ $form->{$array} }, { - 'name' => $value, - 'value' => $value, - 'selected' => $form->{IC}->{$key}->{$accno}->{id} == $form->{defaults}->{$key}, - }; - } - } - - $form->{title} = $locale->text('Ranges of numbers and default accounts'); - - $form->header(); - print $form->parse_html_template('am/edit_defaults', - { ALL_LANGUAGES => $all_languages, }); - - $main::lxdebug->leave_sub(); -} - -sub save_defaults { - $main::lxdebug->enter_sub(); - - my $form = $main::form; - my $locale = $main::locale; - - AM->save_defaults(); - - $form->redirect($locale->text('Defaults saved.')); - - $main::lxdebug->leave_sub(); -} - sub _build_cfg_options { my $form = $main::form; my %myconfig = %main::myconfig; @@ -1014,7 +840,8 @@ sub config { my $locale = $main::locale; _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')); + _build_cfg_options('timeformat', qw(hh:mm hh:mm:ss)); + _build_cfg_options('numberformat', ('1,000.00', '1000.00', '1.000,00', '1000,00', "1'000.00")); my @formats = (); if ($::lx_office_conf{print_templates}->{opendocument} @@ -1059,7 +886,7 @@ sub config { { 'name' => $locale->text('Queue'), 'value' => 'queue', 'selected' => $selected{queue}, }, ]; - $form->{PRINTERS} = [ SL::Printer->all_printers(%::myconfig) ]; + $form->{PRINTERS} = SL::DB::Manager::Printer->get_all_sorted; my %countrycodes = User->country_codes; @@ -1073,7 +900,7 @@ sub config { } $form->{STYLESHEETS} = []; - foreach my $item (qw(lx-office-erp.css Mobile.css kivitendo.css)) { + foreach my $item (qw(lx-office-erp.css kivitendo.css)) { push @{ $form->{STYLESHEETS} }, { 'name' => $item, 'value' => $item, @@ -1083,11 +910,14 @@ sub config { $myconfig{show_form_details} = 1 unless (defined($myconfig{show_form_details})); $form->{CAN_CHANGE_PASSWORD} = $main::auth->can_change_password(); - $form->{todo_cfg} = { TODO->get_user_config('login' => $form->{login}) }; + $form->{todo_cfg} = { TODO->get_user_config('login' => $::myconfig{login}) }; - $form->{title} = $locale->text('Edit Preferences for #1', $form->{login}); + $form->{title} = $locale->text('Edit Preferences for #1', $::myconfig{login}); $form->header(); + + $form->{full_signature} = $form->create_email_signature(); + print $form->parse_html_template('am/config'); $main::lxdebug->leave_sub(); @@ -1102,9 +932,9 @@ sub save_preferences { $form->{stylesheet} = $form->{usestylesheet}; - TODO->save_user_config('login' => $form->{login}, %{ $form->{todo_cfg} || { } }); + TODO->save_user_config('login' => $::myconfig{login}, %{ $form->{todo_cfg} || { } }); - if (AM->save_preferences(\%myconfig, $form)) { + if (AM->save_preferences($form)) { if ($::auth->can_change_password() && defined $form->{new_password} && ($form->{new_password} ne '********')) { @@ -1115,11 +945,7 @@ sub save_preferences { $form->error($::locale->text('The settings were saved, but the password was not changed.') . ' ' . join(' ', $verifier->errors($result))); } - $::auth->change_password($form->{login}, $form->{new_password}); - - $form->{password} = $form->{new_password}; - $::auth->set_session_value('password', $form->{password}); - $::auth->create_or_refresh_session(); + $::auth->change_password($::myconfig{login}, $form->{new_password}); } $form->redirect($locale->text('Preferences saved!')); @@ -1389,23 +1215,28 @@ sub show_am_history { my $callback = build_std_url(qw(action einschraenkungen fromdate todate mitarbeiter searchid what2search)); $form->{order} ||= 'h.itime--1'; - my %search = ( "Artikelnummer" => "parts", - "Kundennummer" => "customer", - "Lieferantennummer" => "vendor", - "Projektnummer" => "project", - "Buchungsnummer" => "oe", - "Eingangsrechnungnummer" => "ap", - "Ausgangsrechnungnummer" => "ar", - "Mahnungsnummer" => "dunning" - ); + # my %search = ( "Artikelnummer" => "parts", + # "Kundennummer" => "customer", + # "Lieferantennummer" => "vendor", + # "Projektnummer" => "project", + # "Auftragsnummer" => "oe", + # "Angebotsnummer" => "oe", + # "Eingangsrechnungnummer" => "ap", + # "Ausgangsrechnungnummer" => "ar", + # "Mahnungsnummer" => "dunning", + # "Buchungsnummer" => "gl", + # ); + my %searchNo = ( "Artikelnummer" => "partnumber", "Kundennummer" => "customernumber", "Lieferantennummer" => "vendornumber", "Projektnummer" => "projectnumber", - "Buchungsnummer" => "ordnumber", + "Auftragsnummer" => "ordnumber", + "Angebotsnummer" => "quonumber", "Eingangsrechnungnummer" => "invnumber", "Ausgangsrechnungnummer" => "invnumber", - "Mahnungsnummer" => "dunning_id" + "Mahnungsnummer" => "dunning_id", + "Buchungsnummer" => "gltransaction" ); my $dbh = $form->dbconnect(\%myconfig); @@ -1461,10 +1292,18 @@ sub add_tax { _get_taxaccount_selection(); + $form->{asset} = 1; + $form->{liability} = 1; + $form->{equity} = 1; + $form->{revenue} = 1; + $form->{expense} = 1; + $form->{costs} = 1; + $form->header(); my $parameters_ref = { # ChartTypeIsAccount => $ChartTypeIsAccount, + LANGUAGES => SL::DB::Manager::Language->get_all_sorted, }; # Ausgabe des Templates @@ -1485,17 +1324,23 @@ sub edit_tax { $form->{title} = $locale->text('Edit'); AM->get_tax(\%myconfig, \%$form); + _get_taxaccount_selection(); + $form->{asset} = $form->{chart_categories} =~ 'A' ? 1 : 0; + $form->{liability} = $form->{chart_categories} =~ 'L' ? 1 : 0; + $form->{equity} = $form->{chart_categories} =~ 'Q' ? 1 : 0; + $form->{revenue} = $form->{chart_categories} =~ 'I' ? 1 : 0; + $form->{expense} = $form->{chart_categories} =~ 'E' ? 1 : 0; + $form->{costs} = $form->{chart_categories} =~ 'C' ? 1 : 0; + $form->{rate} = $form->format_amount(\%myconfig, $form->{rate}, 2); $form->header(); - #set readonly if the there are entries in acc_trans with the tax - my $readonly = $form->{tax_already_used} ? 'readonly' : ''; - my $parameters_ref = { - readonly => $readonly, + LANGUAGES => SL::DB::Manager::Language->get_all_sorted, + TAX => SL::DB::Manager::Tax->find_by(id => $form->{id}), }; # Ausgabe des Templates @@ -1574,6 +1419,9 @@ sub save_tax { $form->error($locale->text('Tax Percent is a number between 0 and 100')); } + my @translation_keys = grep { $_ =~ '^translation_\d+' } keys %$form; + $form->{translations} = { map { $_ =~ '^translation_(\d+)'; $1 => $form->{$_} } @translation_keys }; + AM->save_tax(\%myconfig, \%$form); $form->redirect($locale->text('Tax saved!')); @@ -1605,7 +1453,6 @@ sub add_price_factor { $form->{title} = $locale->text('Add Price Factor'); $form->{callback} ||= build_std_url('action=add_price_factor'); - $::request->{layout}->focus('#description'); $form->header(); print $form->parse_html_template('am/edit_price_factor'); @@ -1624,7 +1471,6 @@ sub edit_price_factor { $form->{title} = $locale->text('Edit Price Factor'); $form->{callback} ||= build_std_url('action=add_price_factor'); - $::request->{layout}->focus('#description'); AM->get_price_factor(\%myconfig, $form); @@ -1712,7 +1558,6 @@ sub add_warehouse { $form->{title} = $locale->text('Add Warehouse'); $form->{callback} ||= build_std_url('action=add_warehouse'); - $::request->{layout}->focus('#description'); $form->header(); print $form->parse_html_template('am/edit_warehouse'); @@ -1735,7 +1580,6 @@ sub edit_warehouse { $form->{title} = $locale->text('Edit Warehouse'); $form->{callback} ||= build_std_url('action=list_warehouses'); - $::request->{layout}->focus('#description'); $form->header(); print $form->parse_html_template('am/edit_warehouse'); @@ -1800,7 +1644,7 @@ sub delete_warehouse { $form->header(); print $form->parse_html_template('am/confirm_delete_warehouse'); - ::end_of_request(); + $::dispatcher->end_request; } if (AM->delete_warehouse(\%myconfig, $form)) {