Changeset 4


Ignore:
Timestamp:
Sep 10, 2018, 1:41:13 AM (6 years ago)
Author:
chronos
Message:
  • Added: Show list of changes for each runner.
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Global.php

    r2 r4  
    55  return(date('j.n.Y', $Time));
    66}
     7
     8function HumanDateTime($Time)
     9{
     10  return(date('j.n.Y H:i:s', $Time));
     11}
     12
    713function Link2($URL)
    814{
    915  global $Config;
    10  
     16
    1117  return $Config['BaseURL'].$URL;
    1218}
  • trunk/index.php

    r3 r4  
    143143      array('Name' => 'Distance', 'Title' => 'Distance'),
    144144      array('Name' => 'Money', 'Title' => 'Money'),
     145      array('Name' => 'Rank', 'Title' => 'Rank'),
     146      array('Name' => 'Time', 'Title' => 'Last change'),
    145147    );
    146148    $Order = GetOrderTableHeader($TableColumns, 'Distance', 1);
     
    149151    $DbResult = $this->Database->select('Runner', '*, '.
    150152      '(SELECT RunnerStat.Distance FROM RunnerStat WHERE RunnerStat.Runner=Runner.Id ORDER BY Time DESC LIMIT 1) AS Distance'.
    151       ', (SELECT RunnerStat.Money FROM RunnerStat WHERE RunnerStat.Runner=Runner.Id ORDER BY Time DESC LIMIT 1) AS Money',
     153      ', (SELECT RunnerStat.Money FROM RunnerStat WHERE RunnerStat.Runner=Runner.Id ORDER BY Time DESC LIMIT 1) AS Money'.
     154      ', (SELECT RunnerStat.Time FROM RunnerStat WHERE RunnerStat.Runner=Runner.Id ORDER BY Time DESC LIMIT 1) AS Time'.
     155      ', (SELECT RunnerStat.Rank FROM RunnerStat WHERE RunnerStat.Runner=Runner.Id ORDER BY Time DESC LIMIT 1) AS Rank',
    152156      $Where.$Order['SQL'].$PageList['SQLLimit']);
    153157    while($MeetItem = $DbResult->fetch_assoc())
    154158    {
    155159      $Output .= '<tr>'.
    156         '<td>'.$MeetItem['Name'].'</td>'.
     160        '<td><a href="'.$this->Link('/runner/'.$MeetItem['Id'].'/').'">'.$MeetItem['Name'].'</a></td>'.
    157161        '<td>'.$Gender[$MeetItem['Gender']].'</td>'.
    158162        '<td>'.$MeetItem['Distance'].'</td>'.
    159163        '<td>'.$MeetItem['Money'].'</td>'.
     164        '<td>'.$MeetItem['Rank'].'</td>'.
     165        '<td>'.HumanDateTime(MysqlDateTimeToTime($MeetItem['Time'])).'</td>'.
     166        '</tr>';
     167    }
     168    $Output .= '</table>';
     169    $Output .= $PageList['Output'];
     170    $Output .= '</div>';
     171
     172    return($Output);
     173  }
     174
     175  function ShowRunner()
     176  {
     177    $Output = '';
     178
     179    $RunnerId = 1;
     180    if ((count($this->PathItems) > 0) and ($this->PathItems[count($this->PathItems) - 1] != ''))
     181      $RunnerId = $this->PathItems[count($this->PathItems) - 1];
     182    if (!is_numeric($RunnerId)) die('Runner id needs to be numeric');
     183
     184    $DbResult = $this->Database->query('SELECT * FROM Runner WHERE Id='.$RunnerId);
     185    $DbRow = $DbResult->fetch_assoc();
     186    $Output .= '<h4 style="text-align: center;">Runner '.$DbRow['Name'].'</h4></br>';
     187
     188
     189    $Where = 'Runner='.$RunnerId;
     190
     191    $DbResult = $this->Database->query('SELECT COUNT(*) FROM `RunnerStat` WHERE '.$Where);
     192    $DbRow = $DbResult->fetch_row();
     193    $PageList = GetPageList($DbRow[0]);
     194
     195    $Output .= '<div id="list_content">';
     196    $Output .= $PageList['Output'];
     197    $TableColumns = array(
     198      array('Name' => 'Time', 'Title' => 'Time'),
     199      array('Name' => 'Distance', 'Title' => 'Distance'),
     200      array('Name' => 'Money', 'Title' => 'Money'),
     201      array('Name' => 'Rank', 'Title' => 'Rank'),
     202    );
     203    $Order = GetOrderTableHeader($TableColumns, 'Time', 1);
     204    $Output .= '<table class="WideTable">';
     205    $Output .= $Order['Output'];
     206    $DbResult = $this->Database->select('RunnerStat', '*',
     207      $Where.$Order['SQL'].$PageList['SQLLimit']);
     208    while($MeetItem = $DbResult->fetch_assoc())
     209    {
     210      $Output .= '<tr>'.
     211        '<td>'.HumanDateTime(MysqlDateTimeToTime($MeetItem['Time'])).'</td>'.
     212        '<td>'.$MeetItem['Distance'].'</td>'.
     213        '<td>'.$MeetItem['Money'].'</td>'.
     214        '<td>'.$MeetItem['Rank'].'</td>'.
    160215        '</tr>';
    161216    }
     
    204259    {
    205260      if($this->PathItems[0] == 'team-update') $Output .= $this->ShowTeamUpdate();
     261      if($this->PathItems[0] == 'runner') $Output .= $this->ShowRunner();
    206262      else $Output .= $this->ShowTeam();
    207263    } else $Output .= $this->ShowTeam();
Note: See TracChangeset for help on using the changeset viewer.