From d0b22a371bdd4e8f09df8ba63c6206208c244c86 Mon Sep 17 00:00:00 2001
From: Jacek Kowalski <Jacek@jacekk.info>
Date: Sun, 30 Jun 2019 21:26:41 +0000
Subject: [PATCH] Use Composer's PSR-0 autoloader

---
 lib/output.php |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/lib/output.php b/lib/output.php
index 4d05b40..fe7b73e 100644
--- a/lib/output.php
+++ b/lib/output.php
@@ -18,11 +18,15 @@
 
 function createVehiclesList($trips, $mapping, $saveConfig = FALSE) {
 	$lines = [];
+	$vehicles = [];
 	foreach($trips as $trip) {
+		$vehicle = $mapping[$trip['id']] ?? [];
+		$vehicle += ['trip' => $trip['id']];
 		$lines[$trip['line']][] = [
 			'trip' => $trip,
-			'vehicle' => $mapping[$trip['id']] ?? [],
+			'vehicle' => $vehicle,
 		];
+		$vehicles[$vehicle['type'] ?? '?'][] = $vehicle;
 	}
 	foreach($lines as &$line) {
 		usort($line, function($a, $b) {
@@ -31,6 +35,13 @@
 	}
 	unset($line);
 	ksort($lines);
+	foreach($vehicles as &$vehicle) {
+		usort($vehicle, function($a, $b) {
+			return (substr($a['num'] ?? '', 2) <=> substr($b['num'] ?? '', 2));
+		});
+	}
+	unset($vehicle);
+	ksort($vehicles);
 	
 	if($saveConfig) {
 		$twigLoader = new \Twig\Loader\FilesystemLoader(__DIR__.'/../templates');
@@ -38,6 +49,7 @@
 		
 		$vehiclesHtml = $twig->render('vehicles.html', [
 			'lines' => $lines,
+			'vehicles' => $vehicles,
 			'prefix' => $saveConfig['prefix'],
 		]);
 		if(!file_put_contents($saveConfig['result_vehicles_temp'], $vehiclesHtml)) {

--
Gitblit v1.9.1