Axel Nordh 4 lat temu
rodzic
commit
892da00e5a

+ 4 - 1
OddsJavaFx/src/web/index.php

@@ -110,17 +110,20 @@ $dayStats = $conn->getDayBettingsStats();
 </tr>
 </thead>
 <tbody>
-<?php 
+<?php
+$sum = 0;
 foreach ($dayStats as $ds) {
     echo "<tr>";
     echo "<td>" . $ds['date'] . "</td>";
     echo "<td>" . $ds['sumAmount'] . "</td>";
     echo "</tr>";
+    $sum += $ds['sumAmount'];
 }
 ?>
 </tbody>
 </table>
 
+<p>Total: <?php echo $sum; ?></p>
 </body>
 
 

+ 2 - 2
OddsJavaFx/src/web/webDbConnection.php

@@ -161,14 +161,14 @@ class WebDbConnection {
     }
     
     public function getDayBettingsStats() {
-        $sql = "SELECT DATE(gameDate) as date, SUM(
+        $sql = "SELECT DATE(gameDate) as date, ROUND(SUM(
     CASE
         WHEN betOn = '1' AND sr.homeScore > sr.awayScore THEN amount * odds
         WHEN betOn = 'X' AND sr.homeScore = sr.awayScore THEN amount * odds
         WHEN betOn = '2' AND sr.homeScore < sr.awayScore THEN amount * odds
 		ELSE -amount
 	END
-) as sumAmount
+),2 ) as sumAmount
 FROM `Bets` INNER JOIN SoccerResults sr ON matchId = sr.id GROUP BY DATE(sr.gameDate) ORDER BY sr.gameDate ASC";
 
         return $this->getSqlAsArray($sql);