summaryrefslogtreecommitdiff
path: root/lib/RHRD/rddb.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/RHRD/rddb.pm')
-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) = @_;