From e0a2b9aa266e0e42d9224eff3839b1875b211218 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Thu, 19 Dec 2019 20:16:10 +0100 Subject: [PATCH] save all the wagon orders we can get --- lib/Travelynx.pm | 25 ++++++++++++++----------- templates/journey.html.ep | 20 +++++++++++++++++++- 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/lib/Travelynx.pm b/lib/Travelynx.pm index f4c974c..f1ae8dc 100755 --- a/lib/Travelynx.pm +++ b/lib/Travelynx.pm @@ -2192,7 +2192,6 @@ sub startup { if ($is_departure) { $data->{wagonorder_dep} = $wagonorder; - $user_data->{wagons} = []; if ( exists $user_data->{wagongroups} ) { $user_data->{wagongroups} = []; } @@ -2203,11 +2202,12 @@ sub startup { } ) { + my @wagons; for my $wagon ( @{ $group->{allFahrzeug} // [] } ) { push( - @{ $user_data->{wagons} }, + @wagons, { id => $wagon->{fahrzeugnummer}, number => @@ -2216,15 +2216,18 @@ sub startup { } ); } - if ( $group->{fahrzeuggruppebezeichnung} - and $group->{fahrzeuggruppebezeichnung} - =~ m{ ^ ICE }x ) - { - push( - @{ $user_data->{wagongroups} }, - $group->{fahrzeuggruppebezeichnung} - ); - } + push( + @{ $user_data->{wagongroups} }, + { + name => + $group->{fahrzeuggruppebezeichnung}, + from => + $group->{startbetriebsstellename}, + to => $group->{zielbetriebsstellename}, + no => $group->{verkehrlichezugnummer}, + wagons => [@wagons], + } + ); } $db->update( 'in_transit', diff --git a/templates/journey.html.ep b/templates/journey.html.ep index 976dc4d..396bc4e 100644 --- a/templates/journey.html.ep +++ b/templates/journey.html.ep @@ -188,7 +188,25 @@ % } - % if ($journey->{user_data} and $journey->{user_data}{wagons}) { + % if ($journey->{user_data} and $journey->{user_data}{wagongroups} and not exists $journey->{user_data}{wagons}) { + + Rollmaterial + + % for my $wagongroup (@{$journey->{user_data}{wagongroups} // []}) { + Wagenverbund <%= $wagongroup->{name} %> von <%= $wagongroup->{from} %> nach <%= $wagongroup->{to} %> als <%= $journey->{type} %> <%= $wagongroup->{no} %>
+ % for my $wagon (@{$wagongroup->{wagons}}) { + <%= substr($wagon->{id}, 0, 2) %><%= substr($wagon->{id}, 2, 2) %><%= substr($wagon->{id}, 4, 1) %><%= substr($wagon->{id}, 5, 3) %><%= substr($wagon->{id}, 8, 3) %><%= substr($wagon->{id}, 11) %> + %= $wagon->{type} + % if ($wagon->{number}) { + – Wagen <%= $wagon->{number} %> + % } +
+ % } + % } + + + % } + % elsif ($journey->{user_data} and $journey->{user_data}{wagons}) { Rollmaterial