X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=cgi%2Fsets.cgi;h=5dd8a8de27272c85b56d6f4e2443477b3636c220;hb=HEAD;hp=e5c64b1985d6525badee799a5c1f79eeaf4c9d0d;hpb=153e6f03d3b7e0056983d719aadb5edf0d5feb41;p=technostate.git diff --git a/cgi/sets.cgi b/cgi/sets.cgi index e5c64b1..5dd8a8d 100755 --- a/cgi/sets.cgi +++ b/cgi/sets.cgi @@ -1,5 +1,5 @@ #!/usr/bin/perl -Tw -# $Id: sets.cgi,v 1.5 1999-04-22 06:21:06 ivan Exp $ +# $Id: sets.cgi,v 1.7 1999-07-18 05:08:29 ivan Exp $ # Copyright (c) 1999 Ivan Kohler. All rights reserved. # This program is free software; you can redistribute it and/or modify it under # the same terms as perl itself @@ -43,9 +43,8 @@ unless ( $cgi->param('magic') ) { #first time through print $cgi->start_table, $cgi->tr( - map { - $cgi->th($_) - } @columns + ( map { $cgi->th($_) } @columns ), + $cgi->th('People') ) ; @@ -53,7 +52,9 @@ unless ( $cgi->param('magic') ) { #first time through my $hashref = undef; while ( $hashref = $sth->fetchrow_hashref ) { %hash = %{$hashref}; - print $cgi->tr( map { $cgi->td( $hash{$_} ) } @columns ); + print $cgi->tr( + ( map { $cgi->td( $hash{$_} ) } @columns ) ), + ; } print $cgi->end_table; } @@ -99,6 +100,23 @@ unless ( $cgi->param('magic') ) { #first time through my $rv = $sth->execute; die $sth->errstr unless $rv; + my $set_id = $sth->{'insertid'}; + warn $set_id; + + $dbh->do( "DELETE FROM PERSONS_SETS WHERE ( SET_ID = $set_id )" ) + or die $dbh->errstr; + + my $person_id; + foreach $person_id ( $cgi->param('PERSON_ID') ) { + $dbh->do( + "INSERT INTO PERSONS_SETS ( PERSON_ID, SET_ID ) ". + "VALUES ( $person_id, $set_id )" + ) or die $dbh->errstr; + } + + #my $rv = $sth->execute; + #die $sth->errstr unless $rv; + my $url = $cgi->url; $url =~ s/^\/[\/]+$//; print $cgi->redirect($url); @@ -108,6 +126,9 @@ unless ( $cgi->param('magic') ) { #first time through sub print_form { my $cgi = shift; my $action = shift; + + my %persons = map { @{$_}; } + @{$dbh->selectall_arrayref( "SELECT PERSON_ID, NAME FROM PERSONS" )}; print $cgi->header, $cgi->start_html($action), $cgi->h1($action), @@ -119,6 +140,12 @@ sub print_form { "Short Description: ", $cgi->textarea( -name => 'DESCRIPTION', -cols => '45', -rows => '2' ), "
", "Long Description: ", $cgi->textarea( -name => 'INFO', -cols => '45', -rows => '5' ), "
", "Keywords: ", $cgi->textfield( -name => 'KEYWORDS' ), "
", + "People: ", $cgi->scrolling_list( + -name => "PERSON_ID", + '-values' => [ sort { $persons{$a} cmp $persons{$b} } keys(%persons) ], + '-labels' => \%persons, + '-multiple' => 'true', + ), "Show?: ", $cgi->textfield( -name => 'SHOW_ID' ), "
", $cgi->hidden( -name => 'magic'), $cgi->submit('Submit'),