From a590a6518025280c2d6e76c87641764ca6198521 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Wed, 21 Jul 2010 14:45:17 +0200 Subject: [PATCH] save_history sollte NICHT jedesmal eine neue datenbankverbindung aufmachen. --- SL/CP.pm | 2 +- SL/Form.pm | 6 ++++-- bin/mozilla/ap.pl | 8 ++++---- bin/mozilla/ar.pl | 10 +++++----- bin/mozilla/ct.pl | 20 ++++++++++---------- bin/mozilla/dn.pl | 4 ++-- bin/mozilla/do.pl | 6 +++--- bin/mozilla/gl.pl | 6 +++--- bin/mozilla/ic.pl | 6 +++--- bin/mozilla/io.pl | 12 ++++++------ bin/mozilla/ir.pl | 8 ++++---- bin/mozilla/is.pl | 4 ++-- bin/mozilla/oe.pl | 6 +++--- bin/mozilla/pe.pl | 4 ++-- bin/mozilla/projects.pl | 4 ++-- bin/mozilla/rp.pl | 2 +- 16 files changed, 55 insertions(+), 53 deletions(-) diff --git a/SL/CP.pm b/SL/CP.pm index f6c8c1a8e..fbfd6fa43 100644 --- a/SL/CP.pm +++ b/SL/CP.pm @@ -360,7 +360,7 @@ sub process_payment { if(!exists $form->{addition}) { $form->{snumbers} = qq|invnumber_| . $form->{"invnumber_$i"}; $form->{addition} = "POSTED"; - $form->save_history($form->dbconnect($myconfig)); + $form->save_history; } # /saving the history } diff --git a/SL/Form.pm b/SL/Form.pm index 6d2ae4914..63182424d 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -3235,8 +3235,8 @@ sub save_status { sub save_history { $main::lxdebug->enter_sub(); - my $self = shift(); - my $dbh = shift(); + my $self = shift; + my $dbh = shift || $self->get_standard_dbh; if(!exists $self->{employee_id}) { &get_employee($self, $dbh); @@ -3249,6 +3249,8 @@ sub save_history { $self->{addition}, $self->{what_done}, "$self->{snumbers}"); do_query($self, $dbh, $query, @values); + $dbh->commit; + $main::lxdebug->leave_sub(); } diff --git a/bin/mozilla/ap.pl b/bin/mozilla/ap.pl index ae2bda36b..8b32585a0 100644 --- a/bin/mozilla/ap.pl +++ b/bin/mozilla/ap.pl @@ -1081,7 +1081,7 @@ sub post { if(!exists $form->{addition} && $form->{id} ne "") { $form->{snumbers} = qq|invnumber_| . $form->{invnumber}; $form->{addition} = "POSTED"; - $form->save_history($form->dbconnect(\%myconfig)); + $form->save_history; } # /saving the history remove_draft() if $form->{remove_draft}; @@ -1107,7 +1107,7 @@ sub post_as_new { if(!exists $form->{addition} && $form->{id} ne "") { $form->{snumbers} = qq|invnumber_| . $form->{invnumber}; $form->{addition} = "POSTED AS NEW"; - $form->save_history($form->dbconnect(\%myconfig)); + $form->save_history; } # /saving the history &post; @@ -1190,7 +1190,7 @@ sub yes { if(!exists $form->{addition}) { $form->{snumbers} = qq|invnumber_| . $form->{invnumber}; $form->{addition} = "DELETED"; - $form->save_history($form->dbconnect(\%myconfig)); + $form->save_history; } # /saving the history $form->redirect($locale->text('Transaction deleted!')); @@ -1433,7 +1433,7 @@ sub storno { if(!exists $form->{addition} && $form->{id} ne "") { $form->{snumbers} = "ordnumber_$form->{ordnumber}"; $form->{addition} = "STORNO"; - $form->save_history($form->dbconnect(\%myconfig)); + $form->save_history; } # /saving the history diff --git a/bin/mozilla/ar.pl b/bin/mozilla/ar.pl index be99f5477..35f23d6dd 100644 --- a/bin/mozilla/ar.pl +++ b/bin/mozilla/ar.pl @@ -90,7 +90,7 @@ sub add { if(!exists $form->{addition} && ($form->{id} ne "")) { $form->{snumbers} = qq|invnumber_| . $form->{invnumber}; $form->{addition} = "ADDED"; - $form->save_history($form->dbconnect(\%myconfig)); + $form->save_history; } # /saving the history @@ -1140,7 +1140,7 @@ sub post { if(!exists $form->{addition} && $form->{id} ne "") { $form->{snumbers} = "invnumber_$form->{invnumber}"; $form->{addition} = "POSTED"; - $form->save_history($form->dbconnect(\%myconfig)); + $form->save_history; } # /saving the history remove_draft() if $form->{remove_draft}; @@ -1163,7 +1163,7 @@ sub post_as_new { if(!exists $form->{addition} && $form->{id} ne "") { $form->{snumbers} = qq|invnumber_| . $form->{invnumber}; $form->{addition} = "POSTED AS NEW"; - $form->save_history($form->dbconnect(\%myconfig)); + $form->save_history; } # /saving the history &post; @@ -1246,7 +1246,7 @@ sub yes { if(!exists $form->{addition}) { $form->{snumbers} = qq|invnumber_| . $form->{invnumber}; $form->{addition} = "DELETED"; - $form->save_history($form->dbconnect(\%myconfig)); + $form->save_history; } # /saving the history $form->redirect($locale->text('Transaction deleted!')); @@ -1520,7 +1520,7 @@ sub storno { if(!exists $form->{addition} && $form->{id} ne "") { $form->{snumbers} = "ordnumber_$form->{ordnumber}"; $form->{addition} = "STORNO"; - $form->save_history($form->dbconnect(\%myconfig)); + $form->save_history; } # /saving the history diff --git a/bin/mozilla/ct.pl b/bin/mozilla/ct.pl index 10b138e62..274ae4a6d 100644 --- a/bin/mozilla/ct.pl +++ b/bin/mozilla/ct.pl @@ -350,7 +350,7 @@ sub add_transaction { # # saving the history # if(!exists $form->{addition}) { # $form->{addition} = "ADD TRANSACTION"; -# $form->save_history($form->dbconnect(\%myconfig)); +# $form->save_history; # } # # /saving the history @@ -384,7 +384,7 @@ sub save_and_ap_transaction { if(!exists $form->{addition}) { $form->{snumbers} = qq|invnumber_| . $form->{invnumber}; $form->{addition} = "SAVED"; - $form->save_history($form->dbconnect(\%myconfig)); + $form->save_history; } # /saving the history &add_transaction; @@ -404,7 +404,7 @@ sub save_and_ar_transaction { if(!exists $form->{addition}) { $form->{snumbers} = qq|invnumber_| . $form->{invnumber}; $form->{addition} = "SAVED"; - $form->save_history($form->dbconnect(\%myconfig)); + $form->save_history; } # /saving the history &add_transaction; @@ -429,7 +429,7 @@ sub save_and_invoice { if(!exists $form->{addition}) { $form->{snumbers} = qq|invnumber_| . $form->{invnumber}; $form->{addition} = "SAVED"; - $form->save_history($form->dbconnect(\%myconfig)); + $form->save_history; } # /saving the history &add_transaction; @@ -450,7 +450,7 @@ sub save_and_rfq { if(!exists $form->{addition}) { $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber}; $form->{addition} = "SAVED"; - $form->save_history($form->dbconnect(\%myconfig)); + $form->save_history; } # /saving the history &add_transaction; @@ -471,7 +471,7 @@ sub save_and_quotation { if(!exists $form->{addition}) { $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber}; $form->{addition} = "SAVED"; - $form->save_history($form->dbconnect(\%myconfig)); + $form->save_history; } # /saving the history &add_transaction; @@ -497,7 +497,7 @@ sub save_and_order { if(!exists $form->{addition}) { $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber}; $form->{addition} = "SAVED"; - $form->save_history($form->dbconnect(\%myconfig)); + $form->save_history; } # /saving the history &add_transaction; @@ -530,7 +530,7 @@ sub save_and_close { if(!exists $form->{addition}) { $form->{snumbers} = ($form->{"db"} eq "customer" ? qq|customernumber_| . $form->{customernumber} : qq|vendornumber_| . $form->{vendornumber}); $form->{addition} = "SAVED"; - $form->save_history($form->dbconnect(\%myconfig)); + $form->save_history; } # /saving the history $form->redirect($locale->text($msg)); @@ -570,7 +570,7 @@ sub save { if(!exists $form->{addition}) { $form->{snumbers} = ($form->{"db"} eq "customer" ? qq|customernumber_| . $form->{customernumber} : qq|vendornumber_| . $form->{vendornumber}); $form->{addition} = "SAVED"; - $form->save_history($form->dbconnect(\%myconfig)); + $form->save_history; } # /saving the history &edit; @@ -596,7 +596,7 @@ sub delete { if(!exists $form->{addition}) { $form->{snumbers} = ($form->{"db"} eq "customer" ? qq|customernumber_| . $form->{customernumber} : qq|vendornumber_| . $form->{vendornumber}); $form->{addition} = "DELETED"; - $form->save_history($form->dbconnect(\%myconfig)); + $form->save_history; } # /saving the history $form->redirect($locale->text($msg)); diff --git a/bin/mozilla/dn.pl b/bin/mozilla/dn.pl index 845d2cd64..6c918fe58 100644 --- a/bin/mozilla/dn.pl +++ b/bin/mozilla/dn.pl @@ -178,7 +178,7 @@ sub save { if(!exists $form->{addition} && $form->{id} ne "") { $form->{snumbers} = qq|dunning_id_| . $form->{"dunning_id"}; $form->{addition} = "SAVED FOR DUNNING"; - $form->save_history($form->dbconnect(\%myconfig)); + $form->save_history; } # /saving the history $form->redirect($locale->text('Dunning Process Config saved!')); @@ -247,7 +247,7 @@ sub save_dunning { if(!exists $form->{addition} && $form->{id} ne "") { $form->{snumbers} = qq|dunning_id_| . $form->{"dunning_id"}; $form->{addition} = "DUNNING STARTED"; - $form->save_history($form->dbconnect(\%myconfig)); + $form->save_history; } # /saving the history diff --git a/bin/mozilla/do.pl b/bin/mozilla/do.pl index d5e8d3a0e..0d5941cb0 100644 --- a/bin/mozilla/do.pl +++ b/bin/mozilla/do.pl @@ -637,7 +637,7 @@ sub save { if(!exists $form->{addition}) { $form->{snumbers} = qq|donumber_| . $form->{donumber}; $form->{addition} = "SAVED"; - $form->save_history($form->dbconnect(\%myconfig)); + $form->save_history; } # /saving the history @@ -683,7 +683,7 @@ sub delete_delivery_order { if(!exists $form->{addition}) { $form->{snumbers} = qq|donumber_| . $form->{donumber}; $form->{addition} = "DELETED"; - $form->save_history($form->dbconnect(\%myconfig)); + $form->save_history; } # /saving the history @@ -732,7 +732,7 @@ sub invoice { for my $i (1 .. $form->{rowcount}) { # für bug 1284 - if ($form->{discount}){ # Falls wir einen Kundenrabatt haben + if ($form->{discount}){ # Falls wir einen Kundenrabatt haben # und keinen anderen discount wert an $i ... $form->{"discount_$i"} ||= $form->{discount}*100; # ... nehmen wir den kundenrabatt } diff --git a/bin/mozilla/gl.pl b/bin/mozilla/gl.pl index 44360f43d..f26d67157 100644 --- a/bin/mozilla/gl.pl +++ b/bin/mozilla/gl.pl @@ -1420,7 +1420,7 @@ sub yes { if(!exists $form->{addition} && $form->{id} ne "") { $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber}; $form->{addition} = "DELETED"; - $form->save_history($form->dbconnect(\%myconfig)); + $form->save_history; } # /saving the history $form->redirect($locale->text('Transaction deleted!')) @@ -1578,7 +1578,7 @@ sub post_transaction { $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber}; $form->{addition} = "SAVED"; $form->{what_done} = $locale->text("Buchungsnummer") . " = " . $form->{id}; - $form->save_history($form->dbconnect(\%myconfig)); + $form->save_history; } # /saving the history @@ -1646,7 +1646,7 @@ sub storno { if(!exists $form->{addition} && $form->{id} ne "") { $form->{snumbers} = "ordnumber_$form->{ordnumber}"; $form->{addition} = "STORNO"; - $form->save_history($form->dbconnect(\%myconfig)); + $form->save_history; } # /saving the history diff --git a/bin/mozilla/ic.pl b/bin/mozilla/ic.pl index eed4db516..5c9b5508a 100644 --- a/bin/mozilla/ic.pl +++ b/bin/mozilla/ic.pl @@ -1783,7 +1783,7 @@ sub save { if(!exists $form->{addition}) { $form->{snumbers} = qq|partnumber_| . $form->{partnumber}; $form->{addition} = "SAVED"; - $form->save_history($form->dbconnect(\%myconfig)); + $form->save_history; } # /saving the history $parts_id = $form->{id}; @@ -1916,7 +1916,7 @@ sub save_as_new { if(!exists $form->{addition}) { $form->{snumbers} = qq|partnumber_| . $form->{partnumber}; $form->{addition} = "SAVED AS NEW"; - $form->save_history($form->dbconnect(\%myconfig)); + $form->save_history; } # /saving the history $form->{id} = 0; @@ -1937,7 +1937,7 @@ sub delete { if(!exists $form->{addition}) { $form->{snumbers} = qq|partnumber_| . $form->{partnumber}; $form->{addition} = "DELETED"; - $form->save_history($form->dbconnect(\%myconfig)); + $form->save_history; } # /saving the history my $rc = IC->delete(\%myconfig, \%$form); diff --git a/bin/mozilla/io.pl b/bin/mozilla/io.pl index 2bf8e0786..dc0940d43 100644 --- a/bin/mozilla/io.pl +++ b/bin/mozilla/io.pl @@ -210,8 +210,8 @@ sub display_row { my %column_data = (); # undo formatting - map { $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) } - qw(qty discount sellprice lastcost price_new price_old) + map { $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) } + qw(qty discount sellprice lastcost price_new price_old) unless ($form->{simple_save}); # unit begin @@ -343,8 +343,8 @@ sub display_row { map { $form->{"${_}_$i"} = $form->format_amount(\%myconfig, $form->{"${_}_$i"}, 2) } qw(marge_absolut marge_percent); push @ROW2, { value => sprintf qq| - %s %s  %s%% -  %s %s + %s %s  %s%% +  %s %s  %s |, $marge_color, $locale->text('Ertrag'),$form->{"marge_absolut_$i"}, $form->{"marge_percent_$i"}, $locale->text('LP'), $form->format_amount(\%myconfig, $form->{"listprice_$i"}, 2), @@ -1429,7 +1429,7 @@ sub print_form { if(!exists $form->{addition}) { $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber}; $form->{addition} = "PRINTED"; - $form->save_history($form->dbconnect(\%myconfig)); + $form->save_history; } # /saving the history ::end_of_request(); @@ -1660,7 +1660,7 @@ sub print_form { elsif($form->{media} =~ /screen/) { $form->{addition} = "SCREENED"; } - $form->save_history($form->dbconnect(\%myconfig)); + $form->save_history; } # /saving the history diff --git a/bin/mozilla/ir.pl b/bin/mozilla/ir.pl index 03b605ee6..2c964d2d5 100644 --- a/bin/mozilla/ir.pl +++ b/bin/mozilla/ir.pl @@ -552,7 +552,7 @@ sub storno { if(!exists $form->{addition} && $form->{id} ne "") { $form->{snumbers} = qq|invnumber_| . $form->{invnumber}; $form->{addition} = "CANCELED"; - $form->save_history($form->dbconnect(\%myconfig)); + $form->save_history; } # /saving the history @@ -618,7 +618,7 @@ sub post_payment { $form->{snumbers} = qq|invnumber_| . $form->{invnumber}; $form->{addition} = "PAYMENT POSTED"; $form->{what_done} = $form->{currency} . qq| | . $form->{paid} . qq| | . $locale->text("POSTED"); - $form->save_history($form->dbconnect(\%myconfig)); + $form->save_history; # /saving the history } @@ -718,7 +718,7 @@ sub post { $form->{snumbers} = qq|invnumber_| . $form->{invnumber}; $form->{addition} = "POSTED"; #$form->{what_done} = $locale->text("Rechnungsnummer") . qq| | . $form->{invnumber}; - $form->save_history($form->dbconnect(\%myconfig)); + $form->save_history; } # /saving the history remove_draft() if $form->{remove_draft}; @@ -784,7 +784,7 @@ sub yes { if(!exists $form->{addition}) { $form->{snumbers} = qq|invnumber_| . $form->{invnumber}; $form->{addition} = "DELETED"; - $form->save_history($form->dbconnect(\%myconfig)); + $form->save_history; } # /saving the history $form->redirect($locale->text('Invoice deleted!')); diff --git a/bin/mozilla/is.pl b/bin/mozilla/is.pl index 4192beb5b..450d0b613 100644 --- a/bin/mozilla/is.pl +++ b/bin/mozilla/is.pl @@ -721,7 +721,7 @@ sub post { $form->{addition} = $form->{print_and_post} ? "PRINTED AND POSTED" : $form->{storno} ? "STORNO" : "POSTED"; - $form->save_history($form->dbconnect(\%myconfig)); + $form->save_history; } if (!$form->{no_redirect_after_post}) { @@ -942,7 +942,7 @@ sub yes { if(!exists $form->{addition}) { $form->{snumbers} = qq|invnumber_| . $form->{invnumber}; $form->{addition} = "DELETED"; - $form->save_history($form->dbconnect(\%myconfig)); + $form->save_history; } # /saving the history $form->redirect($locale->text('Invoice deleted!')); diff --git a/bin/mozilla/oe.pl b/bin/mozilla/oe.pl index a2085f6a0..5ded2b7aa 100644 --- a/bin/mozilla/oe.pl +++ b/bin/mozilla/oe.pl @@ -1063,7 +1063,7 @@ sub save_and_close { if(!exists $form->{addition}) { $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber}; $form->{addition} = "SAVED"; - $form->save_history($form->dbconnect(\%myconfig)); + $form->save_history; } # /saving the history @@ -1171,7 +1171,7 @@ sub save { if(!exists $form->{addition}) { $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber}; $form->{addition} = "SAVED"; - $form->save_history($form->dbconnect(\%myconfig)); + $form->save_history; } # /saving the history @@ -1259,7 +1259,7 @@ sub delete_order_quotation { if(!exists $form->{addition}) { $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber}; $form->{addition} = "DELETED"; - $form->save_history($form->dbconnect(\%myconfig)); + $form->save_history; } # /saving the history $form->info($msg); diff --git a/bin/mozilla/pe.pl b/bin/mozilla/pe.pl index e003e07d2..532dcfac5 100644 --- a/bin/mozilla/pe.pl +++ b/bin/mozilla/pe.pl @@ -195,7 +195,7 @@ sub save { if(!exists $form->{addition} && $form->{id} ne "") { $form->{snumbers} = qq|projectnumber_| . $form->{projectnumber}; $form->{addition} = "SAVED"; - $form->save_history($form->dbconnect(\%myconfig)); + $form->save_history; } # /saving the history @@ -223,7 +223,7 @@ sub delete { if(!exists $form->{addition}) { $form->{snumbers} = qq|projectnumber_| . $form->{projectnumber}; $form->{addition} = "DELETED"; - $form->save_history($form->dbconnect(\%myconfig)); + $form->save_history; } # /saving the history $main::lxdebug->leave_sub(); diff --git a/bin/mozilla/projects.pl b/bin/mozilla/projects.pl index 0e74d53e2..a59ecc978 100644 --- a/bin/mozilla/projects.pl +++ b/bin/mozilla/projects.pl @@ -235,7 +235,7 @@ sub save { $form->{id} = $project->{id}; $form->{snumbers} = qq|projectnumber_| . $project->{projectnumber}; $form->{addition} = "SAVED"; - $form->save_history($form->dbconnect(\%myconfig)); + $form->save_history; } # /saving the history @@ -278,7 +278,7 @@ sub delete { if(!exists $form->{addition}) { $form->{snumbers} = qq|projectnumber_| . $project->{projectnumber}; $form->{addition} = "DELETED"; - $form->save_history($form->dbconnect(\%myconfig)); + $form->save_history; } # /saving the history diff --git a/bin/mozilla/rp.pl b/bin/mozilla/rp.pl index b7adc2176..c5f2c3f3b 100644 --- a/bin/mozilla/rp.pl +++ b/bin/mozilla/rp.pl @@ -2062,7 +2062,7 @@ sub print_form { $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber}; $form->{addition} = "PRINTED"; $form->{what_done} = $form->{type}; - $form->save_history($form->dbconnect(\%myconfig)); + $form->save_history; } # /saving the history $main::lxdebug->leave_sub(); -- 2.20.1