Database->query('SELECT Ride.Details, Ride.Id, Ride.SeatCount, '. 'RideStopFrom.Id AS RideStopFromId, RideStopTo.Id AS RideStopToId, '. '(SELECT Name FROM User WHERE User.Id=Ride.Driver) AS DriverName, '. 'CONCAT(CarManufacturer.Name, " ", CarModel.Name) AS CarName FROM Ride '. 'JOIN RideStop AS RideStopFrom ON (RideStopFrom.Ride = Ride.Id) AND (RideStopFrom.Place LIKE "%'.$_GET['from'].'%") '. 'JOIN RideStop AS RideStopTo ON (RideStopTo.Ride = Ride.Id) AND (RideStopTo.Place LIKE "%'.$_GET['to'].'%") '. 'LEFT JOIN Car ON Car.Id = Ride.Car '. 'LEFT JOIN CarModel ON CarModel.Id = Car.Model '. 'LEFT JOIN CarManufacturer ON CarManufacturer.Id = CarModel.Manufacturer '. 'WHERE Ride.Id='.$RideId); $DbRow = $DbResult->fetch_assoc(); $Track = array(); $Stops = array(); $DbResult2 = $this->Database->query('SELECT * FROM RideStop WHERE Ride='.$DbRow['Id'].' ORDER BY Sequence'); while ($DbRow2 = $DbResult2->fetch_assoc()) { $Track[] = $DbRow2; $Stops[] = $DbRow2['Place']; } $Output = '

Detail jízdy

'. ''. ''. ''. ''. ''; $Output .= '
Trasa:'.implode(' → ', $Stops).'
Odjezd z:'.$Track[0]['Place'].'
Příjezd do:'.$Track[count($Track) - 1]['Place'].'
Čas odjezdu:'.$Track[0]['Time'].'
Podrobnosti:'.$DbRow['Details'].'
'; $Output .= '
'. 'Počet míst: '. ''. ''. ''. ''. '
'; $Output .= '

Cestující

'. ''; // Load passengers table $Table = array_fill(0, count($Track), array_fill(0, $DbRow['SeatCount'], NULL)); $Passengers = array(); $DbResult = $this->System->Database->query('SELECT User.Name AS UserName, PassengerRideStopFrom.Sequence AS SequenceFrom, '. 'PassengerRideStopTo.Sequence AS SequenceTo FROM Passenger '. 'LEFT JOIN RideStop AS PassengerRideStopFrom ON PassengerRideStopFrom.Id=Passenger.RideStopFrom '. 'LEFT JOIN RideStop AS PassengerRideStopTo ON PassengerRideStopTo.Id=Passenger.RideStopTo '. 'LEFT JOIN User ON User.Id=Passenger.User '. 'WHERE Passenger.Ride='.$RideId); while ($Passenger = $DbResult->fetch_assoc()) { $Passengers[] = $Passenger; $Seat = 0; do { $Check = true; for ($I = $Passenger['SequenceFrom']; $I < $Passenger['SequenceTo']; $I++) { if ($Table[$I][$Seat] != 0) $Check = false; } if (!$Check) $Seat++; } while (!$Check); for ($I = $Passenger['SequenceFrom']; $I < $Passenger['SequenceTo']; $I++) $Table[$I][$Seat] = count($Passengers) - 1; } $Output .= ''; for ($I = 0; $I < $DbRow['SeatCount']; $I++) $Output .= ''; $Output .= ''; foreach ($Track as $Index => $TrackItem) { $Output .= ''; if ($Index == 0) $Output .= ''; for ($I = 0; $I < $DbRow['SeatCount']; $I++) { if (!is_null($Table[$Index][$I])) { $Passenger = $Passengers[$Table[$Index][$I]]; if ($Index == $Passenger['SequenceFrom']) $Output .= ''; } else { // Show unused space if (($Index == 0) or ((($Index - 1) >= 0) and (!is_null($Table[$Index - 1][$I])))) { $J = 1; while ((($Index + $J) < count($Table)) and is_null($Table[$Index + $J][$I])) $J++; $Output .= ''; } } } $Output .= ''; } $Output .= '
Zastávka / ČasŘidičCestující
'.$TrackItem['Place'].'
'.$TrackItem['Time'].'
Řidič'.$Passenger['UserName'].' 
'; return $Output; } function Show(): string { if (!array_key_exists('step', $_GET)) $Output = $this->ShowDetail(); else { if ($_GET['step'] == 2) { $this->System->Database->insert('Passenger', array( 'Ride' => $_POST['id'], 'User' => Core::Cast($this->System)->User->User['Id'], 'SeatCount' => $_POST['seats'], 'RideStopFrom' => $_POST['fromid'], 'RideStopTo' => $_POST['toid'], )); $this->System->ModuleManager->Modules['Ride']->UpdatePassengerCount($_POST['id']); $Output = 'Rezervace dokončena'; } } return $Output; } }