summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2019-09-18 20:21:16 +0200
committerDaniel Friesel <derf@finalrewind.org>2019-09-18 20:21:16 +0200
commit1cb26e205374370809ba6e325e135f20acd69f23 (patch)
tree93789a46a105d058e134dca7b0b206ec0894fe86
parent8e6ee729e0a444f4aaf01d0535862c290bdde311 (diff)
handle substitute connections in passenger rights form
-rw-r--r--lib/Travelynx/Controller/Passengerrights.pm37
-rw-r--r--templates/passengerrights.html.ep6
2 files changed, 38 insertions, 5 deletions
diff --git a/lib/Travelynx/Controller/Passengerrights.pm b/lib/Travelynx/Controller/Passengerrights.pm
index 2e6de96..0170ed5 100644
--- a/lib/Travelynx/Controller/Passengerrights.pm
+++ b/lib/Travelynx/Controller/Passengerrights.pm
@@ -75,6 +75,9 @@ sub mark_substitute_connection {
$journey->{has_substitute} = 1;
$journey->{from_substitute} = $first_substitute;
$journey->{to_substitute} = $last_substitute;
+ $journey->{substitute_delay}
+ = ( $last_substitute->{rt_arrival}->epoch
+ - $journey->{sched_arrival}->epoch ) / 60;
}
}
@@ -177,7 +180,10 @@ sub generate {
= ( $journey->{rt_arrival}->epoch - $journey->{sched_arrival}->epoch )
/ 60;
- if ( $journey->{delay} < 120 ) {
+ if ( $journey->{cancelled} ) {
+ $self->mark_substitute_connection($journey);
+ }
+ elsif ( $journey->{delay} < 120 ) {
my @connections = $self->get_user_travels(
uid => $uid,
after => $journey->{rt_arrival},
@@ -209,7 +215,34 @@ sub generate {
$pdf->fillFormFields( 'S1F7', $journey->{to_name} );
}
- if ( not $journey->{cancelled} ) {
+ if ( $journey->{has_substitute} ) {
+
+ # arived with: TRAIN NO
+ $pdf->fillFormFields( 'S1F13', $journey->{to_substitute}{type} );
+ $pdf->fillFormFields( 'S1F14', $journey->{to_substitute}{no} );
+
+ # arrival YYMMDD
+ $pdf->fillFormFields( 'S1F10',
+ $journey->{to_substitute}{rt_arrival}->strftime('%d') );
+ $pdf->fillFormFields( 'S1F11',
+ $journey->{to_substitute}{rt_arrival}->strftime('%m') );
+ $pdf->fillFormFields( 'S1F12',
+ $journey->{to_substitute}{rt_arrival}->strftime('%y') );
+
+ # arrival HHMM
+ $pdf->fillFormFields( 'S1F15',
+ $journey->{to_substitute}{rt_arrival}->strftime('%H') );
+ $pdf->fillFormFields( 'S1F16',
+ $journey->{to_substitute}{rt_arrival}->strftime('%M') );
+
+ if ( $journey->{from_substitute} != $journey->{to_substitute} ) {
+
+ # last change in:
+ $pdf->fillFormFields( 'S1F24',
+ $journey->{to_substitute}{from_name} );
+ }
+ }
+ elsif ( not $journey->{cancelled} ) {
# arived with: TRAIN NO
if ( $journey->{connection} ) {
diff --git a/templates/passengerrights.html.ep b/templates/passengerrights.html.ep
index c906319..3d5d21d 100644
--- a/templates/passengerrights.html.ep
+++ b/templates/passengerrights.html.ep
@@ -42,12 +42,12 @@
</a></td>
<td>
% if ($journey->{cancelled}) {
- Ausfall
% if ($journey->{has_substitute}) {
- (Ersatzverbindung)
+ Ausfall, Ersatzverbindung
+ %= sprintf('%+d', $journey->{substitute_delay})
% }
% else {
- ohne Ersatzverbindung
+ Ausfall ohne Ersatzverbindung
% }
% }
% elsif ($journey->{connection}) {