house rules bdfore playing." : ""; $maybe_message = ( check_val( $_POST , "rsvp" , "Maybe" ) ) ? "

Remember! Your seat isn't secure until you've RSVP'd yes. As soon as you're sure you can make it, be sure to come back and indicate as such." : ""; $waitlist_message = $waitlist ? " (waitlist)" : ""; switch( $_POST["submit"] ){ case "update" : if( isset( $_POST["rsvp"] ) ){ $sql = "UPDATE poker_rsvp SET response=:response , waitlist=:waitlist WHERE player=:player AND game=:game"; $params = [ ":player" => $_SESSION["username"] , ":game" => $_POST["game"] , ":response" => $_POST["rsvp"] , ":waitlist" => $waitlist ]; $success = bs_alert( [ "class" => "success mb-4" , "message" => "Your RSVP for " . date( "M j" , strtotime( $_POST["date"] ) ) . " has been updated to: {$_POST["rsvp"]}{$waitlist_message}.{$rule_message}{$maybe_message}" ] ); } break; case "rsvp" : if( isset( $_POST["rsvp"] ) ){ $sql = "INSERT INTO poker_rsvp (player,game,response,waitlist) VALUES (:player,:game,:response,:waitlist)"; $params = [ ":player" => $_SESSION["username"] , ":game" => $_POST["game"] , ":response" => $_POST["rsvp"] , ":waitlist" => $waitlist ]; $success = bs_alert( [ "class" => "success mb-4" , "message" => "Your RSVP for " . date( "M j" , strtotime( $_POST["date"] ) ) . " has been submitted as: {$_POST["rsvp"]}{$waitlist_message}.{$rule_message}{$maybe_message}" ] ); } break; case "players" : foreach( explode( "," , $_POST["updates"] ) as $pair ){ if( $pair ){ list( $username , $response ) = explode( "->" , $pair ); $stmt = conn()->prepare( "SELECT * FROM poker_rsvp WHERE player=:player AND game=:game" ); $stmt->execute( [ ":game" => $_POST["id"] , ":player" => $username ] ); $stmt = conn()->prepare( $stmt->rowCount() > 0 ? "UPDATE poker_rsvp SET response=:response WHERE game=:game AND player=:player" : "INSERT INTO poker_rsvp (player,game,response) VALUES (:player,:game,:response)" ); $stmt->execute( [ ":game" => $_POST["id"] , ":player" => $username , ":response" => $response ] ); } } break; case "create" : list( $start , $stop ) = start_stop( $_POST["date"] , $_POST["start"] , $_POST["stop"] ); $sql = "INSERT INTO poker_games (start,stop,host,cancelled,tax) VALUES (:start,:stop,:host,0,0)"; $params = [ ":start" => $start , ":stop" => $stop , ":host" => $_POST["host"] ]; $success = bs_alert( [ "class" => "success mb-4" , "message" => "New game created!" ] ); break; case "edit" : list( $start , $stop ) = start_stop( $_POST["date"] , $_POST["start"] , $_POST["stop"] ); $sql = "UPDATE poker_games SET start=:start,stop=:stop,host=:host WHERE id=:id"; $params = [ ":start" => $start , ":stop" => $stop , ":host" => $_POST["host"] , ":id" => $_POST["id"] ]; $success = bs_alert( [ "class" => "success mb-4" , "message" => "Game updated!" ] ); break; case "cancel" : $sql = "UPDATE poker_games SET cancelled=1 WHERE id=:game"; $params = [ ":game" => $_POST["id"] ]; // email all players who rsvp'ed yes or maybe $stmt = conn()->prepare( "SELECT pr.player,pr.game,pr.response,pr.waitlist,pp.email,pp.name,pp.phone,pp.carrier FROM poker_rsvp pr LEFT JOIN poker_players pp ON pp.username = pr.player WHERE game = :game AND ( pr.response = 'Yes' OR pr.response = 'Maybe' ) ORDER BY pr.waitlist ASC" ); $stmt->execute( $params ); $players = $stmt->fetchAll( PDO::FETCH_ASSOC ); foreach( $players as $player ){ $to = $player["email"]; $subject = "Game Cancelled: " . date( "l, F j - g:i a" , strtotime( $_POST["date"] ) ); $html = generate_email( [ [ "text" , "Game Cancelled!" , "Sorry to say, " . first_name( $player["name"] ) . ", but the game on " . date( "M j" , strtotime( $_POST["date"] ) ) . " has been cancelled. Please do not show up. It'll just be awkward for everyone." ] ] ); $plain = "Game on " . date( "M j" , strtotime( $_POST["date"] ) ) . " has been cancelled."; if( $to ){ send_smtp( $to , $subject , $html , $plain ); } } $stmt = conn()->prepare( "DELETE FROM poker_rsvp WHERE game = :game" ); $stmt->execute( $params ); $success = bs_alert( [ "class" => "success mb-4" , "message" => "Game cancelled and " . count( $players ) . " participants notified." ] ); break; } if( isset( $sql ) && isset( $params ) ){ $stmt = conn()->prepare( $sql ); $stmt->execute( $params ); $message = $success; // if rsvp/update, send email to steve, unless it's steve if( check_val( $_POST , "submit" , [ "update" , "rsvp" ] ) && strlen( get_val( $_POST , "rsvp" ) ) && is_numeric( get_val( $_POST , "game" , null ) ) ){ if( $_SESSION["username"] != "steve" ){ $game = get_game_rsvps( $_POST["game"] ); $subject = "RSVP Recorded: {$_SESSION["username"]} ({$_POST["rsvp"]})"; $html = generate_email( [ [ "text" , "New RSVP!" , "{$_SESSION["name"]} responded: {$_POST["rsvp"]}. That makes the count: " . count( $game["Yes"] ) . " Yes, " . count( $game["Maybe"] ) . " Maybe, " . count( $game["No"] ) . " No." ] ] ); $plain = "RSVP Recorded: {$_SESSION["name"]} ({$_POST["rsvp"]})"; send_smtp( "steve.mammarella@gmail.com" , $subject , $html , $plain ); } } } // waitlist check - only done after rsvp if( isset( $_POST["game"] ) ){ $stmt = conn()->prepare( "SELECT pr.player,pr.game,pr.response,pr.waitlist,pp.phone,pp.carrier FROM poker_rsvp pr LEFT JOIN poker_players pp ON pp.username = pr.player WHERE game = :game AND response = 'Yes' ORDER BY waitlist ASC" ); $stmt->execute( [ ":game" => $_POST["game"] ] ); $players = $stmt->fetchAll( PDO::FETCH_ASSOC ); $active = array_filter( $players , function( $p ){ return is_null( $p["waitlist"] ); } ); $waitlisted = array_filter( $players , function( $p ){ return !is_null( $p["waitlist"] ); } ); while( count( $waitlisted ) && count( $active ) < max_players() ){ $active[] = $upgraded = array_shift( $waitlisted ); $stmt = conn()->prepare( "UPDATE poker_rsvp SET waitlist = NULL WHERE player=:player AND game=:game" ); $stmt->execute( [ "player" => $upgraded["player"] , ":game" => $upgraded["game"] ] ); $to = get_phone_email( $upgraded["phone"] , $upgraded["carrier"] ); $subject = "Poker Waitlist Update"; send_smtp( $to , "Poker " . date( "n/j" , strtotime( $_POST["date"] ) ) , "Someone bailed, so you're in. See you there!" , "Someone bailed, so you're in. See you there!" ); } } } } // if admin, all upcoming games, else only next $stmt = conn()->prepare( "SELECT pg.id,pg.cancelled,pg.start,pg.stop,pg.host,pp.address,pp.name,rsvp.response FROM poker_games pg LEFT JOIN poker_players pp ON pg.host = pp.username LEFT JOIN ( SELECT game,response FROM poker_rsvp WHERE player = :player ) rsvp ON rsvp.game = pg.id WHERE pg.stop > :dt ORDER BY start ASC" . ( $access >= 5 ? "" : " LIMIT 1" ) ); $stmt->execute( [ ":dt" => date( "Y-m-d H:i:s" ) , ":player" => get_val( $_SESSION , "username" , "" ) ] ); $games = $stmt->fetchAll( PDO::FETCH_ASSOC ); // add rsvps to each game foreach( $games as &$g ){ $g["rsvps"] = get_game_rsvps( $g["id"] , true ); } // if admin $hosts = []; if( $access >= 5 ){ // list of available hosts $stmt = conn()->prepare( "SELECT * FROM poker_players WHERE ( address IS NOT NULL AND address!='' ) ORDER BY CASE WHEN username = 'brian' THEN 1 ELSE 2 END ASC, username ASC" ); $stmt->execute(); $hosts = $stmt->fetchAll( PDO::FETCH_ASSOC ); } ?>

Warning: Undefined variable $message in /home/stevemammarella.helioho.st/httpdocs/poker/event.php on line 153
= 5 ){ ?>
Date Host RSVPs Your RSVP Edit Players

Warning: Undefined variable $game in /home/stevemammarella.helioho.st/httpdocs/poker/event.php on line 176

Warning: Trying to access array offset on null in /home/stevemammarella.helioho.st/httpdocs/poker/event.php on line 176
Jan 01: 12:00 am
- CANCELLED -
Fatal error: Uncaught Error: Call to undefined function first_name() in /home/stevemammarella.helioho.st/httpdocs/poker/event.php:180 Stack trace: #0 {main} thrown in /home/stevemammarella.helioho.st/httpdocs/poker/event.php on line 180