Add table of vehicles by type
| | |
| | | |
| | | 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) { |
| | |
| | | } |
| | | unset($line); |
| | | ksort($lines); |
| | | ksort($vehicles); |
| | | |
| | | if($saveConfig) { |
| | | $twigLoader = new \Twig\Loader\FilesystemLoader(__DIR__.'/../templates'); |
| | |
| | | |
| | | $vehiclesHtml = $twig->render('vehicles.html', [ |
| | | 'lines' => $lines, |
| | | 'vehicles' => $vehicles, |
| | | 'prefix' => $saveConfig['prefix'], |
| | | ]); |
| | | if(!file_put_contents($saveConfig['result_vehicles_temp'], $vehiclesHtml)) { |
| | |
| | | table { |
| | | border-collapse: collapse; |
| | | border-spacing: 0; |
| | | margin: 10px 0; |
| | | } |
| | | caption { |
| | | text-align: left; |
| | | font-size: 120%; |
| | | } |
| | | th, td { |
| | | border: 1px solid black; |
| | |
| | | } |
| | | td { |
| | | vertical-align: top; |
| | | } |
| | | table.center td { |
| | | text-align: center; |
| | | } |
| | | a { |
| | |
| | | } |
| | | </style> |
| | | |
| | | <table> |
| | | |
| | | <table class="center"> |
| | | <caption>Vehicles by line</caption> |
| | | <thead> |
| | | <tr> |
| | | {% for line in lines|keys %} |
| | |
| | | {% endfor %} |
| | | </tr> |
| | | </thead> |
| | | |
| | | <tbody> |
| | | <tr> |
| | | {% for trips in lines %} |
| | | <td> |
| | | {% for trip in trips %} |
| | | <a href="https://mpk.jacekk.net/map.html#!{{ prefix }}{{ trip.trip.id | e }}" class="low{{ trip.vehicle.low | default }}"> |
| | | <a href="https://mpk.jacekk.net/map.html#!{{ prefix }}{{ trip.vehicle.trip | e }}" class="low{{ trip.vehicle.low | default }}"> |
| | | {{ trip.vehicle.num | default('<?>') | e }}<br /> |
| | | </a> |
| | | {% endfor %} |
| | |
| | | {% endfor %} |
| | | </tr> |
| | | </tbody> |
| | | </table> |
| | | |
| | | <table> |
| | | <caption>Vehicles by type</caption> |
| | | {% for type, vhcls in vehicles %} |
| | | <tr> |
| | | <th>{{ type }}</th> |
| | | <td>{{ vhcls | length }}</td> |
| | | <td> |
| | | {% for vehicle in vhcls %} |
| | | <a href="https://mpk.jacekk.net/map.html#!{{ prefix }}{{ vehicle.trip | e }}" class="low{{ vehicle.low | default }}"> |
| | | {{ vehicle.num | default('<?>') | e }} |
| | | </a> |
| | | {% endfor %} |
| | | </td> |
| | | </tr> |
| | | {% endfor %} |
| | | </table> |
| | | |
| | | Generated at {{ "now" | date("Y-m-d H:i:s P") }} |
| | | |