<?php

include "../Database.class";
include "../Functions.php";

//---------------------------------------------------------------------------------------------------------------- 
// INIT
//----------------------------------------------------------------------------------------------------------------  

  $Db = FN_DbOpen();
  
  $CR = "\n";
  $CR = "<br>";

//---------------------------------------------------------------------------------------------------------------- 
// 
//----------------------------------------------------------------------------------------------------------------  
/* 
  $Query  = "SELECT funzione, COUNT(*) as records FROM logs GROUP BY funzione";
  echo "Query=".$Query.$CR;
  $Result = $Db->Exec($Query);
  $TotRec = $Db->Numrows($Result);
  echo "TotRec=".$TotRec.$CR;
  //exit();
  
  //$TotRec = 2;  
  
  echo '<select name="ComboFunctions">'.chr(10);    
  
  for ($Rec=0;$Rec<$TotRec; $Rec++)
  {
    $Record = $Db->Fetch($Result, $Rec);
	  
	  echo '<option value="'.$Record["funzione"].'">'.$Record["funzione"].'</option>';
	  
  } 
  
  echo "</select>"; 
*/ 
//---------------------------------------------------------------------------------------------------------------- 
// 
//----------------------------------------------------------------------------------------------------------------  
 
  $Query  = "SELECT * FROM logs ORDER BY data DESC, ora DESC LIMIT 200";
  //echo "Query=".$Query.$CR;
  $Result = $Db->Exec($Query);
  $TotRec = $Db->Numrows($Result);
  //echo "TotRec=".$TotRec.$CR;
  //exit();
  
  //$TotRec = 2;  
  
  echo '<table border=1>'.chr(10);  
  
  echo '<tr>'.chr(10);
	echo '  <td><strong>DATA</strong></td>'.chr(10);
	echo '  <td><strong>ORA</strong></td>'.chr(10);
	echo '  <td><strong>FUNZIONE</strong></td>'.chr(10);
	echo '  <td><strong>PARAMETRI</strong></td>'.chr(10);
	echo '  <td><strong>RISPOSTA</strong></td>'.chr(10);
	echo '</tr>'.chr(10);  
  
  for ($Rec=0;$Rec<$TotRec; $Rec++)
  {
    $Record = $Db->Fetch($Result, $Rec);
	  
	  echo '<tr>'.chr(10);
	  echo '  <td>'.$Record["data"].'</td>'.chr(10);
	  echo '  <td>'.$Record["ora"].'</td>'.chr(10);
	  echo '  <td>'.$Record["funzione"].'</td>'.chr(10);
	  echo '  <td>'.$Record["parametri"].'</td>'.chr(10);
    echo '  <td>'.$Record["risposta"].'</td>'.chr(10);	  
	  echo '</tr>'.chr(10);
	  
  } 
  
  echo "</select>";       
 
?>