summaryrefslogtreecommitdiff
path: root/lib/Travelynx
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Travelynx')
-rw-r--r--lib/Travelynx/Command/work.pm39
-rwxr-xr-xlib/Travelynx/Controller/Traveling.pm4
2 files changed, 42 insertions, 1 deletions
diff --git a/lib/Travelynx/Command/work.pm b/lib/Travelynx/Command/work.pm
index 04ea95b..04dbd2d 100644
--- a/lib/Travelynx/Command/work.pm
+++ b/lib/Travelynx/Command/work.pm
@@ -70,7 +70,44 @@ sub run {
train_no => $train->train_no
}
);
- $self->app->add_route_timestamps( $uid, $train, 1 );
+ if ( $train->departure_is_cancelled and $arr ) {
+
+ # depending on the amount of users in transit, some time may
+ # have passed between fetching $entry from the database and
+ # now. Ensure that the user is still checked into this train
+ # before calling checkout to mark the cancellation.
+ if (
+ $db->select(
+ 'in_transit',
+ 'count(*) as count',
+ {
+ user_id => $uid,
+ train_no => $train->train_no,
+ checkin_station_id => $dep
+ }
+ )->hash->{count}
+ )
+ {
+ $db->update(
+ 'in_transit',
+ {
+ cancelled => 1,
+ },
+ {
+ user_id => $uid,
+ train_no => $train->train_no,
+ checkin_station_id => $dep
+ }
+ );
+
+ # check out (adds a cancelled journey and resets journey state
+ # to checkin
+ $self->app->checkout( $arr, 1, $uid );
+ }
+ }
+ else {
+ $self->app->add_route_timestamps( $uid, $train, 1 );
+ }
}
};
if ($@) {
diff --git a/lib/Travelynx/Controller/Traveling.pm b/lib/Travelynx/Controller/Traveling.pm
index 7a9ab9e..59466f3 100755
--- a/lib/Travelynx/Controller/Traveling.pm
+++ b/lib/Travelynx/Controller/Traveling.pm
@@ -133,6 +133,10 @@ sub status_card {
if ( $status->{checked_in} ) {
$self->render( '_checked_in', journey => $status );
}
+ elsif ( $status->{cancellation} ) {
+ $self->render( '_cancelled_departure',
+ journey => $status->{cancellation} );
+ }
else {
$self->render( '_checked_out', journey => $status );
}