]> wagnertech.de Git - mfinanz.git/blobdiff - SL/IC.pm
IC: Umstellung IC::save auf single dbh
[mfinanz.git] / SL / IC.pm
index 0b5db7e844a92c62cadc4135abb6b3adda47e673..305d3f34c3c76049b5cb06959d9ce16bb79013f2 100644 (file)
--- a/SL/IC.pm
+++ b/SL/IC.pm
@@ -193,8 +193,7 @@ sub get_pricegroups {
 
   my $i = 1;
   foreach my $pg (@{ $pricegroups }) {
-    $form->{"klass_$i"} = "$pg->{id}";
-    $form->{"price_$i"} = $form->format_amount($myconfig, $form->{"price_$i"}, -2);
+    $form->{"price_$i"}         = $form->format_amount($myconfig, $form->{"price_$i"}, -2);
     $form->{"pricegroup_id_$i"} = "$pg->{id}";
     $form->{"pricegroup_$i"}    = "$pg->{pricegroup}";
     $i++;
@@ -225,12 +224,20 @@ sub retrieve_buchungsgruppen {
 }
 
 sub save {
+  my ($self, $myconfig, $form) = @_;
   $main::lxdebug->enter_sub();
 
+  my $rc = SL::DB->client->with_transaction(\&_save, $self, $myconfig, $form);
+
+  $main::lxdebug->leave_sub();
+  return $rc;
+}
+
+sub _save {
   my ($self, $myconfig, $form) = @_;
   my @values;
   # connect to database, turn off AutoCommit
-  my $dbh = $form->get_standard_dbh;
+  my $dbh = SL::DB->client->dbh;
   my $restricter = SL::HTML::Restrict->create;
 
   # save the part
@@ -328,7 +335,6 @@ sub save {
          partnumber = ?,
          description = ?,
          makemodel = ?,
-         alternate = 'f',
          assembly = ?,
          listprice = ?,
          sellprice = ?,
@@ -537,12 +543,7 @@ sub save {
 SQL
   do_query($form, $dbh, $query, ($form->{id}) x 2);
 
-  # commit
-  my $rc = $dbh->commit;
-
-  $main::lxdebug->leave_sub();
-
-  return $rc;
+  return 1;
 }
 
 sub retrieve_assemblies {