prepare( "INSERT INTO poker_records(game,player,buyin,cashout) VALUES(:game,:player,:buyin,:cashout)" ); $stmt->execute( [ ":game" => $_POST['game'] , ":player" => $_SESSION['username'] , ":buyin" => $_POST['buyin'] , ":cashout" => $_POST['cashout'] ] ); $profit = $_POST['cashout'] - $_POST['buyin']; $index = ( $profit < 0 ? "floor" : "ceil" )( $profit / 20 ); if( $index > 3 ) $index = 3; if( $index < -3 ) $index = -3; // caps range at -3 to 3 for simplicity sake $comment = [ "Well, that REALLY sucked." , "Well, that sucked." , "Well, that kinda sucked." , "Huh, well, that was...something, I guess." , "Well, that was good." , "Well, that was really good!" , "DUDE! You were on FIRE!" ][$index + 3]; // instead of -3 to 3, range is now 0 - 6 $message = "Game inserted. {$comment}"; } //get all user years and set which year to view $years = array_keys( array_flip( array_map( function( $g ){ return substr( $g["game"] , 0 , 4 ); } , get_games() ) ) ); sort( $years ); $years[] = "all"; $year = ( isset( $_GET["year"] ) && in_array( $_GET["year"] , $years ) ) ? $_GET["year"] : date( "Y" ); // data for specific year if( is_numeric( $year ) ){ $data = get_games( $year ); $netp = 0; // data for charts $avg = count( $data ) ? ( ( array_sum( array_column( $data , "cashout" ) ) - array_sum( array_column( $data, "buyin" ) ) ) / count( $data ) ) : 0; foreach( $data as $i => $game ){ $data[$i]["profit"] = $profit = $game["cashout"] - $game["buyin"]; $net[] = "[" . to_js_time( $game["game"] ) . "," . ( $netp += $profit ) . "]"; $night[] = "[" . to_js_time( $game["game"] ) . "," . $profit . "]"; $expected[] = "[" . to_js_time( $game["game"] ) . "," . ( $avg * ++$i ) . "]"; $ppg[] = "[" . to_js_time( $game["game"] ) . "," . $avg . "]"; } // data for quick glance $wins = $losses = []; $buyins = $cashouts = 0; $rebuys = $rebuyins = $recashouts = 0; foreach( $data as $i => $game ){ if( $game["profit"] >= 0 ){ $wins[$i] = $data[$i]; } else{ $losses[$i] = $data[$i]; } $buyins += $game["buyin"]; $cashouts += $game["cashout"]; if( $game["buyin"] > 20 ){ $rebuys += ceil( $game["buyin"] / 20 ) - 1; $rebuyins += $game["buyin"] - 20; $recashouts += $game["cashout"]; } } $stats = [ [ "Games Played" => count( $data ) , "Total Wins" => $wins ? count( $wins ) : 0 , "Total Losses" => $losses ? count( $losses ) : 0 , "Total Buy-In" => money( $buyins ) , "Total Cash-Out" => money( $cashouts ) , "Net Profit" => money( $cashouts - $buyins ) , "Projected Profit" => money( ( date( "Y" ) > $year ) ? ( $cashouts - $buyins ) : ( count( $data ) ? ( ( $cashouts - $buyins ) / count( $data ) * ( count( $data ) + floor( ( strtotime( "12/31" ) - strtotime( "next tuesday" ) ) / 864000 ) ) ) : 0 ) , 0 ) , // 604800 / .7 = 864000 "Rebuys" => $rebuys ], [ "Profit Per Game" => money( count( $data ) ? ( ( $cashouts - $buyins ) / count( $data ) ) : 0 ) , "Profit Per Rebuy" => money( $rebuys ? ( ( $recashouts - $rebuyins ) / $rebuys ) : 0 ) , "Average Win" => money( $wins ? array_sum( array_column( $wins , "profit" ) ) / count( $wins ) : 0 ) , "Average Loss" => money( $losses ? array_sum( array_column( $losses , "profit" ) ) / count( $losses ) : 0 ) , "Largest Win" => money( $wins ? max( array_column( $wins , "profit" ) ) : 0 ) , "Largest Loss" => money( $losses ? min( array_column( $losses , "profit" ) ) : 0 ) , "Longest Win Streak" => longest_streak( $wins ) , "Longest Lose Streak" => longest_streak( $losses ) ] ]; } // data for all years else{ $data = get_games(); $gps = []; foreach( $data as $game ){ $time = strtotime( $game["game"] ); $net[date( "Y" , $time )][date( "n" , $time )] = $game["profit"]; @$gps[date( "Y" , $time )] += $game["games"]; } foreach( $net as $yr => $months ){ $jnet[$yr] = $jmon[$yr] = [ "name" => "$yr" , "data" => [] ]; for( $s = 0, $i = 1 ; $i < 13 ; $i++ ){ @$jnet[$yr]["data"][$i-1] = ( $s += $months[$i] ); @$jmon[$yr]["data"][$i-1] = $months[$i] ?: 0; } } foreach( $gps as $yr => $gp ){ $jppg[] = [ "name" => $yr , "data" => [ array_sum( $net[$yr] ) / $gp ] ]; } $wins = $losses = []; $buyins = $cashouts = $games = 0; foreach( $data as $i => $game ){ if( $game["profit"] >= 0 ){ $wins[$i] = $game; } else{ $losses[$i] = $game; } $games += $game["games"]; $buyins += $game["buyin"]; $cashouts += $game["cashout"]; } $stats = [ [ "Months Played" => count( $data ), "Winning Months" => count( $wins ) . " (" . percent( count( $wins ) / count( $data ) ) . "%)", "Losing Months" => count( $losses ) . " (" . percent( count( $losses ) / count( $data ) ) . "%)", "Total Buy-In" => money( $buyins ), "Total Cash-Out" => money( $cashouts ), "Net Profit" => money( $cashouts - $buyins ) ], [ "Average Profit/Game" => money( ( $cashouts - $buyins ) / $games ), "Average Profit/Month" => money( ( $cashouts - $buyins ) / count( $data ) ), "Average Winning Month" => money( count( $wins ) ? ( array_sum( array_column( $wins , "profit" ) ) / count( $wins ) ) : 0 ), "Average Losing Month" => money( count( $losses ) ? ( array_sum( array_column( $losses , "profit" ) ) / count( $losses ) ) : 0 ), "Best Month" => money( max( array_column( $wins , "profit" ) ) ), "Worst Month" => money( min( array_column( $losses , "profit" ) ) ) ] ]; } ?>

Warning: Undefined variable $message in /home/stevemammarella.helioho.st/httpdocs/poker/stats.php on line 155

Quick Glance

$value ){ ?>
Stat Data

Warning: Undefined variable $stat in /home/stevemammarella.helioho.st/httpdocs/poker/stats.php on line 195

Warning: Undefined variable $value in /home/stevemammarella.helioho.st/httpdocs/poker/stats.php on line 196

Charts

Raw Data Table

Date In Out Gain (Loss)

Warning: Undefined variable $year in /home/stevemammarella.helioho.st/httpdocs/poker/stats.php on line 235

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

Warning: Trying to access array offset on null in /home/stevemammarella.helioho.st/httpdocs/poker/stats.php on line 235
Jan '70

Fatal error: Uncaught Error: Call to undefined function money() in /home/stevemammarella.helioho.st/httpdocs/poker/stats.php:236 Stack trace: #0 {main} thrown in /home/stevemammarella.helioho.st/httpdocs/poker/stats.php on line 236