summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2015-10-06 01:28:21 (GMT)
committerChristian Pointner <equinox@spreadspace.org>2015-10-06 01:28:21 (GMT)
commita7b6abe6afb412f1a3f9efb07d51c71ed3127bae (patch)
tree1e96a983a83c21c0302c9b07fec958997b97f286 /lib
parent00e77d7b60e850a6f1df2e3fcd6a3c795f9663de (diff)
creation of show macro cart is working now as well
Diffstat (limited to 'lib')
-rwxr-xr-xlib/RHRD/rddb.pm55
1 files changed, 53 insertions, 2 deletions
diff --git a/lib/RHRD/rddb.pm b/lib/RHRD/rddb.pm
index e1afd55..d87acb7 100755
--- a/lib/RHRD/rddb.pm
+++ b/lib/RHRD/rddb.pm
@@ -1002,7 +1002,7 @@ sub create_show_log
return (undef, 'ERROR', "Log with name '" . $logname . "' already exists")
}
- my $sql = qq{insert into LOGS set NAME = ?, LOG_EXISTS='N', TYPE=0, DESCRIPTION = ?, ORIGIN_USER = ?, ORIGIN_DATETIME=NOW(), LINK_DATETIME=NOW(), SERVICE = ?};
+ my $sql = qq{insert into LOGS (NAME, LOG_EXISTS, TYPE, DESCRIPTION, ORIGIN_USER, ORIGIN_DATETIME, LINK_DATETIME, SERVICE) values (?, 'N', 0, ?, ?, NOW(), NOW(), ?)};
my $sth = $ctx->{'dbh'}->prepare($sql)
or return (undef, 'ERROR', "Database Error: " . $ctx->{'dbh'}->errstr);
@@ -1010,8 +1010,10 @@ sub create_show_log
$sth->execute($logname, $logname . " log", $ctx->{'config'}{'shows'}{'defaultuser'}, $ctx->{'config'}{'shows'}{'service'})
or return (undef, 'ERROR', "Database Error: " . $sth->errstr);
+ $sth->finish();
+
(my $result, $status, $errorstring) = create_log_table($ctx, $logname);
- unless (defined $result && defined $status) {
+ unless (defined $result) {
return (undef, $status, $errorstring);
}
@@ -1039,9 +1041,58 @@ sub create_show_log
$sth->execute($next_id, $logname)
or return (undef, 'ERROR', "Database Error: " . $sth->errstr);
+ $sth->finish();
+
return (1, 'OK', 'success');
}
+sub get_next_free_showid
+{
+ my ($ctx) = @_;
+
+ my ($low, $high, $type, undef) = RHRD::rddb::get_group_carts($ctx, $ctx->{'config'}{'specialgroups'}{'shows'});
+ unless(defined $low) {
+ return (undef, $high, $type);
+ }
+
+ my $sql = qq{select NUMBER from CART where GROUP_NAME = ? order by NUMBER};
+
+ my $sth = $ctx->{'dbh'}->prepare($sql)
+ or return (undef, 'ERROR', "Database Error: " . $ctx->{'dbh'}->errstr);
+
+ $sth->execute($ctx->{'config'}{'specialgroups'}{'shows'})
+ or return (undef, 'ERROR', "Database Error: " . $sth->errstr);
+
+ my $show_id = $low;
+ while(my ($cart) = $sth->fetchrow_array()) {
+ last if($show_id < $cart);
+ $show_id += 1;
+ }
+ $sth->finish();
+
+ return ($show_id, 'OK', 'success');
+}
+
+sub create_show_macro_cart
+{
+ my ($ctx, $logname, $title) = @_;
+ my $macro = 'LL 1 ' . $logname . ' 0!';
+
+ my ($number, $status, $errorstring) = get_next_free_showid($ctx);
+
+ my $sql = qq{insert into CART (NUMBER, TYPE, GROUP_NAME, TITLE, MACROS, VALIDITY, METADATA_DATETIME) values (?, 2, ?, ?, ?, 3, NOW())};
+
+ my $sth = $ctx->{'dbh'}->prepare($sql)
+ or return (undef, 'ERROR', "Database Error: " . $ctx->{'dbh'}->errstr);
+
+ $sth->execute($number, $ctx->{'config'}{'specialgroups'}{'shows'}, $title, $macro)
+ or return (undef, 'ERROR', "Database Error: " . $sth->errstr);
+
+ $sth->finish();
+
+ return ($number, 'OK', 'success');
+}
+
########################### MUSICPOOL handling ###########################
sub get_musicpools_cart_range