summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2015-10-09 20:12:01 (GMT)
committerChristian Pointner <equinox@spreadspace.org>2015-10-09 20:12:01 (GMT)
commit79151dc4de2bb8758cd220ee0111c25edadc99e7 (patch)
tree457cf90acdb7ae79f986d5838eafc26869973708 /lib
parent439d98c65289f19662459106de1cc1a40ee2c5f4 (diff)
fill carts into log table with corret type
Diffstat (limited to 'lib')
-rwxr-xr-xlib/RHRD/rddb.pm29
1 files changed, 24 insertions, 5 deletions
diff --git a/lib/RHRD/rddb.pm b/lib/RHRD/rddb.pm
index 3a6bf21..48aed35 100755
--- a/lib/RHRD/rddb.pm
+++ b/lib/RHRD/rddb.pm
@@ -264,6 +264,8 @@ sub create_log_table
$sth->execute(RD_FADE_DEPTH, RD_FADE_DEPTH, RD_FADE_DEPTH)
or return (undef, 'ERROR', "Database Error: " . $sth->errstr);
+ $sth->finish();
+
return (1, 'OK', 'success');
}
@@ -274,15 +276,26 @@ sub fill_log_table
my @carts = @_;
$logname = get_log_table_name($ctx, $logname);
- my $sql = qq{insert into $logname (ID, COUNT, START_TIME, CART_NUMBER, TRANS_TYPE) values (?, ?, ?, ?, ?);};
+ my $sql_log = qq{insert into $logname (ID, COUNT, TYPE, START_TIME, CART_NUMBER, TRANS_TYPE) values (?, ?, ?, ?, ?, ?);};
+ my $sql_cart_type = qq{select TYPE from CART where NUMBER = ?;};
- my $sth = $ctx->{'dbh'}->prepare($sql)
+ my $sth_log = $ctx->{'dbh'}->prepare($sql_log)
+ or return (undef, 'ERROR', "Database Error: " . $ctx->{'dbh'}->errstr);
+
+ my $sth_cart_type = $ctx->{'dbh'}->prepare($sql_cart_type)
or return (undef, 'ERROR', "Database Error: " . $ctx->{'dbh'}->errstr);
my $cnt = 0;
for my $cart (@carts) {
- $sth->execute($cnt + 1, $cnt, $cart->{'START_TIME'}, $cart->{'NUMBER'}, $cart->{'TRANS_TYPE'})
- or return (undef, 'ERROR', "Database Error: " . $sth->errstr);
+ $sth_cart_type->execute($cart->{'NUMBER'})
+ or return (undef, 'ERROR', "Database Error: " . $sth_log->errstr);
+
+ my ($type) = $sth_cart_type->fetchrow_array;
+ $type = 0 unless(defined($type) && $type == 2);
+
+ $sth_log->execute($cnt + 1, $cnt, $type, $cart->{'START_TIME'}, $cart->{'NUMBER'}, $cart->{'TRANS_TYPE'})
+ or return (undef, 'ERROR', "Database Error: " . $sth_log->errstr);
+ $sth_log->finish();
$cnt++;
}
@@ -861,6 +874,7 @@ sub get_dropboxes
my ($title, $log, $status, $errorstring) = get_show_title_and_log($ctx, $to_cart);
unless (defined $title && defined $log) {
+ $sth->finish();
return (undef, $status, $errorstring);
}
$entry->{'SHOWTITLE'} = $title;
@@ -934,6 +948,7 @@ sub list_shows
$entry->{'ID'} = $to_cart;
my ($title, $log, $status, $errorstring) = get_show_title_and_log($ctx, $to_cart);
unless (defined $title && defined $log) {
+ $sth->finish();
return (undef, $status, $errorstring);
}
$entry->{'TITLE'} = $title;
@@ -1017,6 +1032,8 @@ sub get_show_group
or return (undef, 'ERROR', "Database Error: " . $sth->errstr);
my ($groupname) = $sth->fetchrow_array();
+ $sth->finish();
+
unless(defined($groupname)) {
return (undef, 'ERROR', "Show not found");
}
@@ -1035,6 +1052,8 @@ sub get_show_group_cart_range
or return (undef, undef, 'ERROR', "Database Error: " . $sth->errstr);
my ($group_low_cart, $group_high_cart) = $sth->fetchrow_array();
+ $sth->finish();
+
unless(defined($group_low_cart) && defined($group_high_cart)) {
return (undef, undef, 'ERROR', "Show not found");
}
@@ -1337,8 +1356,8 @@ sub remove_show
my $cnt = 0;
for my $cart (@show_carts) {
$cnt += ($sth->execute($cart) or return (undef, 'ERROR', "Database Error: " . $sth->errstr));
+ $sth->finish();
}
- $sth->finish();
push @actions, { name => 'audio carts', cnt => $cnt };
}