Vermeidung von SQL injection durch Verwendung von parametrisierten Queries. Zusätzlic...
[kivitendo-erp.git] / SL / DN.pm
1 #======================================================================
2 # LX-Office ERP
3 # Copyright (C) 2006
4 # Based on SQL-Ledger Version 2.1.9
5 # Web http://www.lx-office.org
6 #
7 #=====================================================================
8 # SQL-Ledger Accounting
9 # Copyright (C) 1998-2002
10 #
11 #  Author: Dieter Simader
12 #   Email: dsimader@sql-ledger.org
13 #     Web: http://www.sql-ledger.org
14 #
15 #  Contributors:
16 #
17 # This program is free software; you can redistribute it and/or modify
18 # it under the terms of the GNU General Public License as published by
19 # the Free Software Foundation; either version 2 of the License, or
20 # (at your option) any later version.
21 #
22 # This program is distributed in the hope that it will be useful,
23 # but WITHOUT ANY WARRANTY; without even the implied warranty of
24 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25 # GNU General Public License for more details.
26 # You should have received a copy of the GNU General Public License
27 # along with this program; if not, write to the Free Software
28 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 #======================================================================
30 #
31 # Dunning process module
32 #
33 #======================================================================
34
35 package DN;
36
37 use SL::Template;
38 use SL::IS;
39 use SL::Common;
40 use SL::DBUtils;
41 use Data::Dumper;
42
43 sub get_config {
44   $main::lxdebug->enter_sub();
45
46   my ($self, $myconfig, $form) = @_;
47
48   # connect to database
49   my $dbh = $form->dbconnect($myconfig);
50
51   my $query =
52     qq|SELECT * | .
53     qq|FROM dunning_config | .
54     qq|ORDER BY dunning_level|;
55   $form->{DUNNING} = selectall_hashref_query($form, $dbh, $query);
56
57   foreach my $ref (@{ $form->{DUNNING} }) {
58     $ref->{fee} = $form->format_amount($myconfig, $ref->{fee}, 2);
59     $ref->{interest} = $form->format_amount($myconfig, ($ref->{interest} * 100));
60   }
61
62   $dbh->disconnect();
63
64   $main::lxdebug->leave_sub();
65 }
66
67 sub save_config {
68   $main::lxdebug->enter_sub();
69
70   my ($self, $myconfig, $form) = @_;
71
72   # connect to database
73   my $dbh = $form->dbconnect_noauto($myconfig);
74
75   my ($query, @values);
76
77   for my $i (1 .. $form->{rowcount}) {
78     $form->{"fee_$i"} = $form->parse_amount($myconfig, $form->{"fee_$i"}) * 1;
79     $form->{"interest_$i"} = $form->parse_amount($myconfig, $form->{"interest_$i"}) / 100;
80
81     if (($form->{"dunning_level_$i"} ne "") &&
82         ($form->{"dunning_description_$i"} ne "")) {
83       @values = (conv_i($form->{"dunning_level_$i"}), $form->{"dunning_description_$i"},
84                  $form->{"email_subject_$i"}, $form->{"email_body_$i"},
85                  $form->{"template_$i"}, $form->{"fee_$i"}, $form->{"interest_$i"},
86                  $form->{"active_$i"} ? 't' : 'f', $form->{"auto_$i"} ? 't' : 'f', $form->{"email_$i"} ? 't' : 'f',
87                  $form->{"email_attachment_$i"} ? 't' : 'f', conv_i($form->{"payment_terms_$i"}), conv_i($form->{"terms_$i"}));
88       if ($form->{"id_$i"}) {
89         $query =
90           qq|UPDATE dunning_config SET
91                dunning_level = ?, dunning_description = ?,
92                email_subject = ?, email_body = ?,
93                template = ?, fee = ?, interest = ?,
94                active = ?, auto = ?, email = ?,
95                email_attachment = ?, payment_terms = ?, terms = ?
96              WHERE id = ?|;
97         push(@values, conv_i($form->{"id_$i"}));
98       } else {
99         $query =
100           qq|INSERT INTO dunning_config
101                (dunning_level, dunning_description, email_subject, email_body,
102                 template, fee, interest, active, auto, email,
103                 email_attachment, payment_terms, terms)
104              VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)|;
105       }
106       do_query($form, $dbh, $query, @values);
107     }
108
109     if (($form->{"dunning_description_$i"} eq "") && ($form->{"id_$i"})) {
110       $query = qq|DELETE FROM dunning_config WHERE id = ?|;
111       do_query($form, $dbh, $query, $form->{"id_$i"});
112     }
113   }
114
115   $dbh->commit;
116   $dbh->disconnect;
117
118   $main::lxdebug->leave_sub();
119 }
120
121 sub save_dunning {
122   $main::lxdebug->enter_sub();
123
124   my ($self, $myconfig, $form, $rows, $userspath,$spool, $sendmail) = @_;
125   # connect to database
126   my $dbh = $form->dbconnect_noauto($myconfig);
127
128   my ($query, @values);
129
130   foreach my $row (@{ $rows }) {
131
132     $form->{"interest_$row"} = $form->parse_amount($myconfig,$form->{"interest_$row"});
133     $form->{"fee_$row"} = $form->parse_amount($myconfig,$form->{"fee_$row"});
134     $form->{send_email} = $form->{"email_$row"};
135
136     $query = qq|UPDATE ar SET dunning_id = ? WHERE id = ?|;
137     @values = ($form->{"next_dunning_id_$row"}, $form->{"inv_id_$row"});
138     do_query($form, $dbh, $query, @values);
139     $query =
140       qq|INSERT INTO dunning (dunning_id, dunning_level, trans_id, fee,
141                               interest, transdate, duedate)
142          VALUES (?, (SELECT dunning_level FROM dunning_config WHERE id = ?),
143                  ?, ?, ?, current_date, ?)|;
144     @values = (conv_i($form->{"next_dunning_id_$row"}),
145                conv_i($form->{"next_dunning_id_$row"}),
146                conv_i($form->{"inv_id_$row"}), $form->{"fee_$row"},
147                $form->{"interest_$row"},
148                conv_date($form->{"next_duedate_$row"}));
149     do_query($form, $dbh, $query, @values);
150   }
151
152   my $query =
153     qq|SELECT invnumber, ordnumber, customer_id, amount, netamount,
154          ar.transdate, ar.duedate, paid, amount - paid AS open_amount,
155          template AS formname, email_subject, email_body, email_attachment,
156          da.fee, da.interest, da.transdate AS dunning_date,
157          da.duedate AS dunning_duedate
158        FROM ar LEFT JOIN dunning_config ON (dunning_config.id = ar.dunning_id)
159        LEFT JOIN dunning da ON (ar.id = da.trans_id AND dunning_config.dunning_level = da.dunning_level)
160        WHERE ar.id IN (|
161        . join(", ", map("?", @{ $form->{"inv_ids"} })) . qq|)|;
162
163   my $sth = prepare_execute_query($form, $dbh, $query, @{ $form->{"inv_ids"} });
164   my $first = 1;
165   while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
166     if ($first) {
167       map({ $form->{"dn_$_"} = []; } keys(%{$ref}));
168       $first = 0;
169     }
170     map { $ref->{$_} = $form->format_amount($myconfig, $ref->{$_}, 2) } qw(amount netamount paid open_amount fee interest);
171     map { $form->{$_} = $ref->{$_} } keys %$ref;
172     #print(STDERR Dumper($ref));
173     map { push(@{ $form->{"dn_$_"} }, $ref->{$_})} keys %$ref;
174   }
175   $sth->finish;
176
177   IS->customer_details($myconfig,$form);
178   #print(STDERR Dumper($form->{dn_invnumber}));
179   $form->{templates} = "$myconfig->{templates}";
180
181
182
183   $form->{language} = $form->get_template_language(\%myconfig);
184   $form->{printer_code} = $form->get_printer_code(\%myconfig);
185
186   if ($form->{language} ne "") {
187     $form->{language} = "_" . $form->{language};
188   }
189
190   if ($form->{printer_code} ne "") {
191     $form->{printer_code} = "_" . $form->{printer_code};
192   }
193
194   $form->{IN} = "$form->{formname}$form->{language}$form->{printer_code}.html";
195   if ($form->{format} eq 'postscript') {
196     $form->{postscript} = 1;
197     $form->{IN} =~ s/html$/tex/;
198   } elsif ($form->{"format"} =~ /pdf/) {
199     $form->{pdf} = 1;
200     if ($form->{"format"} =~ /opendocument/) {
201       $form->{IN} =~ s/html$/odt/;
202     } else {
203       $form->{IN} =~ s/html$/tex/;
204     }
205   } elsif ($form->{"format"} =~ /opendocument/) {
206     $form->{"opendocument"} = 1;
207     $form->{"IN"} =~ s/html$/odt/;
208   }
209
210   if ($form->{"send_email"} && ($form->{email} ne "")) {
211     $form->{media} = 'email';
212   }
213
214   $form->{keep_tmpfile} = 0;
215   if ($form->{media} eq 'email') {
216     $form->{subject} = qq|$form->{label} $form->{"${inv}number"}|
217       unless $form->{subject};
218     if (!$form->{email_attachment}) {
219       $form->{do_not_attach} = 1;
220     } else {
221       $form->{do_not_attach} = 0;
222     }
223     $form->{subject} = parse_strings($myconfig, $form, $userspath, $form->{email_subject});
224     $form->{message} = parse_strings($myconfig, $form, $userspath, $form->{email_body});
225
226     $form->{OUT} = "$sendmail";
227
228   } else {
229
230     my $filename = Common::unique_id() . $form->{login} . ".pdf";
231     $form->{OUT} = ">$spool/$filename";
232     push(@{ $form->{DUNNING_PDFS} }, $filename);
233     $form->{keep_tmpfile} = 1;
234   }
235
236   $form->parse_template($myconfig, $userspath);
237
238   $dbh->commit;
239   $dbh->disconnect;
240
241   $main::lxdebug->leave_sub();
242 }
243
244 sub get_invoices {
245
246   $main::lxdebug->enter_sub();
247
248   my ($self, $myconfig, $form) = @_;
249
250   # connect to database
251   my $dbh = $form->dbconnect($myconfig);
252
253   my $where =
254     qq| WHERE (a.paid < a.amount)
255           AND (a.duedate < current_date)
256           AND (dnn.id =
257             (SELECT id FROM dunning_config
258              WHERE dunning_level >
259                (SELECT
260                   CASE
261                     WHEN a.dunning_id IS NULL
262                     THEN 0
263                     ELSE (SELECT dunning_level FROM dunning_config WHERE id = a.dunning_id ORDER BY dunning_level LIMIT 1)
264                   END
265                 FROM dunning_config LIMIT 1)
266              LIMIT 1)) |;
267   my @values;
268
269   $form->{customer_id} = $1 if ($form->{customer} =~ /--(\d+)$/);
270
271   if ($form->{customer_id}) {
272     $where .= qq| AND (a.customer_id = ?)|;
273     push(@values, $form->{customer_id});
274
275   } elsif ($form->{customer}) {
276     $where .= qq| AND (ct.name ILIKE ?)|;
277     push(@values, '%' . $form->{customer} . '%');
278   }
279
280   my %columns = (
281     "ordnumber" => "a.ordnumber",
282     "invnumber" => "a.invnumber",
283     "notes" => "a.notes",
284     );
285   foreach my $key (keys(%columns)) {
286     next unless ($form->{$key});
287     $where .= qq| AND $columns{$key} ILIKE ?|;
288     push(@values, '%' . $form->{$key} . '%');
289   }
290
291   if ($form->{dunning_level}) {
292     $where .= qq| AND a.dunning_id = ?|;
293     push(@values, conv_i($form->{dunning_level}));
294   }
295
296   $form->{minamount} = $form->parse_amount($myconfig,$form->{minamount});
297   if ($form->{minamount}) {
298     $where .= qq| AND ((a.amount - a.paid) > ?) |;
299     push(@values, $form->{minamount});
300   }
301
302   $paymentdate = $form->{paymentuntil} ? $dbh->quote($form->{paymentuntil}) :
303     "current_date";
304
305   $query =
306     qq|SELECT a.id, a.ordnumber, a.transdate, a.invnumber, a.amount,
307          ct.name AS customername, a.customer_id, a.duedate,
308          da.fee AS old_fee, dnn.active, dnn.email, dnn.fee + da.fee AS fee,
309          dn.dunning_description, da.transdate AS dunning_date, da.duedate AS dunning_duedate,
310          a.duedate + dnn.terms - current_date AS nextlevel,
311          $paymentdate - a.duedate AS pastdue, dn.dunning_level,
312          current_date + dnn.payment_terms AS next_duedate,
313          dnn.dunning_description AS next_dunning_description, dnn.id AS next_dunning_id,
314          dnn.interest AS interest_rate, dnn.terms
315        FROM dunning_config dnn, ar a
316        JOIN customer ct ON (a.customer_id = ct.id)
317        LEFT JOIN dunning_config dn ON (dn.id = a.dunning_id)
318        LEFT JOIN dunning da ON ((da.trans_id = a.id) AND (dn.dunning_level = da.dunning_level))
319        $where
320        ORDER BY a.id, transdate, duedate, name|;
321
322   my $sth = prepare_execute_query($form, $dbh, $query, @values);
323
324   $form->{DUNNINGS} = [];
325
326   while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
327     $ref->{interest} = ($ref->{amount} * $ref->{pastdue} * $ref->{interest_rate}) / 360;
328     $ref->{interest} = $form->round_amount($ref->{interest}, 2);
329     map({ $ref->{$_} = $form->format_amount($myconfig, $ref->{$_}, 2)} qw(amount fee interest));
330     if ($ref->{pastdue} >= $ref->{terms}) {
331       push(@{ $form->{DUNNINGS} }, $ref);
332     }
333   }
334
335   $sth->finish;
336
337   $query = qq|SELECT id, dunning_description FROM dunning_config ORDER BY dunning_level|;
338   $form->{DUNNING_CONFIG} = selectall_hashref_query($form, $dbh, $query);
339
340   $dbh->disconnect;
341   $main::lxdebug->leave_sub();
342 }
343
344 sub get_dunning {
345
346   $main::lxdebug->enter_sub();
347
348   my ($self, $myconfig, $form) = @_;
349
350   # connect to database
351   my $dbh = $form->dbconnect($myconfig);
352
353   $where = qq| WHERE (da.trans_id = a.id)|;
354
355   my @values;
356
357   $form->{customer_id} = $1 if ($form->{customer} =~ /--(\d+)$/);
358
359   if ($form->{customer_id}) {
360     $where .= qq| AND (a.customer_id = ?)|;
361     push(@values, $form->{customer_id});
362
363   } elsif ($form->{customer}) {
364     $where .= qq| AND (ct.name ILIKE ?)|;
365     push(@values, '%' . $form->{customer} . '%');
366   }
367
368
369   my %columns = (
370     "ordnumber" => "a.ordnumber",
371     "invnumber" => "a.invnumber",
372     "notes" => "a.notes",
373     );
374   foreach my $key (keys(%columns)) {
375     next unless ($form->{$key});
376     $where .= qq| AND $columns{$key} ILIKE ?|;
377     push(@values, '%' . $form->{$key} . '%');
378   }
379
380   if ($form->{dunning_level}) {
381     $where .= qq| AND a.dunning_id = ?|;
382     push(@values, conv_i($form->{dunning_level}));
383   }
384
385   $form->{minamount} = $form->parse_amount($myconfig,$form->{minamount});
386   if ($form->{minamount}) {
387     $where .= qq| AND ((a.amount - a.paid) > ?) |;
388     push(@values, $form->{minamount});
389   }
390
391   if (!$form->{showold}) {
392     $where .= qq| AND (a.amount > a.paid) AND (da.dunning_id = a.dunning_id) |;
393   }
394
395   if ($form->{transdatefrom}) {
396     $where .= qq| AND a.transdate >= ?|;
397     push(@values, $form->{transdatefrom});
398   }
399   if ($form->{transdateto}) {
400     $where .= qq| AND a.transdate <= ?|;
401     push(@values, $form->{transdateto});
402   }
403   if ($form->{dunningfrom}) {
404     $where .= qq| AND da.transdate >= ?|;
405     push(@values, $form->{dunningfrom});
406   }
407   if ($form->{dunningto}) {
408     $where .= qq| AND da.transdate >= ?|;
409     push(@values, $form->{dunningto});
410   }
411
412   $query =
413     qq|SELECT a.id, a.ordnumber, a.invoice, a.transdate, a.invnumber, a.amount,
414         ct.name AS customername, ct.id AS customer_id, a.duedate, da.fee,
415         da.interest, dn.dunning_description, da.transdate AS dunning_date, da.duedate AS dunning_duedate, da.dunning_id
416       FROM ar a
417       JOIN customer ct ON (a.customer_id = ct.id), dunning da
418       LEFT JOIN dunning_config dn ON (da.dunning_id = dn.id)
419       $where
420       ORDER BY name, a.id|;
421
422   $form->{DUNNINGS} = selectall_hashref_query($form, $dbh, $query, @values);
423
424   foreach my $ref (@{ $form->{DUNNINGS} }) {
425     map { $ref->{$_} = $form->format_amount($myconfig, $ref->{$_}, 2)} qw(amount fee interest);
426   }
427
428   $dbh->disconnect;
429   $main::lxdebug->leave_sub();
430 }
431
432 sub parse_strings {
433
434   $main::lxdebug->enter_sub();
435
436   my ($myconfig, $form, $userspath, $string) = @_;
437
438   my $format = $form->{format};
439   $form->{format} = "html";
440
441   $tmpstring = "parse_string.html";
442   $tmpfile = "$myconfig->{templates}/$tmpstring";
443   open(OUT, ">$tmpfile") or $form->error("$tmpfile : $!");
444   print(OUT $string);
445   close(OUT);
446
447   my $in = $form->{IN};
448   $form->{IN} = $tmpstring;
449   $template = HTMLTemplate->new($tmpstring, $form, $myconfig, $userspath);
450
451   my $fileid = time;
452   $form->{tmpfile} = "$userspath/${fileid}.$tmpstring";
453   $out = $form->{OUT};
454   $form->{OUT} = ">$form->{tmpfile}";
455
456   if ($form->{OUT}) {
457     open(OUT, "$form->{OUT}") or $form->error("$form->{OUT} : $!");
458   }
459   if (!$template->parse(*OUT)) {
460     $form->cleanup();
461     $form->error("$form->{IN} : " . $template->get_error());
462   }
463
464   close(OUT);
465   my $result = "";
466   open(IN, $form->{tmpfile}) or $form->error($form->cleanup . "$form->{tmpfile} : $!");
467
468   while (<IN>) {
469     $result .= $_;
470   }
471
472   close(IN);
473 #   unlink($tmpfile);
474 #   unlink($form->{tmpfile});
475   $form->{IN} = $in;
476   $form->{format} = $format;
477
478   $main::lxdebug->leave_sub();
479   return $result;
480 }
481
482 sub melt_pdfs {
483
484   $main::lxdebug->enter_sub();
485
486   my ($self, $myconfig, $form, $userspath) = @_;
487
488   map({ $_ =~ s|.*/||g; } @{ $form->{DUNNING_PDFS} });
489
490   foreach my $file (@{ $form->{DUNNING_PDFS} }) {
491     $inputfiles .= " $userspath/$file ";
492   }
493
494   my $outputfile = "$userspath/dunning.pdf";
495   system("gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=$outputfile $inputfiles");
496   foreach my $file (@{ $form->{DUNNING_PDFS} }) {
497     unlink("$userspath/$file");
498   }
499   $out = "";
500
501   $form->{OUT} = $out;
502
503   my $numbytes = (-s $outputfile);
504   open(IN, $outputfile)
505     or $form->error($self->cleanup . "$outputfile : $!");
506
507   $form->{copies} = 1 unless $form->{media} eq 'printer';
508
509   chdir("$self->{cwd}");
510
511   for my $i (1 .. $form->{copies}) {
512     if ($form->{OUT}) {
513       open(OUT, $form->{OUT})
514         or $form->error($form->cleanup . "$form->{OUT} : $!");
515     } else {
516
517       # launch application
518       print qq|Content-Type: Application/PDF
519 Content-Disposition: attachment; filename="$outputfile"
520 Content-Length: $numbytes
521
522 |;
523
524       open(OUT, ">-") or $form->error($form->cleanup . "$!: STDOUT");
525
526     }
527
528     while (<IN>) {
529       print OUT $_;
530     }
531
532     close(OUT);
533
534     seek(IN, 0, 0);
535   }
536
537   close(IN);
538   unlink("$userspath/$outputfile");
539
540   $main::lxdebug->leave_sub();
541 }
542
543 sub print_dunning {
544   $main::lxdebug->enter_sub();
545
546   my ($self, $myconfig, $form, $dunning_id, $customer_id, $userspath,$spool, $sendmail) = @_;
547   # connect to database
548   my $dbh = $form->dbconnect_noauto($myconfig);
549
550   my $query =
551     qq|SELECT invnumber, ordnumber, customer_id, amount, netamount,
552          ar.transdate, ar.duedate, paid, amount - paid AS open_amount,
553          template AS formname, email_subject, email_body, email_attachment,
554          da.fee, da.interest, da.transdate AS dunning_date, da.duedate AS dunning_duedate
555        FROM ar
556        LEFT JOIN dunning_config ON (dunning_config.id = ar.dunning_id)
557        LEFT JOIN dunning da ON ((ar.id = da.trans_id) AND (dunning_config.dunning_level = da.dunning_level))
558        WHERE (ar.dunning_id = ?) AND (customer_id = ?)|;
559
560   my $sth = prepare_execute_query($form, $dbh, $query, $dunning_id, $customer_id);
561   my $first = 1;
562   while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
563     if ($first) {
564       map({ $form->{"dn_$_"} = []; } keys(%{$ref}));
565       $first = 0;
566     }
567     map { $ref->{$_} = $form->format_amount($myconfig, $ref->{$_}, 2) } qw(amount netamount paid open_amount fee interest);
568     map { $form->{$_} = $ref->{$_} } keys %$ref;
569     map { push @{ $form->{"dn_$_"} }, $ref->{$_}} keys %$ref;
570   }
571   $sth->finish;
572
573   IS->customer_details($myconfig,$form);
574   $form->{templates} = "$myconfig->{templates}";
575
576   $form->{language} = $form->get_template_language(\%myconfig);
577   $form->{printer_code} = $form->get_printer_code(\%myconfig);
578
579   if ($form->{language} ne "") {
580     $form->{language} = "_" . $form->{language};
581   }
582
583   if ($form->{printer_code} ne "") {
584     $form->{printer_code} = "_" . $form->{printer_code};
585   }
586
587   $form->{IN} = "$form->{formname}$form->{language}$form->{printer_code}.html";
588   if ($form->{format} eq 'postscript') {
589     $form->{postscript} = 1;
590     $form->{IN} =~ s/html$/tex/;
591   } elsif ($form->{"format"} =~ /pdf/) {
592     $form->{pdf} = 1;
593     if ($form->{"format"} =~ /opendocument/) {
594       $form->{IN} =~ s/html$/odt/;
595     } else {
596       $form->{IN} =~ s/html$/tex/;
597     }
598   } elsif ($form->{"format"} =~ /opendocument/) {
599     $form->{"opendocument"} = 1;
600     $form->{"IN"} =~ s/html$/odt/;
601   }
602
603   if ($form->{"send_email"} && ($form->{email} ne "")) {
604     $form->{media} = 'email';
605   }
606
607   $form->{keep_tmpfile} = 0;
608   if ($form->{media} eq 'email') {
609     $form->{subject} = qq|$form->{label} $form->{"${inv}number"}|
610       unless $form->{subject};
611     if (!$form->{email_attachment}) {
612       $form->{do_not_attach} = 1;
613     } else {
614       $form->{do_not_attach} = 0;
615     }
616     $form->{subject} = parse_strings($myconfig, $form, $userspath, $form->{email_subject});
617     $form->{message} = parse_strings($myconfig, $form, $userspath, $form->{email_body});
618
619     $form->{OUT} = "$sendmail";
620
621   } else {
622
623     my $filename = Common::unique_id() . $form->{login} . ".pdf";
624
625     push(@{ $form->{DUNNING_PDFS} }, $filename);
626     $form->{keep_tmpfile} = 1;
627   }
628
629   $form->parse_template($myconfig, $userspath);
630
631   $dbh->commit;
632   $dbh->disconnect;
633
634   $main::lxdebug->leave_sub();
635 }
636
637 1;