summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2016-08-03 17:01:47 (GMT)
committerChristian Pointner <equinox@helsinki.at>2016-08-03 17:01:47 (GMT)
commit9ca564354715514ad7199294749fb80085d9fec9 (patch)
tree98c861a77ea8354e7d7f5d855b587ed8ed67e84b /lib
parent04b0ce29cb5d25565ce68ae3cd195c5f0f7565b0 (diff)
added clear command to rhrd-pool
Diffstat (limited to 'lib')
-rwxr-xr-xlib/RHRD/rddb.pm35
1 files changed, 35 insertions, 0 deletions
diff --git a/lib/RHRD/rddb.pm b/lib/RHRD/rddb.pm
index 5e6289e..7c5bae3 100755
--- a/lib/RHRD/rddb.pm
+++ b/lib/RHRD/rddb.pm
@@ -2296,6 +2296,41 @@ sub update_musicpool_title
return ($cnt, 'OK', 'success');
}
+sub clear_musicpool
+{
+ my ($ctx, $shortname) = @_;
+
+ my ($groupname, $status, $errorstring) = get_musicpool_group($ctx, $shortname);
+ unless (defined $groupname) {
+ return (undef, $status, $errorstring);
+ }
+
+ my @actions = ({
+ # Delete Member Cuts
+ sql => qq{delete from CUTS where CART_NUMBER IN (select NUMBER from CART where GROUP_NAME = ?);},
+ name => 'member cuts',
+ cnt => 0
+ }, {
+ # Delete Member Carts
+ sql => qq{delete from CART where GROUP_NAME = ?;},
+ name => 'member carts',
+ cnt => 0
+ });
+
+ for my $href (@actions) {
+ my $sth = $ctx->{'dbh'}->prepare($href->{sql})
+ or return (undef, 'ERROR', "Database Error: " . $ctx->{'dbh'}->errstr);
+ delete($href->{sql});
+
+ $href->{cnt} = $sth->execute($groupname)
+ or return (undef, 'ERROR', "Database Error: " . $sth->errstr);
+
+ $sth->finish();
+ }
+
+ return @actions;
+}
+
sub remove_musicpool
{
my ($ctx, $shortname) = @_;