diff options
-rwxr-xr-x | lib/RHRD/rddb.pm | 40 | ||||
-rwxr-xr-x | utils/rd-show | 3 |
2 files changed, 40 insertions, 3 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 = ?}; diff --git a/utils/rd-show b/utils/rd-show index c193f11..0ec08da 100755 --- a/utils/rd-show +++ b/utils/rd-show @@ -235,10 +235,11 @@ sub add print STDERR $status . ": " . $errorstring . "\n"; return 1; } + print " * created log with name: " . $name . "\n"; # TODO: # create macro cart referencing log -> show-id - # create dropbox for: groupname, show-id, $rhythm, $dow, $starttime, $len + # create dropbox for: groupname, show-id, rhythm, dow, starttime, len print " * finished\n"; |