summaryrefslogtreecommitdiff
path: root/lib/RHRD/rddb.pm
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2016-07-31 12:43:47 (GMT)
committerChristian Pointner <equinox@helsinki.at>2016-07-31 12:43:47 (GMT)
commitaf294a1f65fd66f0a0ecf59e199785703d1b947e (patch)
tree50014968aca2abafee7987e18eb694a23d554094 /lib/RHRD/rddb.pm
parent1283d78ec24c3b4e084409610e4711015044ce58 (diff)
print clock usage for musicpool
Diffstat (limited to 'lib/RHRD/rddb.pm')
-rwxr-xr-xlib/RHRD/rddb.pm81
1 files changed, 55 insertions, 26 deletions
diff --git a/lib/RHRD/rddb.pm b/lib/RHRD/rddb.pm
index de34bbd..5141ff5 100755
--- a/lib/RHRD/rddb.pm
+++ b/lib/RHRD/rddb.pm
@@ -2119,6 +2119,32 @@ sub create_musicpool_group
return ($num, 'OK', 'success');
}
+sub get_musicpool_carts_used
+{
+ my ($ctx, $shortname) = @_;
+
+ my ($groupname, $status, $errorstring) = get_musicpool_group($ctx, $shortname);
+ unless (defined $groupname) {
+ return (undef, $status, $errorstring);
+ }
+
+ 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($groupname)
+ or return (undef, 'ERROR', "Database Error: " . $sth->errstr);
+
+ my @carts;
+ while(my ($cart) = $sth->fetchrow_array()) {
+ push @carts, $cart;
+ }
+ $sth->finish();
+
+ return @carts;
+}
+
sub create_musicpool_event
{
my ($ctx, $shortname, $groupname, $color) = @_;
@@ -2187,6 +2213,35 @@ sub create_musicpool_clock
return (1, 'OK', 'success');
}
+sub get_musicpool_clock_usage
+{
+ my ($ctx, $shortname) = @_;
+
+ my $sql = 'select HOUR from SVC_CLOCKS where CLOCK_NAME = ? order by HOUR;';
+
+ my $sth = $ctx->{'dbh'}->prepare($sql)
+ or return (undef, 'ERROR', "Database Error: " . $ctx->{'dbh'}->errstr);
+
+ my $cnt = $sth->execute($shortname)
+ or return (undef, 'ERROR', "Database Error: " . $sth->errstr);
+
+ my @slots;
+ while(my ($idx) = $sth->fetchrow_array()) {
+ my $dow = int($idx / 24) + 1;
+ $dow = 0 if $dow > 6;
+ my $hour = $idx % 24;
+
+ my $slot = {};
+ $slot->{'DOW'} = $dow;
+ $slot->{'HOUR'} = $hour;
+ push @slots, $slot;
+ }
+
+ $sth->finish();
+
+ return @slots;
+}
+
sub create_musicpool_dropbox
{
my ($ctx, $groupname, $shortname) = @_;
@@ -2284,32 +2339,6 @@ sub remove_musicpool
return @actions;
}
-sub get_musicpool_carts_used
-{
- my ($ctx, $shortname) = @_;
-
- my ($groupname, $status, $errorstring) = get_musicpool_group($ctx, $shortname);
- unless (defined $groupname) {
- return (undef, $status, $errorstring);
- }
-
- 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($groupname)
- or return (undef, 'ERROR', "Database Error: " . $sth->errstr);
-
- my @carts;
- while(my ($cart) = $sth->fetchrow_array()) {
- push @carts, $cart;
- }
- $sth->finish();
-
- return @carts;
-}
-
sub is_musicgrid_user
{
my ($ctx, $username) = @_;