Changeset 5 for trunk


Ignore:
Timestamp:
Sep 9, 2016, 10:17:39 PM (8 years ago)
Author:
chronos
Message:
  • Added: Show driver age.
Location:
trunk/Modules
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/Ride/Ride.php

    r4 r5  
    1919    $this->System->RegisterPage('nova-jizda', 'PageNewRide');
    2020    $this->System->RegisterPage('jizda', 'PageRideDetail');
     21    $this->System->RegisterPage('jizdy', 'PageRideList');
    2122    $this->System->RegisterPageBarItem('TopLeft', 'Logo', array($this, 'ShowLogo'));
    2223  }
     
    129130  {
    130131    $Output = '<img src="" width="200" height="50" alt="Logo"/> '.
    131       '<a href="'.$this->System->Link('/hledat/').'">Hledat jízdu</a> nebo '.
     132      '<a href="'.$this->System->Link('/jizdy/').'">Hledat jízdu</a> nebo '.
    132133      '<a href="'.$this->System->Link('/nova-jizda/').'">Nabídnout jízdu</a>';
    133134    return($Output);
     
    228229    }
    229230
    230     $Output .= '<tr><th>Zastávka / Čas</th><th>Řidič</th>';
     231    $Output .= '<tr><th>Zastávka / Čas</th><th style="width: 80px">Řidič</th>';
    231232    for ($I = 0; $I < $DbRow['SeatCount']; $I++)
    232       $Output .= '<th>Cestující</th>';
     233      $Output .= '<th style="width: 80px">Cestující</th>';
    233234    $Output .= '</tr>';
    234235    foreach($Track as $Index => $TrackItem)
     
    288289    if(array_key_exists('to', $_GET)) $PlaceTo = $_GET['to'];
    289290      else $PlaceTo = '';
    290      $Output = '<table style="width: 100%"><tr><td>'.
    291      '<form style="display: inline;" method="get" action="'.$this->System->Link('/').'">'.
     291    if(array_key_exists('time', $_GET)) $Time = $_GET['time'];
     292      else $Time = '';
     293    $Output = '<table style="width: 100%; margin-top: 100px; margin-bottom: 100px;"><tr><td style="text-align: center">'.
     294      '<div><h3>Vyhledat jízdu</h3>'.
     295      '<form style="display: inline;" method="get" action="'.$this->System->Link('/jizdy/').'">'.
    292296      'Odkud: <input type="text" name="from" value="'.$PlaceFrom.'"/> '.
    293297      'Kam: <input type="text" name="to" value="'.$PlaceTo.'"/> '.
     298      'Čas: <input type="text" name="time" value="'.$Time.'"/> '.
    294299      '<input type="submit" value="Hledat"/>'.
    295       '</form></td><td><a href="'.$this->System->Link('/nova-jizda/').'">Nová jízda</a></td></tr></table>';
     300      '</form></div></td></tr></table>';
     301    return($Output);
     302  }
     303}
     304
     305class PageRideList extends Page
     306{
     307  function Show()
     308  {
     309    if(array_key_exists('from', $_GET)) $PlaceFrom = $_GET['from'];
     310      else $PlaceFrom = '';
     311    if(array_key_exists('to', $_GET)) $PlaceTo = $_GET['to'];
     312      else $PlaceTo = '';
     313    if(array_key_exists('time', $_GET)) $Time = $_GET['time'];
     314      else $Time = '';
     315    $Output = '<table style="width: 100%"><tr><td style="text-align: center;">'.
     316      '<form style="display: inline;" method="get" action="'.$this->System->Link('/').'">'.
     317      'Odkud: <input type="text" name="from" value="'.$PlaceFrom.'"/> '.
     318      'Kam: <input type="text" name="to" value="'.$PlaceTo.'"/> '.
     319      'Čas: <input type="text" name="time" value="'.$Time.'"/> '.
     320      '<input type="submit" value="Hledat"/>'.
     321      '</form></td></tr></table>';
    296322    if (array_key_exists('from', $_GET) and array_key_exists('to', $_GET)) {
    297323      $Output .= $this->ShowRides($_GET['from'], $_GET['to']);
     
    304330    $Output = '<h3>Jízdy:</h3>';
    305331    $Output .= '<table>';
    306     $Query = 'SELECT Ride.Id, Ride.SeatCount, (SELECT Name FROM User WHERE User.Id=Ride.Driver) AS DriverName, '.
     332    $Query = 'SELECT Ride.Id, Ride.SeatCount, User.Name AS DriverName, User.BirthDate, '.
    307333      'CONCAT(CarManufacturer.Name, " ", CarModel.Name) AS CarName ';
    308334    if((trim($PlaceFrom) != '') and (trim($PlaceTo != '')))
     
    317343      'LEFT JOIN Car ON Car.Id = Ride.Car '.
    318344      'LEFT JOIN CarModel ON CarModel.Id = Car.Model '.
    319       'LEFT JOIN CarManufacturer ON CarManufacturer.Id = CarModel.Manufacturer ';
     345      'LEFT JOIN CarManufacturer ON CarManufacturer.Id = CarModel.Manufacturer '.
     346      'LEFT JOIN User ON User.Id=Ride.Driver ';
    320347    if((trim($PlaceFrom) != '') and (trim($PlaceTo != '')))
    321348      $Query .= 'JOIN RideStop AS RideStopFrom ON (RideStopFrom.Ride = Ride.Id) AND (RideStopFrom.Place LIKE "%'.$PlaceFrom.'%") '.
     
    335362      }
    336363
    337       $Output .= '<tr><td>Řidič:</td><td>'.$DbRow['DriverName'].'</td>'.
     364      if ($DbRow['BirthDate'] != '') $Age = ' ('.round((time() - MysqlDateToTime($DbRow['BirthDate'])) / (3600*24*364.25)).' let)';
     365        else $Age = '';
     366      $Output .= '<tr><td>Řidič:</td><td>'.$DbRow['DriverName'].$Age.'</td>'.
    338367        '<td colspan="4"><a href="'.$this->System->Link('/jizda/?id='.$DbRow['Id'].'&from='.$PlaceFrom.'&to='.$PlaceTo).'">Ukázat</a></td></tr>'.
    339368        '<tr><td>Trasa:</td><td>'.implode(' → ', $Stops).'</td></tr>'.
  • trunk/Modules/User/User.php

    r1 r5  
    3030      '`Salt` varchar(255) NOT NULL,'.
    3131      '`Email` varchar(128) NOT NULL DEFAULT "",'.
     32      '`BirthDate` date NULL,'.
    3233      '`LastIpAddress` varchar(16) NOT NULL DEFAULT "",'.
    3334      '`LastLoginTime` datetime NULL,'.
  • trunk/Modules/User/UserModel.php

    r1 r5  
    174174
    175175            $Result = USER_REGISTRATED;
    176             $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'NewRegistration', $Login);
     176            if(array_key_exists('Log', $this->System->ModuleManager->Modules))
     177              $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'NewRegistration', $Login);
    177178          }
    178179        }
Note: See TracChangeset for help on using the changeset viewer.