summaryrefslogtreecommitdiff
path: root/lib/RHRD
diff options
context:
space:
mode:
Diffstat (limited to 'lib/RHRD')
-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 = ?};