From cb7815ba73f0882787682e3f481ae73373ad1470 Mon Sep 17 00:00:00 2001
From: TonyFord <tonyford@strategy-investor.de>
Date: Fri, 5 Aug 2022 19:08:44 +0200
Subject: [PATCH] bugfix

---
 html/_layouts/default.php     |  2 +-
 html/functions/db_methods.php | 26 ++++++--------------------
 2 files changed, 7 insertions(+), 21 deletions(-)

diff --git a/html/_layouts/default.php b/html/_layouts/default.php
index 0a563d3..c5b6524 100644
--- a/html/_layouts/default.php
+++ b/html/_layouts/default.php
@@ -225,7 +225,7 @@ if( !empty($csv) ){
 
               var td = document.createElement('td');
 
-              var st=parseInt(( new Date() - new Date(v.zeitstempel) ) / 1000 / 3600 / 24);
+              var st=parseInt(( new Date() - new Date(v.zeitstempl) ) / 1000 / 3600 / 24);
 
 
               $(td).text( st == 1 ? 'vor ' + st + ' Tag' : 'vor ' + st + ' Tagen' );
diff --git a/html/functions/db_methods.php b/html/functions/db_methods.php
index 19716fb..c28d841 100644
--- a/html/functions/db_methods.php
+++ b/html/functions/db_methods.php
@@ -286,31 +286,17 @@ function db_getLatestFromSpieler($days=34){
 
   $db=new db;
 
-  $sql = 'SELECT *, Statistik.zeitstempel AS zeitstempl FROM Spieler INNER JOIN Statistik ON Spieler.id = Statistik.SpielerID WHERE Statistik.zeitstempel > NOW()-'.$days.' GROUP BY SpielerID ORDER BY zeitstempl DESC';
-  $result = $db->query($sql);
-  echo $sql;
-  
-  $ROW=Array();
-  while( $row = $result->fetch_assoc() ){
-    $row['id']=bin2hex($row['id']);
-    $ROW[]=$row;
-  }
-
-  unset($db);
-  return $ROW;
-
-}
-function db_getLatest2FromSpieler($days=34){
-
-  $db=new db;
-
-  $sql = 'SELECT * FROM Spieler WHERE zeitstempel > NOW()-'.$days.' ORDER BY zeitstempel';
+  $sql = 'SELECT Spieler.*, Statistik.zeitstempel AS zeitstempl
+          FROM Spieler INNER JOIN Statistik ON Spieler.id = Statistik.SpielerID
+          WHERE Statistik.zeitstempel > NOW()-'.$days.'
+          GROUP BY Statistik.SpielerID
+          ORDER BY zeitstempl DESC';
   $result = $db->query($sql);
 
   $ROW=Array();
-
   while( $row = $result->fetch_assoc() ){
     $row['id']=bin2hex($row['id']);
+    $row['SpielerID']=bin2hex($row['SpielerID']);
     $ROW[]=$row;
   }
 
-- 
GitLab