| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- <?php
- include_once __DIR__ . '/webDbConnection.php';
- $conn = new WebDbConnection( );
- $countryId = $_POST['countrySelector'];
- $leagueId = $_POST['leagueSelector'];
- $conn->getBettingStats($leagueId);
- $matches = $conn->getMatches($countryId, $leagueId);
- $leagueInfo = $conn->getLeagueInfo($leagueId)[0];
- $betMarginHome = 1 + ($leagueInfo['betMarginHome'] / 100);
- $betMarginDraw = 1 + ($leagueInfo['betMarginDraw'] / 100);
- $betMarginAway = 1 + ($leagueInfo['betMarginAway'] / 100);
- ?>
- <head>
- <link rel="stylesheet" href="style.css">
- </head>
- <body>
- <iframe name="hiddenFrame" class="hide"></iframe>
- <table id="matchTable">
- <thead>
- <tr>
- <th hidden/>
- <th>Datum</th>
- <th>Hemma lag</th>
- <th>Borta lag</th>
- <th>Odds 1</th>
- <th>Odds X</th>
- <th>Odds 2</th>
- <th>1, X , 2</th>
- <th>Bet Odds</th>
- <th>Bet Amount</th>
- <th> </th>
- </tr>
- </thead>
- <tbody>
- <?php
- foreach ($matches as $match) {
- echo "<form id='makeBetFormId' action='makeBet.php' method='post' target='hiddenFrame'>";
- echo "<tr>";
- echo "<td hidden><input hidden id='gameId' name='gameIdName' value='" . $match['id'] . "'/>";
- echo "<td>".$match['gameDate'] . "</td>";
- echo "<td>".$match['homeTeamName'] . "</td>";
- echo "<td>".$match['awayTeamName'] . "</td>";
- echo "<td>". round((100 / $match['homeWinPercent']) * $betMarginHome, 2) . "</td>";
- echo "<td>". round((100 / $match['drawPercent']) * $betMarginDraw, 2) . "</td>";
- echo "<td>". round((100 / $match['awayWinPercent']) * $betMarginAway, 2) . "</td>";
- echo "<td><select name='betTypeName'>
- <option value='1'>1</option>
- <option value='X'>X</option>
- <option value='2'>2</option>
- </select></td>";
- echo "<td><input id='betOdds' name='betOddsName' type='number' step='.01'/></td>";
- echo "<td><input id='betAmount' name='betAmountName' type='number' step='.01'/></td>";
- echo "<td><input id='button' type='submit'/></td>";
- echo "</form>";
- echo "</tr>";
- }
- ?>
- </tbody>
- </table>
- <h2>Stats</h2>
- <?php
- $betStats = $conn->getBettingStats($leagueId)[0];
- $wins = 0;
- $losses = 0;
- $result = 0;
- $pendingResult = 0;
- foreach ($betStats as $betStat) {
- if ($betStat['homeScore'] < 0) {
- $pendingResult++;
- }
- if ($betStat['betOn'] === "1") {
- $result -= $betStat['betAmount'];
- if ($betStat['homeScore'] > $betStat['awayStat']) {
- $wins++;
- $result = $result * ($betStat['betAmount'] * $betStat['betOdds']);
- } else {
- $losses++;
- }
- }
- if ($betStat['betOn'] === "X") {
- $result -= $betStat['betAmount'];
- if ($betStat['homeScore'] == $betStat['awayStat']) {
- $wins++;
- $result = $result * ($betStat['betAmount'] * $betStat['betOdds']);
- } else {
- $losses++;
- }
- }
- if ($betStat['betOn'] === "2") {
- $result -= $betStat['betAmount'];
- if ($betStat['homeScore'] < $betStat['awayStat']) {
- $wins++;
- $result = $result * ($betStat['betAmount'] * $betStat['betOdds']);
- } else {
- $losses++;
- }
- }
- }
- echo "<p>Pending Result: $pendingResult</p>";
- echo "<p>Wins: $wins</p>";
- echo "<p>Losses: $losses</p>";
- echo "<p>Result: $result</p>";
- ?>
- </body>
|