diff options
author | Christian Pointner <equinox@helsinki.at> | 2016-11-25 23:10:47 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2016-11-25 23:10:47 (GMT) |
commit | 1c231c329cccf70fa809f57e75378f0963742388 (patch) | |
tree | 8d3ce21dc82c8137638d04f224e25c104f99ab6a | |
parent | 2309e83af61203a814ade7a5df89cd68f73d41ef (diff) |
also add show types to multi-shows
-rwxr-xr-x | lib/RHRD/rddb.pm | 20 | ||||
-rwxr-xr-x | utils/rhrd-show | 38 |
2 files changed, 40 insertions, 18 deletions
diff --git a/lib/RHRD/rddb.pm b/lib/RHRD/rddb.pm index e9f79ef..83a5f5b 100755 --- a/lib/RHRD/rddb.pm +++ b/lib/RHRD/rddb.pm @@ -2036,7 +2036,7 @@ sub list_multi_shows { my ($ctx) = @_; - my $sql = qq{select NUMBER,TITLE,USER_DEFINED from CART where GROUP_NAME = ? order by NUMBER}; + my $sql = qq{select NUMBER,TITLE,USER_DEFINED,NOTES from CART where GROUP_NAME = ? order by NUMBER}; my $sth = $ctx->{'dbh'}->prepare($sql) or return (undef, 'ERROR', "Database Error: " . $ctx->{'dbh'}->errstr); @@ -2045,12 +2045,13 @@ sub list_multi_shows or return (undef, 'ERROR', "Database Error: " . $sth->errstr); my @mshows; - while(my ($id, $title, $shows) = $sth->fetchrow_array()) { + while(my ($id, $title, $shows, $type) = $sth->fetchrow_array()) { my $entry = {}; $entry->{'ID'} = $id; $entry->{'TITLE'} = $title; $entry->{'SHOWS'} = {}; + $entry->{'TYPE'} = $type; my @showlist = split(';', $shows); foreach my $show (@showlist) { @@ -2097,6 +2098,7 @@ sub create_multi_show { my $ctx = shift; my $title = shift; + my $type = shift; my %shows = %{shift()}; my $showstr = join(";", map { "$_:$shows{$_}" } sort keys %shows); @@ -2106,12 +2108,12 @@ sub create_multi_show return (undef, $status, $errorstring); } - my $sql = qq{insert into CART (NUMBER, TYPE, GROUP_NAME, TITLE, USER_DEFINED, VALIDITY, METADATA_DATETIME) values (?, 2, ?, ?, ?, 3, NOW())}; + my $sql = qq{insert into CART (NUMBER, TYPE, GROUP_NAME, TITLE, USER_DEFINED, NOTES, VALIDITY, METADATA_DATETIME) values (?, 2, ?, ?, ?, ?, 3, NOW())}; my $sth = $ctx->{'dbh'}->prepare($sql) or return (undef, 'ERROR', "Database Error: " . $ctx->{'dbh'}->errstr); - $sth->execute($number, $ctx->{'config'}{'specialgroups'}{'multishows'}, $title, $showstr) + $sth->execute($number, $ctx->{'config'}{'specialgroups'}{'multishows'}, $title, $showstr, $type) or return (undef, 'ERROR', "Database Error: " . $sth->errstr); $sth->finish(); @@ -2124,16 +2126,17 @@ sub update_multi_show my $ctx = shift; my $showid = shift; my $title = shift; + my $type = shift; my %shows = %{shift()}; my $showstr = join(";", map { "$_:$shows{$_}" } sort keys %shows); - my $sql = qq{update CART set TITLE = ?, USER_DEFINED = ? where NUMBER = ?}; + my $sql = qq{update CART set TITLE = ?, USER_DEFINED = ?, NOTES = ? where NUMBER = ?}; my $sth = $ctx->{'dbh'}->prepare($sql) or return (undef, 'ERROR', "Database Error: " . $ctx->{'dbh'}->errstr); - my $cnt = $sth->execute($title, $showstr, $showid) + my $cnt = $sth->execute($title, $showstr, $type, $showid) or return (undef, 'ERROR', "Database Error: " . $sth->errstr); $sth->finish(); @@ -2149,7 +2152,7 @@ sub get_multi_show_info { my ($ctx, $showid) = @_; - my $sql = qq{select TITLE,USER_DEFINED from CART where NUMBER = ?}; + my $sql = qq{select TITLE,USER_DEFINED,NOTES from CART where NUMBER = ?}; my $sth = $ctx->{'dbh'}->prepare($sql) or return (undef, 'ERROR', "Database Error: " . $ctx->{'dbh'}->errstr); @@ -2161,13 +2164,14 @@ sub get_multi_show_info return (undef, 'ERROR', 'multi-show does not exist'); } - my ($title, $shows) = $sth->fetchrow_array(); + my ($title, $shows, $type) = $sth->fetchrow_array(); $sth->finish(); my $entry = {}; $entry->{'ID'} = $showid; $entry->{'TITLE'} = $title; $entry->{'SHOWS'} = {}; + $entry->{'TYPE'} = $type; my @showlist = split(';', $shows); foreach my $show (@showlist) { diff --git a/utils/rhrd-show b/utils/rhrd-show index 8bdc4cf..a9e0abc 100755 --- a/utils/rhrd-show +++ b/utils/rhrd-show @@ -37,8 +37,8 @@ sub print_usage " multi show handling:\n" . " rhrd-show multi-list\n" . " rhrd-show (multi-show|multi-remove) <multi-show-id>\n" . - " rhrd-show multi-add <title> <week>=<show-id> [ <week>=<show-id> [ .. ] ]\n" . - " rhrd-show multi-edit <multi-show-id> <title> <week>=<show-id> [ <week>=<show-id> [ .. ] ]\n"; + " rhrd-show multi-add <title> <type> <week>=<show-id> [ <week>=<show-id> [ .. ] ]\n" . + " rhrd-show multi-edit <multi-show-id> <title> <type> <week>=<show-id> [ <week>=<show-id> [ .. ] ]\n"; } sub list @@ -340,8 +340,9 @@ sub multi_list my @sorted = sort { lc($a->{'TITLE'}) cmp lc($b->{'TITLE'}) } @mshows; for my $href (@sorted) { my %showids = %{$href->{'SHOWS'}}; + my $showtype = RHRD::utils::dropbox_param_showtype_to_string($href->{'TYPE'}); my $showstr = join(", ", map { "W$_: $showids{$_}" } sort keys %showids); - print $href->{'ID'} . ": " . $href->{'TITLE'} . " (" . $showstr . ")\n"; + print $href->{'ID'} . ": " . $href->{'TITLE'} . ", " . $showtype. ", (" . $showstr . ")\n"; } return 0; } @@ -406,6 +407,13 @@ sub multi_add { my $ctx = shift; my $title = shift; + my $type = shift; + + my ($result, $err, $hint) = RHRD::utils::dropbox_param_showtype_ok($type); + unless($result) { + print STDERR $err . "\n " . $hint . "\n"; + return 1; + } print " * creating multi-show: " . $title . "\n"; @@ -415,7 +423,7 @@ sub multi_add } my %shows = %{$showref}; - my ($result, $status, $errorstring) = RHRD::rddb::create_multi_show($ctx, $title, \%shows); + ($result, my $status, my $errorstring) = RHRD::rddb::create_multi_show($ctx, $title, $type, \%shows); unless(defined $result) { print STDERR $status . ": " . $errorstring . "\n"; return 1; @@ -431,6 +439,13 @@ sub multi_edit my $ctx = shift; my $showid = shift; my $title = shift; + my $type = shift; + + my ($result, $err, $hint) = RHRD::utils::dropbox_param_showtype_ok($type); + unless($result) { + print STDERR $err . "\n " . $hint . "\n"; + return 1; + } print " * updating multi-show: " . $showid . "\n"; @@ -440,7 +455,7 @@ sub multi_edit } my %shows = %{$showref}; - my ($result, $status, $errorstring) = RHRD::rddb::update_multi_show($ctx, $showid, $title, \%shows); + ($result, my $status, my $errorstring) = RHRD::rddb::update_multi_show($ctx, $showid, $title, $type, \%shows); unless(defined $result) { print STDERR $status . ": " . $errorstring . "\n"; return 1; @@ -459,7 +474,8 @@ sub multi_show print STDERR "$errorstring\n"; return 1; } - print $show->{'TITLE'} . ":\n"; + my $showtype = RHRD::utils::dropbox_param_showtype_to_string($show->{'TYPE'}); + print $show->{'TITLE'} . ": " . $showtype . "\n"; my %showids = %{$show->{'SHOWS'}}; foreach my $week (sort keys %showids) { @@ -578,13 +594,14 @@ if(defined $ctx) { } } elsif($cmd eq "multi-add") { - if($num_args < 3) { + if($num_args < 4) { print_usage(); $ret = 1; } else { shift @ARGV; my $title = shift @ARGV; - $ret = multi_add($ctx, $title, @ARGV) + my $type = shift @ARGV; + $ret = multi_add($ctx, $type, @ARGV) } } elsif($cmd eq "multi-show") { @@ -604,14 +621,15 @@ if(defined $ctx) { } } elsif($cmd eq "multi-edit") { - if($num_args < 4) { + if($num_args < 5) { print_usage(); $ret = 1; } else { shift @ARGV; my $showid = shift @ARGV; my $title = shift @ARGV; - $ret = multi_edit($ctx, $showid, $title, @ARGV) + my $type = shift @ARGV; + $ret = multi_edit($ctx, $showid, $title, $type, @ARGV) } } else { |