index.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <?php
  2. include_once __DIR__ . '/webDbConnection.php';
  3. $conn = new WebDbConnection( );
  4. $countries = $conn->getCountries();
  5. $leagues = $conn->getLeagues();
  6. ?>
  7. <head>
  8. <link rel="stylesheet" href="style.css">
  9. </head>
  10. <body>
  11. <H2>Odds</H2>
  12. <form id="selectionForm" action="matchTable.php" method="post">
  13. <label for="countrySelector">Select country: </label>
  14. <select name="countrySelector" id="countrySelector">
  15. <?php
  16. foreach ($countries as $country) {
  17. echo "<option value='" . $country['id'] . "'>" . $country['name'] . "</option>";
  18. }
  19. ?>
  20. </select>
  21. <label for="leagueSelector">Select league: </label>
  22. <select name="leagueSelector" id="league">
  23. <?php
  24. foreach ($leagues as $league) {
  25. echo "<option value='" . $league['id'] . "'>" . $league['name'] . " - " . $league['countryId'] ."</option>";
  26. }
  27. ?>
  28. </select>
  29. <input type='submit' id='getMatches' value='Se Matcher'/>
  30. </form>
  31. </br>
  32. </br>
  33. <h2>Betting Stats</h2>
  34. <?php
  35. $betSummary = $conn->getBettingSummary();
  36. $result = array();
  37. foreach ($betSummary as $bs) {
  38. if ($bs['homeScore'] < 0) {
  39. $result[$bs['leagueName']]['pending'] = $result[$bs['leagueName']]['pending'] + 1;
  40. continue;
  41. }
  42. $result[$bs['leagueName']]['result'] = $result[$bs['leagueName']]['result'] - $bs['amount'];
  43. if ($bs['betOn'] === '1' && $bs['homeScore'] > $bs['awayScore']) {
  44. $result[$bs['leagueName']]['wins'] = $result[$bs['leagueName']]['wins'] + 1;
  45. $result[$bs['leagueName']]['result'] = $result[$bs['leagueName']]['result'] + ($bs['amount'] * $bs['odds']);
  46. } else if ($bs['betOn'] === 'X' && $bs['homeScore'] == $bs['awayScore']) {
  47. $result[$bs['leagueName']]['wins'] = $result[$bs['leagueName']]['wins'] + 1;
  48. $result[$bs['leagueName']]['result'] = $result[$bs['leagueName']]['result'] + ($bs['amount'] * $bs['odds']);
  49. } else if ($bs['betOn'] === '2' && $bs['homeScore'] < $bs['awayScore']) {
  50. $result[$bs['leagueName']]['wins'] = $result[$bs['leagueName']]['wins'] + 1;
  51. $result[$bs['leagueName']]['result'] = $result[$bs['leagueName']]['result'] + ($bs['amount'] * $bs['odds']);
  52. } else {
  53. $result[$bs['leagueName']]['losses'] = $result[$bs['leagueName']]['losses'] + 1;
  54. }
  55. }
  56. ?>
  57. <table>
  58. <thead>
  59. <tr>
  60. <th>League</th>
  61. <th>Wins</th>
  62. <th>Losses</th>
  63. <th>Percentage</th>
  64. <th>Result</th>
  65. <th>Pending</th>
  66. </tr>
  67. </thead>
  68. <tbody>
  69. <?php
  70. foreach ($result as $name => $res) {
  71. echo "<tr>";
  72. echo "<td>" . $name . "</td>";
  73. echo "<td>" . $res['wins'] . "</td>";
  74. echo "<td>" . $res['losses'] . "</td>";
  75. echo "<td>" . round($res['wins'] / ($res['wins'] + $res['losses']),2) . "</td>";
  76. echo "<td>" . $res['result'] . "</td>";
  77. echo "<td>" . $res['pending'] . "</td>";
  78. }
  79. ?>
  80. </tbody>
  81. </table>
  82. <h2>Day results</h2>
  83. <?php
  84. $dayStats = $conn->getDayBettingsStats();
  85. ?>
  86. <table>
  87. <thead>
  88. <tr>
  89. <th>Datum</th>
  90. <th>Resultat</th>
  91. <th>Games Played</th>
  92. <th>Bet amount</th>
  93. </tr>
  94. </thead>
  95. <tbody>
  96. <?php
  97. $sum = 0;
  98. foreach ($dayStats as $ds) {
  99. echo "<tr>";
  100. echo "<td>" . $ds['date'] . "</td>";
  101. echo "<td>" . $ds['sumAmount'] . "</td>";
  102. echo "<td>" . $ds['numGames'] . "</td>";
  103. echo "<td>" . $ds['betAmount'] . "</td>";
  104. echo "</tr>";
  105. $sum += $ds['sumAmount'];
  106. }
  107. ?>
  108. </tbody>
  109. </table>
  110. <p>Total: <?php echo $sum; ?></p>
  111. </body>
  112. <script type="text/javascript">
  113. </script>