summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2016-07-31 12:12:14 (GMT)
committerChristian Pointner <equinox@helsinki.at>2016-07-31 12:12:14 (GMT)
commit1283d78ec24c3b4e084409610e4711015044ce58 (patch)
tree00efc5edf30655d407961f06d22e1bb4606b7333
parent96b197680f423d4afda7c113a1049a656cc81abf (diff)
print used carts for musicpools
-rwxr-xr-xlib/RHRD/rddb.pm26
-rwxr-xr-xutils/rhrd-pool8
2 files changed, 33 insertions, 1 deletions
diff --git a/lib/RHRD/rddb.pm b/lib/RHRD/rddb.pm
index b576ad4..de34bbd 100755
--- a/lib/RHRD/rddb.pm
+++ b/lib/RHRD/rddb.pm
@@ -2284,6 +2284,32 @@ 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) = @_;
diff --git a/utils/rhrd-pool b/utils/rhrd-pool
index 1534af6..dc85f94 100755
--- a/utils/rhrd-pool
+++ b/utils/rhrd-pool
@@ -58,8 +58,14 @@ sub show
print STDERR "$errorstring\n";
return 1;
}
+ my @carts = RHRD::rddb::get_musicpool_carts_used($ctx, $shortname);
+ if(!defined $carts[0] && defined $carts[1]) {
+ print STDERR "$carts[1]: $carts[2]";
+ return 1;
+ }
+
print $pool->{'TITLE'} . " (" . $pool->{'SHORTNAME'} . "):\n";
- print " group: " . $pool->{'GROUP'} . ", carts: " . $pool->{'LOW_CART'} . "-" . $pool->{'HIGH_CART'} . "\n"; # TODO print info about cart usage
+ print " group: " . $pool->{'GROUP'} . ", carts: " . $pool->{'LOW_CART'} . "-" . $pool->{'HIGH_CART'} . " (" . scalar(@carts) . " used)\n";
return 0;
}