'. '
'. 'Odkud: '. 'Kam: '. 'Čas: '. ''. '
'; if (array_key_exists('from', $_GET) and array_key_exists('to', $_GET)) { $Output .= $this->ShowRides($_GET['from'], $_GET['to']); } else $Output .= $this->ShowRides('', ''); return $Output; } function ShowRides($PlaceFrom, $PlaceTo) { $Output = '

Jízdy:

'; $Output .= ''; $Query = 'SELECT Ride.Id, Ride.SeatCount, User.Name AS DriverName, User.BirthDate, '. 'CONCAT(CarManufacturer.Name, " ", CarModel.Name) AS CarName '; if ((trim($PlaceFrom) != '') and (trim($PlaceTo != ''))) $Query .= ', (SELECT COALESCE(MAX(RideStop.PassengerCount), 0) FROM RideStop '. 'WHERE (RideStop.Ride=Ride.Id) AND (RideStop.Sequence > RideStopFrom.Sequence) AND '. '(RideStop.Sequence <= RideStopTo.Sequence)) AS PassengerCount '; else $Query .= ', (SELECT COALESCE(MAX(RideStop.PassengerCount), 0) FROM RideStop '. 'WHERE (RideStop.Ride=Ride.Id)) AS PassengerCount '; $Query .= 'FROM Ride '. 'LEFT JOIN Car ON Car.Id = Ride.Car '. 'LEFT JOIN CarModel ON CarModel.Id = Car.Model '. 'LEFT JOIN CarManufacturer ON CarManufacturer.Id = CarModel.Manufacturer '. 'LEFT JOIN User ON User.Id=Ride.Driver '; if ((trim($PlaceFrom) != '') and (trim($PlaceTo != ''))) $Query .= 'JOIN RideStop AS RideStopFrom ON (RideStopFrom.Ride = Ride.Id) AND (RideStopFrom.Place LIKE "%'.$PlaceFrom.'%") '. 'JOIN RideStop AS RideStopTo ON (RideStopTo.Ride = Ride.Id) AND (RideStopTo.Place LIKE "%'.$PlaceTo.'%") '. 'WHERE (RideStopFrom.Sequence < RideStopTo.Sequence)'; $Query .= 'LIMIT 10'; $DbResult = $this->Database->query($Query); while ($DbRow = $DbResult->fetch_assoc()) { $Stops = array(); $Price = 0; $DbResult2 = $this->Database->query('SELECT * FROM RideStop WHERE Ride='.$DbRow['Id'].' ORDER BY Sequence'); while ($DbRow2 = $DbResult2->fetch_assoc()) { $Stops[] = $DbRow2['Place']; $Price += $DbRow2['Price']; } if ($DbRow['BirthDate'] != '') $Age = ' ('.round((time() - MysqlDateToTime($DbRow['BirthDate'])) / (3600*24*364.25)).' let)'; else $Age = ''; $Output .= ''. ''. ''. ''. ''. ''. ''; } $Output .= '
Řidič:'.$DbRow['DriverName'].$Age.'Ukázat
Trasa:'.implode(' → ', $Stops).'
Cena:'.$Price.' Kč
Volných míst:'.($DbRow['SeatCount'] - $DbRow['PassengerCount']).'
Auto:'.$DbRow['CarName'].'
 
'; return $Output; } }