travelynx/templates/journey.html.ep
2020-09-03 22:27:50 +02:00

274 lines
8.6 KiB
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

% if ($error) {
<div class="row">
<div class="col s12">
<div class="card caution-color">
<div class="card-content white-text">
<span class="card-title">Fehler</span>
<p>Zugfahrt nicht gefunden.</p>
</div>
</div>
</div>
</div>
% }
% else {
<div class="row">
<div class="col s12">
<p>
% if (my $name = stash('username')) {
<b><a href="/p/<%= $name %>"><%= $name %></a></b>s
% }
% if ($journey->{cancelled}) {
Ausgefallene Fahrt
% }
% else {
Fahrt
% }
% if ($journey->{edited} & 0x0020) {
% }
von
<b><%= $journey->{from_name} %></b>
% if ($journey->{edited} & 0x0004) {
% }
nach
<b><%= $journey->{to_name} %></b>
% if ($journey->{edited} & 0x0400) {
% }
am
<b><%= $journey->{sched_departure}->strftime('%d.%m.%Y') %></b>
</p>
% if ($journey->{edited}) {
<p>
Daten wurden manuell eingetragen
</p>
% }
% if ($journey->{cancelled} or ($journey->{rt_arrival} and ($journey->{rt_arrival}->epoch - $journey->{sched_arrival}->epoch) >= 3600)) {
<div style="text-align: center; margin-bottom: 1em;">
% my $form_target = sprintf('/journey/passenger_rights/FGR %s %s %s.pdf', $journey->{sched_departure}->ymd, $journey->{type}, $journey->{no});
%= form_for $form_target => (method => 'POST') => begin
%= csrf_field
%= hidden_field id => $journey->{id}
<button class="btn waves-effect waves-light grey darken-3" type="submit" name="action" value="generate">
<i class="material-icons left">file_download</i>
Fahrgastrechte
</button>
%= end
</div>
% }
<table class="striped">
<tr>
<th scope="row">Zug</th>
<td>
<%= $journey->{type} %> <%= $journey->{no} %>
% if ($journey->{line}) {
(Linie <%= $journey->{line} %>)
% }
</td>
</tr>
<tr>
<th scope="row">Abfahrt</th>
<td>
% if ($journey->{cancelled}) {
<i class="material-icons">cancel</i>
(Plan: <%= $journey->{sched_departure}->strftime('%H:%M'); %>)
% }
% elsif ($journey->{rt_departure} != $journey->{sched_departure}) {
%= $journey->{rt_departure}->strftime('%H:%M');
(<%= sprintf('%+d', ($journey->{rt_departure}->epoch - $journey->{sched_departure}->epoch) / 60) %>,
Plan: <%= $journey->{sched_departure}->strftime('%H:%M'); %>)
% }
% else {
%= $journey->{sched_departure}->strftime('%H:%M');
% }
% if ($journey->{edited} & 0x0003) {
% }
</td>
</tr>
<tr>
<th scope="row">Ankunft</th>
<td>
% if ($journey->{cancelled}) {
<i class="material-icons">cancel</i>
% if ($journey->{sched_arrival}->epoch != 0) {
(Plan: <%= $journey->{sched_arrival}->strftime('%H:%M'); %>)
% }
% }
% elsif ($journey->{rt_arrival}->epoch == 0 and $journey->{sched_arrival}->epoch == 0) {
<i class="material-icons">timer_off</i>
% }
% elsif ($journey->{rt_arrival} != $journey->{sched_arrival}) {
%= $journey->{rt_arrival}->strftime('%H:%M');
(<%= sprintf('%+d', ($journey->{rt_arrival}->epoch - $journey->{sched_arrival}->epoch) / 60) %>,
Plan: <%= $journey->{sched_arrival}->strftime('%H:%M'); %>)
% }
% else {
%= $journey->{sched_arrival}->strftime('%H:%M');
% }
% if ($journey->{edited} & 0x0300) {
% }
</td>
</tr>
<tr>
<th scope="row">Entfernung</th>
<td>
% if ($journey->{skip_route}) {
<i class="material-icons right">location_off</i>
<%= numify_skipped_stations($journey->{skip_route}) %><br/>
% }
% if ($journey->{km_route} > 0.1) {
ca. <%= sprintf('%.f', $journey->{km_route}) %> km
(Luftlinie: <%= sprintf('%.f', $journey->{km_beeline}) %> km)
% }
% else {
?
% }
% if ($journey->{edited} & 0x0010) {
% }
</td>
</tr>
<tr>
<th scope="row">Geschwindigkeit</th>
<td>
% if ($journey->{skip_route}) {
<i class="material-icons right">location_off</i>
<%= numify_skipped_stations($journey->{skip_route}) %><br/>
% }
% if ($journey->{km_route} > 0.1 and $journey->{kmh_route} > 0.01) {
∅ <%= sprintf('%.f', $journey->{kmh_route}) %> km/h
(<%= sprintf('%.f', $journey->{kmh_beeline}) %> km/h)
% if ($journey->{edited} & 0x0303) {
% }
% }
% else {
?
% }
</td>
</tr>
% if ($journey->{messages} and @{$journey->{messages}}) {
<tr>
<th scope="row">Meldungen</th>
<td>
% for my $message (@{$journey->{messages} // []}) {
% my ($ts, $msg) = @{$message};
<%= $ts->strftime('%d.%m.%Y %H:%M') %> : <%= $msg %><br/>
% }
</td>
</tr>
% }
% if ($journey->{user_data} and $journey->{user_data}{comment}) {
<tr>
<th scope="row">Kommentar</th>
<td>
<%= $journey->{user_data}{comment} %>
</td>
</tr>
% }
% if ($journey->{user_data} and $journey->{user_data}{wagongroups} and not exists $journey->{user_data}{wagons}) {
<tr>
<th scope="row">Rollmaterial</th>
<td class="wagons">
%= include '_wagons', wagongroups => $journey->{user_data}{wagongroups};
</td>
</tr>
% }
% elsif ($journey->{user_data} and $journey->{user_data}{wagons}) {
<tr>
<th scope="row">Rollmaterial</th>
<td class="wagons">
% for my $wagongroup (@{$journey->{user_data}{wagongroups} // []}) {
Wagenverbund <%= $wagongroup %><br/>
% }
% for my $wagon (@{$journey->{user_data}{wagons}}) {
<span><%= substr($wagon->{id}, 0, 2) %></span><span><%= substr($wagon->{id}, 2, 2) %></span><span><%= substr($wagon->{id}, 4, 1) %></span><span class="wagonclass"><%= substr($wagon->{id}, 5, 3) %></span><span class="wagonnum"><%= substr($wagon->{id}, 8, 3) %></span><span class="checksum"><%= substr($wagon->{id}, 11) %></span>
%= $wagon->{type}
% if ($wagon->{number}) {
Wagen <%= $wagon->{number} %>
% }
<br/>
% }
</td>
</tr>
% }
<tr>
<th scope="row">Route</th>
<td>
% my $within = 0;
% my $at_startstop = 0;
% for my $station (@{$journey->{route}}) {
% if ($station->[0] eq $journey->{from_name}) {
% $within = 1; $at_startstop = 1;
% }
% elsif ($station->[0] eq $journey->{to_name}) {
% $within = 0; $at_startstop = 1;
% }
% else {
% $at_startstop = 0;
% }
% if ($at_startstop or $within) {
<%= $station->[0] %>
% }
% else {
<span style="color: #808080;"><%= $station->[0] %></span>
% }
% if ($journey->{edited} & 0x0010) {
% }
<br/>
% }
</td>
</tr>
</table>
</div>
</div>
% if (stash('polyline_groups')) {
%= include '_map', station_coordinates => stash('station_coordinates'), polyline_groups => stash('polyline_groups')
% }
% if (not stash('readonly')) {
<div class="row hide-on-small-only">
<div class="col s12 m6 l6 center-align">
<a class="waves-effect waves-light red btn action-delete"
data-id="<%= $journey->{id} %>"
data-checkin="<%= $journey->{checkin}->epoch %>"
data-checkout="<%= $journey->{checkout}->epoch %>">
<i class="material-icons left">delete_forever</i>
Löschen
</a>
</div>
<div class="col s12 m6 l6 center-align">
%= form_for '/journey/edit' => (method => 'POST') => begin
%= hidden_field 'journey_id' => param('journey_id')
<button class="btn waves-effect waves-light" type="submit" name="action" value="edit">
<i class="material-icons left" aria-hidden="true">edit</i>
Bearbeiten
</button>
%= end
</div>
</div>
<div class="row hide-on-med-and-up">
<div class="col s12 m6 l6 center-align">
%= form_for '/journey/edit' => (method => 'POST') => begin
%= hidden_field 'journey_id' => param('journey_id')
<button class="btn waves-effect waves-light" type="submit" name="action" value="edit">
<i class="material-icons left" aria-hidden="true">edit</i>
Bearbeiten
</button>
%= end
</div>
<div class="col s12 m6 l6 center-align" style="margin-top: 1em;">
<a class="waves-effect waves-light red btn action-delete"
data-id="<%= $journey->{id} %>"
data-checkin="<%= $journey->{checkin}->epoch %>"
data-checkout="<%= $journey->{checkout}->epoch %>">
<i class="material-icons left" aria-hidden="true">delete_forever</i>
Löschen
</a>
</div>
</div>
% }
% }