diff options
author | Christian Pointner <equinox@helsinki.at> | 2016-08-03 17:01:47 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2016-08-03 17:01:47 (GMT) |
commit | 9ca564354715514ad7199294749fb80085d9fec9 (patch) | |
tree | 98c861a77ea8354e7d7f5d855b587ed8ed67e84b /lib/RHRD | |
parent | 04b0ce29cb5d25565ce68ae3cd195c5f0f7565b0 (diff) |
added clear command to rhrd-pool
Diffstat (limited to 'lib/RHRD')
-rwxr-xr-x | lib/RHRD/rddb.pm | 35 |
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) = @_; |