From 42ed89f33e7f38dcf9bba8983a070e59b5b61a47 Mon Sep 17 00:00:00 2001 From: Philip Reetz Date: Wed, 9 Jul 2008 08:26:43 +0000 Subject: [PATCH] Beim Bearbeiten von Konten die Funktion "als neu speichern" hinzugefuegt, um ein Konto mit allen Einstelungen zu klonen --- SL/AM.pm | 56 ++++--------------- bin/mozilla/am.pl | 37 ++++++++++++ locale/de/all | 1 + locale/de/am | 5 ++ templates/webpages/am/edit_accounts_de.html | 1 + .../webpages/am/edit_accounts_master.html | 1 + 6 files changed, 55 insertions(+), 46 deletions(-) diff --git a/SL/AM.pm b/SL/AM.pm index fa7826095..5ffb6a1c5 100644 --- a/SL/AM.pm +++ b/SL/AM.pm @@ -230,6 +230,13 @@ sub save_account { $form->{id} = ""; } + if (!$form->{id} || $form->{id} eq "") { + $query = qq|SELECT nextval('id')|; + ($form->{"id"}) = selectrow_query($form, $dbh, $query); + $query = qq|INSERT INTO chart (id, accno) VALUES (?, ?)|; + do_query($form, $dbh, $query, $form->{"id"}, $form->{"accno"}); + } + my @values; if ($form->{id}) { @@ -262,52 +269,6 @@ sub save_account { $form->{id}, ); - } - elsif ($form->{id} && !$form->{new_chart_valid}) { - - $query = qq| - UPDATE chart - SET new_chart_id = ?, - valid_from = ? - WHERE id = ? - |; - - @values = ( - conv_i($form->{new_chart_id}), - conv_date($form->{valid_from}), - $form->{id} - ); - } - else { - - $query = qq| - INSERT INTO chart ( - accno, - description, - charttype, - category, - link, - pos_bwa, - pos_bilanz, - pos_eur, - new_chart_id, - valid_from, - datevautomatik ) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) - |; - - @values = ( - $form->{accno}, - $form->{description}, - $form->{charttype}, - $form->{category}, $form->{link}, - conv_i($form->{pos_bwa}), - conv_i($form->{pos_bilanz}), conv_i($form->{pos_eur}), - conv_i($form->{new_chart_id}), - conv_date($form->{valid_from}), - ($form->{datevautomatik} eq 'T') ? 'true':'false', - ); - } do_query($form, $dbh, $query, @values); @@ -325,6 +286,9 @@ sub save_account { # Loop control # Check if the account already exists, else cancel + + print(STDERR "Keine Taxkeys weil ID =: $form->{id}\n"); + last READTAXKEYS if ( $form->{'id'} == 0); # check if there is a startdate diff --git a/bin/mozilla/am.pl b/bin/mozilla/am.pl index 45333c1cd..29d283b93 100644 --- a/bin/mozilla/am.pl +++ b/bin/mozilla/am.pl @@ -55,6 +55,7 @@ sub delete { call_sub("delete_$form->{type}"); } sub save { call_sub("save_$form->{type}"); } sub edit { call_sub("edit_$form->{type}"); } sub continue { call_sub($form->{"nextsub"}); } +sub save_as_new { call_sub("save_as_new_$form->{type}"); } sub add_account { $lxdebug->enter_sub(); @@ -373,6 +374,12 @@ sub form_footer { . $locale->text('Delete') . qq|">|; } + if ($form->{id} && $form->{type} eq "account") { + print qq| + |; + } + print qq| @@ -402,6 +409,36 @@ sub save_account { $lxdebug->leave_sub(); } +sub save_as_new_account { + $lxdebug->enter_sub(); + + $auth->assert('config'); + + $form->isblank("accno", $locale->text('Account Number missing!')); + $form->isblank("description", $locale->text('Account Description missing!')); + + if ($form->{charttype} eq 'A'){ + $form->isblank("category", $locale->text('Account Type missing!')); + } + + for my $taxkey (0 .. 9) { + if ($form->{"taxkey_id_$taxkey"}) { + $form->{"taxkey_id_$taxkey"} = "NEW"; + } + } + + $form->{id} = 0; + if ($form->{"original_accno"} && + ($form->{"accno"} eq $form->{"original_accno"})) { + $form->error($locale->text('Account Number already used!')); + } + $form->redirect($locale->text('Account saved!')) + if (AM->save_account(\%myconfig, \%$form)); + $form->error($locale->text('Cannot save account!')); + + $lxdebug->leave_sub(); +} + sub list_account { $lxdebug->enter_sub(); diff --git a/locale/de/all b/locale/de/all index b2b0382e3..c763e4177 100644 --- a/locale/de/all +++ b/locale/de/all @@ -76,6 +76,7 @@ $self->{texts} = { 'Account Link IC_taxpart' => 'Warenliste Steuer', 'Account Link IC_taxservice' => 'Dienstleistungen Steuer', 'Account Number' => 'Kontonummer', + 'Account Number already used!' => 'Kontonummer ist bereits in Benutzung!', 'Account Number missing!' => 'Kontonummer fehlt!', 'Account Nummer' => 'Kontonummer', 'Account Type' => 'Kontoart', diff --git a/locale/de/am b/locale/de/am index 0baf4da9d..766b8a5de 100644 --- a/locale/de/am +++ b/locale/de/am @@ -42,6 +42,7 @@ $self->{texts} = { 'Account Link IC_sale' => 'Warenliste Erlöskonto', 'Account Link IC_taxpart' => 'Warenliste Steuer', 'Account Link IC_taxservice' => 'Dienstleistungen Steuer', + 'Account Number already used!' => 'Kontonummer ist bereits in Benutzung!', 'Account Number missing!' => 'Kontonummer fehlt!', 'Account Type missing!' => 'Kontoart fehlt!', 'Account deleted!' => 'Konto gelöscht!', @@ -236,6 +237,7 @@ $self->{texts} = { 'SAVED FOR DUNNING' => 'Gespeichert', 'SCREENED' => 'Angezeigt', 'Save' => 'Speichern', + 'Save as new' => 'als neu speichern', 'Screen' => 'Bildschirm', 'Select a Customer' => 'Endkunde auswählen', 'Select a customer' => 'Einen Kunden auswählen', @@ -409,6 +411,8 @@ $self->{subs} = { 'retrieve_partunits' => 'retrieve_partunits', 'save' => 'save', 'save_account' => 'save_account', + 'save_as_new' => 'save_as_new', + 'save_as_new_account' => 'save_as_new_account', 'save_bin' => 'save_bin', 'save_buchungsgruppe' => 'save_buchungsgruppe', 'save_business' => 'save_business', @@ -444,6 +448,7 @@ $self->{subs} = { 'kontodaten_bearbeiten' => 'edit_account', 'neue_ware' => 'new_part', 'speichern' => 'save', + 'als_neu_speichern' => 'save_as_new', }; 1; diff --git a/templates/webpages/am/edit_accounts_de.html b/templates/webpages/am/edit_accounts_de.html index 08829fcca..f43945723 100644 --- a/templates/webpages/am/edit_accounts_de.html +++ b/templates/webpages/am/edit_accounts_de.html @@ -18,6 +18,7 @@ window.onload = function() { + diff --git a/templates/webpages/am/edit_accounts_master.html b/templates/webpages/am/edit_accounts_master.html index d2eab9da0..f9599a513 100644 --- a/templates/webpages/am/edit_accounts_master.html +++ b/templates/webpages/am/edit_accounts_master.html @@ -18,6 +18,7 @@ window.onload = function() { + -- 2.20.1