summaryrefslogtreecommitdiff
path: root/lib/RHRD/rddb.pm
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2015-10-06 00:48:17 (GMT)
committerChristian Pointner <equinox@spreadspace.org>2015-10-06 00:48:17 (GMT)
commit00e77d7b60e850a6f1df2e3fcd6a3c795f9663de (patch)
treea1149a2457b84d4e049331c13b11a5709aeaae47 /lib/RHRD/rddb.pm
parent07713309fa3d14e2ff3926901f7571507f44fa32 (diff)
log gets now filled with actual carts
Diffstat (limited to 'lib/RHRD/rddb.pm')
-rwxr-xr-xlib/RHRD/rddb.pm40
1 files changed, 38 insertions, 2 deletions
diff --git a/lib/RHRD/rddb.pm b/lib/RHRD/rddb.pm
index e3e4b0b..e1afd55 100755
--- a/lib/RHRD/rddb.pm
+++ b/lib/RHRD/rddb.pm
@@ -257,6 +257,29 @@ sub create_log_table
return (1, 'OK', 'success');
}
+sub fill_log_table
+{
+ my $ctx = shift;
+ my $logname = shift;
+ my @carts = @_;
+
+ $logname=~s/ /_/g;
+ $logname = $ctx->{'dbh'}->quote_identifier($logname . '_LOG');
+ my $sql = qq{insert into $logname (ID, COUNT, START_TIME, CART_NUMBER, TRANS_TYPE) values (?, ?, ?, ?, ?);};
+
+ my $sth = $ctx->{'dbh'}->prepare($sql)
+ 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);
+
+ $cnt++;
+ }
+
+ return ($cnt+1, 'OK', 'success');
+}
########################### TOKEN handling ###########################
@@ -992,8 +1015,21 @@ sub create_show_log
return (undef, $status, $errorstring);
}
-# TODO: fill up new log with cart references
- my $next_id = 0;
+ my @carts = ();
+ for my $cart (@{$ctx->{'config'}{'shows'}{'logprefix'}}) {
+ push @carts, { NUMBER => $cart, START_TIME => 0, TRANS_TYPE => 2 };
+ }
+ for my $cart ($low_cart .. $high_cart) {
+ push @carts, { NUMBER => $cart, START_TIME => 0, TRANS_TYPE => 0 };
+ }
+ for my $cart (@{$ctx->{'config'}{'shows'}{'logsuffix'}}) {
+ push @carts, { NUMBER => $cart, START_TIME => 0, TRANS_TYPE => 0 };
+ }
+
+ (my $next_id, $status, $errorstring) = fill_log_table($ctx, $logname, @carts);
+ unless (defined $next_id) {
+ return (undef, $status, $errorstring);
+ }
$sql = qq{update LOGS set LOG_EXISTS='Y', AUTO_REFRESH='Y', NEXT_ID = ? where NAME = ?};