Changeset 7 for trunk/Modules/Ride/Ride.php
- Timestamp:
- Apr 14, 2020, 11:13:32 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Ride/Ride.php
r6 r7 140 140 'Vsetín', 'Nový Jičín', 'Prostějov', 'Vyškov', 'Mohelnice', 'Ústí nad Orlicí'); 141 141 142 for ($I = 0; $I < 100; $I++)142 for ($I = 0; $I < 100; $I++) 143 143 { 144 144 $Stops = array_fill(0, random(5), ''); 145 for ($J = 0; $J < count($Stops); $J++)145 for ($J = 0; $J < count($Stops); $J++) 146 146 $Stops[$J] = $Cities[random(count($Cities))]; 147 147 … … 158 158 '<a href="'.$this->System->Link('/jizdy/').'">Hledat jízdu</a> nebo '. 159 159 '<a href="'.$this->System->Link('/nova-jizda/').'">Nabídnout jízdu</a>'; 160 return ($Output);160 return $Output; 161 161 } 162 162 … … 173 173 'LEFT JOIN RideStop AS PassengerRideStopTo ON PassengerRideStopTo.Id=Passenger.RideStopTo '. 174 174 'WHERE Passenger.Ride='.$RideId); 175 while ($DbRow = $DbResult->fetch_assoc())176 { 177 for ($I = $DbRow['SequenceFrom'] + 1; $I <= $DbRow['SequenceTo']; $I++)175 while ($DbRow = $DbResult->fetch_assoc()) 176 { 177 for ($I = $DbRow['SequenceFrom'] + 1; $I <= $DbRow['SequenceTo']; $I++) 178 178 { 179 179 $Stops[$I] = $Stops[$I] + $DbRow['SeatCount']; 180 180 } 181 181 } 182 foreach ($Stops as $Index => $Stop)182 foreach ($Stops as $Index => $Stop) 183 183 { 184 184 $this->System->Database->update('RideStop', 'Ride='.$RideId.' AND Sequence='.$Index, array('PassengerCount' => $Stop)); … … 206 206 $Stops = array(); 207 207 $DbResult2 = $this->Database->query('SELECT * FROM RideStop WHERE Ride='.$DbRow['Id'].' ORDER BY Sequence'); 208 while ($DbRow2 = $DbResult2->fetch_assoc())208 while ($DbRow2 = $DbResult2->fetch_assoc()) 209 209 { 210 210 $Track[] = $DbRow2; … … 239 239 'LEFT JOIN User ON User.Id=Passenger.User '. 240 240 'WHERE Passenger.Ride='.$RideId); 241 while ($Passenger = $DbResult->fetch_assoc())241 while ($Passenger = $DbResult->fetch_assoc()) 242 242 { 243 243 $Passengers[] = $Passenger; … … 245 245 do { 246 246 $Check = true; 247 for ($I = $Passenger['SequenceFrom']; $I < $Passenger['SequenceTo']; $I++)247 for ($I = $Passenger['SequenceFrom']; $I < $Passenger['SequenceTo']; $I++) 248 248 { 249 if ($Table[$I][$Seat] != 0) $Check = false;249 if ($Table[$I][$Seat] != 0) $Check = false; 250 250 } 251 251 if (!$Check) $Seat++; 252 } while (!$Check);253 for ($I = $Passenger['SequenceFrom']; $I < $Passenger['SequenceTo']; $I++)252 } while (!$Check); 253 for ($I = $Passenger['SequenceFrom']; $I < $Passenger['SequenceTo']; $I++) 254 254 $Table[$I][$Seat] = count($Passengers) - 1; 255 255 } … … 259 259 $Output .= '<th style="width: 80px">Cestující</th>'; 260 260 $Output .= '</tr>'; 261 foreach ($Track as $Index => $TrackItem)261 foreach ($Track as $Index => $TrackItem) 262 262 { 263 263 $Output .= '<tr><td style="height: 100px">'.$TrackItem['Place'].'<br/>'.$TrackItem['Time'].'</td>'; 264 if ($Index == 0) $Output .= '<td rowspan="'.count($Track).'">Řidič</td>';264 if ($Index == 0) $Output .= '<td rowspan="'.count($Track).'">Řidič</td>'; 265 265 for ($I = 0; $I < $DbRow['SeatCount']; $I++) 266 266 { … … 271 271 } else { 272 272 // Show unused space 273 if (($Index == 0) or ((($Index - 1) >= 0) and (!is_null($Table[$Index - 1][$I]))))273 if (($Index == 0) or ((($Index - 1) >= 0) and (!is_null($Table[$Index - 1][$I])))) 274 274 { 275 275 $J = 1; 276 while ((($Index + $J) < count($Table)) and is_null($Table[$Index + $J][$I])) $J++;276 while ((($Index + $J) < count($Table)) and is_null($Table[$Index + $J][$I])) $J++; 277 277 $Output .= '<td rowspan="'.$J.'"> </td>'; 278 278 } … … 284 284 285 285 286 return ($Output);286 return $Output; 287 287 } 288 288 … … 303 303 } 304 304 } 305 return ($Output);305 return $Output; 306 306 } 307 307 } … … 311 311 function Show() 312 312 { 313 if (array_key_exists('from', $_GET)) $PlaceFrom = $_GET['from'];313 if (array_key_exists('from', $_GET)) $PlaceFrom = $_GET['from']; 314 314 else $PlaceFrom = ''; 315 if (array_key_exists('to', $_GET)) $PlaceTo = $_GET['to'];315 if (array_key_exists('to', $_GET)) $PlaceTo = $_GET['to']; 316 316 else $PlaceTo = ''; 317 if (array_key_exists('time', $_GET)) $Time = $_GET['time'];317 if (array_key_exists('time', $_GET)) $Time = $_GET['time']; 318 318 else $Time = ''; 319 319 $Output = '<table style="width: 100%; margin-top: 100px; margin-bottom: 100px;"><tr><td style="text-align: center">'. … … 325 325 '<input type="submit" value="Hledat"/>'. 326 326 '</form></div></td></tr></table>'; 327 return ($Output);327 return $Output; 328 328 } 329 329 } … … 333 333 function Show() 334 334 { 335 if (array_key_exists('from', $_GET)) $PlaceFrom = $_GET['from'];335 if (array_key_exists('from', $_GET)) $PlaceFrom = $_GET['from']; 336 336 else $PlaceFrom = ''; 337 if (array_key_exists('to', $_GET)) $PlaceTo = $_GET['to'];337 if (array_key_exists('to', $_GET)) $PlaceTo = $_GET['to']; 338 338 else $PlaceTo = ''; 339 if (array_key_exists('time', $_GET)) $Time = $_GET['time'];339 if (array_key_exists('time', $_GET)) $Time = $_GET['time']; 340 340 else $Time = ''; 341 341 $Output = '<table style="width: 100%"><tr><td style="text-align: center;">'. … … 349 349 $Output .= $this->ShowRides($_GET['from'], $_GET['to']); 350 350 } else $Output .= $this->ShowRides('', ''); 351 return ($Output);351 return $Output; 352 352 } 353 353 … … 358 358 $Query = 'SELECT Ride.Id, Ride.SeatCount, User.Name AS DriverName, User.BirthDate, '. 359 359 'CONCAT(CarManufacturer.Name, " ", CarModel.Name) AS CarName '; 360 if ((trim($PlaceFrom) != '') and (trim($PlaceTo != '')))360 if ((trim($PlaceFrom) != '') and (trim($PlaceTo != ''))) 361 361 $Query .= ', (SELECT COALESCE(MAX(RideStop.PassengerCount), 0) FROM RideStop '. 362 362 'WHERE (RideStop.Ride=Ride.Id) AND (RideStop.Sequence > RideStopFrom.Sequence) AND '. … … 371 371 'LEFT JOIN CarManufacturer ON CarManufacturer.Id = CarModel.Manufacturer '. 372 372 'LEFT JOIN User ON User.Id=Ride.Driver '; 373 if ((trim($PlaceFrom) != '') and (trim($PlaceTo != '')))373 if ((trim($PlaceFrom) != '') and (trim($PlaceTo != ''))) 374 374 $Query .= 'JOIN RideStop AS RideStopFrom ON (RideStopFrom.Ride = Ride.Id) AND (RideStopFrom.Place LIKE "%'.$PlaceFrom.'%") '. 375 375 'JOIN RideStop AS RideStopTo ON (RideStopTo.Ride = Ride.Id) AND (RideStopTo.Place LIKE "%'.$PlaceTo.'%") '. … … 377 377 $Query .= 'LIMIT 10'; 378 378 $DbResult = $this->Database->query($Query); 379 while ($DbRow = $DbResult->fetch_assoc())379 while ($DbRow = $DbResult->fetch_assoc()) 380 380 { 381 381 $Stops = array(); 382 382 $Price = 0; 383 383 $DbResult2 = $this->Database->query('SELECT * FROM RideStop WHERE Ride='.$DbRow['Id'].' ORDER BY Sequence'); 384 while ($DbRow2 = $DbResult2->fetch_assoc())384 while ($DbRow2 = $DbResult2->fetch_assoc()) 385 385 { 386 386 $Stops[] = $DbRow2['Place']; … … 400 400 $Output .= '</table>'; 401 401 402 return ($Output);402 return $Output; 403 403 } 404 404 } … … 416 416 417 417 $ret = array(); 418 foreach ($bit as $k => $v)419 if ($v > 0)$ret[] = $v . $k;418 foreach ($bit as $k => $v) 419 if ($v > 0)$ret[] = $v . $k; 420 420 421 421 return join(' ', $ret); … … 483 483 'LEFT JOIN CarManufacturer ON CarManufacturer.Id = CarModel.Manufacturer '. 484 484 'WHERE Car.Owner='.$this->System->User->User['Id']); 485 while ($DbRow = $DbResult->fetch_assoc())485 while ($DbRow = $DbResult->fetch_assoc()) 486 486 { 487 487 $Output .= '<option value="'.$DbRow['Id'].'"/>'.$DbRow['ModelName'].'</option>'; … … 500 500 $PricePerKm = 0.8; 501 501 $Output .= '<table class="WideTable"><tr><th>Úsek</th><th>Odjezd</th><th>Trvání</th><th>Vzdálenost [km]</th><th>Cena [Kč]</th></tr>'; 502 foreach ($Track as $Index => $TrackItem)502 foreach ($Track as $Index => $TrackItem) 503 503 { 504 if ($Index > 0)504 if ($Index > 0) 505 505 { 506 506 $Track[$Index]['Time'] = $TimeFrom + $Track[$Index - 1]['Duration']; … … 542 542 )); 543 543 $RideId = $this->Database->insert_id; 544 foreach ($_SESSION['Track'] as $Index => $TrackItem)544 foreach ($_SESSION['Track'] as $Index => $TrackItem) 545 545 { 546 546 $this->Database->insert('RideStop', array( … … 556 556 } 557 557 } 558 return ($Output);559 } 560 } 561 558 return $Output; 559 } 560 } 561
Note:
See TracChangeset
for help on using the changeset viewer.