From d7177aa0309b044596f04af4e269dc29f82ad1e0 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Wed, 14 Sep 2016 22:11:20 +0200 Subject: implemented multi-show remove diff --git a/lib/RHRD/rddb.pm b/lib/RHRD/rddb.pm index 5e0afbc..da3a1e5 100755 --- a/lib/RHRD/rddb.pm +++ b/lib/RHRD/rddb.pm @@ -155,6 +155,12 @@ sub get_showid_range return get_cart_range($ctx, $ctx->{'config'}{'specialgroups'}{'shows'}) } +sub get_multi_showid_range +{ + my ($ctx) = @_; + return get_cart_range($ctx, $ctx->{'config'}{'specialgroups'}{'multishows'}) +} + sub get_next_free_slot { my ($ctx, $groupname) = @_; @@ -2058,6 +2064,23 @@ sub create_multi_show return ($number, 'OK', 'success'); } +sub remove_multi_show +{ + my ($ctx, $showid) = @_; + + my $sql = qq{delete from CART where NUMBER = ?;}; + + my $sth = $ctx->{'dbh'}->prepare($sql) + or return (undef, 'ERROR', "Database Error: " . $ctx->{'dbh'}->errstr); + + my $cnt = $sth->execute($showid) + or return (undef, 'ERROR', "Database Error: " . $sth->errstr); + + $sth->finish(); + + return ($cnt, 'OK', 'success'); +} + ########################### MUSICPOOL handling ########################### diff --git a/utils/rhrd-show b/utils/rhrd-show index d4646ba..ef8cb7a 100755 --- a/utils/rhrd-show +++ b/utils/rhrd-show @@ -411,6 +411,29 @@ sub multi_add return 0; } +sub multi_remove +{ + my ($ctx, $showid) = @_; + + my ($showid_min, $showid_max, $errorstring) = RHRD::rddb::get_multi_showid_range($ctx); + unless(defined $showid_min) { + print STDERR $showid_max . ": " . $errorstring . "\n"; + return 1; + } + if ($showid < $showid_min || $showid > $showid_max) { + print STDERR "multi-show-id '" . $showid . "' is out of range (min: $showid_min, max: $showid_max)\n"; + return 1; + } + + (my $result, my $status, $errorstring) = RHRD::rddb::remove_multi_show($ctx, $showid); + unless(defined $result) { + print STDERR $status . ": " . $errorstring . "\n"; + return 1; + } + print int($result) . " rows affected\n"; + + return 0; +} my $num_args = $#ARGV + 1; @@ -489,6 +512,14 @@ if(defined $ctx) { $ret = multi_add($ctx, $title, @ARGV) } } + elsif($cmd eq "multi-remove") { + if($num_args != 2) { + print_usage(); + $ret = 1; + } else { + $ret = multi_remove($ctx, $ARGV[1]); + } + } else { print_usage(); $ret = 1; -- cgit v0.10.2